How do I create turn based AI that follows the player?

Get help using Construct 2

Post » Sun Sep 18, 2016 4:09 am

I am trying to make a rouge-like game where the enemies follow the player 1 space at a time. I am using the moveto plugin to move the sprites. The best example I have found of this is a rouge-like called Cardinal quest (http://www.kongregate.com/games/randomn ... al-quest-2). I have tried many methods of re-creating this with no luck. Could anyone give me some pointers on how to re-create the Cardinal Quest enemy AI?
B
34
S
21
G
11
Posts: 9
Reputation: 8,576

Post » Sun Sep 18, 2016 2:51 pm

Probably use line of sight to detect if player is in range of enemy. Then they seem to move when you move so have so have them move towards the player by a certain number of pixels on player movement. You'll need loads of detection though for what spaces are free on the level to move to, you could have a detection sprite around each charac to check for overlaps with walls and then pick a free square to move to each time. The enemies move in exactly the same way as the player right? So once you have the player moving as you want, it would just be the same movement. Also check for if player is colliding with enemy then once this happens you can enable the sub-battle system.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Mon Sep 19, 2016 3:02 am

I developed an AI that works really well (except I haven't added in collisions yet). However, I have run into a roadblock that I can't get past. (Download the capx so the explanation below will make sense. https://drive.google.com/file/d/0B0u-LjouEgnXVWI5ODl6NXVrWkE/view?usp=sharing) In my AI I used 4 squares that surround each enemy (the enemy and 4 squares are a container). These are named after their orientation around the enemy and always remain in the same spot with an every tick event. When there is one enemy on the layout the player moves, then the enemy finds which of the 4 squares is closest to the player. The enemy then moves to the square that is closest. However with 2 enemies on the screen it doesn't work. The enemy furthest away travels towards the closest enemy. What I Want: I want the 2 enemies to act independently of each other. The 1st enemy will find which of its 4 squares is closest to the player and move to it. The 2nd enemy will find which of its 4 squares is and move to it. Sorry for the long explanation, but I would greatly appreciate the help.
B
34
S
21
G
11
Posts: 9
Reputation: 8,576

Post » Mon Sep 19, 2016 9:33 am

Because of the way you've set this up it's always picking the closest movement square on screen to the player regardless of which enemy it's next to. You'll have to do some checks for each enemy pick the closest movement square to the enemy that is also the closest to the player.
B
46
S
16
G
74
Posts: 2,089
Reputation: 44,187

Post » Mon Sep 19, 2016 8:32 pm

How would I go about doing that exactly? I have tried using UIDs and grouping objects together by distance but I just can't seem to get it to work.
B
34
S
21
G
11
Posts: 9
Reputation: 8,576


Return to How do I....?

Who is online

Users browsing this forum: Lordshiva1948 and 62 guests