AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Multiply slash damage by two (https://forums.alliedmods.net/showthread.php?t=188622)

Backstabnoob 06-28-2012 14:21

Multiply slash damage by two
 
How would you do this? I thought about checking if the weapon is knife and damage before hooking is 15 but that feels a little bit uncool. Ham_TakeDamage would be greatly appreciated as I already use it.

Liverwiz 06-28-2012 14:40

Re: Multiply slash damage by two
 
hook Ham_TakeDamage as pre
Check that the attacker's weapon is CSW_KNIFE (or 29)
inside that....
PHP Code:

    SetHamParamFloat(4flDamage*2


Backstabnoob 06-28-2012 14:43

Re: Multiply slash damage by two
 
Read the topic name again please.

Exolent[jNr] 06-28-2012 14:46

Re: Multiply slash damage by two
 
There is a plugin that measures slash and stab distances separately.
You should take a look at that code and see if it helps you.

I think it's Knife Distance by SchlumPF.

Liverwiz 06-28-2012 14:50

Re: Multiply slash damage by two
 
oh.:oops: sorry

PHP Code:

(flDamage 30) ? SetHamParamFloat(4flDamage*2) : return HAM_HANDLED 

i figure a stab is gonna be around 55 or greater at all times. so being less than 30 would give it a pretty good threshold if anything messes with it.


Quote:

Originally Posted by Exolent[jNr] (Post 1738308)
There is a plugin that measures slash and stab distances separately.
You should take a look at that code and see if it helps you.

I think it's Knife Distance by SchlumPF.

What i have to say about that is you can slash within the same distance as a stab (and quite frequently do)
Or you can check to see if the weapon is under primary, or secondary operations (left or right click) but i don't know that at the top off my head. Or at all....

Backstabnoob 06-28-2012 14:52

Re: Multiply slash damage by two
 
It checks for the pressed button via pev_button. I'm going to try using that.
If anyone knows it won't work in TakeDamage, please tell me so I can save some headaches :D

Liverwiz 06-28-2012 14:56

Re: Multiply slash damage by two
 
Quote:

Originally Posted by Liverwiz (Post 1738310)
Or you can check to see if the weapon is under primary, or secondary operations (left or right click) but i don't know that at the top off my head. Or at all....

Quote:

Originally Posted by Backstabnoob (Post 1738312)
It checks for the pressed button via pev_button. I'm going to try using that.
If anyone knows it won't work in TakeDamage, please tell me so I can save some headaches :D

YAY! i was right. and yay for fakemeta. :mrgreen:

ConnorMcLeod 06-29-2012 00:47

Re: Multiply slash damage by two
 
You can see in cssdk : http://code.google.com/p/cs-sdk/sour.../wpn_knife.cpp
that on slah, pre-damage passed is 15.0 or 20.0, and on stab, damage is 65.0 (or 65.0 * 3.0)

PHP Code:

#include <amxmodx>

#include <hamsandwich>


new g_iMaxPlayers
#define IsPlayer(%0)    ( 1 <= %0 <= g_iMaxPlayers )

public plugin_init()
{
    
g_iMaxPlayers get_maxplayers()
    
RegisterHam(Ham_TraceAttack"player""OnCBasePlayer_TraceAttack"false)
}

public 
OnCBasePlayer_TraceAttack(idiAttackerFloat:flDamage /* , Float:fVecDir[3], ptr, bitsDamageType */ )
{
    if( 
IsPlayer(iAttacker) && flDamage 21.0 && get_user_weapon(iAttacker) == CSW_KNIFE )
    {
        
SetHamParamFloat(3flDamage 2.0)
        return 
HAM_HANDLED
    
}
    return 
HAM_IGNORED



Backstabnoob 06-29-2012 04:22

Re: Multiply slash damage by two
 
I said I could check the damage in the first post, but it may cause problems if any plugin modifies the damage and is loaded before this one. While I take this as a second method, I'll still try using pev_button first as it may be a better solution if it works.

Backstabnoob 06-29-2012 18:12

Re: Multiply slash damage by two
 
I can confirm that pev_button works flawlessly.


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

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