-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathtriggers.qc
2317 lines (1791 loc) · 52.1 KB
/
triggers.qc
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
void() trigger_reactivate =
{
self.solid = SOLID_TRIGGER;
};
//=============================================================================
float SPAWNFLAG_NOMESSAGE = 1;
float SPAWNFLAG_NOTOUCH = 1;
float TRIGGER_MONSTERTRIGGERABLE = 128;
void() SUB_EndWaiting = {
self.is_waiting = 0;
self.estate = STATE_ACTIVE;
if (self.use == SUB_EndWaiting) self.use = self.dormant_use;
// special case for teleports, makes it ignore the fact that it has a targetname when touched
if (self.classname == "trigger_teleport") {
self.is_waiting = -1;
}
};
void() SUB_CheckWaiting = {
if (self.is_waiting > 0) {
self.dormant_use = self.use;
self.use = SUB_EndWaiting;
self.estate = STATE_INACTIVE;
}
};
// the wait time has passed, so set back up for another activation
void() multi_wait =
{
if (self.max_health)
{
self.health = self.max_health;
self.takedamage = DAMAGE_YES;
self.solid = SOLID_BBOX;
}
};
// the trigger was just touched/killed/used
// self.enemy should be set to the activator so it can be held through a delay
// so wait for the delay time before firing
void() multi_trigger = {
if (self.nextthink > time)
return; // already been triggered
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
if (self.classname == "trigger_secret")
{
if (self.enemy.classname != "player")
return;
found_secrets = found_secrets + 1;
WriteByte (MSG_ALL, SVC_FOUNDSECRET);
}
if (self.noise) {
if (self.enemy.flags & FL_CLIENT)
sound (self.enemy, CHAN_VOICE, self.noise, 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}
// don't trigger again until reset
self.takedamage = DAMAGE_NO;
activator = self.enemy;
SUB_UseTargets();
if (self.wait > 0) {
self.think = multi_wait;
self.nextthink = time + self.wait;
}
else {
// we can't just remove (self) here, because this is a touch function
// called wheil C code is looping through area links...
self.touch = SUB_Null;
self.nextthink = time + 0.1;
self.think = SUB_Remove;
}
if (self.count > 0) {
self.count -= 1;
if (self.count == 0) {
remove(self);
return;
}
}
};
void() multi_killed = //dumptruck_ds
{
if (self.estate != STATE_ACTIVE) { //restore health and do nothing if trigger is disabled
self.health = self.max_health; // nyah nyah~!
self.takedamage = DAMAGE_YES;
self.solid = SOLID_BBOX;
return;
}
self.enemy = damage_attacker;
multi_trigger();
};
void() multi_use = //dumptruck_ds
{
self.enemy = activator;
multi_trigger();
};
void() multi_touch =
{
if (other.classname != "player" && !(other.flags & FL_MONSTER && self.spawnflags & TRIGGER_MONSTERTRIGGERABLE))
return;
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
// if the trigger has an angles field, check player's facing direction.
// view_ofs sets the cone angle
if (self.movedir != '0 0 0')
{
vector cone = self.view_ofs;
if (cone == '0 0 0')
cone = '90 90 0';
if (!isInAngle([-other.v_angle_x, other.v_angle_y, other.v_angle_z], self.mangle, cone))
return;
}
self.enemy = other;
multi_trigger ();
};
/*QUAKED trigger_multiple (.5 .5 .5) ? notouch
Variable sized repeatable trigger. Must be targeted at one or more entities. If "health" is set, the trigger must be killed to activate each time.
If "delay" is set, the trigger waits some time after activating before firing.
"wait" : Seconds between triggerings. (.2 default)
If notouch is set, the trigger is only fired by other entities, not by touching.
NOTOUCH has been obsoleted by trigger_relay!
sounds
1) secret
2) beep beep
3) large switch
4)
set "message" to text string
*/
void() trigger_multiple =
{
if (!SUB_InitEntity()) return;
if (self.noise == "") {
if (self.sounds == 1)
self.noise = "misc/secret.wav";
else if (self.sounds == 2)
self.noise = "misc/talk.wav";
else if (self.sounds == 3)
self.noise = "misc/trigger1.wav";
}
if (self.noise != "")
precache_sound(self.noise);
if (!self.wait)
self.wait = 0.2;
self.use = multi_use;
InitTrigger();
if (self.health) {
if (self.spawnflags & SPAWNFLAG_NOTOUCH)
objerror ("health and notouch don't make sense\n");
self.max_health = self.health;
self.th_die = multi_killed;
self.takedamage = DAMAGE_YES;
self.solid = SOLID_BBOX;
setorigin(self, self.origin); // make sure it links into the world
}
else {
if (!(self.spawnflags & SPAWNFLAG_NOTOUCH))
self.touch = multi_touch;
}
SUB_CheckWaiting();
};
/*QUAKED trigger_once (.5 .5 .5) ? notouch
Variable sized trigger. Triggers once, then removes itself. You must set the key "target" to the name of another object in the level that has a matching
"targetname". If "health" is set, the trigger must be killed to activate.
If notouch is set, the trigger is only fired by other entities, not by touching.
if "killtarget" is set, any objects that have a matching "target" will be removed when the trigger is fired.
if "angle" is set, the trigger will only fire when someone is facing the direction of the angle. Use "360" for an angle of 0.
sounds
1) secret
2) beep beep
3) large switch
4)
set "message" to text string
*/
void() trigger_once =
{
if (!SUB_InitEntity()) return;
self.wait = -1;
trigger_multiple();
};
//=============================================================================
/*QUAKED trigger_relay (.5 .5 .5) (-8 -8 -8) (8 8 8)
This fixed size trigger cannot be touched, it can only be fired by other events. It can contain killtargets, targets, delays, and messages.
*/
float RELAY_AUTO = 1;
float RELAY_ALWAYSPLAYER = 2;
float RELAY_PLAYERONLY = 4;
void() trigger_relay_use = {
if (self.estate != STATE_ACTIVE)
return;
if (time < self.attack_finished)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
if (self.spawnflags & RELAY_AUTO) {
self.spawnflags &~= RELAY_AUTO;
dprint3("trigger_relay fired on map start at ", vtos(self.origin), "\n");
}
if (self.spawnflags & RELAY_ALWAYSPLAYER && !(activator.flags & FL_CLIENT)) {
entity closest;
closest = findClosest(self.origin, classname, "player", 1);
if (!closest) closest = findClosest(self.origin, classname, "player", 0);
if (closest) activator = closest;
}
if (self.spawnflags & RELAY_PLAYERONLY && !(activator.flags & FL_CLIENT))
return;
entity t;
if (self.noise) {
if (self.spawnflags & TRIGGER_CENTERPRINTALL) {
t = find(world, classname, "player");
while (t) {
sound (t, CHAN_VOICE, self.noise, 1, ATTN_NORM);
t = find(t, classname, "player");
}
}
else if (self.enemy.flags & FL_CLIENT)
sound (self.enemy, CHAN_VOICE, self.noise, 1, ATTN_NORM);
else
sound (self, CHAN_VOICE, self.noise, 1, ATTN_NORM);
}
SUB_UseTargets();
if (self.count > 0) {
self.count -= 1;
if (self.count == 0)
remove(self);
}
if (self.wait) {
self.attack_finished = time + self.wait;
}
}
void() trigger_relay =
{
if (!SUB_InitEntity()) return;
// Spawnflag 8192: Not in Nightmare
if (self.spawnflags & 8192 && startskill == SKILL_NIGHTMARE)
remove(self);
// Spawnflag 4096: Not in Hard
// Needed a change because the engine removes it for both Hard *and* Nightmare if the original 1024 spawnflag is on
if (self.spawnflags & 4096 && startskill == SKILL_HARD)
remove(self);
if (self.noise == "") {
if (self.sounds == 1)
self.noise = "misc/secret.wav";
else if (self.sounds == 2)
self.noise = "misc/talk.wav";
else if (self.sounds == 3)
self.noise = "misc/trigger1.wav";
}
if (self.noise != "") precache_sound(self.noise);
self.use = trigger_relay_use;
// Spawnflag 1: fire automatically on map start
if (self.spawnflags & 1) {
self.think = trigger_relay_use;
self.nextthink = time + 0.5;
}
};
//=============================================================================
/*QUAKED trigger_secret (.5 .5 .5) ?
secret counter trigger
sounds
1) secret
2) beep beep
3)
4)
set "message" to text string
*/
void() trigger_secret =
{
if (!SUB_InitEntity()) return;
total_secrets = total_secrets + 1;
self.wait = -1;
if (!self.message)
self.message = "You found a secret area!";
if (!self.sounds)
self.sounds = 1;
if (self.sounds == 1)
{
precache_sound ("misc/secret.wav");
self.noise = "misc/secret.wav";
}
else if (self.sounds == 2)
{
precache_sound ("misc/talk.wav");
self.noise = "misc/talk.wav";
}
trigger_multiple ();
};
//=============================================================================
float COUNTER_RESET = 2;
void() counter_use =
{
// local string junk;
if (self.estate != STATE_ACTIVE) return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
if (self.count <= 0)
return;
self.count--;
if (self.count > 0) {
if (activator.classname == "player" && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0) {
if (self.count >= 6)
centerprint (activator, "There are more to go ...");
else if (self.count == 5)
centerprint (activator, "There are 5 more to go ...");
else if (self.count == 4)
centerprint (activator, "There are 4 more to go ...");
else if (self.count == 3)
centerprint (activator, "There are 3 more to go ...");
else if (self.count == 2)
centerprint (activator, "Only 2 more to go...");
else
centerprint (activator, "Only 1 more to go...");
}
return;
}
if (activator.classname == "player" && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
centerprint(activator, "Sequence completed!");
self.enemy = activator;
SUB_UseTargets();
if (self.spawnflags & COUNTER_RESET)
self.count = self.bubble_count;
};
/*QUAKED trigger_counter (.5 .5 .5) (-8 -8 -8) (8 8 8) nomessage
Acts as an intermediary for an action that takes multiple inputs.
If nomessage is not set, t will print "1 more.. " etc when triggered and "sequence complete" when finished.
After the counter has been triggered "count" times (default 2), it will fire all of it's targets and remove itself.
*/
void() trigger_counter =
{
if (!SUB_InitEntity()) return;
self.wait = -1;
if (!self.count)
self.count = 2;
if (!self.bubble_count) self.bubble_count = self.count; // store the initial count amount
self.use = counter_use;
};
void() trigger_test_touch = {
if (other.classname == "player"){
other.fixangle = 1;
other.angles_x = 45;
}
}
void() trigger_test = {
InitTrigger();
self.touch = trigger_test_touch;
}
/*
==============================================================================
trigger_setskill
==============================================================================
*/
void() trigger_skill_touch =
{
if (self.estate != STATE_ACTIVE) return;
if (self.mapvar && !read_mapvar(self.mapvar)) return;
if (other.classname != "player")
return;
cvar_set("skill", self.message);
skill = cvar("skill");
};
//johnfitz -- make it targetable
void() trigger_skill_use =
{
if (activator.classname != "player")
return;
other = activator;
trigger_skill_touch();
};
//johnfitz
/*QUAKED trigger_setskill (.5 .5 .5) ?
sets skill level to the value of "message".
Only used on start map.
*/
void() trigger_setskill =
{
if (!SUB_InitEntity()) return;
InitTrigger ();
self.touch = trigger_skill_touch;
self.use = trigger_skill_use; //johnfitz -- make it targetable
SUB_CheckWaiting();
};
void() target_setskill_use = {
if (self.estate != STATE_ACTIVE) return;
if (self.mapvar && !read_mapvar(self.mapvar)) return;
cvar_set("skill", self.message);
skill = cvar("skill");
}
void() target_setskill = {
if (!SUB_InitEntity()) return;
self.use = target_setskill_use;
}
/*
==============================================================================
ONLY REGISTERED TRIGGERS
==============================================================================
*/
void() trigger_onlyregistered_touch =
{
if (other.classname != "player")
return;
if (self.attack_finished > time)
return;
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
self.attack_finished = time + 2;
if (cvar("registered"))
{
self.message = "";
SUB_UseTargets ();
remove (self);
}
else
{
if (self.message != "")
{
centerprint (other, self.message);
sound (other, CHAN_BODY, "misc/talk.wav", 1, ATTN_NORM);
}
}
};
/*QUAKED trigger_onlyregistered (.5 .5 .5) ?
Only fires if playing the registered version, otherwise prints the message
*/
void() trigger_onlyregistered =
{
if (!SUB_InitEntity()) return;
precache_sound ("misc/talk.wav");
InitTrigger ();
self.touch = trigger_onlyregistered_touch;
SUB_CheckWaiting();
};
/*
==============================================================================
trigger_hurt
==============================================================================
*/
void() hurt_retouch = {
force_retouch = 2;
}
void() hurt_touch =
{
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
if (self.spawnflags & 1 && other.flags & FL_CLIENT)
return;
if (self.spawnflags & 2 && other.flags & FL_MONSTER)
return;
if (time < other.hurt_started + self.wait)
return;
if (other.takedamage) {
T_Damage(other, self, self, self.dmg, self.style);
other.hurt_started = time;
}
// From Copper:
// this is not ideal but all the other solutions are also not ideal: monsters
// who stand still in a trigger hurt don't catch the trigger, so (for example)
// enforcers who plant and open fire will be immune to the hurt as long as they
// stay in one place
if (other.flags & FL_MONSTER && other.health > 0) {
// so we have to ask the engine to spam a collision test of everything vs
// everything else to catch them
self.think = hurt_retouch;
self.nextthink = time + self.wait;
}
};
/*QUAKED trigger_hurt (.5 .5 .5) ?
Any object touching this will be hurt
set dmg to damage amount
defalt dmg = 5
*/
void() trigger_hurt =
{
if (!SUB_InitEntity()) return;
InitTrigger();
self.touch = hurt_touch;
if(!self.wait) self.wait = 1;
if (!self.dmg)
self.dmg = 5;
// monsters won't react to this attack
self.flags |= FL_IGNOREDATTACK;
SUB_CheckWaiting();
};
/*
==============================================================================
target_hurt
==============================================================================
*/
void() hurt_think = {
if (self.owner.health <= 0 || self.attack_finished < time) {
if (self.attack_finished < time) {
if (self.dmg_save < self.dmg)
T_Damage(self.owner, self.enemy, self.enemy, self.dmg - self.dmg_save, self.style);
}
self.owner.hurtcontroller = world;
remove(self);
return;
}
self.dmg_take += self.dmg / self.delay / 20;
float take;
if (fabs(self.dmg_take) >= 1) {
if (self.dmg_take < 0) {
take = ceil(self.dmg_take);
self.owner.health -= take;
}
else {
take = floor(self.dmg_take);
T_Damage(self.owner, self.enemy, self.enemy, take, self.style);
}
self.dmg_save += take;
self.dmg_take = self.dmg_take % take;
}
self.nextthink = time + 0.05;
};
void(entity tgt, float totaldmg, float duration, float dmgtype) hurt_start = {
entity controller;
if (self.spawnflags & 1 && tgt.flags & FL_CLIENT)
return;
if (self.spawnflags & 2 && tgt.flags & FL_MONSTER)
return;
if (!tgt.takedamage || tgt.health <= 0)
return;
if (!tgt.hurtcontroller ||
tgt.hurtcontroller.classname != "hurt_controller" ||
tgt.hurtcontroller.enemy != self
) {
if (tgt.hurtcontroller) remove(tgt.hurtcontroller);
controller = spawn();
controller.owner = tgt;
controller.enemy = self;
controller.classname = "hurt_controller";
tgt.hurtcontroller = controller;
controller.attack_finished = time + duration;
controller.dmg = totaldmg;
controller.delay = duration;
controller.style = dmgtype;
controller.think = hurt_think;
controller.nextthink = time + 0.05;
}
};
void(string name, .string fld) hurt_find = {
local entity t;
t = find(world, fld, name);
while (t) {
hurt_start(t, self.dmg, self.speed, self.style);
t = find(t, fld, name);
}
}
void() hurt_use = {
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
float has_target;
if (self.target && self.target != "") {
hurt_find(self.target, targetname);
hurt_find(self.target, targetname2);
has_target = TRUE;
}
if (self.target2 && self.target2 != "") {
hurt_find(self.target2, targetname);
hurt_find(self.target2, targetname2);
has_target = TRUE;
}
if (self.target3 && self.target3 != "") {
hurt_find(self.target3, targetname);
hurt_find(self.target3, targetname2);
has_target = TRUE;
}
if (self.target4 && self.target4 != "") {
hurt_find(self.target4, targetname);
hurt_find(self.target4, targetname2);
has_target = TRUE;
}
if (!has_target) {
hurt_start(activator, self.dmg, self.speed, self.style);
}
}
void() target_hurt = {
if (!SUB_InitEntity()) return;
self.use = hurt_use;
};
/*
==============================================================================
target_heal
==============================================================================
*/
void() heal_think = {
/*
dmg_save -> amount of healing left to do
dmg_take -> amount of healing already done
healamount -> total heal
*/
if (self.owner.health <= 0 || self.attack_finished < time || self.owner.health >= self.owner.max_health) {
// make sure target health is reached at the last tic
if (self.attack_finished < time) {
if (self.dmg_save < self.healamount)
self.owner.health += self.healamount - self.dmg_save;
}
self.owner.hurtcontroller = world;
remove(self);
return;
}
self.dmg_take += self.healamount / self.delay / 20;
float take;
if (fabs(self.dmg_take) >= 1) {
if (self.dmg_take < 0) {
take = ceil(self.dmg_take);
self.owner.health += take;
}
else {
take = floor(self.dmg_take);
self.owner.health += take;
}
self.dmg_save += take;
self.dmg_take = self.dmg_take % take;
}
self.nextthink = time + 0.05;
};
void(entity tgt, float totalheal, float duration) heal_start = {
entity controller;
if (self.spawnflags & 1 && tgt.flags & FL_CLIENT)
return;
if (self.spawnflags & 2 && tgt.flags & FL_MONSTER)
return;
if (tgt.health <= 0)
return;
if (!tgt.hurtcontroller ||
tgt.hurtcontroller.classname != "hurt_controller" ||
tgt.hurtcontroller.enemy != self
) {
if (tgt.hurtcontroller) remove(tgt.hurtcontroller);
controller = spawn();
controller.owner = tgt;
controller.enemy = self;
controller.classname = "hurt_controller";
tgt.hurtcontroller = controller;
controller.attack_finished = time + duration;
controller.healamount = totalheal;
controller.delay = duration;
controller.think = heal_think;
controller.nextthink = time + 0.05;
}
};
void(string name, .string fld) heal_find = {
local entity t;
t = find(world, fld, name);
while (t) {
heal_start(t, self.healamount, self.speed);
t = find(t, fld, name);
}
}
void() heal_use = {
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
float has_target;
if (self.target && self.target != "") {
heal_find(self.target, targetname);
heal_find(self.target, targetname2);
has_target = TRUE;
}
if (self.target2 && self.target2 != "") {
heal_find(self.target2, targetname);
heal_find(self.target2, targetname2);
has_target = TRUE;
}
if (self.target3 && self.target3 != "") {
heal_find(self.target3, targetname);
heal_find(self.target3, targetname2);
has_target = TRUE;
}
if (self.target4 && self.target4 != "") {
heal_find(self.target4, targetname);
heal_find(self.target4, targetname2);
has_target = TRUE;
}
if (!has_target) {
heal_start(activator, self.healamount, self.speed);
}
}
void() target_heal = {
if (!SUB_InitEntity()) return;
self.use = heal_use;
};
/*
==============================================================================
trigger_push
==============================================================================
*/
float PUSH_ONCE = 1;
float PUSH_SILENT = 2;
float PUSH_TUNNEL = 8;
void() trigger_push_touch =
{
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
if (other.classname == "grenade")
other.velocity = self.speed * self.movedir * 10;
else if (other.health > 0)
{
other.velocity = self.speed * self.movedir * 10;
if (other.classname == "player" && !(self.spawnflags & PUSH_SILENT))
{
if (other.fly_sound < time)
{
other.fly_sound = time + self.delay;
sound (other, CHAN_AUTO, self.noise, 1, ATTN_NORM);
}
}
if (self.spawnflags & PUSH_TUNNEL)
{
vector suck = self.origin + (self.mins + self.maxs )/2 - other.origin;
suck -= self.movedir * (suck * self.movedir);
other.velocity += suck * self.speed * 0.1;
}
}
if (self.spawnflags & PUSH_ONCE)
remove(self);
};
/*QUAKED trigger_push (.5 .5 .5) ? PUSH_ONCE PUSH_SILENT
Pushes the player
*/
void() trigger_push =
{
if (!SUB_InitEntity()) return;
if (self.angles == '0 0 0')
self.angles = '0 360 0';
if (!self.noise)
self.noise = "ambience/windfly.wav";
if (!self.delay)
self.delay = 1.5;
if (!(self.spawnflags & PUSH_SILENT)) precache_sound(self.noise);
self.touch = trigger_push_touch;
if (!self.speed)
self.speed = 1000;
InitTrigger ();
SUB_CheckWaiting();
};
/*
==============================================================================
trigger_monsterjump
==============================================================================
*/
float SPAWN_MJUMP_NOLARGE = 1;
float SPAWN_MJUMP_NOSMALL = 2;
float SPAWN_MJUMP_MELEES = 8;
float SPAWN_MJUMP_ONLYFRONT = 16;
float SPAWN_MJUMP_ONLYBELOW = 32;
void() trigger_monsterjump_touch =
{
if (self.estate != STATE_ACTIVE)
return;
if (self.mapvar && !read_mapvar(self.mapvar))
return;
//if(!self.count)
// return;
// only walking monsters
if (other.flags & (FL_MONSTER | FL_FLY | FL_SWIM) != FL_MONSTER)
return;
// dead monsters can't jump
if (other.health <= 0)
return;
/*
if (self.include && other.classname != self.include)
return;
if (self.exclude && other.classname == self.exclude)
return;
*/
if (self.include == string_null ||
(other.classname != self.include && other.targetname != self.include)) // always allow this class/tname
{
if (self.spawnflags & SPAWN_MJUMP_NOLARGE && other.maxs_x >= 24) return;
if (self.spawnflags & SPAWN_MJUMP_NOSMALL && other.maxs_x < 24) return;
//if (self.spawnflags & SPAWN_MJUMP_MELEES && !(other.customflags & CFL_MELEEONLY)) return;