Jump to content
androkiller

how to disable damage when unconscious?

Recommended Posts

Hello

So I want to use the arma 3 revive system but i do not like the feature of when you are unconscious you can receive damage thus killing you. So I was wondering how to go about disabling this feature because I don't see any options in the parameters of being able to do so

Share this post


Link to post
Share on other sites

Either with

unit allowDamage false

or with the damage event handler

unit addEventHandler ["HandleDamage", {0}]

Use lifeState to check when a unit is incapcacitated and allowDamage false it. (I prefer using EH since it gives you more control.)

Share this post


Link to post
Share on other sites

AllowDamage will not work as the revives handleDamage bypasses the normal damage routine by saving and adding up damage to hitPoints and then applying it manually with setDamage which does not trigger allowDamage.

Using the handleDamage EH with 0 although it will stop damage as shown will likely also break revive as once revived it will override the damage EH as it will be the last handleDamage EH added, unless you store a reference to it and remove it once revived.

 

See the script in this thread Here and just remove the damage reduction calculation.

Share this post


Link to post
Share on other sites

You can cut most of the script out as -ami- mofo also wanted to reduce damage across the board for all units.

//initPlayerLocal.sqf
params[ "_unit" ];

//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", {
    private[ "_damage" ];
    params [ "_unit" ];
    
    //If we are not incapacitated
    if ( lifeState _unit != "INCAPACITATED" ) then {
        //Get revives handle damage
        _damage = _this call BIS_fnc_reviveOnPlayerHandleDamage;
    }else{
        //if we are incapacitated
        _damage = 0;
    };
    
    _damage
    
}];

Placed in the initPlayerLocal.sqf as revive only works on players. If they are not incapacitated then call the function revive uses to calculate damage otherwise just return 0 damage.

  • Like 1

Share this post


Link to post
Share on other sites

Yep Larrow's the man... he sorted me out.

 

Make an InitPlayerLocal.sqf file with Larrow's scripting and slip it into your missions folder and then you can stay in revive mode until the timer runs out without taking anymore damage and dying.

 

I use the script below (also from Larrow) as it does ^^that but also enables me to alter the damage we take as we often play in a small co-op group against quite a few AI. So we need to be less prone to damage than usual.

 

Quote

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"];
    
      
    if ( lifeState _unit != "INCAPACITATED" ) then {
        
        //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 / 5;
            _damage = _damageRecieved + _selectionDamage;
        };
        
            
        //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;
        };
    }else{
        _damage = 0;
    };
    
       
    _damage
    
}];

 

Couple of other things...

 

I think you have to disable respawn in the editors multiplayer attributes as I've heard revive and respawn don't work well together. I don't use respawn though anyway so can't confirm whether true or not.

Also in editor MP attributes have the revive mode 'controlled by player attributes'.

Incapacitation mode 'basic'.

Set the revive timer to how long you want players to stay in revive until they bleed out and die.

 

Then right click on your playable units and choose 'attributes', 'object special states' and check the 'revive enable' box.

 

Now you should be good to go. 

 

 

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

×