Raised This Month: $32 Target: $400
 8% 

Quick damage type info (TF2)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 02-04-2015 , 19:00   Quick damage type info (TF2)
Reply With Quote #1

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(clientSDKHook_OnTakeDamageOnTakeDamagePre_Player);
}
public 
OnEntityCreated(entity, const String:classname[])
{
    if (
StrEqual(classname"obj_sentrygun"))
    {
        
SDKHook(entitySDKHook_OnTakeDamageOnTakeDamagePre_Sentry);
    }
}

public 
Action:OnTakeDamagePre_Player(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat:damageForce[3], Float:damagePosition[3], damagecustom)
{
    
PrintToChatAll("%032b (%i)"damagetype);
    return 
Plugin_Changed;
}
public 
Action:OnTakeDamagePre_Sentry(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat: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(clientSDKHook_OnTakeDamageOnTakeDamagePre_Player);
}

public 
Action:OnTakeDamagePre_Player(victim, &attacker, &inflictor, &Float:damage, &damagetype, &weaponFloat: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
CoolJosh3k is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-04-2015 , 19:35   Re: Quick damage type info (TF2)
Reply With Quote #2

Just a fact: Afterburn in TF2 CAN NOT CRIT it can only MINICRIT same with sentries. So afterburn doing CRIT damage is actually afterburn doing MINICRIT damage(the crit define is for both crith + minicrit)
__________________
WildCard65 is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 02-04-2015 , 20:15   Re: Quick damage type info (TF2)
Reply With Quote #3

Never tested to see if a sentry can crit or mini crit, but I know that you can increase the fire rate with a buff banner condition on the engi. Without modding weapons, you can't do crit afterburn, but do you mean it will actually turn into a mini crit if you did?
CoolJosh3k is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-04-2015 , 20:29   Re: Quick damage type info (TF2)
Reply With Quote #4

btw, don't use that example to force crits on or off... that's what TF2_CalcIsAttackCritical is for.

Now, talking about crits is a good time to mention SM 1.7's SDKHook_OnTakeDamageAlive.

Its damage argument is post-minicrit/post-crit/post-random spread, which makes it extremely useful if you want to find out if it would kill a player or not and block if it does.

It also has a corresponding SDKHook_OnTakeDamageAlivePost.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-04-2015 at 20:30.
Powerlord is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-04-2015 , 21:17   Re: Quick damage type info (TF2)
Reply With Quote #5

Quote:
Originally Posted by CoolJosh3k View Post
Never tested to see if a sentry can crit or mini crit, but I know that you can increase the fire rate with a buff banner condition on the engi. Without modding weapons, you can't do crit afterburn, but do you mean it will actually turn into a mini crit if you did?
sm's dmg_crit flag is actually for both crits + minicrits so when applied, the game I believe determines if it should crit or minicrit
__________________
WildCard65 is offline
CoolJosh3k
AlliedModders Donor
Join Date: Mar 2010
Old 02-04-2015 , 22:06   Re: Quick damage type info (TF2)
Reply With Quote #6

Quote:
Originally Posted by Powerlord View Post
btw, don't use that example to force crits on or off... that's what TF2_CalcIsAttackCritical is for.
Is the result not the same? What does TF2_CalcIsAttackCritical do differently?

Quote:
Originally Posted by Powerlord View Post
Now, talking about crits is a good time to mention SM 1.7's SDKHook_OnTakeDamageAlive.

Its damage argument is post-minicrit/post-crit/post-random spread, which makes it extremely useful if you want to find out if it would kill a player or not and block if it does.

It also has a corresponding SDKHook_OnTakeDamageAlivePost.
I look forward to that function and the many things that will be fixed.
CoolJosh3k is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-04-2015 , 23:26   Re: Quick damage type info (TF2)
Reply With Quote #7

Sentries can only minicrit. Same with telefrags. Dunno about afterburn or bleed.

Sdkhooks_Takedamage dealt damage will be 1.35x with minicrits buffs, so you can /= 1.35 if the player is in one of the minicrit TFCond's. I don't think that type of damage can become a full crit unless you add DMG_CRIT to the flags.

Slag Gaming had this in Advanced Weaponiser... I don't really use it yet tho.

PHP Code:
#define TF_DMG_BULLET                       DMG_BULLET
#define TF_DMG_BLEED                        DMG_SLASH
#define TF_DMG_CRIT                         DMG_ACID
#define TF_DMG_UNKNOWN_1                    DMG_PREVENT_PHYSICS_FORCE
#define TF_DMG_FIRE                         DMG_PLASMA
#define TF_DMG_AFTERBURN                    DMG_PREVENT_PHYSICS_FORCE | DMG_BURN

#define TF_DMG_FLAMETHROWER                 DMG_PREVENT_PHYSICS_FORCE | TF_DMG_FIRE
#define TF_DMG_FLAMETHROWER_CRIT            TF_DMG_FLAMETHROWER | TF_DMG_CRIT

#define TF_DMG_FLARE                        TF_DMG_FIRE | TF_DMG_BULLET
#define TF_DMG_FLARE_CRIT                   TF_DMG_FLARE | TF_DMG_CRIT

// These two also work for arrows it seems
#define TF_DMG_RIFLE                        DMG_BULLET
#define TF_DMG_RIFLE_CHARGED                DMG_AIRBOAT | DMG_BULLET
#define TF_DMG_RIFLE_CRIT                   TF_DMG_RIFLE_CHARGED | TF_DMG_CRIT

#define TF_DMG_REVOLVER                     DMG_SLOWBURN | DMG_BULLET
#define TF_DMG_REVOLVER_CRIT                TF_DMG_REVOLVER | TF_DMG_CRIT

#define TF_DMG_MELEE                        DMG_CLUB | DMG_BLAST_SURFACE | DMG_NEVERGIB
#define TF_DMG_MELEE_CRIT                   TF_DMG_MELEE | TF_DMG_CRIT
#define TF_DMG_DELAY                        (1 << 30)                                       // Used by attributes 1151 & 1152 in AW2

stock bool:IsAfterDamage(iDamageType)
{
    return (
iDamageType == TF_DMG_BLEED || iDamageType == TF_DMG_AFTERBURN);

... Mostly cause I mess with dmg types a lot.

Here's some vaccinator stuff I use. You can change the macros to normal functions if you want.

PHP Code:
#define IsBlastUber(%1)         TF2_IsPlayerInCondition(%1, TFCond_UberBlastResist)
#define IsBulletUber(%1)        TF2_IsPlayerInCondition(%1, TFCond_UberBulletResist)
#define IsBurnUber(%1)          TF2_IsPlayerInCondition(%1, TFCond_UberFireResist)

stock bool:IsVacUber(iClient)
{
    return (
IsBlastUber(iClient) || IsBulletUber(iClient) || IsBurnUber(iClient));
}

#define IsBlastHeal(%1)         TF2_IsPlayerInCondition(%1, TFCond_SmallBlastResist)
#define IsBulletHeal(%1)        TF2_IsPlayerInCondition(%1, TFCond_SmallBulletResist)
#define IsBurnHeal(%1)          TF2_IsPlayerInCondition(%1, TFCond_SmallFireResist)

stock bool:IsVacHeal(iClient)
{
    return (
IsBlastHeal(iClient) || IsBulletHeal(iClient) || IsBurnHeal(iClient));
}

stock GetVacUberTypes(iClient)
{
    new 
iDmgType 0;
    if (
IsBlastUber(iClient))
    {
        
iDmgType |= DMG_BLAST;
    }
    if (
IsBulletUber(iClient))
    {
        
iDmgType |= DMG_BULLET;
    }
    if (
IsBurnUber(iClient))
    {
        
iDmgType |= DMG_BURN;
    }
    return 
iDmgType;
}

stock GetVacHealTypes(iClient)
{
    new 
iDmgType 0;
    if (
IsBlastHeal(iClient))
    {
        
iDmgType |= DMG_BLAST;
    }
    if (
IsBulletHeal(iClient))
    {
        
iDmgType |= DMG_BULLET;
    }
    if (
IsBurnHeal(iClient))
    {
        
iDmgType |= DMG_BURN;
    }
    return 
iDmgType;

__________________

Last edited by Chdata; 02-04-2015 at 23:26.
Chdata is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 02-05-2015 , 06:58   Re: Quick damage type info (TF2)
Reply With Quote #8

Chdata, you TF_DMG_CRIT is useless for this reason:
in sdkhooks.inc:
PHP Code:
#if !defined DMG_CRIT
    // TF2 crits and minicrits
    #define DMG_CRIT DMG_ACID
#endif 
__________________
WildCard65 is offline
Chdata
Veteran Member
Join Date: Aug 2012
Location: Computer Chair, Illinois
Old 02-05-2015 , 13:02   Re: Quick damage type info (TF2)
Reply With Quote #9

Quote:
12:01 PM - Chdata ♠: I didn't make TF_DMG_CRIT, that's from advanced weaponiser
12:01 PM - Chdata ♠: I don't use it
12:01 PM - Chdata ♠: but I figure some of their other defines might be useful
12:01 PM - Chdata ♠: like afterdamage
They probably made that so they could be consistent with their own convention.
__________________

Last edited by Chdata; 02-05-2015 at 14:27.
Chdata is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 02-10-2015 , 10:44   Re: Quick damage type info (TF2)
Reply With Quote #10

Quote:
Originally Posted by CoolJosh3k View Post
Is the result not the same? What does TF2_CalcIsAttackCritical do differently?
For one, it's a dedicated way of managing crits.

For two, mixing the two methods will result in one of them not working as the other will override it.

Anyway, SM 1.7 has come out since this thread started. SM 1.7 has a new hook type in SDKHooks: SDKHook_OnTakeDamageAlive (and SDKHook_OnTakeDamageAlivePost).

While this is likely too late to change the damagetype from being a crit/mini-crit (crit/mini-crit damage calculations have already happened), it will give you the real damage the player is about to take / has taken. Of course, since this is a pre hook, you can adjust the damage taken here.
__________________
Not currently working on SourceMod plugin development.

Last edited by Powerlord; 02-10-2015 at 10:45.
Powerlord is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 22:58.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode