AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Take damage not working properly (https://forums.alliedmods.net/showthread.php?t=326602)

Abhinash 08-07-2020 11:23

Take damage not working properly
 
Hey everyone.
Everything i working fine expect ammo packs in not rewarded to g_sniper and g_zadoc according to the damage.
Note. SNIPER_IGNOREAMMO and ZADOC_IGNOREAMMO is set to 0

Code --
Code:

// Ham Take Damage Forward
public fw_TakeDamage(victim, inflictor, attacker, Float:damage, damage_type, ptr)
{
        // Non-player damage or self damage
        if (victim == attacker || !is_user_valid_connected(attacker))
        return HAM_IGNORED;

       
        // New round starting or round ended
        if (g_newround || g_endround)
        return HAM_SUPERCEDE;
       
        // Victim shouldn't take damage
        if (g_nodamage[victim])
        return HAM_SUPERCEDE;
       
        // Prevent friendly fire
        if (g_zombie[attacker] == g_zombie[victim])
        return HAM_SUPERCEDE;

        // Set Sniper's damage
        if (g_sniper[attacker] && g_currentweapon[attacker] == CSW_AWP)
        SetHamParamFloat(4, SNIPER_DAMAGE)
       
        // Set Zadoc's damage                // Abhinash
        if (g_zadoc[attacker] && g_currentweapon[attacker] == CSW_KNIFE)
        SetHamParamFloat(4, get_pcvar_float(cvar_zadocdamage))

       
        // Attacker is human...
        if (!g_zombie[attacker])
        {
                // Armor multiplier for the final damage on normal zombies
                if (!g_nemesis[victim] && !g_assassin[victim] && !g_bombardier[victim] && !g_sniper[attacker] && !g_zadoc[attacker])                // Abhinash
                {
                        damage *= get_pcvar_float(cvar_zombiearmor)
                        SetHamParamFloat(4, damage)
                }
               
                // Reward ammo packs to humans for damaging zombies?       
                if (!g_zombie[attacker])
                {
                        // Store damage dealt
                        g_damagedealt_human[attacker] += floatround(damage)
                       
                        if(g_sniper[attacker])
                        {
                                if(SNIPER_IGNOREAMMO == 0)
                                {
                                        while (g_damagedealt_human[attacker] >= 5000)
                                        {
                                                g_ammopacks[attacker]++
                                                g_damagedealt_human[attacker] -= 5000
                                        }
                                }
                                else
                                {
                                        return HAM_IGNORED
                                }
                        }
                        else if(g_survivor[attacker])
                        {
                                if(SURVIVOR_IGNOREAMMO == 0)
                                {
                                        while (g_damagedealt_human[attacker] > 500)
                                        {
                                                g_ammopacks[attacker]++
                                                g_damagedealt_human[attacker] -= 500
                                        }
                                }
                                else
                                {
                                        return HAM_IGNORED
                                }
                        }
                        else if(g_zadoc[attacker])
                        {
                                if(ZADOC_IGNOREAMMO == 0)
                                {
                                        while (g_damagedealt_human[attacker] > 5000)
                                        {
                                                g_ammopacks[attacker]++
                                                g_damagedealt_human[attacker] -= 5000
                                        }
                                }
                                else
                                {
                                        return HAM_IGNORED
                                }
                        }
                        else if(!g_sniper[attacker] || !g_survivor[attacker] || !g_zadoc[attacker])
                        {
                                while (g_damagedealt_human[attacker] > 500)
                                        {
                                                g_ammopacks[attacker]++
                                                g_damagedealt_human[attacker] -= 500
                                        }
                        }
                       
                        return HAM_IGNORED
                }
               
                // Abhinash
                if (g_doubledamage[attacker])
                {
                        damage *= 2.0;
                        SetHamParamFloat(4, damage);
                }
               
                return HAM_IGNORED;
        }
       
        // Attacker is zombie...
       
        // Prevent infection/damage by HE grenade (bugfix)
        if (damage_type & DMG_HEGRENADE)
        return HAM_SUPERCEDE;
       
        // Nemesis?
        if (g_nemesis[attacker])
        {
                // Ignore nemesis damage override if damage comes from a 3rd party entity
                // (to prevent this from affecting a sub-plugin's rockets e.g.)
                if (inflictor == attacker)
                {
                        // Set nemesis damage
                        SetHamParamFloat(4, NEMESIS_DAMAGE)
                }
               
                return HAM_IGNORED;
        }
        else if (g_assassin[attacker])
        {
                // Ignore assassin damage override if damage comes from a 3rd party entity
                // (to prevent this from affecting a sub-plugin's rockets e.g.)
                if (inflictor == attacker)
                {
                        // Set assassin damage
                        SetHamParamFloat(4, ASSASSIN_DAMAGE)
                }
               
                return HAM_IGNORED;
        }
        else if (g_bombardier[attacker])
        {
                // Ignore assassin damage override if damage comes from a 3rd party entity
                // (to prevent this from affecting a sub-plugin's rockets e.g.)
                if (inflictor == attacker)
                {
                        // Set assassin damage
                        SetHamParamFloat(4, BOMBARDIER_DAMAGE)
                }
               
                return HAM_IGNORED;
        }
       
        // Reward ammo packs to zombies for damaging humans?
        if (get_pcvar_num(cvar_ammodamage_zombie) > 0)
        {
                // Store damage dealt
                g_damagedealt_zombie[attacker] += floatround(damage)
               
                // Reward ammo packs for every [ammo damage] dealt
                while (g_damagedealt_zombie[attacker] > get_pcvar_num(cvar_ammodamage_zombie))
                {
                        g_ammopacks[attacker]++
                        g_damagedealt_zombie[attacker] -= get_pcvar_num(cvar_ammodamage_zombie)
                }
        }
       
        // Last human or not an infection round
        if (g_survround || g_sniround || g_nemround || g_assaround || g_bombardierround/* Abhinash*/ || g_zadocround /* Abhinash */|| g_swarmround || g_plagueround || g_armageround || g_apocround || g_nightround || fnGetHumans() == 1)
        return HAM_IGNORED; // human is killed
       
        // Does human armor need to be reduced before infecting?
        if (get_pcvar_num(cvar_humanarmor))
        {
                // Get victim armor
                static Float:armor
                pev(victim, pev_armorvalue, armor)
               
                // If he has some, block the infection and reduce armor instead
                if (armor > 0.0)
                {
                        emit_sound(victim, CHAN_BODY, sound_armorhit, 1.0, ATTN_NORM, 0, PITCH_NORM)
                        if (armor - damage > 0.0)
                        set_pev(victim, pev_armorvalue, armor - damage)
                        else
                        cs_set_user_armor(victim, 0, CS_ARMOR_NONE)
                        return HAM_SUPERCEDE;
                }
        }
       
        // Infection allowed
        zombieme(victim, attacker, 0, 0, 0, 0, 1) // turn into zombie
        g_points[attacker]++                // Abhinash
        SavePoints(attacker)                // Abhinash
        return HAM_SUPERCEDE;
}


Abhinash 08-08-2020 17:35

Re: Take damage not working properly
 
Can anyone please help me out ?

ZaX 08-08-2020 20:25

Re: Take damage not working properly
 
add debugs, check logs

Abhinash 08-09-2020 11:41

Re: Take damage not working properly
 
Quote:

Originally Posted by ZaX (Post 2713588)
add debugs, check logs

Debug is on and nothing in logs.
The code executes fine but doesn't work for g_sniper and g_zadoc.
How can I fix it ?

HamletEagle 08-09-2020 15:19

Re: Take damage not working properly
 
Not "debug". You should add messages in the code to understand what gets executed and what doesn't.

Abhinash 08-12-2020 17:15

Re: Take damage not working properly
 
Can you edit my code for example ?

Black Rose 08-12-2020 17:32

Re: Take damage not working properly
 
Code:
        // Reward ammo packs to humans for damaging zombies?            if (!g_zombie[attacker])         {             // Store damage dealt             g_damagedealt_human[attacker] += floatround(damage)                         if(g_sniper[attacker])             {
->
Code:
        // Reward ammo packs to humans for damaging zombies?            server_print("g_zombie[%d]: %s", attacker, g_zombie[attacker] ? "true" : "false");         if (!g_zombie[attacker])         {             // Store damage dealt             g_damagedealt_human[attacker] += floatround(damage)                         server_print("g_sniper[%d]: %s", attacker, g_sniper[attacker] ? "true" : "false");             if(g_sniper[attacker])             {

... and so on.


All times are GMT -4. The time now is 13:54.

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