TR_m3_q_3_Burglar_sc
TR_Mainland.esm
Variables
21
Local Variables
TR_Map
NoLore
state
dead
IntimidatingPC
hisDisposition
greetonce
commanded
DoorIsOpen
FadeToBlack
PCResting
knockingout
restrainattempt
button
T_Local_NPC
T_Local_NoLore
TheTime
LookAtTheTime
timer
unlocktimer
paralysetimer
Source
1Begin TR_m3_q_3_Burglar_sc
2
3;script on the copy of Balamus Arthre placed into the Vault during the burglary
4
5;WARNING: script seems to somehow stretch capacity for potential operations considered per frame?
6;some seemingly superfluous Returns or duplicatas are there to avoid this
7;might still be places where adding any line at all would result in immediate left eval
8
9short TR_Map
10short NoLore
11
12short state
13short dead
14short IntimidatingPC
15short hisDisposition
16short greetonce
17short commanded
18short DoorIsOpen
19short FadeToBlack
20short PCResting
21
22float TheTime
23float LookAtTheTime
24float timer
25float unlocktimer
26short knockingout
27float paralysetimer
28short restrainattempt
29short button
30short T_Local_NPC
31short T_Local_NoLore
32
33If ( GetDisabled == 1 )
34 SetDelete 1
35 Return
36Endif
37
38If ( CellChanged == 1 ) ;make sure he doesn't stay stuck in the cell
39 Disable
40 Return
41Endif
42
43
44;----------- Death
45
46If ( dead == 1 )
47 Return
48ElseIf ( OnDeath == 1 )
49 set dead to 1
50 set TR_m3_q_3_thieving to 2
51 If ( GetJournalIndex "TR_m3_Bo_Burglar2" < 95 )
52 Journal "TR_m3_Bo_Burglar2" 42
53 Endif
54 Return
55Endif
56
57
58;----------- Detect player loitering
59;----------- (alternative solution= place 'enemies nearby' while the thief is inside so you can't rest?)
60
61If ( TheTime == 0 )
62 set TheTime to GameHour
63Endif
64If ( MenuMode == 1 )
65 set LookAtTheTime to ( GameHour - TheTime )
66 if ( LookAtTheTime > 0.5 ) ;before the usual return, check if time jumps while in MenuMode
67 set PCResting to 1 ;if so it means the player's resting
68 elseif ( LookAtTheTime < -0.5 )
69 set PCResting to 1
70 else
71 set PCResting to 0
72 endif
73 If ( PCResting == 1 )
74 If ( GetJournalIndex "TR_m3_Bo_Burglar2" < 40 )
75 If ( GameHour >= 20 ) ;in case the PC starts resting (loitering) AFTER this NPC is placed,
76 set TR_m3_q_3_thieving to 0 ;he shant be hanging around any longer
77 set dead to 1
78 Disable
79 Endif
80 Endif
81 Endif
82 Return
83Endif
84set TheTime to GameHour
85
86
87;----------- Capture by knock-down
88
89If ( GetJournalIndex "TR_m3_Bo_Burglar2" < 41 )
90 If ( knockingout == 1 )
91 set paralysetimer to ( paralysetimer + GetSecondsPassed )
92 If ( paralysetimer > 1 )
93 set paralysetimer to 0
94 Journal "TR_m3_Bo_Burglar2" 41
95 set TR_m3_q_3_thieving to 3
96 StopCombat
97 SetFight 30
98 AiWander 0, 0, 0
99 Set FadeToBlack to 1
100 Return
101 Endif
102 ElseIf ( OnKnockout == 1 )
103 set paralysetimer to 0
104 set knockingout to 1
105 ModCurrentFatigue -200
106
107
108;----------- Capture by paralysis
109
110 ElseIf ( GetParalysis == 1 ) ;he's captured if paralysed more than 8 seconds, or more than 2 with a STR+h2h check
111 If ( restrainattempt >= 0 )
112 set paralysetimer to ( paralysetimer + GetSecondsPassed )
113 If ( restrainattempt == 0 )
114 If ( paralysetimer > 2 )
115 MessageBox "He's paralyzed!", "Keep fighting", "Get close and try to restrain him"
116 set restrainattempt to 1
117 Endif
118 ElseIf ( restrainattempt == 1 )
119 set button to GetButtonPressed
120 If ( button == -1 )
121 Return
122 ElseIf ( button == 0 )
123 set restrainattempt to -1
124 Return
125 ElseIf ( button == 1 )
126 set restrainattempt to 2
127 Return
128 Endif
129 ElseIf ( restrainattempt == 2 )
130 If ( paralysetimer > 6 )
131 Journal "TR_m3_Bo_Burglar2" 41 ;long enough, gets captured
132 set TR_m3_q_3_thieving to 3
133 StopCombat
134 SetFight 30
135 AiWander 0, 0, 0
136 Set FadeToBlack to 1
137 SetParalysis 1
138 Return
139 Endif
140 Endif
141 Endif
142 ElseIf ( restrainattempt == 2 ) ;paralysis ends while trying to restrain him
143 If ( GetDistance, player <= 100 )
144 set restrainattempt to ( player->GetLevel + GetHandToHand )
145 If ( restrainattempt >= 80 )
146 set restrainattempt to 3 ;if strong enough, gets captured...
147 MessageBox, "You manage to restrain him."
148 Else
149 Set restrainattempt to -1
150 MessageBox, "He breaks free!"
151 Say, "vo\d\m\Atk_DM006.mp3", "ARRRR!"
152 Endif
153 Endif
154 ElseIf ( restrainattempt == 3 ) ;...is captured
155 Journal "TR_m3_Bo_Burglar2" 41
156 set TR_m3_q_3_thieving to 3
157 StopCombat
158 SetFight 30
159 AiWander 0, 0, 0
160 Set FadeToBlack to 1
161 Return
162 ElseIf ( paralysetimer > 0 )
163 Set paralysetimer to 0
164 Endif
165Endif
166
167
168;----------- Capture by command
169
170If ( GetEffect, sEffectCommandHumanoids == 1 )
171 set commanded to 1 ;used in dialogue
172ElseIf ( commanded == 1 )
173 set commanded to 0
174Endif
175
176
177;----------- Ellipsis after capturing him
178
179If ( FadeToBlack == 1 )
180 If ( GameHour > 22 ) ;cancel in the unlikely case that the thievery was stretched for hours and the capn's already in
181 Set FadeToBlack to 0
182 Else
183 DisablePlayerControls
184 FadeOut 0.8
185 set timer to 0
186 set FadeToBlack to 2
187 Endif
188ElseIf ( FadeToBlack == 2 )
189 set timer to ( timer + GetSecondsPassed )
190 If ( timer > 1 )
191 set GameHour to 21.999 ;cut to the Captain entering
192 set FadeToBlack to 3
193 Endif
194ElseIf ( FadeToBlack == 3 )
195 set timer to ( timer + GetSecondsPassed )
196 If ( timer > 2 )
197 ;EnablePlayerControls ;4o4 player controls stay disabled to prevent them from leaving before his dialogue
198 FadeIn 0.8
199 set FadeToBlack to 4
200 Endif
201Endif
202
203
204;----------- Movement AI
205
206If ( GetJournalIndex "TR_m3_Bo_Burglar2" < 40 )
207 If ( TR_m3_q_3_thieving == 1 ) ;set by the global script when he enters -unnecessary now that he's a copy NPC!
208 If ( state == 0 )
209 set hisDisposition to ( TR_m3_Balamus_Arthre->GetDisposition )
210 set hisDisposition to ( hisDisposition - GetDisposition )
211 ModDisposition hisDisposition
212 set IntimidatingPC to ( player->GetLevel + GetStrength )
213 if ( IntimidatingPC >= 90 )
214 set IntimidatingPC to 1 ;used in dialogue
215 else
216 set IntimidatingPC to 0
217 endif
218 PlaySound3D "Wooden Door Open 1"
219 MessageBox, "You hear a muffled noise coming from the entrance."
220 ForceSneak
221 Cast, "TR_m3_q_3_Burglar_sp", "TR_m3_q_3_Burglar"
222 set state to 1
223 ElseIf ( state == 1 ) ;wait while he casts invisibility on himself
224 set timer to ( timer + GetSecondsPassed )
225 If ( timer > 2 )
226 AiTravel 4400, 4200, 12350, 1 ;walks to the door
227 set state to 2
228 set timer to 0
229 Endif
230 ElseIf ( state == 2 )
231 If ( "TR_m3_q_3_VaultDoor02".isOpen == 1 ) ;if it's already open, or PC opens it now, he'll run away
232 set timer to ( timer + GetSecondsPassed )
233 If ( timer > 1 )
234 AiTravel 3800, 3845, 12350, 1
235 set state to 6
236 Endif
237 Endif
238 If ( GetAIPackageDone == 1 )
239 If ( "TR_m3_q_3_VaultDoor02"->GetLocked == 1 )
240 AiWander 0 0 0 0 0 0 0 0 0
241 set unlocktimer to 0.1 ;starts unlocking
242 "TR_m3_q_3_VaultDoor02"->PlaySound3D "Open Lock"
243 Else ;if it was already unlocked, he smells a rat when opening it and heads back out
244 Set "TR_m3_q_3_VaultDoor02".beOpen to 1
245 AiTravel 3800, 3845, 12350, 1
246 set state to 6
247 Endif
248 Endif
249 If ( unlocktimer > 0 )
250 set unlocktimer to ( unlocktimer + GetSecondsPassed )
251 if ( unlocktimer > 2 )
252 "TR_m3_q_3_VaultDoor02"->PlaySound3D "Open Lock"
253 "TR_m3_q_3_VaultDoor02"->Unlock ;opens it
254 Set "TR_m3_q_3_VaultDoor02".beOpen to 1
255 set state to 3
256 endif
257 Endif
258 ElseIf ( state == 3 )
259 If ( "TR_m3_q_3_VaultDoor02".isOpen == 0 )
260 Else ;have to condition it in that contrived way or it crashes. (?_?) - aitravel gets called on door?
261 AiTravel 3850, 4400, 12086, 1 ;walks a bit down there
262 set state to 4
263 Endif
264 ElseIf ( state == 4 )
265 If ( GetAIPackageDone == 1 )
266 AiTravel 4380, 4400, 12350, 1 ;sees there are people inside too, doubles back up
267 set state to 5
268 Endif
269 ElseIf ( state == 5 )
270 If ( GetAIPackageDone == 1 )
271 AiTravel 3800, 3845, 12350, 1 ;goes back to the entrance
272 set state to 6
273 Endif
274 ElseIf ( state == 6 )
275 If ( GetAIPackageDone == 1 ) ;and, if uninterrupted so far, leaves
276 set state to 7
277 set TR_m3_q_3_thieving to 0
278 set dead to 1
279 Disable ;we're done with this copy of the NPC
280 Endif
281 Endif
282 Endif
283Endif
284
285If ( GetJournalIndex "TR_m3_Bo_Burglar2" >= 100 ) ;the captain's come to take him away
286 If ( state < 8 )
287 RemoveSpellEffects, "TR_m3_q_3_Burglar_sp"
288 SetParalysis 0 ;get back up if necessary
289 SetFatigue 200
290 ClearForceSneak
291 AiTravel 3800, 3845, 12350, 1 ;goes back to the entrance
292 set state to 8
293 ElseIf ( state == 8 )
294 If ( GetAIPackageDone == 1 )
295 set state to 9
296 Disable ;he leaves
297 Endif
298 Endif
299Endif
300
301; regional filter & nolore
302
303if ( TR_Map == 3 )
304 return
305endif
306
307set TR_Map to 3
308
309End