Raised This Month: $ Target: $400
 0% 

Quick damage type info (TF2)


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
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
 


Thread Tools
Display Modes

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 18:27.


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