AlliedModders

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

egbertjan 10-01-2011 08:35

damage multiplier
 
Hello,

My current problem is the following:
I got a damage multiplier on every gun depending on the amount of points you have on a certain skill (Power).

PHP Code:

public fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    new 
powers = (player_power[inflictor]/50)
    new 
extradmg powers
    SetHamParamFloat
(4damage extradmg)
    


As you can see it should basicly come out to this: normale damage × (1 + (player_power[inflictor]/50). So it should do 200% at max level (it's 50 points per skill).
When it's maxed out it actually works. But below level 50 it's all the same damage (100%). Is there a reason that it won't work correctly?

P.S. I got an error index out of bounds on the "new powers = (player_power[inflictor]/50)" line. I've tried attacker instead of inflictor aswell.

Hunter-Digital 10-01-2011 08:38

Re: damage multiplier
 
You've got integer variables, the division will be rounded, just use float variables and problem solved.

About index out of bounds, use attacker but check if attacker is a player first.
Inflictor can be the HE grenade that killed the victim, but attacker is still the HE's owner, but if victim was killed by a gun, then inflictor is equal to attacker.

egbertjan 10-01-2011 09:14

Re: damage multiplier
 
So basicly the idea of a floating variable is used for an integer? (If so I would now understand the purpose of a float). I will try it out anyway.
Thanks.

Edit:
I've tried to change it to what you suggested with the floating variable. However I got a tag mismachted now because of the float. I've also tried to put a check if the attacker is a player (I believe it's done this way, if not please correct me).
PHP Code:

public fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if (
is_user_connected(attacker) && is_user_alive(attacker))  {
    new 
floatextradmg + (player_power[inflictor]/100)
    
    
SetHamParamFloat(4damage extradmg)
    }



Bugsy 10-01-2011 09:33

Re: damage multiplier
 
Use Float not float, there is a difference.

Use client print to make sure you are getting a good value, %f for float.

egbertjan 10-01-2011 10:00

Re: damage multiplier
 
I tried to change it to what you said, but I got a tag mismatch once again.

PHP Code:

public fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if (
is_user_connected(attacker) && is_user_alive(attacker))  {
    new 
Floatextradmg + (player_power[attacker]/100)
    
    
SetHamParamFloat(4damage extradmg)
    }



Bugsy 10-01-2011 10:08

Re: damage multiplier
 
Try 1.0 + ( float( player_power[ attacker ] ) / 100.0 )

or Float: ( player_power[ ...

egbertjan 10-01-2011 10:54

Re: damage multiplier
 
After making it this code it's finnaly working! Thanks Bugsy!
PHP Code:

public fw_TakeDamage(victiminflictorattackerFloat:damage)
{
    if (
is_user_connected(attacker) && is_user_alive(attacker))  {
        
    
SetHamParamFloat(4damage * (1.0 + ( floatplayer_powerattacker ] ) / 100.0 )))
    }


P.S. I wish you could help me with some other problems aswell, but I assume that you are quite busy. I've PMmed joaquimandrade for some private plugin recreation (also made a topic for this), but he hasn't replied yet perhaps you could help me out.


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

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