AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Just a stupid Question..About Damage (https://forums.alliedmods.net/showthread.php?t=134004)

davidto1995 07-30-2010 18:36

Just a stupid Question..About Damage
 
how can i increase the damage or decrease it?
i mean increase or decrease on percentage(%)

Alucard^ 07-30-2010 20:06

Re: Just a stupid Question..About Damage
 
I don't know if this is the best method or the correct one, but tell me if it work and if this is what you want:

Code:
#include <amxmodx> #include <hamsandwich> #define PLUGIN  "Increase Damage by Porcent" #define AUTHOR  "Alucard" #define VERSION "0.0.1" #define PORCENT 50 public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR);         RegisterHam(Ham_TakeDamage, "player", "FwdTakeDamage"); } public FwdTakeDamage(id, iInflictor, iAttacker, Float:fDamage, iDamagebits) {     new Float:fResult = (fDamage * PORCENT) / 100;         fDamage += fResult;         SetHamParamFloat(4, fDamage);         return HAM_HANDLED; }

This should take the 50% of the damage, and then increase that porcent to the default damage.

Bugsy 07-30-2010 20:31

Re: Just a stupid Question..About Damage
 
Alucard, you must use a float for the entire calculation.

#define PORCENT 50.0

new Float:fResult = (fDamage * PORCENT) / 100.0;

Why not just set PORCENT as a percentage ( 0.5 , 0.75 , 1.5 ) etc. Then you will not need to divide by 100.

davidto1995 07-30-2010 20:57

Re: Just a stupid Question..About Damage
 
..i can't understand at all..
can someone just make a easy explanation for me
PS:i come form Hong Kong my english is poor= =
#define PORCENT 50

public FwdTakeDamage(id, iInflictor, iAttacker, Float:fDamage, iDamagebits)
{
new Float:fResult = (fDamage * PORCENT) / 100;

fDamage += fResult;
so it means increase 50% damage?

Bugsy 07-30-2010 21:04

Re: Just a stupid Question..About Damage
 
PHP Code:

#include <amxmodx>
#include <hamsandwich>

const FloatfDmgPercent 0.50;

public 
plugin_init()
{
    
RegisterHam(Ham_TakeDamage"player""FwdTakeDamage");
}

public 
FwdTakeDamageiVictim iInflictor iAttacker Float:fDamage iDamagebits )
{
    
//fDamage passed to this forward is the amount of damage caused to victim
    
    //Here you multiply the damage value by whatever multiplier you want.
    //In this example, fDmgPercent is 0.50 meaning the damage amount will
    //be reduced by half.
    
new FloatfResult = ( fDamage fDmgPercent );
    
    
//This modifies the damage value passed to the game engine to make
    //our calculated damage value take effect.
    
SetHamParamFloatfResult );
    
    return 
HAM_HANDLED;



davidto1995 07-30-2010 21:19

Re: Just a stupid Question..About Damage
 
THX =]


All times are GMT -4. The time now is 00:11.

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