TR_m4_TJ_DremoraLord_sc
TR_Mainland.esm
Variables
10
Local Variables
control
isDead
forceGreet
attackTwilight
fleePC
fightPC
foughtSpider
OnPCHitMe
backstabPC
proxDoOnce
Source
1Begin TR_m4_TJ_DremoraLord_sc
2
3short control
4; control is the main variable that governs the state of the dremora, whether he is following you, how pissed off he is if he is, and the final wrap-up.
5short isDead
6short forceGreet
7short attackTwilight
8short fleePC
9short fightPC
10short foughtSpider
11short OnPCHitMe
12short backstabPC
13short proxDoOnce
14
15; if menu don't run
16if ( MenuMode )
17 Return
18endif
19
20;if dead don't run
21if ( isDead )
22 Return
23endif
24
25; if dying set dead, set ogrim duel won - ogrim resets it if there was never a duel.
26if ( OnDeath )
27 set TR_m4_TJ_Ogrim.duelWon to 1
28 set isDead to 1
29endif
30
31; if we want this guy to initiate a greeting, initiate a greeting once. Rocket science.
32if ( forceGreet == 1 )
33 set forceGreet to 2
34 ForceGreeting
35 Return
36endif
37
38; if PC attacks ever
39if ( OnPCHitMe )
40 set OnPCHitMe to 0
41
42 ; if following the player
43 if ( control > 0 )
44 if ( control < 10 )
45
46 ; if this is the first time, talk then fight
47 if ( backstabPC == 0 )
48 set forceGreet to 1
49 ;MessageBox "triggered backstab forcegreet" "ok"
50 set fightPC to 1
51 set backstabPC to 1
52 ; else just fight
53 else
54 SetFight 100
55 StartCombat player
56 endif
57
58 ; if not following the player, fight
59 else
60 SetFight 100
61 StartCombat player
62 endif
63 else
64 SetFight 100
65 StartCombat player
66 endif
67endif
68
69; if we've ever initiated a fight through dialogue, stop worrying about states and just fight.
70if ( fightPC >= 1 )
71 Return
72endif
73
74; states
75
76; initial - if not following
77if ( control == 0 )
78
79 ; if entering the cell
80 if ( CellChanged )
81 ; if the exit is close - the one facing the guy's starting position
82 if ( GetDistance player < 600 )
83 ; greet to initialize the Dremora's story
84 ;MessageBox "triggered cellchange initialize forcegreet" "ok"
85 set forceGreet to 1
86 Return
87 endif
88 ; if not entering and the player gets really close, also forcegreet and initiate
89 elseif ( GetDistance player < 250 )
90 if ( proxDoOnce == 0 )
91 set proxDoOnce to 1
92 ;MessageBox "triggered proximity forcegreet" "ok"
93 set forceGreet to 1
94 Return
95 endif
96 endif
97
98 ; no recording attacks on Twilights if not following player
99 if ( attackTwilight == 1 )
100 set attackTwilight to 0
101 ;MessageBox "reset twilight attack" "ok"
102 endif
103
104 Return
105
106; if dremora is following player
107elseif ( control < 10 )
108
109 ; every time the player moves through a cell transition
110 if ( CellChanged )
111
112 ; if we left Tur Julan, fight player
113 if ( GetPCCell "Tur Julan" == 0 )
114 set fightPC to 1
115 ;MessageBox "triggered out of tj forcegreet" "ok"
116 set forceGreet to 1
117 Return
118
119 ; if we're outside, but too high, fight player and assume fleeing
120 elseif ( GetInterior == 0 )
121 if ( player->GetPos z > 6850 )
122 set fightPC to 1
123 set fleePC to 1
124 ;MessageBox "triggered height forcegreet" "ok"
125 set forceGreet to 1
126 endif
127 Return
128
129 ; if we're in a forbidden cell, fight player
130 elseif ( GetPCCell "Tur Julan, Black Hand Hall" )
131 set fightPC to 1
132 ;MessageBox "triggered forbidden cell bh forcegreet" "ok"
133 set forceGreet to 1
134 Return
135 elseif ( GetPCCell "Tur Julan, Craftsmen's Hall" )
136 set fightPC to 1
137 ;MessageBox "triggered forbidden cell sp forcegreet" "ok"
138 set forceGreet to 1
139 Return
140 elseif ( GetPCCell "Tur Julan, Crossing of Wings" )
141 set fightPC to 1
142 ;MessageBox "triggered forbidden cell cw forcegreet" "ok"
143 set forceGreet to 1
144 Return
145 elseif ( GetPCCell "Tur Julan, Llathsa House: Statesmen's Hall" )
146 set fightPC to 1
147 ;MessageBox "triggered forbidden cell sh forcegreet" "ok"
148 set forceGreet to 1
149 Return
150
151 ; if too far from the player, implies player left this guy behind earlier - interpret as flee and attack
152 elseif ( GetDistance player > 500 )
153 set fightPC to 1
154 set fleePC to 1
155 set forceGreet to 1
156 ;MessageBox "triggered flee cell return forcegreet" "ok"
157 Return
158
159 ; else increment control, Dremora gets more and more bored
160 else
161 set control to ( control + 1 )
162 endif
163 endif
164
165 ; if too far away in any other interior (except prison) interpret as fleeing, fight
166 if ( fleePC == 0 )
167 if ( GetPCCell "Tur Julan, Warrior's Hall: Prison" == 0 )
168 if ( GetDistance player > 1000 )
169 set fightPC to 1
170 set fleePC to 1
171 ;MessageBox "triggered distance flee forcegreet" "ok"
172 set forceGreet to 1
173 Return
174 endif
175 endif
176 endif
177
178 ; if attacking a Winged Twilight, attack player
179 if ( attackTwilight == 1 )
180 set forceGreet to 1
181 ;MessageBox "triggered twilight attack forcegreet" "ok"
182 set fightPC to 1
183 ; disengage Twilight
184 StopCombat
185 ; stop following the player
186 AIWander, 200, 0, 0, 0, 30, 0, 10, 10, 30, 0, 20, 0
187 Return
188 endif
189
190 ; if we kill the spider...
191 if ( foughtSpider == 1 )
192 set foughtSpider to 2
193 set forceGreet to 1
194 ;MessageBox "triggered spider death forcegreet" "ok"
195 Return
196 endif
197
198 ; if we meet the Ogrim, and Ogrim is still alive, get ready to rumble
199 if ( TR_m4_TJ_OgrimStatus < 2 )
200 if ( GetDistance TR_m4_TJ_Ogrim < 1500 )
201 set control to 20
202 AIWander, 200, 0, 0, 0, 30, 0, 10, 10, 30, 0, 20, 0
203 set forcegreet to 1
204 ;MessageBox "triggered ogrim fight forcegreet" "ok"
205 Return
206 endif
207 endif
208
209; if followed player for too long, bored, attack
210elseif ( control == 10 )
211 set fightPC to 1
212 ;MessageBox "triggered bored forcegreet" "ok"
213 set forceGreet to 1
214 Return
215
216; we're fighting Ogrims now!
217elseif ( control == 20 )
218 ; end this sequence and start fighting
219 set control to 21
220 set TR_m4_TJ_Ogrim.duelStart to 1
221 StartCombat TR_m4_TJ_Ogrim
222
223endif
224
225End