AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   fw_TakeDamage, about armor/health/zombies (Not ZP) (https://forums.alliedmods.net/showthread.php?t=241999)

SkumTomteN 06-12-2014 09:58

fw_TakeDamage, about armor/health/zombies (Not ZP)
 
So i want that if the human got armor, zombies need to reduce the armor to infect the player, but i don't know correct the method for it. if somebody could teach me, or simply correct the code.

i will not post full code, you do not need it and its private.

i want it pretty much like zp 4.3.

PHP Code:

public fw_TakeDamage(VictimInflictorAttackerFloat:DamageDamageType)
{
    if(!
g_Game_Start)
        return 
HAM_SUPERCEDE
    
if(Victim == Attacker)
        return 
HAM_IGNORED
    
if(!is_user_alive(Attacker))
        return 
HAM_IGNORED
    
    
if(Get_BitVar(g_IsZombieVictim) && !Get_BitVar(g_IsZombieAttacker)) // Human -> Zombie
    
{
        if(
DamageType DMG_HEGRENADESetHamParamFloat(4Damage float(D_GrenadePower))
        else {
            
Damage *= g_fDamageMulti[g_Level[Attacker]]
            
            
// Zombie Victim Evolution Code Here!!!
            
if(g_Level[Victim] < 3)
            {
                
g_Evolution[Victim] += (g_Level[Victim] < 2) ? Damage 2000.0 Damage 1000.0
                UpdateLevelZombie
(Victim0)
            }
            
            
// Set Damage
            
SetHamParamFloat(4Damage)
        }
    } else if(!
Get_BitVar(g_IsZombieVictim) && Get_BitVar(g_IsZombieAttacker) { // Zombie -> Human
        
if(DamageType DMG_HEGRENADE)
            return 
HAM_SUPERCEDE
        
if(Damage <= 0.0)
    
        
// Set Zombie
        
set_user_zombie(VictimAttacker00)
        
        return 
HAM_SUPERCEDE
    
}
    
    return 
HAM_HANDLED


So i need something like get_user_armor. but more advanced.

the user cannot get infected if the user have any sort of armor, but zombies can reduce the armor, but not the health.

hope you understand, got any questions post them below:)

Thank you.

Flick3rR 06-12-2014 10:34

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
PHP Code:

if(Damage <= 0.0

What? I think that means there is no damage received, therefore ham takedamage is not called.

SkumTomteN 06-12-2014 12:14

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
Quote:

Originally Posted by Flick3rR (Post 2150497)
PHP Code:

if(Damage <= 0.0

What? I think that means there is no damage received, therefore ham takedamage is not called.

Edit: No, its for Attack power. Attack power for humans increase when humans shoot zombies.

Flick3rR 06-12-2014 16:14

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
Yes, that's why the upper part of the code is doing. But I was talking about that check, what do you think? It checks if the damage is 0.0, therefore there is no damage received.

SkumTomteN 06-12-2014 18:01

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
Quote:

Originally Posted by Flick3rR (Post 2150679)
Yes, that's why the upper part of the code is doing. But I was talking about that check, what do you think? It checks if the damage is 0.0, therefore there is no damage received.

Alright, can't hurt if i try:)

Edit:

Took a code from zp 4.3. but do not know how to add it in the code. because i suck.

PHP Code:

public fw_TakeDamage(VictimInflictorAttackerFloat:DamageDamageType)
    {
    if(!
g_Game_Start)
        return 
HAM_SUPERCEDE
    
if(Victim == Attacker)
        return 
HAM_IGNORED
    
if(!is_user_alive(Attacker))
        return 
HAM_IGNORED
    
    
if(Get_BitVar(g_IsZombieVictim) && !Get_BitVar(g_IsZombieAttacker)) // Human -> Zombie
        
{
        if(
DamageType DMG_HEGRENADESetHamParamFloat(4Damage float(D_GrenadePower))
        else {
            
Damage *= g_fDamageMulti[g_Level[Attacker]]
            
            
// Zombie Victim Evolution Code Here!!!
            
if(g_Level[Victim] < 3)
                {
                
g_Evolution[Victim] += (g_Level[Victim] < 2) ? Damage 2000.0 Damage 1000.0
                UpdateLevelZombie
(Victim0)
            }
            
            
// Set Damage
            
SetHamParamFloat(4Damage)
        }
        } else if(!
Get_BitVar(g_IsZombieVictim) && Get_BitVar(g_IsZombieAttacker)) { // Zombie -> Human
        
if(DamageType DMG_HEGRENADE)
            return 
HAM_SUPERCEDE
        
        
// Get victim armor
        
static Float:armor
        pev
(Victimpev_armorvaluearmor)
        
        
// If he has some, block the infection and reduce armor instead
        
if (armor 0.0)
            {
            if (
armor damage 0.0)
                
set_pev(victimpev_armorvaluearmor damage)
            else
            
cs_set_user_armor(victim0CS_ARMOR_NONE)
            
            return 
HAM_SUPERCEDE;
            
        }      
        
// Set Zombie
        
set_user_zombie(VictimAttacker00)
        
        return 
HAM_SUPERCEDE
    
}
    
    return  
HAM_HANDLED



Compidence 06-12-2014 19:40

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
You need to reword your question. What do you need help with exactly?

PHP Code:

        // Get victim armor 
        
static Float:armor 
        pev
(Victimpev_armorvaluearmor
         
        
// If he has some, block the infection and reduce armor instead 
        
if (armor 0.0
            { 
            if (
armor damage 0.0
                
set_pev(victimpev_armorvaluearmor damage
            else 
            
cs_set_user_armor(victim0CS_ARMOR_NONE
             
            return 
HAM_SUPERCEDE
             
        }       
        
// Set Zombie 
        
set_user_zombie(VictimAttacker00

Is that part not working? It looks fine to me.

aron9forever 06-13-2014 00:56

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
Quote:

Originally Posted by Compidence (Post 2150795)
You need to reword your question. What do you need help with exactly?

PHP Code:

        // Get victim armor 
        
static Float:armor 
        pev
(Victimpev_armorvaluearmor
         
        
// If he has some, block the infection and reduce armor instead 
        
if (armor 0.0
            { 
            if (
armor damage 0.0
                
set_pev(victimpev_armorvaluearmor damage
            else 
            
cs_set_user_armor(victim0CS_ARMOR_NONE
             
            return 
HAM_SUPERCEDE
             
        }       
        
// Set Zombie 
        
set_user_zombie(VictimAttacker00

Is that part not working? It looks fine to me.

there's one issue, the fact that the first time the player is hit and his armor drops below 0 he doesn't become a zombie until the next hit
also, I don't recall cs_set_user_armor using float

SkumTomteN 06-13-2014 02:47

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
Quote:

Originally Posted by Compidence (Post 2150795)
You need to reword your question. What do you need help with exactly?

PHP Code:

        // Get victim armor 
        
static Float:armor 
        pev
(Victimpev_armorvaluearmor
         
        
// If he has some, block the infection and reduce armor instead 
        
if (armor 0.0
            { 
            if (
armor damage 0.0
                
set_pev(victimpev_armorvaluearmor damage
            else 
            
cs_set_user_armor(victim0CS_ARMOR_NONE
             
            return 
HAM_SUPERCEDE
             
        }       
        
// Set Zombie 
        
set_user_zombie(VictimAttacker00

Is that part not working? It looks fine to me.

I did it wrong, so i get errors...

Edit: I was tired, and fixed the code, but now i get loose intendtion, even though i have intended it.

PHP Code:

public fw_TakeDamage(VictimInflictorAttackerFloat:DamageDamageType)
    {
    if(!
g_Game_Start)
        return 
HAM_SUPERCEDE
    
if(Victim == Attacker)
        return 
HAM_IGNORED
    
if(!is_user_alive(Attacker))
        return 
HAM_IGNORED
    
    
if(Get_BitVar(g_IsZombieVictim) && !Get_BitVar(g_IsZombieAttacker)) // Human -> Zombie
        
{
        if(
DamageType DMG_HEGRENADESetHamParamFloat(4Damage float(D_GrenadePower))
        else {
            
Damage *= g_fDamageMulti[g_Level[Attacker]]
            
            
// Zombie Victim Evolution Code Here!!!
            
if(g_Level[Victim] < 3)
                {
                
g_Evolution[Victim] += (g_Level[Victim] < 2) ? Damage 2000.0 Damage 1000.0
                UpdateLevelZombie
(Victim0)
            }
            
            
// Set Damage
            
SetHamParamFloat(4Damage)
        }
        } else if(!
Get_BitVar(g_IsZombieVictim) && Get_BitVar(g_IsZombieAttacker)) { // Zombie -> Human
        
if(DamageType DMG_HEGRENADE)
            return 
HAM_SUPERCEDE
        
        
// Get victim armor
        
static Float:armor
        pev
(Victimpev_armorvaluearmor)
        
        
// If he has some, block the infection and reduce armor instead
        
if (armor 0.0)
            {
            if (
armor Damage 0.0)
                
set_pev(Victimpev_armorvaluearmor Damage)
            else
            
cs_set_user_armor(Victim0CS_ARMOR_NONE)
            
            return 
HAM_SUPERCEDE;
        }
        
        
// Set Zombie
        
set_user_zombie(VictimAttacker00)
        
        return 
HAM_SUPERCEDE
    
}
    
    return  
HAM_HANDLED


Edit: It works now!, don't know why i get loose intendtion though. but atleast it works.

Flick3rR 06-13-2014 03:07

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
Because your identation was wrong.
PHP Code:

public fw_TakeDamage(VictimInflictorAttackerFloat:DamageDamageType)
{
    if(!
g_Game_Start)
        return 
HAM_SUPERCEDE
    
if(Victim == Attacker)
        return 
HAM_IGNORED
    
if(!is_user_alive(Attacker))
        return 
HAM_IGNORED
    
    
if(Get_BitVar(g_IsZombieVictim) && !Get_BitVar(g_IsZombieAttacker)) // Human -> Zombie
    
{
        if(
DamageType DMG_HEGRENADE
            
SetHamParamFloat(4Damage float(D_GrenadePower))
        else 
        {
            
Damage *= g_fDamageMulti[g_Level[Attacker]]
            
            
// Zombie Victim Evolution Code Here!!!
            
if(g_Level[Victim] < 3)
            {
                
g_Evolution[Victim] += (g_Level[Victim] < 2) ? Damage 2000.0 Damage 1000.0
                UpdateLevelZombie
(Victim0)
            }
            
            
// Set Damage
            
SetHamParamFloat(4Damage)
        }
    } 
    else if(!
Get_BitVar(g_IsZombieVictim) && Get_BitVar(g_IsZombieAttacker)) 
    { 
// Zombie -> Human
        
if(DamageType DMG_HEGRENADE)
            return 
HAM_SUPERCEDE
        
        
// Get victim armor
        
static Float:armor
        pev
(Victimpev_armorvaluearmor)
        
            
// If he has some, block the infection and reduce armor instead
        
if (armor 0.0)
        {
            if (
armor Damage 0.0)
                
set_pev(Victimpev_armorvaluearmor Damage)
            else
                
cs_set_user_armor(Victim0CS_ARMOR_NONE)
            
            return 
HAM_SUPERCEDE;
        }
        
        
// Set Zombie
        
set_user_zombie(VictimAttacker00)
        
        return 
HAM_SUPERCEDE
    
}
    
    return  
HAM_HANDLED


This is my way for making identation, also moved som brackets to look better and for easier orientating.

<VeCo> 06-13-2014 03:43

Re: fw_TakeDamage, about armor/health/zombies (Not ZP)
 
Quote:

Originally Posted by Flick3rR (Post 2150497)
PHP Code:

if(Damage <= 0.0

What? I think that means there is no damage received, therefore ham takedamage is not called.

It is, when you attack a teammate.


All times are GMT -4. The time now is 21:14.

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