Jump to content
LSValmont

Can't get Force Respawn Hold Action to show once player is incapacitated

Recommended Posts

I've tried this in the Init.sqf file: (It should show the action every time the lifeState changes (or == Incapacitated).

Spoiler



[] spawn {
while {true} do
  {
sleep 1;  
_state = lifeState player;
hint _state;
waitUntil { lifeState player != _state }; 
[
    player,                                            // Object the action is attached to
    "Hold Space to Force Respawn",                                        // Title of the action
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",    // Idle icon shown on screen
    "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",    // Progress icon shown on screen
    "true;",                        // Condition for the action to be shown
    "true;",                        // Condition for the action to progress
    {},                                                    // Code executed when action starts
    {},                                                    // Code executed on every progress tick
    {forceRespawn player; },                // Code executed on completion
    {},                                                    // Code executed on interrupted
    [],                                                    // Arguments passed to the scripts as _this select 3
    12,                                                    // Action duration [s]
    0,                                                    // Priority
    true,                                                // Remove on completion
    true                                                // Show in unconscious state 
] remoteExec ["BIS_fnc_holdActionAdd", 1, player];    // MP compatible implementation        
  };
};


 


And this in the InitPlayerLocal.sqf file: (It was supposed to show the Hold Action everytime the player changed animations to "unconsciousrevivedefault".

Spoiler



player addEventHandler ["AnimStateChanged", {
    if (_this select 1 == "unconsciousrevivedefault") then {
	
[
	player,											// Object the action is attached to
	"Hold Space to Force Respawn",										// Title of the action
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",	// Idle icon shown on screen
	"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",	// Progress icon shown on screen
	"true;",						// Condition for the action to be shown
	"true;",						// Condition for the action to progress
	{},													// Code executed when action starts
	{},													// Code executed on every progress tick
	{forceRespawn player;},				// Code executed on completion
	{},													// Code executed on interrupted
	[],													// Arguments passed to the scripts as _this select 3
	12,													// Action duration [s]
	0,													// Priority
	true,												// Remove on completion
	true												// Show in unconscious state 
] remoteExec ["BIS_fnc_holdActionAdd", 10, player];	// MP compatible implementation		

    };
}]; 


 

 

PS: This is for a MP hosted Coop mission btw.

 

Any help would be greatly appreciated! 

Share this post


Link to post
Share on other sites
//initPlayerLocal.sqf

        [
            player,
            "Hold Space to Force Respawn",
            "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
            "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
            "lifestate _target == 'INCAPACITATED'",
            "true",
            {},
            {},
            {forceRespawn player},
            {},
            [],
            12,
            0,
            true,
            true
        ] call BIS_fnc_holdActionAdd;

player addEventHandler ["Respawn", {

		[
			player,
			"Hold Space to Force Respawn",
			"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
			"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
			"lifestate _target == 'INCAPACITATED'",
			"true",
			{},
			{},
			{forceRespawn player},
			{},
			[],
			12,
			0,
			true,
			true
		] call BIS_fnc_holdActionAdd; 
	
}];

 

  • Like 1
  • Thanks 1

Share this post


Link to post
Share on other sites

Just because i 'm really curious !

Why to do all this , when you can enable the revive ?

  • Like 2

Share this post


Link to post
Share on other sites
Just now, GEORGE FLOROS GR said:

Just because i 'm really curious !

Why to do all this , when you can enable the revive ?

 

Yes! You're right as far as players are concerned.

 

Apart: Because the revive is not provided, nor for SP mission, neither for not playable AIs in MP, you could exit the incapacitated state (something to plan also) at once, but it's better to make some action, and wait for an hold action completed for reviving a unit.

That's exactly what I'm doing in my script for healing AIs SP/MP.

 

 

EDITED: If you fail to display the Bis_fnc_holdActionAdd,  then check your scripts for a removeAllActions or any mod which could use this kind of command.

  • Like 2
  • Thanks 1

Share this post


Link to post
Share on other sites
On 14/11/2018 at 12:58 AM, davidoss said:

//initPlayerLocal.sqf

        [
            player,
            "Hold Space to Force Respawn",
            "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
            "\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
            "lifestate _target == 'INCAPACITATED'",
            "true",
            {},
            {},
            {forceRespawn player},
            {},
            [],
            12,
            0,
            true,
            true
        ] call BIS_fnc_holdActionAdd;

player addEventHandler ["Respawn", {

		[
			player,
			"Hold Space to Force Respawn",
			"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
			"\a3\ui_f\data\IGUI\Cfg\holdactions\holdAction_forceRespawn_ca.paa",
			"lifestate _target == 'INCAPACITATED'",
			"true",
			{},
			{},
			{forceRespawn player},
			{},
			[],
			12,
			0,
			true,
			true
		] call BIS_fnc_holdActionAdd; 
	
}];

 

 

You are a life saver davidoss! Thank you! Gonna test it ASAP!

 

On 14/11/2018 at 3:36 AM, GEORGE FLOROS GR said:

Just because i 'm really curious !

Why to do all this , when you can enable the revive ?

 

Simply put... because bis' revive implementation takes you to the incapacitated state regardless of your current health. (You could have 90% health and a single shot could bring you to incapacitated) and that was against of what I am trying to achieve in my mission. Also because of that my players could almost never get to the "limping" state that you get at 30% health or lower. That really adds to the immersion of being injured and that not only created tension/immersion but also more cooperation and better teamplay. Bis revive simply removed all that and made the whole "Health %" useless so I had to do my own custom solution that also included a very simple bleeding mechanic and a health system that rewards players that keep their nutrition high with a slight health regeneration. 

 

So I am combining a custom super simple player damage + nutrition check script with a custom Damage EH for my Ravage mission and for the whole system to work the way I intended it to work the player must be able get to that 10% health or less without going incapacitated before that. The Damage EH is tuned so that players get to that 10% health after ~ 3 shots from a high caliber weapon and ~ 6 shots from a low caliber weapon.

 

health.sqf, run from initPlayerLocal.sqf.

Spoiler

 


//Very simple health system for Ravage missions by Valmont

if (!hasInterface) exitWith {};

/*
rev_suicideActionAdd = [
		(_this select 0),
		"Suicide",
		"\A3\Ui_f\data\IGUI\Cfg\Revive\overlayIcons\d50_ca.paa",
		"\A3\Ui_f\data\IGUI\Cfg\Revive\overlayIcons\d100_ca.paa",
		"(damage _this select 0) > 0.90",
		"alive _this select 0",
		{},
		{},
		{			
			_this forceRespawn;
		},
		{},
		[],
		3,
		1000,
		true,
		true
] remoteExec ["BIS_fnc_holdActionAdd", 0, (_this select 0)];

*/

while {true} do {
/*
_health = damage player;
hint _health;
waitUntil { damage player != _health };
*/

  if (alive player) then {
	_hydration = player getVariable ["thirst", 100];
	_nutrition = player getVariable ["hunger", 100];
	sleep 1;
    if (damage player > 0.5 && damage player < 0.90 && _hydration > 20 && _nutrition > 20) then {
        player setDamage (damage player + 0.005);
		titleText ["You are bleeding, use a first aid kit to bandage yourself","PLAIN DOWN"]; titleFadeOut 12;
		[4000] call BIS_fnc_bloodEffect;
		player setUnconscious false;
    };
    if (damage player < 0.4 && damage player > 0.05 && _hydration > 55 && _nutrition > 55) then {
        player setDamage (damage player - 0.005);
		titleText ["Your wounds are minor and your good nutrition is slowly healing you...","PLAIN DOWN"]; titleFadeOut 6;
		//titleText ["Your wounds are minor and your nutrition is slowly healing you","PLAIN", 3];
    };	
    if (damage player > 0.90) then {
		player setUnconscious true;
		player setDamage (damage player + 0.0005);
		titleText ["You are Incapacitated and slowly bleeding, call for help!","PLAIN", 3];
		[8000] call BIS_fnc_bloodEffect;
		removeAllActions player;
//		_suicideAction = [player] call rev_suicideActionAdd;
	};

/*	
	if (lifeState player == 'incapacitated') then {
		waituntil {lifeState player == 'incapacitated' or (!(player call BIS_fnc_reviveEnabled) && damage player >=0.86)};
		_suicideAction = [player] call rev_suicideActionAdd;
		waituntil {!alive player or (!(player call BIS_fnc_reviveEnabled) && damage player <=0.30)};
		[player, rev_suicideActionAdd] call BIS_fnc_holdActionRemove;
	};
*/
	sleep 5;
	
  };
};

 

 

 

And the Damage regulation EH

Spoiler

 


player addEventHandler
	[
        "Dammaged",
        {
            _this spawn
            {
                //sleep 0.1;
                _unit = _this select 0;
                if (damage _unit >= 0.91) then
                {
                    //_unit execVM "scripts\bleed.sqf"
					//player setDamage (damage player - 0.01);
					//_damage = 0;
					//player allowDamage false;
					_unit setDamage 0.92;
                };
            };
        }
    ];	

// Damage reduction EH
params[ "_unit" ];

// Damage reduction from https://forums.bistudio.com/forums/topic/198136-reducing-player-damage/

// Exit if we are a player and not local
// Otherwise add EH for AI every where just in case 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 {
	_unit removeAllEventHandlers 'HandleDamage';
};

