forked from rcbotCheeseh/rcbot2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bot_commands.cpp
2647 lines (2120 loc) · 69.9 KB
/
bot_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
/*
* This file is part of RCBot.
*
* RCBot by Paul Murphy adapted from Botman's HPB Bot 2 template.
*
* RCBot is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at
* your option) any later version.
*
* RCBot is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with RCBot; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*
*/
#include "bot.h"
#include "bot_client.h"
#include "bot_strings.h"
#include "bot_commands.h"
#include "bot_globals.h"
#include "bot_accessclient.h"
#include "bot_schedule.h"
#include "bot_waypoint.h" // for waypoint commands
#include "bot_waypoint_locations.h" // for waypoint commands
#include "ndebugoverlay.h"
#include "bot_waypoint_visibility.h"
#include "bot_getprop.h"
#include "bot_weapons.h"
#include "bot_menu.h"
#include "bot_tf2_points.h"
CBotCommandContainer *CBotGlobals :: m_pCommands = new CRCBotCommand();
extern IVDebugOverlay *debugoverlay;
///////////////////////////////////////////////////
// Setup commands
CRCBotCommand :: CRCBotCommand ()
{
setName("rcbot");
setAccessLevel(0);
add(new CWaypointCommand());
add(new CAddBotCommand());
add(new CControlCommand());
add(new CPathWaypointCommand());
add(new CDebugCommand());
add(new CPrintCommands());
add(new CConfigCommand());
add(new CKickBotCommand());
add(new CUsersCommand());
add(new CUtilCommand());
}
CWaypointCommand :: CWaypointCommand()
{
setName("waypoint");
//setAccessLevel(CMD_ACCESS_WAYPOINT);
setAccessLevel(0);
add(new CWaypointOnCommand());
add(new CWaypointOffCommand());
add(new CWaypointAddCommand());
add(new CWaypointDeleteCommand());
add(new CWaypointInfoCommand());
add(new CWaypointSaveCommand());
add(new CWaypointLoadCommand());
add(new CWaypointClearCommand());
add(new CWaypointGiveTypeCommand());
add(new CWaypointDrawTypeCommand());
add(new CWaypointAngleCommand());
add(new CWaypointSetAngleCommand());
add(new CWaypointSetAreaCommand());
add(new CWaypointSetRadiusCommand());
add(new CWaypointMenuCommand());
add(new CWaypointCut());
add(new CWaypointCopy());
add(new CWaypointPaste());
add(new CWaypointShiftAreas());
add(new CWaypointTeleportCommand());
add(new CWaypointAreaSetToNearest());
add(new CWaypointShowCommand());
add(new CWaypointCheckCommand());
add(new CWaypointShowVisCommand());
add(new CWaypointAutoWaypointCommand());
add(new CWaypointAutoFix());
}///////////////
CWaypointShowCommand :: CWaypointShowCommand()
{
setName("show");
setHelp("show <waypoint ID>, shows you to this waypoint");
}
eBotCommandResult CWaypointShowCommand::execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
int wpt = atoi(pcmd);
CWaypoint *pwpt = CWaypoints::getWaypoint(wpt);
if ( pwpt )
{
g_pEffects->Beam( CBotGlobals::entityOrigin(pClient->getPlayer()), pwpt->getOrigin(), CWaypoints::waypointTexture(),
0, 0, 1,
5, 12, 12, 255,
10, 255, 255, 255, 200, 10);
//pClient->setShowWpt(wpt);
return COMMAND_ACCESSED;
}
//else
//pClient->setShowWpt(-1);
}
return COMMAND_ERROR;
}
//////////////
CWaypointCopy :: CWaypointCopy()
{
setName("copy");
setHelp("Go to a waypoint, and copy to hold its properties, then use paste to make a new waypoint with the same properties");
}
eBotCommandResult CWaypointCopy :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
pClient->updateCurrentWaypoint();
CWaypoint *pwpt = CWaypoints::getWaypoint(pClient->currentWaypoint());
if ( pwpt )
{
pClient->setWaypointCopy(pwpt);
return COMMAND_ACCESSED;
}
}
return COMMAND_ERROR;
}
//////////////////////////////////////////
CWaypointCut :: CWaypointCut()
{
setName("cut");
setHelp("allows you to move a waypoint by cutting it and pasting it");
}
eBotCommandResult CWaypointCut :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
pClient->updateCurrentWaypoint();
CWaypoint *pwpt = CWaypoints::getWaypoint(pClient->currentWaypoint());
if ( pwpt )
{
pClient->setWaypointCut(pwpt);
CWaypoints::deleteWaypoint(pClient->currentWaypoint());
}
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
////////////////////////////////
eBotCommandResult CSetProp :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
// classname // key // type //value
if ( (pcmd && *pcmd) &&(arg1 && *arg1) && (arg2 && *arg2) && (arg3 && *arg3))
{
//int i = 0;
edict_t *pPlayer = pClient->getPlayer();
// edict_t *pEdict;
edict_t *pNearest = NULL;
// float fDistance;
// float fNearest = 400.0f;
pNearest = CClassInterface::FindEntityByNetClassNearest(pClient->getOrigin(),pcmd);
if ( pNearest )
{
void *data = NULL;
extern bool g_PrintProps;
unsigned int m_offset = 0;
ServerClass *sc = UTIL_FindServerClass(pcmd);
if ( sc )
{
UTIL_FindSendPropInfo(sc,arg1,&m_offset);
if ( m_offset )
{
static IServerUnknown *pUnknown;
static CBaseEntity *pEntity;
Vector vdata;
pUnknown = (IServerUnknown *)pNearest->GetUnknown();
pEntity = pUnknown->GetBaseEntity();
data = (void *)((char *)pEntity + m_offset);
if ( data )
{
bool *booldata = (bool*)data;
int *intdata = (int*)data;
float *floatdata = (float*)data;
if ( strcmp(arg2,"int")==0)
*intdata = atoi(arg3);
else if ( strcmp(arg2,"bool")==0 )
*booldata = (atoi(arg3)==1);
else if ( strcmp(arg2,"float")==0 )
*floatdata = atof(arg3);
}
else
CBotGlobals::botMessage(pPlayer,0,"NULL");
}
else
CBotGlobals::botMessage(NULL,0,"OFFSET NOT FOUND");
}
else
CBotGlobals::botMessage(NULL,0,"CLASS NOT FOUND");
}
else
CBotGlobals::botMessage(NULL,0,"EDICT NOT FOUND");
}
else
CBotGlobals::botMessage(NULL,0,"Usage: getprop CLASSNAME KEY TYPE(int,bool,float) VALUE");
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
////////////////////////////////
eBotCommandResult CGetProp :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
if ( (pcmd && *pcmd) &&(arg1 && *arg1) )
{
//int i = 0;
edict_t *pPlayer = pClient->getPlayer();
// edict_t *pEdict;
edict_t *pNearest = NULL;
// float fDistance;
// float fNearest = 400.0f;
pNearest = CClassInterface::FindEntityByNetClassNearest(pClient->getOrigin(),pcmd);
if ( pNearest )
{
void *data = NULL;
extern bool g_PrintProps;
unsigned int m_offset = 0;
ServerClass *sc = UTIL_FindServerClass(pcmd);
if ( sc )
{
UTIL_FindSendPropInfo(sc,arg1,&m_offset);
if ( m_offset )
{
static IServerUnknown *pUnknown;
static CBaseEntity *pEntity;
Vector vdata;
pUnknown = (IServerUnknown *)pNearest->GetUnknown();
pEntity = pUnknown->GetBaseEntity();
int preoffs = 0;
if ( (arg2 && *arg2) )
{
preoffs = atoi(arg2);
}
data = (void *)((char *)pEntity + m_offset);
if ( data )
{
vdata = *((Vector*)data+preoffs);
CBotGlobals::botMessage(pPlayer,0,"int = %d, float = %f, bool = %s, Vector = (%0.4f,%0.4f,%0.4f)",*((int*)data + preoffs),*((float*)data+preoffs),*((bool*)data+preoffs) ? ("true"):("false"),vdata.x,vdata.y,vdata.z );
}
else
CBotGlobals::botMessage(pPlayer,0,"NULL");
}
else
CBotGlobals::botMessage(NULL,0,"OFFSET NOT FOUND");
}
else
CBotGlobals::botMessage(NULL,0,"CLASS NOT FOUND");
}
else
CBotGlobals::botMessage(NULL,0,"EDICT NOT FOUND");
}
else
CBotGlobals::botMessage(NULL,0,"Usage: getprop CLASS CLASSNAME KEY");
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
//////////////////////////////
eBotCommandResult CFindProp :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pcmd && *pcmd )
{
UTIL_FindPropPrint(pcmd);
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
///////////////////////////
eBotCommandResult CFindClassname :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
if ( pcmd && *pcmd )
{
const char *pclass = CClassInterface::FindEntityNetClass(0,pcmd);
if ( pclass )
CBotGlobals::botMessage(pClient->getPlayer(),0,"%s network name = %s",pcmd,pclass);
else
CBotGlobals::botMessage(pClient->getPlayer(),0,"%s network name not found",pcmd,pclass);
}
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
////////////////////////////////
eBotCommandResult CFindClass :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
if ( pcmd && *pcmd )
{
UTIL_FindServerClassPrint(pcmd);
}
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
///////////////////////////////////////////
////////////////////////////////
eBotCommandResult CPrintProps :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
if ( pcmd && *pcmd )
{
extern bool g_PrintProps;
unsigned int m_offset;
g_PrintProps = true;
ServerClass *sc = UTIL_FindServerClass(pcmd);
if ( sc )
UTIL_FindSendPropInfo(sc,"",&m_offset);
g_PrintProps = false;
}
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
///////////////////////////////////////////
CWaypointPaste :: CWaypointPaste()
{
setName("paste");
setHelp("first copy a waypoint using the copy command and then use paste to make a new waypoint with the same properties");
}
eBotCommandResult CWaypointPaste :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
CWaypoints::addWaypoint(pClient,NULL,NULL,NULL,NULL,true);
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
//////////////////////////////////
CWaypointShiftAreas :: CWaypointShiftAreas()
{
setName("shiftareas");
setHelp("shift the areas of flagged waypoints to a different area/only use this once");
}
eBotCommandResult CWaypointShiftAreas :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
int val = 1;
if ( pcmd && *pcmd )
val = atoi(pcmd);
if ( arg1 && *arg1 )
{
int newarea = atoi(arg1);
if ( pClient )
{
// change area val to newarea
CWaypoints::shiftVisibleAreas(pClient->getPlayer(),val,newarea);
}
}
else
CWaypoints::shiftAreas(val);
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;
}
////////////////////////////////////
CWaypointSetAreaCommand :: CWaypointSetAreaCommand ()
{
setName("setarea");
setHelp("Go to a waypoint, use setarea <areaid>");
}
eBotCommandResult CWaypointSetAreaCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
pClient->updateCurrentWaypoint();
if ( pcmd && *pcmd && ( CWaypoints::validWaypointIndex(pClient->currentWaypoint()) ) )
{
CWaypoint *pWpt = CWaypoints::getWaypoint(pClient->currentWaypoint());
pWpt->setArea(atoi(pcmd));
}
else
return COMMAND_ERROR;
return COMMAND_ACCESSED;
}
//////////////
CWaypointShowVisCommand :: CWaypointShowVisCommand ()
{
setName("showvis");
setHelp("Go to a waypoint, use showvis to see visibility");
}
eBotCommandResult CWaypointShowVisCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
#ifndef __linux__
pClient->updateCurrentWaypoint();
if ( CWaypoints::validWaypointIndex(pClient->currentWaypoint()) )
{
CWaypoint *pWpt = CWaypoints::getWaypoint(pClient->currentWaypoint());
int i = 0;
int index;
bool bVis;
float ftime;
ftime = (pcmd&&*pcmd) ? atof(pcmd) : 5.0f;
if ( pWpt )
{
index = CWaypoints::getWaypointIndex(pWpt);
CWaypointVisibilityTable *pTable = CWaypoints::getVisiblity();
for ( i = 0; i < CWaypoints::numWaypoints(); i ++ )
{
CWaypoint *pOther = CWaypoints::getWaypoint(i);
if ( !pOther->isUsed() )
continue;
if ( pOther->distanceFrom(pWpt) > 1024.0f )
continue;
bVis = pTable->GetVisibilityFromTo(index,i);
debugoverlay->AddTextOverlayRGB(pOther->getOrigin(),0,ftime,bVis ? 0 : 255,bVis ? 255 : 0,0,200,bVis ? "VIS" : "INV" );
}
}
}
else
return COMMAND_ERROR;
#endif
return COMMAND_ACCESSED;
}
///////////////
CWaypointSetRadiusCommand :: CWaypointSetRadiusCommand ()
{
setName("setradius");
setHelp("Go to a waypoint, use setradius <radius>");
}
eBotCommandResult CWaypointSetRadiusCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
pClient->updateCurrentWaypoint();
if ( pcmd && *pcmd && ( CWaypoints::validWaypointIndex(pClient->currentWaypoint()) ) )
{
CWaypoint *pWpt = CWaypoints::getWaypoint(pClient->currentWaypoint());
pWpt->setRadius(atof(pcmd));
}
else
return COMMAND_ERROR;
return COMMAND_ACCESSED;
}
/////////////////
CWaypointMenuCommand :: CWaypointMenuCommand()
{
setName("menu");
};
eBotCommandResult CWaypointMenuCommand:: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
pClient->setCurrentMenu(CBotMenuList::getMenu(BOT_MENU_WPT));
return COMMAND_ACCESSED;
/*
if ( pClient )
{
// number of waypoint types to show per menu
unsigned const int iNumToShow = 7;
unsigned int i = 0;
// menu level .. ?
unsigned int iLevel = 0;
// number of possible waypoint types to show
unsigned int iNumTypes = CWaypointTypes::getNumTypes();
char num[64], msg[64], cmd[128];
CWaypointType *p;
CWaypoint *pWpt;
// get current waypoint types on current waypoint
pClient->updateCurrentWaypoint();
pWpt = CWaypoints::getWaypoint(pClient->currentWaypoint());
if ( !pWpt )
{
CBotGlobals::botMessage(pClient->getPlayer(),0,"Not next to any waypoints to show a menu for");
return COMMAND_ERROR;
}
// Menu level to start, 0 = beginning
if ( pcmd && *pcmd )
{
iLevel = atoi(pcmd);
}
else
{
iLevel = 0;
}
//pClient->update
KeyValues *kv = new KeyValues( "menu" );
kv->SetString( "title", "Waypoint Menu" );
kv->SetInt( "level", 1 );
kv->SetColor( "color", Color( 255, 0, 0, 255 ));
kv->SetInt( "time", 15 );
kv->SetString( "msg", "Select Waypoint Type" );
// start at this waypoint type index
unsigned int iIndex = iLevel*iNumToShow;
// run through a small number
while ( (i < iNumToShow) && (iIndex < iNumTypes) )
{
p = CWaypointTypes::getTypeByIndex(iIndex);
Q_snprintf( num, sizeof(num), "%i", i );
// if waypoint has this type show it by putting a "[x]" next to it
if ( pWpt->getFlags() & p->getBits() )
Q_snprintf( msg, sizeof(msg), "%s [x]", p->getName() );
else
Q_snprintf( msg, sizeof(msg), "%s [ ]", p->getName() );
Q_snprintf( cmd, sizeof(cmd), "rcbot waypoint givetype %s", p->getName() );
KeyValues *item1 = kv->FindKey( num, true );
item1->SetString( "msg", msg );
item1->SetString( "command", cmd );
iIndex ++;
i++;
}
// finally show "More" option if available
if ( iIndex < iNumTypes )
{
Q_snprintf( num, sizeof(num), "%i", i );
Q_snprintf( msg, sizeof(msg), "More..." );
Q_snprintf( cmd, sizeof(cmd), "rcbot waypoint menu %d", iLevel+1 );
KeyValues *item1 = kv->FindKey( num, true );
item1->SetString( "msg", msg );
item1->SetString( "command", cmd );
}
helpers->CreateMessage( pClient->getPlayer(), DIALOG_MENU, kv, &g_RCBOTServerPlugin );
kv->deleteThis();
//pClient->showMenu();
return COMMAND_ACCESSED;
}
return COMMAND_ERROR;*/
};
////////////////////////////
CWaypointSetAngleCommand :: CWaypointSetAngleCommand()
{
setName("updateyaw");
}
eBotCommandResult CWaypointSetAngleCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
pClient->updateCurrentWaypoint();
if ( CWaypoints::validWaypointIndex(pClient->currentWaypoint()) )
{
CWaypoint *pWpt = CWaypoints::getWaypoint(pClient->currentWaypoint());
pWpt->setAim(CBotGlobals::playerAngles(pClient->getPlayer()).y);
}
return COMMAND_ACCESSED;
}
CUsersCommand :: CUsersCommand ()
{
setName("users");
setAccessLevel(0);
add(new CShowUsersCommand());
}
CDebugCommand :: CDebugCommand()
{
setName("debug");
setAccessLevel(CMD_ACCESS_DEBUG);
add(new CDebugGameEventCommand());
add(new CDebugBotCommand());
add(new CDebugNavCommand());
add(new CDebugVisCommand());
add(new CDebugThinkCommand());
add(new CDebugLookCommand());
add(new CDebugHudCommand());
add(new CDebugAimCommand());
add(new CDebugChatCommand());
add(new CBotGoto());
add(new CBotFlush());
add(new CDebugTaskCommand());
add(new CBotTaskCommand());
add(new CDebugButtonsCommand());
add(new CDebugSpeedCommand());
add(new CDebugUsercmdCommand());
add(new CDebugUtilCommand());
add(new CDebugProfilingCommand());
add(new CDebugEdictsCommand());
add(new CPrintProps());
add(new CGetProp());
add(new CSetProp());
add(new CFindClass());
add(new CFindClassname());
add(new CFindProp());
add(new CDebugMemoryScanCommand());
add(new CDebugMemoryCheckCommand());
add(new CDebugMstrOffsetSearch());
}
/////////////////////
CWaypointOnCommand::CWaypointOnCommand()
{
setName("on");
setAccessLevel(CMD_ACCESS_WAYPOINT);
}
CWaypointDrawTypeCommand::CWaypointDrawTypeCommand()
{
setName("drawtype");
setHelp("0: for effects engine (maximum limit of beams)\n1: for debug overlay (no limit of beams) [LISTEN SERVER CLIENT ONLY]");
setAccessLevel(CMD_ACCESS_WAYPOINT);
}
eBotCommandResult CWaypointDrawTypeCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
if ( pcmd && *pcmd )
{
pClient->setDrawType(atoi(pcmd));
return COMMAND_ACCESSED;
}
}
return COMMAND_ERROR;
}
eBotCommandResult CWaypointOnCommand:: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
pClient->setWaypointOn(true);
pClient->giveMessage("Waypoints On");
}
return COMMAND_ACCESSED;
}
eBotCommandResult CWaypointGiveTypeCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
edict_t *pEntity = pClient->getPlayer();
if ( pcmd && *pcmd )
{
if ( pClient->currentWaypoint() == -1 )
CBotGlobals::botMessage(pEntity,0,"No waypoint nearby to give types (move closer to the waypoint you want to give types)");
else
{
char *type = NULL;
for ( int i = 0; i < 4; i ++ )
{
if ( i == 0 )
type = (char*)pcmd;
else if ( i == 1 )
type = (char*)arg1;
else if ( i == 2 )
type = (char*)arg2;
else if ( i == 3 )
type = (char*)arg3;
if ( !type || !*type )
break;
CWaypointType *pType = CWaypointTypes::getType(type);
if ( pType )
{
CWaypoint *pWaypoint = CWaypoints::getWaypoint(pClient->currentWaypoint());
if ( pWaypoint )
{
if ( pWaypoint->hasFlag(pType->getBits()) )
{
pWaypoint->removeFlag(pType->getBits());
CBotGlobals::botMessage(pEntity,0,"type %s removed from waypoint %d",type,CWaypoints::getWaypointIndex(pWaypoint));
pClient->playSound("UI/buttonrollover");
}
else
{
pWaypoint->addFlag(pType->getBits());
if ( pType->getBits() & CWaypointTypes::W_FL_UNREACHABLE )
{
CWaypoints::deletePathsTo(CWaypoints::getWaypointIndex(pWaypoint));
CWaypoints::deletePathsFrom(CWaypoints::getWaypointIndex(pWaypoint));
}
CBotGlobals::botMessage(pEntity,0,"type %s added to waypoint %d",type,CWaypoints::getWaypointIndex(pWaypoint));
pClient->playSound("UI/buttonclickrelease");
}
}
}
else
{
CBotGlobals::botMessage(pEntity,0,"type '%s' not found",type);
CWaypointTypes::showTypesOnConsole(pEntity);
}
}
}
}
else
{
CWaypointTypes::showTypesOnConsole(pEntity);
}
return COMMAND_ACCESSED;
}
//////////////////
CWaypointOffCommand::CWaypointOffCommand()
{
setName("off");
setAccessLevel(CMD_ACCESS_WAYPOINT);
}
eBotCommandResult CWaypointClearCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
CWaypoints::init();
CBotGlobals::botMessage(pClient->getPlayer(),0,"waypoints cleared");
return COMMAND_ACCESSED;
}
eBotCommandResult CWaypointOffCommand:: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
pClient->setWaypointOn(false);
pClient->giveMessage("Waypoints Off");
CBotGlobals::botMessage(pClient->getPlayer(),0,"waypoints off");
return COMMAND_ACCESSED;
}
////////////////////////
CWaypointAddCommand::CWaypointAddCommand()
{
setName("add");
setAccessLevel(CMD_ACCESS_WAYPOINT);
}
eBotCommandResult CWaypointAddCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
CWaypoints::addWaypoint(pClient,pcmd,arg1,arg2,arg3);
return COMMAND_ACCESSED;
}
////////////////////
CWaypointDeleteCommand ::CWaypointDeleteCommand()
{
setName("delete");
setAccessLevel(CMD_ACCESS_WAYPOINT);
}
eBotCommandResult CWaypointDeleteCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
if ( pClient )
{
if ( pcmd && *pcmd )
{
float radius = atof(pcmd);
if ( radius > 0 )
{
std::vector<int> pWpt;
int numdeleted = 0;
Vector vOrigin = pClient->getOrigin();
CWaypointLocations::GetAllInArea(vOrigin,&pWpt,-1);
for ( unsigned short int i = 0; i < pWpt.size(); i ++ )
{
CWaypoint *pWaypoint = CWaypoints::getWaypoint(pWpt[i]);
if ( pWaypoint->distanceFrom(vOrigin) < radius)
{
CWaypoints::deleteWaypoint(pWpt[i]);
numdeleted++;
}
}
if ( numdeleted > 0 )
{
CBotGlobals::botMessage(pClient->getPlayer(),0,"%d waypoints within range of %0.0f deleted",numdeleted,radius);
pClient->updateCurrentWaypoint(); // waypoint deleted so get a new one
pClient->playSound("buttons/combine_button_locked");
pClient->giveMessage("Waypoints deleted");
}
else
{
CBotGlobals::botMessage(pClient->getPlayer(),0,"no waypoints within range of %0.0f",radius);
pClient->playSound("weapons/wpn_denyselect");
pClient->giveMessage("Waypoints deleted");
pClient->updateCurrentWaypoint(); // waypoint deleted so get a new one
}
}
}
else
{
pClient->updateCurrentWaypoint();
if ( CWaypoints::validWaypointIndex(pClient->currentWaypoint()) )
{
CWaypoints::deleteWaypoint(pClient->currentWaypoint());
CBotGlobals::botMessage(pClient->getPlayer(),0,"waypoint %d deleted",pClient->currentWaypoint());
pClient->updateCurrentWaypoint(); // waypoint deleted so get a new one
pClient->playSound("buttons/combine_button_locked");
pClient->giveMessage("Waypoint deleted");
}
else
{
CBotGlobals::botMessage(pClient->getPlayer(),0,"no waypoint nearby to delete");
pClient->playSound("weapons/wpn_denyselect");
pClient->giveMessage("No Waypoint");
}
}
}
return COMMAND_ACCESSED;
}
/////////////////////
CControlCommand :: CControlCommand ()
{
setName("control");
setAccessLevel(CMD_ACCESS_BOT);
}
eBotCommandResult CControlCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
edict_t *pEntity = NULL;
if ( pClient )
pEntity = pClient->getPlayer();
if ( pcmd && *pcmd )
{
if ( CBots::controlBot(pcmd,pcmd,arg2,arg3) )
CBotGlobals::botMessage(pEntity,0,"bot added");
else
CBotGlobals::botMessage(pEntity,0,"error: couldn't control bot '%s'",pcmd);
return COMMAND_ACCESSED;
}
else
return COMMAND_ERROR;
}
////////////////////
CAddBotCommand ::CAddBotCommand()
{
setName("addbot");
setAccessLevel(CMD_ACCESS_BOT);
}
eBotCommandResult CAddBotCommand :: execute ( CClient *pClient, const char *pcmd, const char *arg1, const char *arg2, const char *arg3, const char *arg4, const char *arg5 )
{
// bool bOkay = false;
edict_t *pEntity = NULL;
if ( pClient )
pEntity = pClient->getPlayer();