This repository has been archived by the owner on Dec 18, 2017. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vgm_game.cpp
2734 lines (2601 loc) · 128 KB
/
vgm_game.cpp
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 "vgm_crystal.h"
#include "vgm_game.h"
bool Offensive;
bool EMPon;
bool GGstarted;
void InitiateOffensive() {
Offensive = true;
if (Team_Base_Defense(0)) { Team_Base_Defense(0)->Enable_Power(false); }
if (Team_Base_Defense(1)) { Team_Base_Defense(1)->Enable_Power(false); }
HostMessage("[VGM] --------------------------------");
HostMessage("[VGM] --- Offensive Mode initiated!");
HostMessage("[VGM] --- Base defenses are now offline!");
HostMessage("[VGM] --------------------------------");
Stewie_BackgroundMgrClass::Set_Clouds(50.0f,55.0f,1.0f);
Stewie_BackgroundMgrClass::Set_Lightning(10.0f,0.0f,1.0f,0.0f,1.0f,1.0f);
Stewie_BackgroundMgrClass::Override_Sky_Tint(8.0f,0.0f);
if (Config->Sounds) {
Create_2D_WAV_Sound("amb_airraid.wav");
Create_2D_WAV_Sound("10-stomp.mp3");
//Create_2D_WAV_Sound("m00evag_dsgn0086i1evag_snd.wav");
}
for (Stewie_SLNode<Stewie_cPlayer>* Node = Stewie_cPlayerManager::PlayerList.HeadNode; Node; Node = Node->NodeNext) {
if (!Node->NodeData) { continue; }
if (Node->NodeData->IsActive == false || Node->NodeData->IsInGame == false) { continue; }
GameObject *o = Player_GameObj(Node->NodeData->PlayerId);
TeamPurchaseSettingsDefClass *PT = TeamPurchaseSettingsDefClass::Get_Definition(Node->NodeData->PlayerType.Get());
Powerup((Stewie_SoldierGameObj *)o,Get_Definition_Name(PT->beaconpresetid),true);
if (Config->Sounds) {
if (Node->NodeData->PlayerType.Get() == 0) {
Create_2D_WAV_Sound_Player(o,"m00evag_dsgn0070i1evag_snd.wav");
} else {
Create_2D_WAV_Sound_Player(o,"m00evan_dsgn0074i1evan_snd.wav");
}
}
}
}
void __stdcall ChatMsgHook(Stewie_WideStringClass *string, int vtype, bool popup, int sender, int receiver) {
ChatMsgProcessing(WCharToStr(string->m_Buffer),vtype,popup,sender,receiver);
}
void ChatMsgProcessing(std::string string, int vtype, bool popup, int sender, int receiver) {
bool process = true;
char strraw[1024];
sprintf(strraw,"%s",string.c_str());
const char *str = (const char *)strraw;
if (sender <= 0) { goto doproc; }
if (receiver <= -2) {
vTokenParser *BHSStr = new vTokenParser((char *)str);
BHSStr->Parse("\n");
if (BHSStr->Numtok() >= 3 && !stricmp(BHSStr->Gettok(1).c_str(),"j") && atoi(BHSStr->Gettok(2).c_str()) == sender) {
vBhsVersionTag VerTag;
VerTag.PID = sender;
VerTag.Version = (float)atof(BHSStr->Gettok(3).c_str());
vPManager->Add_BHS_Version(VerTag);
ConsoleOut("[VGM] Detected BHS version of player %d: %.1f",sender,VerTag.Version);
}
BHSStr->Delete();
goto doproc;
}
vPlayer *p = vPManager->Get_Player(sender);
if (!p) { process = false; goto doproc; }
if (p->muted) { process = false; goto doproc; }
if (p->serial == false && Config->BlockNoSerialActions) { process = false; goto doproc; }
int GameTime = vManager.DurationAsInt();
if (GameTime > 1) {
if (p->CSpamExpire > GameTime) { process = false; goto doproc; }
if (p->FirstCSpam <= GameTime - 5) { p->ChatMsgs = 0; }
if (p->ChatMsgs == 0) { p->FirstCSpam = GameTime; }
p->ChatMsgs++;
if (p->ChatMsgs >= 5) {
p->ChatMsgs = 0;
p->CSpamExpire = GameTime + 5;
}
}
vTokenParser *Str = new vTokenParser((char *)str);
Str->Parse(" ");
if (Config->GameMode == Config->vAOW || Config->GameMode == Config->vMONEY || Config->GameMode == Config->vINFONLY) {
if (Execute_AOWCommand(sender,Str,vtype) == false) { process = false; }
else if (Execute_OtherCommand(sender,Str,vtype) == false) { process = false; }
else if (Hide_Command(sender,Str,vtype)) { process = false; }
} else if (Config->GameMode == Config->vSNIPER) {
if (Execute_SniperCommand(sender,Str,vtype) == false) { process = false; }
else if (Execute_OtherCommand(sender,Str,vtype) == false) { process = false; }
else if (Hide_Command(sender,Str,vtype)) { process = false; }
}
Str->Delete();
doproc:
if (process) {
if (vtype == 2) {
if (sender > 0 && receiver > 0) {
New_Chat_Message(sender,receiver > 0 ? receiver : -1,str,false,vtype);
if (Config->ShowPrivateChat) {
vLogger->Log(vLoggerType::vVGM,"_PRIVATE","%s (to %s): %s",Player_Name_From_ID(sender).c_str(),Player_Name_From_ID(receiver).c_str(),str);
}
}
} else {
char str2[512];
sprintf(str2,"%s",Execute_Autocomplete(str).c_str());
if (stricmp(str2,"NULL")) { New_Chat_Message(sender,receiver > 0 ? receiver : -1,str2,false,1); }
else { New_Chat_Message(sender,receiver > 0 ? receiver : -1,str,false,vtype); }
}
}
}
bool Execute_AOWCommand(int ID, vTokenParser *Str, int type) {
int tokens = Str->Numtok();
std::string cmd = Str->Gettok(1);
GameObject *o = Player_GameObj(ID);
#ifdef _DEV_
if (!stricmp(cmd.c_str(),"!freeze")) {
Stewie_BaseGameObj *b = (Stewie_BaseGameObj *)o;
b->Freeze = true;
DebugMessage("%s, Frozen.",b->Definition->Get_Name());
return false;
} else if (!stricmp(cmd.c_str(),"!ff")) {
bool &FriendlyFire = *(bool *)0x000000; // For security and licensing purposes, an address has been hidden from this line
FriendlyFire = (FriendlyFire ? false : true);
DebugMessage("FF toggled.");
return false;
} else if (!stricmp(cmd.c_str(),"!showpos")) {
Vector3 pos = Commands->Get_Position(o);
DebugMessage("Position: %.4f %.4f %.4f",pos.X,pos.Y,pos.Z);
return false;
} else if (!stricmp(cmd.c_str(),"!rv")) {
if (Stewie_cPlayerManager::Tally_Team_Size(1) >= 1) { Create_Vehicle(Find_Random(VehicleCID,1)->Get_Name(),0.0f,Find_First_Player(1),1); }
if (Stewie_cPlayerManager::Tally_Team_Size(0) >= 1) { Create_Vehicle(Find_Random(VehicleCID,0)->Get_Name(),0.0f,Find_First_Player(0),0); }
return false;
} else if (!stricmp(cmd.c_str(),"!d1")) {
DebugMessage("%f",vManager.DurationAsFloat());
return false;
} else if (!stricmp(cmd.c_str(),"!d2")) {
vPlayer *p = vPManager->Get_Player(ID);
if (p) {
int WhoCares = 0;
DebugMessage("PLAYERHITS1 %s %u",p->name.c_str(),p->Hits.size());
for (int i = 0; i < 500; i++) { p->Add_Hit(Commands->Get_ID(o),Get_Held_Weapon((Stewie_SoldierGameObj *)o)->Definition->PrimaryAmmoDefId); }
DebugMessage("PLAYERHITS2 %s %u",p->name.c_str(),p->Hits.size());
DebugMessage("PLAYERGETHITS1 %s %d",p->name.c_str(),clock());
for (int i = 0; i < 500; i++) { WhoCares = p->Get_Hits(Commands->Get_ID(o),1.0f,Get_Held_Weapon((Stewie_SoldierGameObj *)o)->Definition->PrimaryAmmoDefId); }
DebugMessage("PLAYERGETHITS2 %s %d %d",p->name.c_str(),clock(),WhoCares);
} else {
DebugMessage("NOPLAYER");
}
return false;
} else if (!stricmp(cmd.c_str(),"!d3")) {
#ifdef DEBUG
m_dumpLog();
#else
DebugMessage("Cannot commit memory dump in non-debug mode.");
#endif
return false;
}
#endif
if (!stricmp(cmd.c_str(),"!debug8291")) {
unsigned int OCount = 0, PCount = 0, HitsArr = 0, SeensArr = 0;
for (GenericSLNode *Node = BaseGameObjList->HeadNode; Node; Node = Node->NodeNext) {
if (!Node->NodeData) { continue; }
OCount++;
}
for (unsigned int i = 0; i < vPManager->Get_Player_Count(); i++) {
if (!vPManager->Data[i]) { continue; }
PCount++;
HitsArr += vPManager->Data[i]->Hits.size();
SeensArr += vPManager->Data[i]->SeenList.size();
}
unsigned int VehArr = vVManager->Get_Vehicle_Count();
unsigned int VetPtsArr = vVetManager->Pending_VetPoints.size();
unsigned int CheatMsgsArr = vPManager->CheatMessages.size();
unsigned int RecsArr = vPManager->Recommendations.size();
unsigned int BountiesArr = vPManager->Bounties.size();
Stewie_cNetwork::Update_Fps();
HostMessage("[DEBUG1] SFPS: %d ;; Objects: %u ;; V: %u, H: %u, S: %u, P: %u, C: %u, R: %u, B: %u, Total: %u (%u)",Stewie_cNetwork::Fps,OCount,VehArr,HitsArr,SeensArr,VetPtsArr,CheatMsgsArr,RecsArr,BountiesArr,(VehArr + HitsArr + SeensArr + VetPtsArr + CheatMsgsArr + RecsArr + BountiesArr),PCount);
return false;
} else if (!stricmp(cmd.c_str(),"!rweapon") || !stricmp(cmd.c_str(),"!wdrop")) {
int team = Commands->Get_Player_Type(o);
float d = FLT_MAX;
Vector3 Position = Commands->Get_Position(o);
if (team == 1) { d = Find_Distance_To_Closest_Object_By_Preset(Position,"pct_zone_gdi"); }
else if (team == 0) { d = Find_Distance_To_Closest_Object_By_Preset(Position,"pct_zone_nod"); }
if (d > 30.0f) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You must be closer to a friendly Purchase Terminal to drop weapons.");
} else {
const char *Wep = Get_Current_Weapon(o);
if (Get_Weapon_Count(o) <= 1) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your weapon bag is too empty to drop any more weapons!");
} else if (Get_Current_Total_Bullets(o) == 0) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You cannot drop a weapon with no ammo.");
} else if (isin(Wep,"pistol") || isin(Wep,"timed")) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Default weapons cannot be dropped.");
} else {
vPlayer *p = vPManager->Get_Player(ID);
bool CanDrop = true;
if (p) {
CanDrop = false;
for (unsigned int i = 0; i < p->WeaponBag.size(); i++) {
if (!p->WeaponBag[i]) { continue; }
if (!stricmp(Wep,p->WeaponBag[i]->Get_Name())) {
CanDrop = true;
p->WeaponBag.erase(p->WeaponBag.begin() + i);
break;
}
}
}
if (CanDrop == false) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Default weapons cannot be dropped.");
return false;
}
Remove_Weapon(o,Wep);
Stewie_WeaponBagClass *bag = Get_Weapon_Bag((Stewie_ArmedGameObj *)o);
if (bag->Vector.Count() >= 1) { bag->Select_Index(1); }
vWManager->Create_Pack_Weapon(World_Position((Stewie_BaseGameObj *)o),Wep,true,false);
}
}
return false;
} else if (!stricmp(cmd.c_str(),"!buy")) {
vPlayer *p = vPManager->Get_Player(ID);
if (p && tokens >= 2) {
std::string type = Str->Gettok(2);
int Recs = vPManager->Get_Current_Recs(ID);
if (vManager.DurationAsInt() <= Config->VetCmdCooldown) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You must be %s into the game to use the !buy feature.",Duration(Config->VetCmdCooldown).c_str());
} else if (!stricmp(type.c_str(),"veh")) {
int Cost = 15;
if (Recs > Cost) { vPManager->Recommend(-1,ID,-1 * Cost,vRECNONE); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Error; you do not have enough recommendations for this. (Current: %d, Required: %d)",Recs,Cost); return false; }
Vector3 pos = Commands->Get_Position(o);
pos.Z += 5.0f;
GameObject *v = Commands->Create_Object(Find_Random(VehicleCID,Commands->Get_Player_Type(o))->Get_Name(),pos);
Commands->Set_Player_Type(v,-2);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a(n) %s.",Get_Pretty_Name(v).c_str());
vVetManager->Upgrade(v,p->VetRank - 1,2);
} else if (!stricmp(type.c_str(),"char")) {
int Cost = 10;
if (Recs > Cost) { vPManager->Recommend(-1,ID,-1 * Cost,vRECNONE); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Error; you do not have enough recommendations for this. (Current: %d, Required: %d)",Recs,Cost); return false; }
const char *ch = "";
while (Get_Cost(ch) <= 0) { ch = Find_Random(SoldierCID,Commands->Get_Player_Type(o))->Get_Name(); }
Change_Character(o,ch);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a(n) %s character.",Get_Pretty_Name(ch).c_str());
} else if (!stricmp(type.c_str(),"wep") || !stricmp(type.c_str(),"weapon")) {
int Cost = 5;
if (Recs > Cost) { vPManager->Recommend(-1,ID,-1 * Cost,vRECNONE); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Error; you do not have enough recommendations for this. (Current: %d, Required: %d)",Recs,Cost); return false; }
Stewie_WeaponDefinitionClass *w = (Stewie_WeaponDefinitionClass *)Find_Random(WeaponCID);
Stewie_WeaponBagClass *bag = Get_Weapon_Bag((Stewie_ArmedGameObj *)o);
int bullets = w->DSClipSize.Get() + w->DSMaxClipBullets.Get();
if (w->DSMaxClipBullets.Get() == -1) { bullets = -1; }
bag->Add_Weapon(w,bullets,true);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a(n) %s.",Get_Pretty_Name(w->Get_Name()).c_str());
} else if (!stricmp(type.c_str(),"spy")) {
int Cost = 50;
if (Recs > Cost) { vPManager->Recommend(-1,ID,-1 * Cost,vRECNONE); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Error; you do not have enough recommendations for this. (Current: %d, Required: %d)",Recs,Cost); return false; }
Change_Character(o,"CnC_Nod_FlameThrower_2SF");
Set_Is_Visible((Stewie_ScriptableGameObj *)o,false);
HostMessage("[VGM] Warning! Player %s has purchased a Spy.",p->Get_Name());
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a Spy.");
} else if (!stricmp(type.c_str(),"god")) {
int Cost = 50;
if (Recs > Cost) { vPManager->Recommend(-1,ID,-1 * Cost,vRECNONE); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Error; you do not have enough recommendations for this. (Current: %d, Required: %d)",Recs,Cost); return false; }
if (Commands->Get_Player_Type(o) == 1) {
Change_Character(o,"CnC_GDI_RocketSoldier_2SF_Secret");
Commands->Clear_Weapons(o);
Commands->Give_Powerup(o,"CnC_POW_VoltAutoRifle_Player",true);
} else {
Change_Character(o,"CnC_GDI_RocketSoldier_2SF_Secret");
Commands->Clear_Weapons(o);
Commands->Give_Powerup(o,"CnC_POW_VoltAutoRifle_Player_Nod",true);
}
float MH = Commands->Get_Max_Health(o), MSS = Commands->Get_Max_Shield_Strength(o);
Stewie_SoldierGameObjDef *SDef = Get_Soldier_Definition(o);
if (SDef) {
MH = (MH / SDef->HealthMax.Get()) * 500.0f;
MSS = (MSS / SDef->ShieldStrengthMax.Get()) * 500.0f;
} else {
MH = 500.0f;
MSS = 500.0f;
}
Set_Max_Health(o,MH);
Set_Max_Shield_Strength(o,MSS);
Commands->Give_Powerup(o,"CnC_POW_MineRemote_02",true);
Commands->Give_Powerup(o,"CnC_POW_MineTimed_Player_02",true);
Commands->Give_Powerup(o,"CnC_POW_MineProximity_05",true);
Commands->Give_Powerup(o,"POW_Pistol_Player",true);
Commands->Set_Shield_Type(o,"SkinChemWarrior");
Grant_Refill(o);
Remove_Script(o,"SelfRepair");
Stewie_WeaponBagClass *bag = Get_Weapon_Bag((Stewie_ArmedGameObj *)o);
if (bag && bag->Vector.Count() >= 1) { bag->Select_Index(1); }
char params[64];
sprintf(params,"%f,%f",1.0f,1.0f);
Commands->Attach_Script(o,"SelfRepair",params);
HostMessage("[VGM] Warning! Player %s has purchased a God.",p->Get_Name());
if (Config->Sounds) { Create_2D_WAV_Sound("m00gemg_atoc0001i1gemg_snd.wav"); }
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a God.");
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Error; please make sure you have requested one of the following to buy: veh, char, wep, spy, god.");
}
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Error; please make sure you have requested one of the following to buy: veh, char, wep, spy, god.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!wep") || !stricmp(cmd.c_str(),"!weapon")) {
vPlayer *p = vPManager->Get_Player(ID);
if (p && p->VetRank >= Config->VetLevels - 2) {
if (p->LastVetCmds[0] < vManager.DurationAsInt() - Config->VetCmdCooldown) {
FindWep:
Stewie_WeaponDefinitionClass *w = (Stewie_WeaponDefinitionClass *)Find_Random(WeaponCID);
if (isin(w->Get_Name(),"beacon")) { goto FindWep; }
Stewie_WeaponBagClass *bag = Get_Weapon_Bag((Stewie_ArmedGameObj *)o);
int bullets = w->DSClipSize.Get() + w->DSMaxClipBullets.Get();
if (w->DSMaxClipBullets.Get() == -1) { bullets = -1; }
bag->Add_Weapon(w,bullets,true);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a(n) %s.",Get_Pretty_Name(w->Get_Name()).c_str());
p->LastVetCmds[0] = vManager.DurationAsInt();
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You must wait another %d seconds to do this.",(Config->VetCmdCooldown - vManager.DurationAsInt() + p->LastVetCmds[0]));
}
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your veteran level is not high enough to do this.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!char")) {
vPlayer *p = vPManager->Get_Player(ID);
if (p && p->VetRank >= Config->VetLevels - 1) {
if (p->LastVetCmds[1] < vManager.DurationAsInt() - Config->VetCmdCooldown) {
const char *ch = Find_Random(SoldierCID,Commands->Get_Player_Type(o))->Get_Name();
Change_Character(o,ch);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a(n) %s character.",Get_Pretty_Name(ch).c_str());
p->LastVetCmds[1] = vManager.DurationAsInt();
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You must wait another %d seconds to do this.",(Config->VetCmdCooldown - vManager.DurationAsInt() + p->LastVetCmds[1]));
}
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your veteran level is not high enough to do this.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!veh")) {
vPlayer *p = vPManager->Get_Player(ID);
int team = Commands->Get_Player_Type(o);
if (p && p->VetRank >= Config->VetLevels) {
if (p->LastVetCmds[2] < vManager.DurationAsInt() - Config->VetCmdCooldown) {
float d = FLT_MAX;
Vector3 Pos = Commands->Get_Position(o);
if (team == 1) { d = Find_Distance_To_Closest_Object_By_Preset(Pos,"pct_zone_gdi"); }
else if (team == 0) { d = Find_Distance_To_Closest_Object_By_Preset(Pos,"pct_zone_nod"); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You must be on %s or %s to do this.",Get_Translated_Team_Name(1).c_str(),Get_Translated_Team_Name(0).c_str()); return false; }
if (d > 40) { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You are too far from a Purchase Terminal to do this."); return false; }
Vector3 pos = Commands->Get_Position(o);
pos.Z += 5.0f;
GameObject *v = Commands->Create_Object(Find_Random(VehicleCID,team)->Get_Name(),pos);
Commands->Set_Player_Type(v,-2);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been given a(n) %s.",Get_Pretty_Name(v).c_str());
vVetManager->Upgrade(v,p->VetRank - 1,2);
p->LastVetCmds[2] = vManager.DurationAsInt();
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You must wait another %d seconds to do this.",(Config->VetCmdCooldown - vManager.DurationAsInt() + p->LastVetCmds[2]));
}
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your veteran level is not high enough to do this.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!ach") || !stricmp(cmd.c_str(),"!achieves") || !stricmp(cmd.c_str(),"!achievements") || !stricmp(cmd.c_str(),"!vault")) {
const char *nick = Get_Player_Name_By_ID(ID);
bool allowed = false;
if (Config->MedalsRestricted) {
for (int totry = 1; totry <= 256; totry++) {
char entry[64];
sprintf(entry,"User%d",totry);
char result[512];
if (getProfileString("MedalUsers",(const char *)entry,"",result,512,"vgm_users.ini")) {
if (!stricmp(result,nick)) {
allowed = true;
break;
}
}
}
} else {
allowed = true;
for (int totry = 1; totry <= 256; totry++) {
char entry[64];
sprintf(entry,"User%d",totry);
char result[512];
if (getProfileString("MedalUsers",(const char *)entry,"",result,512,"vgm_users.ini")) {
if (!stricmp(result,nick)) {
allowed = false;
break;
}
}
}
}
if (allowed) {
int TotalMedals = 0;
for (unsigned int j = 0; j < (int)vMManager->vLAST; j++) {
char m[16],f[128];
sprintf(m,"Medal%d",j);
sprintf(f,"vgm\\medals_%s.ini",nick);
int Medals = getProfileInt("Medals",(const char*)m,0,(const char*)f);
TotalMedals += Medals;
if (Medals > 0) { PrivMsgColoredVA(ID,2,0,200,200,"[VGM] %s times Achieved: %d",AwardNames[j],Medals); }
}
if (TotalMedals == 0) { PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You have no achievements."); }
else { PrivMsgColoredVA(ID,2,0,200,200,"[VGM] Total %d achievements.",TotalMedals); }
}
return false;
} else if (!stricmp(cmd.c_str(),"!com") || !stricmp(cmd.c_str(),"!command") || !stricmp(cmd.c_str(),"!commander")) {
if (tokens == 1) {
int team = Commands->Get_Player_Type(o);
if (team == 1 && GDICommander > 0) { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your current Team Commander is: %s.",Player_Name_From_ID(GDICommander).c_str()); }
else if (team == 0 && NodCommander > 0) { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your current Team Commander is: %s.",Player_Name_From_ID(NodCommander).c_str()); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your team currently has no Team Commander."); }
} else if (tokens == 2) {
if (Is_Commander(ID,Commands->Get_Player_Type(o),false) == false) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You are not the Commander for your team.");
return false;
}
std::string order = Str->Gettok(2);
if (!stricmp(order.c_str(),"o") || !stricmp(order.c_str(),"order") || !stricmp(order.c_str(),"w") || !stricmp(order.c_str(),"warn") || !stricmp(order.c_str(),"harv")) {
PrivMsgColoredVA(ID,2,0,200,0,"Invalid parameters.");
} else if (!stricmp(order.c_str(),"c4")) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] %s C4: %s",Get_Translated_Team_Name(Commands->Get_Player_Type(o)).c_str(),Find_Proxy_C4_On_Buildings(Commands->Get_Player_Type(o)).c_str());
}
} else if (tokens >= 3) {
if (Is_Commander(ID,Commands->Get_Player_Type(o),false) == false) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You are not the Commander for your team.");
return false;
}
std::string order = Str->Gettok(2);
if (!stricmp(order.c_str(),"o") || !stricmp(order.c_str(),"order")) {
std::string message = Str->Gettok(3,-1);
char m[512];
sprintf(m,"Order from Commander: %s",message.c_str());
Send_Private_Message_Team(Commands->Get_Player_Type(o),m);
} else if (!stricmp(order.c_str(),"w") || !stricmp(order.c_str(),"warn")) {
std::string message = Str->Gettok(3,-1);
char m[512];
sprintf(m,"WARNING from Commander: %s",message.c_str());
Send_Private_Message_Team(Commands->Get_Player_Type(o),m);
} else if (!stricmp(order.c_str(),"harv") && Team_Refinery(Commands->Get_Player_Type(o))) {
std::string message = Str->Gettok(3,-1);
if (!stricmp(message.c_str(),"start")) {
Stewie_HarvesterClass *HarvCheck = Team_Refinery(Commands->Get_Player_Type(o))->Harvester;
if (!HarvCheck) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your team's Harvester is not available.");
return false;
}
Stewie_HarvesterClass &Harvester = *HarvCheck;
if (Harvester.State == 3) { Harvester.Go_Unload_Tiberium(); }
else { Harvester.Go_Harvest(); }
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Harvester started.");
} else if (!stricmp(message.c_str(),"stop")) {
Stewie_BaseControllerClass *Base = Stewie_BaseControllerClass::Find_Base(Commands->Get_Player_Type(o));
Stewie_HarvesterClass *HarvCheck = ((Stewie_RefineryGameObj *)(Stewie_BuildingGameObj *)(Base->Find_Building(vRefinery)))->Harvester;
if (!HarvCheck) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your team's Harvester is not available.");
return false;
}
Stewie_HarvesterClass &Harvester = *HarvCheck;
// TO-DO: Doesn't work whilst harvesting.
Harvester.Stop();
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Harvester stopped.");
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Invalid Command. Please choose %s %s [start/stop].",cmd,order.c_str());
}
return false;
}
}
return false;
} else if (!stricmp(cmd.c_str(),"!d") || !stricmp(cmd.c_str(),"!donate")) {
if (tokens >= 3) {
std::string player = Str->Gettok(2);
std::string amt = Str->Gettok(3);
float amount = 0.0f;
if ((unsigned int)Config->DonateTime > vManager.DurationAsUint()) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] The map must have elapsed %.0f minutes to donate.",float(Config->DonateTime) / 60.0f);
return false;
} else if (!stricmp(amt.c_str(),"all")) {
amount = Commands->Get_Money(o);
} else {
amount = (float)atof(amt.c_str());
}
if (Commands->Get_Money(o) < amount) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You don't have %.0f credits.",amount);
return false;
} else if (amount <= 0.0f) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You can't donate negative credits!");
return false;
}
GameObject *d = Player_GameObj_By_Name(player.c_str());
if (!d) { d = Player_GameObj_By_Part_Name(player.c_str()); }
if (d) {
d = Player_GameObj_By_Part_Name(player.c_str());
if (d == o) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You cannot donate to yourself.");
return false;
}
if (Commands->Get_Player_Type(d) != Commands->Get_Player_Type(o)) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You cannot donate to the other team.");
return false;
}
Commands->Give_Money(o,-1 * amount,false);
Commands->Give_Money(d,amount,false);
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You donated %.0f credits to %s.",amount,Player_Name_From_GameObj(d).c_str());
PrivMsgColoredVA(Get_Player_ID(d),2,0,200,200,"[VGM] You have received %.0f credits from %s.",amount,Player_Name_From_ID(ID).c_str());
if (Config->Sounds) { Create_2D_WAV_Sound_Player(d,"m00pc$$_aqob0002i1evag_snd.wav"); }
return false;
} else {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] Player \"%s\" not found.",player.c_str());
return false;
}
} else {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You must specify an amount and a username! EG: %s Someone 500",cmd.c_str());
}
return false;
} else if (!stricmp(cmd.c_str(),"!td") || !stricmp(cmd.c_str(),"!tdonate")) {
if (tokens >= 2) {
int team = Commands->Get_Player_Type(o);
std::string amt = Str->Gettok(2);
float amount = 0.0f;
if ((unsigned int)Config->DonateTime > vManager.DurationAsUint()) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] The map must have elapsed %.0f minutes to donate.",float(Config->DonateTime) / 60.0f);
return false;
} else if (!stricmp(amt.c_str(),"all")) {
amount = Commands->Get_Money(o);
} else {
amount = (float)atof(amt.c_str());
}
if (amount <= 0.0f) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You can't donate negative credits!");
return false;
}
if ((unsigned int)Config->DonateTime > vManager.DurationAsUint()) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] The map must have elapsed %.0f minutes to donate.",float(Config->DonateTime) / 60.0f);
} else if (Stewie_cPlayerManager::Tally_Team_Size(team) < 2) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You are the only one on your team.");
} else if (amount > Commands->Get_Money(o)) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You do not have that much money.");
} else if (amount > 0) {
int divisors = (int)(Stewie_cPlayerManager::Tally_Team_Size(team) - 1);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have donated %.0f credits to your team. (%.0f each)",amount,floor(float(amount) / float(divisors)));
Commands->Give_Money(o,-1 * amount,false);
amount = floor(float(amount) / float(divisors));
Commands->Give_Money(o,-1 * amount,false);
Give_Money_To_All_Players(amount,team);
PrivMsgColoredVA(-1 * ID,team,0,200,0,"[VGM] You have received %.0f credits from %s.",amount,Player_Name_From_ID(ID).c_str());
Create_2D_WAV_Sound_Team("m00pc$$_aqob0002i1evag_snd.wav",team);
} else {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You must specify an amount greater than zero.");
}
} else {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You must specify an amount! EG: %s 500",cmd.c_str());
}
return false;
} else if (!stricmp(cmd.c_str(),"!tp")) {
int team = Commands->Get_Player_Type(o);
if (tokens >= 2) {
int amount = atoi(Str->Gettok(2).c_str());
if (amount > (int)Commands->Get_Money(o)) {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You do not have that much money.");
} else if (amount > 0) {
if (team == 1) { GDITeamPool += amount; }
else if (team == 0) { NODTeamPool += amount; }
else { return false; }
Commands->Give_Money(o,(float)(-1 * amount),false);
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You have donated %d credits to the team pool.",amount);
if (Has_Commander(team)) {
PrivMsgColoredVA(team == 1 ? GDICommander : NodCommander,2,0,200,200,"[VGM] %s has donated %d credits to the team pool!",Player_Name_From_ID(ID).c_str(),amount);
}
} else {
PrivMsgColoredVA(ID,2,0,200,200,"[VGM] You must specify an amount greater than zero.");
}
} else if (Is_Commander(ID,team,false)) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] The %s Team Pool currently has %d credits.",Get_Translated_Team_Name(team).c_str(),team == 1 ? GDITeamPool : NODTeamPool);
}
return false;
} else if (!stricmp(cmd.c_str(),"!c4")) {
int Team = Commands->Get_Player_Type(o);
if (Team == 1) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Remote: %d/%d - Timed: %d/%d - Proximity: %d/%d",Get_C4_Count_Remote(Team),Config->GDIRemoteC4Limit,Get_C4_Count_Timed(Team),Config->GDITimedC4Limit,Get_C4_Count_Proximity(Team),Config->GDIProximityC4Limit);
} else if (Team == 0) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Remote: %d/%d - Timed: %d/%d - Proximity: %d/%d",Get_C4_Count_Remote(Team),Config->NODRemoteC4Limit,Get_C4_Count_Timed(Team),Config->NODTimedC4Limit,Get_C4_Count_Proximity(Team),Config->NODProximityC4Limit);
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] C4 limits not available.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!bind")) {
GameObject *v = Get_Vehicle(o);
if (v) {
vVehicle *veh = vVManager->Get_Vehicle(Commands->Get_ID(v));
if (veh) {
if (veh->Locked == 0) {
int VehType = Get_Vehicle_Parent_Type(v);
if (VehType == Commands->Get_Player_Type(o)) {
int c = vVManager->Count_Player_Bound_Vehicles(ID,false);
if (c < Config->MaxFriendlyVeh) {
veh->Lock(ID,1);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle (%s) has been bound to you.",Get_Pretty_Name(v).c_str());
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You cannot bind any more friendly vehicles.");
}
} else {
int c = vVManager->Count_Player_Bound_Vehicles(ID,true);
if (c < Config->MaxEnemyVeh) {
veh->Lock(ID,1);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle (%s) has been bound to you.",Get_Pretty_Name(v).c_str());
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You cannot bind any more enemy vehicles.");
}
}
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle is already bound.");
}
}
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You must be in a vehicle to use this command.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!lock") || !stricmp(cmd.c_str(),"!bl")) {
GameObject *v = Get_Vehicle(o);
if (v) {
vVehicle *veh = vVManager->Get_Vehicle(Commands->Get_ID(v));
if (veh) {
if (veh->Locked == 0) {
int VehType = Get_Vehicle_Parent_Type(v);
if (VehType == Commands->Get_Player_Type(o)) {
int c = vVManager->Count_Player_Bound_Vehicles(ID,false);
if (c < Config->MaxFriendlyVeh) {
veh->Lock(ID,2);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle (%s) has been bound and locked to you.",Get_Pretty_Name(v).c_str());
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You cannot bind any more friendly vehicles.");
}
} else {
int c = vVManager->Count_Player_Bound_Vehicles(ID,true);
if (c < Config->MaxEnemyVeh) {
veh->Lock(ID,2);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle (%s) has been bound and locked to you.",Get_Pretty_Name(v).c_str());
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You cannot bind any more enemy vehicles.");
}
}
} else if (veh->Locked == 1) {
if (veh->Owner == ID) {
veh->Lock(ID,2);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle (%s) has been locked to you.",Get_Pretty_Name(v).c_str());
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This is not your vehicle!");
}
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle is already locked.");
}
}
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You must be in a vehicle to use this command.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!unlock")) {
if (Get_Vehicle(o)) {
vVehicle *veh = vVManager->Get_Vehicle(Commands->Get_ID(Get_Vehicle(o)));
if (veh) {
if (veh->Owner != ID) {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This is not your vehicle!");
} else if (veh->Locked < 2) {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle is not locked.");
} else {
veh->Lock(ID,1);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] Your vehicle (%s) has been unlocked.",Get_Pretty_Name(Get_Vehicle(o)).c_str());
}
}
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You must be in a vehicle to use this command.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!unbind") || !stricmp(cmd.c_str(),"!unbl") || !stricmp(cmd.c_str(),"!ub")) {
if (!stricmp(Str->Gettok(2).c_str(),"all")) {
vVManager->Unbind_All_Player_Vehicles(ID);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] All of your vehicles have been unbound.");
} else if (Get_Vehicle(o)) {
vVehicle *veh = vVManager->Get_Vehicle(Commands->Get_ID(Get_Vehicle(o)));
if (veh) {
if (veh->Locked == 0) {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This vehicle is not bound.");
} else if (veh->Owner != ID) {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] This is not your vehicle!");
} else if (veh->Locked > 0) {
veh->Lock(ID,0);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] Your vehicle (%s) has been unbound.",Get_Pretty_Name(Get_Vehicle(o)).c_str());
}
}
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You must be in a vehicle to use this command.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!vlist")) {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] Vehicles Bound: %s.",vVManager->Get_Bound_Vehicles(ID).c_str());
return false;
} else if (!stricmp(cmd.c_str(),"!vkick")) {
if (tokens >= 2) {
std::string nick = Str->Gettok(2);
GameObject *d = Player_GameObj_By_Part_Name(nick.c_str());
if (d) {
nick = Player_Name_From_GameObj(d);
if (d == o) { PrivMsgColoredVA(ID,2,200,200,0,"[VGM] You cannot kick yourself from your bound vehicles."); }
else {
GameObject *v = Get_Vehicle(d);
if (!v) { PrivMsgColoredVA(ID,2,200,200,0,"[VGM] %s is not in a vehicle.",nick.c_str()); }
else {
vVehicle *veh = vVManager->Get_Vehicle(Commands->Get_ID(v));
if (veh && veh->Owner == ID && veh->Locked > 0) {
Force_Occupant_ID_Exit(v,Get_Player_ID(d));
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] %s has been kicked from your bound vehicle.",nick.c_str());
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] %s is not in any of your bound vehicles.",nick.c_str());
}
}
}
} else {
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] \"%s\" not found.",nick.c_str());
}
} else {
vVManager->Kick_All_Players_From_My_Vehicles(ID);
PrivMsgColoredVA(ID,2,200,200,0,"[VGM] All players were kicked from your vehicles.");
}
return false;
}
return true;
}
bool Execute_SniperCommand(int ID, vTokenParser *Str, int type) {
std::string cmd = Str->Gettok(1);
int Tokens = Str->Numtok();
GameObject *o = Player_GameObj(ID);
int maxdist = 18;
if (!stricmp(cmd.c_str(),"!killme")) {
Kill_Player(ID);
PrivMsgColoredVA(ID,2,200,0,0,"[VGM] You have been killed.");
return false;
}
return true;
}
bool Execute_OtherCommand(int ID, vTokenParser *Str, int type) {
std::string cmd = Str->Gettok(1);
int tokens = Str->Numtok();
GameObject *o = Player_GameObj(ID);
if (!stricmp(cmd.c_str(),"!recs") || !stricmp(cmd.c_str(),"!myrecs")) {
int pID = ID;
if (tokens >= 2) {
std::string player = Str->Gettok(2);
GameObject *d = Player_GameObj_By_Name(player.c_str());
if (!d) { d = Player_GameObj_By_Part_Name(player.c_str()); }
if (d) { pID = Get_Player_ID(d); }
else { PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Player \"%s\" not found.",player.c_str()); return false; }
}
vPlayer *p = vPManager->Get_Player(pID);
if (!p) { return false; }
char f[128];
sprintf(f,"vgm\\medals_%s.ini",p->Get_Name());
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Current Recs for %s: %d - Kill Recs: %d - KD Recs: %d - MVP Recs: %d - Misc Recs: %d",
p->Get_Name(),
getProfileInt("Medals","Recs",0,(const char*)f),
getProfileInt("Medals","KillRecs",0,(const char*)f),
getProfileInt("Medals","KDRecs",0,(const char*)f),
getProfileInt("Medals","MVPRecs",0,(const char*)f),
getProfileInt("Medals","MiscRecs",0,(const char*)f)
);
return false;
} else if (!stricmp(cmd.c_str(),"!rec")) {
if (tokens >= 2) {
vPlayer *p = vPManager->Get_Player(ID);
if (!p) { return false; }
std::string player = Str->Gettok(2);
std::string reason("No reason");
if (tokens >= 3) { reason = Str->Gettok(3,-1); }
GameObject *d = Player_GameObj_By_Name(player.c_str());
if (!d) { d = Player_GameObj_By_Part_Name(player.c_str()); }
if (d == o) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You cannot recommend yourself.");
return false;
} else if (d) {
if (vPManager->Recommend(ID,Get_Player_ID(d),1)) {
HostMessage("[VGM] %s has been recommended by %s for: %s",Player_Name_From_GameObj(d).c_str(),Player_Name_From_ID(ID).c_str(),reason.c_str());
p->LastRecommend = (int)clock();
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have rec'd/n00b'd someone too recently. Please wait to do it again.");
}
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Player \"%s\" not found.",player.c_str());
return false;
}
}
return false;
} else if (!stricmp(cmd.c_str(),"!n00b") || !stricmp(cmd.c_str(),"!noob")) {
if (tokens >= 2) {
vPlayer *p = vPManager->Get_Player(ID);
if (!p) { return false; }
std::string player = Str->Gettok(2);
std::string reason("No reason");
if (tokens >= 3) { reason = Str->Gettok(3,-1); }
GameObject *d = Player_GameObj_By_Name(player.c_str());
if (!d) { d = Player_GameObj_By_Part_Name(player.c_str()); }
if (d) {
if (vPManager->Recommend(ID,Get_Player_ID(d),-1)) {
HostMessage("[VGM] %s has been n00bed by %s for: %s",Player_Name_From_GameObj(d).c_str(),Player_Name_From_ID(ID).c_str(),reason.c_str());
p->LastRecommend = (int)clock();
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have rec'd/n00b'd someone too recently. Please wait to do it again.");
}
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Player \"%s\" not found.",player.c_str());
return false;
}
}
return false;
} else if (!stricmp(cmd.c_str(),"!tc") && tokens == 1) {
int MyTeam = Commands->Get_Player_Type(o);
if (MyTeam != 0 && MyTeam != 1) { return false; }
int EnTeam = 1 - MyTeam;
//Stewie_cTeam *MyCTeam = Stewie_cTeamManager::Find_Team(MyTeam);
//Stewie_cTeam *EnCTeam = Stewie_cTeamManager::Find_Team(EnTeam);
if (Stewie_cPlayerManager::Tally_Team_Size(EnTeam) <= Stewie_cPlayerManager::Tally_Team_Size(MyTeam) - 2) { // && MyCTeam->Score >= EnCTeam->Score + 1000
Change_Team(o,EnTeam);
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You have been switched to %s.",Get_Translated_Team_Name(EnTeam).c_str());
HostMessage("[VGM] %s has changed to %s to even the teams.",Player_Name_From_ID(ID).c_str(),Get_Translated_Team_Name(EnTeam).c_str());
} else {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] You cannot change teams under these conditions.");
}
return false;
} else if (!stricmp(cmd.c_str(),"!rtc")) {
vPManager->RTC(ID);
return false;
} else if (!stricmp(cmd.c_str(),"!bounty")) {
if (tokens >= 3) {
std::string player = Str->Gettok(2);
std::string amt = Str->Gettok(3);
float amount;
if (!stricmp(amt.c_str(),"all")) { amount = Commands->Get_Money(o); }
else { amount = (float)atof(amt.c_str()); }
if (Commands->Get_Money(o) < amount) {
PrivMsgColoredVA(ID,2,128,0,0,"[VGM] You don't have %.0f credits.",amount);
return false;
}
if (amount < 1000.0f) {
PrivMsgColoredVA(ID,2,128,0,0,"[VGM] You must place at least $1000 to start a bounty.");
return false;
}
GameObject *d = Player_GameObj_By_Name(player.c_str());
if (!d) { d = Player_GameObj_By_Part_Name(player.c_str()); }
if (!d) {
PrivMsgColoredVA(ID,2,128,0,0,"[VGM] Player \"%s\" not found.",player.c_str());
return false;
}
if (d == o) {
PrivMsgColoredVA(ID,2,128,0,0,"[VGM] You cannot place a bounty on yourself.");
return false;
} else if (vPManager->Get_Bounty(ID,Get_Player_ID(d)) > 0.0f) {
PrivMsgColoredVA(ID,2,128,0,0,"[VGM] You must wait for your current bounty on this player to expire.");
return false;
}
if (vPManager->Place_Bounty(ID,Get_Player_ID(d),amount)) {
Commands->Give_Money(o,-1 * amount,false);
PrivMsgColoredVA(ID,2,128,0,0,"[VGM] You have placed a bounty of $%.0f on %s.",amount,Player_Name_From_GameObj(d).c_str());
PrivMsgColoredVA(Get_Player_ID(d),2,128,0,0,"[VGM] %s has placed a bounty of %.0f on you.",Player_Name_From_ID(ID).c_str(),amount);
HostMessage("[VGM] %s has placed a bounty of %.0f on %s!",Player_Name_From_ID(ID).c_str(),amount,Player_Name_From_GameObj(d).c_str());
Create_2D_WAV_Sound("l06b_11_rav03.wav");
} else {
PrivMsgColoredVA(ID,2,128,0,0,"[VGM] Invalid amount or target.");
}
return false;
}
return false;
} else if (!stricmp(cmd.c_str(),"!vets")) {
char rank[128],entry[64];
int total = getProfileInt("VeteranPresets","Levels",0,"vgm_presets.ini");
for (int i = 2; i <= total; i++) { // for (int i = total; i > 0; i--) {
vTokenParser *S = new vTokenParser("");
S->Parse(", ");
for (Stewie_SLNode<Stewie_cPlayer>* Node = Stewie_cPlayerManager::PlayerList.HeadNode; Node; Node = Node->NodeNext) {
if (!Node->NodeData) { continue; }
if (Node->NodeData->IsActive == false || Node->NodeData->IsInGame == false) { continue; }
vPlayer *p = vPManager->Get_Player(Node->NodeData->PlayerId);
if (!p) { continue; }
if (p->VetRank == i) { S->Addtok(p->Get_Name()); }
}
if (S->Numtok()) {
sprintf(entry,"Level%d",i);
getProfileString("VeteranPresets",entry,"Recruit",rank,128,"vgm_presets.ini");
HostMessage("[VGM] %ss: %s",rank,S->Get().c_str());
}
S->Delete();
}
return false;
} else if (!stricmp(cmd.c_str(),"!vet") || !stricmp(cmd.c_str(),"!vetstatus") || !stricmp(cmd.c_str(),"!vetstats")) {
vPlayer *p = vPManager->Get_Player(ID);
if (!p) { return false; }
char rank[128],entry[64];
sprintf(entry,"Level%d",p->VetRank);
getProfileString("VeteranPresets",entry,"Recruit",rank,128,"vgm_presets.ini");
if (!rank) { return false; }
if (p->VetRank >= (int)vVetManager->Promo_ScoreReqd.size()) { return false; }
float missingscore = vVetManager->Promo_ScoreReqd[p->VetRank] - Get_Score(ID);
float missingpoints = vVetManager->Promo_VetPtsReqd[p->VetRank] - p->VetPoints;
int missingtime = vVetManager->Promo_TimeIngameReqd[p->VetRank] - p->SecondsIngame;
if (p->VetRank >= Config->VetLevels || (missingscore <= 0.0f && missingpoints <= 0.0f && missingtime < 0)) {
PrivMsgColoredVA(ID,2,255,119,51,"[VGM] Rank: %s - Veteran Points: %.2f - You cannot receive any more promotions.",rank,p->VetPoints);
} else {
vTokenParser *Header = new vTokenParser("");
Header->Parse("/");
vTokenParser *Infos = new vTokenParser("");
Infos->Parse("/");
char m[512];
if (missingscore > 0.0f) {
Header->Addtok("Score");
sprintf(m,"%.0f",MinZero(missingscore));
Infos->Addtok(m);
}
if (missingpoints > 0.0f) {
Header->Addtok("VetPoints");
sprintf(m,"%.0f",MinZero(missingpoints));
Infos->Addtok(m);
}
if (missingtime > 0) {
Header->Addtok("Time");
Infos->Addtok(Duration(missingtime).c_str());
}
if (strlen(Header->Get().c_str()) > 0 && strlen(Infos->Get().c_str()) > 0) {
PrivMsgColoredVA(ID,2,255,119,51,"[VGM] Rank: %s - Veteran Points: %.2f - %s to promotion: %s",rank,p->VetPoints,Header->Get().c_str(),Infos->Get().c_str());
} else {
PrivMsgColoredVA(ID,2,255,119,51,"[VGM] Rank: %s - Veteran Points: %.2f - Promotion data unavailable. Please retry.",rank,p->VetPoints);
}
Header->Delete();
Infos->Delete();
}
return false;
} else if (!stricmp(cmd.c_str(),"!ping")) {
Stewie_cPlayer *p = Stewie_cPlayerManager::Find_Player(ID);
if (!p || p->IsInGame == false || p->IsActive == false) { return false; }
HostMessage("[VGM] %s, your ping is: %d.",WCharToStr(p->PlayerName.m_Buffer).c_str(),p->Get_Ping());
return false;
} else if (!stricmp(cmd.c_str(),"!speed") || !stricmp(cmd.c_str(),"!setspeed") || !stricmp(cmd.c_str(),"!ss")) {
if (Is_Spectating(o) == false) { return false; }
int i = atoi(Str->Gettok(2).c_str());
if (i <= 0 || i > 100) {
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Invalid speed.");
} else {
Set_Speed((Stewie_SoldierGameObj *)o,float(i));
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] Your speed is now %d.",i);
}
return false;
} else if (!stricmp(cmd.c_str(),"!time")) {
int time = vManager.DurationAsInt();
PrivMsgColoredVA(ID,2,0,200,0,"[VGM] The map %s has elapsed %s.",GameDataObj()->MapName,Duration(time).c_str());
return false;
}
return true;
}
bool Hide_Command(int ID, vTokenParser *Str, int type) {
std::string cmd = Str->Gettok(1);
char cmd2[512];
sprintf(cmd2," %s ",cmd.c_str());
if (isin(" !afk !allow !amsg !atm !back !ban !cmd !disarm !disarmb !disarmc4 !disarmp !dtm !forgive !gameover !help !kb !kban !kick !kickban !kill !ladder !m !medals !mods !next !nextmap !ntc !observe !pamsg !qkick !qspec !qspectate !rank !refund !rotation !rules !seen !setjoin !setnext !showmods !shun !spec !spectate !tban !tc !tc2 !tele !ts !unwarn !teleport !unban !viewjoin !vjoin !vset !warn !web !website ",cmd2) && (type == 0 || type == 1)) {
vLogger->Log(vLoggerType::vRENLOG,"NULL","%s: %s",Player_Name_From_ID(ID).c_str(),Str->Get().c_str());
return true;
}
return false;
}
std::string Execute_Autocomplete(const char *str) {
char completed[512];
getProfileString("Autocomplete",str,"NULL",completed,512,"Autocomplete.ini");
std::string Retn = completed;
return Retn;
}
bool __stdcall RadioHook(Stewie_CSAnnouncement *Event) {
if (Event->AnnouncementId >= 8535 && Event->AnnouncementId < 8565 && Event->IconId >= 0 && Event->IconId < 30) {
vPlayer *p = vPManager->Get_Player(Event->PlayerId);
if (!p) { return false; }
if (p->muted) { return false; }
if (p->serial == false && Config->BlockNoSerialActions) { return false; }
int GameTime = vManager.DurationAsInt();
if (p->RSpamExpire > GameTime) { return false; }
if (p->FirstRSpam <= GameTime - 5) { p->RadioMsgs = 0; }
if (p->RadioMsgs == 0) { p->FirstRSpam = GameTime; }
p->RadioMsgs++;
if (p->RadioMsgs >= 5) {
p->RadioMsgs = 0;
p->RSpamExpire = GameTime + 5;