Enemy movement in Rougelikes?

Make games! Discuss those games here.

Moderators: Bob the Hamster, marionline, SDHawk

Post Reply
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Enemy movement in Rougelikes?

Post by sheamkennedy »

I have been more and more interested with rougelikes lately and was wondering how movement can be performed in a step-by-step sort of way? I believe I played an OHRRPGCE rougelike a while back and it had this sort of movement where every time the player takes a step or action, all the monsters also take a step or action.

I assume this is somehow carried out with an eachstep script. Mainly what I am looking for is a solution that allows me to use OHRRPGCE's built-in movement types (chase, avoid, wander, etc...) but in a step by step manner.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
User avatar
kylekrack
Liquid Metal Slime
Posts: 1240
Joined: Mon Jun 16, 2014 8:58 am
Location: USA
Contact:

Post by kylekrack »

Ok, so I don't know how well this would work, but I'll try to explain it as concisely as I can.

I think you could suspend the player and override the movement with a keypress script. Then have an each-step script call "suspend NPCs" to effectively pause their movement. Each time the player moves, resume NPCs for a tick or something to allow them to move one space, then suspend them again. I don't have any idea how well that would work, but it's the only thing I can think of without writing your own pathing and AI.
My pronouns are they/them
Ps. I love my wife
TMC
Metal King Slime
Posts: 4308
Joined: Sun Apr 10, 2011 9:19 am

Post by TMC »

Don't use an each-step script, that triggers at the end of a movement. Instead use an on-keypress script.
You could suspend all npcs, and then resume them for just one tick whenever the player takes a step. If you use "hero is moving" then there'll be a one tick delay between when the hero starts moving and when the npcs do. That might be acceptable, or might cause problems. You can use the hero will move script to avoid it.
Note that the 'wander' npc move type has only a 1/4 chance each tick to start a step if it's not already moving. Which might be too infrequently. Well, it's a pretty short script to script the wander AI yourself.

Edit: kylekrack beat me to it. But I don't see any reason to suspend the player.
Last edited by TMC on Wed Jan 25, 2017 7:19 am, edited 1 time in total.
User avatar
sheamkennedy
Liquid Metal Slime
Posts: 1110
Joined: Mon Sep 16, 2013 9:29 pm
Location: Tama-shi, Tokyo, Japan
Contact:

Post by sheamkennedy »

Thanks I should be able to sort things out from here. Also I just noticed I posted this in the wrong section. I should really get some rest haha.
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
� C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases
Post Reply