From ac10daeb4d7e4af6da2163ed90edaf0760a967a2 Mon Sep 17 00:00:00 2001 From: ebayShopper Date: Sat, 25 Nov 2017 14:52:06 -0500 Subject: [PATCH] Update humanity morphing Vanilla commits: https://github.com/DayZMod/DayZ/commit/33d4165e64fde04bf43628069e2d006b45548b38 https://github.com/DayZMod/DayZ/commit/6674be6d5faabc37699142d93e20e08527dda0c3 https://github.com/DayZMod/DayZ/commit/f4d18a6fefd231cef88d39e5b91e4827e09a7a28 --- .../compile/player_humanityChange.sqf | 63 +++---------------- .../compile/player_humanityCheck.sqf | 50 +++++++++++++++ .../compile/player_humanityMorph.sqf | 4 +- SQF/dayz_code/init/compiles.sqf | 3 +- SQF/dayz_code/init/variables.sqf | 1 + .../system/scheduler/sched_humanityChange.sqf | 18 ++++++ SQF/dayz_code/system/scheduler/sched_init.sqf | 2 + 7 files changed, 86 insertions(+), 55 deletions(-) create mode 100644 SQF/dayz_code/compile/player_humanityCheck.sqf create mode 100644 SQF/dayz_code/system/scheduler/sched_humanityChange.sqf diff --git a/SQF/dayz_code/compile/player_humanityChange.sqf b/SQF/dayz_code/compile/player_humanityChange.sqf index 71bc68260..f0f149416 100644 --- a/SQF/dayz_code/compile/player_humanityChange.sqf +++ b/SQF/dayz_code/compile/player_humanityChange.sqf @@ -1,4 +1,8 @@ -private ["_change","_wait","_humanity","_model","_isMen","_isMenH","_isMenB","_isWomen","_isWomenH","_isWomenB"]; +private ["_change","_wait","_humanity"]; +/* + Set humanity chanages and sets freeTarget(openTarget) +*/ + _change = _this select 0; _wait = _this select 1; @@ -7,7 +11,6 @@ player setVariable["humanity",_humanity,true]; if (_change < 0) then { //non-bandit player can be "punished" in next "_wait" seconds w/o loosing humanity if ((_humanity > -2000) and (_wait > 0)) then { -// player setVariable ["freeTarget",true,true]; player setVariable ["FTcounter",((player getVariable ["FTcounter",0]) + _wait)]; [_wait] spawn { private ["_endtime","_wait"]; @@ -17,59 +20,13 @@ if (_change < 0) then { //non-bandit player can be "punished" in next "_wait" se player setVariable ["FTcounter",((player getVariable ["FTcounter",0]) - _wait)]; if ((player getVariable ["FTcounter",0]) <= 0) then { player setVariable ["FTcounter",0]; -// player setVariable ["freeTarget",false,true]; }; }; }; }; -/* Humanity morphing disabled on Epoch to avoid loss of purchased clothing -//add humanity cap both ways -//if (_humanity < 500000) then { player setVariable["humanity",-500000,true]; }; //Hive adds/removes diffrence -//if (_humanity > 500000) then { player setVariable["humanity",500000,true]; }; //Hive adds/removes diffrence - -_model = typeOf player; - -//if model will not be changed by humanity -if !(_model in ["Survivor1_DZ","Survivor2_DZ","Survivor3_DZ","SurvivorW2_DZ","SurvivorW3_DZ","Bandit1_DZ","BanditW1_DZ"]) exitWith {}; -//don't switch model when in a vehicle (ejects player) -if (vehicle player != player) exitWith {}; - -//Not sure if this will work needs testing -_isMen = _model == "Survivor1_DZ" || _model == "Survivor2_DZ"; -_isMenH = _model == "Survivor3_DZ"; -_isMenB = _model == "Bandit1_DZ"; -_isWomen = _model == "SurvivorW2_DZ"; -_isWomenH = _model == "SurvivorW3_DZ"; //TODO -_isWomenB = _model == "BanditW1_DZ"; - -// Bandit -if (_humanity <= -2000) then { - if (_isMen || _isMenH) then { - [dayz_playerUID,dayz_characterID,"Bandit1_DZ"] spawn player_humanityMorph; - }; - if (_isWomen || _isWomenH) then { - [dayz_playerUID,dayz_characterID,"BanditW1_DZ"] spawn player_humanityMorph; - }; -}; -//Survivor -if (_humanity > -2000 && _humanity <= 5000) then { - if (_isMenH || _isMenB) then { - [dayz_playerUID,dayz_characterID,"Survivor2_DZ"] spawn player_humanityMorph; - }; - if (_isWomenH || _isWomenB) then { - [dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph; - }; -}; - -// Hero -if (_humanity > 5000) then { - if (_isMen || _isMenB) then { - [dayz_playerUID,dayz_characterID,"Survivor3_DZ"] spawn player_humanityMorph; - }; - if (_isWomenB) then { - [dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph; - }; -}; - -*/ \ No newline at end of file +/* + Should block damageHandler running humanityCheck(Skin change check), allow all other humanity events to run humanityCheck(Skin change check) +*/ +//if ((_wait == 0) and (vehicle player == player)) then { [_humanity] call player_humanityCheck; }; +//Humanity morphing disabled on Epoch to avoid loss of purchased clothing \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_humanityCheck.sqf b/SQF/dayz_code/compile/player_humanityCheck.sqf new file mode 100644 index 000000000..29c762087 --- /dev/null +++ b/SQF/dayz_code/compile/player_humanityCheck.sqf @@ -0,0 +1,50 @@ +private ["_humanity","_model","_isMen","_isMenH","_isMenB","_isWomen","_isWomenH","_isWomenB"]; + +_humanity = _this select 0; + +//add humanity cap both ways +//if (_humanity < 500000) then { player setVariable["humanity",-500000,true]; }; //Hive adds/removes diffrence +//if (_humanity > 500000) then { player setVariable["humanity",500000,true]; }; //Hive adds/removes diffrence + +_model = typeOf player; + +//if model will not be changed by humanity +if !(_model in ["Survivor1_DZ","Survivor2_DZ","Survivor3_DZ","SurvivorW2_DZ","SurvivorW3_DZ","Bandit1_DZ","BanditW1_DZ"]) exitWith {}; + +//Not sure if this will work needs testing +_isMen = _model == "Survivor1_DZ" || _model == "Survivor2_DZ"; +_isMenH = _model == "Survivor3_DZ"; +_isMenB = _model == "Bandit1_DZ"; +_isWomen = _model == "SurvivorW2_DZ"; +_isWomenH = _model == "SurvivorW3_DZ"; //TODO +_isWomenB = _model == "BanditW1_DZ"; + +// Bandit +if (_humanity <= -2000) then { + if (_isMen || _isMenH) then { + [dayz_playerUID,dayz_characterID,"Bandit1_DZ"] spawn player_humanityMorph; + }; + if (_isWomen || _isWomenH) then { + [dayz_playerUID,dayz_characterID,"BanditW1_DZ"] spawn player_humanityMorph; + }; +}; + +//Survivor +if (_humanity > -2000 && _humanity <= 5000) then { + if (_isMenH || _isMenB) then { + [dayz_playerUID,dayz_characterID,"Survivor2_DZ"] spawn player_humanityMorph; + }; + if (_isWomenH || _isWomenB) then { + [dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph; + }; +}; + +// Hero +if (_humanity > 5000) then { + if (_isMen || _isMenB) then { + [dayz_playerUID,dayz_characterID,"Survivor3_DZ"] spawn player_humanityMorph; + }; + if (_isWomenB) then { + [dayz_playerUID,dayz_characterID,"SurvivorW2_DZ"] spawn player_humanityMorph; + }; +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_humanityMorph.sqf b/SQF/dayz_code/compile/player_humanityMorph.sqf index 2e5cda575..02376cff9 100644 --- a/SQF/dayz_code/compile/player_humanityMorph.sqf +++ b/SQF/dayz_code/compile/player_humanityMorph.sqf @@ -2,8 +2,10 @@ private ["_charID","_newmodel","_old","_humanity","_medical","_worldspace","_zom //_playerUID = _this select 0; _charID = _this select 1; _model = _this select 2; -_old = player; +if (typeOf player == _model) exitWith {}; + +_old = player; _old removeAllEventHandlers "FiredNear"; _old removeAllEventHandlers "HandleDamage"; _old removeAllEventHandlers "Killed"; diff --git a/SQF/dayz_code/init/compiles.sqf b/SQF/dayz_code/init/compiles.sqf index e1d6e42b6..3b9abc0d6 100644 --- a/SQF/dayz_code/init/compiles.sqf +++ b/SQF/dayz_code/init/compiles.sqf @@ -652,7 +652,8 @@ player_medTransfuse = compile preprocessFileLineNumbers "\z\addons\dayz_code\med player_medMorphine = compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\publicEH\medMorphine.sqf"; player_medPainkiller = compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\publicEH\medPainkiller.sqf"; player_medAntiBiotics = compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\publicEH\medAntibiotics.sqf"; -player_humanityChange = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_humanityChange.sqf"; +player_humanityChange = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_humanityChange.sqf"; //New +player_humanityCheck = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_humanityCheck.sqf"; //Old player_projectileNear = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\player_projectileNear.sqf"; player_bloodCalc = compile preprocessFileLineNumbers "\z\addons\dayz_code\medical\bloodCalc.sqf"; fn_selectRandomLocation = compile preprocessFileLineNumbers "\z\addons\dayz_code\compile\fn_selectRandomLocation.sqf"; diff --git a/SQF/dayz_code/init/variables.sqf b/SQF/dayz_code/init/variables.sqf index c1ee3b203..417c98891 100644 --- a/SQF/dayz_code/init/variables.sqf +++ b/SQF/dayz_code/init/variables.sqf @@ -670,6 +670,7 @@ if (!isDedicated) then { dayz_hitByTime = 0; skipGearSound = false; TimeOutDisplayed = false; + playerHumanityCHK = 0; voice_actions = ["voiceOverNet","PushToTalk","PushToTalkAll","PushToTalkCommand","PushToTalkDirect","PushToTalkGroup","PushToTalkSide","PushToTalkVehicle"]; // EPOCH ADDITIONS diff --git a/SQF/dayz_code/system/scheduler/sched_humanityChange.sqf b/SQF/dayz_code/system/scheduler/sched_humanityChange.sqf new file mode 100644 index 000000000..11e1b7dd1 --- /dev/null +++ b/SQF/dayz_code/system/scheduler/sched_humanityChange.sqf @@ -0,0 +1,18 @@ +#include "scheduler.hpp" + +sched_humanityChange = { + HIDE_FSM_VARS + + _startcombattimer = player getVariable["startcombattimer", 0]; + //If player is not in combat and humanity differs from the last time it ran run humanityCheck(skin change check) + if (_startcombattimer == 0) then { + _playerHumanity = player getVariable ["humanity",0]; + + if ((_playerHumanity != playerHumanityCHK) and (vehicle player == player)) then { + [_playerHumanity] call player_humanityCheck; + playerHumanityCHK = _playerHumanity; + }; + }; + + objNull +}; \ No newline at end of file diff --git a/SQF/dayz_code/system/scheduler/sched_init.sqf b/SQF/dayz_code/system/scheduler/sched_init.sqf index 4ceed37c8..648a4d29c 100644 --- a/SQF/dayz_code/system/scheduler/sched_init.sqf +++ b/SQF/dayz_code/system/scheduler/sched_init.sqf @@ -14,6 +14,7 @@ call compile preprocessFileLineNumbers (_base+"sched_medical.sqf"); //call compile preprocessFileLineNumbers (_base+"sched_achievement.sqf"); call compile preprocessFileLineNumbers (_base+"sched_gui.sqf"); call compile preprocessFileLineNumbers (_base+"sched_buildingBubble.sqf"); +//call compile preprocessFileLineNumbers (_base+"sched_humanityChange.sqf"); if (dayz_antihack == 1) then { call compile preprocessFileLineNumbers (_base+"sched_security.sqf"); @@ -39,6 +40,7 @@ if (count _list == 0) then { [ 6, 24.18, sched_spawnCheck, sched_spawnCheck_init ], [ 1, 0.63, sched_throwable, sched_throwable_init ], [ 1, 0.33, sched_medical, sched_medical_init ], + //[ 15, 3, sched_humanityChange ], //Humanity morphing disabled on Epoch to avoid loss of purchased clothing //[ 3, 2.70, sched_achievement, sched_achievement_init ], [ 4, 2.38, sched_bloodStains, sched_bloodStains_init ], [ 60, 10.44, sched_animals ],