Jump to content
kouli2fraiz

How to increase the health of a unit ?

Recommended Posts

Hello, I want to give the player 4x the ammount of normal HP.

Is this possible ? I found lot of things with EH but they all seem to bug...

Share this post


Link to post
Share on other sites

This could work:

player addEventHandler ["handleDamage",{ (_this select 2) /4 }];

edit. No, it wouldn't.

  • Like 5

Share this post


Link to post
Share on other sites

Hey, can we use this for MP Player-health? 

plus it would go in initplayerlocal.sqf or in the init on the player (unit) in the map editor?

Share this post


Link to post
Share on other sites
On 10/24/2016 at 6:25 AM, Greenfist said:

This could work:


player addEventHandler ["handleDamage",{ (_this select 2) /4 }];


It wouldn't, there is no accumulation of damage.

Share this post


Link to post
Share on other sites
9 minutes ago, killzone_kid said:


It wouldn't, there is no accumulation of damage.

You're absolutely right. The third argument is the resulting damage, not the dealt amount. I didn't think that one through one bit.

Share this post


Link to post
Share on other sites
_unit addEventHandler ["HandleDamage", {
	params["_unit", "_selName", "_damage"];
	_diff = _damage - (_unit getHitPointDamage _selName);
	_result = (_unit getHitPointDamage _selName) + _diff * 0.25;
	_result
}];

Didn't test it but at least the idea seems sound.

Share this post


Link to post
Share on other sites

i've been trying this for 2 days now and i have search the net but i can't seems to get it to work, 

I'm trying to make player health on my server adjustable or just stronger so we dont get one shot, I have also tryed the 2 codes below in my iniplayerlocal.sqf at different times not together plus i have tryed it in the player init in the map editor , do you know a way i can make this work? i feel so lost haha

 

-----------------------------------------------------------------------------------------------------------------------------------------------------------


this addeventhandler ["HandleDamage", 

    private ["_return"];
    _unit             = _this select 0; 
    _selection         = _this select 1; 
    _passedDamage             = _this select 2; 
    _source            = _this select 3; 
    _projectile             = _this select 4; 
    
    _oldDamage = 0; 
    
    _bodyMultiplier      = 0; 
    _legsMultiplier      = 0.0025; 
    _handsMultiplier     = 0.0025;
    _headMultiplier      = 0.0075;
    _overAllMultiplier     = 0.0025; 
    
    switch (_selection) do
    { 
        case("head")    :
        {
            _oldDamage     = _unit getHitPointDamage "HitHead";
            _return     = _oldDamage + ((_passedDamage - _oldDamage) * _headMultiplier); 
        }; 
        case("body")    :
        {
            _oldDamage     = _unit getHitPointDamage "HitBody";
            _return     = _oldDamage + ((_passedDamage - _oldDamage) * _bodyMultiplier); 
        }; 
        case("hands")    :
        {
            _oldDamage     = _unit getHitPointDamage "HitHands";
            _return     = _oldDamage + ((_passedDamage - _oldDamage) * _handsMultiplier); 
        }; 
        case("legs")    :
        {
            _oldDamage     = _unit getHitPointDamage "HitLegs";
            _return     = _oldDamage + ((_passedDamage - _oldDamage) * _legsMultiplier); 
        }; 
        case("")        :
        {
            _oldDamage = damage _unit;
            _return     = _oldDamage + ((_passedDamage - _oldDamage) * _overAllMultiplier); 
        }; 
        default{}; 
    }; 
    
    _return
}];

 

--------------------------------------------------------------------------------------------------------------------------------------------------------------

 


params[ "_unit" ];

//Exit if we are a player and not local
//Otherwise add EH for AI every where just incase their locality
//changes due to moving into a players group
//the EH will only fire where the AI is local
if ( isPlayer _unit && { !local _unit } ) exitWith {};

if ( isPlayer _unit ) then {
    //Waituntil REVIVE handleDamage EH has been applied
    waitUntil{ !isNil { _unit getVariable "bis_revive_ehDamage" } };
    //Remove REVIVE HandleDamage EH
    _unit removeEventHandler[ "HandleDamage", _unit getVariable "bis_revive_ehDamage" ];
};

//Only damage from last applied handleDamage EH is taken into consideration by the engine
//Apply a new EH so as we can override the damage applied
_unit addEventHandler [ "HandleDamage", {
    params ["_unit", "_selection", "_damage","_source","","_index"];
    
    systemChat format[ "Damage recieved: %1", _damage ];
    
    //Do any other damage calculations here
    //_damage is the total damage the unit has for this selection once this EH returns
    //e.g lets change the damage recieved for each selection
    if ( _index > -1 ) then {
        private _selectionDamage = _unit getHit _selection;
        private _damageRecieved = (_damage - _selectionDamage) max 0;
        _damageRecieved = _damageRecieved / 100;
        _damage = _damageRecieved + _selectionDamage;
    };
    
    systemChat format[ "Damage to REVIVE: %1", _damage ];
    
    //Only players respond to REVIVE
    if ( isPlayer _unit ) then {
        _this set[ 2, _damage ];
        //Call BI REVIVE HandleDamage EH passing new _damage value
        _damage = _this call BIS_fnc_reviveOnPlayerHandleDamage;
    };
    
    systemChat format[ "Damage to engine: %1", _damage ];
    
    _damage
    
}];

systemChat format[ "Override REVIVE EH applied to %1", _unit ];

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×