Guest User

Untitled

a guest
Apr 8th, 2016
25
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /*
  2. [_object,_type] spawn server_updateObject;
  3. */
  4. private ["_object","_type","_objectID","_uid","_lastUpdate","_needUpdate","_object_position","_object_inventory","_object_damage","_isNotOk","_parachuteWest","_firstTime","_object_killed","_object_repair","_isbuildable"];
  5.  
  6. _object = _this select 0;
  7.  
  8. if(isNull(_object)) exitWith {
  9. diag_log format["Skipping Null Object: %1", _object];
  10. };
  11.  
  12. _type = _this select 1;
  13. _parachuteWest = ((typeOf _object == "ParachuteWest") || (typeOf _object == "ParachuteC"));
  14. _isbuildable = (typeOf _object) in dayz_allowedObjects;
  15. _isNotOk = false;
  16. _firstTime = false;
  17.  
  18. _objectID = _object getVariable ["ObjectID","0"];
  19. _uid = _object getVariable ["ObjectUID","0"];
  20.  
  21. if ((typeName _objectID != "string") || (typeName _uid != "string")) then
  22. {
  23. diag_log(format["Non-string Object: ID %1 UID %2", _objectID, _uid]);
  24. //force fail
  25. _objectID = "0";
  26. _uid = "0";
  27. };
  28. if (!_parachuteWest && !(locked _object)) then {
  29. if (_objectID == "0" && _uid == "0") then
  30. {
  31. _object_position = getPosATL _object;
  32. _isNotOk = true;
  33. };
  34. };
  35.  
  36. // added for custom missions
  37. if (_object getVariable "Mission" == 1) exitWith {};
  38. if (_object getVariable "Sarge" == 1) exitWith {};
  39. if (_object getVariable "DZMSUnitsMinor" == 1) exitWith {};
  40. if (_object getVariable "DZMSUnitsMajor" == 1) exitWith {};
  41. if (_object getVariable "MalSar" == 1) exitWith {};
  42.  
  43. // do not update if buildable && not ok
  44. if (_isNotOk && _isbuildable) exitWith { };
  45.  
  46. // delete if still not ok
  47. if (_isNotOk) exitWith { deleteVehicle _object; diag_log(format["Deleting object %1 with invalid ID at pos [%2,%3,%4]",typeOf _object,_object_position select 0,_object_position select 1, _object_position select 2]); };
  48.  
  49.  
  50. _lastUpdate = _object getVariable ["lastUpdate",time];
  51. _needUpdate = _object in needUpdate_objects;
  52.  
  53. // TODO ----------------------
  54. _object_position = {
  55. private["_position","_worldspace","_fuel","_key"];
  56. _position = getPosATL _object;
  57. _worldspace = [
  58. round(direction _object),
  59. _position
  60. ];
  61. _fuel = 0;
  62. if (_object isKindOf "AllVehicles") then {
  63. _fuel = fuel _object;
  64. };
  65. _key = format["CHILD:305:%1:%2:%3:",_objectID,_worldspace,_fuel];
  66. //diag_log ("HIVE: WRITE: "+ str(_key));
  67. _key call server_hiveWrite;
  68. };
  69.  
  70. _object_inventory = {
  71. private["_inventory","_previous","_key"];
  72. _isNormal = true;
  73. if (typeOf (_object)in DZE_DoorsLocked) then{
  74. _isNormal = false;
  75. _inventory = _object getVariable ["doorfriends", []]; //We're replacing the inventory with UIDs for this item
  76. };
  77. if(_isNormal)then {
  78. _inventory = [
  79. getWeaponCargo _object,
  80. getMagazineCargo _object,
  81. getBackpackCargo _object,
  82. ];
  83. };
  84. /*ZSC*/
  85. _object getVariable["bankMoney",0]
  86. /*ZSC*/
  87. ];
  88. _previous = str(_object getVariable["lastInventory",[]]);
  89. if (str(_inventory) != _previous) then {
  90. _object setVariable["lastInventory",_inventory];
  91. if (_objectID == "0") then {
  92. _key = format["CHILD:309:%1:%2:",_uid,_inventory];
  93. } else {
  94. _key = format["CHILD:303:%1:%2:",_objectID,_inventory];
  95. };
  96. //diag_log ("HIVE: WRITE: "+ str(_key));
  97. _key call server_hiveWrite;
  98. };
  99. };
  100.  
  101. _object_damage = {
  102. private["_hitpoints","_array","_hit","_selection","_key","_damage"];
  103. _hitpoints = _object call vehicle_getHitpoints;
  104. _damage = damage _object;
  105. _array = [];
  106. {
  107. _hit = [_object,_x] call object_getHit;
  108. _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
  109. if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
  110. _object setHit ["_selection", _hit];
  111. } count _hitpoints;
  112.  
  113. _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
  114. //diag_log ("HIVE: WRITE: "+ str(_key));
  115. _key call server_hiveWrite;
  116. _object setVariable ["needUpdate",false,true];
  117. };
  118.  
  119. _object_killed = {
  120. private["_hitpoints","_array","_hit","_selection","_key","_damage"];
  121. _hitpoints = _object call vehicle_getHitpoints;
  122. //_damage = damage _object;
  123. _damage = 1;
  124. _array = [];
  125. {
  126. _hit = [_object,_x] call object_getHit;
  127. _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
  128. if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
  129. _hit = 1;
  130. _object setHit ["_selection", _hit];
  131. } count _hitpoints;
  132.  
  133. if (_objectID == "0") then {
  134. _key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage];
  135. } else {
  136. _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
  137. };
  138. //diag_log ("HIVE: WRITE: "+ str(_key));
  139. _key call server_hiveWrite;
  140. _object setVariable ["needUpdate",false,true];
  141. if ((count _this) > 2) then {
  142. _killer = _this select 2;
  143. _charID = _object getVariable ['CharacterID','0'];
  144. _objID = _object getVariable['ObjectID','0'];
  145. _objUID = _object getVariable['ObjectUID','0'];
  146. _worldSpace = getPosATL _object;
  147. if (getPlayerUID _killer != "") then {
  148. _name = if (alive _killer) then { name _killer; } else { format["OBJECT %1", _killer]; };
  149. diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6, Killer: %7 (UID: %8)", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace, _name, (getPlayerUID _killer)];
  150. } else {
  151. diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace];
  152. };
  153. };
  154. };
  155.  
  156. _object_repair = {
  157. private["_hitpoints","_array","_hit","_selection","_key","_damage"];
  158. _hitpoints = _object call vehicle_getHitpoints;
  159. _damage = damage _object;
  160. _array = [];
  161. {
  162. _hit = [_object,_x] call object_getHit;
  163. _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name");
  164. if (_hit > 0) then {_array set [count _array,[_selection,_hit]]};
  165. _object setHit ["_selection", _hit];
  166. } count _hitpoints;
  167.  
  168. _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage];
  169. //diag_log ("HIVE: WRITE: "+ str(_key));
  170. _key call server_hiveWrite;
  171. _object setVariable ["needUpdate",false,true];
  172. };
  173. // TODO ----------------------
  174.  
  175. _object setVariable ["lastUpdate",time,true];
  176. switch (_type) do {
  177. case "all": {
  178. call _object_position;
  179. call _object_inventory;
  180. call _object_damage;
  181. };
  182. case "position": {
  183. if (!(_object in needUpdate_objects)) then {
  184. //diag_log format["DEBUG Position: Added to NeedUpdate=%1",_object];
  185. needUpdate_objects set [count needUpdate_objects, _object];
  186. };
  187. };
  188. case "gear": {
  189. call _object_inventory;
  190. };
  191. case "damage": {
  192. if ( (time - _lastUpdate) > 5) then {
  193. call _object_damage;
  194. } else {
  195. if (!(_object in needUpdate_objects)) then {
  196. //diag_log format["DEBUG Damage: Added to NeedUpdate=%1",_object];
  197. needUpdate_objects set [count needUpdate_objects, _object];
  198. };
  199. };
  200. };
  201. case "killed": {
  202. call _object_killed;
  203. };
  204. case "repair": {
  205. call _object_damage;
  206. };
  207. };
RAW Paste Data