Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TakeDamage should trigger TraceAttack when bypassHooks = false #2055

Open
eyal282 opened this issue Oct 1, 2023 · 3 comments
Open

TakeDamage should trigger TraceAttack when bypassHooks = false #2055

eyal282 opened this issue Oct 1, 2023 · 3 comments

Comments

@eyal282
Copy link
Contributor

eyal282 commented Oct 1, 2023

Help us help you

  • [ x] I have checked that my issue doesn't exist yet.
  • [ x] I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • [ x] I can always reproduce the issue with the provided description below.

Problematic Code (or Steps to Reproduce)

Plugin A ( RPG-Perks, a damage handling plugin )


// I suspect fall damage is fully ignored in these functions.
public Action Event_TakeDamage(int victim, int& attacker, int& inflictor, float& damage, int& damagetype)
{		
  if(RPG_Perks_GetZombieType(victim) == ZombieType_Invalid)
  	return Plugin_Continue;

  else if(damage == 0.0)
  	return Plugin_Continue;

  else if(!SurvivorVictimNextBotAttacker(victim, attacker) && !(damagetype & DMG_BURN) && !(damagetype & DMG_FALL) && !IsDamageToSelf(victim, attacker) && !IsPinDamage(victim, attacker))
  	return Plugin_Continue;


  float fFinalDamage = damage;

  Action rtn = RPG_OnTraceAttack(victim, attacker, inflictor, fFinalDamage, damagetype, 0, 0);

  damage = fFinalDamage;

  return rtn;
  
}

// Trace Attack does not trigger with common on survivor violence. ACCOUNT FOR IT.
public Action Event_TraceAttack(int victim, int& attacker, int& inflictor, float& damage, int& damagetype, int& ammotype, int hitbox, int hitgroup)
{	
  if(RPG_Perks_GetZombieType(victim) == ZombieType_Invalid)
  	return Plugin_Continue;

  else if(damage == 0.0)
  	return Plugin_Continue;

  else if(SurvivorVictimNextBotAttacker(victim, attacker) || damagetype & DMG_BURN || damagetype & DMG_FALL || IsDamageToSelf(victim, attacker) || IsPinDamage(victim, attacker))
  	return Plugin_Continue;

  float fFinalDamage = damage;

  Action rtn = RPG_OnTraceAttack(victim, attacker, inflictor, fFinalDamage, damagetype, hitbox, hitgroup);

  damage = fFinalDamage;

  // Only on trace attack
  if(rtn == Plugin_Continue)
  	rtn = Plugin_Changed;

  return rtn;
}

Plugin B, a damage sending plugin

SDKHooks_TakeDamage(pinner, inflictor, attacker, damage, damagetype, _, _, _, false);

TraceAttack is generally more useful to catch involving player on player violence on things like blood, slow, etc..., so swapping to TakeDamage is not very good ( I also want to increase the chances my plugin goes first when detecting and modifying damage )

I need one of three things:

  1. Ability to tell on "SDKHook_TakeDamage" when bypassHooks was used with the sending function (SDKHooks_TakeDamage)
  2. SDKHook_TakeDamageBypassHooks
  3. Make bypass hooks also send a TraceAttack with as many relevant parameters as possible ( hitgroup & hitbox set to 0 = "GENERIC")
@eyal282
Copy link
Contributor Author

eyal282 commented Oct 1, 2023

Note: I obviously don't want every plugin on earth to be fully compatible with my damage handling plugin via natives and forwards, but this interaction messes with me in a special way.

Second note: If your plugin tries to detect a TraceAttack ( because Plugin B attempts to replicate a charger punching a jockey [ SDKHooks_TakeDamage is exclusively meant to replicate client damaging another ] )

@Mikusch
Copy link
Contributor

Mikusch commented Oct 1, 2023

This isn't going to happen, since the call order doesn't make sense. TraceAttack usually calls OnTakeDamage, not the other way around. You could SDKCall CBaseEntity::DispatchTraceAttack manually to achieve what you want.

@eyal282
Copy link
Contributor Author

eyal282 commented Oct 2, 2023

This isn't going to happen, since the call order doesn't make sense. TraceAttack usually calls OnTakeDamage, not the other way around. You could SDKCall CBaseEntity::DispatchTraceAttack manually to achieve what you want.

It is unreasonable to ask a developer to do this. If this won't happen in Sourcemod the devs are screwed basically.

When I said "Make bypass hooks also send a TraceAttack with as many relevant parameters as possible ( hitgroup & hitbox set to 0 = "GENERIC")

I meant also. Means on top of sending a TakeDamage, it will also send a TraceAttack. Because you said the obvious, indeed TraceAttack calls TakeDamage, this means SDKHooks_TakeDamage will call TraceAttack, then immediately afterwards call TakeDamage

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants