SHOW:
|
|
- or go back to the newest paste.
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 | _object_inventory = { | |
54 | - | _isNormal = true; |
54 | + | private["_inventory","_previous","_key"]; |
55 | - | if (typeOf (_object) == "Plastic_Pole_EP1_DZ") then{ |
55 | + | _isNormal = true; |
56 | - | _isNormal = false; |
56 | + | if (typeOf _object == "Plastic_Pole_EP1_DZ") then{ |
57 | - | _inventory = _object getVariable ["plotfriends", []]; //We're replacing the inventory with UIDs for this item |
57 | + | _isNormal = false; |
58 | - | }; |
58 | + | _inventory = _object getVariable ["plotfriends", []]; //We're replacing the inventory with UIDs for this item |
59 | - | if (typeOf (_object)in DZE_DoorsLocked) then{ |
59 | + | }; |
60 | - | _isNormal = false; |
60 | + | if (typeOf _object in DZE_DoorsLocked) then{ |
61 | - | _inventory = _object getVariable ["doorfriends", []]; //We're replacing the inventory with UIDs for this item |
61 | + | _isNormal = false; |
62 | _inventory = _object getVariable ["doorfriends", []]; //We're replacing the inventory with UIDs for this item | |
63 | }; | |
64 | - | if(_isNormal)then { |
64 | + | |
65 | if(_isNormal)then { | |
66 | - | getWeaponCargo _object, |
66 | + | |
67 | - | getMagazineCargo _object, |
67 | + | getWeaponCargo _object, |
68 | - | getBackpackCargo _object |
68 | + | getMagazineCargo _object, |
69 | getBackpackCargo _object | |
70 | ]; | |
71 | }; | |
72 | _previous = str(_object getVariable["lastInventory",[]]); | |
73 | if (str(_inventory) != _previous) then { | |
74 | _object setVariable["lastInventory",_inventory]; | |
75 | if (_objectID == "0") then { | |
76 | _key = format["CHILD:309:%1:%2:",_uid,_inventory]; | |
77 | } else { | |
78 | _key = format["CHILD:303:%1:%2:",_objectID,_inventory]; | |
79 | }; | |
80 | //diag_log ("HIVE: WRITE: "+ str(_key)); | |
81 | _key call server_hiveWrite; | |
82 | }; | |
83 | }; | |
84 | ||
85 | _object_damage = { | |
86 | private["_hitpoints","_array","_hit","_selection","_key","_damage"]; | |
87 | _hitpoints = _object call vehicle_getHitpoints; | |
88 | _damage = damage _object; | |
89 | _array = []; | |
90 | { | |
91 | _hit = [_object,_x] call object_getHit; | |
92 | _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name"); | |
93 | if (_hit > 0) then {_array set [count _array,[_selection,_hit]]}; | |
94 | _object setHit ["_selection", _hit]; | |
95 | } count _hitpoints; | |
96 | _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage]; | |
97 | _key call server_hiveWrite; | |
98 | _object setVariable ["needUpdate",false,true]; | |
99 | }; | |
100 | ||
101 | _object_killed = { | |
102 | private["_hitpoints","_array","_hit","_selection","_key","_damage"]; | |
103 | _hitpoints = _object call vehicle_getHitpoints; | |
104 | _damage = 1; | |
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 | _hit = 1; | |
111 | _object setHit ["_selection", _hit]; | |
112 | } count _hitpoints; | |
113 | if (_objectID == "0") then { | |
114 | _key = format["CHILD:306:%1:%2:%3:",_uid,_array,_damage]; | |
115 | } else { | |
116 | _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage]; | |
117 | }; | |
118 | _key call server_hiveWrite; | |
119 | _object setVariable ["needUpdate",false,true]; | |
120 | if ((count _this) > 2) then { | |
121 | _killer = _this select 2; | |
122 | _charID = _object getVariable ['CharacterID','0']; | |
123 | _objID = _object getVariable['ObjectID','0']; | |
124 | _objUID = _object getVariable['ObjectUID','0']; | |
125 | _worldSpace = getPosATL _object; | |
126 | if (getPlayerUID _killer != "") then { | |
127 | _name = if (alive _killer) then { name _killer; } else { format["OBJECT %1", _killer]; }; | |
128 | 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)]; | |
129 | } else { | |
130 | diag_log format["Vehicle killed: Vehicle %1 (TYPE: %2), CharacterID: %3, ObjectID: %4, ObjectUID: %5, Position: %6", _object, (typeOf _object), _charID, _objID, _objUID, _worldSpace]; | |
131 | }; | |
132 | }; | |
133 | }; | |
134 | ||
135 | _object_repair = { | |
136 | private["_hitpoints","_array","_hit","_selection","_key","_damage"]; | |
137 | _hitpoints = _object call vehicle_getHitpoints; | |
138 | _damage = damage _object; | |
139 | _array = []; | |
140 | { | |
141 | _hit = [_object,_x] call object_getHit; | |
142 | _selection = getText (configFile >> "CfgVehicles" >> (typeOf _object) >> "HitPoints" >> _x >> "name"); | |
143 | if (_hit > 0) then {_array set [count _array,[_selection,_hit]]}; | |
144 | _object setHit ["_selection", _hit]; | |
145 | } count _hitpoints; | |
146 | ||
147 | _key = format["CHILD:306:%1:%2:%3:",_objectID,_array,_damage]; | |
148 | _key call server_hiveWrite; | |
149 | _object setVariable ["needUpdate",false,true]; | |
150 | }; | |
151 | ||
152 | _object setVariable ["lastUpdate",time,true]; | |
153 | ||
154 | switch (_type) do { | |
155 | case "all": { | |
156 | call _object_position; | |
157 | call _object_inventory; | |
158 | call _object_damage; | |
159 | }; | |
160 | case "position": { | |
161 | if (!(_object in needUpdate_objects)) then { | |
162 | needUpdate_objects set [count needUpdate_objects, _object]; | |
163 | }; | |
164 | }; | |
165 | case "gear": { | |
166 | call _object_inventory; | |
167 | }; | |
168 | case "damage": { | |
169 | if ( (time - _lastUpdate) > 5) then { | |
170 | call _object_damage; | |
171 | } else { | |
172 | if (!(_object in needUpdate_objects)) then { | |
173 | needUpdate_objects set [count needUpdate_objects, _object]; | |
174 | }; | |
175 | }; | |
176 | }; | |
177 | case "killed": { | |
178 | call _object_killed; | |
179 | }; | |
180 | case "repair": { | |
181 | call _object_damage; | |
182 | }; | |
183 | }; |