-
Notifications
You must be signed in to change notification settings - Fork 1
/
hpbar.acs
635 lines (517 loc) · 20.8 KB
/
hpbar.acs
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
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
#library "hpbar"
#include "zcommon.acs"
#define STYLE_FULL 1
#define STYLE_MINIMAL 2
#define FULL_HUD_WIDTH 800
#define FULL_HUD_HEIGHT 600
#define FULL_HOLDTIME 0.25
#define FULL_HPBAR_X 400.0
#define FULL_HPBAR_Y 40.0
#define FULL_NAME_Y (FULL_HPBAR_Y + 25.0)
#define FULL_INFO_Y (FULL_NAME_Y + 12.0)
#define MINIMAL_HUD_WIDTH 1280
#define MINIMAL_HUD_HEIGHT 960
#define MINIMAL_HOLDTIME ((1.0 / 35) + 1)
#define MINIMAL_FADETIME 0.1
#define MINIMAL_HP_X 640.0
#define MINIMAL_HP_Y 500.0
script "hpbar-enter" enter {
if (GetCVar("hpbar_rekt")) SetThingSpecial(0, ACS_ExecuteAlways, 31241, 0, PlayerNumber());
while (true) {
ACS_ExecuteAlways(31233, 0);
delay(1);
}
}
script 31233 (void) {
int pn = PlayerNumber();
if (is_zan3()) {
int old_tid = PickActor(0, GetActorAngle(0), GetActorPitch(0), 8192.0, 0, MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, PICKAF_RETURNTID);
int new_tid = UniqueTID();
if (PickActor(0, GetActorAngle(0), GetActorPitch(0), 8192.0, new_tid, MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, PICKAF_FORCETID)) {
SetActivator(new_tid);
common31233(pn);
Thing_ChangeTID(new_tid, old_tid);
}
} else {
if (SetActivatorToTarget(0)) {
common31233(pn);
}
}
}
function void common31233(int pn) {
int hp = GetActorProperty(0, APROP_Health);
int max_hp = GetActorProperty(0, APROP_SpawnHealth);
if (max_hp <= 0) max_hp = hp;
if (max_hp > 0) {
if (max_hp >= GetCVar("hpbar_threshold")) {
SetCVarString(strparam(s: "hpbar_target_name", d: pn), get_actor_name(0));
ACS_ExecuteAlways(31234, 0, pn, hp, max_hp);
}
if (GetCVar("hpbar_tracker")) {
ACS_ExecuteAlways(31235, 0, false);
}
}
}
script 31234 (int player, int hp, int max_hp) clientside {
if (ConsolePlayerNumber() != player) terminate;
int hp_percentage = hp * 100 / max_hp;
str name = GetCVarString(strparam(s: "hpbar_target_name", d: ConsolePlayerNumber()));
bool invul = get_actor_invul(0);
bool friendly = GetActorProperty(0, APROP_Friendly);
if (friendly && !get_my_user_cvar("hpbar_show_friendly")) terminate;
int style = get_my_user_cvar("hpbar_style");
if (style == STYLE_FULL) {
show_full_hpbar(hp, max_hp, hp_percentage, name, invul, friendly);
} else if (style == STYLE_MINIMAL) {
show_minimal_hpbar(hp_percentage);
}
}
function void show_full_hpbar(int hp, int max_hp, int hp_percentage, str name, bool invul, bool friendly) {
SetHudSize(FULL_HUD_WIDTH, FULL_HUD_HEIGHT, true);
SetFont("NORMAL");
HudMessageBold(d: hp, s: " / ", d: max_hp, s: " (", d: hp_percentage, s: "%)";
HUDMSG_FADEOUT, 6000, CR_WHITE, FULL_HPBAR_X, FULL_HPBAR_Y, FULL_HOLDTIME);
if (hp_percentage < 25)
SetFont("FILLCRIT");
else if (hp_percentage < 50)
SetFont("FILLDAMG");
else
SetFont("FILLNORM");
for (int i = 0; i <= 100 && i <= hp_percentage; ++i) {
HudMessageBold(s: "A"; HUDMSG_FADEOUT , 6001 + i, CR_UNTRANSLATED, FULL_HPBAR_X - 97.0 + to_fixed(i * 2), FULL_HPBAR_Y, FULL_HOLDTIME);
}
SetFont("HPBAR");
HudMessageBold(s: "A"; HUDMSG_FADEOUT, 6102, CR_UNTRANSLATED, FULL_HPBAR_X, FULL_HPBAR_Y, FULL_HOLDTIME);
SetFont("NORMAL");
HudMessageBold(s: name; HUDMSG_FADEOUT, 6103, CR_WHITE, FULL_HPBAR_X, FULL_NAME_Y, FULL_HOLDTIME);
int ln = 0;
if (invul) {
HudMessageBold(s: "\c[i8]Invulnerable\c-"; HUDMSG_FADEOUT, 6104 + ln, CR_WHITE, FULL_HPBAR_X, FULL_INFO_Y + to_fixed(ln * 10), FULL_HOLDTIME);
++ln;
}
if (friendly) {
HudMessageBold(s: "\c[x5]Friendly\c-"; HUDMSG_FADEOUT, 6104 + ln, CR_WHITE, FULL_HPBAR_X, FULL_INFO_Y + to_fixed(ln * 10), FULL_HOLDTIME);
++ln;
}
}
function str hpp_to_color(int p) {
if (p >= 100)
return "\c[x5]";
else if (p >= 75)
return "\c[a6]";
else if (p >= 50)
return "\ck";
else if (p >= 25)
return "\c[o4]";
return "\cr";
}
function void show_minimal_hpbar(int hp_percentage) {
SetHudSize(MINIMAL_HUD_WIDTH, MINIMAL_HUD_HEIGHT, false);
SetFont("NORMAL");
HudMessageBold(s: hpp_to_color(hp_percentage), d: hp_percentage, s: "%\c-";
HUDMSG_FADEOUT, 6000, CR_UNTRANSLATED, MINIMAL_HP_X, MINIMAL_HP_Y, MINIMAL_HOLDTIME, MINIMAL_FADETIME);
}
#define MAX_TRACKERS 32
#define NUM_RANKINGS 10
// This should be -1, but Zandronum 2.1.2 has a bug where ACS_ExecuteAlways would send -1 as 255! WTF?!!!
#define INVALID_TID (-129)
int tracked_tids[MAX_TRACKERS];
int tracked_hps[MAX_TRACKERS];
int tracked_max_hps[MAX_TRACKERS];
bool tracked_invul[MAX_TRACKERS];
bool tracked_reflect[MAX_TRACKERS];
int tracked_kills[MAX_TRACKERS];
script "hpbar-open" open {
// Hack for broken open clientside script in Zandronum v3.0-alpha-r160814.
// See: https://zandronum.com/tracker/view.php?id=2884
ACS_Execute(31240, 0);
for (int i = 0; i < MAX_TRACKERS; ++i) {
tracked_tids[i] = INVALID_TID;
}
}
script 31235 (int force_track) {
// We only track monsters. :)
if (!(ClassifyActor(0) & ACTOR_MONSTER)) terminate;
// Should we track it?
if (!force_track && !should_track(0)) terminate;
// Give it a new TID if it doesn't have one.
int tid = ActivatorTID();
if (tid == 0) {
tid = UniqueTID(0, 0);
Thing_ChangeTID(0, tid);
}
// Find an empty slot for this monster and check if it is already tracked.
int i;
for (int j = MAX_TRACKERS - 1; j >= 0; --j) {
if (tracked_tids[j] == tid) {
terminate; // already tracked by another script
} else if (tracked_tids[j] == INVALID_TID) {
i = j;
}
}
// Add tid to the slot and tell clients to track this activator.
tracked_tids[i] = tid;
ACS_ExecuteAlways(31236, 0, i, tracked_tids[i]);
tracked_max_hps[i] = GetActorProperty(0, APROP_SpawnHealth);
str name_cvar = strparam(s: "hpbar_tracked_names", d: i);
// Keep updating clients the HP and name of the monster while it is alive.
while (ClassifyActor(0) & ACTOR_ALIVE) {
// Send monster HP
int old_hp = tracked_hps[i];
int old_kills = tracked_kills[i];
tracked_hps[i] = GetActorProperty(0, APROP_Health);
tracked_kills[i] = CheckInventory("MonsterScore");
if (old_hp != tracked_hps[i] || old_kills != tracked_kills[i]) {
ACS_ExecuteAlways(31237, 0, i, tracked_hps[i], tracked_kills[i]);
}
bool old_invul = tracked_invul[i];
tracked_invul[i] = get_actor_invul(0);
if (is_zan3()) {
bool old_reflect = tracked_reflect[i];
tracked_reflect[i] = CheckFlag(0, "REFLECTIVE");
}
if (old_invul != tracked_invul[i] || old_reflect != tracked_reflect[i]) {
ACS_ExecuteAlways(31238, 0, i, tracked_invul[i], tracked_reflect[i]);
}
// Send name of monster
str old_name = GetCVarString(name_cvar);
str name = get_actor_name(0);
if (old_name == 0 || !streq(old_name, name)) {
SetCVarString(name_cvar, name);
}
delay(1);
}
// The monster is dead, remove it from the slot and tell clients to stop tracking it.
tracked_tids[i] = INVALID_TID;
SetCVarString(strparam(s: "hpbar_tracked_names", d: i), "");
ACS_ExecuteAlways(31236, 0, i, INVALID_TID);
}
script 31236 (int i, int tid) clientside {
if (tid == INVALID_TID) {
tracked_tids[i] = tid;
} else {
if (ClassifyActor(0) & ACTOR_ALIVE) {
tracked_tids[i] = tid;
tracked_max_hps[i] = GetActorProperty(0, APROP_SpawnHealth);
} else {
tracked_tids[i] = INVALID_TID;
}
}
}
script 31237 (int i, int hp, int kills) clientside {
tracked_hps[i] = hp;
tracked_kills[i] = kills;
}
script 31238 (int i, int invul, int reflect) clientside {
tracked_invul[i] = invul;
tracked_reflect[i] = reflect;
}
script 31239 (void) net {
for (int i = 0; i < MAX_TRACKERS; ++i) {
int tid = tracked_tids[i];
if (tid != INVALID_TID) {
SetActivator(tid);
SetCVarString(strparam(s: "hpbar_tracked_names", d: i), get_actor_name(0));
ACS_ExecuteAlways(31236, 0, i, tid);
ACS_ExecuteAlways(31237, 0, i, tracked_hps[i], tracked_kills[i]);
ACS_ExecuteAlways(31238, 0, i, tracked_invul[i], tracked_reflect[i]);
}
}
}
function void request_broadcast_tracker_info(void) {
RequestScriptPuke(31239, 0, 0, 0);
}
int maxhp_rankings[NUM_RANKINGS];
function bool already_selected(int x, int n) {
for (int i = 0; i < n; ++i) {
if (x == maxhp_rankings[i]) {
return true;
}
}
return false;
}
function int align_left(int x) {
if (x >= 0) {
return to_fixed(x) + 0.1;
}
return to_fixed(x) - 0.1;
}
function int align_right(int x) {
if (x >= 0) {
return to_fixed(x) + 0.2;
}
return to_fixed(x) - 0.2;
}
#define TRACKER_HUD_WIDTH 1024
#define TRACKER_HUD_HEIGHT 768
script 31240 open clientside {
for (int i = 0; i < MAX_TRACKERS; ++i) {
tracked_tids[i] = INVALID_TID;
}
request_broadcast_tracker_info();
SetHudSize(TRACKER_HUD_WIDTH, TRACKER_HUD_HEIGHT, false);
while (true) {
if (!GetCVar("hpbar_tracker")) { delay(35); continue; }
int x = to_int((GetCVar("hpbar_tracker_x") - 0.5) * GetScreenWidth() / GetScreenHeight() * TRACKER_HUD_HEIGHT) + (TRACKER_HUD_WIDTH / 2);
int y = to_fixed(to_int((GetCVar("hpbar_tracker_y") - 0.5) * GetScreenHeight()) + (TRACKER_HUD_HEIGHT / 2));
for (int rank = 0; rank < NUM_RANKINGS; ++rank) {
int hp_limit = 0;
int maxhp_limit = 0;
maxhp_rankings[rank] = -1;
for (i = 0; i < MAX_TRACKERS; ++i) {
int tid = tracked_tids[i];
if (tid != INVALID_TID) {
if (already_selected(i, rank)) continue;
int max_hp = tracked_max_hps[i];
int hp = tracked_hps[i];
if (max_hp > maxhp_limit) {
maxhp_rankings[rank] = i;
maxhp_limit = max_hp;
hp_limit = hp;
} else if (max_hp == maxhp_limit && hp > hp_limit) {
maxhp_rankings[rank] = i;
hp_limit = hp;
}
}
}
int n = maxhp_rankings[rank];
if (n == -1) break;
hp = tracked_hps[n];
max_hp = tracked_max_hps[n];
int hpp = hp * 100 / max_hp;
str name = GetCVarString(strparam(s: "hpbar_tracked_names", d: n));
HudMessage(s: hpp_to_color(hpp), d: hp, s: "/", d: max_hp, s: "\c-";
HUDMSG_FADEOUT, 7000 + rank, CR_WHITE, align_right(x + 80), y + rank * 12.0, 1.0 / 35 + 1, 0.1);
HudMessage(s: hpp_to_color(hpp), d: hpp, s: "%\c-";
HUDMSG_FADEOUT, 7000 + NUM_RANKINGS + rank, CR_WHITE, align_right(x + 120), y + rank * 12.0, 1.0 / 35 + 1, 0.1);
str statemsg = " ";
if (tracked_reflect[n])
statemsg = strparam(s: statemsg, s: "\c[x5][REFLECT]\c-");
if (tracked_invul[n])
statemsg = strparam(s: statemsg, s: "\c[i8][INVUL]\c-");
str killsmsg = "";
if (GetCVar("hpbar_rekt")) {
int kills = tracked_kills[n];
if (kills == 1) {
killsmsg = " \cm(1 rekt)\c-";
} else if (kills >= 2 && kills < 5) {
killsmsg = strparam(s: " \cr(", d: kills, s: " rekts)\c-");
} else if (kills >= 5 && kills < 10) {
killsmsg = strparam(s: " \cg(", d: kills, s: " rekts)\c-");
} else if (kills >= 10) {
killsmsg = strparam(s: " \c[a6](", d: kills, s: " rekts)\c-");
}
}
HudMessage(s: name, s: killsmsg, s: statemsg;
HUDMSG_FADEOUT, 7000 + NUM_RANKINGS * 2 + rank, CR_WHITE, align_left(x + 132), y + rank * 12.0, 1.0 / 35 + 1, 0.1);
}
delay(1);
}
}
int announcers_playing = 0;
int announcer_priority = -1;
int announcer_id = 0;
bool firstblood = false;
script "hpbar-respawn" respawn {
if (GetCVar("hpbar_rekt")) {
SetThingSpecial(0, ACS_ExecuteAlways, 31241, 0, PlayerNumber());
}
}
script 31241 (int pn) {
if (GetCVar("hpbar_tracker")) ACS_ExecuteAlways(31235, 0, true);
GiveInventory("MonsterScore", 1); // Total score
GiveInventory("MonsterScoreTemporary", 1); // Temporary score
int score = CheckInventory("MonsterScore");
int score_temp = CheckInventory("MonsterScoreTemporary");
ACS_ExecuteAlways(31242, 0, score, score_temp);
if (!firstblood) {
if (PlayerNumber() == pn || ClassifyActor(0) == ACTOR_WORLD) {
int gender = GetPlayerInfo(pn, PLAYERINFO_GENDER);
str killstr = "";
if (gender == 0)
killstr = "Killed himself";
else if (gender == 1)
killstr = "Killed herself";
else
killstr = "Killed itself";
announce(1, "hpbar/firstblood", "\c[d4]FIRST DUMB\c-", strparam(n: pn + 1), killstr);
} else {
announce(1, "hpbar/firstblood", "\c[d4]FIRST BLOOD\c-", get_actor_name(0), "First kill on the map");
}
firstblood = true;
}
// Wait for 5 seconds. If the monster didn't score other kills in the mean time, reset its temporary score.
delay(35 * 5);
if (CheckInventory("MonsterScoreTemporary") == score_temp) {
TakeInventory("MonsterScoreTemporary", score_temp);
}
}
script 31242 (int score, int score_temp) {
if (!(ClassifyActor(0) & ACTOR_MONSTER)) terminate;
str name = get_actor_name(0);
if (score_temp == 2) {
announce(100 + score_temp, "hpbar/doublekill", "\c[d4]DOUBLE KILL\c-", name, "2 consecutive kills");
} else if (score_temp == 3) {
announce(100 + score_temp, "hpbar/multikill", "\c[d4]MULTI KILL\c-", name, "3 consecutive kills");
} else if (score_temp == 4) {
announce(100 + score_temp, "hpbar/megakill", "\c[d4]MEGA KILL\c-", name, "4 consecutive kills");
} else if (score_temp == 5) {
announce(100 + score_temp, "hpbar/ultrakill", "\c[d4]ULTRA KILL\c-", name, "5 consecutive kills");
} else if (score_temp == 6) {
announce(100 + score_temp, "hpbar/monsterkill", "\c[d4]M-M-MONSTER KILL!\c-", name, "6 consecutive kills");
} else if (score_temp == 7) {
announce(100 + score_temp, "hpbar/ludicrouskill", "\c[d4]L U D I C R O U S K I L L !\c-", name, "7 consecutive kills");
} else if (score_temp == 8 || score_temp == 9) {
announce(100 + score_temp, "hpbar/holyshit", "\c[m6]! ! ! H O L Y S H I T ! ! !\c-", name, strparam(d: score_temp, s: " consecutive kills"));
} else if (score_temp >= 10) {
announce(100 + score_temp, "hpbar/sexyholyshit", "\c[m6]! ! ! H O L Y S H I T ! ! !\c-", name, strparam(d: score_temp, s: " consecutive kills"));
}
// Wait until nothing is playing.
while (announcers_playing > 0) delay(1);
// Skip the announcement if the monster has gained another tier during the wait.
if (score == 3 && CheckInventory("MonsterScore") < 5) {
announce(2, "hpbar/killingspree", "\c[l5]KILLING SPREE\c-", name, "3 total kills");
} else if (score == 5 && CheckInventory("MonsterScore") < 8) {
announce(3, "hpbar/rampage", "\c[l5]RAMPAGE\c-", name, "5 total kills");
} else if (score == 8 && CheckInventory("MonsterScore") < 10) {
announce(4, "hpbar/dominating", "\c[d4]DOMINATING\c-", name, "8 total kills");
} else if (score == 10 && CheckInventory("MonsterScore") < 15) {
announce(5, "hpbar/unstoppable", "\c[k9]UNSTOPPABLE\c-", name, "10 total kills");
} else if (score == 15 && CheckInventory("MonsterScore") < 25) {
announce(6, "hpbar/godlike", "\c[k9]G O D L I K E !\c-", name, "15 total kills");
} else if (score == 25) {
announce(7, "hpbar/wickedsick", "\c[n3]W I C K E D S I C K !\c-", name, "25 total kills");
}
}
script 31243 (int announcer_id_) clientside {
if (!get_my_user_cvar("hpbar_announcer")) terminate;
if (GetCVar("hpbar_announcer_id") != announcer_id_) terminate;
str sound = GetCVarString("hpbar_announcer_sound");
str bigtext = GetCVarString("hpbar_announcer_bigtext");
str smalltext = GetCVarString("hpbar_announcer_smalltext");
str tinytext = GetCVarString("hpbar_announcer_tinytext");
StopSound(0, 5);
StopSound(0, 6);
StopSound(0, 7);
PlaySound(0, sound, 5 | CHAN_NOPAUSE, 1.0, false, ATTN_NONE);
PlaySound(0, sound, 6 | CHAN_NOPAUSE, 1.0, false, ATTN_NONE);
PlaySound(0, sound, 7 | CHAN_NOPAUSE, 1.0, false, ATTN_NONE);
SetHudSize(800, 600, true);
SetFont("SMALLFONT");
HudMessageBold(s: smalltext; HUDMSG_FADEOUT, 7100, CR_WHITE, 400.0, 125.2, 5.0, 0.5);
HudMessageBold(s: tinytext; HUDMSG_FADEOUT, 7102, CR_WHITE, 400.0, 150.1, 5.0, 0.5);
SetHudSize(640, 480, true);
SetFont("BIGFONT");
HudMessageBold(s: bigtext; HUDMSG_FADEOUT, 7101, CR_UNTRANSLATED, 320.0, 104.1, 5.0, 0.5);
Log(s: smalltext, s: ": ", s: bigtext);
}
script 31244 (void) {
delay(35 * 3);
announcers_playing -= 1;
if (announcers_playing == 0) {
announcer_priority = -1;
}
}
function void announce(int priority, str sound, str bigtext, str smalltext, str tinytext) {
if (priority >= announcer_priority) {
// Increment here so the it is seen within the same tic.
announcers_playing += 1;
announcer_priority = priority;
SetCVarString("hpbar_announcer_sound", sound);
SetCVarString("hpbar_announcer_bigtext", bigtext);
SetCVarString("hpbar_announcer_smalltext", smalltext);
SetCVarString("hpbar_announcer_tinytext", tinytext);
SetCVar("hpbar_announcer_id", ++announcer_id);
ACS_ExecuteAlways(31243, 0, announcer_id);
ACS_ExecuteAlways(31244, 0);
}
}
function int to_fixed(int x) {
return x << 16;
}
function int to_int(int x) {
return x >> 16;
}
function str ccunescape_impl(str s, int n) {
for (int i = n; i < strlen(s); ++i) {
if (i < strlen(s) - 1 && GetChar(s, i) == '\\' && GetChar(s, i + 1) == 'c') {
return strparam(s: strmid(s, n, i - n), s: "\c", s: ccunescape_impl(s, i + 2));
}
}
return strmid(s, n, 99999);
}
function str ccunescape(str s) {
return ccunescape_impl(s, 0);
}
function str get_actor_name(int tid) {
if (tid == 0 && ClassifyActor(tid) & ACTOR_PLAYER) {
return strparam(n: 0);
}
str class = GetActorClass(tid);
str name = GetCVarString(strparam(s: "hpbar_name_", s: class));
if (name != 0) {
return ccunescape(name);
}
name = GetCVarString(strparam(s: "hpbar_name_", s: normalize_class(class)));
if (name != 0) {
return ccunescape(name);
}
return ccunescape(GetActorProperty(tid, APROP_NameTag));
}
function bool should_track(int tid) {
str class = GetActorClass(tid);
bool boss = GetCVar(strparam(s: "hpbar_track_", s: class));
if (boss == 1) {
return true;
} else if (boss == -1) {
return false;
}
boss = GetCVar(strparam(s: "hpbar_track_", s: normalize_class(class)));
if (boss == 1) {
return true;
} else if (boss == -1) {
return false;
}
if (is_zan3()) {
if (CheckFlag(tid, "BOSS")) {
return true;
}
}
return GetActorProperty(tid, APROP_SpawnHealth) >= GetCVar("hpbar_tracker_threshold");
}
function bool get_actor_invul(int tid) {
bool invul = GetActorProperty(tid, APROP_Invulnerable);
if (is_zan3()) {
invul |= !CheckFlag(tid, "SHOOTABLE");
}
return invul;
}
function bool streq(str x, str y) {
return strcmp(x, y) == 0;
}
function str normalize_class(str class) {
// These can't be declared as cvars due to special characters, so we special case them here:
if (streq(class, "Spectre~")) { return "Spectre"; }
if (streq(class, "Cacodemon~")) { return "Cacodemon"; }
if (streq(class, "HellKnight~")) { return "HellKnight"; }
if (streq(class, "BaronOfHell~")) { return "BaronOfHell"; }
if (streq(class, "Hexa-ShotgunZombie")) { return "HexaShotgunZombie"; }
if (streq(class, "LegendaryCyberNoble~")) { return "LegendaryCyberNoble"; }
// HEM
if (streq(class, "Hades-TechZombie")) { return "HadesTechZombie"; }
str s = GetCVarString(strparam(s: "hpbar_map_", s: class));
if (s != 0) {
return s;
}
return class;
}
function int get_my_user_cvar(str cvar) {
if (is_zan3()) {
return GetUserCVar(ConsolePlayerNumber(), cvar);
}
return GetCVar(cvar);
}
function bool is_zan3(void) {
return GetCVar("hpbar_zan3");
}
// vim: set ft=c: