Figured I leave this for those looking for it, but no answers showing up for them in searches...
---
While not defined clearly in the include file (sdkhooks), you can use the damage types with TF2 once you know which is which.
For example, "DMG_SLASH" is used in bleed damage. In this case you'd typically have the flags 100 (or 4 as an integer). Of course, you should just use DMG_SLASH instead of a hard coded number.
To find out quickly find what the damage is, you can use something like:
PHP Code:
#include <sdkhooks>
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamagePre_Player);
}
public OnEntityCreated(entity, const String:classname[])
{
if (StrEqual(classname, "obj_sentrygun"))
{
SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamagePre_Sentry);
}
}
public Action:OnTakeDamagePre_Player(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
PrintToChatAll("%032b (%i)", damagetype);
return Plugin_Changed;
}
public Action:OnTakeDamagePre_Sentry(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
PrintToChatAll("%032b (%i)", damagetype);
return Plugin_Changed;
}
So something like:
Code:
00000000000100000000000000001000 (1048584)
Would have been afterburn doing critical damage.
(There is no flag for minicrits.)
To make the rest of your life easier, once you know the types you need to can have something like:
PHP Code:
#include <sdkhooks>
#define DMG_CRUSH DMG_FALL
#define DMG_SLASH DMG_BLEED
#define DMG_BURN DMG_AFTERBURN
new Handle:CritToggle
public OnPluginStart()
{
CritToggle = CreateConVar("tf_force_critical_toggle", "0");
}
public OnClientPutInServer(client)
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamagePre_Player);
}
public Action:OnTakeDamagePre_Player(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weapon, Float:damageForce[3], Float:damagePosition[3], damagecustom)
{
if (damagetype & DMG_BLEED)
{
PrintToChatAll("Follow the red drip road.", damagetype);
}
if (GetConVarBool(CritToggle))
{
damagetype &= ~DMG_CRIT; //Force a crit result
}
else
{
damagetype |= DMG_CRIT; //Deny a crit result
}
return Plugin_Changed;
}
Hope this tidbit helped someone