Advertisement
Guest User

Untitled

a guest
Nov 9th, 2013
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.41 KB | None | 0 0
  1. /*
  2. [_object,_type] spawn server_updateObject;
  3. */
  4. private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk"];
  5.  
  6. #include "\z\addons\dayz_server\compile\server_toggle_debug.hpp"
  7.  
  8. _object = _this select 0;
  9. _type = _this select 1;
  10. _forced = false;
  11. if (count _this > 2) then {
  12. _forced = _this select 2;
  13. };
  14. _parachuteWest = typeOf _object == "ParachuteWest";
  15. _isNotOk = false;
  16.  
  17. _objectID = "0";
  18. _uid = "0";
  19.  
  20. if (!((isNil "_object") OR {(isNull _object)})) then {
  21. _objectID = _object getVariable ["ObjectID","0"];
  22. _uid = _object getVariable ["ObjectUID","0"];
  23. };
  24.  
  25. if ((typeName _objectID != "string") || (typeName _uid != "string")) then
  26. {
  27. #ifdef OBJECT_DEBUG
  28. diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
  29. #endif
  30. //force fail
  31. _objectID = "0";
  32. _uid = "0";
  33. };
  34.  
  35. if (_object getVariable ["Sarge",0] != 1) exitWith {};
  36.  
  37. if (!_parachuteWest) then {
  38. if ((typeOf _object) in SafeObjects) then {
  39.  
  40. } else {
  41. if (_objectID == "0" && _uid == "0") then
  42. {
  43. _object_position = getPosATL _object;
  44. #ifdef OBJECT_DEBUG
  45. diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",
  46. typeOf _object,
  47. _object_position select 0,
  48. _object_position select 1,
  49. _object_position select 2]);
  50. #endif
  51. _isNotOk = true;
  52. };
  53. };
  54. };
  55.  
  56. if (_isNotOk) exitWith { deleteVehicle _object; };
  57.  
  58. _lastUpdate = _object getVariable ["lastUpdate",diag_tickTime];
  59. _needUpdate = _object in needUpdate_objects;
  60.  
  61. // TODO ----------------------
  62. _object_position = {
  63. private["_position","_worldspace","_fuel","_key"];
  64. _position = getPosATL _object;
  65. _worldspace = [
  66. round(direction _object),
  67. _position
  68. ];
  69. _fuel = 0;
  70. if (_object isKindOf "AllVehicles") then {
  71. _fuel = fuel _object;
  72. };
  73. _key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
  74. #ifdef OBJECT_DEBUG
  75. diag_log ("HIVE: WRITE: "+ str(_key));
  76. #endif
  77.  
  78. _key call server_hiveWrite;
  79. };
  80.  
  81. _object_inventory = {
  82. private["_inventory","_previous","_key"];
  83. if (_object isKindOf "TrapItems") then {
  84. _inventory = [_object getVariable ["armed", false]];
  85. } else {
  86. _inventory = [
  87. getWeaponCargo _object,
  88. getMagazineCargo _object,
  89. getBackpackCargo _object
  90. ];
  91. };
  92. _previous = str(_object getVariable["lastInventory",[]]);
  93. if (str(_inventory) != _previous) then {
  94. _object setVariable["lastInventory",_inventory];
  95. if (_objectID == "0") then {
  96. _key = format["CHILD:309:%1:%2:",_uid,_inventory];
  97. } else {
  98. _key = format["CHILD:303:%1:%2:",_objectID,_inventory];
  99. };
  100. #ifdef OBJECT_DEBUG
  101. diag_log ("HIVE: WRITE: "+ str(_key));
  102. #endif
  103. _key call server_hiveWrite;
  104. };
  105. };
  106.  
  107. _object_damage = {
  108. //Allow dmg process
  109. private["_hitpoints","_array","_hit","_selection","_key","_damage"];
  110. _hitpoints = _object call vehicle_getHitpoints;
  111. _damage = damage _object;
  112. _array = [];
  113. {
  114. _hit = [_object,_x] call object_getHit;
  115. _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
  116. if (_hit > 0) then {
  117. _array set [count _array,[_selection,_hit]];
  118. //diag_log format ["Section Part: %1, Dmg: %2",_selection,_hit];
  119. } else {
  120. _array set [count _array,[_selection,0]];
  121. };
  122. //"_selection" ??? anyway seems not needed
  123. //_object setHit ["_selection", _hit];
  124.  
  125. } forEach _hitpoints;
  126.  
  127. if (_forced) then {
  128. if (_object in needUpdate_objects) then {
  129. needUpdate_objects = needUpdate_objects - [_object];
  130. };
  131.  
  132. if (_objectID == "0") then {
  133. _key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage];
  134. } else {
  135. _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
  136. };
  137. diag_log ("HIVE: WRITE: "+ str(_key));
  138. _key call server_hiveWrite;
  139.  
  140. } else {
  141. if (!(_object in needUpdate_objects)) then {
  142. diag_log format["DEBUG: Monitoring: %1",_object];
  143. needUpdate_objects set [count needUpdate_objects, _object];
  144. };
  145. };
  146. };
  147.  
  148. _object_killed = {
  149. [_ObjectID,_UID] call server_deleteObj;
  150. };
  151.  
  152.  
  153. _object setVariable ["lastUpdate",time,true];
  154. switch (_type) do {
  155. case "all": {
  156. call _object_position;
  157. call _object_inventory;
  158. call _object_damage;
  159. };
  160. case "position": {
  161. call _object_position;
  162. };
  163. case "gear": {
  164. call _object_inventory;
  165. };
  166. case "damage"; case "repair" : {
  167. call _object_damage;
  168. };
  169. case "killed": {
  170. call _object_killed;
  171. };
  172. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement