-
Notifications
You must be signed in to change notification settings - Fork 2
/
p_client.c
4609 lines (3931 loc) · 115 KB
/
p_client.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
/* D-Day: Normandy by Vipersoft
************************************
* $Source: /usr/local/cvsroot/dday/src/p_client.c,v $
* $Revision: 1.63 $
* $Date: 2002/07/23 07:26:15 $
*
***********************************
Copyright (C) 2002 Vipersoft
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "g_local.h"
#include "m_player.h"
#include "g_cmds.h"
#include "x_fire.h"
//#include "p_menus.h"
void ShowGun(edict_t* ent);
void SwitchToObserver(edict_t* ent);
void ClientUserinfoChanged(edict_t* ent, char* userinfo);
//void weapon_grenade_fire (edict_t *ent, int team, float time)
//bcass start - TNT
void weapon_tnt_fire(edict_t* ent);
//bcass end
void SP_misc_teleporter_dest(edict_t* ent);
void change_stance(edict_t* self, int stance);
qboolean Cmd_Scope_f(edict_t* ent);
void Drop_Weapon(edict_t* ent, gitem_t* item);
void weapon_grenade_fire(edict_t* ent);
void check_unscope(edict_t* ent);//faf
//
// Gross, ugly, disgustuing hack section
//
// this function is an ugly as hell hack to fix some map flaws
//
// the coop spawn spots on some maps are SNAFU. There are coop spots
// with the wrong targetname as well as spots with no name at all
//
// we use carnal knowledge of the maps to fix the coop spot targetnames to match
// that of the nearest named single player spot
static void SP_FixCoopSpots(edict_t* self)
{
edict_t* spot = NULL; /* MetalGod moved initialization/assignment up here. */
vec3_t d;
while (1)
{
spot = G_Find(spot, FOFS(classname), "info_player_start");
if (!spot)
return;
if (!spot->targetname)
continue;
VectorSubtract(self->s.origin, spot->s.origin, d);
if (VectorLength(d) < 384)
{
if ((!self->targetname) || Q_stricmp(self->targetname, spot->targetname) != 0)
{
// gi.dprintf("FixCoopSpots changed %s at %s targetname from %s to %s\n", self->classname, vtos(self->s.origin), self->targetname, spot->targetname);
self->targetname = spot->targetname;
}
return;
}
}
}
// now if that one wasn't ugly enough for you then try this one on for size
// some maps don't have any coop spots at all, so we need to create them
// where they should have been
static void SP_CreateCoopSpots(edict_t* self)
{
edict_t* spot;
if (Q_stricmp(level.mapname, "security") == 0)
{
spot = G_Spawn();
spot->classname = "info_player_coop";
spot->s.origin[0] = 188 - 64;
spot->s.origin[1] = -164;
spot->s.origin[2] = 80;
spot->targetname = "jail3";
spot->s.angles[1] = 90;
spot = G_Spawn();
spot->classname = "info_player_coop";
spot->s.origin[0] = 188 + 64;
spot->s.origin[1] = -164;
spot->s.origin[2] = 80;
spot->targetname = "jail3";
spot->s.angles[1] = 90;
spot = G_Spawn();
spot->classname = "info_player_coop";
spot->s.origin[0] = 188 + 128;
spot->s.origin[1] = -164;
spot->s.origin[2] = 80;
spot->targetname = "jail3";
spot->s.angles[1] = 90;
return;
}
}
/* needs testing
void SP_info_team_start(edict_t *ent);
//faf: for maps with no info_team_starts
void Create_InfoTeamStarts (edict_t *self)
{
edict_t *spot;
spot = NULL;
spot = G_Find(spot, FOFS(classname), "info_team_start");
if (spot)
return;
gi.dprintf("WARNING: No info_team_start entities found. Creating from scratch.\n");
spot = G_Spawn();
spot->classname = "info_team_start";
spot->dmg = 50;
spot->map = "dday1";
spot->count = 99;
spot->pathtarget = "usa";
spot->obj_owner = 0;
spot->message = "Allies";
SP_info_team_start(spot);
spot = G_Spawn();
spot->classname = "info_team_start";
spot->dmg = 50;
spot->map = "dday1";
spot->count = 99;
spot->pathtarget = "grm";
spot->obj_owner = 1;
spot->message = "Axis";
SP_info_team_start(spot);
}
*/
/*QUAKED info_player_start (1 0 0) (-16 -16 -24) (16 16 32)
the normal starting point for a level.
*/
//void Create_CTB_Entities(edict_t* self);
void SP_info_player_start(edict_t* self)
{
//Create_CTB_Entities(self);
//faf
// Create_InfoTeamStarts(self);
if (!coop->value)
return;
if (Q_stricmp(level.mapname, "security") == 0)
{
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_CreateCoopSpots;
self->nextthink = level.time + FRAMETIME;
}
}
/*QUAKED info_player_deathmatch (1 0 1) (-16 -16 -24) (16 16 32)
potential spawning position for deathmatch games
*/
void SP_info_player_deathmatch(edict_t* self)
{
if (!deathmatch->value)
{
G_FreeEdict(self);
return;
}
SP_misc_teleporter_dest(self);
}
/*QUAKED info_player_coop (1 0 1) (-16 -16 -24) (16 16 32)
potential spawning position for coop games
*/
void SP_info_player_coop(edict_t* self)
{
if (!coop->value)
{
G_FreeEdict(self);
return;
}
if ((Q_stricmp(level.mapname, "jail2") == 0) ||
(Q_stricmp(level.mapname, "jail4") == 0) ||
(Q_stricmp(level.mapname, "mine1") == 0) ||
(Q_stricmp(level.mapname, "mine2") == 0) ||
(Q_stricmp(level.mapname, "mine3") == 0) ||
(Q_stricmp(level.mapname, "mine4") == 0) ||
(Q_stricmp(level.mapname, "lab") == 0) ||
(Q_stricmp(level.mapname, "boss1") == 0) ||
(Q_stricmp(level.mapname, "fact3") == 0) ||
(Q_stricmp(level.mapname, "biggun") == 0) ||
(Q_stricmp(level.mapname, "space") == 0) ||
(Q_stricmp(level.mapname, "command") == 0) ||
(Q_stricmp(level.mapname, "power2") == 0) ||
(Q_stricmp(level.mapname, "strike") == 0))
{
// invoke one of our gross, ugly, disgusting hacks
self->think = SP_FixCoopSpots;
self->nextthink = level.time + FRAMETIME;
}
}
/* QUAKED info_player_intermission (1 0 1) (-16 -16 -24) (16 16 32)
he deathmatch intermission point will be at one of these
se 'angles' instead of 'angle', so you can set pitch or roll as well as yaw. 'pitch yaw roll'
*/
/*
void SP_info_player_intermission(void){}
void SP_info_reinforcement_start(edict_t *ent);
void SP_info_Infantry_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_L_Gunner_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_H_Gunner_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_Sniper_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_Engineer_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_Medic_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_Flamethrower_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_Special_Start(edict_t *ent){SP_info_reinforcement_start(ent);}
void SP_info_Officer_Start(edict_t *ent) {SP_info_reinforcement_start(ent);}
*/
void SP_info_player_intermission(edict_t* ent) {} /* MetalGod make the prototype match the actual function */
void SP_info_reinforcement_start(edict_t* ent);
void SP_info_Infantry_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][INFANTRY].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_L_Gunner_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][L_GUNNER].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_H_Gunner_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][H_GUNNER].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_Sniper_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][SNIPER].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_Engineer_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][ENGINEER].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_Medic_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][MEDIC].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_Flamethrower_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][FLAMER].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_Special_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][SPECIAL].limit = ent->count;
SP_info_reinforcement_start(ent);
}
void SP_info_Officer_Start(edict_t* ent)
{
if (ent->count)
mapclasslimits[ent->obj_owner][OFFICER].limit = ent->count;
SP_info_reinforcement_start(ent);
}
//=======================================================================
void player_pain(edict_t* self, edict_t* other, float kick, int damage)
{
// player pain is handled at the end of the frame in P_DamageFeedback
}
qboolean IsFemale(edict_t* ent)
{
// char *info;
// if (!ent->client)
// return false;
// info = Info_ValueForKey (ent->client->pers.userinfo, "skin");
// if (info[0] == 'f' || info[0] == 'F')
// return true;
return false;
}
qboolean OnSameTeam(edict_t* self, edict_t* target);
void ClientObituary(edict_t* self, edict_t* inflictor, edict_t* attacker)
{
int mod, i;
char* message;
char* message2;
char* message3;
qboolean ff;
edict_t* Tent;
/* MetalGod Sanity check */
if (!self || !self->client)
{
return;
}
/* MetalGod */
/*-----/ PM /-----/ MODIFIED: Condition split up for portability. /-----*/
if (coop->value)
if (attacker->client)
meansOfDeath |= MOD_FRIENDLY_FIRE;
/*-----------------------------------------------------------------------*/
if (deathmatch->value || coop->value)
{
ff = meansOfDeath & MOD_FRIENDLY_FIRE;
mod = meansOfDeath & ~MOD_FRIENDLY_FIRE;
message = NULL;
message2 = "";
switch (mod)
{
case MOD_SUICIDE:
message = "suicides";
break;
case MOD_FALLING:
message = "fell to his death";
break;
case MOD_CRUSH:
message = "was squished";
break;
case MOD_WATER:
message = "drowned";
break;
case MOD_SLIME:
message = "melted";
break;
case MOD_LAVA:
message = "tripped on barbedwire";
break;
case MOD_EXPLOSIVE:
case MOD_BARREL:
message = "blew up";
break;
case MOD_EXIT:
message = "found a way out";
break;
case MOD_TARGET_LASER:
message = "saw the light";
break;
case MOD_TARGET_BLASTER:
message = "got blasted";
break;
case MOD_BOMB:
case MOD_SPLASH:
case MOD_TRIGGER_HURT:
if (inflictor->deathtarget)
message = inflictor->deathtarget;
else
message = "was in the wrong place";
break;
case MOD_CHANGETEAM:
message = "changed teams";
break;
case MOD_CHANGETEAM_WOUNDED:
message = "changed teams";
break;
case MOD_PENALTY:
message = NULL; // penalties have their own obituaries
break;
case MOD_NOMOD:
message = NULL;
break;
}
if (message) //already have message = killed self somehow
{
if (self->ai && self->client->resp.team_on)
{
int teamnum = self->client->resp.team_on->index;
if (botchat->value && (int)rand() % ((int)botchatfreq->value) == 1 && botchat_self_count[teamnum])
{
self->ai->chatdelay = 10;
self->ai->chat = botchat_self[teamnum][(int)rand() % (botchat_self_count[teamnum])];
ParseBotChat(self->ai->chat, self);
}
}
}
if (attacker == self)
{
if (self->ai && self->client->resp.team_on)
{
int teamnum = self->client->resp.team_on->index;
if (botchat->value && botchat_self_count[teamnum])
{
self->ai->chatdelay = 10;
self->ai->chat = botchat_self[teamnum][(int)rand() % (botchat_self_count[teamnum])];
ParseBotChat(self->ai->chat, self);
}
}
switch (mod)
{
case MOD_HELD_TNT:
message = "forgot to drop the TNT";
break;
case MOD_HELD_GRENADE:
message = "tried to put the pin back in";
break;
case MOD_HG_SPLASH:
case MOD_G_SPLASH:
if (IsFemale(self))
message = "tripped on her own grenade";
else
message = "tripped on his own grenade";
break;
case MOD_R_SPLASH:
if (IsFemale(self))
message = "blew herself up";
else
message = "blew himself up";
break;
case MOD_SPAWNCAMP://faf
message = "was killed for being in a spawn area";
break;
case MOD_AIRSTRIKE_SPLASH: //faf
if (IsFemale(self))
message = "called an airstrike on herself";
else
message = "called an airstrike on himself";
break;
/*-----/ PM /-----/ NEW: Fire related obituaries for suicides. /-----*/
case MOD_FIRE_SPLASH:
case MOD_FIREBALL:
if (IsFemale(self))
message = "burned herself";
else
message = "burned himself";
break;
case MOD_ON_FIRE:
message = "became toast";
break;
/*--------------------------------------------------------------------*/
default:
if (IsFemale(self))
message = "killed herself";
else
message = "killed himself";
break;
}
}
if (message)
{
//faf: if they were wounded before they got themselves killed, name who wounded them.
if (self->client->last_wound_inflictor && self->client->last_wound_inflictor->client && self->client->last_wound_inflictor->client->resp.team_on)
{
self->client->last_wound_inflictor->client->resp.team_on->kills++;
message2 = "(kill credited to";
// if (OnSameTeam (self->client->last_wound_inflictor, self)
// {}
// Means of Death msgs now server customizable
if (death_msg->value == 0) // print to self only
safe_cprintf(self, PRINT_HIGH, "%s %s %s %s).\n", self->client->pers.netname, message, message2, self->client->last_wound_inflictor->client->pers.netname);
else if (death_msg->value == 1 || death_msg->value == 3) // print to everybody
{
for (i = 1; i <= game.maxclients; i++)
{
Tent = &g_edicts[i];
if (!Tent->inuse || !Tent->client)
continue;
// if (self->client->resp.team_on->index == Tent->client->resp.team_on->index)
// {
if (OnSameTeam(Tent, self)) {
safe_cprintf(Tent, PRINT_MEDIUM, "\2%s ", self->client->pers.netname);
}
else {
safe_cprintf(Tent, PRINT_MEDIUM, "%s ", self->client->pers.netname);
}
safe_cprintf(Tent, PRINT_MEDIUM, "%s %s ", message, message2);
if (OnSameTeam(Tent, self->client->last_wound_inflictor)) {
safe_cprintf(Tent, PRINT_MEDIUM, "\2%s", self->client->last_wound_inflictor->client->pers.netname);
}
else {
safe_cprintf(Tent, PRINT_MEDIUM, "%s", self->client->last_wound_inflictor->client->pers.netname);
}
safe_cprintf(Tent, PRINT_MEDIUM, ").\n");
}
if (death_msg->value == 3)
{
gi.cprintf(NULL, PRINT_MEDIUM, "%s ", self->client->pers.netname);
gi.cprintf(NULL, PRINT_MEDIUM, "%s %s ", message, message2);
gi.cprintf(NULL, PRINT_MEDIUM, "%s", self->client->last_wound_inflictor->client->pers.netname);
gi.cprintf(NULL, PRINT_MEDIUM, ").\n");
}
}
else if (death_msg->value == 2) // print to team
{
for (i = 1; i <= game.maxclients; i++)
{
Tent = &g_edicts[i];
if (!Tent->inuse || !Tent->client || !Tent->client->resp.team_on || !Tent->client->resp.mos)
continue;
if (self->client->resp.team_on->index == Tent->client->resp.team_on->index)
safe_cprintf(Tent, PRINT_MEDIUM, "%s %s %s %s).\n", self->client->pers.netname, message, message2, self->client->last_wound_inflictor->client->pers.netname);
}
}
}
else
{
if (death_msg->value == 0) // print to self only
safe_cprintf(self, PRINT_HIGH, "%s %s.\n", self->client->pers.netname, message);
else if (death_msg->value == 1 || death_msg->value == 3) // print to everybody
{
for (i = 1; i <= game.maxclients; i++)
{
Tent = &g_edicts[i];
if (!Tent->inuse || !Tent->client)
continue;
if (OnSameTeam(Tent, self)) {
safe_cprintf(Tent, PRINT_MEDIUM, "\2%s", self->client->pers.netname);
}
else { safe_cprintf(Tent, PRINT_MEDIUM, "%s", self->client->pers.netname); }
safe_cprintf(Tent, PRINT_MEDIUM, " %s.\n", message);
}
if (death_msg->value == 3)
{
gi.cprintf(NULL, PRINT_MEDIUM, "%s", self->client->pers.netname);
gi.cprintf(NULL, PRINT_MEDIUM, " %s.\n", message);
}
}
else if (death_msg->value == 2) // print to team
{
for (i = 1; i <= game.maxclients; i++)
{
Tent = &g_edicts[i];
if (!Tent->inuse || !Tent->client || !Tent->client->resp.team_on || !Tent->client->resp.mos)
continue;
if (self->client->resp.team_on->index == Tent->client->resp.team_on->index)
safe_cprintf(Tent, PRINT_MEDIUM, "%s %s.\n", self->client->pers.netname, message);
}
}
}
if (deathmatch->value)
self->client->resp.score--;
if (!self->ai)
self->enemy = NULL;
return;
}
self->enemy = attacker;
if (attacker && attacker->client)
{
switch (mod)
{
case MOD_PISTOL:
message = "was capped by";
break;
case MOD_SHOTGUN:
message = "was gunned down by";
break;
case MOD_SHOTGUN2:
message = "was shotgunned by";
break;
case MOD_RIFLE:
message = "was shot down by";
message2 = "'s rifle";
break;
case MOD_LMG:
message = "was machinegunned by";
message2 = "'s light machine gun";
break;
case MOD_HMG:
message = "was killed by";
message2 = "'s heavy machine gun";
break;
case MOD_GRENADE:
message = "was popped by";
message2 = "'s grenade";
break;
case MOD_G_SPLASH:
message = "was shredded by";
message2 = "'s shrapnel";
break;
case MOD_ROCKET:
message = "ate";
message2 = "'s rocket";
break;
case MOD_R_SPLASH:
message = "did not survive";
message2 = "'s explosive attack";
break;
case MOD_AIRSTRIKE: //faf
message = "ate";
message2 = "'s airstrike";
break;
case MOD_AIRSTRIKE_SPLASH: //faf
message = "was killed by";
message2 = "'s airstrike";
break;
case MOD_SUBMG:
message = "was gunned down by";
message2 = "'s submachinegun";
break;
case MOD_SNIPER:
message = "was sniped by";
break;
case MOD_HANDGRENADE:
message = "caught";
message2 = "'s handgrenade";
break;
//bcass start - TNT
case MOD_TNT:
message = "caught";
message2 = "'s TNT";
break;
case MOD_TNT_SPLASH:
message = "didn't see";
message2 = "'s TNT";
break;
case MOD_TNT1_SPLASH:
if (IsFemale(self))
message = "tripped on her own TNT";
else
message = "tripped on his own TNT";
break;
//bcass end
case MOD_HG_SPLASH:
message = "didn't see";
message2 = "'s handgrenade";
break;
case MOD_HELD_GRENADE:
message = "feels";
message2 = "'s pain";
break;
case MOD_WOUND:
message = "died of severe wounds inflicted by";
break;
case MOD_TELEFRAG:
message = "tried to invade";
message2 = "'s personal space";
break;
/*-----/ PM /-----/ NEW: Fire related obituaries for frags. /-----*/
case MOD_FIRE_SPLASH:
message = "was scorched by";
break;
case MOD_ON_FIRE:
message = "was cremated by";
break;
case MOD_FIREBALL:
message = "got flamed by";
break;
/*-----------------------------------------------------------------*/
case MOD_KNIFE:
if (attacker->client->pers.weapon &&
attacker->client->pers.weapon->classnameb == WEAPON_KATANA)
message = "was sliced in half by";
else if (attacker->client->pers.weapon &&
attacker->client->pers.weapon->classnameb == WEAPON_SABRE)
message = "was sliced in half by";
else
{
message = "was castrated by";
if (self->client && !self->ai && attacker && attacker->client && !attacker->ai && !OnSameTeam(self, attacker))
attacker->client->resp.stat_castrations++;
}
break;
case MOD_FISTS:
message = "got knocked out by";
if (self->client && !self->ai && attacker && attacker->client && !attacker->ai && !OnSameTeam(self, attacker))
attacker->client->resp.stat_fists++;
break;
case MOD_HELMET:
message = "was helmeted by"; //faf
if (self->client && !self->ai && attacker && attacker->client && !attacker->ai && !OnSameTeam(self, attacker))
attacker->client->resp.stat_helmets++;
break;
case MOD_BAYONET:
message = "was bayoneted by";
break;//faf
case MOD_PLONK:
message = "was flattened by";
break;//faf
case MOD_BOTTLE:
message = "was molotoved by";
break;//faf
case MOD_TANKHIT:
message = "got blown up by";
break;
}
//faf: announce team kills
if (OnSameTeam(attacker, self) && attacker != self)
{
message3 = " (Friendly fire";
if (attacker->ai && attacker->client && attacker->client->resp.team_on)
{
int teamnum = attacker->client->resp.team_on->index;
if (botchat->value && (int)rand() % ((int)botchatfreq->value) == 1 && botchat_sorry_count[teamnum])
{
attacker->ai->chatdelay = 10 + rand() % 9;
attacker->ai->chat = botchat_sorry[teamnum][(int)rand() % (botchat_sorry_count[teamnum])];
ParseBotChat(attacker->ai->chat, self);
}
}
if (self->ai && self->client && self->client->resp.team_on)
{
int teamnum = self->client->resp.team_on->index;
if (botchat->value && (int)rand() % ((int)botchatfreq->value) == 1 && botchat_forgive_count[teamnum])
{
int randchat = (int)rand() % (botchat_forgive_count[teamnum]);
self->ai->chatdelay = 20 + rand() % 9;
self->ai->chat = botchat_forgive[teamnum][randchat];
ParseBotChat(self->ai->chat, attacker);
}
}
}
else
{
message3 = "";
if (self->ai && self->client && self->client->resp.team_on)
{
int teamnum = self->client->resp.team_on->index;
if (botchat->value && (int)rand() % ((int)botchatfreq->value) == 1 && botchat_killed_count[teamnum])
{
self->ai->chatdelay = 10;
self->ai->chat = botchat_killed[teamnum][(int)rand() % (botchat_killed_count[teamnum])];
ParseBotChat(self->ai->chat, attacker);
}
}
}
if (message)
{
// Means of Death msgs now server customizable
if (death_msg->value == 0) // print to self only
safe_cprintf(self, PRINT_HIGH, "%s %s %s%s%s\n", self->client->pers.netname, message, attacker->client->pers.netname, message2, message3);
else if (death_msg->value == 1 || death_msg->value == 3) // print to everybody
{
for (i = 1; i <= game.maxclients; i++)
{
Tent = &g_edicts[i];
if (!Tent->inuse || !Tent->client)
continue;
// if (self->client->resp.team_on->index == Tent->client->resp.team_on->index)
// {
if (OnSameTeam(Tent, self)) {
safe_cprintf(Tent, PRINT_MEDIUM, "\2%s", self->client->pers.netname);
}
else { safe_cprintf(Tent, PRINT_MEDIUM, "%s", self->client->pers.netname); }
safe_cprintf(Tent, PRINT_MEDIUM, " %s ", message);
if (OnSameTeam(Tent, attacker)) {
safe_cprintf(Tent, PRINT_MEDIUM, "\2%s", attacker->client->pers.netname);
}
else { safe_cprintf(Tent, PRINT_MEDIUM, "%s", attacker->client->pers.netname); }
safe_cprintf(Tent, PRINT_MEDIUM, "%s%s", message2, message3);
if (OnSameTeam(attacker, self) && attacker != self)
{
if (self->client->last_wound_inflictor && self->client->last_wound_inflictor->client) {
safe_cprintf(Tent, PRINT_MEDIUM, ", Kill credited to ");
if (OnSameTeam(Tent, self->client->last_wound_inflictor))
safe_cprintf(Tent, PRINT_MEDIUM, "\2%s", self->client->last_wound_inflictor->client->pers.netname);
else
safe_cprintf(Tent, PRINT_MEDIUM, "%s", self->client->last_wound_inflictor->client->pers.netname);
}
safe_cprintf(Tent, PRINT_MEDIUM, ")\n");
}
else safe_cprintf(Tent, PRINT_MEDIUM, "\n");
}
if (death_msg->value == 3) //print to server console
{
gi.cprintf(NULL, PRINT_MEDIUM, "%s", self->client->pers.netname);
gi.cprintf(NULL, PRINT_MEDIUM, " %s ", message);
gi.cprintf(NULL, PRINT_MEDIUM, "%s", attacker->client->pers.netname);
gi.cprintf(NULL, PRINT_MEDIUM, "%s%s\n", message2, message3);
}
}
else if (death_msg->value == 2) // print to team
{
for (i = 1; i <= game.maxclients; i++)
{
Tent = &g_edicts[i];
if (!Tent->inuse || !Tent->client || !Tent->client->resp.team_on || !Tent->client->resp.mos)
continue;
if (self->client->resp.team_on->index == Tent->client->resp.team_on->index)
safe_cprintf(Tent, PRINT_MEDIUM, "%s %s %s%s%s\n", self->client->pers.netname, message, attacker->client->pers.netname, message2, message3);
}
}
//give credit to original attacker when wounded player is tk'ed.
if (OnSameTeam(attacker, self) && attacker != self && self->client->last_wound_inflictor && self->client->last_wound_inflictor->client)
{
if (self->client->last_wound_inflictor->client->resp.team_on)
{
self->client->last_wound_inflictor->client->resp.team_on->kills++;
self->client->last_wound_inflictor->client->resp.score++;
if (self->client->aim)
self->client->last_wound_inflictor->client->resp.stat_bot_plus++;
else
self->client->last_wound_inflictor->client->resp.stat_human_plus++;
}
}
if (deathmatch->value)
{
if (ff)
attacker->client->resp.score--;
else
attacker->client->resp.score++;
}
return;
}
}
}
/*
if (!mod == MOD_NOMOD) {
safe_bprintf (PRINT_MEDIUM,"%s died.\n", self->client->pers.netname);
if (deathmatch->value)
self->client->resp.score--;
}
*/
}
void Touch_Item(edict_t* ent, edict_t* other, cplane_t* plane, csurface_t* surf);
void TossClientWeapon(edict_t* self)
{
gitem_t* item;
// edict_t *drop;
qboolean quad;
float spread;
if (!deathmatch->value)
return;
if (self->client->weaponstate == WEAPON_DROPPING)
return;//faf: fixes dropping 2 weaps with drop_shot
item = self->client->pers.weapon;
if (!self->client->pers.inventory[self->client->ammo_index])
item = NULL;
if (item &&
((Q_stricmp(item->pickup_name, "Morphine") == 0) ||
(Q_stricmp(item->pickup_name, "Fists") == 0) ||
(Q_stricmp(item->pickup_name, "TNT") == 0) ||
(Q_stricmp(item->pickup_name, "Sandbags") == 0) ||
(Q_stricmp(item->pickup_name, "Binoculars") == 0)))
item = NULL;
if (!((int)(dmflags->value) & DF_QUAD_DROP))
quad = false;
else
quad = (self->client->quad_framenum > (level.framenum + 10));
if (item && quad)
spread = 22.5;
else
spread = 0.0;
// pbowens: fixed the 0 rnd count for persistant rnds on client death
if (item)
{
self->client->v_angle[YAW] -= spread;
// drop = Drop_Item (self, item);
self->client->v_angle[YAW] += spread;
// drop->spawnflags = DROPPED_PLAYER_ITEM;
// pbowens: drop ammo
if (item->ammo &&
item->position &&
(item->position != LOC_KNIFE) &&
(item->position != LOC_GRENADES) &&
(item->position != LOC_TNT) &&
(item->position != LOC_SPECIAL))
{
edict_t* dropped;
gitem_t* ammo_item;
int ammo_index;
ammo_item = FindItem(item->ammo);
ammo_index = ITEM_INDEX(ammo_item);
if (self->client->pers.inventory[ammo_index])
{
if (!ammo_item->drop)
return;
dropped = Drop_Item(self, ammo_item);
dropped->count = self->client->pers.inventory[ammo_index];
dropped->item->quantity = ammo_item->quantity;
self->client->pers.inventory[ammo_index] = 0;
}
}
Drop_Weapon(self, item);
}
/*
if (quad)
{
self->client->v_angle[YAW] += spread;
drop = Drop_Item (self, FindItemByClassname ("item_quad"));
self->client->v_angle[YAW] -= spread;
drop->spawnflags |= DROPPED_PLAYER_ITEM;
drop->touch = Touch_Item;
drop->nextthink = level.time + (self->client->quad_framenum - level.framenum) * FRAMETIME;
drop->think = G_FreeEdict;
}
*/
}
/*
==================
LookAtKiller
==================
*/
void LookAtKiller(edict_t* self, edict_t* inflictor, edict_t* attacker)
{
vec3_t dir;
if (attacker && attacker != world && attacker != self)
{
VectorSubtract(attacker->s.origin, self->s.origin, dir);
}
else if (inflictor && inflictor != world && inflictor != self)
{
VectorSubtract(inflictor->s.origin, self->s.origin, dir);
}
else
{
self->client->killer_yaw = self->s.angles[YAW];
return;
}
self->client->killer_yaw = 180 / M_PI * atan2(dir[1], dir[0]);
}
/*