AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved dmg without killing (dmg Armor only) (https://forums.alliedmods.net/showthread.php?t=295333)

abdobiskra 03-22-2017 18:06

dmg without killing (dmg Armor only)
 
Hi, i try to get victim dmg without killing ( i want only dmg for armor not health)
That's what I thought from the beginning but I did not succeed in achieving it. Is there any help?
PHP Code:

public plugin_init() {

    
RegisterHam(Ham_TraceAttack,"player","fw_TraceAttack")
}
public 
fw_TraceAttack(victiminflictorFloat:damageFloat:direction[3], traceresultdamagebits){
        
    if(
get_user_weapon(inflictor) == HLW_CROWBAR && get_user_armor(victim))
    {        
        
set_user_health(victimget_user_health(victim))
        
        
SetHamParamFloat(3100.0)
        
        return 
HAM_HANDLED;
    }
    return 
HAM_IGNORED


My question: is it possible to block victim's death if the damage inflicted to the victim is greater then the victim's hp?

EFFx 03-22-2017 18:27

Re: dmg without killing (dmg Armor only)
 
PHP Code:

if(!(floatround(damage) > get_user_health(victim)))
    return 
HAM_IGNORED 


OciXCrom 03-22-2017 18:28

Re: dmg without killing (dmg Armor only)
 
PHP Code:

RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"0)

// Completely block damage when player has armor:

public fw_TakeDamage(iVictimiInflictoriAttacker)
    return (
get_user_weapon(iAttacker) == HLW_CROWBAR && iInflictor == iAttacker && get_user_armor(iVictim)) ? HAM_SUPERCEDE HAM_IGNORED

// Don't do damage below 1 health:

public fw_TakeDamage(iVictimiInflictoriAttackerFloat:fDamage)
{
    if(
get_user_weapon(iAttacker) == HLW_CROWBAR && iInflictor == iAttacker && get_user_armor(iVictim))
    {
        
SetHamParamFloat(3floatclamp(fDamage0.0float(get_user_health(id) - 1)))
        return 
HAM_SUPERCEDE
    
}

    return 
HAM_IGNORED



abdobiskra 03-23-2017 11:52

Re: dmg without killing (dmg Armor only)
 
thx for rply guys
EFFx
Your code does not work !

OciXCrom

Quote:

// Completely block damage when player has armor:
The first function do not cause any damage for victim ?

Quote:

// Don't do damage below 1 health:
the second code worked for HP + ARmor but i need it for Armor only ?

PS:
To be more clear
I want to consume the armor from the victim to get the infection

The possibility of problem may be when the victim has a small health (ex: 1 hp) and a large armor (ex: 100)
So here the player may die without infection

MspoR 03-23-2017 12:06

Re: dmg without killing (dmg Armor only)
 
Quote:

if(!(floatround(damage) > get_user_health(victim)))
return HAM_IGNORED
Means it will not kill player if dmg is greater than hp so it can't kill victim, but all the time u are damaged, ur armor is destroying.

abdobiskra 03-23-2017 12:28

Re: dmg without killing (dmg Armor only)
 
MspoR
Yes it should, but I tried it and I dead !

MspoR 03-23-2017 12:52

Re: dmg without killing (dmg Armor only)
 
PHP Code:

    RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"0); 

It has to work.

abdobiskra 03-23-2017 14:11

Re: dmg without killing (dmg Armor only)
 
MspoR
Yes, Should it be that way or am I wrong?
PHP Code:

public plugin_init() {
    
register_plugin(PLUGINVERSIONAUTHOR)
    
RegisterHam(Ham_TakeDamage"player""fw_TakeDamage"0);  
    
// Add your code here...
}

public 
fw_TakeDamage(victiminflictoriAttackerFloat:fDamage)
{

    if(
get_user_weapon(iAttacker) == HLW_CROWBAR && get_user_armor(victim) && inflictor == iAttacker)
    { 
        if(!(
floatround(fDamage) > get_user_health(victim)))
            return 
HAM_IGNORED 
            
        
//set_user_health(victim, get_user_health(victim))
        
SetHamParamFloat(3100.0// here dmg == 100 I want to lose 100 Armor  per shot
        
client_print(print_chat"ABC")
        
        return 
HAM_HANDLED;
    }
    return 
HAM_IGNORED



You test it ?

EFFx 03-23-2017 14:46

Re: dmg without killing (dmg Armor only)
 
Why don't you test it by yourself?

As you said:

Quote:

My question: is it possible to block victim's death if the damage inflicted to the victim is greater then the victim's hp?
My code doesn't worked because I was returning HAM_IGNORED, it should be HAM_SUPERCEDE

PHP Code:

if(!(floatround(fDamage) > get_user_health(victim))) 

->

PHP Code:

if(floatround(fDamage) > get_user_health(victim))
    return 
HAM_SUPERCEDE 

And
PHP Code:

SetHamParamFloat(3100.0

It will take 100 Health Pack, not Armor Pack. I think here you must use set_user_armor()


All times are GMT -4. The time now is 17:55.

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