ID:1706310
 
Keywords: like, movement, rouge
(See the best response by Kaiochao.)
Hey guys I'm wondering how I would be able to make a simple rougelike game and I can't seem to wrap my head around simulating that type of movement, I'd like everything to move when the player moves or performs an action otherwise its paused. Thanks in advanced for your help :)

bloodocean7
Best response
Simply put, player movement controls time, right?

What processes are time-dependent?

AI?

So, for AI, instead of having a loop like this:
AI
infinite loop:
sleep some time
ponder existence


You set it up like this:
AI
when a player moves:
ponder existence


Surely you know of a couple built-in procs you could override to handle "when a player moves", and broadcasting that message to the relevant AI (like, for each NPC nearby).
This is starting to clear it up for me thank you, I'm on my phone so I can't really post examples of code I would use for critque at the moment lol but perhaps you could elaborate a bit more? I see what you mean but still am unsure how to accomplish this without a mess lol

thanks for the quick reply :)
mob
proc
// Players call this whenever they do something.
// NPCs have this called by players.
Act()

npc
// When it's the NPC's turn to act,
Act()
// step towards a player nearby
for(var/mob/player/p in ohearers(src))
step_towards(src, p)
break

player
// Whenever the player moves successfully, it has acted
Move()
. = ..()
if(.)
Act()

// When the player has acted,
Act()
// Notify every nearby NPC
for(var/mob/npc/npc in ohearers(src))
npc.Act()

verb
// A verb to stand still for a turn
wait()
Act()

// A verb to use up a turn by doing a thing
fart()
hearers() << "[src] farted"
Act()