AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Editing damage dealt by custom weapons (https://forums.alliedmods.net/showthread.php?t=163033)

DeLiriuM 07-26-2011 02:41

Editing damage dealt by custom weapons
 
Hey,

I'm trying to edit a custom weapons damage dealt, but everything i try seems to fail.

So here's the code->

Code:
public TakeDamage(victim, inflictor, attacker, Float:damage, damage_type) {     if (victim == attacker || !is_user_connected(attacker))         return HAM_IGNORED;                 if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor) && g_Chain[attacker])     {                 SetHamParamFloat(4, 500)     }                     if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor) && g_Electro[attacker])     {         SetHamParamFloat(4, 80)     }     if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor) && g_CrowBar[attacker] && get_user_team(attacker) != get_user_team(victim))     {         SetHamParamFloat(4, 50)     }         if (get_user_team(victim) == get_user_team(attacker) && IsGrenade(inflictor))     {         return HAM_SUPERCEDE     }         return HAM_IGNORED }

Weapons deal waay too little damage. Between 15-20, no matter if it's in the head or body.

So I want the weapons to deal atleast 25 damage, and 50-70 if it's in the head...

t3hNox 07-26-2011 04:21

Re: Editing damage dealt by custom weapons
 
I don't know if it is the main fault but you are not passing a float value in SetHamParamFloat.

It should be SetHamParamFloat(4, 500.0) NOT SetHamParamFloat(4, 500).
Also probably 3rd and 4th IF could be changed to ELSE IF.

Hunter-Digital 07-26-2011 05:08

Re: Editing damage dealt by custom weapons
 
Test on non-armored players and print some debug messages to be sure they get damaged by the right values...

Also, alot of wasted calls there, consider this instead:
Code:

    if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor))
    {
        new Float:fDamage = 0.0

        if(g_Chain[attacker])
          fDamage = 500.0
        else if(g_Electro[attacker])
          fDamage = 80.0
        else if(g_CrowBar[attacker] && get_user_team(attacker) != get_user_team(victim))
          fDamage = 50.0

        if(fDamage > 0.0)
        {
          SetHamParamFloat(4, fDamage)
          client_print(attacker, print_chat, "[debug] Damage changed to %.1f", fDamage)
        }
        else
          client_print(attacker, print_chat, "[debug] No damage change!")
    }

And why are you checking for friendlyfire only on crowbar ?

DeLiriuM 07-26-2011 05:32

Re: Editing damage dealt by custom weapons
 
Quote:

Originally Posted by Hunter-Digital (Post 1518688)
Test on non-armored players and print some debug messages to be sure they get damaged by the right values...

Also, alot of wasted calls there, consider this instead:
Code:

    if (get_user_weapon(attacker) == CSW_KNIFE && !IsGrenade(inflictor))
    {
        new Float:fDamage = 0.0

        if(g_Chain[attacker])
          fDamage = 500.0
        else if(g_Electro[attacker])
          fDamage = 80.0
        else if(g_CrowBar[attacker] && get_user_team(attacker) != get_user_team(victim))
          fDamage = 50.0

        if(fDamage > 0.0)
        {
          SetHamParamFloat(4, fDamage)
          client_print(attacker, print_chat, "[debug] Damage changed to %.1f", fDamage)
        }
        else
          client_print(attacker, print_chat, "[debug] No damage change!")
    }

And why are you checking for friendlyfire only on crowbar ?

Thanks!

The plugins isn't mine, but yeah. That's strange, will fix that :)

Exolent[jNr] 07-26-2011 17:06

Re: Editing damage dealt by custom weapons
 
Also, you were setting integer values into a function that accepts floats.
When the integer is casted into the float value, it isn't the same value anymore.


All times are GMT -4. The time now is 01:10.

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