-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTFORTTM.QC
1411 lines (1185 loc) · 31.9 KB
/
TFORTTM.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
/*
TeamFortress 2.1 - 22/1/97
TeamFortress Software
Robin Walker, John Cook, Ian Caughley.
Functions handling all the help displaying for TeamFortress.
*/
// Prototypes
// Team Functions
void (float full_clean) CleanUpEverything;
float() TeamFortress_TeamPutPlayerInTeam;
float(float tno) TeamFortress_TeamSet;
float(float tno) TeamFortress_TeamGetColor;
void(float tno) TeamFortress_TeamSetColor;
void() TeamFortress_CheckTeamCheats;
void(float tno, float scoretoadd) TeamFortress_TeamIncreaseScore;
float(float tno) TeamFortress_TeamGetScore;
float (float tno) TeamFortress_TeamGetLives;
float(float tno) TeamFortress_TeamGetNoPlayers;
float (float tno) TeamFortress_TeamGetMaxPlayers;
float() TeamFortress_TeamGetWinner;
void(float all, float teamscored, float scorepoints) TeamFortress_TeamShowScores;
string(float tno) TeamFortress_TeamGetColorString;
void(entity Player) TeamFortress_TeamShowMemberClasses;
float(float tno) TeamFortress_TeamGetIllegalClasses;
float(float tno) TeamFortress_TeamIsCivilian;
#ifdef QUAKE_WORLD
void(entity p) SetTeamName;
#endif
string(float tno) GetTrueTeamName;
//-------- OfN ---------------------------------//
void(float tno, entity ignore) teamprefixsprint;
//- OfN - Extra cheat checking...
float (string skin_str) Is_TF_Skin;
float (float tno, float theColor ) IsValidTopColor;
//=========================================================================
// TEAM FUNCTIONS
//=========================================================================
// Put the player into the team with the least number of players in it. Return #TRUE if successful
float() TeamFortress_TeamPutPlayerInTeam =
{
local float i, j, lowest, likely_team;
//local string st;
//WK 1/7/7 Use KKMay's Server Side function to do this??
i = 1;
likely_team = random() * number_of_teams;
likely_team = ceil(likely_team);
if (likely_team == 0)
likely_team = number_of_teams;
lowest = 33;
while (i < (number_of_teams + 1))
{
j = TeamFortress_TeamGetNoPlayers(i);
if (j <= lowest) //WK j < lowest
{
// Is the team full?
if (TeamFortress_TeamGetMaxPlayers(i) > j)
{
if (lowest == j) { //WK tie
if (random() < (1/number_of_teams)) {
lowest = j;
likely_team = i;
}
}
else {
lowest = j;
likely_team = i;
}
}
}
i = i + 1;
}
// Put the player in likely_team
return TeamFortress_TeamSet(likely_team);
};
//=========================================================================
// Return the color for the team corresponding to the no passed in
float(float tno) TeamFortress_TeamGetColor =
{
if (tno == 1)
return #DARKBLUE;
if (tno == 2)
{
// Neo mode
if (neo) return #WHITE;
return #RED;
}
if (tno == 3)
return #YELLOW;
if (tno == 4)
return #DARKGREEN;
return 0;
};
//=========================================================================
// Set the color for the team corresponding to the no passed in, to self.team_no
void(float tno) TeamFortress_TeamSetColor =
{
if (tno == 1)
{
team1col = #DARKBLUE;
return;
}
if (tno == 2)
{
if (neo) team2col = #WHITE; // Neo mode
else team2col = #RED;
return;
}
if (tno == 3)
{
team3col = #YELLOW;
return;
}
if (tno == 4)
{
team4col = #DARKGREEN;
return;
}
};
#ifdef QUAKE_WORLD
string(float tno) GetTeamName =
{
local string st;
if (tno == 1)
{
/*if (world.b_b != "" && world.b_b != string_null)
{
return world.b_b;
}*/
// for Neo mode
if (neo)
{
local string temp;
temp = colstr("Neo", #COLSTR_RED);
return temp;
}
st = infokey(world, "team1");
if (st == string_null)
st = infokey(world, "t1");
if (st == string_null || st == "")
return "blue";
}
else if (tno == 2)
{
/*if (world.b_t != "" && world.b_t != string_null)
{
return world.b_t;
}*/
// for Neo mode
if (neo) return "Smth";
st = infokey(world, "team2");
if (st == string_null)
st = infokey(world, "t2");
if (st == string_null || st == "")
return "red";
}
else if (tno == 3)
{
/*if (world.b_n != "" && world.b_n != string_null)
{
return world.b_n;
}*/
st = infokey(world, "team3");
if (st == string_null)
st = infokey(world, "t3");
if (st == string_null || st == "")
return "yell";
}
else if (tno == 4)
{
/*if (world.b_o != "" && world.b_o != string_null)
{
return world.b_o;
}*/
st = infokey(world, "team4");
if (st == string_null)
st = infokey(world, "t4");
if (st == string_null || st == "")
return "teal";
}
else
st = "\"\"";
return st;
};
//returns only the team color
string(float tno) GetTrueTeamName =
{
if (tno == 1)
return "Âìõå";
else if (tno == 2)
return "Òåä";
else if (tno == 3)
return "Ùåììï÷";
else if (tno == 4)
return "Çòååî";
else
return "ERROR";
};
#endif
#ifdef QUAKE_WORLD
void(entity p) SetTeamName =
{
local string st;
stuffcmd(p, "team ");
st = GetTeamName(p.team_no);
stuffcmd(p, st);
stuffcmd(p, "\n");
};
#endif
//=========================================================================
// Set the current player's.team_no to self.impulse. Return #TRUE if successful
float(float tno) TeamFortress_TeamSet =
{
local string st;
local float tc;
if (teamplay < 1)
{
sprint (self, #PRINT_HIGH, "Teamplay is not On, so FortressTeams are inactive.\n");
return #FALSE;
}
/* if (chris)
if (prematch > time)
{
sprint(self, #PRINT_HIGH, "Sorry, Chris' Teamplay Plus Mode is active and a round is in progress. Please wait for the next round to begin.\n");
PlayerObserverMode();
}*/
if (tno > number_of_teams && number_of_teams != 0)
{
sprint (self, #PRINT_HIGH, "There can be only ");
st = ftos(number_of_teams);
sprint (self, #PRINT_HIGH, st);
sprint (self, #PRINT_HIGH, " teams on this map.\nTry again\n");
return #FALSE;
}
if (self.team_no > 0)
{
/* WK 5-15-08 We allow people to switch teams in play now
It just blows up all your stuff
sprint (self, #PRINT_HIGH, "You're already in Team No ");
st = ftos(self.team_no);
sprint (self, #PRINT_HIGH, st);
sprint (self, #PRINT_HIGH, ".\n");
return #FALSE;
*/
CleanUpEverything(#TRUE);
}
tc = TeamFortress_TeamGetNoPlayers(tno);
if (tc >= TeamFortress_TeamGetMaxPlayers(tno))
{
//- OfN
if (mapname == "huntedr")
{
if (tno == 3)
sprint (self, #PRINT_HIGH, "The game has already enough assassins, be a bodyguard.\n");
else if (tno == 1)
sprint (self, #PRINT_HIGH, "You wanna be the vicepresident or what?\n");
}
else
sprint (self, #PRINT_HIGH, "That team is full. Pick another.\n");
return #FALSE;
}
// If the color for the team this player is changing to is 0,
// then this is the first player in this team, and we set the
// teamcolor to this player's pants color.
// If not, we change this player's color to this team.
if (TeamFortress_TeamGetColor(tno) == 0)
{
TeamFortress_TeamSetColor(tno);
// If the color wasn't set
if (TeamFortress_TeamGetColor(tno) == 0)
{
sprint (self, #PRINT_HIGH, "You can't start a new team with your color, since another ");
sprint (self, #PRINT_HIGH, "already using that color. Change your pants color, then try again.\n");
return #FALSE;
}
// Announce the new team
bprint(#PRINT_HIGH, self.netname);
bprint(#PRINT_HIGH, " has started Team No ");
st = ftos(tno);
bprint(#PRINT_HIGH, st);
bprint(#PRINT_HIGH, ".\n");
// Prevent the cheatchecking mechanism from nabbing them b4 the
// color command works.
makeImmune(self,time+10);
//self.immune_to_check = time + 10;
// Set the player's color
stuffcmd(self, "color ");
tc = TeamFortress_TeamGetColor(tno) - 1;
st = ftos(tc);
//- OfN - Nice colors
if (nicecolors==1) st =TeamGetNiceColor(tno);
stuffcmd(self, st);
stuffcmd(self, "\n");
self.team_no = tno;
self.connect_time = time; //WK 5-15-08 Start their time they "connected" from the time they joined the team. This gets reset if they switch teams to stop abuse from joining a team to force a reteam of someone on the other side.
self.lives = TeamFortress_TeamGetLives(tno);
#ifdef QUAKE_WORLD
SetTeamName(self);
#endif
// Set the Civilian Class of anyone in a Civilian Team
if (self.playerclass == #PC_UNDEFINED)
{
if (TeamFortress_TeamIsCivilian(self.team_no))
{
self.impulse = 1;
TeamFortress_ChangeClass();
}
}
return #TRUE;
}
// Announce the new teammember
#ifndef OLD_TEAM_ANNOUNCEMENTS
bprint(#PRINT_HIGH, self.netname);
bprint(#PRINT_HIGH, " has joined Team No ");
st = ftos(tno);
bprint(#PRINT_HIGH, st);
st = GetTrueTeamName(tno);
bprint(#PRINT_HIGH, " (", st, " team)\n");
#else
bprint(#PRINT_HIGH, self.netname);
bprint(#PRINT_HIGH, " has joined Team No ");
st = ftos(tno);
bprint(#PRINT_HIGH, ".\n");
#endif
// Set the player's color
stuffcmd(self, "color ");
tc = TeamFortress_TeamGetColor(tno) - 1;
st = ftos(tc);
//- OfN - Nice colors
if (nicecolors==1) st =TeamGetNiceColor(tno);
stuffcmd(self, st);
stuffcmd(self, "\n");
self.team_no = tno;
self.connect_time = time; //WK 5-15-08 Start their time they "connected" from the time they joined the team. This gets reset if they switch teams to stop abuse from joining a team to force a reteam of someone on the other side.
// Prevent the cheatchecking mechanism from nabbing them b4 the
// color command works.
makeImmune(self,time+10);
//self.immune_to_check = time + 10;
self.lives = TeamFortress_TeamGetLives(tno);
// Tell them what class the other members of their team are
TeamFortress_TeamShowMemberClasses(self);
#ifdef QUAKE_WORLD
SetTeamName(self);
#endif
// Set the Civilian Class of anyone in a Civilian Team
if (self.playerclass == #PC_UNDEFINED)
{
if (TeamFortress_TeamIsCivilian(self.team_no))
{
self.impulse = 1;
TeamFortress_ChangeClass();
}
}
//RJM
if (toggleflags & #TFLAG_TEAMFRAGS)
self.frags = TeamFortress_TeamGetScore(self.team_no);
//RJM
//- OfN Team3 should have less players than red in Hunted
if (mapname == "huntedr")
{
local float result;
result = floor(TeamFortress_TeamGetNoPlayers(2) * #HUNTED_YELLOWTEAM_FACTOR);
team3maxplayers = result;
if (team3maxplayers < 1) team3maxplayers = 1;
}
else
if (mapname == "border1" || mapname == "border1r")
{
local float result;
result = floor(TeamFortress_TeamGetNoPlayers(2) * #BORDER_FACTOR);
team3maxplayers = result;
team1maxplayers = result;
if (team3maxplayers < 1) team3maxplayers = 1;
if (team1maxplayers < 1) team1maxplayers = 1;
}
// OfN - Adjust his teammates army rating as needed
ArmyRatingJoin(self);
// PZ - created playersOnTeam# for AGR mode
if (self.team_no == 1) playersOnTeam1 = playersOnTeam1 + 1;
else if (self.team_no == 2) playersOnTeam2 = playersOnTeam2 + 1;
else if (self.team_no == 3) playersOnTeam3 = playersOnTeam3 + 1;
else if (self.team_no == 4) playersOnTeam4 = playersOnTeam4 + 1;
return #TRUE;
};
//=========================================================================
// Make sure no-one is changing their colors
void() TeamFortress_CheckTeamCheats =
{
local string st, sk;
local float tc;
local float rate;
if (self.immune_to_chec > time)
return;
if (self.deadflag)
return;
#ifdef COOP_MODE
if (coop && !deathmatch) // don't worry about it if in coop game
return;
#endif
//WK Add in hack for "skins" cheat. This is as good a place as any
if (self.netname == string_null) {
stuffcmd(self,"name \"I'm a cheater even when RENAMED\"\n");
stuffcmd(self,"disconnect\n");
}
#ifdef QUAKE_WORLD
//WK Limit rate to 10k?
st = infokey(self,"rate");
if (st != string_null)
rate = stof(st);
if (rate > 10000) {
stuffcmd(self,"rate 10000\n");
}
#endif
//- OfN - Added checking for topcolor changes... (see IsValidTopColor in OfteN.qc)
local float tTopColor;
st = infokey(self,"topcolor");
tTopColor=stof(st);
// Have they changed color?
if (self.team_no > 0 && teamplay > 0)
{
#ifndef QUAKE_WORLD
// if they're a spy, check to see if they've changed colors manually
if ((self.cutf_items & #CUTF_SPY_KIT) && self.undercover_team != 0)
{
if (TeamFortress_TeamGetColor(self.undercover_team) != self.team) //- OfN
//if ((TeamFortress_TeamGetColor(self.undercover_team) != self.team) || !IsValidTopColor(self.undercover_team,tTopColor))
// || !IsValidTopColor(self.undercover_team,tTopColor)
{
// Set their color
stuffcmd(self, "color ");
tc = TeamFortress_TeamGetColor(self.undercover_team) - 1;
st = ftos(tc);
//- OfN - Nice colors
if (nicecolors==1) st =TeamGetNiceColor(self.undercover_team);
stuffcmd(self, st);
stuffcmd(self, "\n");
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
stuffcmd(self, "disconnect\n");
return;
}
}
else if (TeamFortress_TeamGetColor(self.team_no) != self.team)
{
// Set their color
stuffcmd(self, "color ");
tc = TeamFortress_TeamGetColor(self.team_no) - 1;
st = ftos(tc);
//- OfN - Nice colors
if (nicecolors==1) st =TeamGetNiceColor(self.team_no);
stuffcmd(self, st);
stuffcmd(self, "\n");
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
stuffcmd(self, "disconnect\n");
return;
}
#else
// QuakeWorld
st = infokey(self, "bottomcolor");
tc = stof(st);
// if they're a spy, check to see if they've changed colors manually
if ((self.cutf_items & #CUTF_SPY_KIT) && self.undercover_team != 0)
{
if ((TeamFortress_TeamGetColor(self.undercover_team) - 1) != tc || !IsValidTopColor(self.undercover_team,tTopColor))
{
#ifdef CHEAT_WARNINGS
RPrint(self.netname);
RPrint(" had his colors reset.\n");
#endif
// Set the player's color
stuffcmd(self, "color ");
tc = TeamFortress_TeamGetColor(self.undercover_team) - 1;
st = ftos(tc);
//- OfN - Nice colors
if (nicecolors==1) st =TeamGetNiceColor(self.undercover_team);
stuffcmd(self, st);
stuffcmd(self, "\n");
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
stuffcmd(self, "disconnect\n");
return;
}
}
else if (tc != (TeamFortress_TeamGetColor(self.team_no) - 1) || !IsValidTopColor(self.team_no,tTopColor))
{
#ifdef CHEAT_WARNINGS
RPrint(self.netname);
RPrint(" had his colors reset.\n");
#endif
// Set the player's color
stuffcmd(self, "color ");
tc = TeamFortress_TeamGetColor(self.team_no) - 1;
st = ftos(tc);
//- OfN - Nice colors
if (nicecolors==1) st =TeamGetNiceColor(self.team_no);
stuffcmd(self, st);
stuffcmd(self, "\n");
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing color.\n");
sprint(self, #PRINT_HIGH, "You have been kicked for changing your color. Don't do it.\n");
stuffcmd(self, "disconnect\n");
return;
}
#endif
// Have they changed their skin?
#ifdef QUAKE_WORLD
if (self.playerclass != #PC_UNDEFINED)
{
//WK For some reason, this isn't reading right for el PC_CUSTOM
st = infokey(self, "skin");
tc = 0;
// OfN kick custom player classes using a non TF-skin
if (self.playerclass == #PC_CUSTOM && !Is_TF_Skin(st))
{
TeamFortress_SetSkin(self);
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n");
sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n");
stuffcmd(self, "disconnect\n");
}
if ((self.cutf_items & #CUTF_SPY_KIT) && self.undercover_skin != 0)
{
//WK tc = #PC_SPY;
tc = self.playerclass;
self.playerclass = self.undercover_skin;
}
if ( self.playerclass == #PC_SCOUT )
sk = "tf_scout";
else if ( self.playerclass == #PC_SNIPER )
sk = "tf_snipe";
else if ( self.playerclass == #PC_SOLDIER )
sk = "tf_sold";
else if ( self.playerclass == #PC_DEMOMAN )
sk = "tf_demo";
else if ( self.playerclass == #PC_MEDIC )
sk = "tf_medic";
else if ( self.playerclass == #PC_HVYWEAP )
sk = "tf_hwguy";
else if ( self.playerclass == #PC_PYRO )
sk = "tf_pyro";
else if ( self.playerclass == #PC_SPY )
sk = "tf_spy";
else if ( self.playerclass == #PC_ENGINEER )
sk = "tf_eng";
else
{
if ((self.cutf_items & #CUTF_SPY_KIT) && self.undercover_skin != 0)
{
self.playerclass = tc;
}
return; //WK Don't check as a safety precaution.
}
if (self.cutf_items & #CUTF_SPY_KIT && self.undercover_skin != 0)
{
//sprint(self,#PRINT_HIGH,"Mommy Wuvs You!\n");
self.playerclass = tc;
}
//WK Ignore our custom, spy-kitting friends. Kick everyone else
if ((st != sk) && !((self.playerclass == #PC_CUSTOM) && (self.cutf_items & #CUTF_SPY_KIT)))
{
#ifdef CHEAT_WARNINGS
RPrint(self.netname);
RPrint(" had his skin reset.\n");
#endif
TeamFortress_SetSkin(self);
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing skin.\n");
sprint(self, #PRINT_HIGH, "You have been kicked for changing your skin. Don't do it.\n");
stuffcmd(self, "disconnect\n");
}
}
// Have they Changed their Team?
st = GetTeamName(self.team_no);
if (st != infokey(self, "team"))
{
if (self.penance_time < time) { //Ignore if we're cursed
#ifdef CHEAT_WARNINGS
RPrint(self.netname);
RPrint(" had his team reset.\n");
#endif
// Set the player's team
SetTeamName(self);
bprint2(#PRINT_MEDIUM, self.netname, " has been kicked for changing team.\n");
sprint(self, #PRINT_HIGH, "You have been kicked for changing your team. Don't do it.\n");
stuffcmd(self, "disconnect\n");
return;
}
}
#endif
}
};
//=========================================================================
// Increase the score of a team
void(float tno, float scoretoadd) TeamFortress_TeamIncreaseScore =
{
local entity e;
if (tno == 0 || scoretoadd == 0)
return;
if (tno == 1)
team1score = team1score + scoretoadd;
if (tno == 2)
team2score = team2score + scoretoadd;
if (tno == 3)
team3score = team3score + scoretoadd;
if (tno == 4)
team4score = team4score + scoretoadd;
// If TeamFrags is on, update all the team's player's frags.
if (toggleflags & #TFLAG_TEAMFRAGS)
{
e = find(world, classname, "player");
while (e)
{
if (e.team_no == tno)
e.frags = TeamFortress_TeamGetScore(tno);
e = find(e, classname, "player");
}
}
};
//=========================================================================
// Return the score of a team
float (float tno) TeamFortress_TeamGetScore =
{
if (tno == 1)
return team1score;
if (tno == 2)
return team2score;
if (tno == 3)
return team3score;
if (tno == 4)
return team4score;
return 0;
};
//=========================================================================
// Return the number of lives each team member in a team has
float (float tno) TeamFortress_TeamGetLives =
{
if (tno == 1)
return team1lives;
if (tno == 2)
return team2lives;
if (tno == 3)
return team3lives;
if (tno == 4)
return team4lives;
return 0;
};
//=========================================================================
// WK -- Return the number of players in the game
// WK -- We really needed a function like this for a while. =p (4/27/7)
float () TeamFortress_GetNoPlayers =
{
local float playercount;
local entity search;
playercount = 0;
search = find (world, classname, "player");
while (search != world)
{
playercount = playercount + 1;
search = find (search, classname, "player");
}
return playercount;
};
//=========================================================================
// Return the number of players in a team
float (float tno) TeamFortress_TeamGetNoPlayers =
{
local float size_team;
local entity search;
//local string st;
search = find (world, classname, "player");
while (search != world)
{
if (search.team_no == tno)
size_team = size_team + 1;
search = find (search, classname, "player");
}
return size_team;
};
//=========================================================================
// Return the number of lives each team member in a team has
float (float tno) TeamFortress_TeamGetMaxPlayers =
{
if (tno == 1)
return team1maxplayers;
if (tno == 2)
return team2maxplayers;
if (tno == 3)
return team3maxplayers;
if (tno == 4)
return team4maxplayers;
return 0;
};
//=========================================================================
// Return the team that's winning
float() TeamFortress_TeamGetWinner =
{
local float i,j,highest,highestteam;
i = 1;
highest = 0;
highestteam = 0;
while (i < (number_of_teams + 1))
{
j = TeamFortress_TeamGetScore(i);
if (j > highest)
{
highest = j;
highestteam = i;
}
i = i + 1;
}
return highestteam;
};
//=========================================================================
// Return the team that's winning
/*CH i saw no uses
float() TeamFortress_TeamGetSecond =
{
local float i,j,highest,highestteam, secondteam, second;
i = 1;
highestteam = TeamFortress_TeamGetWinner();
highest = TeamFortress_TeamGetScore(highestteam);
secondteam = 0;
second = 0;
while (i < (number_of_teams + 1))
{
j = TeamFortress_TeamGetScore(i);
if (j < highest && j > second)
{
second = j;
secondteam = i;
}
i = i + 1;
}
return secondteam;
};
*/
//=========================================================================
// Display all the Team Scores
void(float all, float teamscored, float scorepoints) TeamFortress_TeamShowScores =
{
local string st;
local float i,j;
i = 1;
// OfN - End of map team scores
if (all == 3)
{
// long scores
while (i <= number_of_teams)
{
if (TeamFortress_TeamGetColor(i) > 0)
{
st = ftos(i);
bprint (#PRINT_HIGH, "Team ", st, " (");
st = GetTrueTeamName(i);
st = strcat(st,") ");
st = padstr(st,8);
st = strcat(st,": ");
bprint (#PRINT_HIGH, st);
j = TeamFortress_TeamGetScore(i);
st = ftos(j);
st = colstr(st,#COLSTR_NUMBER);
if (j < 10)
bprint(#PRINT_HIGH," ");
else if (j < 100)
bprint(#PRINT_HIGH," ");
bprint (#PRINT_HIGH, st, " points\n");
}
i = i + 1;
}
return;
}
// short scores
if (all == 2)
{
while (i <= number_of_teams)
{
if (TeamFortress_TeamGetColor(i) > 0)
{
j = TeamFortress_TeamGetScore(i);
st = TeamFortress_TeamGetColorString(i);
bprint(#PRINT_HIGH, st);
bprint(#PRINT_HIGH, ": ");
st = ftos(j);
bprint(#PRINT_HIGH, st);
bprint(#PRINT_HIGH, " ");
}
i = i + 1;
}
if (!teamscored)
bprint(#PRINT_HIGH," (mixed scoring)\n");
else
{
st = GetTrueTeamName(teamscored);
bprint(#PRINT_HIGH," [",st," scores ");
st = ftos(scorepoints);
st = colstr(st,#COLSTR_NUMBER);
bprint(#PRINT_HIGH,st,"]\n");
}
return;
}
// long scores
while (i <= number_of_teams)
{
if (TeamFortress_TeamGetColor(i) > 0)
{
if (all)
bprint (#PRINT_HIGH, "Team ");
else
sprint (self, #PRINT_HIGH, "Team ");
st = ftos(i);
if (all)
bprint (#PRINT_HIGH, st);
else
sprint (self, #PRINT_HIGH, st);
if (all)
bprint (#PRINT_HIGH, " (");
else
sprint (self, #PRINT_HIGH, " (");
st = TeamFortress_TeamGetColorString(i);
if (all)
bprint (#PRINT_HIGH, st);
else
sprint (self, #PRINT_HIGH, st);
if (all)
bprint (#PRINT_HIGH, ") : ");
else
sprint (self, #PRINT_HIGH, ") : ");
j = TeamFortress_TeamGetScore(i);
st = ftos(j);
if (all)
bprint (#PRINT_HIGH, st);
else
sprint (self, #PRINT_HIGH, st);
if (all)
bprint (#PRINT_HIGH, "\n");
else
sprint (self, #PRINT_HIGH, "\n");
}
i = i + 1;
}
};
//=========================================================================
// Return a string containing the color of the team passed in tno
string(float tno) TeamFortress_TeamGetColorString =
{
local float col;
col = TeamFortress_TeamGetColor(tno);
if (col == 1)
return "White";
if (col == 2)
return "Brown";
if (col == 3)
return "LightBlue"; //- OfN was blue
if (col == 4)
return "Green";
if (col == 5)
return "Red";
if (col == 6)
return "Tan";
if (col == 7)
return "Pink";
if (col == 8)
return "Orange";
if (col == 9)