mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-02-06 10:40:41 +03:00
Various defuser fixes and code refactory (#848)
* Defuser code refactory and fix
This commit is contained in:
parent
2e6e77906f
commit
facc2be534
@ -153,15 +153,7 @@ EXT_FUNC bool CCSPlayer::RemovePlayerItemEx(const char* pszItemName, bool bRemov
|
|||||||
if (!pPlayer->m_bHasDefuser)
|
if (!pPlayer->m_bHasDefuser)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
pPlayer->m_bHasDefuser = false;
|
pPlayer->RemoveDefuser();
|
||||||
pPlayer->pev->body = 0;
|
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pPlayer->pev);
|
|
||||||
WRITE_BYTE(STATUSICON_HIDE);
|
|
||||||
WRITE_STRING("defuser");
|
|
||||||
MESSAGE_END();
|
|
||||||
|
|
||||||
pPlayer->SendItemStatus();
|
|
||||||
}
|
}
|
||||||
// item_longjump
|
// item_longjump
|
||||||
else if (FStrEq(pszItemName, "longjump"))
|
else if (FStrEq(pszItemName, "longjump"))
|
||||||
|
@ -621,6 +621,9 @@ void EXT_FUNC ClientPutInServer(edict_t *pEntity)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef REGAMEDLL_FIXES
|
||||||
|
pPlayer->m_bHasDefuser = false;
|
||||||
|
#endif
|
||||||
pPlayer->m_bNotKilled = true;
|
pPlayer->m_bNotKilled = true;
|
||||||
pPlayer->m_iIgnoreGlobalChat = IGNOREMSG_NONE;
|
pPlayer->m_iIgnoreGlobalChat = IGNOREMSG_NONE;
|
||||||
pPlayer->m_iTeamKills = 0;
|
pPlayer->m_iTeamKills = 0;
|
||||||
|
@ -1690,14 +1690,6 @@ void CBasePlayer::RemoveAllItems(BOOL removeSuit)
|
|||||||
if (m_bHasDefuser)
|
if (m_bHasDefuser)
|
||||||
{
|
{
|
||||||
RemoveDefuser();
|
RemoveDefuser();
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
|
|
||||||
WRITE_BYTE(STATUSICON_HIDE);
|
|
||||||
WRITE_STRING("defuser");
|
|
||||||
MESSAGE_END();
|
|
||||||
|
|
||||||
SendItemStatus();
|
|
||||||
bKillProgBar = true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bHasC4)
|
if (m_bHasC4)
|
||||||
@ -2396,8 +2388,8 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
|||||||
}
|
}
|
||||||
|
|
||||||
SetSuitUpdate(nullptr, SUIT_SENTENCE, SUIT_REPEAT_OK);
|
SetSuitUpdate(nullptr, SUIT_SENTENCE, SUIT_REPEAT_OK);
|
||||||
m_iClientHealth = 0;
|
|
||||||
|
|
||||||
|
m_iClientHealth = 0;
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgHealth, nullptr, pev);
|
MESSAGE_BEGIN(MSG_ONE, gmsgHealth, nullptr, pev);
|
||||||
WRITE_BYTE(m_iClientHealth);
|
WRITE_BYTE(m_iClientHealth);
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
@ -2425,31 +2417,18 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Killed)(entvars_t *pevAttacker, int iGib)
|
|||||||
else if (m_bHasDefuser)
|
else if (m_bHasDefuser)
|
||||||
{
|
{
|
||||||
RemoveDefuser();
|
RemoveDefuser();
|
||||||
|
|
||||||
#ifdef REGAMEDLL_FIXES
|
#ifdef REGAMEDLL_FIXES
|
||||||
CItemThighPack *pDefuser = (CItemThighPack *)CBaseEntity::Create("item_thighpack", pev->origin, g_vecZero, ENT(pev));
|
SpawnDefuser(pev->origin, ENT(pev));
|
||||||
|
|
||||||
pDefuser->SetThink(&CBaseEntity::SUB_Remove);
|
|
||||||
pDefuser->pev->nextthink = gpGlobals->time + CGameRules::GetItemKillDelay();
|
|
||||||
pDefuser->pev->spawnflags |= SF_NORESPAWN;
|
|
||||||
#else
|
#else
|
||||||
GiveNamedItem("item_thighpack");
|
GiveNamedItem("item_thighpack");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
|
|
||||||
WRITE_BYTE(STATUSICON_HIDE);
|
|
||||||
WRITE_STRING("defuser");
|
|
||||||
MESSAGE_END();
|
|
||||||
|
|
||||||
SendItemStatus();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (m_bIsDefusing)
|
#ifndef REGAMEDLL_FIXES
|
||||||
{
|
// NOTE: moved to RemoveDefuser
|
||||||
SetProgressBarTime(0);
|
m_bIsDefusing = false;
|
||||||
}
|
#endif
|
||||||
|
|
||||||
m_bIsDefusing = false;
|
|
||||||
BuyZoneIcon_Clear(this);
|
BuyZoneIcon_Clear(this);
|
||||||
|
|
||||||
#ifdef REGAMEDLL_ADD
|
#ifdef REGAMEDLL_ADD
|
||||||
@ -3640,16 +3619,20 @@ void EXT_FUNC CBasePlayer::__API_HOOK(JoiningThink)()
|
|||||||
ResetMenu();
|
ResetMenu();
|
||||||
m_iJoiningState = SHOWTEAMSELECT;
|
m_iJoiningState = SHOWTEAMSELECT;
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
|
#ifndef REGAMEDLL_FIXES
|
||||||
|
// NOTE: client already clears StatusIcon on join
|
||||||
|
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
|
||||||
WRITE_BYTE(STATUSICON_HIDE);
|
WRITE_BYTE(STATUSICON_HIDE);
|
||||||
WRITE_STRING("defuser");
|
WRITE_STRING("defuser");
|
||||||
MESSAGE_END();
|
MESSAGE_END();
|
||||||
|
|
||||||
m_bHasDefuser = false;
|
m_bHasDefuser = false; // set in ClientPutInServer
|
||||||
|
#endif
|
||||||
m_fLastMovement = gpGlobals->time;
|
m_fLastMovement = gpGlobals->time;
|
||||||
m_bMissionBriefing = false;
|
m_bMissionBriefing = false;
|
||||||
|
|
||||||
SendItemStatus();
|
SendItemStatus(); // NOTE: must be on UpdateClientData
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case READINGLTEXT:
|
case READINGLTEXT:
|
||||||
@ -3768,18 +3751,11 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Disappear)()
|
|||||||
else if (m_bHasDefuser)
|
else if (m_bHasDefuser)
|
||||||
{
|
{
|
||||||
RemoveDefuser();
|
RemoveDefuser();
|
||||||
|
#ifdef REGAMEDLL_FIXES
|
||||||
#ifndef REGAMEDLL_FIXES
|
SpawnDefuser(pev->origin, ENT(pev));
|
||||||
|
#else
|
||||||
GiveNamedItem("item_thighpack");
|
GiveNamedItem("item_thighpack");
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
|
|
||||||
WRITE_BYTE(STATUSICON_HIDE);
|
|
||||||
WRITE_STRING("defuser");
|
|
||||||
MESSAGE_END();
|
|
||||||
|
|
||||||
SendItemStatus();
|
|
||||||
SetProgressBarTime(0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BuyZoneIcon_Clear(this);
|
BuyZoneIcon_Clear(this);
|
||||||
@ -5695,10 +5671,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(Spawn)()
|
|||||||
ReloadWeapons();
|
ReloadWeapons();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (m_bHasDefuser)
|
pev->body = m_bHasDefuser ? 1 : 0;
|
||||||
pev->body = 1;
|
|
||||||
else
|
|
||||||
pev->body = 0;
|
|
||||||
|
|
||||||
if (m_bMissionBriefing)
|
if (m_bMissionBriefing)
|
||||||
{
|
{
|
||||||
@ -8293,14 +8266,6 @@ void CBasePlayer::__API_HOOK(SwitchTeam)()
|
|||||||
{
|
{
|
||||||
RemoveDefuser();
|
RemoveDefuser();
|
||||||
|
|
||||||
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
|
|
||||||
WRITE_BYTE(STATUSICON_HIDE);
|
|
||||||
WRITE_STRING("defuser");
|
|
||||||
MESSAGE_END();
|
|
||||||
|
|
||||||
SendItemStatus();
|
|
||||||
SetProgressBarTime(0);
|
|
||||||
|
|
||||||
#ifndef REGAMEDLL_FIXES
|
#ifndef REGAMEDLL_FIXES
|
||||||
// NOTE: unreachable code - Vaqtincha
|
// NOTE: unreachable code - Vaqtincha
|
||||||
for (int i = 0; i < MAX_ITEM_TYPES; i++)
|
for (int i = 0; i < MAX_ITEM_TYPES; i++)
|
||||||
@ -10145,6 +10110,37 @@ void CBasePlayer::RemoveDefuser()
|
|||||||
{
|
{
|
||||||
m_bHasDefuser = false;
|
m_bHasDefuser = false;
|
||||||
pev->body = 0;
|
pev->body = 0;
|
||||||
|
|
||||||
|
MESSAGE_BEGIN(MSG_ONE, gmsgStatusIcon, nullptr, pev);
|
||||||
|
WRITE_BYTE(STATUSICON_HIDE);
|
||||||
|
WRITE_STRING("defuser");
|
||||||
|
MESSAGE_END();
|
||||||
|
|
||||||
|
SendItemStatus();
|
||||||
|
|
||||||
|
#ifdef REGAMEDLL_FIXES
|
||||||
|
if (m_bIsDefusing)
|
||||||
|
{
|
||||||
|
SetProgressBarTime(0);
|
||||||
|
m_bIsDefusing = false;
|
||||||
|
}
|
||||||
|
#else
|
||||||
|
SetProgressBarTime(0);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
CItemThighPack *SpawnDefuser(const Vector &vecOrigin, edict_t *pentOwner)
|
||||||
|
{
|
||||||
|
CItemThighPack *pDefuser = (CItemThighPack *)CBaseEntity::Create("item_thighpack", vecOrigin, g_vecZero, pentOwner);
|
||||||
|
|
||||||
|
if (pDefuser)
|
||||||
|
{
|
||||||
|
pDefuser->SetThink(&CBaseEntity::SUB_Remove);
|
||||||
|
pDefuser->pev->nextthink = gpGlobals->time + CGameRules::GetItemKillDelay();
|
||||||
|
pDefuser->pev->spawnflags |= SF_NORESPAWN;
|
||||||
|
}
|
||||||
|
|
||||||
|
return pDefuser;
|
||||||
}
|
}
|
||||||
|
|
||||||
void CBasePlayer::Disconnect()
|
void CBasePlayer::Disconnect()
|
||||||
|
@ -910,6 +910,7 @@ public:
|
|||||||
|
|
||||||
CWeaponBox *CreateWeaponBox(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo);
|
CWeaponBox *CreateWeaponBox(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo);
|
||||||
CWeaponBox *CreateWeaponBox_OrigFunc(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo);
|
CWeaponBox *CreateWeaponBox_OrigFunc(CBasePlayerItem *pItem, CBasePlayer *pPlayerOwner, const char *modelName, Vector &origin, Vector &angles, Vector &velocity, float lifeTime, bool packAmmo);
|
||||||
|
CItemThighPack *SpawnDefuser(const Vector &vecOrigin, edict_t *pentOwner);
|
||||||
|
|
||||||
class CWShield: public CBaseEntity
|
class CWShield: public CBaseEntity
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user