This repository was archived by the owner on Jan 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathg_newtarg.c
3270 lines (2963 loc) · 88.7 KB
/
g_newtarg.c
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
#include "g_local.h"
qboolean FindTarget (edict_t *self);
//==========================================================
/*QUAKED target_steam (1 0 0) (-8 -8 -8) (8 8 8)
Creates a steam effect (particles w/ velocity in a line).
speed = velocity of particles (default 50)
count = number of particles (default 32)
sounds = color of particles (default 8 for steam)
the color range is from this color to this color + 6
wait = seconds to run before stopping (overrides default
value derived from func_timer)
best way to use this is to tie it to a func_timer that "pokes"
it every second (or however long you set the wait time, above)
note that the width of the base is proportional to the speed
good colors to use:
6-9 - varying whites (darker to brighter)
224 - sparks
176 - blue water
80 - brown water
208 - slime
232 - blood
*/
void use_target_steam (edict_t *self, edict_t *other, edict_t *activator)
{
// FIXME - this needs to be a global
static int nextid;
vec3_t point;
if (nextid > 20000)
nextid = nextid %20000;
nextid++;
// automagically set wait from func_timer unless they set it already, or
// default to 1000 if not called by a func_timer (eek!)
if (!self->wait) {
if (other) {
self->wait = other->wait * 1000;
} else {
self->wait = 1000;
}
}
if (self->enemy)
{
VectorMA (self->enemy->absmin, 0.5, self->enemy->size, point);
VectorSubtract (point, self->s.origin, self->movedir);
VectorNormalize (self->movedir);
}
VectorMA (self->s.origin, self->plat2flags*0.5, self->movedir, point);
if (self->wait > 100)
{
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_STEAM);
gi.WriteShort (nextid);
gi.WriteByte (self->count);
gi.WritePosition (self->s.origin);
gi.WriteDir (self->movedir);
gi.WriteByte (self->sounds&0xff);
gi.WriteShort ( (short int)(self->plat2flags) );
gi.WriteLong ( (int)(self->wait) );
gi.multicast (self->s.origin, MULTICAST_PVS);
}
else
{
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_STEAM);
gi.WriteShort ((short int)-1);
gi.WriteByte (self->count);
gi.WritePosition (self->s.origin);
gi.WriteDir (self->movedir);
gi.WriteByte (self->sounds&0xff);
gi.WriteShort ( (short int)(self->plat2flags) );
gi.multicast (self->s.origin, MULTICAST_PVS);
}
}
void target_steam_start (edict_t *self)
{
edict_t *ent;
self->use = use_target_steam;
if (self->target)
{
ent = G_Find (NULL, FOFS(targetname), self->target);
if (!ent)
gi.dprintf ("%s at %s: %s is a bad target\n", self->classname, vtos(self->s.origin), self->target);
self->enemy = ent;
}
else
{
G_SetMovedir (self->s.angles, self->movedir);
}
if (!self->count)
self->count = 32;
if (!self->plat2flags)
self->plat2flags = 75;
if (!self->sounds)
self->sounds = 8;
if (self->wait)
self->wait *= 1000; // we want it in milliseconds, not seconds
// paranoia is good
self->sounds &= 0xff;
self->count &= 0xff;
self->svflags = SVF_NOCLIENT;
gi.linkentity (self);
}
void SP_target_steam (edict_t *self)
{
self->plat2flags = self->speed;
if (self->target)
{
self->think = target_steam_start;
self->nextthink = level.time + 1;
}
else
target_steam_start (self);
}
//==========================================================
// target_anger
//==========================================================
void target_anger_use (edict_t *self, edict_t *other, edict_t *activator)
{
edict_t *target;
edict_t *t;
t = NULL;
target = G_Find (t, FOFS(targetname), self->killtarget);
if (target && self->target)
{
// Make whatever a "good guy" so the monster will try to kill it!
target->monsterinfo.aiflags |= AI_GOOD_GUY;
target->svflags |= SVF_MONSTER;
//Knightmare- removed
if (target->health == 0)
target->health = 300;
t = NULL;
while ((t = G_Find (t, FOFS(targetname), self->target)))
{
if (t == self)
{
gi.dprintf ("WARNING: entity used itself.\n");
}
else
{
if (t->use)
{
if (t->health < 0)
{
// if ((g_showlogic) && (g_showlogic->value))
// gi.dprintf ("target_anger with dead monster!\n");
return;
}
t->enemy = target;
t->monsterinfo.aiflags |= AI_TARGET_ANGER;
FoundTarget (t);
}
}
if (!self->inuse)
{
gi.dprintf("entity was removed while using targets\n");
return;
}
}
}
}
/*QUAKED target_anger (1 0 0) (-8 -8 -8) (8 8 8)
This trigger will cause an entity to be angry at another entity when a player touches it. Target the
entity you want to anger, and killtarget the entity you want it to be angry at.
target - entity to piss off
killtarget - entity to be pissed off at
*/
void SP_target_anger (edict_t *self)
{
if(deathmatch->value)
{
G_FreeEdict(self);
return;
}
if (!self->target)
{
gi.dprintf("target_anger without target!\n");
G_FreeEdict (self);
return;
}
if (!self->killtarget)
{
gi.dprintf("target_anger without killtarget!\n");
G_FreeEdict (self);
return;
}
self->use = target_anger_use;
self->svflags = SVF_NOCLIENT;
}
// target_monsterbattle serves the same purpose as target_anger, but
// ends up turning a dmgteam group of monsters against another dmgteam
void use_target_monsterbattle(edict_t *self, edict_t *other, edict_t *activator)
{
edict_t *grouch, *grouchmate;
edict_t *target, *targetmate;
grouch = G_Find(NULL,FOFS(targetname),self->target);
if(!grouch) return;
if(!grouch->inuse) return;
target = G_Find(NULL,FOFS(targetname),self->killtarget);
if(!target) return;
if(!target->inuse) return;
if(grouch->dmgteam)
{
grouchmate = G_Find(NULL,FOFS(dmgteam),grouch->dmgteam);
while(grouchmate)
{
grouchmate->monsterinfo.moreaiflags |= AI_FREEFORALL;
grouchmate = G_Find(grouchmate,FOFS(dmgteam),grouch->dmgteam);
}
}
if(target->dmgteam)
{
targetmate = G_Find(NULL,FOFS(dmgteam),target->dmgteam);
while(targetmate)
{
targetmate->monsterinfo.moreaiflags |= AI_FREEFORALL;
targetmate = G_Find(targetmate,FOFS(dmgteam),target->dmgteam);
}
}
grouch->enemy = target;
grouch->monsterinfo.aiflags |= AI_TARGET_ANGER;
FoundTarget(grouch);
self->count--;
if(self->count == 0)
{
self->think = G_FreeEdict;
self->nextthink = level.time + 1;
}
}
void SP_target_monsterbattle(edict_t *self)
{
if(deathmatch->value)
{
G_FreeEdict(self);
return;
}
if(!self->target)
{
gi.dprintf("target_monsterbattle with no target set at %s\n",vtos(self->s.origin));
G_FreeEdict(self);
return;
}
if(!self->killtarget)
{
gi.dprintf("target_monsterbattle with no killtarget set at %s\n",vtos(self->s.origin));
G_FreeEdict(self);
return;
}
self->use = use_target_monsterbattle;
}
// ================
// target_spawn
// ================
/*
extern edict_t *CreateMonster(vec3_t origin, vec3_t angles, char *classname);
void target_spawn_use (edict_t *self, edict_t *other, edict_t *activator)
{
edict_t *newEnt;
newEnt = CreateMonster (self->s.origin, self->s.angles, "monster_infantry");
if(newEnt)
newEnt->enemy = other;
}
*/
/*Q U AKED target_spawn (1 0 0) (-32 -32 -24) (32 32 72)
*/
/*
void SP_target_spawn (edict_t *self)
{
self->use = target_spawn_use;
self->svflags = SVF_NOCLIENT;
}
*/
// ***********************************
// target_killplayers
// ***********************************
void target_killplayers_use (edict_t *self, edict_t *other, edict_t *activator)
{
int i;
edict_t *ent, *player;
// kill the players
for (i=0 ; i<game.maxclients ; i++)
{
player = &g_edicts[1+i];
if (!player->inuse)
continue;
// nail it
T_Damage (player, self, self, vec3_origin, self->s.origin, vec3_origin, 100000, 0, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);
}
// kill any visible monsters
for (ent = g_edicts; ent < &g_edicts[globals.num_edicts] ; ent++)
{
if (!ent->inuse)
continue;
if (ent->health < 1)
continue;
if (!ent->takedamage)
continue;
for(i=0;i<game.maxclients ; i++)
{
player = &g_edicts[1+i];
if(!player->inuse)
continue;
if(visible(player, ent))
{
T_Damage (ent, self, self, vec3_origin, ent->s.origin, vec3_origin,
ent->health, 0, DAMAGE_NO_PROTECTION, MOD_TELEFRAG);
break;
}
}
}
}
/*QUAKED target_killplayers (1 0 0) (-8 -8 -8) (8 8 8)
When triggered, this will kill all the players on the map.
*/
void SP_target_killplayers (edict_t *self)
{
self->use = target_killplayers_use;
self->svflags = SVF_NOCLIENT;
}
/*QUAKED target_blacklight (1 0 1) (-16 -16 -24) (16 16 24)
Pulsing black light with sphere in the center
*/
void blacklight_think (edict_t *self)
{
self->s.angles[0] = rand()%360;
self->s.angles[1] = rand()%360;
self->s.angles[2] = rand()%360;
self->nextthink = level.time + 0.1;
}
void SP_target_blacklight(edict_t *ent)
{
if (deathmatch->value)
{ // auto-remove for deathmatch
G_FreeEdict (ent);
return;
}
VectorClear (ent->mins);
VectorClear (ent->maxs);
ent->s.effects |= (EF_TRACKERTRAIL|EF_TRACKER);
ent->think = blacklight_think;
ent->s.modelindex = gi.modelindex ("models/items/spawngro2/tris.md2");
ent->s.frame = 1;
ent->nextthink = level.time + 0.1;
gi.linkentity (ent);
}
/*QUAKED target_orb (1 0 1) (-16 -16 -24) (16 16 24)
Translucent pulsing orb with speckles
*/
void orb_think (edict_t *self)
{
self->s.angles[0] = rand()%360;
self->s.angles[1] = rand()%360;
self->s.angles[2] = rand()%360;
// self->s.effects |= (EF_TRACKERTRAIL|EF_DOUBLE);
self->nextthink = level.time + 0.1;
}
void SP_target_orb(edict_t *ent)
{
if (deathmatch->value)
{ // auto-remove for deathmatch
G_FreeEdict (ent);
return;
}
VectorClear (ent->mins);
VectorClear (ent->maxs);
// ent->s.effects |= EF_TRACKERTRAIL;
ent->think = orb_think;
ent->nextthink = level.time + 0.1;
ent->s.modelindex = gi.modelindex ("models/items/spawngro2/tris.md2");
ent->s.frame = 2;
ent->s.effects |= EF_SPHERETRANS;
gi.linkentity (ent);
}
/*
===============================================
MAPPACK AND LAZARUS ADDITIONS
===============================================
*/
/*QUAKED target_command (1 0 0) (-8 -8 -8) (8 8 8)
Sends a command to the console which gets executed imediately,
unless it requires a restart of the server.
message - command to send
*/
void target_command_use (edict_t *self, edict_t *activator, edict_t *other)
{
gi.WriteByte (11);
gi.WriteString (self->message);
gi.unicast (self, true);
}
void SP_target_command (edict_t *self)
{
if(!self->message)
{
gi.dprintf("target_command with no command, target name is %s at %s", self->targetname, vtos(self->s.origin));
G_FreeEdict (self);
return;
}
self->use = target_command_use;
self->svflags = SVF_NOCLIENT;
gi.linkentity (self);
}
#define ON 1
#define OFF 2
#define TOGGLE 4
/*QUAKED target_set_effect (1 0 0) (-8 -8 -8) (8 8 8)
Changes the effects of the targeted entities.
"target" - set the properties to this entity
"style" -
0 = Set
1 = Remove
2 = XOR (toggle)
"alpha" : Change the alpha value of the target (between 0 and 1)
"effects"
1: ROTATE Rotate like a weapon
2: GIB
8: BLASTER Yellowish orange glow plus particles
16: ROCKET Rocket trail
32: GRENADE Grenade trail
64: HYPERBLASTER BLASTER w/o the particles
128: BFG Big green ball
256: COLOR_SHELL
512: POWERSCREEN Green power shield
16384: FLIES Ewwww
32768: QUAD Blue shell
65536: PENT Red shell
131072: TELEPORTER Teleporter particles
262144: FLAG1 Red glow
524288: FLAG2 Blue glow
1048576: IONRIPPER
2097152: GREENGIB
4194304: BLUE_HB Blue hyperblaster glow
8388608: SPINNING_LIGHTS Red spinning lights
16777216: PLASMA
33554432: TRAP
67108864: TRACKER
134217728: DOUBLE Yellow shell
268435456: SPHERETRANS Transparent
536870912: TAGTRAIL
1073741824: HALF_DAMAGE
2147483648: TRACKER_TRAIL
"renderfx"
1: MINLIGHT Never completely dark
2: VIEWERMODEL
4: WEAPONMODEL
8: FULLBRIGHT
16: DEPTHHACK
32: TRANSLUCENT Transparent
64: FRAMELERP
128: BEAM
512: GLOW Pulsating glow of normal Q2 pickup items
1024: SHELL_RED
2048: SHELL_GREEN
4096: SHELL_BLUE
32768: IR_VISIBLE
65536: SHELL_DOUBLE
131072: SHELL_HALF_DAMAGE White shell
262144: USE_DISGUISE
*/
void target_set_effect_use (edict_t *self, edict_t *activator, edict_t *other)
{
edict_t *target;
target = G_Find (NULL, FOFS(targetname), self->target);
while(target)
{
if(self->style == 1)
{
target->s.effects &= ~self->effects;
target->s.renderfx &= ~self->renderfx;
}
else if(self->style == 2)
{
target->s.effects ^= self->effects;
target->s.renderfx ^= self->renderfx;
}
else
{
target->s.effects = self->effects;
target->s.renderfx = self->renderfx;
}
#ifdef KMQUAKE2_ENGINE_MOD //Knightmare added
if ((self->alpha >= 0.0) && (self->alpha <= 1.0))
target->s.alpha = self->alpha;
#endif
gi.linkentity(target);
target = G_Find(target,FOFS(targetname),self->target);
}
}
void SP_target_set_effect (edict_t *self)
{
if(!self->target)
{
gi.dprintf("target_set_effect w/o a target at %s\n",vtos(self->s.origin));
G_FreeEdict(self);
return;
}
self->use = target_set_effect_use;
self->svflags = SVF_NOCLIENT;
gi.linkentity (self);
}
/*QUAKED target_global_text (1 0 0) (-8 -8 -8) (8 8 8)
Send a string to all clients to be printed.
message - what to print.
*/
void target_global_text_use (edict_t *self, edict_t *activator, edict_t *other)
{
//FIXME : Send this to all clients notjust the activator.
//gi.centerprintf (activator, "%s", self->message);
gi.bprintf (PRINT_CHAT, "%s\n", self->message);
}
void SP_target_global_text (edict_t *self)
{
if (!self->message)
{
gi.dprintf("target_global_text at %s with no message\n", vtos(self->s.origin));
G_FreeEdict(self);
return;
}
if (!self->targetname)
{
gi.dprintf("target_global_text at %s with no targetname\n", vtos(self->s.origin));
G_FreeEdict(self);
return;
}
self->use = target_global_text_use;
self->svflags = SVF_NOCLIENT;
gi.linkentity (self);
}
/*QUAKED target_ignore_player (1 0 0) (-8 -8 -8) (8 8 8) OFF
Switches monsters ignoring the player on and off.
OFF - switch the effect off.
target - monster to switch
*/
/*#define IGNORE_CLIENT 64
void target_ignore_player_use (edict_t *self, edict_t *activator, edict_t *other)
{
if (self->spawnflags & 1)
self->enemy->monsterinfo.aiflags &= ~IGNORE_CLIENT;
else
self->enemy->monsterinfo.aiflags |= IGNORE_CLIENT;
}
void SP_target_ignore_player (edict_t *self)
{
if (!self->target)
{
gi.dprintf("target_ignore_player with out target at %s", vtos(self->s.origin));
G_FreeEdict(self);
return;
}
self->svflags = SVF_NOCLIENT;
self->think = VerifyTarget;
self->nextthink = 1;
self->use = target_ignore_player_use;
self->svflags |= SVF_NOCLIENT;
gi.linkentity (self);
}*/
/*QUAKED target_effect (1 0 0) (-8 -8 -8) (8 8 8) LoopOn LoopOff
Calls an effect when used
"target" ent aimed at
"sounds" splash or pallete index
"count" pixels/splash (1-255)
"wait" steam duration
"speed" steam speed
"style" Select from the list below
0 : Gunshot
1 : Blood
2 : Blaster
3 : Railtrail
4 : Shotgun
5 : Explosion1
6 : Explosion2
7 : Rocket explosion
8 : Grenade explosion
9 : Sparks
10 : Splash
11 : Bubbletrail
12 : Screen sparks
13 : Shield sparks
14 : Bullet sparks
15 : Laser sparks
16 : Parasite attack
17 : Rocket expl (water)
18 : Grenade expl (water)
19 : Medic cable attack
20 : BFG explosion
21 : BFG big explosion
22 : BossTport
23 : BFG laser
24 : Grapple cable
25 : Welding sparks
26 : GreenBlood
28 : Plasma explosion
29 : Tunnel sparks
30 : Blaster2
33 : Lightning
34 : Debugtrail
35 : Plain explosion
36 : Flashlight
38 : Heatbeam
39 : Monster heatbeam
40 : Steam
41 : Bubbletrail2
42 : MoreBlood
43 : Heatbeam sparks
44 : Heatbeam steam
45 : Chainfist smoke
46 : Electric sparks
47 : Tracker explosion
48 : Teleport effect
49 : DBall goal
50 : WidowBeamOut
51 : NukeBlast
52 : WidowSplash
53 : Explosion1 Big
54 : Explosion1 NP
55 : Flechette
*/
/*====================================================================================
TARGET_EFFECT
======================================================================================*/
/* Unknowns or not supported
TE_FLAME, 32 Rogue flamethrower, never implemented
TE_FORCEWALL, 37 ??
*/
//=========================================================================
/* Spawns an effect at the entity origin
TE_FLASHLIGHT 36
*/
void target_effect_at (edict_t *self, edict_t *activator)
{
gi.WriteByte (svc_temp_entity);
gi.WriteByte (self->style);
gi.WritePosition (self->s.origin);
gi.WriteShort (self - g_edicts);
gi.multicast (self->s.origin, MULTICAST_PVS);
}
/* Poor man's target_steam
TE_STEAM 40
*/
void target_effect_steam (edict_t *self, edict_t *activator)
{
static int nextid;
int wait;
if(self->wait)
wait = self->wait*1000;
else
wait = 0;
if (nextid > 20000)
nextid = nextid %20000;
nextid++;
gi.WriteByte (svc_temp_entity);
gi.WriteByte (self->style);
gi.WriteShort (nextid);
gi.WriteByte (self->count);
gi.WritePosition (self->s.origin);
gi.WriteDir (self->movedir);
gi.WriteByte (self->sounds&0xff);
gi.WriteShort ( (int)(self->speed) );
gi.WriteLong ( (int)(wait) );
gi.multicast (self->s.origin, MULTICAST_PVS);
// if(level.num_reflectors)
// ReflectSteam (self->s.origin,self->movedir,self->count,self->sounds,(int)(self->speed),wait,nextid);
}
//=========================================================================
/*
Spawns (style) Splash with (count) particles of (sounds) color at (origin)
moving in (movedir) direction.
TE_SPLASH 10 Randomly shaded shower of particles
TE_LASER_SPARKS 15 Splash particles obey gravity
TE_WELDING_SPARKS 25 Splash particles with flash of light at {origin}
*/
//=========================================================================
void target_effect_splash (edict_t *self, edict_t *activator)
{
gi.WriteByte(svc_temp_entity);
gi.WriteByte(self->style);
gi.WriteByte(self->count);
gi.WritePosition(self->s.origin);
gi.WriteDir(self->movedir);
gi.WriteByte(self->sounds);
gi.multicast(self->s.origin, MULTICAST_PVS);
}
//======================================================
/*
Spawns a trail of (type) from (start) to (end) and Broadcasts to all
in Potentially Visible Set from vector (origin)
TE_RAILTRAIL 3 Spawns a blue spiral trail filled with white smoke
TE_BUBBLETRAIL 11 Spawns a trail of bubbles
TE_PARASITE_ATTACK 16
TE_MEDIC_CABLE_ATTACK 19
TE_BFG_LASER 23 Spawns a green laser
TE_GRAPPLE_CABLE 24
TE_RAILTRAIL2 31 NOT IMPLEMENTED IN ENGINE
TE_DEBUGTRAIL 34
TE_HEATBEAM, 38 Requires Rogue model
TE_MONSTER_HEATBEAM, 39 Requires Rogue model
TE_BUBBLETRAIL2 41
*/
//======================================================
void target_effect_trail (edict_t *self, edict_t *activator)
{
edict_t *target;
if(!self->target) return;
target = G_Find(NULL,FOFS(targetname),self->target);
if(!target) return;
gi.WriteByte(svc_temp_entity);
gi.WriteByte(self->style);
if((self->style == TE_PARASITE_ATTACK) || (self->style==TE_MEDIC_CABLE_ATTACK) ||
(self->style == TE_HEATBEAM) || (self->style==TE_MONSTER_HEATBEAM) ||
(self->style == TE_GRAPPLE_CABLE) )
gi.WriteShort(self-g_edicts);
gi.WritePosition(self->s.origin);
gi.WritePosition(target->s.origin);
if(self->style == TE_GRAPPLE_CABLE) {
gi.WritePosition(vec3_origin);
}
gi.multicast(self->s.origin, MULTICAST_PVS);
/* if(level.num_reflectors)
{
if((self->style == TE_RAILTRAIL) || (self->style == TE_BUBBLETRAIL) ||
(self->style == TE_BFG_LASER) || (self->style == TE_DEBUGTRAIL) ||
(self->style == TE_BUBBLETRAIL2))
ReflectTrail(self->style,self->s.origin,target->s.origin);
}*/
}
//===========================================================================
/* TE_LIGHTNING 33 Lightning bolt
Similar but slightly different syntax to trail stuff */
void target_effect_lightning(edict_t *self, edict_t *activator)
{
edict_t *target;
if(!self->target) return;
target = G_Find(NULL,FOFS(targetname),self->target);
if(!target) return;
gi.WriteByte (svc_temp_entity);
gi.WriteByte (self->style);
gi.WriteShort (target - g_edicts); // destination entity
gi.WriteShort (self - g_edicts); // source entity
gi.WritePosition (target->s.origin);
gi.WritePosition (self->s.origin);
gi.multicast (self->s.origin, MULTICAST_PVS);
}
//===========================================================================
/*
Spawns sparks of (type) from (start) in direction of (movdir) and
Broadcasts to all in Potentially Visible Set from vector (origin)
TE_GUNSHOT 0 Spawns a grey splash of particles, with a bullet puff
TE_BLOOD 1 Spawns a spurt of red blood
TE_BLASTER 2 Spawns a blaster sparks
TE_SHOTGUN 4 Spawns a small grey splash of spark particles, with a bullet puff
TE_SPARKS 9 Spawns a red/gold splash of spark particles
TE_SCREEN_SPARKS 12 Spawns a large green/white splash of sparks
TE_SHIELD_SPARKS 13 Spawns a large blue/violet splash of sparks
TE_BULLET_SPARKS 14 Same as TE_SPARKS, with a bullet puff and richochet sound
TE_GREENBLOOD 26 Spurt of green (actually kinda yellow) blood
TE_BLUEHYPERBLASTER 27 NOT IMPLEMENTED
TE_BLASTER2 30 Green/white sparks with a yellow/white flash
TE_MOREBLOOD 42
TE_HEATBEAM_SPARKS 43
TE_HEATBEAM_STEAM 44
TE_CHAINFIST_SMOKE 45
TE_ELECTRIC_SPARKS 46
TE_FLECHETTE 55
*/
//======================================================
void target_effect_sparks (edict_t *self, edict_t *activator)
{
gi.WriteByte(svc_temp_entity);
gi.WriteByte(self->style);
gi.WritePosition(self->s.origin);
if(self->style != TE_CHAINFIST_SMOKE)
gi.WriteDir(self->movedir);
gi.multicast(self->s.origin, MULTICAST_PVS);
// if(level.num_reflectors)
// ReflectSparks(self->style,self->s.origin,self->movedir);
}
//======================================================
/*
Spawns a (type) effect at (start} and Broadcasts to all in the
Potentially Hearable set from vector (origin)
TE_EXPLOSION1 5 airburst
TE_EXPLOSION2 6 ground burst
TE_ROCKET_EXPLOSION 7 rocket explosion
TE_GRENADE_EXPLOSION 8 grenade explosion
TE_ROCKET_EXPLOSION_WATER 17 underwater rocket explosion
TE_GRENADE_EXPLOSION_WATER 18 underwater grenade explosion
TE_BFG_EXPLOSION 20 BFG explosion sprite
TE_BFG_BIGEXPLOSION 21 BFG particle explosion
TE_BOSSTPORT 22
TE_PLASMA_EXPLOSION 28
TE_PLAIN_EXPLOSION 35
TE_TRACKER_EXPLOSION 47
TE_TELEPORT_EFFECT 48
TE_DBALL_GOAL 49 Identical to TE_TELEPORT_EFFECT?
TE_NUKEBLAST 51
TE_WIDOWSPLASH 52
TE_EXPLOSION1_BIG 53 Works, but requires Rogue models/objects/r_explode2
TE_EXPLOSION1_NP 54
*/
//==============================================================================
void target_effect_explosion (edict_t *self, edict_t *activator)
{
gi.WriteByte(svc_temp_entity);
gi.WriteByte(self->style);
gi.WritePosition(self->s.origin);
gi.multicast(self->s.origin, MULTICAST_PHS);
// if (level.num_reflectors)
// ReflectExplosion (self->style, self->s.origin);
}
//===============================================================================
/* TE_TUNNEL_SPARKS 29
Similar to other splash effects, but Xatrix does some funky things with
the origin so we'll do the same */
void target_effect_tunnel_sparks (edict_t *self, edict_t *activator)
{
vec3_t origin;
int i;
VectorCopy(self->s.origin,origin);
for (i=0; i<self->count; i++)
{
origin[2] += (self->speed * 0.01) * (i + random());
gi.WriteByte (svc_temp_entity);
gi.WriteByte (self->style);
gi.WriteByte (1);
gi.WritePosition (origin);
gi.WriteDir (vec3_origin);
gi.WriteByte (self->sounds + (rand()&7)); // color
gi.multicast (self->s.origin, MULTICAST_PVS);
}
}
//===============================================================================
/* TE_WIDOWBEAMOUT 50
*/
void target_effect_widowbeam(edict_t *self, edict_t *activator)
{
gi.WriteByte (svc_temp_entity);
gi.WriteByte (TE_WIDOWBEAMOUT);
gi.WriteShort (20001);
gi.WritePosition (self->s.origin);
gi.multicast (self->s.origin, MULTICAST_PVS);
}
//===============================================================================
void target_effect_use(edict_t *self, edict_t *other, edict_t *activator)
{
if(self->spawnflags & 1) {
// currently looped on - turn it off
self->spawnflags &= ~1;
self->spawnflags |= 2;
self->nextthink = 0;
return;
}
if(self->spawnflags & 2) {
// currently looped off - turn it on
self->spawnflags &= ~2;
self->spawnflags |= 1;
self->nextthink = level.time + self->wait;
}
if(self->spawnflags & 4) {
// "if_moving" set. If movewith target isn't moving,
// don't play
edict_t *mover;
if(!self->movewith) return;
mover = G_Find(NULL,FOFS(targetname),self->movewith);
if(!mover) return;
if(!VectorLength(mover->velocity)) return;
}
self->play(self,activator);
}
void target_effect_think(edict_t *self)
{
self->play(self,NULL);
self->nextthink = level.time + self->wait;
}
//===============================================================================
void SP_target_effect (edict_t *self)
{
self->class_id = ENTITY_TARGET_EFFECT;
if(self->movewith)
self->movetype = MOVETYPE_PUSH;
else
self->movetype = MOVETYPE_NONE;
switch (self->style )
{
case TE_FLASHLIGHT:
self->play = target_effect_at;
break;
case TE_STEAM:
self->play = target_effect_steam;
G_SetMovedir (self->s.angles, self->movedir);