Turn-based pathfinding

0 favourites
  • 1 posts
From the Asset Store
A well commented RPG game template to learn from or use as a base for your own game!
  • Hello Constructors!

    Since I'm new in your community, let me introduce myself - I'm a Hungarian game designer (previously I've been working on Theocracy, Panzers, the Flash adventure Morningstar and a few smaller titles), recently trying to make a few small games on my own. I've been playing around with Stencyl but after a year the limitations of the 2.1 version and the instabilities of the 3.0 beta freaked me out so I decided to take a look at Construct 2 - and I really like it so far. Now I'm working on my first C2 platformer.

    But in the meanwhile I've been thinking what I'd like to do next and something came to my mind - a turn-based and tile-based tactics game. I think it could be done - C2 has almost all the necessary modules - I'm just not quite sure how.

    Imagine a gameplay like X-Com, Jagged Alliance or Advance Wars - an ortographic tile-based board that has your own units and AI-controlled enemy units. Your turn/enemy turn is basically a global boolean. In your turn, you can select a unit, move it to a given tile (with the Pathfinding behav) and when an enemy is within range/line of sight you can shoot it. With each tile walked or bullets shot the unit loses an action point and when it's out of APs it can't be used until the next turn. The enemy AI is just that simple: it goes towards your nearest unit (with Pathfinding), then when it's in range it switches to the Turret behav and shoots it until it's out of APs. After each unit movement the game regenerates the obstacle map so the units don't walk over each other - yes, it's CPU intensive but since the game is turn-based it doesn't matter much.

    Now what we'd need for all of this to work is get a bit deeper into the Pathfinding behav and extract the "movement cost" associated with each tile. This way when you select a friendly unit that has 8 APs, the game could highlight all the tiles having a movement cost of 8 or less so you can see how far you can move. The other thing we'd need is to remove an AP each time a new tile is entered. Simple as it may sound, I didn't find a definite solution to this. I've been thinking about counting the pathfinding nodes reached but the game doesn't put a node to every single tile (could it be changed?) I also thought I count the time, e.g. if the unit is moving with an 1 tile/sec speed I subtract an AP in every 1 second, but it works only if I don't use diagonal movement (since this way that would cost "2 square rooted" AP), and it sounds like a terribly stupid workaround anyways.

    Does anyone has any idea? Any help would be greatly appreciated.

    Best regards and keep up the good work!


  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)