Scripts

TR_m2_q_9_VilynScript

TR_Mainland.esm
Variables 10
Local Variables
distcheck
trackmove
TR_Map
control
controlQ
T_Local_NPC
NoLore
Timer_A
Timer_B
Timer_C
Source
1Begin TR_m2_q_9_VilynScript 2 3;this is the local script on Vilyn Avani for the Flin Galore! quest. 4;It handles Vilyn's movement and checking whether the player is caught following him 5 6Short distcheck ;toggles checking whether player is caught peeking (0 = not caught, -1 = caught, more than 1 = checking) 7Short trackmove ;tracks the progress of movement 8Float Timer_A ;timer for distcheck 9Float Timer_B ;timer for trackmove 10Float Timer_C ;timer for preventing Vilyn getting stuck (bug prevention) 11short TR_Map 12short control 13short controlQ 14short T_Local_NPC 15short NoLore 16 17;standard map2 npc clause 18if ( TR_Map != 2 ) 19 Set TR_Map to 2 20endif 21 22 23;don't run in menu mode 24if ( menumode ) 25 return 26endif 27 28 29;rest of the script only runs when Vilyn leaves his shack - this is triggered from the global script TR_m2_q_9_FlinGaloreGlobal 30if ( GetPCCell "Andar Mok, Vilyn Avani's Shack" ) 31 return 32endif 33 34 35;this block deals with Vilyn checking to see if the player is following (checks every 2 seconds) 36if ( distcheck == 1 ) 37 Set Timer_A to ( Timer_A + GetSecondsPassed ) ;count seconds 38 if ( Timer_A > 2 ) ;if 2 seconds passed 39 Set Timer_A to 0 ;reset timer 40 Set distcheck to 2 ;check conditions 41 endif 42elseif ( distcheck == 2 ) 43 if ( GetDistance "player" < 1000 ) ;player is close enough to be caught 44 set distcheck to 3 45 else 46 set distcheck to 1 ;player isn't close, start counting again 47 endif 48elseif ( distcheck == 3 ) 49 if ( GetDetected, player ) ;player is detected 50 Set distcheck to 4 51 else 52 set distcheck to 1 ;player isn't detected, start counting again 53 endif 54elseif ( distcheck == 4 ) 55 if ( GetLOS, player ) ;player can be seen 56 Set distcheck to 5 57 else 58 Set distcheck to 1 ;player can't be seen, start counting again 59 endif 60elseif ( distcheck == 5 ) ;now Vilyn has caught the player 61 if ( GetForceSneak ) 62 ClearForceSneak ;stop Vilyn sneaking 63 endif 64 Set distcheck to 6 65 AiWander, 0, 0, 0 ;stop 66elseif ( distcheck == 6 ) 67 Set Timer_A to ( Timer_A + GetSecondsPassed ) 68 if ( Timer_A > 2 ) ;wait for 2 seconds 69 Set Timer_A to 0 70 Set distcheck to 7 71 if ( GetDistance "player" < 300 ) ;if the player is very near 72 ForceGreeting ;force greet 73 Return 74 endif 75 endif 76elseif ( distcheck == 7 ) 77 Set distcheck to -1 ;stop checking and remember player was caught 78 if ( GetJournalIndex "TR_m2_AO_FlinGalore" < 55 ) 79 Journal TR_m2_AO_FlinGalore 55 80 else 81 MessageBox "Vilyn appears to have seen you." 82 endif 83 Set trackmove to ( trackmove - 1 ) ;give Vilyn his AITravel instructions again 84endif 85 86;prevents AI being modified by rest of script executing 87if ( distcheck >= 4 ) 88 return 89endif 90 91;this block deals with performing the movement 92if ( trackmove == 0 ) 93 disable ;disable (for bug fix) 94 Set trackmove to 1 95 Set "TR_m2_q_9_FlinGaloreGlobal".vilynvar to -1 ;note that walk has begun ( Global script then prevents repeat that night) 96elseif ( trackmove == 1 ) 97 enable ;enable (for bug fix) 98 set trackmove to 2 99 Set distcheck to 0 ;don't check for player following yet 100 SetHello, 0 ;don't greet the player 101 AiTravel, 267825, -4577, 157, 1 ;walk down from platform 102elseif ( trackmove == 2 ) 103 if ( GetAIPackageDone ) ;wait for him to get there 104 Set trackmove to 3 105 endif 106elseif ( trackmove == 3 ) 107 AiTravel, 267065, -4372, 157, 1 ;walk to village center 108 Set trackmove to 4 109elseif ( trackmove == 4 ) 110 if ( GetAIPackageDone ) ;wait for him to get there 111 Set trackmove to 5 112 endif 113elseif ( trackmove == 5 ) 114 Set Timer_B to ( Timer_B + GetSecondsPassed ) ;wait for 2 seconds 115 if ( Timer_B > 2 ) 116 Set Timer_B to 0 117 Set trackmove to 6 118 endif 119elseif ( trackmove == 6 ) 120 AiTravel, 265782, -4628, 252, 1 ;walk towards field 121 Set trackmove to 7 122elseif ( trackmove == 7 ) 123 if ( GetAIPackageDone ) ;wait for him to get there 124 Set trackmove to 8 125 endif 126elseif ( trackmove == 8 ) 127 AiTravel, 265491, -5202, 252, 1 ;walk behind Dreynis Teran's shack 128 Set trackmove to 9 129elseif ( trackmove == 9 ) 130 if ( GetAIPackageDone ) ;wait for him to get there 131 Set trackmove to 10 132 endif 133elseif ( trackmove == 10 ) 134 Set Timer_B to ( Timer_B + GetSecondsPassed ) ;wait for 3 seconds 135 if ( Timer_B > 3 ) 136 Set Timer_B to 0 137 Set trackmove to 11 138 if ( distcheck != -1 ) ;if not already shouted at player, 139 Set distcheck to 1 ;start to check for player following 140 endif 141 endif 142elseif ( trackmove == 11 ) 143 if ( distcheck != -1 ) ;if not already caught, 144 ForceSneak ;start sneaking 145 endif 146 AiTravel, 265928, -5393, 131, 1 ;go behind Dreynis's shack 147 Set trackmove to 12 148elseif ( trackmove == 12 ) 149 if ( GetAIPackageDone ) ;wait for him to get there 150 Set trackmove to 13 151 endif 152elseif ( trackmove == 13 ) 153 AiTravel, 266126, -5746, 216, 1 ;go towards rocks 154 Set trackmove to 14 155elseif ( trackmove == 14 ) 156 if ( GetAIPackageDone ) ;wait for him to get there 157 Set trackmove to 15 158 endif 159elseif ( trackmove == 15 ) 160 AiTravel, 267126, -5670, 216, 1 ;go past Andilo Vadryon's shack 161 Set trackmove to 16 162elseif ( trackmove == 16 ) 163 if ( GetAIPackageDone ) ;wait for him to get there 164 Set trackmove to 17 165 ClearForceSneak ;stop sneaking 166 endif 167elseif ( trackmove == 17 ) 168 Set Timer_B to ( Timer_B + GetSecondsPassed ) ;wait for 3 seconds 169 if ( Timer_B > 3 ) 170 Set Timer_B to 0 171 Set trackmove to 18 172 endif 173elseif ( trackmove == 18 ) 174 if ( distcheck != -1 ) ;if not caught by player 175 ForceSneak ;start sneaking again 176 endif 177 AiTravel, 267874, -5766, 195, 1 ;go behind Vilyn's shack 178 Set trackmove to 19 179elseif ( trackmove == 19 ) 180 if ( GetAIPackageDone ) ;wait for him to get there 181 Set trackmove to 20 182 endif 183elseif ( trackmove == 20 ) 184 AiTravel, 268659, -5380, 263, 1 ;go towards rocks 185 Set trackmove to 21 186elseif ( trackmove == 21 ) 187 if ( GetAIPackageDone ) ;wait for him to get there 188 Set trackmove to 22 189 ClearForceSneak ;stop sneaking 190 endif 191elseif ( trackmove == 22 ) 192 Set Timer_B to ( Timer_B + GetSecondsPassed ) ;wait for 2 seconds 193 if ( Timer_B > 2 ) 194 Set Timer_B to 0 195; MessageBox "He should split paths here." 196 if ( distcheck == -1 ) ;if caught by the player 197 Set trackmove to 33 ;head home 198 else ;otherwise 199 Set trackmove to 23 ;head for the barrel 200 endif 201 endif 202 203elseif ( trackmove == 23 ) ;this section continues towards the hidden Flin 204 205 if ( distcheck != -1 ) ;if not caught by player 206 ForceSneak ;start sneaking again 207 endif 208 AiTravel, 269703, -5408, 308, 1 ;go towards treestump 209 Set trackmove to 24 210elseif ( trackmove == 24 ) 211 if ( GetAIPackageDone ) ;wait for him to get there 212 Set trackmove to 25 213 endif 214elseif ( trackmove == 25 ) 215 AiTravel, 270356, -4885, 328, 1 ;go around rocks 216 Set trackmove to 26 217elseif ( trackmove == 26 ) 218 if ( GetAIPackageDone ) ;wait for him to get there 219 if ( distcheck == -1 ) ;if caught by the player 220 Set trackmove to 31 ;head home 221 else ;otherwise 222 Set trackmove to 27 ;keep heading for the barrel 223 endif 224 endif 225 226elseif ( trackmove == 27 ) ;this section continues towards the hidden Flin 227 228 AiTravel, 270635, -4990, 328, 1 ;sneak to hidden barrel 229 Set trackmove to 28 230elseif ( trackmove == 28 ) 231 if ( GetAIPackageDone ) ;wait for him to get there 232 Set trackmove to 29 233 endif 234elseif ( trackmove == 29 ) 235 Set Timer_B to ( Timer_B + GetSecondsPassed ) ;wait for 8 seconds 236 if ( Timer_B > 8 ) 237 Set Timer_B to 0 238 Set trackmove to 31 239 endif 240 241elseif ( trackmove == 31 ) ;from here is the return journey 242 243 AiTravel, 269224, -4618, 272, 1 ;go back towards village 244 Set trackmove to 32 245elseif ( trackmove == 32 ) 246 if ( GetAIPackageDone ) ;wait for him to get there 247 Set trackmove to 33 248 if ( GetForceSneak ) 249 ClearForceSneak ;stop sneaking 250 Set distcheck to 0 ;stops checking for player following (if he still was) 251 endif 252 endif 253 254elseif ( trackmove == 33 ) ;this is the shortcut to the return journey 255 256 AiTravel, 268656, -4671, 209, 1 ;go further towards village 257 Set trackmove to 34 258elseif ( trackmove == 34 ) 259 if ( GetAIPackageDone ) ;wait for him to get there 260 Set trackmove to 35 261 endif 262elseif ( trackmove == 35 ) 263 AiTravel, 267799, -4531, 164, 1 ;walk back to platform outside shack 264 Set trackmove to 36 265elseif ( trackmove == 36 ) 266 if ( GetAIPackageDone ) ;wait for him to get there 267 Set trackmove to 37 268 endif 269elseif ( trackmove == 37 ) 270 AiTravel, 268046, -4893, 249, 1 ;walk to door 271 Set trackmove to 38 272elseif ( trackmove == 38 ) 273 if ( GetAIPackageDone ) ;wait for him to get there 274 SetHello, 30 275 Set trackmove to 0 ;reset trackmove 276 Set Timer_A to 0 277 Set Timer_B to 0 ;reset all the timers 278 Set Timer_C to 0 279 PositionCell, -438, -489, -111, 132, "Andar Mok, Vilyn Avani's Shack" ;go back into shack 280 AiWander 0 0 0 0 0 0 0 0 0 0 0 0 281 Set "TR_m2_q_9_FlinGaloreGlobal".vilynvar to -1 ;prevents bug 282 endif 283endif 284 285;This block prevents bugs with Vilyn getting stuck / forgetting where he should be going 286if ( GetCurrentAIPackage <= 0 ) ;if Vilyn is idle 287 Set Timer_C to ( Timer_C + GetsecondsPassed ) 288 if ( Timer_C > 10 ) ;for more than 10 seconds (should only happen if something's gone wrong) 289 Set trackmove to ( trackmove - 1 ) ;give him his last AITravel orders again 290 if ( trackmove == 30 ) ;since there is no stage 30 -- arvisrend 291 set trackmove to 29 292 endif 293 Set Timer_C to 0 ;reset timer 294 endif 295else 296 if ( Timer_C > 0 ) ;if nothing's going wrong 297 Set Timer_C to 0 ;reset timer 298 endif 299endif 300 301End