Raised This Month: $ Target: $400
 0% 

damage multiplier


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 10-01-2011 , 08:35   damage multiplier
Reply With Quote #1

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.
egbertjan is offline
Hunter-Digital
Veteran Member
Join Date: Aug 2006
Location: In the Game [ro]
Old 10-01-2011 , 08:38   Re: damage multiplier
Reply With Quote #2

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.
__________________

Last edited by Hunter-Digital; 10-01-2011 at 08:40.
Hunter-Digital is offline
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 10-01-2011 , 09:14   Re: damage multiplier
Reply With Quote #3

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)
    }


Last edited by egbertjan; 10-01-2011 at 09:23.
egbertjan is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-01-2011 , 09:33   Re: damage multiplier
Reply With Quote #4

Use Float not float, there is a difference.

Use client print to make sure you are getting a good value, %f for float.
__________________
Bugsy is online now
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 10-01-2011 , 10:00   Re: damage multiplier
Reply With Quote #5

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)
    }

egbertjan is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 10-01-2011 , 10:08   Re: damage multiplier
Reply With Quote #6

Try 1.0 + ( float( player_power[ attacker ] ) / 100.0 )

or Float: ( player_power[ ...
__________________
Bugsy is online now
egbertjan
Senior Member
Join Date: Mar 2007
Location: The Netherlands
Old 10-01-2011 , 10:54   Re: damage multiplier
Reply With Quote #7

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.
egbertjan is offline
Reply


Thread Tools
Display Modes

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 19:38.


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