Sorry to keep bringing this script up, but hopefully this will be the last time. I need to make a slight modification to it for a third condition. The original script triggered a forced greeting from a stationary NPC. The second condition addressed the same from a wandering NPC (by temporarily putting him into AiFollow until the greeting is recited). Now I have an NPC who is stationary, but has an animation running on him (one of RX-31's animation sequences). So while the NPC is not wandering, he is in constant motion, making hand gestures, etc. When I walk up to him, I'd like him to stop whatever gesture he is doing and turn to face the player and recite his line (like a wandering NPC).
I started by placing the wandering NPC script on him. That stopped the animation, made the NPC face the player and recite his greeting all perfectly. However, after the greeting, he started wandering around - not surprising, since the script is written to return him to wander mode. For this animated character, instead of returning to AiWander, I just need to get him out of AiFollow after he's said his greeting. Easier said than done (for me), because whatever I'm doing isn't working. This is the script that works for wandering NPC's:
Begin FW_greeting_NM_wander_nice01 short doOnce float timer short wanderingNPC if ( OnDeath > 0 ) set doOnce to 99 endif if ( doOnce == 0 ) if ( ( GetDistance player ) < 200 ) ; increased from 150 (too close) if ( GetCurrentAIPackage == 0 ) ; wandering set wanderingNPC to 1 endif set doOnce to 1 AIFollow player 0 0 0 0 endif elseif ( doOnce == 1 ) set timer to ( timer + GetSecondsPassed ) if ( timer < 1 ) return else set timer to 0 set doOnce to 3 say "vo\N\m\Hlo_NM135.mp3" "Hail and welcome friend, hail!" endif elseIf ( doOnce == 3 ) if ( ( GetDistance player ) > 150 ) ; increased from 50 to allow NPC to complete dialogue before resuming wander if ( wanderingNPC == 1 ) set wanderingNPC to 0 AIWander 2000 5 0 60 20 10 10 0 0 0 0 endif set doOnce to 4 ; stop following but don't check for vicinity yet endif elseif ( doOnce == 4 ) if ( ( Getdistance player ) > 500 ) ; NOW you can reset set doOnce to 0 endif endifEnd FW_greeting_NM_wander_nice01
I modified that script to the following for the stationary but animated NPC (the first part is just a sleep timer to make this character appear between certain hours, and I wanted to keep that function so just combined it with the greeting script):
begin FW_greeting_ANIMATEDif ( GetDisabled ) if ( GameHour >= 8 ) if ( GameHour <= 22 ) enable endif endif returnendifif ( GameHour > 22 ) disable returnelseif ( GameHour < 8 ) disableendif short doOnce float timer short wanderingNPC if ( OnDeath > 0 ) set doOnce to 99 endif if ( doOnce == 0 ) if ( ( GetDistance player ) < 200 ) ; increased from 150 (too close) set doOnce to 1 AIFollow player 0 0 0 0 endif elseif ( doOnce == 1 ) set timer to ( timer + GetSecondsPassed ) if ( timer < 1 ) return else set timer to 0 set doOnce to 3 say "vo\I\m\Hlo_IM151.mp3" "Well hello there! How are you?" endif elseIf ( doOnce == 3 ) if ( ( GetDistance player ) > 150 ) ; increased from 50 to allow NPC to complete dialogue before resuming wander if ( GetCurrentAIPackage == 3 ) GetCurrentAIPackage == -1 endif set doOnce to 4 ; stop following but don't check for vicinity yet endif elseif ( doOnce == 4 ) if ( ( Getdistance player ) > 500 ) ; NOW you can reset set doOnce to 0 endif endifend
The 9th and 10th lines from the bottom are the ones I changed. I figured the NPC is in AiFollow mode (AiPackage 3), and want to change it to None (AiPackage -1). But that didn't work, because now he's stalking me. :confused: What did I do wrong this time, and how do I fix it? Many thanks in advance.