Announcement: Be excellent to each other.


Caravel Forum : DROD RPG Boards : RPG Bugs : Global script that damages each turn damages twice on 2nd turn
New Topic New Poll Post Reply
Poster Message
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged

File: Damage Test.drh (848 bytes)
Downloaded 29 times.
License: Public Domain
icon Global script that damages each turn damages twice on 2nd turn (+2)  
See attached hold.

A global character script that simply deals damage to the player each turn deals two lots of damage on the second turn.

I checked the last non-alpha release and this happens there too, so none of the recent changes have caused this.

Worth noting that this only happens if the character is set to be a global script via the Imperative command in its default script. A regular character script functions as expected, with no second set of damage.

[Last edited by kieranmillar at 10-01-2020 08:53 PM]
10-01-2020 at 08:51 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Global script that damages each turn damages twice on 2nd turn (+1)  
Thanks, Kieran. :)

I've identified two issues here:

1. On room entrance (in CCurrentGame::SetMembersAfterRoomLoad), first global scripts are processed, and then monsters in the room are pre-processed. This is fine, but any NPCs processed here that execute "Imperative Make Script Global" were not actually getting moved over to the global scripts list at this point. It doesn't happen until after the first move is made in the room, which is incorrect. Fixing this oversight corrects the issue you've noted.

2. However! If you add a "Wait 0" to the top of your default script, the issue resurfaces (same as before). This gets to the root cause of the issue you noted: each turn, first the monsters are processed, and then global scripts are processed. Note this is in the opposite order from the order of global-then-room on room entrance noted in (1) above. So, when an NPC is made global, it gets to run in the monster list, and then it runs again on the same turn in the global scripts list. This second iteration of processing shouldn't happen on the same turn.

Please let me know if I've lost you with my explanation yet.

My thoughts at this point:

First, it's somewhat unfortunate that entities are processed in an inconsistent order across (1) and (2). I can see reasons for doing both, and we probably don't want to change any ordering at this point.

To fix the issue you reported, I'm adding code to ensure NPCs that run "in room" don't process their scripts again as a global script on the same turn. Can't think of a more elegant solution for this while leaving global/in-room processing ordering as-is.

Feel free to share your thoughts.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 10-26-2020 11:05 PM]
10-26-2020 at 11:03 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Global script that damages each turn damages twice on 2nd turn (+1)  
I found a way to apply the second fix cleanly. I feel better about that.

PR

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
10-27-2020 at 01:45 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged
icon Re: Global script that damages each turn damages twice on 2nd turn (+1)  
I can confirm that this is fixed in 1.2.8.2020-10-29. I also added Wait 0 to the top of the script and it still worked as expected.
10-29-2020 at 07:55 PM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
kieranmillar
Level: Smitemaster
Rank Points: 2668
Registered: 07-11-2014
IP: Logged

File: Growing.drh (9.9 KB)
Downloaded 27 times.
License: Public Domain
icon Re: Global script that damages each turn damages twice on 2nd turn (+2)  
Reopening this to say that this change changes the behaviour of the hold Growing.

Growing uses global scripts at the start of the hold, and every turn where you neither move or change direction (because you waited or bumped something) a counter increases.

Previously this erreneously ran twice on the first turn, assuming you therefore hadn't moved and increasing the counter by 1, so the counter starts at -1 to compensate for this, turning to 0 on the first turn.

Now, the counter stays at -1, letting you effectively do things initially with a counter too low. This lets you kill the first boss really early.

To accommodate for the new behaviour, I have attached a fix to the scripting of the hold to begin the counter at 0 instead, given it now no longer increases on turn 1. I used an old special exe Mike gave me back in the days of the disarm token change to trick the editor into thinking I was the original author.

[Last edited by kieranmillar at 10-30-2020 12:09 AM]
10-30-2020 at 12:07 AM
View Profile Send Private Message to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Global script that damages each turn damages twice on 2nd turn (0)  
Good catch, Kieran!

Thank you for the fixed hold.

Matt, do we need to hack the hold version metadata prior to updating the version on CaravelNet?

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.
10-30-2020 at 05:17 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
Schik
Level: Legendary Smitemaster
Avatar
Rank Points: 5381
Registered: 02-04-2003
IP: Logged
icon Re: Global script that damages each turn damages twice on 2nd turn (0)  
Yeah, if a hold needs to be updated, we'd generally have a new LastUpdated time on it. The only exceptions have been official holds where we have different versions for different engines.

____________________________
The greatness of a nation and its moral progress can be judged by the way it treats its animals.
--Mahatma Gandhi
10-30-2020 at 06:29 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Global script that damages each turn damages twice on 2nd turn (0)  
Thanks. Okay, sounds like this new hold version will need to be uploaded when we officially release 1.2.8.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 10-31-2020 01:30 AM]
10-31-2020 at 01:30 AM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
mrimer
Level: Legendary Smitemaster
Avatar
Rank Points: 5056
Registered: 02-04-2003
IP: Logged
icon Re: Global script that damages each turn damages twice on 2nd turn (+2)  
Working to get 1.2.8 out the door now. Bump to remind us to do this.

____________________________
Gandalf? Yes... That's what they used to call me.
Gandalf the Grey. That was my name.
I am Gandalf the White.
And I come back to you now at the turn of the tide.

[Last edited by mrimer at 07-28-2021 06:08 PM]
07-28-2021 at 06:08 PM
View Profile Send Private Message to User Send Email to User Show all user's posts High Scores This architect's holds Quote Reply
New Topic New Poll Post Reply
Caravel Forum : DROD RPG Boards : RPG Bugs : Global script that damages each turn damages twice on 2nd turn
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.