TR_m1_M_Rilki_sc
TR_Mainland.esm
Variables
15
Local Variables
companion
noLore
noHello
control
controlQ
TR_Map
T_Local_NPC
T_Local_NoLore
TR_Merc
timer
ftemp
xPos
yPos
zPos
minimumProfit
Source
1Begin TR_m1_M_Rilki_sc
2
3;Local script on NPC TR_m1_M_Rilki
4;---
5;Original template by Greatness7
6;Companion should keep up with the player
7;---
8;control 0 - initial state, NPC at regrouping point (Nivalis, outside the Black Ogre Tavern)
9;control 1 - NPC has left regrouping point
10;control 2 - NPC is to regroup back at regrouping point
11;---
12;TR_Merc -1 = Available for hire after contract ran out
13;TR_Merc 0 = Available for hire first time
14;TR_Merc 1 = Currently hired
15;TR_Merc 2 = Not hirable (player took their profit)
16;---
17
18short companion
19short noLore
20short noHello
21
22short control ;set via dialogue
23short controlQ ;unused
24short TR_Map
25short T_Local_NPC
26short T_Local_NoLore
27
28float timer
29float ftemp
30float xPos
31float yPos
32float zPos
33
34short TR_Merc
35float minimumProfit
36
37if ( OnDeath )
38 if ( ScriptRunning TR_m1_M_Rilki_Glb_sc )
39 StopScript TR_m1_M_Rilki_Glb_sc
40 endif
41 if ( ScriptRunning TR_m1_M_Rilki_Move_sc )
42 StopScript TR_m1_M_Rilki_Move_sc
43 endif
44endif
45
46if ( MenuMode )
47 Return
48endif
49
50set timer to ( timer + GetSecondsPassed )
51if ( timer < 0.1 )
52 return
53endif
54set timer to 0
55
56if ( TR_Merc == 1 )
57 if ( minimumProfit < 0 )
58 AIWander 0 0 0 0 20 10 0 20 10 0 0 10
59 set companion to 0
60 StopScript TR_m1_M_Rilki_Glb_sc
61 StartScript TR_m1_M_Rilki_Move_sc
62 ForceGreeting
63 return
64 endif
65 if ( GetPCCell "Nivalis" )
66 if ( ScriptRunning TR_m1_M_Rilki_Move_sc == 0 )
67 set control to 0
68 endif
69 elseif ( control == 0 )
70 set control to 1
71 endif
72endif
73
74if ( GetCurrentAIPackage != 3 )
75 return
76endif
77
78; detect combat
79if ( GetSpellReadied != GetWeaponDrawn )
80 set ftemp to ( ftemp + 1 )
81
82 ; remove bonus speed
83 if ( GetSpeed > 100 )
84 SetSpeed 100
85 endif
86
87 ; detect combat action
88 if ( GetSoundPlaying "Weapon Swish" )
89 elseif ( GetSoundPlaying CrossbowShoot )
90 elseif ( GetSoundPlaying BowShoot )
91 elseif ( ftemp < 40 )
92 return
93 else ; break combat
94 set timer to -1
95 AddItem "iron dagger" 1
96 Equip "iron dagger"
97 RemoveItem "iron dagger" 1
98 endif
99
100 set ftemp to 0
101 return
102endif
103
104; water walking aka effect 2
105if ( Player->GetEffect sEffectWaterWalking )
106 if ( GetEffect sEffectWaterWalking == 0 )
107 ExplodeSpell TR_Follow_WW_Fake
108 AddSpell TR_Follow_WW_Real
109 endif
110elseif ( GetEffect sEffectWaterWalking )
111 RemoveSpell TR_Follow_WW_Real
112 RemoveEffects 2
113endif
114
115; levitation aka effect 10
116if ( Player->GetEffect sEffectLevitate )
117 if ( GetEffect sEffectLevitate == 0 )
118 ExplodeSpell TR_Follow_LV_Fake
119 AddSpell TR_Follow_LV_Real
120 else ; align height to pc
121 set zPos to ( Player->GetPos z )
122 SetPos z zPos
123 endif
124elseif ( GetEffect sEffectLevitate )
125 RemoveSpell TR_Follow_LV_Real
126 RemoveEffects 10
127endif
128
129; sneaking
130if ( GetPCSneaking )
131 ForceSneak
132else
133 ClearForceSneak
134endif
135
136; distance warp
137set ftemp to ( GetDistance Player )
138
139if ( ftemp < 300 )
140 ClearForceRun
141 SetSpeed 40
142elseif ( ftemp < 900 )
143 set ftemp to ( Player->GetSpeed ) * 2.25
144 SetSpeed ftemp
145else ; warp behind pc
146 set zPos to ( Player->GetAngle z )
147 if ( zPos <= -135 )
148 set xPos to -1
149 set yPos to -2
150 elseif ( zPos <= -90 )
151 set xPos to -2
152 set yPos to -1
153 elseif ( zPos <= -45 )
154 set xPos to -2
155 set yPos to 1
156 elseif ( zPos <= 0 )
157 set xPos to -1
158 set yPos to 2
159 elseif ( zPos <= 45 )
160 set xPos to 1
161 set yPos to 2
162 elseif ( zPos <= 90 )
163 set xPos to 2
164 set yPos to 1
165 elseif ( zPos <= 135 )
166 set xPos to 2
167 set yPos to -1
168 else
169 set xPos to 1
170 set yPos to -2
171 endif
172
173 set xPos to ( Player->GetPos x ) - ( xPos * 20 )
174 set yPos to ( Player->GetPos y ) - ( yPos * 20 )
175 set zPos to ( Player->GetPos z )
176
177 SetPos x xPos
178 SetPos y yPos
179 SetPos z zPos
180
181 AiFollow Player 0 0 0 0
182 ForceRun
183endif
184
185set ftemp to 0
186
187if ( TR_Map == 0 )
188 set TR_Map to 1
189endif
190
191End