TR_m4_VethaLlathsa_sc
TR_Mainland.esm
Variables
11
Local Variables
control
controlQ
nolore
T_Local_NoLore
TR_Map
T_Local_NPC
doonce
ftemp
xPos
yPos
zPos
Source
1begin TR_m4_VethaLlathsa_sc
2
3;uses elements of Follower template by Greatness7
4;Companion should keep up with the player
5
6short control
7short controlQ
8short nolore
9short T_Local_NoLore
10short TR_Map
11short T_Local_NPC
12short doonce
13
14float ftemp
15float xPos
16float yPos
17float zPos
18; global TR_m4_VethaLlathsa_sum_glb
19
20if ( menumode )
21 return
22endif
23
24if ( OnDeath )
25 set TR_m4_VethaLlathsa_sum_glb to 0
26 if ( GetJournalIndex TR_m4_TJ_MT_1 < 100 )
27 Resurrect
28 PlaceAtMe "T_Glb_Var_GhostDeathFX1" 1 0 0
29 PlaySound3D "conjuration hit"
30 endif
31endif
32
33if ( GetJournalIndex TR_m4_TJ_MT_1 < 100 )
34 return
35endif
36
37if ( OnActivate )
38 return
39endif
40
41if ( control == 0 )
42 AIFollow player 0 0 0 0
43 PlaySound3D "conjuration hit"
44 PlaceAtMe "T_Glb_Var_GhostDeathFX1" 1 0 0
45 set control to 1
46endif
47
48if ( TR_m4_VethaLlathsa_sum_glb == 0 )
49 if ( doonce == 0 )
50 PlaceAtMe "T_Glb_Var_GhostDeathFX1" 1 0 0
51 PlaySound3D "conjuration hit"
52 set doonce to 1
53 endif
54 disable
55 setdelete 1
56endif
57
58; detect combat
59if ( GetSpellReadied != GetWeaponDrawn )
60 set ftemp to ( ftemp + 1 )
61
62 ; remove bonus speed
63 if ( GetSpeed > 100 )
64 SetSpeed 100
65 endif
66
67 ; detect combat action
68 if ( GetSoundPlaying "Weapon Swish" )
69 elseif ( GetSoundPlaying CrossbowShoot )
70 elseif ( GetSoundPlaying BowShoot )
71 elseif ( ftemp < 40 )
72 return
73 else ; break combat
74 AddItem "iron dagger" 1
75 Equip "iron dagger"
76 RemoveItem "iron dagger" 1
77 endif
78
79 set ftemp to 0
80 return
81endif
82
83; water walking aka effect 2
84if ( Player->GetEffect sEffectWaterWalking )
85 if ( GetEffect sEffectWaterWalking == 0 )
86 AddSpell TR_Follow_WW_Real
87 endif
88elseif ( GetEffect sEffectWaterWalking )
89 RemoveSpell TR_Follow_WW_Real
90 RemoveEffects 2
91endif
92
93; levitation aka effect 10
94if ( Player->GetEffect sEffectLevitate )
95 if ( GetEffect sEffectLevitate == 0 )
96 AddSpell TR_Follow_LV_Real
97 else ; align height to pc
98 set zPos to ( Player->GetPos z )
99 SetPos z zPos
100 endif
101elseif ( GetEffect sEffectLevitate )
102 RemoveSpell TR_Follow_LV_Real
103 RemoveEffects 10
104endif
105
106; sneaking
107if ( GetPCSneaking )
108 ForceSneak
109else
110 ClearForceSneak
111endif
112
113; distance warp
114set ftemp to ( GetDistance Player )
115
116if ( ftemp < 300 )
117 ClearForceRun
118 SetSpeed 40
119elseif ( ftemp < 900 )
120 set ftemp to ( Player->GetSpeed ) * 2.25
121 SetSpeed ftemp
122else ; warp behind pc
123 set zPos to ( Player->GetAngle z )
124 if ( zPos <= -135 )
125 set xPos to -1
126 set yPos to -2
127 elseif ( zPos <= -90 )
128 set xPos to -2
129 set yPos to -1
130 elseif ( zPos <= -45 )
131 set xPos to -2
132 set yPos to 1
133 elseif ( zPos <= 0 )
134 set xPos to -1
135 set yPos to 2
136 elseif ( zPos <= 45 )
137 set xPos to 1
138 set yPos to 2
139 elseif ( zPos <= 90 )
140 set xPos to 2
141 set yPos to 1
142 elseif ( zPos <= 135 )
143 set xPos to 2
144 set yPos to -1
145 else
146 set xPos to 1
147 set yPos to -2
148 endif
149
150 set xPos to ( Player->GetPos x ) - ( xPos * 20 )
151 set yPos to ( Player->GetPos y ) - ( yPos * 20 )
152 set zPos to ( Player->GetPos z )
153
154 SetPos x xPos
155 SetPos y yPos
156 SetPos z zPos
157
158 AiFollow Player 0 0 0 0
159 ForceRun
160endif
161
162set ftemp to 0
163
164if ( TR_Map == 0 )
165 set TR_Map to 3
166endif
167
168
169end