ondras / rot.js

ROguelike Toolkit in JavaScript. Cool dungeon-related stuff, interactive manual, documentation, tests!
https://ondras.github.io/rot.js/hp/
BSD 3-Clause "New" or "Revised" License
2.33k stars 254 forks source link

Unshift in Scheduler #159

Open st33d opened 5 years ago

st33d commented 5 years ago

The Scheduler as is can only push entities to its stack. If I want to change the order of entities acting then I am forced to hack this into the engine. I can’t just modify the speed - if I want a new entity to act first then I have to push a silent turn on all other entities to get there, which is a bigger hack than modifying ROT.js. I needed this hack for player summoned entities that copy the player’s moves - they must act before the monsters, because the player will assume they follow the same rules as themselves.

My hack of ROT.js is used in my game No’hanz: https://st33d.itch.io/nohanz

I’ve used an old version of ROT.js as I was building on top of an engine of mine from 2015 and didn’t want to deal with any changes that would be easy to miss. I’ve basically duplicated the Event scheduler stack push and rewritten it to an unshift, then I’ve repeated that operation down to the Speed Scheduler which was all I needed.

Being able to request and load arrays of entities would also be useful for games that do some hacking with turn order.

ondras commented 5 years ago

It looks like the behavior depends on the scheduler type:

I assume you would like this functionality for the Speed scheduler, right?