From 919e65d19e616d403261e5307fb6b2c19e24d717 Mon Sep 17 00:00:00 2001 From: "Skaronator.com" Date: Wed, 18 Jun 2014 14:27:54 +0200 Subject: [PATCH] Cleanup code #1320 --- SQF/dayz_code/actions/player_build.sqf | 4 +-- SQF/dayz_code/actions/player_tagFriendly.sqf | 27 ++++++++++---------- SQF/dayz_code/compile/player_updateGui.sqf | 22 ++++++---------- 3 files changed, 24 insertions(+), 29 deletions(-) diff --git a/SQF/dayz_code/actions/player_build.sqf b/SQF/dayz_code/actions/player_build.sqf index c8d0f388b..c393f005f 100644 --- a/SQF/dayz_code/actions/player_build.sqf +++ b/SQF/dayz_code/actions/player_build.sqf @@ -153,7 +153,7 @@ if(_IsNearPlot == 0) then { _nearestPole = _findNearestPole select 0; // Find owner - _ownerID = _nearestPole getVariable["CharacterID","0"]; + _ownerID = _nearestPole getVariable ["CharacterID","0"]; // diag_log format["DEBUG BUILDING: %1 = %2", dayz_characterID, _ownerID]; @@ -183,7 +183,7 @@ _missing = ""; _hasrequireditem = true; { _hastoolweapon = _x in weapons player; - if(!_hastoolweapon) exitWith { _hasrequireditem = false; _missing = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); } + if(!_hastoolweapon) exitWith { _hasrequireditem = false; _missing = getText (configFile >> "cfgWeapons" >> _x >> "displayName"); }; } count _require; _hasbuilditem = _this in magazines player; diff --git a/SQF/dayz_code/actions/player_tagFriendly.sqf b/SQF/dayz_code/actions/player_tagFriendly.sqf index 4205c6a7b..80aad571e 100644 --- a/SQF/dayz_code/actions/player_tagFriendly.sqf +++ b/SQF/dayz_code/actions/player_tagFriendly.sqf @@ -5,18 +5,19 @@ _caller = _this select 1; call fnc_usec_medic_removeActions; r_action = false; -_callerID = _caller getVariable "CharacterID"; -_targetID = _target getVariable "CharacterID"; +_callerID = _caller getVariable ["CharacterID", "0"]; +_targetID = _target getVariable ["CharacterID", "0"]; +if ((_callerID != 0) && (_callerID != 0)) then { + _friendlies = _caller getVariable ["friendlies", []]; + _friendlies set [count _friendlies, _targetID]; + _caller setVariable ["friendlies", _friendlies, true]; -_friendlies = _caller getVariable ["friendlies", []]; -_friendlies set [count _friendlies, _targetID]; -_caller setVariable ["friendlies", _friendlies, true]; + _rfriendlies = _target getVariable ["friendlies", []]; -_rfriendlies = _target getVariable ["friendlies", []]; - -if !(_callerID in _rfriendlies) then { - titleText [(localize "STR_EPOCH_ACTIONS_8"), "PLAIN DOWN"]; //To Caller - /* PVS/PVC - Skaronator */ - PVDZE_send = [_target,"tagFriendly",[_target]]; //To Target - publicVariableServer "PVDZE_send"; -}; + if !(_callerID in _rfriendlies) then { + titleText [(localize "STR_EPOCH_ACTIONS_8"), "PLAIN DOWN"]; //To Caller + /* PVS/PVC - Skaronator */ + PVDZE_send = [_target,"tagFriendly",[_target]]; //To Target + publicVariableServer "PVDZE_send"; + }; +}; \ No newline at end of file diff --git a/SQF/dayz_code/compile/player_updateGui.sqf b/SQF/dayz_code/compile/player_updateGui.sqf index 7dcd68766..aef15cdac 100644 --- a/SQF/dayz_code/compile/player_updateGui.sqf +++ b/SQF/dayz_code/compile/player_updateGui.sqf @@ -1,4 +1,4 @@ -private ["_display","_ctrlBlood","_ctrlBleed","_bloodVal","_humanityName","_ctrlFood","_ctrlThirst","_thirstVal","_foodVal","_ctrlTemp","_tempVal","_combatVal","_array","_ctrlEar","_ctrlEye","_ctrlCombat","_ctrlFracture","_visualText","_visual","_audibleText","_audible","_blood","_thirstLvl","_foodLvl","_tempImg","_thirst","_food","_temp","_bloodLvl","_tempLvl","_color","_string","_humanity","_size","_friendlies","_charID","_rcharID","_rfriendlies","_rfriendlyTo","_distance","_targetControl","_humanityTarget"]; +private ["_display","_ctrlBlood","_ctrlBleed","_bloodVal","_humanityName","_ctrlFood","_ctrlThirst","_thirstVal","_foodVal","_ctrlTemp","_tempVal","_combatVal","_array","_ctrlEar","_ctrlEye","_ctrlCombat","_ctrlFracture","_visualText","_visual","_audibleText","_audible","_blood","_thirstLvl","_foodLvl","_tempImg","_thirst","_food","_temp","_bloodLvl","_tempLvl","_color","_string","_humanity","_size","_friendlies","_charID","_rcharID","_rfriendlies","_rfriendlyTo","_distance","_targetControl"]; disableSerialization; _foodVal = 1 - (dayz_hunger / SleepFood); @@ -6,7 +6,7 @@ _thirstVal = 1 - (dayz_thirst / SleepWater); _tempVal = 1 - ((dayz_temperatur - dayz_temperaturmin)/(dayz_temperaturmax - dayz_temperaturmin)); // Normalise to [0,1] _combatVal = 1 - dayz_combat; // May change later to be a range of red/green to loosely indicate 'time left in combat' -if (uiNamespace getVariable ['DZ_displayUI', 0] == 1) exitWith { +if (uiNamespace getVariable ["DZ_displayUI", 0] == 1) exitWith { _array = [_foodVal,_thirstVal]; _array }; @@ -139,12 +139,11 @@ if (r_player_injured) then { /* Opt-in tag system with friend tagging */ -_targetControl = _display displayCtrl 1199; _string = ""; _humanityTarget = cursorTarget; if (!isNull _humanityTarget && isPlayer _humanityTarget && alive _humanityTarget) then { - _distance = (player distance _humanityTarget); + _distance = player distance _humanityTarget; if (_distance < DZE_HumanityTargetDistance) then { @@ -157,24 +156,19 @@ if (!isNull _humanityTarget && isPlayer _humanityTarget && alive _humanityTarget _rcharID = _humanityTarget getVariable ["CharacterID", "0"]; _rfriendlies = _humanityTarget getVariable ["friendlies", []]; _rfriendlyTo = _humanityTarget getVariable ["friendlyTo", []]; - + if ((_rcharID in _friendlies) && (_charID in _rfriendlies)) then { - if (!(_charID in _rfriendlyTo)) then { - + if !(_charID in _rfriendlyTo) then { // diag_log format["IS FRIENDLY: %1", _player]; _rfriendlyTo set [count _rfriendlyTo, _charID]; _humanityTarget setVariable ["friendlyTo", _rfriendlyTo, true]; - - // titleText [format[(localize "STR_EPOCH_ACTIONS_17"), (name _humanityTarget)], "PLAIN DOWN"]; - }; //
Humanity: %3 _color = "color='#339933'"; - _humanityName = if (alive _humanityTarget) then {name _humanityTarget; } else { "Dead Player";}; - _string = format["%1",_humanityName,_color,_size]; + _string = format["%1",(name _humanityTarget),_color,_size]; } else { @@ -190,8 +184,7 @@ if (!isNull _humanityTarget && isPlayer _humanityTarget && alive _humanityTarget }; }; if((_humanityTarget getVariable ["DZE_display_name", false]) || (DZE_ForceNameTagsInTrader && isInTraderCity)) then { - _humanityName = if (alive _humanityTarget) then {name _humanityTarget; } else { "Dead Player";}; - _string = format["%1",_humanityName,_color,_size]; + _string = format["%1",(name _humanityTarget),_color,_size]; }; }; }; @@ -199,6 +192,7 @@ if (!isNull _humanityTarget && isPlayer _humanityTarget && alive _humanityTarget // update gui if changed if (dayz_humanitytarget != _string) then { + _targetControl = _display displayCtrl 1199; _targetControl ctrlSetStructuredText (parseText _string); dayz_humanitytarget = _string; };