Dealloc flags on player ent removal, minor bot fixes

This commit is contained in:
Marco Cawthorne 2023-06-28 10:30:37 -07:00
parent d30501d7f4
commit c3726e85b9
Signed by: eukara
GPG Key ID: CE2032F0A2882A22
5 changed files with 25 additions and 1 deletions

View File

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

View File

@ -73,6 +73,12 @@ OP4CTFRules::PlayerSpawn(NSClientPlayer pp)
CharacterSpawn(pp, pl.m_oldModel);
}
bool
OP4CTFRules::IsTeamplay(void)
{
return true;
}
void CSEv_TeamJoin_f(float);
void CSEv_ClassJoin_f(float);
@ -82,7 +88,7 @@ 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);
CSEv_ClassJoin_f(tag == 1 ? 0 : 13);
}
tokenize(cmd);
@ -145,6 +151,7 @@ OP4CTFRules::CaptureFlag(NSClientPlayer pp)
/* detach flag */
pl.g_items &= ~ITEM_GOALITEM;
pl.flags &= ~FL_GOALITEM;
pl.flagmodel = 0;
pl.score += 10;
forceinfokey(pl, "*icon1", "");

View File

@ -52,4 +52,5 @@ item_ctfbase::Respawn(void)
SetModel(GetSpawnModel());
SetSize([-16, -16, 0], [16, 16, 72]);
DropToFloor();
botinfo = BOTINFO_TEAM_GOALCAPTURE;
}

View File

@ -61,10 +61,13 @@ item_ctfflag::Respawn(void)
SetSolid(SOLID_TRIGGER);
DropToFloor();
SetFrame(4);
botinfo = BOTINFO_TEAM_GOALITEM;
classname = strcat("info_ctfflag_", ftos(m_iTeamID));
forceinfokey(world, strcat("ctfflag_", ftos(m_iTeamID)), ftos(CTFFLAG_IDLE));
m_eActivator = __NULL__;
team = m_iTeamID;
}
void
@ -87,6 +90,7 @@ item_ctfflag::Touch(entity eToucher)
m_eActivator = pl;
pl.g_items |= ITEM_GOALITEM;
pl.flags |= FL_GOALITEM;
forceinfokey(pl, "*icon1", "score_flag");
if (eToucher.team == 1) {

View File

@ -176,6 +176,7 @@ class player:NSClientPlayer
virtual void(void) PredictPreFrame;
virtual void(void) PredictPostFrame;
virtual void UpdateAliveCam(void);
virtual void OnRemoveEntity(void);
#else
float m_flPickUpTime;
virtual void(void) EvaluateEntity;
@ -296,6 +297,16 @@ player::UpdatePlayerAttachments(bool visible)
void Weapons_AmmoUpdate(entity);
void HUD_AmmoNotify_Check(player pl);
void HUD_ItemNotify_Check(player pl);
void
player::OnRemoveEntity(void)
{
super::OnRemoveEntity();
if (m_eFlag) {
m_eFlag.Destroy();
}
}
/*
=================
player::ReceiveEntity