Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(SwitchTeam): add of bomb removal on team switch #895

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 14 additions & 15 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8390,21 +8390,6 @@ void CBasePlayer::__API_HOOK(SwitchTeam)()
if (m_bHasDefuser)
{
RemoveDefuser();

#ifndef REGAMEDLL_FIXES
// NOTE: unreachable code - Vaqtincha
for (int i = 0; i < MAX_ITEM_TYPES; i++)
{
m_pActiveItem = m_rgpPlayerItems[i];

if (m_pActiveItem && FClassnameIs(m_pActiveItem->pev, "item_thighpack"))
{
m_pActiveItem->Drop();
m_rgpPlayerItems[i] = nullptr;
}
}
#endif

}

szOldTeam = GetTeam(oldTeam);
Expand Down Expand Up @@ -8439,6 +8424,20 @@ void CBasePlayer::__API_HOOK(SwitchTeam)()
// Initialize the player counts now that a player has switched teams
int NumDeadCT, NumDeadTerrorist, NumAliveTerrorist, NumAliveCT;
CSGameRules()->InitializePlayerCounts(NumAliveTerrorist, NumAliveCT, NumDeadTerrorist, NumDeadCT);

if (m_bHasC4)
{
if (NumAliveTerrorist > 0 && CSPlayer()->RemovePlayerItemEx("weapon_c4", true)) {
m_bHasC4 = false;
pev->body = 0;
SetBombIcon(FALSE);
SetProgressBarTime(0);
Copy link

@justgo97 justgo97 Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

pPlayer->m_bHasC4 = false;
pPlayer->pev->body = 0;
pPlayer->SetBombIcon(FALSE);
pPlayer->SetProgressBarTime(0);

You probably can remove these 4 lines since RemovePlayerItemEx already has them. also the bRemoveAmmo param of RemovePlayerItemEx can be set to false since we are dealing with an item that has no ammo.

Copy link
Contributor Author

@Javekson Javekson Nov 15, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for the feedback! I'll remove the suggested 4 lines. Regarding bRemoveAmmo, I'll keep it as true because in certain non-standard scenarios or mods, there might be a possibility of having ammo reserves for the bomb. I've tested this case.

CSGameRules()->GiveC4();
}
else {
DropPlayerItem("weapon_c4");
}
}
#endif
}

Expand Down