You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As of version 1.13.0.7168, the bypassHooks parameter of the function SDKHooks_TakeDamage only bypasses the OnTakeDamage and OnTakeDamagePost hooks. I request for a way to also bypass OnTakeDamageAlive and OnTakeDamageAlivePost by either making bypassHooks also apply to alive hooks or by adding another parameter to optionally block the alive hooks.
According to psychonic, who looked into the reason that the alive hooks aren't blocked:
"it's not checked in the hook, but rather just changes how otd is called"
"since otda isn't called by sdkhooks, but rather by the game itself, the same thing doesn't apply"
Test Case
public voidOnPluginStart()
{
RegConsoleCmd("hitme", HitMe);
for (int i = MaxClients; i; i--)
{
if (!IsClientInGame(i))
continue;
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
SDKHook(i, SDKHook_OnTakeDamagePost, OnTakeDamagePost);
SDKHook(i, SDKHook_OnTakeDamageAlive, OnTakeDamageAlive);
SDKHook(i, SDKHook_OnTakeDamageAlivePost, OnTakeDamageAlivePost);
}
}
Action HitMe(int client, int args)
{
PrintToServer("Hitting %N", client);
SDKHooks_TakeDamage(client, client, client, 1.0, .bypassHooks = true);
return Plugin_Handled;
}
Action OnTakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
PrintToServer("OnTakeDamage");
return Plugin_Continue;
}
voidOnTakeDamagePost(int victim, int attacker, int inflictor, float damage, int damagetype, int weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
PrintToServer("OnTakeDamagePost");
}
Action OnTakeDamageAlive(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& weapon, float damageForce[3], float damagePosition[3], int damagecustom)
{
PrintToServer("OnTakeDamageAlive");
return Plugin_Continue;
}
voidOnTakeDamageAlivePost(int victim, int attacker, int inflictor, float damage, int damagetype, int weapon, constfloat damageForce[3], constfloat damagePosition[3], int damagecustom)
{
PrintToServer("OnTakeDamageAlivePost");
}
Mostly against this (at least as an extension of bypasshook).
SDKHooks TakeDamage native has always been problematic in my eyes as it calls CBaseEntity::OnTakeDamage rather than CBaseEntity::TakeDamage. Two very distinct functions, as the former is where health calculation takes place while the latter is where damage filtering happens. Now the reason why that matters to the issue at hand, if the native had been properly named SDKHook_OnTakeDamage rather than SDKHook_TakeDamage the ambiguity surrounding bypasshook parameter wouldn't have emerged. I suppose it's a consequence that there's an enum entry with the same name making that function nane unavailable.
Still if we are to suddenly also have OnTakeDamageAlive hooks bypassed then so should OnTakeDamageDead as well. It's not exposed and perhaps never will be. But I believe making the distinction now, will save troubles for later. A bypassalivehook would make for the most sense.
Finally as personal opinion, I believe nothing should be changed. Bypass parameters are a lot of troubles when it comes down to building your plugin logic. In the present day bypass is often used because the plugin author does not want the damage blocked, usually in instant death scenario. However there are other ways to go about instant death than relying on hook bypass. On the flip side, a plugin might have a very good reason to block or modify damage, let's say a ghost or friendly plugin. Bypass parameter wrecks havoc on all of that. The responsibility of when to intercept damage should fall on the plugin, rather than relying on bypass. That's what natives and forwards are for.
Description
As of version 1.13.0.7168, the
bypassHooks
parameter of the functionSDKHooks_TakeDamage
only bypasses theOnTakeDamage
andOnTakeDamagePost
hooks. I request for a way to also bypassOnTakeDamageAlive
andOnTakeDamageAlivePost
by either makingbypassHooks
also apply to alive hooks or by adding another parameter to optionally block the alive hooks.According to psychonic, who looked into the reason that the alive hooks aren't blocked:
Test Case
Log
Upon using the
hitme
command:The text was updated successfully, but these errors were encountered: