AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Getting weapon damage (https://forums.alliedmods.net/showthread.php?t=164101)

r14170 08-07-2011 10:19

Getting weapon damage
 
How do i get damage dealt from a weapon?

avril-lavigne 08-07-2011 10:32

Re: Getting weapon damage
 
Ham_Takedamage
also event damage

look for damager.sma

r14170 08-07-2011 11:57

Re: Getting weapon damage
 
when i get the damage from a HE (for example) and then double it? sry for stupid questions :D

nikhilgupta345 08-07-2011 12:08

Re: Getting weapon damage
 
Are you asking how to double damage?

SetHamParamFloat( 4, Float:flDamage * 2 );

drekes 08-07-2011 12:21

Re: Getting weapon damage
 
To get damage done by a grenade do this:
PHP Code:

public plugin_init()
    
RegisterHam(Ham_TakeDamage"player""FwdPlayerTakeDamage");

public 
FwdPlayerTakeDamage(iVictimiInflictoriAttackerFloatflDamageiDmgBits)
{
    if(
iDmgBits & (1<<24))
    {
        
// Grenade damage
    
}



Bugsy 08-07-2011 13:46

Re: Getting weapon damage
 
Enter the weapons for which you want damage to be modified in the MULTIPLIER_WEAPONS const in the same way the current ones are listed. Set DMG_MULTIPLIER to the value that you want damage to be multiplied by. Default is 2.0, you can also reduce damage with this by using a value less than 1.0. Let me know if you have any problems, I quickly tested it and it worked. Something like this I'm sure already exists.
PHP Code:

#include <amxmodx>
#include <hamsandwich>

new const Version[] = "0.1";

const 
DMG_GRENADE = ( << 24 );

//Weapons that are affected by the multiplier:
const MULTIPLIER_WEAPONS 

    ( 
<< CSW_HEGRENADE ) | 
    ( 
<< CSW_AWP ) | 
    ( 
<< CSW_AK47 
);

//Damage gets multiplied by this:
const Float:DMG_MULTIPLIER 2.0;

new 
g_iMaxPlayers;

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

public plugin_init() 
{
    
register_plugin"Damage Multiplier" Version "bugsy" );
    
    
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );
    
g_iMaxPlayers get_maxplayers();
}

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage DmgBits )
{
    if ( 
IsPlayeriAttacker ) && 
        ( ( ( 
DmgBits DMG_GRENADE ) && ( MULTIPLIER_WEAPONS & ( << CSW_HEGRENADE ) ) ) || 
        ( !( 
DmgBits DMG_GRENADE ) && ( MULTIPLIER_WEAPONS & ( << get_user_weaponiAttacker ) ) ) ) ) )
    {
        
SetHamParamFloatfDamage DMG_MULTIPLIER );
        return 
HAM_HANDLED;
    }
    
    return 
HAM_IGNORED;


Damage issued
PHP Code:

#include <amxmodx>
#include <fakemeta>
#include <hamsandwich>

new const Version[] = "0.1";

public 
plugin_init() 
{
    
register_plugin"Damage" Version "bugsy" )
    
    
RegisterHamHam_TakeDamage "player" "fw_HamTakeDamage" );
}

public 
fw_HamTakeDamageiVictim iInflictor iAttacker Float:fDamage DmgBits )
{
    
//fDamage is the total damage issued to a player. If the victim has armor, the 
    //armor will absorb some of the damage which will result in the victims reduction in hp
    //to be less than fDamage.
    
    //This is the reduction in victims hp.
    
new iDamage peviVictim pev_dmg_take );
    



r14170 08-07-2011 16:39

Re: Getting weapon damage
 
Thanks Bugsy! helped me a lot!


All times are GMT -4. The time now is 03:27.

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