NyxGrimlock

player_updateGUI.sqf

Aug 24th, 2014
235
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.56 KB | None | 0 0
  1. 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"];
  2. disableSerialization;
  3.  
  4. _foodVal = 1 - (dayz_hunger / SleepFood);
  5. _thirstVal = 1 - (dayz_thirst / SleepWater);
  6. _tempVal = 1 - ((dayz_temperatur - dayz_temperaturmin)/(dayz_temperaturmax - dayz_temperaturmin)); // Normalise to [0,1]
  7. _combatVal = 1 - dayz_combat; // May change later to be a range of red/green to loosely indicate 'time left in combat'
  8.  
  9. if (uiNamespace getVariable ["DZ_displayUI", 0] == 1) exitWith {
  10. _array = [_foodVal,_thirstVal];
  11. _array
  12. };
  13.  
  14. _display = uiNamespace getVariable 'DAYZ_GUI_display';
  15.  
  16. _ctrlBlood = _display displayCtrl 1300;
  17. _ctrlBleed = _display displayCtrl 1303;
  18. _bloodVal = r_player_blood / r_player_bloodTotal;
  19. _ctrlFood = _display displayCtrl 1301;
  20. _ctrlThirst = _display displayCtrl 1302;
  21. _ctrlTemp = _display displayCtrl 1306; //TeeChange
  22. _ctrlEar = _display displayCtrl 1304;
  23. _ctrlEye = _display displayCtrl 1305;
  24. //_ctrlHumanity = _display displayCtrl 1207;
  25. _ctrlCombat = _display displayCtrl 1307;
  26. _ctrlFracture = _display displayCtrl 1203;
  27.  
  28. //Food/Water/Blood
  29. _ctrlBlood ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_bloodVal))),(Dayz_GUI_G * _bloodVal),(Dayz_GUI_B * _bloodVal), 0.5];
  30. _ctrlFood ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_foodVal))),(Dayz_GUI_G * _foodVal),(Dayz_GUI_B * _foodVal), 0.5];
  31. _ctrlThirst ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_thirstVal))),(Dayz_GUI_G * _thirstVal),(Dayz_GUI_B * _thirstVal), 0.5];
  32. _ctrlTemp ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_tempVal))), (Dayz_GUI_G * _tempVal), _tempVal, 0.5]; // Color ranges from iceblue (cold) to red (hot)
  33. _ctrlCombat ctrlSetTextColor [(Dayz_GUI_R + (0.3 * (1-_combatVal))),(Dayz_GUI_G * _combatVal),(Dayz_GUI_B * _combatVal), 0.5];
  34.  
  35. /*
  36. Blood: round((r_player_blood / 2) / 1000) = _bloodLvl (6 = full, 1 = empty)
  37. Thirst: round(_thirstVal / 0.25) = _thirstLvl (4 = full, 0 = empty)
  38. Hunger: round(_foodVal / 0.25) = _foodLvl (4 = full, 0 = empty)
  39. Temp: round(dayz_temperatur) = tempLvl (>= 36 = full <= 28 = empty)
  40. */
  41.  
  42. _blood = "";
  43. _thirst = "";
  44. _food = "";
  45. _temp = "";
  46. _tempImg = 0;
  47. _bloodLvl = round((r_player_blood / 2) / 1000);
  48. _thirstLvl = round(_thirstVal / 0.25);
  49. _foodLvl = round(_foodVal / 0.25);
  50. _tempLvl = round(dayz_temperatur);
  51.  
  52. /*
  53. diag_log format["DEBUG: bloodlvl: %1 r_player_blood: %2 bloodval: %3",_bloodLvl, r_player_blood, _bloodVal];
  54. diag_log format["DEBUG: thirstlvl: %1 dayz_thirst: %2 thirstval: %3",_thirstLvl, dayz_thirst, _thirstVal];
  55. diag_log format["DEBUG: foodlvl: %1 dayz_hunger: %2 foodval: %3",_foodLvl, dayz_hunger, _foodVal];
  56. diag_log format["DEBUG: templvl: %1 dayz_temperatur: %2 tempval: %3",_tempLvl, dayz_temperatur, _tempVal];
  57. */
  58.  
  59. if (_bloodLvl <= 0) then {
  60. _blood = "\z\addons\dayz_code\gui\status_blood_inside_1_ca.paa";
  61. } else {
  62. _blood = "\z\addons\dayz_code\gui\status_blood_inside_" + str(_bloodLvl) + "_ca.paa";
  63. };
  64.  
  65. if (_thirstLvl < 0) then { _thirstLvl = 0 };
  66. _thirst = "\z\addons\dayz_code\gui\status_thirst_inside_" + str(_thirstLvl) + "_ca.paa";
  67.  
  68. if (_foodLvl < 0) then { _foodLvl = 0 };
  69. _food = "\z\addons\dayz_code\gui\status_food_inside_" + str(_foodLvl) + "_ca.paa";
  70.  
  71. if ( _tempLvl >= 36 ) then { _tempImg = 4 };
  72. if ( _tempLvl > 33 && _tempLvl < 36 ) then { _tempImg = 3 };
  73. if ( _tempLvl >= 30 && _tempLvl <= 33 ) then { _tempImg = 2 };
  74. if ( _tempLvl > 28 && _tempLvl < 30 ) then { _tempImg = 1 };
  75. if ( _tempLvl <= 28 ) then { _tempImg = 0 };
  76.  
  77. _temp = "\z\addons\dayz_code\gui\status_temp_" + str(_tempImg) + "_ca.paa";
  78.  
  79. _ctrlBlood ctrlSetText _blood;
  80. _ctrlThirst ctrlSetText _thirst;
  81. _ctrlFood ctrlSetText _food;
  82. _ctrlTemp ctrlSetText _temp;
  83.  
  84. /*
  85. Visual:
  86. */
  87. _visualtext = "";
  88. _visual = (round((dayz_disVisual / 100) * 4)) min 5;
  89. if (_visual > 0) then {_visualtext = "\z\addons\dayz_code\gui\val_" + str(_visual) + "_ca.paa"};
  90. _ctrlEye ctrlSetText _visualtext;
  91.  
  92. /*
  93. Audible:
  94. */
  95. _audibletext = "";
  96. _audible = (round((dayz_disAudial / 50) * 4)) min 5;
  97. if (_audible > 0) then {_audibletext = "\z\addons\dayz_code\gui\val_" + str(_audible) + "_ca.paa"};
  98. _ctrlEar ctrlSetText _audibletext;
  99.  
  100. /*
  101. Fracture:
  102. */
  103. if (!canStand player) then {
  104. if (!(ctrlShown _ctrlFracture)) then {
  105. r_fracture_legs = true;
  106. _ctrlFracture ctrlShow true;
  107. };
  108. };
  109.  
  110. /*
  111. Flashing:
  112. */
  113. if (_combatVal == 0) then {
  114. _ctrlCombat call player_guiControlFlash;
  115. };
  116.  
  117. if (_bloodVal < 0.2) then {
  118. _ctrlBlood call player_guiControlFlash;
  119. };
  120.  
  121. if (_thirstVal < 0.2) then {
  122. _ctrlThirst call player_guiControlFlash;
  123. };
  124.  
  125. if (_foodVal < 0.2) then {
  126. _ctrlFood call player_guiControlFlash;
  127. };
  128.  
  129. if (_tempVal > 0.8) then { //TeeChange
  130. _ctrlTemp call player_guiControlFlash;
  131. } else {
  132. _ctrlTemp ctrlShow true;
  133. };
  134.  
  135. if (r_player_injured) then {
  136. _ctrlBleed call player_guiControlFlash;
  137. };
  138.  
  139. /*
  140. Opt-in tag system with friend tagging
  141. */
  142. _string = "";
  143. _humanityTarget = cursorTarget;
  144. if (!isNull _humanityTarget && isPlayer _humanityTarget && alive _humanityTarget) then {
  145.  
  146. _distance = player distance _humanityTarget;
  147.  
  148. if (_distance < DZE_HumanityTargetDistance) then {
  149.  
  150. _size = (1-(floor(_distance/5)*0.1)) max 0.1;
  151.  
  152. // Display name if player opt-in || if friend
  153. _friendlies = player getVariable ["friendlies", []];
  154. _charID = player getVariable ["CharacterID", "0"];
  155.  
  156. _rcharID = _humanityTarget getVariable ["CharacterID", "0"];
  157. _rfriendlies = _humanityTarget getVariable ["friendlies", []];
  158. _rfriendlyTo = _humanityTarget getVariable ["friendlyTo", []];
  159.  
  160. if ((_rcharID in _friendlies) && (_charID in _rfriendlies)) then {
  161.  
  162. if !(_charID in _rfriendlyTo) then {
  163. // diag_log format["IS FRIENDLY: %1", _player];
  164. _rfriendlyTo set [count _rfriendlyTo, _charID];
  165. _humanityTarget setVariable ["friendlyTo", _rfriendlyTo, true];
  166. };
  167.  
  168. // <br /><t %2 align='center' size='0.7'>Humanity: %3</t>
  169.  
  170. _color = "color='#339933'";
  171. _string = format["<t %2 align='center' size='%3'>%1</t>",(name _humanityTarget),_color,_size];
  172.  
  173. } else {
  174.  
  175. // Humanity checks
  176. _humanity = _humanityTarget getVariable ["humanity",0];
  177.  
  178. _color = "color='#ffffff'";
  179. if(_humanity < -5000) then {
  180. _color = "color='#ff0000'";
  181. } else {
  182. if(_humanity > 5000) then {
  183. _color = "color='#3333ff'";
  184. };
  185. };
  186. if((_humanityTarget getVariable ["DZE_display_name", false]) || (DZE_ForceNameTagsInTrader && isInTraderCity)) then {
  187. _string = format["<t %2 align='center' size='%3'>%1</t>",(name _humanityTarget),_color,_size];
  188. };
  189. };
  190. };
  191. };
  192.  
  193. // update gui if changed
  194. if (dayz_humanitytarget != _string) then {
  195. _targetControl = _display displayCtrl 1199;
  196. _targetControl ctrlSetStructuredText (parseText _string);
  197. dayz_humanitytarget = _string;
  198. };
  199.  
  200.  
  201. private ["_wealth"];
  202. _wealth = player getVariable ["wealth", 0];
  203. _wealth = if (typeName _wealth == "STRING") then { parseNumber _wealth } else { _wealth };
  204. _wealth = [_wealth] call BIS_fnc_numberText;
  205. _wealth = format["<t size='1' align='right' valign='middle'><img image='addons\playerhud\icons\coins.paa' /> %1</t>", _wealth];
  206. ((uiNamespace getVariable "MTraderwealth") displayCtrl 1) ctrlSetStructuredText parseText _wealth;
  207.  
  208. _array = [_foodVal,_thirstVal];
  209. _array
Advertisement
Add Comment
Please, Sign In to add comment