-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathclient_commands.cpp
8257 lines (7242 loc) · 248 KB
/
client_commands.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
///////////////////////////////////////////////////////////////////////////////////////////////
//
// -- GNU -- open source
// Please read and agree to the mb_gnu_license.txt file
// (the file is located in the marine_bot source folder)
// before editing or distributing this source code.
// This source code is free for use under the rules of the GNU General Public License.
// For more information goto:: http://www.gnu.org/licenses/
//
// credits to - valve, botman.
//
// Marine Bot - code by Frank McNeil, Kota@, Mav, Shrike.
//
// (http://marinebot.xf.cz)
//
//
// client_commands.cpp
//
////////////////////////////////////////////////////////////////////////////////////////////////
#if defined(WIN32)
#pragma warning(disable: 4005 91)
#endif
#include "defines.h"
#include "extdll.h"
#include "util.h"
#include "cbase.h"
#include "bot.h"
#include "bot_func.h"
#include "bot_manager.h"
#include "waypoint.h"
#include "client_commands.h"
#ifdef DEBUG
#include "bot_weapons.h"
#endif // DEBUG
#define MENU_NONE 0
#define MENU_MAIN 1
// bot menu & submenus
#define MENU_1 2
#define MENU_1_9 3
#define MENU_1_9_1 4
#define MENU_1_9_6 5
// waypoint menu & submenus
#define MENU_2 6
#define MENU_2_1AND2_P1 7
#define MENU_2_1AND2_P2 8
#define MENU_2_1AND2_P3 9
#define MENU_2_3 10
#define MENU_2_4 11
#define MENU_2_5 12
#define MENU_2_6 13
#define MENU_2_6_3 14
#define MENU_2_7 15
#define MENU_2_7_9_P1 16
#define MENU_2_7_9_P2 17
#define MENU_2_9 24
#define MENU_2_9_2 25
#define MENU_2_9_2_4 26
#define MENU_2_9_2_9 27
#define MENU_2_9_8 28
// misc menu & submenus
#define MENU_3 66
// special case - team menu
#define MENU_99 99
int g_menu_state = 0; // position in menu (which menu is curr shown)
int g_menu_team; // for team based options
int g_menu_next_state; // in cases that one step between curr and next is needed
// main menu
char* show_menu_main =
{ "MARINE_BOT main menu\n\n1. Bot Menu\n2. Waypoint Menu\n3. Misc\n4. CANCEL" };
// bot menu & all (possible) submenus
char* show_menu_1 =
{ "MARINE_BOT bot menu\n\n1. Add red marine\n2. Add blue marine\n3. Fill server\n4. Kick marine\n5. Kill marine\n6. Balance teams\n\n\n9. Settings\n0. MAIN" };
char* show_menu_1_9 =
{ "MARINE_BOT bot settings menu\n\n1. SpawnSkill\n2. BotSkill (bots in game)\n3. BotSkillUp\n4. BotSkillDown\n5. AimSkill\n6. Reactions\n7. Random SpawnSkill\n8. PassiveHealing\n9. BACK\n0. MAIN" };
char* show_menu_1_9_1 =
{ "MARINE_BOT skill levels menu\n\n1. level 1(best)\n2. level 2\n3. level 3(default)\n4. level 4\n5. level 5(worst)\n\n\n\n9. BACK\n0. MAIN" };
char* show_menu_1_9_6 =
{ "MARINE_BOT bot reactions menu\n\n1. 0.0 s(best)\n2. 0.1 s\n3. 0.2 s(default)\n4. 0.5 s\n5. 1.0 s\n6. 1.5 s\n7. 2.5 s\n8. 5.0 s(worst)\n9. BACK\n0. MAIN" };
// waypoint menu & all (possible) submenus
char* show_menu_2 =
{ "MARINE_BOT waypoint menu\n\n1. Placing\n2. Changing\n3. Priority\n4. Time\n5. Range\n6. Autowaypoint\n7. SettingPaths\n\n9. Service\n0. MAIN" };
char* show_menu_2a =
{ "MARINE_BOT waypoint menu\n\n1. Placing\n2. unavailable\n3. unavailable\n4. unavailable\n5. unavailable\n6. Autowaypoint\n7. SettingPaths\n\n9. Service\n0. MAIN" };
char* show_menu_2_1 =
{ "MARINE_BOT waypoint menu\n\n1. Normal/Std\n2. Delete\n3. Aim\n4. Ammobox\n5. Cross\n6. Crouch\n7. Door\n8. UseDoor\n9. NEXT\n0. MAIN" };
char* show_menu_2_2 =
{ "MARINE_BOT waypoint menu\n\n1. Normal/Std\n\n3. Aim\n4. Ammobox\n5. Cross\n6. Crouch\n7. Door\n8. UseDoor\n9. NEXT\n0. MAIN" };
char* show_menu_2_1and2_p2 =
{ "MARINE_BOT waypoint menu\n\n1. GoBack\n2. Jump\n3. DuckJump\n4. Ladder\n5. Parachute\n6. Prone\n7. Shoot\n8. Use\n9. NEXT\n0. MAIN" };
char* show_menu_2_1and2_p3 =
{ "MARINE_BOT waypoint menu\n\n1. Claymore\n2. Sniper\n3. Sprint \n4. PushPoint/Flag \n5. Trigger \n \n \n \n9. BACKTOTOP\n0. MAIN" };
char* show_menu_2_3 =
{ "MARINE_BOT priority menu\n\n1. level 1(highest)\n2. level 2\n3. level 3\n4. level 4\n5. level 5(lowest/default)\n6. level 0(no)\n\n\n9. BACK\n0. MAIN" };
char* show_menu_2_4 =
{ "MARINE_BOT time menu\n\n1. 1 second\n2. 2 seconds\n3. 3 seconds\n4. 4 seconds\n5. 5 seconds\n6. 10 seconds\n7. 20 seconds\n8. 30 seconds\n9. BACK\n0. MAIN" };
char* show_menu_2_5 =
{ "MARINE_BOT range menu\n\n1. 10 units\n2. 20 units\n3. 30 units\n4. 40 units\n5. 50 units\n6. 75 units\n7. 100 units\n8. 125 units\n9. 150 units\n0. MAIN" };
char* show_menu_2_6 =
{ "MARINE_BOT autowaypoint menu\n\n1. Start autowaypoint\n2. Stop autowaypoint\n3. Set distance\n\n\n\n\n\n\n0. MAIN" };
char* show_menu_2_6_3 =
{ "MARINE_BOT distance menu\n\n1. 80 units(minimum)\n2. 100 units\n3. 120 units\n4. 160 units\n5. 200 units(default)\n6. 280 units\n7. 340 units\n8. 400 units(maximum)\n9. BACK\n0. MAIN" };
char* show_menu_2_7 =
{ "MARINE_BOT path menu\n\n1. Show\\Hide paths\n2. Start path\n3. Stop path\n4. Continue path\n5. Add to\n6. Remove from\n7. Delete path\n8. AutoAdding on\\off\n9. Path flags\n0. MAIN" };
char* show_menu_2_7a =
{ "MARINE_BOT path menu\n\n1. Show\\Hide paths\n2. unavailable\n3. Stop path\n4. Continue path\n5. unavailable\n6. unavailable\n7. unavailable\n8. AutoAdding on\\off\n9. unavailable\n0. MAIN" };
char* show_menu_2_7_9_p1 =
{ "MARINE_BOT path flags menu\n\n1. One-way\n2. Two-way\n3. Patrol type\n4. Red team\n5. Blue team\n6. Both teams\n7. Snipers only\n8. MGunners only\n9. NEXT\n0. MAIN" };
char* show_menu_2_7_9_p2 =
{ "MARINE_BOT path flags menu\n\n1. All classes\n2. Avoid Enemy\n3. Ignore Enemy\n4. Carry Item\n\n\n\n\n9. BACK\n0. MAIN" };
char* show_menu_2_9 =
{ "MARINE_BOT service menu\n\n1. Show\\Hide wpts\n2. Adv. debugging\n3. Load wpts&paths\n4. Save wpts&paths\n5. Convert older wpts\n6. Clear wpts\n7. Destroy wpts\n8. Change wpt folder\n\n0. MAIN" };
char* show_menu_2_9_2 =
{ "MARINE_BOT debugging menu\n\n1. Check cross\n2. Check aim\n3. Check range\n4. Path highlight\n\n\n\n\n9. Draw distance\n0. MAIN" };
char* show_menu_2_9_2_4 =
{ "MARINE_BOT path highlight menu\n\n1. Red team\n2. Blue team\n3. One-way path\n4. Sniper path\n5. Machine gunner path\n\n\n\n9. Turn off\n0. MAIN" };
char* show_menu_2_9_2_9 =
{ "MARINE_BOT draw distance menu\n\n1. 400 units\n2. 500 units\n3. 600 units\n4. 700 units\n5. 800 units(default)\n6. 900 units\n7. 1000 units\n8. 1200 units\n9. 1400 units(maximum)\n0. MAIN" };
char* show_menu_2_9_8 =
{ "MARINE_BOT folder select menu\n\n1. Default\n2. Custom\n\n\n\n\n\n\n9. BACK\n0. MAIN" };
// misc menu & all (possible) submenus
char* show_menu_3 =
{ "MARINE_BOT misc menu\n\n1. Observer\n2. MrFreeze\n3. BotDontShoot\n4. BotIgnoreAll\n5. BotDontSpeak\n6. MBNoClip\n\n\n\n0. MAIN" };
// special case - team menu
char* show_menu_99 =
{ "MARINE_BOT team select menu\n\n1. Red team\n2. Blue team\n\n\n\n\n\n\n\n0. MAIN" };
char* show_menu_99a =
{ "MARINE_BOT team select menu\n\n1. Red team\n2. Blue team\n3. Both teams\n\n\n\n\n\n\n0. MAIN" };
extern bool is_dedicated_server;
extern char mb_version_info[32];
#ifdef _DEBUG
extern int debug_engine;
extern edict_t* pRecipient;
extern botname_t bot_names[MAX_BOT_NAMES];
extern edict_t* g_debug_bot;
extern bool g_debug_bot_on;
extern Section* conf_weapons;
inline bool CheckForSomeDebuggingCommands(edict_t* pEntity, const char* pcmd, const char* arg1, const char* arg2, const char* arg3, const char* arg4, const char* arg5); // debugging commands
#endif
/*
* all Marine Bot listen server commands
* you must end each main 'if' branch with return
* otherwise you'll get 'unknown command' error in game
*/
bool CustomClientCommands(edict_t* pEntity, const char* pcmd, const char* arg1, const char* arg2, const char* arg3, const char* arg4, const char* arg5)
{
char msg[126];
if ((FStrEq(pcmd, "help")) || (FStrEq(pcmd, "?")))
{
if (FStrEq(arg1, "botsetup"))
{
// we don't need to show help in notify area (top left corner on the screen)
// therefore we send them directly to console
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\n***Additional bot settings***\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[kick <\"name\">] kicks bot with specified name (name must be in double quotes)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[killbot <arg>] 'arg' could be <all> - kills all bots, <red/blue> - kills all red/blue team bots currently in the game\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[randomskill] toggles between using default bot skill and generating the skill randomly for each bot\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[spawnskill <number>] sets default bot skill on join (1-5 where 1=best, no effect to bots already in game)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[setbotskill <number>] sets bot skill level for all bots already in game (1-5 where 1=best)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[botskillup] increases bot skill level for all bots already in game (bots will be better)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[botskilldown] decreases bot skill level for all bots already in game (bots will be worse)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[setaimskill <number>] sets aim skill level for all bots already in game (1-5 where 1=best)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[botskillview] prints botskill & aimskill for all bots\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[reactiontime <number>] sets bot reaction time (0-50 where 1 will be converted to 0.1s and 50 to 5.0s)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[rangelimit <number>] sets the max distance of enemy the bot can see & attack (500-7500 units)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[botdontspeak <off>] bots will not use Voice&Radio commands, off parameter returns to normal\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[botdontchat <off>] bots will not use say&say_team commands, off parameter returns to normal\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[passivehealing <off>] bots will not heal teammates automatically, off parameter returns to normal\n");
}
else if (FStrEq(arg1, "cheats"))
{
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\n***Should help in troubles***\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[observer <off>] bot ignores you, off parameter returns to normal\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[mrfreeze <off>] bot doesnt move, off parameter returns to normal\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[botdontshoot <off>] bot doesnt shoot, off parameter returns to normal\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[botignoreall <off>] bot ignores all enemies, off parameter returns to normal\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[mbnoclip <off>] you will be able to fly through all on the map, off parameter returns to normal\n");
}
else if (FStrEq(arg1, "misc"))
{
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\n***Miscellaneous commands***\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[check_aims] connects 'wait timed' waypoint with its valid aim waypoints\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[check_cross] connects cross waypoint with all waypoints in range\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[check_ranges] draws (highlight) waypoint range\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[get_wpt_system] prints the system the waypoint file is created in\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[get_texture_name] prints the name of the texture in front of you\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[mbwptmenu] shortcut to MB waypoint menu\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[mbwptmenuadd] shortcut to MB add waypoint menu\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[mbwptmenuchange] shortcut to MB change waypoint menu\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[mbwptmenupath] shortcut to MB path menu\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[mbwptmenupathflags] shortcut to MB change path flags menu\n");
}
else
{
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\n-------------------------------------------\nMarineBot console commands help\n-------------------------------------------\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[recruit <team> <class> <skin> <skill> <name>] adds bot with specified params, if no params all except skill is taken randomly\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[kickbot <arg>] 'arg' could be <all> - kicks all bots, <red/blue> - kicks one red/blue team bot out of the game\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[balanceteams <off>] tries balancing teams on server (moves bots to weaker team), 'off' disables autobalancing\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[fillserver <number>] fills the server with bots up to maxplayers limit or up to 'number' limit\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[marinebotmenu] shows MB command menu, unavailable since FA2.8\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[directory <name>] toggles through waypoint directories or directly sets one via 'name'\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[versioninfo] prints MB version\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\n<><><><><><><><><><><><><><><><><><><<><><><><><><>\nfor additional help write one of following commands (without brackets)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "<><><><><><><><><><><><><><><><><><><<><><><><><><>\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[help <botsetup>] botsetting help | [help <cheats>] few cheats | [help <misc>] various settings help\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[wpt <help>] waypointing help | [autowpt <help>] autowaypointing help | [pathwpt <help>] pathwaypointing help\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug <help>] debugging help | [test <help>] test help\n");
}
return true;
}
// add one bot
else if ((FStrEq(pcmd, "recruit")) || (FStrEq(pcmd, "addbot")) || (FStrEq(pcmd, "addmarine")))
{
BotCreate(pEntity, arg1, arg2, arg3, arg4, arg5);
botmanager.SetBotCheckTime(gpGlobals->time + 2.5f);
return true;
}
else if (FStrEq(pcmd, "fillserver")) // automatically add bots up to maxplayers
{
int total_clients;
total_clients = 0;
for (int i = 0; i < MAX_CLIENTS; i++)
{
if (clients[i].pEntity != nullptr)
total_clients++;
}
if (total_clients >= gpGlobals->maxClients)
{
botmanager.ResetListenServerFilling();
PlaySoundConfirmation(pEntity, SND_FAILED);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "error - server full\n");
}
else
{
botmanager.SetListeServerFilling(true);
botmanager.SetBotCheckTime(gpGlobals->time + 0.5f);
// check if there is specified bot ammount to add (i.e. "arg filling")
if ((arg1 != nullptr) && (*arg1 != 0))
{
int temp = atoi(arg1);
if ((temp >= 1) && (temp < gpGlobals->maxClients - total_clients))
{
botmanager.SetBotsToBeAdded(temp);
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "%d bots will be added\n", botmanager.GetBotsToBeAdded());
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
}
else
{
botmanager.ResetListenServerFilling();
PlaySoundConfirmation(pEntity, SND_FAILED);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "error - invalid argument or over maxplayers limit!\n");
return true;
}
}
ClientPrint(pEntity, HUD_PRINTNOTIFY, "filling the server...\n");
}
return true;
}
else if (FStrEq(pcmd, "kickbot"))
{
if (FStrEq(arg1, "all")) // kick all bots
{
if (UTIL_KickBot(100))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "all bots were kicked\n");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "error - probably no bots\n");
}
}
else if (FStrEq(arg1, "red")) // kick random red team bot
{
if (UTIL_KickBot(100 + TEAM_RED))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "random red bot was kicked\n");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "error - probably no red bots\n");
}
}
else if (FStrEq(arg1, "blue")) // kick random blue team bot
{
if (UTIL_KickBot(100 + TEAM_BLUE))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "random blue bot was kicked\n");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "error - probably no blue bots\n");
}
}
else if ((arg1 == nullptr) || (*arg1 == 0)) // no arg then kick random bot
{
if (UTIL_KickBot(-100))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "random bot was kicked\n");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "error - probably no bots\n");
}
}
else
{
int index = UTIL_FindBotByName(arg1);
if (index != -1)
{
if (UTIL_KickBot(index))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "bot was successfully kicked\n");
}
else
sprintf(msg, ""); // null the output
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "invalid argument!\n");
}
}
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
return true;
}
else if (FStrEq(pcmd, "killbot"))
{
int temp = 0;
if (FStrEq(arg1, "all")) // kill all bots
{
if (UTIL_KillBot(100))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "all bots were killed\n");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "error - probably no bots\n");
}
}
else if (FStrEq(arg1, "red")) // kill all red team bots
{
if (UTIL_KillBot(100 + TEAM_RED))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "all red team bots were killed\n");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "error - probably no red team bots\n");
}
}
else if (FStrEq(arg1, "blue")) // kill all blue team bots
{
if (UTIL_KillBot(100 + TEAM_BLUE))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "all blue team bots were killed\n");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "error - probably no blue team bots\n");
}
}
else
{
int index = UTIL_FindBotByName(arg1);
if (index != -1)
{
if (UTIL_KillBot(index))
{
PlaySoundConfirmation(pEntity, SND_DONE);
sprintf(msg, "bot was successfully killed\n");
}
else
sprintf(msg, "");
}
else
{
PlaySoundConfirmation(pEntity, SND_FAILED);
sprintf(msg, "invalid or missing argument!\n");
}
}
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
return true;
}
// try balancing teams
else if ((FStrEq(pcmd, "balanceteams")) || (FStrEq(pcmd, "balance_teams")))
{
// turn off autobalance for this map, it will be turned back on after a map change
if (FStrEq(arg1, "off"))
{
// disable it only once
if (botmanager.IsTeamsBalanceNeeded() && (botmanager.IsOverrideTeamsBalance() == false))
{
botmanager.SetOverrideTeamsBalance(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "autobalance is temporary DISABLED\n");
PlaySoundConfirmation(pEntity, SND_DONE);
}
else
ClientPrint(pEntity, HUD_PRINTNOTIFY, "autobalance is already DISABLED\n");
return true;
}
botmanager.SetTeamsBalanceValue(UTIL_BalanceTeams());
if (botmanager.GetTeamsBalanceValue() == -1)
ClientPrint(pEntity, HUD_PRINTNOTIFY, "teams balanced\n");
else if (botmanager.GetTeamsBalanceValue() > 100)
{
sprintf(msg, "kick %d bots from RED team and add them to blue\n", botmanager.GetTeamsBalanceValue() - 100);
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
}
else if ((botmanager.GetTeamsBalanceValue() > 0) && (botmanager.GetTeamsBalanceValue() < 100))
{
sprintf(msg, "kick %d bots from BLUE team and add them to red\n", botmanager.GetTeamsBalanceValue());
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
}
else if (botmanager.GetTeamsBalanceValue() < -1)
{
PlaySoundConfirmation(pEntity, SND_FAILED);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "ERROR\n");
}
return true;
}
// change if the bot will use default spawn skill or pick a skill randomly
else if ((FStrEq(pcmd, "randomskill")) || (FStrEq(pcmd, "random_skill")))
{
RandomSkillCommand(pEntity, arg1);
return true;
}
// set bot skill at spawn
else if ((FStrEq(pcmd, "spawnskill")) || (FStrEq(pcmd, "spawn_skill")))
{
SpawnSkillCommand(pEntity, arg1);
return true;
}
// change bot skill - apply to all bots
else if ((FStrEq(pcmd, "setbotskill")) || (FStrEq(pcmd, "set_botskill")))
{
SetBotSkillCommand(pEntity, arg1);
return true;
}
// increase bot skill - apply to all bots
else if ((FStrEq(pcmd, "botskillup")) || (FStrEq(pcmd, "botskill_up")))
{
BotSkillUpCommand(pEntity, arg1);
return true;
}
// decrease bot skill - apply to all bots
else if ((FStrEq(pcmd, "botskilldown")) || (FStrEq(pcmd, "botskill_down")))
{
BotSkillDownCommand(pEntity, arg1);
return true;
}
// change aim skill - apply to all bots
else if ((FStrEq(pcmd, "setaimskill")) || (FStrEq(pcmd, "set_aimskill")))
{
SetAimSkillCommand(pEntity, arg1);
return true;
}
// show botskill & aimskill for all bots
else if (FStrEq(pcmd, "botskillview"))
{
int i, j;
char client_name[32];
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\n-----------------------------\n");
for (i = 0; i < MAX_CLIENTS; i++)
{
if (bots[i].is_used == FALSE)
continue;
for (j = 0; j < MAX_CLIENTS; j++)
{
if (bots[i].pEdict == clients[j].pEntity)
break;
}
strcpy(client_name, STRING(clients[j].pEntity->v.netname));
sprintf(msg, "%s's bot_skill:%d and aim_skill:%d\n", client_name,
bots[i].bot_skill + 1, bots[i].aim_skill + 1);
ClientPrint(pEntity, HUD_PRINTCONSOLE, msg);
}
ClientPrint(pEntity, HUD_PRINTCONSOLE, "-----------------------------\n\n");
return true;
}
// set bot reaction_time
else if ((FStrEq(pcmd, "reactiontime")) || (FStrEq(pcmd, "reaction_time")))
{
SetReactionTimeCommand(pEntity, arg1);
return true;
}
// bot will not heal teammates automatically
else if ((FStrEq(pcmd, "passivehealing")) || (FStrEq(pcmd, "passive_healing")))
{
PassiveHealingCommand(pEntity, arg1);
return true;
}
// set max distance of enemy the bot can see and thus can engage
else if ((FStrEq(pcmd, "rangelimit")) || (FStrEq(pcmd, "range_limit")))
{
RangeLimitCommand(pEntity, arg1);
return true;
}
else if (FStrEq(pcmd, "directory")) // change waypoint folder
{
SetWaypointDirectoryCommand(pEntity, arg1);
return true;
}
else if (FStrEq(pcmd, "marinebotmenu")) // MarineBot command menu
{
g_menu_state = MENU_MAIN;
UTIL_ShowMenu(pEntity, 0x1F, -1, FALSE, show_menu_main);
return true;
}
else if (FStrEq(pcmd, "mbwptmenu")) // shortcut to waypoint menu
{
g_menu_state = MENU_2;
int is_wpt_near = -1;
if (num_waypoints < 1)
is_wpt_near = -1;
else
is_wpt_near = WaypointFindNearest(pEntity, 50.0, -1);
if (is_wpt_near != -1)
UTIL_ShowMenu(pEntity, 0x3FF, -1, FALSE, show_menu_2);
else
UTIL_ShowMenu(pEntity, 0x3FF, -1, FALSE, show_menu_2a);
return true;
}
else if (FStrEq(pcmd, "mbwptmenuadd")) // shortcut to waypoint menu (add wpt)
{
g_menu_state = MENU_2_1AND2_P1;
g_menu_next_state = 128; // to know that's adding
UTIL_ShowMenu(pEntity, 0x3FF, -1, FALSE, show_menu_2_1);
return true;
}
else if (FStrEq(pcmd, "mbwptmenuchange")) // shortcut to waypoint menu (change wpt)
{
g_menu_state = MENU_2_1AND2_P1;
int is_wpt_near = -1;
if (num_waypoints < 1)
is_wpt_near = -1;
else
is_wpt_near = WaypointFindNearest(pEntity, 50.0, -1);
if (is_wpt_near != -1)
{
g_menu_next_state = 129; // to know that's changing
UTIL_ShowMenu(pEntity, 0x3FF, -1, FALSE, show_menu_2_2);
}
return true;
}
else if (FStrEq(pcmd, "mbwptmenupath")) // shortcut to waypoint menu (setting path)
{
g_menu_state = MENU_2_7;
int is_wpt_near = -1;
if (num_waypoints < 1)
is_wpt_near = -1;
else
is_wpt_near = WaypointFindNearest(pEntity, 50.0, -1);
if (is_wpt_near != -1)
UTIL_ShowMenu(pEntity, 0x3FF, -1, FALSE, show_menu_2_7);
else
UTIL_ShowMenu(pEntity, 0x3FF, -1, FALSE, show_menu_2_7a);
return true;
}
else if (FStrEq(pcmd, "mbwptmenupathflags")) // shortcut to waypoint menu (changing path flags)
{
g_menu_state = MENU_2_7_9_P1;
int is_wpt_near = -1;
if (num_waypoints < 1)
is_wpt_near = -1;
else
is_wpt_near = WaypointFindNearest(pEntity, 50.0, -1);
if (is_wpt_near != -1)
UTIL_ShowMenu(pEntity, 0x3FF, -1, FALSE, show_menu_2_7_9_p1);
return true;
}
else if ((FStrEq(pcmd, "versioninfo")) || (FStrEq(pcmd, "version_info"))) // version info
{
sprintf(msg, "You are running MarineBot in version %s\n", mb_version_info);
// display it also on HUD using same style as MB intro messages
Vector color1 = Vector(200, 50, 0);
Vector color2 = Vector(0, 250, 0);
CustHudMessage(pEntity, msg, color1, color2, 2, 8);
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
return true;
}
else if (FStrEq(pcmd, "observer")) // bots ignore player
{
if (botdebugger.IsObserverMode() || FStrEq(arg1, "off"))
{
botdebugger.ResetObserverMode();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "observer mode DISABLED\n");
}
else
{
botdebugger.SetObserverMode(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "observer mode ENABLED\n");
}
return true;
}
else if (FStrEq(pcmd, "mrfreeze")) // bot is stood/don't move
{
if (botdebugger.IsFreezeMode() || FStrEq(arg1, "off"))
{
botdebugger.ResetFreezeMode();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "freeze mode DISABLED\n");
}
else
{
botdebugger.SetFreezeMode(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "freeze mode ENABLED\n");
}
return true;
}
else if (FStrEq(pcmd, "botdontshoot")) // bot will NOT press trigger
{
if (botdebugger.IsDontShoot() || FStrEq(arg1, "off"))
{
botdebugger.ResetDontShoot();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "botdontshoot mode DISABLED\n");
}
else
{
botdebugger.SetDontShoot(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "botdontshoot mode ENABLED\n");
}
return true;
}
else if (FStrEq(pcmd, "botignoreall")) // bot ignore all opponents
{
if (botdebugger.IsIgnoreAll() || FStrEq(arg1, "off"))
{
botdebugger.ResetIgnoreAll();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "botignoreall mode DISABLED\n");
}
else
{
botdebugger.SetIgnoreAll(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "botignoreall mode ENABLED\n");
}
return true;
}
// bot will not use Voice&Radio cmds
else if ((FStrEq(pcmd, "botdontspeak")) || (FStrEq(pcmd, "dont_speak")))
{
DontSpeakCommand(pEntity, arg1);
return true;
}
// bot will/won't use say and say_team commands
else if ((FStrEq(pcmd, "botdontchat")) || (FStrEq(pcmd, "dont_chat")))
{
DontChatCommand(pEntity, arg1);
return true;
}
// client who use this command will switch to no clipping mode
else if (FStrEq(pcmd, "mbnoclip"))
{
if ((pEntity->v.movetype == MOVETYPE_NOCLIP) || (FStrEq(arg1, "off")))
{
pEntity->v.movetype = MOVETYPE_WALK;
ClientPrint(pEntity, HUD_PRINTNOTIFY, "noclipping mode DISABLED\n");
}
else
{
pEntity->v.movetype = MOVETYPE_NOCLIP;
ClientPrint(pEntity, HUD_PRINTNOTIFY, "noclipping mode ENABLED\n");
}
return true;
}
// show valid connections
else if (FStrEq(pcmd, "check_aims") || FStrEq(pcmd, "checkaims"))
{
// turn off this first to prevent overload on netchannel
wptser.ResetCheckRanges();
if (wptser.IsCheckAims() || FStrEq(arg1, "off"))
{
wptser.ResetCheckAims();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "check_aims DISABLED!\n");
}
else
{
wptser.SetCheckAims(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "check_aims ENABLED!\n");
}
return true;
}
// show valid connections
else if (FStrEq(pcmd, "check_cross") || FStrEq(pcmd, "checkcross"))
{
// turn off this first to prevent overload on netchannel
wptser.ResetCheckRanges();
if (wptser.IsCheckCross() || FStrEq(arg1, "off"))
{
wptser.ResetCheckCross();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "check_cross DISABLED!\n");
}
else
{
wptser.SetCheckCross(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "check_cross ENABLED!\n");
}
return true;
}
// highlight waypoint ranges
else if (FStrEq(pcmd, "check_ranges") || FStrEq(pcmd, "checkranges"))
{
// turn off these two first to prevent overload on netchannel
wptser.ResetCheckAims();
wptser.ResetCheckCross();
if (wptser.IsCheckRanges() || FStrEq(arg1, "off"))
{
wptser.ResetCheckRanges();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "check_ranges DISABLED!\n");
}
else
{
wptser.SetCheckRanges(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "check_ranges ENABLED!\n");
}
return true;
}
// print the waypoint system version
else if ((FStrEq(pcmd, "getwptsystem")) || (FStrEq(pcmd, "get_wpt_system")))
{
int version = WaypointGetSystemVersion();
if (version == -1)
sprintf(msg, "file doesn't exist or not a MB waypoint file!\n");
else
sprintf(msg, "this waypoint file uses waypoint system version %d.0\ncurrent waypoint system is in version %d.0\n",
version, WAYPOINT_VERSION);
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
return true;
}
else if ((FStrEq(pcmd, "gettexturename")) || (FStrEq(pcmd, "get_texture_name")))
{
UTIL_MakeVectors(pEntity->v.v_angle);
Vector vecStart = pEntity->v.origin + pEntity->v.view_ofs;
Vector vecEnd = vecStart + gpGlobals->v_forward * 100;
TraceResult tr;
UTIL_TraceLine(vecStart, vecEnd, dont_ignore_monsters, dont_ignore_glass, pEntity, &tr);
const char* texture = g_engfuncs.pfnTraceTexture(tr.pHit, vecStart, vecEnd);
if (texture == nullptr)
sprintf(msg, "unable to get the texture name or you are too far!\n");
else
sprintf(msg, "the name of the texture in front is \"%s\"\n", texture);
ClientPrint(pEntity, HUD_PRINTNOTIFY, msg);
return true;
}
else if (FStrEq(pcmd, "debug"))
{
if ((FStrEq(arg1, "help")) || (FStrEq(arg1, "?")))
{
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\nAll valid debugging commands you can use\n***TIP: best results are when used with just one bot in game!***\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "--------------------------------\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_actions] prints info about actions the bot does\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_aim_targets] prints valid aim indexes\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_cross] prints details how is bot deciding at cross waypoint\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_paths] prints info about path the bot is following\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_waypoints] prints info about waypoints the bot is heading towards (when not following a path)\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_weapons] prints all weapon indexes the bot spawned with\n");
//ClientPrint(pEntity, HUD_PRINTCONSOLE, "[] \n");
#ifdef _DEBUG
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_menu] prints info about current state of the botmenu\n");
//ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_engine] \n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[debug_stuck] prints stuff if stuck on something\n");
#endif
}
return true;
}
else if (FStrEq(pcmd, "debugaimtargets") || FStrEq(pcmd, "debug_aim_targets"))
{
if (botdebugger.IsDebugAims() || FStrEq(arg1, "off"))
{
botdebugger.ResetDebugAims();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_aim_targets DISABLED!\n");
}
else
{
botdebugger.SetDebugAims(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_aim_targets ENABLED!\n");
}
return true;
}
else if (FStrEq(pcmd, "debugactions") || FStrEq(pcmd, "debug_actions"))
{
if (botdebugger.IsDebugActions() || FStrEq(arg1, "off"))
{
botdebugger.ResetDebugActions();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_actions DISABLED!\n");
}
else
{
botdebugger.SetDebugActions(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_actions ENABLED!\n");
}
return true;
}
else if (FStrEq(pcmd, "debugcross") || FStrEq(pcmd, "debug_cross"))
{
if (botdebugger.IsDebugCross() || FStrEq(arg1, "off"))
{
botdebugger.ResetDebugCross();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_cross DISABLED!\n");
}
else
{
botdebugger.SetDebugCross(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_cross ENABLED!\n");
}
return true;
}
else if (FStrEq(pcmd, "debugpaths") || FStrEq(pcmd, "debug_paths"))
{
if (botdebugger.IsDebugPaths() || FStrEq(arg1, "off"))
{
botdebugger.ResetDebugPaths();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_paths DISABLED!\n");
}
else
{
botdebugger.SetDebugPaths(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_paths ENABLED!\n");
}
return true;
}
else if (FStrEq(pcmd, "debugwaypoints") || FStrEq(pcmd, "debug_waypoints"))
{
if (botdebugger.IsDebugWaypoints() || FStrEq(arg1, "off"))
{
botdebugger.ResetDebugWaypoints();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_waypoints DISABLED!\n");
}
else
{
botdebugger.SetDebugWaypoints(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_waypoints ENABLED!\n");
}
return true;
}
else if (FStrEq(pcmd, "debugweapons") || FStrEq(pcmd, "debug_weapons"))
{
if (botdebugger.IsDebugWeapons() || FStrEq(arg1, "off"))
{
botdebugger.ResetDebugWeapons();
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_weapons DISABLED!\n");
}
else
{
botdebugger.SetDebugWeapons(true);
ClientPrint(pEntity, HUD_PRINTNOTIFY, "debug_weapons ENABLED!\n");
}
return true;
}
else if (FStrEq(pcmd, "test"))
{
if ((FStrEq(arg1, "help")) || (FStrEq(arg1, "?")))
{
ClientPrint(pEntity, HUD_PRINTCONSOLE, "\nAll valid test commands\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "[aimcode] toggles standard/new aim code; the new aim code isn't fully finished\n");
}
else if ((FStrEq(arg1, "aimcode")) || (FStrEq(arg1, "aim_code")))
{
ClientPrint(pEntity, HUD_PRINTCONSOLE, "This command isn't available in current Marine Bot version!\n");
/*/
extern bool g_test_aim_code;
if (g_test_aim_code)
{
g_test_aim_code = false;
ClientPrint(pEntity, HUD_PRINTNOTIFY, "experimental aim code DISABLED!\n");
}
else
{
g_test_aim_code = true;
ClientPrint(pEntity, HUD_PRINTNOTIFY, "experimental aim code ENABLED!\n");
ClientPrint(pEntity, HUD_PRINTCONSOLE, "This new aim code isn't finished yet so you may experience a lot of misses and buggy behaviour!\n");
}
/**/
}
else
{