AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved stop losing hp of victim? (https://forums.alliedmods.net/showthread.php?t=299750)

abdobiskra 07-24-2017 14:54

stop losing hp of victim?
 
Hi
my idea . i want make anti-infection if human has armor dos not infected
i try to set human his hp when tok dmg from zombie :
PHP Code:

public plugin_init(){
   
   
RegisterHam(Ham_TraceAttack,"player","fw_TraceAttack")
}

public 
fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
   
   if(
damagebits == DMG_CLUB){ // crowbar dmg
      
      
      
if(floatround(damage) && get_user_armor(victim))
      {
         
         
set_user_armor(victimget_user_armor(victim) - 35// here i want victim losing 50 armor old dmg = 15 + 35 = 50 :P
         
set_user_health(victimget_user_health(victim) + 5// give the victim hp is losing (5) when has armor 
         
      
}/*else if(floatround(damage) > get_user_armor(victim) ) {
         
         //set_user_armor(victim, 0)
         //set_user_health(victim, 100)
         //return //HAM_IGNORED
      }*/
      
      //if(!is_user_alive(victim) || get_user_armor(victim)) return HAM_IGNORED
   
}


But I think it's a bad way and it does not work well in all cases
Is it correct or better pleas ?

edon1337 07-25-2017 07:04

Re: stop losing hp of victim?
 
1. Why are you using TraceAttack ?
2. What's this
PHP Code:

if(floatround(damage)) 


Natsheh 07-25-2017 08:05

Re: stop losing hp of victim?
 
Quote:

Originally Posted by edon1337 (Post 2537619)
1. Why are you using TraceAttack ?
2. What's this
PHP Code:

if(floatround(damage)) 


I think hes trying to block the victim health from decreasing if the victim has an armour, and damage the armour instead.

CrazY. 07-25-2017 18:28

Re: stop losing hp of victim?
 
Ham_TakeDamage (pre)... If user has armor, SetHamParamFloat(4, 0.0)... ?

abdobiskra 07-26-2017 15:52

Re: stop losing hp of victim?
 
I think I found some solutions but after knowing how to make TraceAttack forwards ?

debug:
PHP Code:

public fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
    
    if(
damage)
    {
        
client_print(0print_chat"ABC 1111111"// this work when i shot victims
        
    
}else{

        
client_print(0print_chat"ABC 000000"// but this no 
    
}



edon1337 07-26-2017 19:08

Re: stop losing hp of victim?
 
Quote:

Originally Posted by abdobiskra (Post 2537938)
I think I found some solutions but after knowing how to make TraceAttack forwards ?

debug:
PHP Code:

public fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
    
    if(
damage)
    {
        
client_print(0print_chat"ABC 1111111"// this work when i shot victims
        
    
}else{

        
client_print(0print_chat"ABC 000000"// but this no 
    
}



It's logically impossible for the second one to be printed, how do you expect to get 0 damage?

abdobiskra 07-27-2017 06:30

Re: stop losing hp of victim?
 
Quote:

Originally Posted by edon1337 (Post 2537991)
It's logically impossible for the second one to be printed, how do you expect to get 0 damage?

im said i want knowing how to make TraceAttack forward to cheak if victim is not in under attack ?
This is just an example of what I want to reach for everyone to understand

siriusmd99 07-28-2017 10:48

Re: stop losing hp of victim?
 
You must modify zombie plugin and check if user has armor before infect_user() function gets called.
something like this:

PHP Code:

new iArmor get_user_armor(victim);
if(
iArmor  35)
{
   
set_user_armor(victimiArmor 35)
}else{

   
infect_user(victim)



abdobiskra 07-29-2017 13:12

Re: stop losing hp of victim?
 
siriusmd99
i think i found right way to do it :
PHP Code:

public plugin_init(){
   
   
RegisterHam(Ham_TakeDamage"player""UserTakeDamage")
}

public 
UserTakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
   if (!
is_user_alive(attacker))
      return 
HAM_IGNORED;
      
   if(
damage_type != DMG_CLUB)
      return 
HAM_IGNORED;
      
   static 
Float:armor
   pev
(victimpev_armorvaluearmor)

   if (
armor 0.0)
   {
      if (
armor damage 0.0
      {
         
         
set_pev(victimpev_armorvaluearmor 50.0// 50.0 damage value
         
      
}else{
         
//SetHamParamFloat(4, damage)
         
hl_set_user_armor(victim0)
      }
      return 
HAM_SUPERCEDE;
   }
   return 
HAM_IGNORED;


How can cheak that the victim is under attack as well as not under attack or damage at the same time?

XINLEI 08-05-2017 18:50

Re: stop losing hp of victim?
 
This is done in ZP 5.0:
PHP Code:

// Ham Take Damage Forward
public fw_TakeDamage(victiminflictorattackerFloat:damagedamage_type)
{
    
// Non-player damage or self damage
    
if (victim == attacker || !is_user_alive(attacker))
        return 
HAM_IGNORED;
    
    
// Zombie attacking human...
    
if (zp_core_is_zombie(attacker) && !zp_core_is_zombie(victim))
    {
        
// Ignore damage coming from a HE grenade (bugfix)
        //if (damage_type & DMG_HEGRENADE)
        //    return HAM_HANDLED;
        
        // Does human armor need to be reduced before infecting/damaging?
        
if (!get_pcvar_num(cvar_human_armor_protect))
            return 
HAM_IGNORED;
        
        
// Should armor protect against nemesis attacks?
        
if (LibraryExists(LIBRARY_NEMESISLibType_Library) && !get_pcvar_num(cvar_armor_protect_nemesis) && zp_class_nemesis_get(attacker))
            return 
HAM_IGNORED;
        
        
// Should armor protect survivor too?
        
if (LibraryExists(LIBRARY_SURVIVORLibType_Library) && !get_pcvar_num(cvar_survivor_armor_protect) && zp_class_survivor_get(victim))
            return 
HAM_IGNORED;
        
        
// Get victim armor
        
static Float:armor
        pev
(victimpev_armorvaluearmor)
        
        
// If he has some, block damage and reduce armor instead
        
if (armor 0.0)
        {
            
emit_sound(victimCHAN_BODYg_sound_armor_hit1.0ATTN_NORM0PITCH_NORM)
            
            if (
armor damage 0.0)
                
set_pev(victimpev_armorvaluearmor damage)
            else
                
cs_set_user_armor(victim0CS_ARMOR_NONE)
            
            
// Block damage, but still set the pain shock offset
            
set_pdata_float(victimOFFSET_PAINSHOCK0.5)
            return 
HAM_SUPERCEDE;
        }
    }
    
    return 
HAM_IGNORED;




All times are GMT -4. The time now is 22:53.

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