// 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", "_hitSelection", "_damage","_source","_projectile","_hitPartIndex", "_instigator", "_hitPoint"];

	// Damage multipliers.  The damage of each projectile will be multiplied by this number.
	private _damageMultiplierHead = 0.60;
	private _damageMultiplierBody = 0.50;
	private _damageMultiplierLimbs = 0.30;
	private _damageMultiplierOverall = 0.40;

	// Damage limits.  Each projectile will be limited to a max of this much damage.
	private _limitHead = 0.40;
	private _limitBody = 0.30;
	private _limitLimbs = 0.15;
	private _limitOverall = 0.20;

	private _oldDamage = 0;
	if (_hitSelection isEqualTo "") then {_oldDamage = damage _unit} else {_oldDamage = _unit getHit _hitSelection};
	private _newDamage = _damage - _oldDamage max 0;
	private _incomingDamage = _newDamage;
	private _playerHealth = damage _unit;

	// Infantry selections
	// Keep in mind that if revive is enabled then incapacitation may occur at around 0.7 damage.
	// "": The overall damage that determines the damage value of the unit. Unit dies at damage equal to or above 1
	// "face_hub": Unit dies at damage equal to or above 1
	// "neck": Unit dies at damage equal to or above 1
	// "head": Unit dies at damage equal to or above 1
	// "pelvis": Unit dies at damage equal to or above 1
	// "spine1": Unit dies at damage equal to or above 1
	// "spine2": Unit dies at damage equal to or above 1
	// "spine3": Unit dies at damage equal to or above 1
	// "body": Unit dies at damage equal to or above 1
	// "arms": Unit doesn't die with damage to this part
	// "hands": Unit doesn't die with damage to this part
	// "legs": Unit doesn't die with damage to this part

	// Do any other damage calculations here
	// _damage is the previous damage plus any new damage and will be applied
	// as the total damage the unit has for this selection once this EH returns

	// Only modify damage if it is a known projectile (leave falling damage etc alone)
	if (_newDamage > 0 && !(_projectile isEqualTo "")) then {
		// Reduce damage by damage multiplier
		private _damageMultiplier = _damageMultiplierBody;
		private _upperLimit = _limitBody;
		switch (_hitSelection) do {
			case "face_hub";
			case "head": {
				_damageMultiplier = _damageMultiplierHead;
				_upperLimit = _limitHead;
			};
			case "arms";
			case "hands";
			case "legs": {
				_damageMultiplier = _damageMultiplierLimbs;
				_upperLimit = _limitLimbs;
			};
			case "": {
				_damageMultiplier = _damageMultiplierOverall;
				_upperLimit = _limitOverall;
			};
			default { 
				_damageMultiplier = _damageMultiplierBody;
				_upperLimit = _limitBody;
			};
		};
		_newDamage = _newDamage * _damageMultiplier;

		// Place an upper limit on projectile damage done at once
		if (_newDamage > _upperLimit) then {
			_newDamage = _upperLimit;
		};

		_damage = _oldDamage  + _newDamage;
	};
	
	// For players ignore damage if they are incapacitated and pass damage to bis revive handler
	if ( isPlayer _unit ) then {
		if ( lifeState _unit == "INCAPACITATED" OR (damage _unit >= 0.91) ) then {
			//if we are incapacitated take no additional damage
			_damage = _oldDamage;
			sleep 10;
			player setDamage (damage player + 0.001);
		} else {
			_this set[ 2, _damage ];
			//Call BI REVIVE HandleDamage EH passing new _damage value
			_damage = _this call bis_fnc_reviveEhHandleDamage;
		};
	};

//	systemChat format[ "pHealth: %1 selection: %2 oldTotal: %3 newTotal: %4 incomingDmg: %6 appliedDmg: %6", _playerHealth, _hitSelection, _oldDamage, _damage, _incomingDamage, _newDamage];
	if(_damage >= 1) then {_damage = 0.91};	
	_damage
	
}];
//systemChat format[ "Damage reduction applied to %1", _unit ];

// End of damage reduction

 

 

 

 

It seems very simple but works very well for what I am trying to achieve.

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

×