Scripts

TR_m7_NS_Irwaen_NpcSc

TR_Mainland.esm
Variables 12
Local Variables
nolore
TR_Map
T_Local_NoLore
T_Local_Npc
Control
controlQ
state
doonce
doonce1
islocked
timer
timer1
Source
1begin TR_m7_NS_Irwaen_NpcSc 2 3short nolore 4short TR_Map 5short T_Local_NoLore 6short T_Local_Npc 7short Control ; variable used for dialogue when convincing Irwaen to leave the bar 8short controlQ ; variable used to determine if the key has been dropped 9short state ; variable used to determine where Irwaen is on her journey home 10float timer 11float timer1 12short doonce 13short doonce1 14short islocked ; variable to see if door is locked 15 16; state key 17; 0 - In the bar, hasn't been convinced to leave yet 18; 1 - Convinced to leave bar and escorting player to the bar door 19; 2 - set when positioncelled outside of bar door, forcegreet dialogue state 20; 3 - 32 - Different nodes on the way to her apartment 21; 4, 8, 12, 16, 21, 24, 28 - States where she falls over 22; 5, 9, 13, 17, 22, 25, 29 - States when she can't be activated right AFTER the frame she falls over 23; 32 - final walking state, she will forcegreet when player is within 150 in state 32 and run islocked sequence 24; 40 - if door is still locked state for dialogue 25; 41 - if door WAS locked and player did not have key, state for dialogue to change greeting when player returns 26; 42 - if door is UNLOCKED at state 31 (that's odd?) 27; 43 - if player magically unlocks door during state 41 28; 50 - final state to tell Irwaen to go inside - this happens if player gives Irwaen key in dialogue OR player unlocks door via a spell and then talks to her 29 30if ( Menumode == 1 ) 31 return 32endif 33 34if ( onactivate ) ; sequence to prevent talking to Irwaen while she is getting up 35 if ( state == 5 ) 36 messagebox "Irwaen is struggling to her feet and can't talk." 37 elseif ( state == 9 ) 38 messagebox "Irwaen is struggling to her feet and can't talk." 39 elseif ( state == 13 ) 40 messagebox "Irwaen is struggling to her feet and can't talk." 41 elseif ( state == 17 ) 42 messagebox "Irwaen is struggling to her feet and can't talk." 43 elseif ( state == 22 ) 44 messagebox "Irwaen is struggling to her feet and can't talk." 45 elseif ( state == 25 ) 46 messagebox "Irwaen is struggling to her feet and can't talk." 47 elseif ( state == 29 ) 48 messagebox "Irwaen is struggling to her feet and can't talk." 49 else 50 activate 51 endif 52endif 53 54if ( T_Local_Nolore == 0 ) ; gives Irwaen topics again once she's home, and also moves her away from the door if you commanded her 55 if ( GetJournalIndex TR_m7_Ns_Irwaen == 100 ) 56 positioncell 4135 3893 15627 0 "Narsis, Irwaen's Apartment" ; TR_m7_MARK_Irwaen 57 aiwander 0 0 0 60 20 10 58 set T_Local_Nolore to 1 59 endif 60endif 61 62if ( GetPCCell "Narsis, Irwaen's Apartment" == 0 ) ; advances quest if the player uses command humanoid to bring Irwaen home 63 if ( GetEffect sEffectCommandHumanoids ) 64 set state to -1 65 endif 66elseif ( state == -1 ) 67 if ( GetJournalIndex TR_m7_Ns_Irwaen > 0 ) 68 if ( GetJournalIndex TR_m7_Ns_Irwaen < 40 ) 69 removeeffects 119 70 journal TR_m7_Ns_Irwaen 40 71 set state to -2 72 endif 73 endif 74endif 75 76if ( state == 51 ) ; short circuit script when quest is complete 77 return 78elseif ( state == -2 ) 79 return 80endif 81 82if ( getjournalindex tr_m7_ns_irwaen == 20 ) ; If Irwaen agrees to leave moves her out of the bar 83 if ( state == 0 ) 84 sethello 0 ; Important to avoid annoying pauses and idle lines 85 aiescort player 0 622 -71 -78 ; TR_m7_MARK_Irwaen 86 set state to 1 87 endif 88endif 89 90if ( state == 1 ) 91 if ( getdistance "TR_m7_NS_Irwaen_travel01" < 100 ) 92 playsound "Door Heavy Open" 93 disable ; disable and enable prevents bugs due to AI package not completing properly 94 positioncell 64090 -407183 150 14000 "Narsis, Waterfront" ; TR_m7_MARK_Irwaen 95 enable 96 set state to 2 97 endif 98elseif ( state == 2 ) 99 if ( getdistance player < 200 ) ; should immediately forcegreet player when they leave the bar 100 forcegreeting 101 set state to 3 102 endif 103elseif ( state == 3 ) 104 aiescort player 0 64037 -407728 118 ; TR_m7_MARK_Irwaen 105 set state to 4 106elseif ( state == 4 ) 107 if ( getdistance "TR_m7_NS_Irwaen_travel02" < 100 ) 108 playgroup "Knockdown" 1 109 playsound3d "Body Fall Medium" 110 if ( random 10 >= 8 ) ; random chance to drop the key in this location 111 drop "TR_m7_Narsis_KeyIrwaen" 1 112 set controlQ to 1 ; if key is dropped set controlQ in order to skip other potential drop locations 113 endif 114 set state to 5 115 endif 116elseif ( state == 5 ) 117 set timer1 to ( timer1 + getsecondspassed ) 118 if ( timer1 > 3 ) 119 playgroup idle 120 aiescort player 0 64128 -408793 118 ; TR_m7_MARK_Irwaen 121 set state to 6 122 set timer1 to 0 123 endif 124elseif ( state == 6 ) 125 if ( getdistance "TR_m7_NS_Irwaen_travel03" < 100 ) 126 aiescort player 0 63825 -408100 647 ; TR_m7_MARK_Irwaen 127 set state to 7 128 endif 129elseif ( state == 7 ) 130 if ( getdistance "TR_m7_NS_Irwaen_travel04" < 100 ) 131 aiescort player 0 64118 -408810 647 ; TR_m7_MARK_Irwaen 132 set state to 8 133 endif 134elseif ( state == 8 ) 135 if ( getdistance "TR_m7_NS_Irwaen_travel05" < 100 ) 136 playgroup "Knockdown" 1 137 playsound3d "Body Fall Medium" 138 if ( controlQ == 0 ) 139 if ( random 10 <= 2 ) ; random chance to drop the key in this location 140 drop "TR_m7_Narsis_KeyIrwaen" 1 141 set controlQ to 1 ; if key is dropped set controlQ in order to skip other potential drop locations 142 endif 143 endif 144 set state to 9 145 endif 146elseif ( state == 9 ) 147 set timer1 to ( timer1 + getsecondspassed ) 148 if ( timer1 > 3 ) 149 playgroup idle 150 aiescort player 0 63940 -409393 680 ; TR_m7_MARK_Irwaen 151 set state to 10 152 set timer1 to 0 153 endif 154elseif ( state == 10 ) 155 if ( getdistance "TR_m7_NS_Irwaen_travel06" < 100 ) 156 aitravel 63610 -409760 680 ; TR_m7_MARK_Irwaen 157 set state to 11 158 endif 159elseif ( state == 11 ) 160 if ( getdistance "TR_m7_NS_Irwaen_travel07" < 100 ) 161 aiescort player 0 62936 -413508 619 ; TR_m7_MARK_Irwaen 162 set state to 12 163 endif 164elseif ( state == 12 ) 165 if ( getdistance "TR_m7_NS_Irwaen_travel08" < 100 ) 166 playgroup "Knockdown" 1 167 playsound3d "Body Fall Medium" 168 if ( controlQ == 0 ) 169 if ( random 10 <= 2 ) ; random chance to drop the key in this location 170 drop "TR_m7_Narsis_KeyIrwaen" 1 171 set controlQ to 1 ; if key is dropped set controlQ in order to skip other potential drop locations 172 endif 173 endif 174 set state to 13 175 endif 176elseif ( state == 13 ) 177 set timer1 to ( timer1 + getsecondspassed ) 178 if ( timer1 > 3 ) 179 playgroup idle 180 aiescort player 0 62504 -415198 680 ; TR_m7_MARK_Irwaen 181 set state to 14 182 set timer1 to 0 183 endif 184elseif ( state == 14 ) 185 if ( getdistance "TR_m7_NS_Irwaen_travel09" < 100 ) 186 aiescort player 0 62287 -417504 19 ; TR_m7_MARK_Irwaen 187 set state to 15 188 endif 189elseif ( state == 15 ) 190 if ( getdistance "TR_m7_NS_Irwaen_travel10" < 100 ) 191 aitravel 62606 -418023 19 ; TR_m7_MARK_Irwaen 192 set state to 16 193 endif 194elseif ( state == 16 ) 195 if ( getdistance "TR_m7_NS_Irwaen_travel11" < 100 ) 196 playgroup "Knockdown" 1 197 playsound3d "Body Fall Medium" 198 set state to 17 199 if ( controlQ == 0 ) 200 if ( random 10 <= 3 ) ; random chance to drop the key in this location 201 drop "TR_m7_Narsis_KeyIrwaen" 1 202 set controlQ to 1 ; if key is dropped set controlQ in order to skip other potential drop locations 203 endif 204 endif 205 endif 206elseif ( state == 17 ) 207 set timer1 to ( timer1 + getsecondspassed ) 208 if ( timer1 > 3 ) 209 playgroup idle 210 aiescort player 0 62236 -418631 19 ; TR_m7_MARK_Irwaen 211 set timer1 to 0 212 set state to 18 213 endif 214elseif ( state == 18 ) 215 if ( getdistance "TR_m7_NS_Irwaen_travel12" < 100 ) 216 aiescort player 0 59887 -419276 109 ; TR_m7_MARK_Irwaen 217 set state to 19 218 endif 219elseif ( state == 19 ) 220 if ( getdistance "TR_m7_NS_Irwaen_travel13" < 100 ) 221 aiescort player 0 57730 -419595 135 ; TR_m7_MARK_Irwaen 222 set state to 20 223 endif 224elseif ( state == 20 ) 225 if ( getdistance "TR_m7_NS_Irwaen_travel14" < 100 ) 226 aitravel 57160 -419556 147 ; TR_m7_MARK_Irwaen 227 set state to 21 228 endif 229elseif ( state == 21 ) 230 if ( getdistance "TR_m7_NS_Irwaen_travel15" < 100 ) 231 playgroup "Knockdown" 1 232 playsound3d "Body Fall Medium" 233 if ( controlQ == 0 ) 234 if ( random 10 <= 4 ) ; random chance to drop the key in this location 235 drop "TR_m7_Narsis_KeyIrwaen" 1 236 set controlQ to 1 ; if key is dropped set controlQ in order to skip other potential drop locations 237 endif 238 endif 239 set state to 22 240 endif 241elseif ( state == 22 ) 242 set timer1 to ( timer1 + getsecondspassed ) 243 if ( timer1 > 3 ) 244 playgroup idle 245 aitravel 56579 -419706 140 ; TR_m7_MARK_Irwaen 246 set state to 23 247 set timer1 to 0 248 endif 249elseif ( state == 23 ) 250 if ( getdistance "TR_m7_NS_Irwaen_travel16" < 100 ) 251 aiescort player 0 56235 -421142 91 ; TR_m7_MARK_Irwaen 252 set state to 24 253 endif 254elseif ( state == 24 ) 255 if ( getdistance "TR_m7_NS_Irwaen_travel17" < 100 ) 256 playgroup "Knockdown" 1 257 playsound3d "Body Fall Medium" 258 if ( controlQ == 0 ) 259 if ( random 10 <= 5 ) ; random chance to drop the key in this location 260 drop "TR_m7_Narsis_KeyIrwaen" 1 261 set controlQ to 1 ; if key is dropped set controlQ in order to skip other potential drop locations 262 endif 263 endif 264 set state to 25 265 endif 266elseif ( state == 25 ) 267 set timer1 to ( timer1 + getsecondspassed ) 268 if ( timer1 > 3 ) 269 playgroup idle 270 aiescort player 0 56081 -422189 277 ; TR_m7_MARK_Irwaen 271 set state to 26 272 set timer1 to 0 273 endif 274elseif ( state == 26 ) 275 if ( getdistance "TR_m7_NS_Irwaen_travel18" < 100 ) 276 aiescort player 0 55293 -422115 419 ; TR_m7_MARK_Irwaen 277 set state to 27 278 endif 279elseif ( state == 27 ) 280 if ( getdistance "TR_m7_NS_Irwaen_travel19" < 100 ) 281 aiescort player 0 54492 -422091 427 ; TR_m7_MARK_Irwaen 282 set state to 28 283 endif 284elseif ( state == 28 ) 285 if ( getdistance "TR_m7_NS_Irwaen_travel20" < 100 ) 286 playgroup "Knockdown" 1 287 playsound3d "Body Fall Medium" 288 if ( controlQ == 0 ) ; random chance to drop the key in this location 289 drop "TR_m7_Narsis_KeyIrwaen" 1 290 set controlQ to 1 ; last possible drop location 291 endif 292 set state to 29 293 endif 294elseif ( state == 29 ) 295 set timer1 to ( timer1 + getsecondspassed ) 296 if ( timer1 > 3 ) 297 playgroup idle 298 aiescort player 0 53706 -422070 427 ; TR_m7_MARK_Irwaen 299 set state to 30 300 set timer1 to 0 301 endif 302elseif ( state == 30 ) 303 if ( getdistance "TR_m7_NS_Irwaen_travel21" < 100 ) 304 aitravel 53049 -422397 458 ; TR_m7_MARK_Irwaen 305 set state to 31 306 endif 307elseif ( state == 31 ) 308 if ( getdistance "TR_m7_NS_Irwaen_travel22" < 100 ) 309 Aiwander 0 0 0 60 20 10 310 set state to 32 311 endif 312elseif ( state == 32 ) 313 face 53090 -421497 ; this only works in OpenMW but it makes her face the player before forcegreeting 314 if ( getdistance player < 150 ) 315 if ( doonce == 0 ) 316 set islocked to ( "TR_m7_IrwaenDoor"->getlocked ) 317 if ( islocked == 1 ) 318 set state to 40 ; Door is still locked - asks for the key 319 forcegreeting 320 elseif ( islocked == 0 ) 321 set state to 42 ; the player must have already unlocked the door! She will comment that this is strange 322 forcegreeting 323 endif 324 set doonce to 1 325 endif 326 endif 327elseif ( state == 41 ) ; state 41 if the player responds that they don't have the key 328 set islocked to ( "TR_m7_IrwaenDoor"->getlocked ) 329 if ( islocked == 0 ) 330 set state to 43 ; for dialogue to thank you for opening the door, presumably with a spell or lockpick 331 endif 332elseif ( state == 50 ) ; Door has been unlocked 333 if ( doonce1 == 0 ) 334 face 53099 -422566 335 aitravel 53121 -422491 458 ; TR_m7_MARK_Irwaen 336 set doonce1 to 1 337 endif 338 set timer to ( timer + getsecondspassed ) 339 if ( timer > 1.5 ) 340 "TR_m7_IrwaenDoor"->unlock ; may already be unlocked if a spell was used 341 playsound "Door Heavy Open" 342 disable 343 journal TR_m7_NS_Irwaen 40 344 sethello 30 345 set state to 51 346 positioncell 4135 3893 15627 0 "Narsis, Irwaen's Apartment" ; TR_m7_MARK_Irwaen 347 aiwander 0 0 0 60 20 10 348 enable 349 endif 350endif 351 352if ( TR_Map ) 353 return 354endif 355 356set TR_Map to 7 357 358end