How do I calcul weapon distance with Dijkstra pathfinding?

0 favourites
  • 2 posts
From the Asset Store
Futuristics Weapons Vol 1 includes 8 different weapons, in a total of 216 sounds
  • Hello!

    This one will probably be tought.

    A few months ago, oosyrag sent me an example of a Dijkstra algorithm to calculate path for instance and the shortest path in a tactical.

    (CF : construct.net/en/forum/construct-3/how-do-i-8/create-distance-tile-164973 and the c3P example : dropbox.com/s/v56jw51ktwd70mj/bfsfloodfillexample.c3p

    I managed to reuse and understand this system for my game, thanks again to him it was really nice, but today I'm stuck on the possibility to add more distances, calculate on weapon the hero is using.

    Here is an example of the current in-game rendering of my game:

    The blue boxes represent the movements, and the red boxes the range of the weapon (2 cases).

    The problem is that the hero is supposed to be able to attack even in an inaccessible area, and there are supposed to be red squares on the left side of the mountain, like this:

    But I have no idea how to handle this, I tried several things without success.

    I'm coming to you with the hope that someone has an idea how to do this in a simple way, but maybe it's impossible and I should revise my whole system?

    I hope that I have been clear in my explanations, and I thank you for reading me.

    Edit : Just editing cause maybe it's not clear about why character should be able to attack on "forbiden" tile.

    Two possibilities, some ennemis can fly and walk on colide tiles, or, like in Fire Emblem, archer can attack even if there is a wall between character, like this :

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Try differentiate between movement area and weapon range. Melee weapon should behave similarly to unit movement plus with it's extended reach. Ranged weapon should just able to cover any terrain within range.

    See at my example; dropbox.com/s/mcd4qp16mp07lce/path_orient3.capx

    There is a square overlay with tiny opacity when something blocked unit way.

    I didn't remove them as a visual cue for what full range looks like. So my method is define unit range then do flood-fill for possible movement area.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)