I had a simple script for a guard on a prison ship. He's supposed to wait by a timer for 10 seconds, then AITravel past the player's prison cell, when he's near, give a forcegreeting, finish his AITravel, then go back to where he started from. Everything else being the same from one run of the game to the next he would sometimes do this correct behavior, and sometimes he would skip the wait, and travel past the player without giving his forcegreeting. I'm able to make the script robust enough that the dialogue that needs to happen does happen, but the fact that the script has 2 different behaviors really bothers me.
I was just wondering if anyone else has had to deal with scripts that function differently from one run of the game to the next?
The "robustified" script, for the curious, with extra code in states 2,3,4 to handle the bugged behavior:
Spoiler
Begin GaleoneWache01NPCShort StateFloat Timerif ( State == 0 ) "GaleoneZettel01"->Disable ; Gets Enabled via GaleoneWache01's dialogue Set Timer to 0 Set State to 1elseif ( State == 1 ) Set Timer to ( Timer + GetSecondsPassed ) if ( Timer > 10 ) ; Wait a short bit ;; First AITravel AITravel 1250 3575 832 ; Then walk past player in cell Set State to 2 endifelseif ( State == 2 ) If ( GetDistance "GaleoneZettel01" < 120 ) if ( GetJournalIndex "A_II_Galeone" < 2 ) ForceGreeting ; Taunt player when near Journal "A_II_Galeone" 2 Set Storyvar to 9 Set State to 3 endif endif if ( GetAIPackageDone ) ; first AITravel to finishes ;; if we got here, somehow the GetDistance stanza above did not trigger !! Set State to 4 endifelseif ( State == 3 ) if ( GetAIPackageDone ) ; wait for first AITravel to finish Set State to 4 endifelseif ( State == 4 ) if ( GetJournalIndex "A_II_Galeone" < 2 ) ; In case previous condition in state 2 was not met ForceGreeting ; Taunt player when near Journal "A_II_Galeone" 2 Set Storyvar to 9 endif ;; Second AITravel AITravel 2176 3584 832 ; then go back to guard's starting point Set State to 5 endifelseif ( State == 5 ) if ( GetAIPackageDone ) ; wait for second aitravel to finish AIWander 1000 5 0 0 60 20 10 0 ; and now just wander Set State to 999 ; Done endifendifEnd