AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Check Slash (https://forums.alliedmods.net/showthread.php?t=242936)

Monster Truck 06-27-2014 06:51

Check Slash
 
Hi, i just wanted to know, is there a way to check in takedamagepre a slash and a stab ? I want to lower the slash damage, without touching to the stab damage.

Thx

klippy 06-27-2014 07:01

Re: Check Slash
 
Check attacker's button bitsum for IN_ATTACK. Like so:
PHP Code:

if(pev(iAttackerpev_button) & IN_ATTACK)
{
       
// slash


To check for stab(if you ever need it), check for IN_ATTACK2.

Monster Truck 06-27-2014 07:06

Re: Check Slash
 
So, Something like this will be good ?

PHP Code:

public fwTakeDamagePrevictiminflictorattackerFloat:damagedamage_bits )
{
    if ( 
IsPlayerattacker ) && g_bHasSuperKnifeattacker ] && is_user_aliveattacker ) && inflictor == attacker && get_user_weaponattacker ) == CSW_KNIFE )
    {
        if( 
peviAttackerpev_button ) & IN_ATTACK )
        {
            
SetHamParamFloat4damage 15 );
        }
        else
        {
            
SetHamParamFloat4damage 100 );
        }
    }



Black Rose 06-27-2014 07:31

Re: Check Slash
 
I don't think inflictor will equal to attacker.
Also, if you're changing a parameter you have to return HAM_HANDLED. Otherwise it will be ignored by Ham.

Here's another way, don't know which is better/more efficient though.
Code:
#include <amxmodx> #include <hamsandwich> const m_pPlayer = 41; const CBasePlayerItemOffset = 4; new bool:gSlashing[33]; public plugin_init() {     RegisterHam(Ham_TakeDamage, "player", "fwdTakeDamage");     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwdPrimaryAttackKnifePre");     RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fwdPrimaryAttackKnifePost", 1); } public fwdTakeDamage(Victim, Inflictor, Attacker, Float:Damage, Damagebits) {         if ( is_user_connected(Attacker) && gSlashing[Attacker] ) {         SetHamParamFloat(4, Damage * 1.5);         return HAM_HANDLED;     }         return HAM_IGNORED; } public fwdPrimaryAttackKnifePre(ent)     gSlashing[get_pdata_cbase(ent, m_pPlayer, CBasePlayerItemOffset)] = true; public fwdPrimaryAttackKnifePost(ent)     gSlashing[get_pdata_cbase(ent, m_pPlayer, CBasePlayerItemOffset)] = false;


All times are GMT -4. The time now is 21:06.

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