Jump to content


Photo

Local triggers when switching between scripts


  • Please log in to reply
No replies to this topic

#1 temnix

temnix
  • Member
  • 983 posts

Posted 13 March 2017 - 03:53 PM

A creature has a regular script. It is summoned for a time, but, to avoid the orange-flash disappearing effect, inappropriate for this kind of summons, it is directed to vanish earlier than the unsummoning. At OnCreation it checks for the level of the summoner, like so:

 

IF

OnCreation()

ClassLevel(LastSummonerOf(Myself),WIZARD,1)

 

THEN

 

(Sets a local trigger for X seconds)

Continue()

END

 

Onwards to other level checks, until the maximum relevant caster level. The X is somewhat before the duration of the spell for that caster level. Below this queue there is a TimerExpired trigger. The creature finds the caster level and scripts itself to self-destruct.

 

While it lives, a second spell may be cast on this creature, containing two applications of opcode 82, the AI change. The first change is to a new script, the second is delayed by a few seconds and puts the old script back on the creature. The temporary script has some operations the creature performs on itself. Meanwhile, the trigger should continue to run. X and the summoning duration are much longer than the script swap, so when the creature dons the old script, it receives the old TimerExpired back and with it awareness of the ticking clock.

 

Most of this works, but not the self-destruction. The creature is unsummoned in the usual manner. It seems to me the reason may be that the engine takes a "return" of a script its first run again, so OnCreation triggers for the second time and restarts the timer. This may be possible if what is created in the engine's eyes is the script "history" for that slot rather than the creature.

 

Or is there another explanation? The unsummoning time is behind the timer by several seconds.

 

One way around this is just to include a delayed RemoveSelf effect in the first spell, and then the timer would not be necessary, but I would like to know.