Raised This Month: $12 Target: $400
 3% 

[INFO] Fakemeta & Ham detailed function descriptions and examples


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-13-2009 , 04:24   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #4

HamSandWich function:
PHP Code:
Ham_TakeDamage 
Description:
This function gives us info about the moment a player takes damage, when we use it as a forward. The return of the forward is a boolean, if it is set to 1 then the damage will be done if set to 0 then it will not be done!
It also can be used to give damage.
Here I will present how to correctly use this function!
You should use this function when you want to simulate an attack by a entity!


Usage:
PHP Code:
#define OFFSET_LAST_HIT_GROUP      75
#define EXTRAOFFSET_PL_LINUX        5

// plugin_init()
RegisterHam(Ham_TakeDamage"player""fw_takedamage")

public 
fw_takedamage(victiminflictorattackerFloat:damagebits)
{
    
// Victim is the entity that has been taken damage
    // Inflictor is the entity that directly gived damage
    // Attacker is the owner of the inflictor
    // If Attacker == Inflictor that means that the damage was inflicted by a player (such as gun shot/knife stab)
    // Damage the damage
    // Bits the type of damage represented in Bitsums
    
    // For grenade damage (In CS) the bits is equal to (1<<24)
    // Basically for hooking the he grenade damage is to put this condition
    // if (bits & (1<<24))
    
    // For bullet/knife damage (In CS) the bits are equal to (DMG_BULLET | DMG_NEVERGIB)
    // Basically for hooking the shot damage is to put this condition
    // if (bits & (DMG_BULLET | DMG_NEVERGIB))

    // Now the most subtile element is that we can get the last hitgroup where the damage was dealt

    
new hitgroup get_pdata_int(victimOFFSET_LAST_HIT_GROUPEXTRAOFFSET_PL_LINUX)

How to properly execute damage? This is the way to do it!
PHP Code:
#define OFFSET_LAST_HIT_GROUP      75
#define EXTRAOFFSET_PL_LINUX        5

new const Float:hitgroup_multi[] =
{
    
1.0,  // HIT_GENERIC
    
4.0,  // HIT_HEAD
    
1.0,  // HIT_CHEST
    
1.25// HIT_STOMACH
    
1.0,  // HIT_LEFTARM
    
1.0,  // HIT_RIGHTARM
    
0.75// HIT_LEFTLEG
    
0.75  // HIT_RIGHTLEG
    
0.0   // HIT_SHIELD
}

stock Ham_ExecDamage(victiminflictorattackerdamagehitgroupbits)
{
    
set_pdata_int(victimOFFSET_LAST_HIT_GROUPhitgroupEXTRAOFFSET_PL_LINUX)
    
ExecuteHam(Ham_TakeDamagevictiminflictorattackerdamage*hitgroup_multi[hitgroup], bits)
}

stock Ham_ExecDamageB(victiminflictorattackerdamagehitgroupbits)
{
    
set_pdata_int(victimOFFSET_LAST_HIT_GROUPhitgroupEXTRAOFFSET_PL_LINUX)
    
ExecuteHamB(Ham_TakeDamagevictiminflictorattackerdamage*hitgroup_multi[hitgroup], bits)
}

stock HamRadiusDamage(entFloat:radiusFloat:damagebits)
{
    new 
target = -1Float:origin[3]
    
pev(entpev_originorigin)
    
    while(( 
target find_ent_in_sphere(targetoriginradius) ))
    {
        static 
Float:o[3]
        
pev(targetpev_origino)
        
        
xs_vec_sub(originoo)
        
        
// Recheck if the entity is in radius
        
if (xs_vec_len(o) > radius)
            continue
        
        
Ham_ExecDamageB(targetentpev(entpev_owner), damage * (xs_vec_len(o) / radius), HIT_GENERICbits)
    }

__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.

Last edited by ot_207; 10-16-2009 at 06:14.
ot_207 is offline
 



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 21:03.


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