Fun facts about script calling order!
Author | Topic: Fun facts about script calling order! |
---|---|
Off With Their Heads
Member # 4045
|
written Sunday, July 18 2004 22:35
Profile
Homepage
Not that anyone probably cares, but meh. I threw a whole bunch of print_str calls into various states in scripts and came up with the following results: When a scenario starts up, the states called go in this order: START_SCEN_STATE LOAD_SCEN_STATE Then monster INIT_STATEs in the first town, in ascending order of creature number (so creature 6 goes first, then 7, then 8, etc -- unless you have joined NPCs, in which case I'd assume it starts with 4). Then it prints "NOW ENTERING: [town name]" Then town INIT_STATE Followed by terrain INIT_STATEs in the first town And the town START_STATE once, which is odd, because this is the only START_STATE called at this time. Every turn, the start states are called in this order: Scenario START_STATE Town START_STATE Monster START_STATEs, in ascending order of creature number (although this can be changed by changing the script mode -- haven't played with this enough to see its effects consistently). However, terrain script START_STATEs are weird and seem to be called whenever BoA feels like it, which appears to be influenced by monster movement -- possibly they are called in between different NPCs moving. So the obvious question is: why would anyone care? Well, there are a few interesting results of this. One involves messaging. I noticed the docs say, "right after a character's or terrain's script is run, its message is set back to -1, so if you don't check for a message once, the creature/terrain will miss it." Some elaboration on that statement: if creature 50 sends a message in tick x that creature 20 can hear, and creature 20 was set to check for the message in tick x, creature 20 will not get the message (because creature 50's script hasn't been run yet). If creature 20 checks again in tick x + 1, it WILL get the message then, and will promptly delete it after doing whatever it is supposed to do. Okay, you say, but SO FREAKING WHAT?! Well, just note that if a creature with a higher creature number sends a message to a creature with a lower creature number, the lower creature won't get it until the following turn, but if a lower creature number sends a message to a higher creature number, that higher creature will get it on that same turn. Something to be aware of if you use messaging calls. I'm sure there are more interesting applications of this knowledge, but I can't think of any right now. -------------------- Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens. Smoo: Get ready to face the walls! Ephesos: In conclusion, yarr. Kelandon's Pink and Pretty Page!!: the authorized location for all things by me The Archive of all released BoE scenarios ever Posts: 7968 | Registered: Saturday, February 28 2004 08:00 |
Warrior
Member # 286
|
written Sunday, July 18 2004 23:06
Profile
It's always useful to know as much as possible about the guts of the system you're programming in. Thanks! :) -------------------- Z: "I just feel so insignificant." Psych: "You ARE. You're an ANT." --Antz Posts: 104 | Registered: Saturday, November 17 2001 08:00 |
Warrior
Member # 4202
|
written Monday, July 19 2004 00:20
Profile
Homepage
Also, for the party triggering step-on specials, if there are multiple types in the same place, the order is terrain script, then special rectangle, then script for stepping on that terrain type (one of the possible special properties of terrain). EDIT: quote:So that's why certain terrain scripts that I've heard of blast the party into oblivion instead of just damaging them once a turn. Things like that would need to check the tick to make sure it's different than last time. Or of course, do it in the town's START_STATE, but terrain scripts are nicer for some things. [ Monday, July 19, 2004 00:26: Message edited by: Isaac ] -------------------- Creator of the 3D Blades of Avernum Editor for Mac. Get it at Ingenious Isaac's Illusion, my web page. Better yet, get Battle for Wesnoth, a wonderful free TBS game. Posts: 192 | Registered: Sunday, April 4 2004 08:00 |
Infiltrator
Member # 4637
|
written Monday, July 19 2004 01:07
Profile
Homepage
Humm... Interesting. Nice work. :) -------------------- Visit the Blades of Avernum Center and the Beta Testing Center -------------- "Beware lest anyone cheat you through philosophy and empty deceit, according to the tradition of men, according to the basic principles of the world, and not according to Christ." Colossians 2:6-9 Posts: 483 | Registered: Tuesday, June 29 2004 07:00 |
Agent
Member # 2820
|
written Tuesday, July 20 2004 07:09
Profile
About the broadcasting thing... I believe that at the end of every turn/tick, all scripts that have new messages will run again regardless of whether it has run once before. -------------------- Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are. ==== Alorael: War and violence would end if we all had each other's babies! ==== Drakefyre: Those are hideous mangos. Posts: 1415 | Registered: Thursday, March 27 2003 08:00 |
Off With Their Heads
Member # 4045
|
written Tuesday, July 20 2004 09:12
Profile
Homepage
I'm pretty sure not, because I tested this out with some visual cues (if my_current_message is whatever, put_boom_on_char myself), and it only happened on the next turn. With tests, I found a definite difference between behaviors based on creature numbers. Have you tried it out? -------------------- Arancaytar: Every time you ask people to compare TM and Kel, you endanger the poor, fluffy kittens. Smoo: Get ready to face the walls! Ephesos: In conclusion, yarr. Kelandon's Pink and Pretty Page!!: the authorized location for all things by me The Archive of all released BoE scenarios ever Posts: 7968 | Registered: Saturday, February 28 2004 08:00 |
Agent
Member # 2820
|
written Tuesday, July 20 2004 13:13
Profile
You're right, I guess, since that only applies when the creature wouldn't have run its script in the first place. -------------------- Thuryl: I mean, most of us don't go around consuming our own bodily fluids, no matter how delicious they are. ==== Alorael: War and violence would end if we all had each other's babies! ==== Drakefyre: Those are hideous mangos. Posts: 1415 | Registered: Thursday, March 27 2003 08:00 |