TR_m1_Q59_MaI_Script_4
TR_Mainland.esm
Variables
18
Local Variables
looking
NoLore
DoOnce
state1
randtime
testvar
comstate
TR_Map
T_Local_NPC
T_Local_NoLore
timer
timer2
PCx
PCy
PCtheta
Sx
Sy
ratio
Source
1Begin TR_m1_Q59_MaI_Script_4
2
3;This is the script on the Odrethi slave.
4;Is slave looking at PC part of script taken partly from MWSD.
5
6short looking
7short NoLore
8short DoOnce
9short state1
10short randtime
11short testvar
12short comstate
13short TR_Map
14float timer
15float timer2
16float PCx
17float PCy
18float PCtheta
19float Sx
20float Sy
21float ratio
22short T_Local_NPC
23short T_Local_NoLore
24
25if ( GetDisabled )
26 Return
27endif
28
29If ( MenuMode )
30 Return
31endif
32
33if ( TR_Map != 1 )
34 set TR_Map to 1
35endif
36
37if ( comstate == -1 )
38 if ( CellChanged )
39 Disable
40 else
41 Return
42 endif
43endif
44
45if ( GetJournalIndex "TR_m1_PT_MaI_4" >= 10 )
46 if ( GetJournalIndex "TR_m1_PT_MaI_4" < 100 )
47 set comstate to ( GetEffect sEffectCommandHumanoids )
48 endif
49endif
50
51if ( GetJournalIndex "TR_m1_PT_MaI_4" == 100 )
52 set comstate to -1
53elseif ( GetJournalIndex "TR_m1_PT_MaI_4" == 110 )
54 set comstate to -1
55endif
56
57if ( GetJournalIndex "TR_m1_PT_MaI_3" < 10 )
58 Return
59elseif ( GetJournalIndex "TR_m1_PT_MaI_3" >= 30 )
60 Return
61endif
62
63set timer to ( timer + GetSecondsPassed )
64set timer2 to ( timer2 + GetSecondsPassed )
65
66if ( timer2 > randtime )
67 if ( state1 == 0 )
68 set randtime to ( Random 41 )
69 Face 3390 4234
70 set PCtheta to -80
71 elseif ( state1 == 1 )
72 set randtime to ( Random 31 )
73 Face 3494 4324
74 set PCtheta to 10
75 elseif ( state1 == 2 )
76 set randtime to ( Random 11 )
77 Face 3567 4277
78 set PCtheta to 40
79 else
80 set randtime to ( Random 21 )
81 Face 3604 4149
82 set PCtheta to 145
83 endif
84 set state1 to ( Random 4 )
85 set randtime to ( randtime + 4 )
86 set timer2 to 0
87endif
88
89set testvar to ( Player->GetArmorType 5 )
90
91if ( GetJournalIndex "TR_m1_PT_MaI_3" < 20 )
92 if ( GetDistance Player <= 256 )
93 if ( getLOS player )
94 if ( testvar != -1 )
95 set DoOnce to -1
96 ForceGreeting
97 return
98 elseif ( GetPCSneaking != 1 )
99 set DoOnce to -1
100 ForceGreeting
101 return
102 endif
103 endif
104 endif
105endif
106
107if ( timer < 3 )
108 Return
109endif
110
111set timer to 0
112set looking to 1
113
114if ( Player->GetInvisible )
115 set looking to 0
116elseif ( Player->GetChameleon >= 85 )
117 set looking to 0
118elseif ( GetDistance Player > 512 )
119 set looking to 0
120else
121 set PCx to ( GetPos X )
122 set PCy to ( GetPos Y )
123 set PCtheta to ( Player->GetAngle Z )
124 set Sy to ( Player->GetPos X )
125 set Sy to ( Player->GetPos Y )
126 set Sx to ( Sx - PCx )
127 set Sy to ( Sy - PCy )
128 if ( Sy > 0.05 )
129 set ratio to ( Sx / Sy )
130 elseif ( Sy < -0.05 )
131 set ratio to ( Sx / Sy )
132 else
133 return
134 endif
135 ; MessageBox "Sx == %.3f Sy == %.3f ratio == %.3f PCtheta == %.3f" Sx Sy ratio PCtheta
136 if ( Sx > 0 )
137 if ( Sy > 0 )
138 if ( ratio > 1 )
139 if ( PCtheta < -45 )
140 set looking to 0
141 endif
142 else
143 if ( PCtheta < -90 )
144 set looking to 0
145 endif
146 if ( PCtheta > 135 )
147 set looking to 0
148 endif
149 endif
150 else
151 if ( ratio < -1 )
152 if ( PCtheta < 0 )
153 if ( PCtheta > -135 )
154 set looking to 0
155 endif
156 endif
157 else
158 if ( PCtheta < 45 )
159 if ( PCtheta > -90 )
160 set looking to 0
161 endif
162 endif
163 endif
164 endif
165 else
166 if ( Sy > 0 )
167 if ( ratio < -1 )
168 if ( PCtheta > 45 )
169 set looking to 0
170 endif
171 else
172 if ( PCtheta > 90 )
173 set looking to 0
174 endif
175 if ( PCtheta < -135 )
176 set looking to 0
177 endif
178 endif
179 else
180 if ( ratio > 1 )
181 if ( PCtheta > 0 )
182 if ( PCtheta < 135 )
183 set looking to 0
184 endif
185 endif
186 else
187 if ( PCtheta > -45 )
188 if ( PCtheta < 90 )
189 set looking to 0
190 endif
191 endif
192 endif
193 endif
194 endif
195endif
196
197if ( looking == 1 )
198 if ( GetDetected Player )
199 if ( getLOS player )
200 set DoOnce to -2
201 ForceGreeting
202 endif
203 endif
204endif
205
206end