Skip to content

Commit

Permalink
Group defuser give code in one function (s1lentq#871)
Browse files Browse the repository at this point in the history
  • Loading branch information
dystopm authored Oct 10, 2023
1 parent a9ec63d commit 2f50f5a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 31 deletions.
18 changes: 1 addition & 17 deletions regamedll/dlls/client.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1440,28 +1440,13 @@ void EXT_FUNC __API_HOOK(BuyItem)(CBasePlayer *pPlayer, int iSlot)
if (pPlayer->m_iAccount >= DEFUSEKIT_PRICE)
{
bEnoughMoney = true;
pPlayer->m_bHasDefuser = true;

MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_SHOW);
WRITE_STRING("defuser");
WRITE_BYTE(0);
WRITE_BYTE(160);
WRITE_BYTE(0);
MESSAGE_END();

pPlayer->pev->body = 1;
pPlayer->GiveDefuser();
pPlayer->AddAccount(-DEFUSEKIT_PRICE, RT_PLAYER_BOUGHT_SOMETHING);

#ifdef REGAMEDLL_FIXES
EMIT_SOUND(ENT(pPlayer->pev), CHAN_VOICE, "items/kevlar.wav", VOL_NORM, ATTN_NORM);
#else
EMIT_SOUND(ENT(pPlayer->pev), CHAN_ITEM, "items/kevlar.wav", VOL_NORM, ATTN_NORM);
#endif
pPlayer->SendItemStatus();

#ifdef BUILD_LATEST
pPlayer->SetScoreboardAttributes();
#endif
}
break;
Expand All @@ -1479,7 +1464,6 @@ void EXT_FUNC __API_HOOK(BuyItem)(CBasePlayer *pPlayer, int iSlot)
if (pPlayer->m_iAccount >= SHIELDGUN_PRICE)
{
bEnoughMoney = true;

pPlayer->DropPrimary();
pPlayer->GiveShield();
pPlayer->AddAccount(-SHIELDGUN_PRICE, RT_PLAYER_BOUGHT_SOMETHING);
Expand Down
15 changes: 1 addition & 14 deletions regamedll/dlls/items.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -481,22 +481,9 @@ BOOL CItemThighPack::MyTouch(CBasePlayer *pPlayer)
return FALSE;
#endif

pPlayer->m_bHasDefuser = true;
pPlayer->pev->body = 1;

pPlayer->GiveDefuser();
ClientPrint(pPlayer->pev, HUD_PRINTCENTER, "#Got_defuser");

MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
WRITE_BYTE(STATUSICON_SHOW);
WRITE_STRING("defuser");
WRITE_BYTE(0);
WRITE_BYTE(160);
WRITE_BYTE(0);
MESSAGE_END();

pPlayer->SendItemStatus();
pPlayer->SetScoreboardAttributes();

EMIT_SOUND(pPlayer->edict(), CHAN_VOICE, "items/kevlar.wav", VOL_NORM, ATTN_NORM);

if (TheTutor)
Expand Down
20 changes: 20 additions & 0 deletions regamedll/dlls/player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10137,6 +10137,26 @@ void CBasePlayer::RemoveBomb()
}
}

void CBasePlayer::GiveDefuser()
{
m_bHasDefuser = true;
pev->body = 1;

MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
WRITE_BYTE(STATUSICON_SHOW);
WRITE_STRING("defuser");
WRITE_BYTE(0);
WRITE_BYTE(160);
WRITE_BYTE(0);
MESSAGE_END();

SendItemStatus();

#if defined(REGAMEDLL_FIXES) || defined(BUILD_LATEST)
SetScoreboardAttributes();
#endif
}

void CBasePlayer::RemoveDefuser()
{
m_bHasDefuser = false;
Expand Down
1 change: 1 addition & 0 deletions regamedll/dlls/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,7 @@ class CBasePlayer: public CBaseMonster {
void DropPrimary();
void OnSpawnEquip(bool addDefault = true, bool equipGame = true);
void RemoveBomb();
void GiveDefuser();
void RemoveDefuser();
void HideTimer();
bool MakeBomber();
Expand Down

0 comments on commit 2f50f5a

Please sign in to comment.