Jump to content

Fun facts about script calling order!


Kelandon

Recommended Posts

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.

Link to comment
Share on other sites

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:
Originally written by Just call me Kel:

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 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.
Link to comment
Share on other sites

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?

Link to comment
Share on other sites

Guest
This topic is now closed to further replies.
×
×
  • Create New...