Advertisement
DeTrix

player_updateGui.sqf

Apr 20th, 2014
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.42 KB | None | 0 0
  1. private ["_found","_display","_ctrlBlood","_ctrlBleed","_bloodVal","_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"];
  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 and _tempLvl < 36 ) then { _tempImg = 3 };
  73. if ( _tempLvl >= 30 and _tempLvl <= 33 ) then { _tempImg = 2 };
  74. if ( _tempLvl > 28 and _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. _targetControl = _display displayCtrl 1199;
  143. _string = "";
  144. _humanityTarget = cursorTarget;
  145. if (!isNull _humanityTarget and isPlayer _humanityTarget and alive _humanityTarget) then {
  146.  
  147. _distance = (player distance _humanityTarget);
  148.  
  149. if (_distance < DZE_HumanityTargetDistance) then {
  150.  
  151. _size = (1-(floor(_distance/5)*0.1)) max 0.1;
  152.  
  153. // Display name if player opt-in or if friend
  154. _friendlies = player getVariable ["friendlies", []];
  155. _charID = getPlayerUID player;
  156. _found=[_charID,"AX"] call KRON_StrInStr;
  157. if (_found) then {
  158. _charID=[_charID] call KRON_convertPlayerUID;
  159. };
  160.  
  161. _rcharID = getPlayerUID _humanityTarget;
  162. _found=[_rcharID,"AX"] call KRON_StrInStr;
  163. if (_found) then {
  164. _rcharID=[_rcharID] call KRON_convertPlayerUID;
  165. };
  166. _rfriendlies = _humanityTarget getVariable ["friendlies", []];
  167. _rfriendlyTo = _humanityTarget getVariable ["friendlyTo", []];
  168.  
  169. if ((_rcharID in _friendlies) and (_charID in _rfriendlies)) then {
  170.  
  171. if (!(_charID in _rfriendlyTo)) then {
  172.  
  173. // diag_log format["IS FRIENDLY: %1", _player];
  174. _rfriendlyTo set [count _rfriendlyTo, _charID];
  175. _humanityTarget setVariable ["friendlyTo", _rfriendlyTo, true];
  176.  
  177. // titleText [format[(localize "STR_EPOCH_ACTIONS_17"), (name _humanityTarget)], "PLAIN DOWN"];
  178.  
  179. };
  180.  
  181. // <br /><t %2 align='center' size='0.7'>Humanity: %3</t>
  182.  
  183. _color = "color='#339933'";
  184. _string = format["<t %2 align='center' size='%3'>%1</t>",(name _humanityTarget),_color,_size];
  185.  
  186. } else {
  187.  
  188. // Humanity checks
  189. _humanity = _humanityTarget getVariable ["humanity",0];
  190.  
  191. _color = "color='#ffffff'";
  192. if(_humanity < -5000) then {
  193. _color = "color='#ff0000'";
  194. } else {
  195. if(_humanity > 5000) then {
  196. _color = "color='#3333ff'";
  197. };
  198. };
  199. if(_humanityTarget getVariable ["DZE_display_name", false]) then {
  200. _string = format["<t %2 align='center' size='%3'>%1</t>",(name _humanityTarget),_color,_size];
  201. };
  202. };
  203. };
  204. };
  205.  
  206. // update gui if changed
  207. if (dayz_humanitytarget != _string) then {
  208. _targetControl ctrlSetStructuredText (parseText _string);
  209. dayz_humanitytarget = _string;
  210. };
  211.  
  212. _array = [_foodVal,_thirstVal];
  213. _array
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement