-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathZSCRIPT.zsc
333 lines (282 loc) · 8.37 KB
/
ZSCRIPT.zsc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
version "4.6"
#include "ZScript/FollowerWeapon.zsc"
#include "ZScript/FollowerHandler.zsc"
#include "ZScript/CommandMenu.zsc"
#include "ZScript/Inventory.zsc"
#include "ZScript/Management.zsc"
#include "ZScript/Ohana.zsc"
#include "ZScript/Recruitment.zsc"
#include "ZScript/Data.zsc"
#include "ZScript/GeneralStates.zsc"
#include "ZScript/Resurrection.zsc"
#include "ZScript/Wearables.zsc"
#include "ZScript/Medical.zsc"
#include "ZScript/Weapons.zsc"
#include "ZScript/AI.zsc"
#include "ZScript/Goals.zsc"
#include "ZScript/Orders.zsc"
#include "ZScript/Stance.zsc"
#include "ZScript/Targeting.zsc"
#include "ZScript/Brass.zsc"
#include "ZScript/Loadout.zsc"
#include "ZScript/Messages.zsc"
#include "ZScript/Followers/Freylis.zsc"
#include "ZScript/Followers/Balthazar.zsc"
#include "ZScript/Followers/Valnos.zsc"
#include "ZScript/Followers/Daina.zsc"
#include "ZScript/Followers/Sewie.zsc"
#include "ZScript/Followers/Nari.zsc"
// [Ace] Needs to be last or else it messes with the Enabled check in the creation loop in FollowerHandler::WorldLoaded().
#include "ZScript/Followers/RecruitedMarine.zsc"
class HDFollower : HDHumanoid abstract
{
enum FollowerDebugLevel
{
FDebug_Weapons = 1,
FDebug_Reloading = 2,
FDebug_Aiming = 4,
FDebug_Targeting = 8,
FDebug_Inventory = 16,
FDebug_Status = 32,
FDebug_Ohana = 64,
}
// --------------------------------------------------
// VIRTUALS
// --------------------------------------------------
override void Die(Actor source, Actor inflictor, int dmgflags, Name mod)
{
OhanaTicker = 0;
Super.Die(source, inflictor, dmgflags, mod);
}
// --------------------------------------------------
// ACTIONS
// --------------------------------------------------
void ChangeLinkedPlayer(HDPlayerPawn plr)
{
LinkedPlayer = plr;
master = plr; // [Ace] War Trophies compatibility.
}
void WarpToPlayer()
{
Warp(LinkedPlayer, 16, flags: WARPF_NOCHECKPOSITION);
}
// --------------------------------------------------
// INFORMATION
// --------------------------------------------------
private HDBleedingWound GetBleedThinker()
{
ThinkerIterator it = ThinkerIterator.Create("HDBleedingWound", STAT_DEFAULT);
HDBleedingWound BleedThinker;
while ((BleedThinker = HDBleedingWound(it.Next())))
{
if (BleedThinker.bleeder == self)
{
return BleedThinker;
}
}
return BleedThinker;
}
clearscope bool CanInteractWith(bool validIfDead = true)
{
return Health > 0 && bFRIENDLY || Health <= 0 && validIfDead;
}
// [Ace] Probably a bit counter-intuitive to return 0 for success.
clearscope int CanReach(double dist, bool ignoreAngle = false)
{
if (DistanceToPlayer > radius + dist)
{
return 1;
}
if (!IsFacedByPlayer() && !ignoreAngle)
{
return 2;
}
return 0;
}
// [Ace] These are relative to the follower. 0 means facing/moving directly towards the follower.
clearscope double GetPlayerFacingAngle()
{
double PAngle = LinkedPlayer.angle;
double PAngleTo = LinkedPlayer.AngleTo(self);
return AbsAngle(PAngle, PAngleTo);
}
clearscope double GetPlayerMovementAngle()
{
double pMovAngle = VectorAngle(LinkedPlayer.vel.x, LinkedPlayer.vel.y);
double pAngTo = LinkedPlayer.AngleTo(self);
return AbsAngle(pMovAngle, pAngTo);
}
override string GetObituary(Actor victim, Actor inflictor, Name mod, bool playerattack)
{
return String.Format("$FLW_OBTFRIENDLY", HDPlayerPawn(victim).player.GetUserName(), inflictor.target ? HDFollower(inflictor.target).GetTag() : inflictor.GetTag());
}
clearscope string GetPronoun(bool upper)
{
// [Ace] Personal pronouns, objective case, third person singular.
switch (Gender)
{
case GENDER_MALE: return upper ? StringTable.Localize("$FLW_HIMU") : StringTable.Localize("$FLW_HIM");
case GENDER_FEMALE: return upper ? StringTable.Localize("$FLW_HERU") : StringTable.Localize("$FLW_HER");
case GENDER_NEUTRAL: return upper ? StringTable.Localize("$FLW_ITU") : StringTable.Localize("$FLW_IT");
case GENDER_OTHER: return upper ? StringTable.Localize("$FLW_THEMU") : StringTable.Localize("$FLW_THEM");
}
return "??????";
}
clearscope string GetTimestamp()
{
return String.Format("%s:%02d", level.TimeFormatted(), level.time % 35);
}
clearscope bool IsDeadOrMissing()
{
if (!LinkedPlayer)
{
return true;
}
bool FollowerDead = Health <= 0;
bool TooFar = Distance3D(LinkedPlayer) > HDCONST_ONEMETRE * 15;
return TooFar || FollowerDead;
}
clearscope bool IsFacedByPlayer()
{
return GetPlayerFacingAngle() <= MaxFaceAngle;
}
clearscope bool PlayerIsCrouching()
{
return LinkedPlayer.player.crouchfactor < 0.6;
}
clearscope bool PlayerIsProne()
{
return LinkedPlayer.incapacitated > 0 && LinkedPlayer.incaptimer <= 0;
}
// --------------------------------------------------
// TICKER
// --------------------------------------------------
override void Tick()
{
if (IsFrozen())
{
return;
}
Super.Tick();
if(DodgeTimer>0)DodgeTimer--;
// [Ace] It's possible for LinkedPlayer to become null if the attached player leaves the game. In that case, automatically assign it to the first non-null player.
if (!LinkedPlayer)
{
for (int i = 0; i < MAXPLAYERS; ++i)
{
if (players[i].mo)
{
ChangeLinkedPlayer(HDPlayerPawn(players[i].mo));
break;
}
}
}
if (!LinkedPlayer || bFRIENDLY && Health > 0 && LinkedPlayer.Health <= 0) // [Ace] If LinkedPlayer ever goes null, something is horribly wrong.
{
return;
}
CanSeePlayer = CheckSight(LinkedPlayer, SF_ALL);
DistanceToPlayer = Distance3D(LinkedPlayer);
CheckOhana();
// [Ace] Only tick timer if idling.
if (!Moving)
{
CommentTimer--;
}
// InventoryThink();
if (Health > 0)
{
if(ReloadCoolDown>0)ReloadCoolDown--;
if(MissPlayer>0 && DistanceToPlayer > 500)MissPlayer--;
//if(MissPlayer>0)Console.Printf("MissPlr "..MissPlayer);
AiThink();
if (GetAge() % 35 * 2 == 0 && Bloodloss > 0)
{
Bloodloss--;
}
}
}
// --------------------------------------------------
// INITIALIZATION
// --------------------------------------------------
override void BeginPlay()
{
Handler = FollowerHandler(EventHandler.Find('FollowerHandler'));
Super.BeginPlay();
}
override void PostBeginPlay()
{
ResetCommentTimer();
// [Ace] Skip HDMobMan's PostBeginPlay because the Resize call in it has A_SetHealth which fucks shit up.
HDMobBase.PostBeginPlay();
// [Ace] I gotta defer setting these until after Super.PostBeginPlay() is called or else picking up the incapped follower and placing them again heals them partially.
Bloodloss = NewBloodloss;
BodyDamage = NewBodyDamage;
Stunned = NewStunned;
}
// --------------------------------------------------
// CONSTANTS/VARIABLES
// --------------------------------------------------
const MaxFaceAngle = 35;
const MaxMovementAngle = 50;
FollowerHandler Handler;
protected double MovementSpeed;
protected meta double MaxMovementSpeed;
property MovementSpeed: MovementSpeed, MaxMovementSpeed;
meta int ResurrectType;
property ResurrectType: ResurrectType;
uint Squad;
uint Index;
int Gender;
meta class<FollowerBody> DataClass;
meta class<LeftBehindFollower> MissingClass; // [Ace] If this is null, assume follower is non-essential. Like marines.
property FollowerInfo: Gender, DataClass, MissingClass;
private int BehaviourFlags;
flagdef Silent: BehaviourFlags, 0;
flagdef CanDismiss: BehaviourFlags, 1;
String UnLocalizeTag;
property UnLocalizeTag : UnLocalizeTag;
int ReloadCoolDown;
property ReloadCoolDown : ReloadCoolDown;
int MissPlayer;
property MissPlayer : MissPlayer;
int DodgeTimer;
Default
{
Health 200;
Radius 12;
Height 52;
HDFollower.MovementSpeed 3, 8;
PainChance 192;
MaxStepHeight 80;
MaxDropOffHeight 192;
MaxTargetRange HDCONST_ONEMETRE * 80;
ReactionTime 8;
HDFollower.ReloadCoolDown 70;
HDFollower.MissPlayer 70;
+ROLLCENTER
+ROLLSPRITE
+FRIENDLY
+NODAMAGETHRUST
+SLIDESONWALLS
+NODROPOFF
+NOBLOCKMONST
+NOTELESTOMP
-NOTELEPORT
+NOTELEFRAG // [Ace] Because starting levels can telefrag the followers in multiplayer if there isn't enough space.
+BLOCKASPLAYER
+NOTRIGGER
+SEEINVISIBLE
+BOSSDEATH
+NOFEAR
+THRUSPECIES
+DONTTRANSLATE
-COUNTKILL
HDMobBase.DownedFrame 16;
HDMobBase.MaxBloodLoss 400;
Species 'HDFollower';
HDFollower.ResurrectType RESF_ALL;
HDFollower.UnLocalizeTag "";
}
}
class LeftBehindFollower : Inventory abstract { Default { +INVENTORY.UNDROPPABLE } }