Announcement: Be excellent to each other.


Caravel Forum : DROD Boards : Bugs : Wait command behaves strangely with speed potions (Okay I don't mean to be mister bug report lately, but here's another one that just doesn't seem right.)
New Topic New Poll Post Reply
Poster Message
Insoluble
Level: Smitemaster
Avatar
Rank Points: 1638
Registered: 09-04-2014
IP: Logged

File: Wait command and speed potions.hold (1.4 KB)
Downloaded 37 times.
License: Public Domain
icon Wait command behaves strangely with speed potions (+2)  
The "Wait" command in the room editor does not seem to behave consistently when speed potions are in use. This is the command that takes a number of turns as it's argument and has the script wait that many turns. The problem is, it can't make up its mind as to what a turn is when Bethro is under the influence of speed potions.

When speeded, if you wait 1 turn(s), the script will wait 1 turn on the threat clock clock (one game turn) which is equivalent to two player turns (i.e. you can input two moves).

If however you wait 10 turn(s), the script will wait 10 player turns (or 5 turns on the threat clock.) I also tested this with 20 and 30 and the same thing happens.

This seems incredibly inconsistent. If you are confused as to what I'm talking about please download the attached hold in which I've scripted two characters to wait (one in increments of 1 turn, the other in increments of 10) and report on their progress. If you don't take the speed potion they sync up nicely. If you do take the speed potion things go crazy.

I apologize if this has been previously reported. I tried to search but did not see it.

____________________________
Links to neat forum tools that I always have trouble finding:
Click here to view the secret text


[Last edited by Insoluble at 02-13-2015 08:11 AM]
02-13-2015 at 08:10 AM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
skell
Level: Legendary Smitemaster
Avatar
Rank Points: 3734
Registered: 12-28-2004
IP: Logged

File: Wait Speed Potion Bug.hold (1.3 KB)
Downloaded 38 times.
License: Public Domain
icon Re: Wait command behaves strangely with speed potions (+11)  
I am afraid it is consistent and works correctly even though it seems completely weird. To understand why this is happening you need to know how the character script execution works.

Basically, when a script is running, the executor goes command by command and executes it. Some commands stop the executor (move* commands) until the next command and some do not (no-move). In normal player speed that's how it works.

The problem starts when you speed the player up - now on each half turn the script executor is ran BUT ONLY only for no-move commands. Wait is kinda peculiar command, because it is at the same a move command (executor stops when it encounters this command and the counter only starts counting on full turns, which is why Wait 0 and 1 results in simply a pause until next turn, usually**) and no-move command (because the timer ticks even on half turns). I have attached a hold where the characters speak and move after the wait command ends and you may notice that...

...If you step from full turn onto half turn:

- First character with no wait command speaks immediately after you step at the starting square
- Second character with Wait 0 speaks 1 HT**** after start
- Third character with Wait 1 speaks 2 HTs after start
- Fourth character with Wait 2 speaks 3 HTs after start
- Etc

But if you step from half turn onto full turn:


- First character with no wait command speaks immediately after you step at the starting square
- Second character with Wait 0 speaks 1 half-turn after start
- Third character with Wait 1 speaks 1 HTs after start
- Fourth character with Wait 2 speaks 2 HTs after start
- Etc

But it looks different for moving. If you start by stepping on the start tile from full turn onto half turn:

- First character (no wait) moves 1 HT after you start, because during half turn execution move commands cannot be executed
- Second character (Wait 0) moves 1 HT after you start, because after start executor encountered Wait 0 and stopped execution. On the next HT (which is full turn) it moved past Wait and executed move command
- Third character (Wait 1) moves 3 HT after you start, after start executor encountered Wait 1 but it could do nothing**, so it will to process Wait 1 again next turn. Next HT is a full turn, Wait is executed and goes down from 1 to 0***. Next HT is half turn, executor goes to the next command and stops on Move becausse you can't execute move commands on half turns. Next HT is full turn, character moves.
- Fourth character (Wait 2) moves 3 HT after start. Next HT=Full, Wait 2 to 1. Next HT=Half, Wait 1 to 0. Next HT=Full do Move.
- Fifth and Sixth will move 5 HT after start.

If you step on the start tile from half turn onto full turn:

- First character (no wait) moves immediately, because it's a full turn and you can execute move commands.
- Second character (0 wait) moves 2 HT after start, on the turn you enter it encounters Wait 0 and stops execution**. Next HT=half, wait for full turn to execute Move. Next HT=Full, execute Move.
- Third character (1 wait) moves 2 HT after start, Wait 1 to 0. Next HT=half, can't execute Move on half turn. Next HT=Full, execute move.
- Fourth character (2 wait) moves 2 HT after start, Wait 2 to 1. Next HT=half, wait 1 to 0. Next HT=Full, execute Move
- Fifth character (3 wait) moves 4 HT after start, Wait 3 to 2. Next HT=half, wait 2 to 1. Next HT=Full wait 1 to 0. Next HT=Half, can't execute Move. Next HT=Full, execute Move
- Sixth moves after 4 HT.
- 7th and 8th moves after 6 HT.

It's surprisingly complicated for such a simple thing, but I hope my explanation is sufficient, but just in case a summary of all facts:
- On half turn Characters can only execute No-move commands
- Wait starts counting down only on Full Turns, but counts down each turn (be it full or half)
- Wait 0 is an exception, it starts counting even on half turns. Wait 0 should be named "Interrupt script execution until next turn".
- When wait starts counting, next command will execute on Nth turn after the current one, so 1 will continue with following command on next turn, 2 on next next turn, 3 on next next next turn


--- Footnotes:

*Move and No-move are just names I am using to reference these two types of commands, not actual Move command.
**Wait 0 is equal to "stop executing script now, continue next turn" wherein Wait 1 or more is "Stop executing script now and continue after N-1 turns, provided we are also executing move commands now, if we are only executing no-move commands stop execution and try this command again next turn". The difference is noticeable on half turns when speeded or on 0th turn, the one happening when entering a room.
***When Wait 1+ command executes a Waiter variable is set to N-1. Each turn, if waiter is > 0, waiter is reduced by one. So Wait 1, when encountered, stops execution and... sets waiter to 0.
****HT is = 1 player turn when sped up

____________________________
My website | Facebook | Twitter

[Last edited by skell at 02-13-2015 09:18 PM]
02-13-2015 at 09:13 PM
View Profile Send Private Message to User Send Email to User Visit Homepage Show all user's posts High Scores This architect's holds Quote Reply
Insoluble
Level: Smitemaster
Avatar
Rank Points: 1638
Registered: 09-04-2014
IP: Logged
icon Re: Wait command behaves strangely with speed potions (+3)  
Okay, I think I understand a lot better now. Thanks for the awesome rundown on how the editor works! Here, have basically all my mod points.

____________________________
Links to neat forum tools that I always have trouble finding:
Click here to view the secret text


[Last edited by Insoluble at 02-13-2015 09:27 PM]
02-13-2015 at 09:27 PM
View Profile Send Private Message to User Send Email to User Show all user's posts This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD Boards : Bugs : Wait command behaves strangely with speed potions (Okay I don't mean to be mister bug report lately, but here's another one that just doesn't seem right.)
Surf To:


Forum Rules:
Can I post a new topic? No
Can I reply? No
Can I read? Yes
HTML Enabled? No
UBBC Enabled? Yes
Words Filter Enable? No

Contact Us | CaravelGames.com

Powered by: tForum tForumHacks Edition b0.98.8
Originally created by Toan Huynh (Copyright © 2000)
Enhanced by the tForumHacks team and the Caravel team.