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

[INFO] Fakemeta & Ham detailed function descriptions and examples


Post New Thread Reply   
 
Thread Tools Display Modes
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 #71

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
stupok
Veteran Member
Join Date: Feb 2006
Old 10-14-2009 , 22:17   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #72

Thats a good post on Ham_TakeDamage!

I think it is worthwhile to discuss when we should use Ham_TakeDamage and when we should use Ham_TraceAttack.
__________________
stupok is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 10-15-2009 , 07:20   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #73

Also to mention that knife damage also equals DMG_BULLET | DMG_NEVERGIB, so if you wanted to catch that you would have to check player's weapon like with other guns.
SnoW is offline
Send a message via MSN to SnoW
joropito
AlliedModders Donor
Join Date: Mar 2009
Location: pfnAddToFullPack
Old 10-15-2009 , 09:33   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #74

Ot, if you have time, it would be nice yo have a full tutorial of TraceModel and TraceHull because they are two of the most powerfull functions I guess.
__________________

Divide et vinces
approved plugins | steam account

I don't accept PM for support. Just ask on forums.
If you're looking for private work, PM me.
joropito is offline
Send a message via MSN to joropito
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-15-2009 , 09:45   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #75

Quote:
Originally Posted by SnoW View Post
Also to mention that knife damage also equals DMG_BULLET | DMG_NEVERGIB, so if you wanted to catch that you would have to check player's weapon like with other guns.
Fixed.

Quote:
Originally Posted by joropito View Post
Ot, if you have time, it would be nice yo have a full tutorial of TraceModel and TraceHull because they are two of the most powerfull functions I guess.
I will do them in the future. This topic will slowly be complete.
The only thing that bothers me is that no one besides me still is active in this topic.
No one is interested in helping others, but everybody is good at observing someone else's mistake...
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-15-2009 , 10:05   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #76

It requires some time to well-written a complete description.
__________________
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-15-2009 , 10:07   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #77

Quote:
Originally Posted by Arkshine View Post
It requires some time to well-written a complete description.
That may be true, but if you try to make them they will be done in maximum one hour, and it only takes that long when you truly have a big description.
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-15-2009 , 10:12   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #78

I'm going to try to make the easy ones.
__________________
Arkshine is offline
ot_207
Veteran Member
Join Date: Jan 2008
Location: Romania The Love Country
Old 10-15-2009 , 10:14   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #79

Quote:
Originally Posted by Arkshine View Post
I'm going to try to make the easy ones.
Ok
__________________
My approved plug-ins | Good for newbies! | Problems?

Back, will come around when I have time.
ot_207 is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-15-2009 , 10:44   Re: [INFO] Fakemeta & Ham detailed function descriptions and examples
Reply With Quote #80

Fakemeta function :

Quote:
EngFunc_ModelIndex

Description :

Returns an unique index of the model name provided.
It's actually the same number that precache_model() returns.

A model index is used for example in some TE_* messages. ( TE_LIGHTNING, TE_GLOWSPRITE, etc.. See message_const.inc file ).
The model index of an entity is stored in pev_modelindex.

Usage :

Code:
ModelIndex = engfunc( EngFunc_ModelIndex, "models/MyModel.mdl" );
__________________
Arkshine 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 17:47.


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