Raised This Month: $ Target: $400
 0% 

Double Damage


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-11-2020 , 08:16   Double Damage
Reply With Quote #1

I'm trying to set double damage when a certain boolean is true
PHP Code:
new bool:bHasWeapon[33]; 
Is this the way to do it or is there a better way? I've found this from a post of 2011 which is why i'm asking since it might be outdated.

PHP Code:
public PreDoubleDamage(idInflictorAttackerFloat:DamageDamagebits)
{
    if(!(
<= Attacker <= get_maxplayers()) || Attacker != Inflictor || !bHasWeapon[Attacker])
    {
        return 
HAM_IGNORED;
    }
    
    
SetHamParamFloat(4Damage 2); 
    return 
HAM_HANDLED;

Original thread: https://forums.alliedmods.net/showthread.php?t=174279
__________________

Last edited by Napoleon_be; 01-11-2020 at 08:19.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-11-2020 , 08:34   Re: Double Damage
Reply With Quote #2

Code:
1 <= Attacker <= get_maxplayers()

is_user_connected(iAttacker)

Code:
Attacker != Inflictor

This check will prevent double damage for HE grenades.

The rest is fine.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-11-2020 , 08:39   Re: Double Damage
Reply With Quote #3

So something like this?

PHP Code:
public PreDoubleDamage(idInflictorAttackerFloat:DamageDamagebits)
{
    if(!
is_user_connected(Attacker) || Attacker != Inflictor || !bHasWeapon[Attacker])
    {
        return 
HAM_IGNORED;
    }
    
    
SetHamParamFloat(4Damage 2); 
    return 
HAM_HANDLED;

__________________

Last edited by Napoleon_be; 01-11-2020 at 09:42.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-11-2020 , 08:53   Re: Double Damage
Reply With Quote #4

I meant to replace the entire check with "is_user_connected", not add it again.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-11-2020 , 09:42   Re: Double Damage
Reply With Quote #5

Adjusted my code, should be okay now?

Also double damage is not needed for HE Grenades. Double damage should only be applied to AK47, M4A1, AWP and Deagle. Gotta add CurWeapon for that, but i'm not that far yet.
__________________

Last edited by Napoleon_be; 01-11-2020 at 09:46.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-11-2020 , 09:52   Re: Double Damage
Reply With Quote #6

You don't need CurWeapon. You can use "get_user_weapon" directly.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-11-2020 , 10:07   Re: Double Damage
Reply With Quote #7

Quote:
Originally Posted by OciXCrom View Post
You don't need CurWeapon. You can use "get_user_weapon" directly.
Awesome thanks for the info, this is what it's become. Will something like this work? Can't really test it on my own. and i don't have a proper bot plugin

PHP Code:
new const iWeapons[] =
{
    
CSW_AK47,
    
CSW_M4A1,
    
CSW_AWP
}; 
PHP Code:
public PreDoubleDamage(idiInflictoriAttackerFloat:iDamageiDamagebits)
{
    if(!
is_user_connected(iAttacker) || iAttacker != iInflictor || !bHasWeapon[iAttacker])
    {
        return 
HAM_IGNORED;
    }
    
    new 
iWeapon get_user_weapon(iAttacker)
    
    for(new 
isizeof(iWeapons); i++)
    {
        if(
iWeapon == iWeapons[i])
        {
            
SetHamParamFloat(4iDamage 2); 
        }
    }
    return 
HAM_HANDLED;

__________________

Last edited by Napoleon_be; 01-11-2020 at 10:28.
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 01-11-2020 , 12:25   Re: Double Damage
Reply With Quote #8

Try this

PHP Code:
new g_WeaponList = ( << CSW_AK47 ) | ( << CSW_M4A1 ) | ( << CSW_AWP );

public 
PreDoubleDamageid iInflictor iAttacker Float:fDamage Damagebits )
{
    if ( ( 
iAttacker == iInflictor ) && bHasWeaponiAttacker ] && is_user_connectediAttacker ) && ( g_WeaponList & ( << get_user_weaponiAttacker ) ) ) )
    {
        
SetHamParamFloatfDamage 2.0 ); 
        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;

__________________

Last edited by Bugsy; 01-11-2020 at 12:57.
Bugsy is offline
Napoleon_be
Veteran Member
Join Date: Jul 2011
Location: Belgium
Old 01-12-2020 , 07:54   Re: Double Damage
Reply With Quote #9

Thanks for the feedback Bugsy, but i'm afraid if i use that code, that this code will become unnessecary.
PHP Code:
new const iWeapons[] =
{
    
CSW_AK47,
    
CSW_M4A1,
    
CSW_AWP
}; 
__________________
Napoleon_be is offline
Send a message via Skype™ to Napoleon_be
OciXCrom
Veteran Member
Join Date: Oct 2013
Location: Macedonia
Old 01-12-2020 , 08:33   Re: Double Damage
Reply With Quote #10

Bugsy gave you everything you need, so you don't need the iWeapons array. It's better to check the weapon using a bitstum rather than looping an entire array.
__________________
OciXCrom is offline
Send a message via Skype™ to OciXCrom
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 02:56.


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