Update combat handling

- Remove startcombattimer variable
- Add combatNoTimeout variable to handle a combat without a time limit
This commit is contained in:
A Man
2022-06-26 15:57:15 +02:00
parent 36f5c8707a
commit b6c7364c56
11 changed files with 122 additions and 137 deletions

View File

@@ -140,6 +140,7 @@ fnc_evr = {
};
if (_this == "Stage4") exitWith {
[player,false] call fnc_setCombat; // Start endless combat until storm has ended
if (_hasAPSI) then {
playSound "ns_evrDetect";
uiSleep 0.2;
@@ -187,7 +188,7 @@ fnc_evr = {
if (_this == "Stage5") exitWith {
DZE_EVRStormRunning = true;
[player,false] call fnc_setCombat;
[player,false] call fnc_setCombat; // Start endless combat until storm has ended
if (_hasAPSI) then {
playSound "ns_evrDetect";
@@ -234,7 +235,8 @@ fnc_evr = {
"chromAberration" ppEffectEnable false;
};
if (_this == "Stage6") exitWith {
if (_this == "Stage6") exitWith {
[player,false] call fnc_setCombat; // Start endless combat until storm has ended
if (_hasAPSI) then {
playSound "ns_evrDetect";
uiSleep 0.2;
@@ -280,7 +282,8 @@ fnc_evr = {
"chromAberration" ppEffectEnable false;
};
if (_this == "Stage7") exitWith {
if (_this == "Stage7") exitWith {
[player,false] call fnc_setCombat; // Start endless combat until storm has ended
if (_hasAPSI) then {
playSound "ns_evrDetect";
cutRsc ["RscAPSI_Start","PLAIN"];
@@ -481,7 +484,7 @@ fnc_evr = {
disableUserInput true; disableUserInput true;
disableUserInput false; disableUserInput false;
DZE_EVRStormRunning = false;
player setVariable["startcombattimer", 0];
player setVariable["combatNoTimeout", 0];
};
};
};

View File

@@ -115,7 +115,7 @@ if (r_player_unconscious) then {
};
//Lets make sure the player is looking at the target
if (isPlayer cursorTarget) then {
if (isPlayer cursorTarget && _hasPatient) then {
if (!r_player_unconscious && !_inVehicle && {!r_drag_sqf && !r_action && player distance _menClose < 3}) then {
local _unit = cursorTarget;
player reveal _unit;
@@ -153,109 +153,107 @@ if (isPlayer cursorTarget) then {
};
local _vehClose = (getPosATL player) nearEntities [["Car","Tank","Helicopter","Plane","StaticWeapon","Ship"],5];
local _action = [];
//Allow player to drag
if(_unconscious && !_dragged) then {
r_action = true;
local _action1 = _unit addAction [localize "STR_UI_GEAR", "\z\addons\dayz_code\actions\openGear.sqf",_unit, 0, true, true];
local _action2 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];
local _action3 = _unit addAction [localize "str_actions_medical_02", "\z\addons\dayz_code\medical\pulse.sqf",_unit, 0, true, true];
local _action4 = _unit addAction [localize "str_actions_medical_drag", "\z\addons\dayz_code\medical\carry.sqf",_unit, 0, true, true];
if (_hasPatient) then {
local _action = [];
//Allow player to drag
if(_unconscious && !_dragged) then {
r_action = true;
local _action1 = _unit addAction [localize "STR_UI_GEAR", "\z\addons\dayz_code\actions\openGear.sqf",_unit, 0, true, true];
local _action2 = _unit addAction [localize "str_actions_medical_01", "\z\addons\dayz_code\medical\drag.sqf",_unit, 0, true, true];
local _action3 = _unit addAction [localize "str_actions_medical_02", "\z\addons\dayz_code\medical\pulse.sqf",_unit, 0, true, true];
local _action4 = _unit addAction [localize "str_actions_medical_drag", "\z\addons\dayz_code\medical\carry.sqf",_unit, 0, true, true];
r_player_actions set [count r_player_actions, _action1];
r_player_actions set [count r_player_actions, _action2];
r_player_actions set [count r_player_actions, _action3];
r_player_actions set [count r_player_actions, _action4];
};
//Load Vehicle
if (_unconscious && {(count _vehClose > 0) && !locked (_vehClose select 0)}) then {
r_action = true;
local _vehicle = _vehClose select 0;
local _vehType = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName");
_action = _unit addAction [format[localize "str_actions_medical_03",_vehType], "\z\addons\dayz_code\medical\load\load_act.sqf",[player,_vehicle,_unit], 0, true, true];
r_player_actions set [count r_player_actions, _action1];
r_player_actions set [count r_player_actions, _action2];
r_player_actions set [count r_player_actions, _action3];
r_player_actions set [count r_player_actions, _action4];
};
//Load Vehicle
if (_unconscious && {(count _vehClose > 0) && !locked (_vehClose select 0)}) then {
r_action = true;
local _vehicle = _vehClose select 0;
local _vehType = getText (configFile >> "CfgVehicles" >> typeOf _vehicle >> "displayName");
_action = _unit addAction [format[localize "str_actions_medical_03",_vehType], "\z\addons\dayz_code\medical\load\load_act.sqf",[player,_vehicle,_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to bandage
if(_injured && _hasBandage) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04", "\z\addons\dayz_code\medical\bandage.sqf",[_unit,"ItemBandage"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give sepsis bandage
if((_injured || _hasSepsis) && _hasSepsisBandage) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04_sepsis", "\z\addons\dayz_code\medical\bandage.sqf",[_unit,"ItemSepsisBandage"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give antibacterial wipe
if(_hasSepsis && _hasABWipes) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04_wipes", "\z\addons\dayz_code\medical\wipes.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Epinephrine
if(_unconscious && _hasEpi) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_05", "\z\addons\dayz_code\medical\epinephrine.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Morphine
if((_legsBroke || _armsBroke) && _hasMorphine) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_06", "\z\addons\dayz_code\medical\brokeBones.sqf",[_unit,"ItemMorphine"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give equip_woodensplint
if((_legsBroke || _armsBroke) && _hasSplint) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_06_splint", "\z\addons\dayz_code\medical\brokeBones.sqf",[_unit,"equip_woodensplint"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Painkillers
if(_inPain && _hasPainkillers) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_07", "\z\addons\dayz_code\medical\painkiller.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to transfuse blood
if(_lowBlood && _hasBloodBag) then {
r_action = true;
if (dayz_classicBloodBagSystem) then {
_action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion.sqf",[_unit,"ItemBloodbag"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
} else {
local _tempArray = [];
{ // This was a TODO by the Vanilla Mod devs.
if (_x in _playerMagazines && {!(_x in _tempArray)}) then {
local _displayName = getText(configFile >> "cfgMagazines" >> _x >> "displayName");
_action = _unit addAction [format[localize "str_actions_medical_08a",_displayName], "\z\addons\dayz_code\medical\transfusion.sqf",[_unit,_x], 0, true, true];
r_player_actions set [count r_player_actions,_action];
_tempArray set [count _tempArray, _x];
};
} count _bloodBags;
};
//Allow player to bandage
if(_injured && _hasBandage) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04", "\z\addons\dayz_code\medical\bandage.sqf",[_unit,"ItemBandage"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give sepsis bandage
if((_injured || _hasSepsis) && _hasSepsisBandage) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04_sepsis", "\z\addons\dayz_code\medical\bandage.sqf",[_unit,"ItemSepsisBandage"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give antibacterial wipe
if(_hasSepsis && _hasABWipes) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_04_wipes", "\z\addons\dayz_code\medical\wipes.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Epinephrine
if(_unconscious && _hasEpi) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_05", "\z\addons\dayz_code\medical\epinephrine.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Morphine
if((_legsBroke || _armsBroke) && _hasMorphine) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_06", "\z\addons\dayz_code\medical\brokeBones.sqf",[_unit,"ItemMorphine"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give equip_woodensplint
if((_legsBroke || _armsBroke) && _hasSplint) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_06_splint", "\z\addons\dayz_code\medical\brokeBones.sqf",[_unit,"equip_woodensplint"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to give Painkillers
if(_inPain && _hasPainkillers) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_07", "\z\addons\dayz_code\medical\painkiller.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions,_action];
};
//Allow player to transfuse blood
if(_lowBlood && _hasBloodBag) then {
r_action = true;
if (dayz_classicBloodBagSystem) then {
_action = _unit addAction [localize "str_actions_medical_08", "\z\addons\dayz_code\medical\transfusion.sqf",[_unit,"ItemBloodbag"], 0, true, true];
r_player_actions set [count r_player_actions,_action];
} else {
local _tempArray = [];
{ // This was a TODO by the Vanilla Mod devs.
if (_x in _playerMagazines && {!(_x in _tempArray)}) then {
local _displayName = getText(configFile >> "cfgMagazines" >> _x >> "displayName");
_action = _unit addAction [format[localize "str_actions_medical_08a",_displayName], "\z\addons\dayz_code\medical\transfusion.sqf",[_unit,_x], 0, true, true];
r_player_actions set [count r_player_actions,_action];
_tempArray set [count _tempArray, _x];
};
} count _bloodBags;
};
};
//Allow player to give antibiotics
if (_infected && _hasAntibiotics) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_give_antibiotics", "\z\addons\dayz_code\medical\antibiotics.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions, _action];
};
_isFriendly = [player, _unit] call FNC_check_access;
if !(_isFriendly select 1) then {
r_action = true;
_action = _unit addAction ["Tag as friendly", "\z\addons\dayz_code\actions\player_tagFriendly.sqf", [], 0, false, true];
r_player_actions set [count r_player_actions,_action];
};
if (r_action) then {
r_action_targets set [(count r_action_targets), _unit];
};
if (r_action_unload) then {
r_action_unload = false;
call fnc_usec_medic_removeActions;
};
};
//Allow player to give antibiotics
if (_infected && _hasAntibiotics) then {
r_action = true;
_action = _unit addAction [localize "str_actions_medical_give_antibiotics", "\z\addons\dayz_code\medical\antibiotics.sqf",[_unit], 0, true, true];
r_player_actions set [count r_player_actions, _action];
};
_isFriendly = [player, _unit] call FNC_check_access;
if !(_isFriendly select 1) then {
r_action = true;
_action = _unit addAction ["Tag as friendly", "\z\addons\dayz_code\actions\player_tagFriendly.sqf", [], 0, false, true];
r_player_actions set [count r_player_actions,_action];
};
if (r_action) then {
r_action_targets set [(count r_action_targets), _unit];
};
if (r_action_unload) then {
r_action_unload = false;
call fnc_usec_medic_removeActions;
};
};
};

View File

@@ -85,11 +85,8 @@ _isPlayer = (isPlayer _source);
if (DZE_PVE_Mode && {_isPlayer} && {!_falling}) exitWith {};
if (_unit == player) then {
//Set player in combat
_unit setVariable["startcombattimer", 1];
if !(_unit getVariable["inCombat",false]) then {
_unit setVariable["inCombat",true,true];
};
//Set player in combat
[_unit,true] call fnc_setCombat;
if (r_player_timeout == 0 && {!_inVehicle}) then {
if (_ammo == "tranquiliser_bolt") then {

View File

@@ -1,10 +1,10 @@
local _object = _this select 0;
local _setCombatOverTime = _this select 1;
local _setCombatOverTime = _this select 1; // if true, combat has a time limit
if (_setCombatOverTime) then {
_object setVariable["combattimeout", diag_tickTime + DZE_CombatTimer];
if (_setCombatOverTime) then {
_object setVariable["combatTimeout", diag_tickTime + DZE_CombatTimer]; // Combat time limited based on DZE_CombatTimer
} else {
_object setVariable["startcombattimer", 1];
_object setVariable["combatNoTimeout", 1]; // Endless combat until the combat variable will be resetted
};
if !(_object getVariable ["inCombat",false]) then {

View File

@@ -177,12 +177,6 @@ disableUserInput true;
if (dayz_soundMuted) then {call player_toggleSoundMute;}; // hide icon before fadeSound
0.1 fadeSound 0;
_body setVariable ["NORRN_unconscious", false, true];
_body setVariable ["unconsciousTime", 0, true];
_body setVariable ["USEC_isCardiac",false,true];
_body setVariable ["bloodTaken", false, true];
_body setVariable ["startcombattimer", 0]; //remove combat timer on death
_body setVariable ["inCombat", false, true];
r_player_unconscious = false;
r_player_cardiac = false;
dayz_autoRun = false;
@@ -212,8 +206,6 @@ deleteGroup _myGroup;
3 cutRsc ["default", "PLAIN",3];
4 cutRsc ["default", "PLAIN",3];
_body setVariable["combattimeout", 0, true];
_animState = toLower (animationState _body);
_animStateArray = toArray _animState;
_animCheck = toString ([(_animStateArray select 0),(_animStateArray select 1),(_animStateArray select 2),(_animStateArray select 3)]);

View File

@@ -22,7 +22,8 @@ local _zombieKills = player getVariable ["zombieKills",0];
local _headShots = player getVariable ["headShots",0];
local _humanKills = player getVariable ["humanKills",0];
local _banditKills = player getVariable ["banditKills",0];
local _combattimeout = player getVariable["combattimeout",0];
local _combattimeout = player getVariable["combatTimeout",0];
local _combatNoTimeout = player getVariable["combatNoTimeout",0];
local _inCombat = player getVariable ["inCombat",false];
local _survivalTime = player getVariable ["SurvivalTime",0];
local _ConfirmedHumanKills = player getVariable ["ConfirmedHumanKills",0];
@@ -91,7 +92,8 @@ if (count _medical > 0) then {
//player setVariable ["banditKills",_banditKills,true]; //Moved to player_switchModel
//player setVariable ["characterID",_charID,true]; //Moved to player_switchModel
player setVariable ["worldspace",_worldspace];
player setVariable ["combattimeout",_combattimeout,false];
player setVariable ["combatTimeout",_combattimeout,false];
player setVariable ["combatNoTimeout",_combatNoTimeout,false];
player setVariable ["inCombat",_inCombat,true];
player setVariable ["SurvivalTime",_survivalTime,false];
player setVariable ["ConfirmedHumanKills",_ConfirmedHumanKills,true];

View File

@@ -23,9 +23,8 @@ if (diag_tickTime - dayz_lastSave > 10) then {
};
while {(!isNull _display) && !r_player_dead} do {
_timeout = 30;
_timeout = player getVariable["combattimeout", 0];
_inCombat = (_timeout >= diag_tickTime);
_timeout = player getVariable["combatTimeout", 0];
_inCombat = (_timeout >= diag_tickTime) || (player getVariable["combatNoTimeout", 0] == 1);
_playerCheck = ({isPlayer _x} count (player nearEntities ["AllVehicles",5]) > 1);
_zedCheck = ((count (player nearEntities ["zZombie_Base",10]) > 0) && !_isPZombie);
_gearDisplay = findDisplay 106;
@@ -70,7 +69,7 @@ while {(!isNull _display) && !r_player_dead} do {
};
case (_inCombat) : {
_btnAbort ctrlEnable false;
_btnAbort ctrlSetText format["%1 (in %2)", _btnAbortText, ceil (_timeout - diag_tickTime)];
_btnAbort ctrlSetText format["%1 (in %2)", _btnAbortText,[DZE_CombatTimer,ceil (_timeout - diag_tickTime)] select ((player getVariable["combatNoTimeout", 0] == 0))];
[localize "str_abort_playerincombat",1] call dayz_rollingMessages;
if (TimeOutDisplayed) then {
_display closeDisplay 2;

View File

@@ -15,7 +15,7 @@ local _foodVal = 1 - (dayz_hunger / SleepFood);
local _thirstVal = 1 - (dayz_thirst / SleepWater);
local _tempVal = 1 - ((dayz_temperatur - dayz_temperaturmin)/(dayz_temperaturmax - dayz_temperaturmin)); // Normalise to [0,1]
local _bloodVal = r_player_blood / r_player_bloodTotal;
local _combatVal = if (player getVariable["combattimeout",0] >= diag_tickTime) then {0} else {1};
local _combatVal = if ((player getVariable["combatTimeout",0] >= diag_tickTime) || (player getVariable["combatNoTimeout", 0] == 1)) then {0} else {1};
local _ctrlBloodOuter = 0;
local _ctrlFoodBorder = 0;
local _ctrlThirstBorder = 0;

View File

@@ -260,12 +260,6 @@ while {1 == 1} do {
pickupInit = true;
};
_startcombattimer = player getVariable["startcombattimer", 0];
if (_startcombattimer == 1) then { //Do not use _PlayerNearby it makes building impossible, this is handled in player_onPause.sqf just fine
[player,true] call fnc_setCombat;
player setVariable["startcombattimer", 0, false];
};
uiSleep 2;
_myPos = player getVariable["lastPos",[]];

View File

@@ -9,7 +9,7 @@ sched_playerActions = {
};
//combat check
if ((player getVariable ["combattimeout",0] < diag_tickTime) && {player getVariable ["inCombat",false]} && {player getVariable["startcombattimer", 0] == 0}) then {
if ((player getVariable ["combatTimeout",0] < diag_tickTime) && {player getVariable ["inCombat",false]} && {player getVariable["combatNoTimeout", 0] == 0}) then {
player setVariable ["inCombat", false, true];
};

View File

@@ -19,7 +19,7 @@ sched_throwable = {
sched_throwable_prevmuzz = currentMuzzle player;
sched_throwable_time = diag_tickTime+11;
};
if (((player getVariable["combattimeout", diag_tickTime])-diag_tickTime)>27) then {
if (((player getVariable["combatTimeout", diag_tickTime])-diag_tickTime)>27) then {
sched_throwable_time = diag_tickTime+21;
};
};