mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2025-02-05 10:10:30 +03:00
Enhance mp_respawn_immunitytime
Minor refactoring
This commit is contained in:
parent
415f3caffe
commit
26db32e884
@ -577,9 +577,18 @@ void EXT_FUNC CBasePlayer::__API_HOOK(TraceAttack)(entvars_t *pevAttacker, float
|
|||||||
bool bHitShield = IsHittingShield(vecDir, ptr);
|
bool bHitShield = IsHittingShield(vecDir, ptr);
|
||||||
|
|
||||||
CBasePlayer *pAttacker = CBasePlayer::Instance(pevAttacker);
|
CBasePlayer *pAttacker = CBasePlayer::Instance(pevAttacker);
|
||||||
|
|
||||||
#ifdef REGAMEDLL_ADD
|
#ifdef REGAMEDLL_ADD
|
||||||
if (pAttacker && pAttacker->IsPlayer() && !CSGameRules()->FPlayerCanTakeDamage(this, pAttacker))
|
if (pAttacker && pAttacker->IsPlayer())
|
||||||
bShouldBleed = false;
|
{
|
||||||
|
// don't take damage if victim has protection
|
||||||
|
if (CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Active)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!CSGameRules()->FPlayerCanTakeDamage(this, pAttacker))
|
||||||
|
bShouldBleed = false;
|
||||||
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
if (pAttacker && pAttacker->IsPlayer() && m_iTeam == pAttacker->m_iTeam && !friendlyfire.value)
|
if (pAttacker && pAttacker->IsPlayer() && m_iTeam == pAttacker->m_iTeam && !friendlyfire.value)
|
||||||
bShouldBleed = false;
|
bShouldBleed = false;
|
||||||
@ -812,6 +821,16 @@ BOOL EXT_FUNC CBasePlayer::__API_HOOK(TakeDamage)(entvars_t *pevInflictor, entva
|
|||||||
int armorHit = 0;
|
int armorHit = 0;
|
||||||
CBasePlayer *pAttack = nullptr;
|
CBasePlayer *pAttack = nullptr;
|
||||||
|
|
||||||
|
#ifdef REGAMEDLL_ADD
|
||||||
|
{
|
||||||
|
CBaseEntity *pAttacker = GET_PRIVATE<CBaseEntity>(ENT(pevAttacker));
|
||||||
|
|
||||||
|
// don't take damage if victim has protection
|
||||||
|
if (((pAttacker && pAttacker->IsPlayer()) || (bitsDamageType & DMG_FALL)) && CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Active)
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL))
|
if (bitsDamageType & (DMG_EXPLOSION | DMG_BLAST | DMG_FALL))
|
||||||
m_LastHitGroup = HITGROUP_GENERIC;
|
m_LastHitGroup = HITGROUP_GENERIC;
|
||||||
|
|
||||||
@ -4378,7 +4397,7 @@ void EXT_FUNC CBasePlayer::__API_HOOK(PreThink)()
|
|||||||
UpdateLocation();
|
UpdateLocation();
|
||||||
|
|
||||||
#ifdef REGAMEDLL_ADD
|
#ifdef REGAMEDLL_ADD
|
||||||
if (CSPlayer()->m_flSpawnProtectionEndTime > 0 && gpGlobals->time > CSPlayer()->m_flSpawnProtectionEndTime)
|
if (CSPlayer()->GetProtectionState() == CCSPlayer::ProtectionSt_Expired)
|
||||||
{
|
{
|
||||||
RemoveSpawnProtection();
|
RemoveSpawnProtection();
|
||||||
}
|
}
|
||||||
@ -5719,19 +5738,16 @@ void CSprayCan::Spawn(entvars_t *pevOwner)
|
|||||||
|
|
||||||
void CSprayCan::Think()
|
void CSprayCan::Think()
|
||||||
{
|
{
|
||||||
TraceResult tr;
|
CBasePlayer *pPlayer = GET_PRIVATE<CBasePlayer>(pev->owner);
|
||||||
int playernum;
|
|
||||||
int nFrames;
|
|
||||||
CBasePlayer *pPlayer;
|
|
||||||
|
|
||||||
pPlayer = (CBasePlayer *)GET_PRIVATE(pev->owner);
|
|
||||||
|
|
||||||
|
int nFrames = -1;
|
||||||
if (pPlayer)
|
if (pPlayer)
|
||||||
|
{
|
||||||
nFrames = pPlayer->GetCustomDecalFrames();
|
nFrames = pPlayer->GetCustomDecalFrames();
|
||||||
else
|
}
|
||||||
nFrames = -1;
|
|
||||||
|
|
||||||
playernum = ENTINDEX(pev->owner);
|
TraceResult tr;
|
||||||
|
int playernum = ENTINDEX(pev->owner);
|
||||||
|
|
||||||
UTIL_MakeVectors(pev->angles);
|
UTIL_MakeVectors(pev->angles);
|
||||||
UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, &tr);
|
UTIL_TraceLine(pev->origin, pev->origin + gpGlobals->v_forward * 128, ignore_monsters, pev->owner, &tr);
|
||||||
@ -5797,7 +5813,7 @@ CBaseEntity *EXT_FUNC CBasePlayer::__API_HOOK(GiveNamedItem)(const char *pszName
|
|||||||
DispatchSpawn(pent);
|
DispatchSpawn(pent);
|
||||||
DispatchTouch(pent, ENT(pev));
|
DispatchTouch(pent, ENT(pev));
|
||||||
|
|
||||||
return (CBaseEntity *)GET_PRIVATE(pent);
|
return GET_PRIVATE<CBaseEntity>(pent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// external function for 3rd-party
|
// external function for 3rd-party
|
||||||
@ -5818,7 +5834,7 @@ CBaseEntity *CBasePlayer::GiveNamedItemEx(const char *pszName)
|
|||||||
DispatchSpawn(pent);
|
DispatchSpawn(pent);
|
||||||
DispatchTouch(pent, ENT(pev));
|
DispatchTouch(pent, ENT(pev));
|
||||||
|
|
||||||
CBaseEntity *pEntity = (CBaseEntity *)GET_PRIVATE(pent);
|
CBaseEntity *pEntity = GET_PRIVATE<CBaseEntity>(pent);
|
||||||
|
|
||||||
#ifdef REGAMEDLL_FIXES
|
#ifdef REGAMEDLL_FIXES
|
||||||
// not allow the item to fall to the ground.
|
// not allow the item to fall to the ground.
|
||||||
@ -9507,7 +9523,6 @@ LINK_HOOK_CLASS_VOID_CHAIN(CBasePlayer, SetSpawnProtection, (float flProtectionT
|
|||||||
|
|
||||||
void EXT_FUNC CBasePlayer::__API_HOOK(SetSpawnProtection)(float flProtectionTime)
|
void EXT_FUNC CBasePlayer::__API_HOOK(SetSpawnProtection)(float flProtectionTime)
|
||||||
{
|
{
|
||||||
pev->takedamage = DAMAGE_NO;
|
|
||||||
pev->rendermode = kRenderTransAdd;
|
pev->rendermode = kRenderTransAdd;
|
||||||
pev->renderamt = 100.0;
|
pev->renderamt = 100.0;
|
||||||
|
|
||||||
@ -9518,7 +9533,6 @@ LINK_HOOK_CLASS_VOID_CHAIN2(CBasePlayer, RemoveSpawnProtection)
|
|||||||
|
|
||||||
void CBasePlayer::__API_HOOK(RemoveSpawnProtection)()
|
void CBasePlayer::__API_HOOK(RemoveSpawnProtection)()
|
||||||
{
|
{
|
||||||
pev->takedamage = DAMAGE_AIM;
|
|
||||||
pev->rendermode = kRenderNormal;
|
pev->rendermode = kRenderNormal;
|
||||||
|
|
||||||
CSPlayer()->m_flSpawnProtectionEndTime = 0.0f;
|
CSPlayer()->m_flSpawnProtectionEndTime = 0.0f;
|
||||||
|
@ -2534,7 +2534,7 @@
|
|||||||
1 : "Only Trigger" : 0
|
1 : "Only Trigger" : 0
|
||||||
2 : "Broken on touch is buggy" : 0
|
2 : "Broken on touch is buggy" : 0
|
||||||
4 : "Pressure is buggy" : 0
|
4 : "Pressure is buggy" : 0
|
||||||
128: "Breakable" : 1
|
128: "Breakable" : 1
|
||||||
256: "Instant Crowbar" : 1
|
256: "Instant Crowbar" : 1
|
||||||
]
|
]
|
||||||
friction(integer) : "Friction (0-400)" : 50
|
friction(integer) : "Friction (0-400)" : 50
|
||||||
|
@ -85,6 +85,16 @@ public:
|
|||||||
|
|
||||||
CBasePlayer *BasePlayer() const;
|
CBasePlayer *BasePlayer() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
enum EProtectionState
|
||||||
|
{
|
||||||
|
ProtectionSt_NoSet,
|
||||||
|
ProtectionSt_Active,
|
||||||
|
ProtectionSt_Expired,
|
||||||
|
};
|
||||||
|
|
||||||
|
EProtectionState GetProtectionState() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
char m_szModel[32];
|
char m_szModel[32];
|
||||||
bool m_bForceShowMenu;
|
bool m_bForceShowMenu;
|
||||||
@ -97,3 +107,17 @@ inline CBasePlayer *CCSPlayer::BasePlayer() const
|
|||||||
{
|
{
|
||||||
return reinterpret_cast<CBasePlayer *>(this->m_pContainingEntity);
|
return reinterpret_cast<CBasePlayer *>(this->m_pContainingEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline CCSPlayer::EProtectionState CCSPlayer::GetProtectionState() const
|
||||||
|
{
|
||||||
|
// no protection set
|
||||||
|
if (m_flSpawnProtectionEndTime <= 0.0f)
|
||||||
|
return ProtectionSt_NoSet;
|
||||||
|
|
||||||
|
// check if end time of protection isn't expired yet
|
||||||
|
if (m_flSpawnProtectionEndTime >= gpGlobals->time)
|
||||||
|
return ProtectionSt_Active;
|
||||||
|
|
||||||
|
// has expired
|
||||||
|
return ProtectionSt_Expired;
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user