Skip to content

Commit

Permalink
Disable hook bypassing for SDKHooks_TakeDamage calls (#113)
Browse files Browse the repository at this point in the history
  • Loading branch information
Phil25 committed May 1, 2024
1 parent 5f75267 commit b08a383
Show file tree
Hide file tree
Showing 13 changed files with 16 additions and 16 deletions.
2 changes: 1 addition & 1 deletion scripting/rtd/perks/eyeforaneye.sp
Original file line number Diff line number Diff line change
Expand Up @@ -25,5 +25,5 @@ public void EyeForAnEye_Init(const Perk perk)

public void EyeForAnEye_OnPlayerAttacked(const int client, const int iVictim, const int iDamage, const int iRemainingHealth)
{
SDKHooks_TakeDamage(client, 0, 0, float(iDamage));
TakeDamage(client, 0, 0, float(iDamage));
}
2 changes: 1 addition & 1 deletion scripting/rtd/perks/firework.sp
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public Action Timer_Firework_Explode(Handle hTimer, DataPack hData)
if (hData.ReadCell())
TF2_IgnitePlayer(client, client);

SDKHooks_TakeDamage(client, 0, 0, float(iDamage), DMG_PREVENT_PHYSICS_FORCE | DMG_CRUSH | DMG_ALWAYSGIB | DMG_BLAST);
TakeDamage(client, 0, 0, float(iDamage), DMG_PREVENT_PHYSICS_FORCE | DMG_CRUSH | DMG_ALWAYSGIB | DMG_BLAST);
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/frozen.sp
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,7 @@ void Frozen_DuplicateAndAttachWearable(const int iOriginalWearable, const int iT
void Frozen_OnTakeDamage(int client, int iAttacker, int iInflictor, float fDamage, int iType, float fPos[3], bool bFriendly)
{
if (!bFriendly)
SDKHooks_TakeDamage(client, iInflictor, iAttacker, fDamage * Cache[client].Resistance, iType);
TakeDamage(client, iInflictor, iAttacker, fDamage * Cache[client].Resistance, iType);

if (!Cache[client].IsBreakable)
return;
Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/hatthrow.sp
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public Action Event_HatThrow_OnHatTouch(int iHat, int client)
{
int iAttacker = GetEntPropEnt(iHat, Prop_Send, "m_hOwnerEntity");
if (iAttacker && CanPlayerBeHurt(client, iAttacker))
SDKHooks_TakeDamage(client, iHat, iAttacker, Cache[iAttacker].Damage, DMG_CLUB);
TakeDamage(client, iHat, iAttacker, Cache[iAttacker].Damage, DMG_CLUB);

EmitSoundToAll(g_sSoundHatHit[GetRandomInt(0, 2)], iHat);
}
Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/hellsreach.sp
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void HellsReach_Hurt(const int client)
KILL_ENT_IN(iEnt,1.0);

float fDamage = GetRandomFloat(Cache[client].MinDamage, Cache[client].MaxDamage);
SDKHooks_TakeDamage(client, client, client, fDamage, DMG_PREVENT_PHYSICS_FORCE);
TakeDamage(client, client, client, fDamage, DMG_PREVENT_PHYSICS_FORCE);

ViewPunchRand(client, 70.0);
EmitSoundToAll(SOUND_HELL_DAMAGE, client);
Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/necromash.sp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ public Action Timer_NecroMash_Hit(Handle hTimer, any hPack)
}

if (GetVectorDistance(fPos, fPos2) <= 60.0)
SDKHooks_TakeDamage(i, i, i, 999999.0, DMG_CLUB | DMG_ALWAYSGIB | DMG_BLAST);
TakeDamage(i, i, i, 999999.0, DMG_CLUB | DMG_ALWAYSGIB | DMG_BLAST);
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/sickness.sp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void Sickness_Cough(const int client, const float fMinDamage, const float fMaxDa
SendTEParticleAttached(TEParticles.GreenGoop, client, .fOffset={0.0, 0.0, 36.0});

float fDamage = GetRandomFloat(fMinDamage, fMaxDamage);
SDKHooks_TakeDamage(client, iAttacker, iAttacker, fDamage, DMG_PREVENT_PHYSICS_FORCE);
TakeDamage(client, iAttacker, iAttacker, fDamage, DMG_PREVENT_PHYSICS_FORCE);

float fShake[3];
fShake[0] = GetRandomFloat(10.0, 15.0);
Expand Down
4 changes: 2 additions & 2 deletions scripting/rtd/perks/smite.sp
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ void Smite_ApplyPerk(const int client, const Perk perk)
SDKHook(client, SDKHook_OnTakeDamagePost, Smite_OnTakeDamage);
}

SDKHooks_TakeDamage(client, client, client, fDamage, DMG_SHOCK);
TakeDamage(client, client, client, fDamage, DMG_SHOCK);

int iStrike[2];
iStrike[0] = CreateEntityByName("info_target");
Expand Down Expand Up @@ -152,7 +152,7 @@ public Action Smite_Tick(const int client)
Cache[client].TicksLeft = iTicksLeft;

if (Cache[client].IsElectrocuted)
SDKHooks_TakeDamage(client, client, client, Cache[client].TickDamage, DMG_SHOCK);
TakeDamage(client, client, client, Cache[client].TickDamage, DMG_SHOCK);

return Plugin_Continue;
}
Expand Down
4 changes: 2 additions & 2 deletions scripting/rtd/perks/suffocation.sp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@ public void Suffocation_ApplyPerk(const int client, const Perk perk)

public void Suffocation_Begin(const int client)
{
SDKHooks_TakeDamage(client, 0, 0, Cache[client].Damage, DMG_DROWN);
TakeDamage(client, 0, 0, Cache[client].Damage, DMG_DROWN);
Cache[client].Repeat(Cache[client].Rate, Suffocation_Tick);
}

public Action Suffocation_Tick(const int client)
{
SDKHooks_TakeDamage(client, 0, 0, Cache[client].Damage, DMG_DROWN);
TakeDamage(client, 0, 0, Cache[client].Damage, DMG_DROWN);
return Plugin_Continue;
}

Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/sunlightspear.sp
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ void SunlightSpear_DamageTick(const int iVictim, const int iAttacker, const bool
float fDamage = Cache[iAttacker].Damage;
fDamage += fDamage * view_as<int>(bInitial);

SDKHooks_TakeDamage(iVictim, iAttacker, iAttacker, fDamage, DMG_SHOCK);
TakeDamage(iVictim, iAttacker, iAttacker, fDamage, DMG_SHOCK);
EmitSoundToAll(g_sSoundZap[GetRandomInt(0, 2)], iVictim, _, _, _, _, GetRandomInt(90, 110));
}

Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/timebomb.sp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void Timebomb_RemovePerk(const int client, const RTDRemoveReason eRemoveR
if (GetVectorDistance(fPos, fTargetPos, true) <= fRadiusSquared)
{
iPlayerDamage += RoundToFloor(fDamage);
SDKHooks_TakeDamage(i, 0, client, fDamage, DMG_PREVENT_PHYSICS_FORCE | DMG_CRUSH | DMG_ALWAYSGIB | DMG_BLAST);
TakeDamage(i, 0, client, fDamage, DMG_PREVENT_PHYSICS_FORCE | DMG_CRUSH | DMG_ALWAYSGIB | DMG_BLAST);
}
}

Expand Down
2 changes: 1 addition & 1 deletion scripting/rtd/perks/vampire.sp
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public Action Vampire_Tick_Followup(Handle hTimer, const int iUserId)
void Vampire_Hurt(const int client)
{
float fDamage = GetRandomFloat(Cache[client].MinDamage, Cache[client].MaxDamage);
SDKHooks_TakeDamage(client, client, client, fDamage, DMG_PREVENT_PHYSICS_FORCE);
TakeDamage(client, client, client, fDamage, DMG_PREVENT_PHYSICS_FORCE);

ViewPunchRand(client, 5.0);
}
Expand Down
4 changes: 2 additions & 2 deletions scripting/rtd/stocks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -545,9 +545,9 @@ stock void DamageRadius(float fOrigin[3], int iInflictor=0, int iAttacker=0, flo
}
}

stock void TakeDamage(int client, int iInflictor, int iAttacker, float fDamage, int iFlags, Function call)
stock void TakeDamage(int client, int iInflictor, int iAttacker, float fDamage, int iFlags=0, Function call=INVALID_FUNCTION)
{
SDKHooks_TakeDamage(client, iInflictor, iAttacker, fDamage, iFlags);
SDKHooks_TakeDamage(client, iInflictor, iAttacker, fDamage, iFlags, .bypassHooks = false);

if (call == INVALID_FUNCTION)
return;
Expand Down

0 comments on commit b08a383

Please sign in to comment.