AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Question]How To Increase Bullet Damage (https://forums.alliedmods.net/showthread.php?t=276551)

zombiesucker 12-23-2015 07:17

[Question]How To Increase Bullet Damage
 
how to increase our bullet damage when we fire useing any weapon??

siriusmd99 12-24-2015 12:19

Re: [Question]How To Increase Bullet Damage
 
You should have searched first because it's not a rare question but anyway. Here is the code:
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new g_amount

public plugin_init( ) 
{
    
RegisterHamHam_TakeDamage"player""fw_TakeDamage" );
    
g_amount register_cvar("amx_damage_increase" "1.5")
}

public 
fw_TakeDamagevictiminflictorattackerFloat:damagedamage_type )
{
    if( 
is_user_aliveattacker ))
    {
        
damage *= get_pcvar_float(g_amount)
        
SetHamParamFloat4damage );
    }


Example :
amx_cvar amx_damage_increase "1.5" - will multiply damage by 1.5 .

Bugsy 12-24-2015 14:33

Re: [Question]How To Increase Bullet Damage
 
Attacker not being alive doesn't matter here and you are not checking if the damage is from a bullet. You should return HAM_HANDLED after SetHamParamFloat().

Modified TakeDamage to increase damage from bullets only.
PHP Code:

#define DMG_BULLET (1<<1)     

public fw_TakeDamagevictiminflictorattackerFloat:damagedamage_type )
{
    if ( !( 
damage_type DMG_BULLET ) )
        return 
HAM_IGNORED;  

    
SetHamParamFloatdamage get_pcvar_floatg_amount ) );
    
    return 
HAM_HANDLED;


Modify damage from any weapon, including grenades
PHP Code:

#include <amxmodx>
#include <hamsandwich> 

#define IsPlayer(%1)    (1<=%1<=g_maxplayers)

new g_amount g_maxplayers;

public 
plugin_init( ) 
{
    
RegisterHamHam_TakeDamage "player" "fw_TakeDamage" );

    
g_amount register_cvar"amx_damage_increase" "1.5" );
    
g_maxplayers get_maxplayers();
}

public 
fw_TakeDamagevictim inflictor attacker Float:damage damage_type )
{
    if ( !
IsPlayerattacker ) )
        return 
HAM_IGNORED;  
    
    
SetHamParamFloatdamage get_pcvar_floatg_amount ) );
    
    return 
HAM_HANDLED;



siriusmd99 12-24-2015 16:26

Re: [Question]How To Increase Bullet Damage
 
Sorry, i just found that code posted be exolent and i thought it was right. Next time i will check.

PartialCloning 12-24-2015 16:37

Re: [Question]How To Increase Bullet Damage
 
What happens if you don't return HAM_HANDLED?

Bugsy 12-24-2015 17:24

Re: [Question]How To Increase Bullet Damage
 
I'm not sure, try it. Documentation states to use HANDLED when you've changed something.

Code:

HAM_IGNORED - Nothing happened, the call continues.
HAM_HANDLED - You did something, but the call continues.
HAM_OVERRIDE - The call will still be executed, but instead you will change the return value.
HAM_SUPERCEDE - The call is not executed, and you use your return value, if applicable


PartialCloning 12-24-2015 18:31

Re: [Question]How To Increase Bullet Damage
 
After reading the include, I think it's just for compatibility with other plugins and post hooks. Like if you were to use GetHamReturnFloat it would return the old value unless you used override or superceded it.

zombiesucker 12-25-2015 07:14

Re: [Question]How To Increase Bullet Damage
 
1 Attachment(s)
thanks all, i have another question,, i'm trying to merg this code to use it with cod mw4 and try make increase our bullet damage with upgrade is it possible?

here is sma to check if needed

addons_zz 12-25-2015 08:13

Re: [Question]How To Increase Bullet Damage
 
Quote:

Originally Posted by zombiesucker (Post 2376108)
thanks all, i have another question,, i'm trying to merg this code to use it with cod mw4 and try make increase our bullet damage with upgrade is it possible?

here is sma to check if needed

I think so, can you test it?

zombiesucker 12-25-2015 14:35

Re: [Question]How To Increase Bullet Damage
 
increase damage worked put how to upgrade it as same as in the sma if you know how?


All times are GMT -4. The time now is 17:59.

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