How hard would it be code-wise...


Questions, Explanations, Howtos

Crypt Cleanser

Posts: 714

Joined: Saturday, 5th December 2015, 06:56

Post Sunday, 29th May 2016, 18:27

How hard would it be code-wise...

To make crawl real-time instead of turn-based?

Like, make each monster move/attack a few times a second based on its speed, regardless of what the player is doing.

Ziggurat Zagger

Posts: 5809

Joined: Tuesday, 30th October 2012, 19:06

Post Wednesday, 1st June 2016, 07:38

Re: How hard would it be code-wise...

Well, there's a few challenges here, crawl action time is really weird, and also *player* actions take varying amount of time.

You'd have to first of all decide:

1. What does it mean if a player does a fast action vs a slow one, does the game prevent you from taking your next action until an appropriate amount of time has passed (What does auto explore do, just click away slowly, are you forced to wait, or does the game speed up with fast player input?)

2. How much time *does* pass per "tick" of inactivity, is it 1.0 Auts? Some other value?

Once you'd decided that, then it'd require you put some sort of timing/event handler or something (there's lots of choices here) that would spin up and run through crawl's main "tick" function every so often, (also possibly another one to unlock the player from taking his next action, if you were going that route, and potentially disconnect the player's action from the firing of the main event loop, again depending on how you were designing it.

Now all of that presumes that you want to preserve crawl's odd step-wise simulation of time, which approximately goes like this:
  Code:
Player takes an action that takes X time,
add X to all the monster's action energy queues,
loop through all the monsters, for each one, if energy is greater than their speed, subtract their speed, take an action, add them to the end of the cycle of things looped through

So of course this means that monsters can get multiple actions *all at the same time* on each heartbeat, which is fine for a turn-based game (what else is it going to do) but is somewhat weird when you throw timing into the loop.

So then if you want to make it more-correctly have monsters take actions *at an appropriate time* instead of all in a chunk between player actions, then you have to construct that action queue very very differently, which either involves a whole large complicated structure to track all the possible waits for all the times that the next thing would fire up and act, or (much more simply, although causing a lot more overhead) a much faster heartbeat that simply checked what needed doing over and over again at frequent intervals.

Overall, it'd probably take me, personally, half a day to a day to do something like that and get it working to my satisfaction, given that I wanted to do so and had a clear idea of which thing it was that I wanted to do, and I had sufficient motivation to do it.
Spoiler: show
This high quality signature has been hidden for your protection. To unlock it's secret, send 3 easy payments of $9.99 to me, by way of your nearest theta band or ley line. Complete your transmission by midnight tonight for a special free gift!

Blades Runner

Posts: 536

Joined: Friday, 1st April 2016, 18:15

Post Friday, 22nd July 2016, 21:34

Re: How hard would it be code-wise...

...it took me half a day to figure out how the code worked.

You are truly a god.
twelwe wrote:It's like Blink, but you end up drowning.

Return to Coding

Who is online

Users browsing this forum: No registered users and 1 guest

Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group.
Designed by ST Software for PTF.