OP4CTFRules: handle bots joining teams

This commit is contained in:
Marco Cawthorne 2023-06-28 09:21:27 -07:00
parent 5bb2984df5
commit 213aa0371f
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
2 changed files with 30 additions and 0 deletions

View File

@ -23,6 +23,7 @@ class OP4CTFRules:HLMultiplayerRules
virtual void PlayerDeath(NSClientPlayer);
virtual void PlayerConnect(NSClientPlayer);
virtual void PlayerDisconnect(NSClientPlayer);
virtual bool ConsoleCommand(NSClientPlayer, string);
nonvirtual void CharacterSpawn(NSClientPlayer, string);
nonvirtual void CaptureFlag(NSClientPlayer);

View File

@ -73,6 +73,35 @@ OP4CTFRules::PlayerSpawn(NSClientPlayer pp)
CharacterSpawn(pp, pl.m_oldModel);
}
void CSEv_TeamJoin_f(float);
void CSEv_ClassJoin_f(float);
bool
OP4CTFRules::ConsoleCommand(NSClientPlayer pp, string cmd)
{
static void OP4CTFRules_BotJoin(void) {
float tag = (random() < 0.5) ? 1 : 2;
CSEv_TeamJoin_f(tag);
CSEv_ClassJoin_f(0);
}
tokenize(cmd);
switch (argv(0)) {
case "bot_add":
entity bot_ent = Bot_AddQuick();
if (bot_ent) {
bot_ent.think = OP4CTFRules_BotJoin;
bot_ent.nextthink = time;
}
break;
default:
return (false);
}
return (true);
}
void
OP4CTFRules::CharacterSpawn(NSClientPlayer playerEnt, string playerModel)
{