Guest User

Untitled

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