From 9aa1784f23b30df6449661eedff1f61efc2aa022 Mon Sep 17 00:00:00 2001 From: icomrade Date: Sun, 21 Aug 2016 15:46:33 -0400 Subject: [PATCH] Globally remove wrecked objects using PVEH PVDZE_obj_Remove. Wrecks only exist for the players currently in the server when the parent object is destroyed. Passing the object through the PVEH does not work. --- CHANGE LOG 1.0.6.txt | 1 + SQF/dayz_code/actions/remove.sqf | 18 ++- SQF/dayz_code/compile/fnc_getPos.sqf | 2 +- SQF/dayz_code/init/publicEH.sqf | 104 +++++++++--------- .../eventHandlers/server_sendToClient.sqf | 9 ++ 5 files changed, 77 insertions(+), 57 deletions(-) diff --git a/CHANGE LOG 1.0.6.txt b/CHANGE LOG 1.0.6.txt index 707a5bd9e..963886dd9 100644 --- a/CHANGE LOG 1.0.6.txt +++ b/CHANGE LOG 1.0.6.txt @@ -105,6 +105,7 @@ [FIXED] Players are no longer able to brute force doors or safes by the method described in #1187 @icomrade [FIXED] Fix some items not displaying removal option #1135 @icomrade [FIXED] Study body message saying his/he on female players. @ebaydayz +[FIXED] Destroyed objects (i.e. ore veins, ammo crates and wrecked buildables) are now deleted globally after being removed. #1730 @icomrade [UPDATED] .hpp files updated in dayz_code\Configs\CfgLoot\CfgBuildingPos. @Uro1 [UPDATED] .bat files updated in Config-Examples @Raziel23x diff --git a/SQF/dayz_code/actions/remove.sqf b/SQF/dayz_code/actions/remove.sqf index eb333f3d8..332481480 100644 --- a/SQF/dayz_code/actions/remove.sqf +++ b/SQF/dayz_code/actions/remove.sqf @@ -27,6 +27,9 @@ if (DZE_permanentPlot) then { if (_obj in DZE_DoorsLocked) exitWith {DZE_ActionInProgress = false; localize "STR_EPOCH_ACTIONS_20" call dayz_rollingMessages;}; if (_obj getVariable ["GeneratorRunning", false]) exitWith {DZE_ActionInProgress = false; localize "str_epoch_player_89" call dayz_rollingMessages;}; +_PlayerNear = {isPlayer _x} count (([_obj] call FNC_GetPos) nearEntities ["CAManBase", 10]) > 1; +if (_PlayerNear) exitWith {localize "str_pickup_limit_5" call dayz_rollingMessages;}; + _objectID = _obj getVariable ["ObjectID","0"]; _objectUID = _obj getVariable ["ObjectUID","0"]; @@ -90,6 +93,9 @@ while {_isOk} do { _isOk = false; _proceed = false; }; + + format[localize "str_epoch_player_163",_nameVehicle,(_counter + 1),_limit] call dayz_rollingMessages; + ["Working",0,[20,40,15,0]] call dayz_NutritionSystem; player playActionNow "Medic"; _dis=20; @@ -138,8 +144,6 @@ while {_isOk} do { _proceed = false; }; - format[localize "str_epoch_player_163",_nameVehicle,_counter,_limit] call dayz_rollingMessages; - if(_counter == _limit) exitWith { _isOk = false; _proceed = true; @@ -179,15 +183,19 @@ if (_proceed && _success) then { if(!isNull(_obj)) then { _ipos = getPosATL _obj; - deleteVehicle _obj; - - if(!_isWreck) then { + + if(!_isWreck && !_isWreckBuilding) then { _activatingPlayer = player; PVDZ_obj_Destroy = [_objectID,_objectUID, _activatingPlayer]; publicVariableServer "PVDZ_obj_Destroy"; }; + if (_isWreckBuilding) then { + PVDZ_send = [player,"RemoveObject",_ipos]; + publicVariableServer "PVDZ_send"; + }; + format[localize "str_epoch_player_165",_nameVehicle] call dayz_rollingMessages; _preventRefund = false; diff --git a/SQF/dayz_code/compile/fnc_getPos.sqf b/SQF/dayz_code/compile/fnc_getPos.sqf index b0af84aaa..4a49bde06 100644 --- a/SQF/dayz_code/compile/fnc_getPos.sqf +++ b/SQF/dayz_code/compile/fnc_getPos.sqf @@ -1,6 +1,6 @@ private "_pos"; -if (isNil {_this select 0}) exitWith {[0,0,0]}; +//if (isNil {_this select 0}) exitWith {[0,0,0]}; _thingy = _this select 0; _pos = getPosASL _thingy; diff --git a/SQF/dayz_code/init/publicEH.sqf b/SQF/dayz_code/init/publicEH.sqf index 41923ba94..2db2d0843 100644 --- a/SQF/dayz_code/init/publicEH.sqf +++ b/SQF/dayz_code/init/publicEH.sqf @@ -15,60 +15,62 @@ "PVDZE_veh_Lock" addPublicVariableEventHandler {(_this select 1) call local_lockUnlock}; "PVDZE_plr_GutBodyZ" addPublicVariableEventHandler {(_this select 1) spawn local_gutObjectZ}; "PVDZE_veh_Init" addPublicVariableEventHandler {(_this select 1) call fnc_veh_ResetEH}; +"PVDZE_obj_Remove" addPublicVariableEventHandler {_pos = (_this select 1); _obj = nearestObjects [_pos, DZE_isWreckBuilding, 5]; if (count _obj > 0) then {deleteVehicle (_obj select 0);};}; -{ - if (toLower worldName != "chernarus") exitWith {}; - private ["_building","_fckingcode"]; +if (toLower worldName == "chernarus") then { + { + private ["_building","_fckingcode"]; - _fckingcode = { - private ["_building","_part","_dmgLvl","_who","_ammo","_dist"]; + _fckingcode = { + private ["_building","_part","_dmgLvl","_who","_ammo","_dist"]; - _building = _this select 0; - _part = _this select 1; - _dmgLvl = 1 min (_this select 2); - _who = _this select 3; - _ammo = _this select 4; - if (_part != 'glass' && _dmgLvl > 0.01) then { - if (isServer) then { - diag_log ['Log building damage', _this]; - } else { - if (isNull _who) then { - if (_ammo != "" && _ammo isKindOf "HelicopterExploSmall") then { - _who = player; - _dist = round (_who distance _building); - PVDZ_sec_atp = toArray (format ["UID#%1 d4maged %2 %5 to %3pct with ammo %4 at dist4nce %6m.", - getPlayerUID _who, typeOf _building, round (100 * _dmgLvl), _ammo, _part, _dist]); - publicVariableServer "PVDZ_sec_atp"; - }; - } else { - if (_who == player) then { - _dist = round (_who distance _building); - PVDZ_sec_atp = toArray (format ["UID#%1 d4maged %2 %5 to %3pct with ammo %4 at dist4nce %6m.", - getPlayerUID _who, typeOf _building, round (100 * _dmgLvl), _ammo, _part, _dist]); - publicVariableServer "PVDZ_sec_atp"; - }; - }; - }; - }; - if ((!isNull _who) && {(_who distance _building < 150)}) then {_dmgLvl} else {0} - }; - _building = [_x select 0,_x select 1,0] nearestObject (_x select 2); - _building removeAllEventHandlers "handleDamage"; - _building addEventHandler ["handleDamage", _fckingcode]; -} forEach [ - [7069,7727,206458], [6009,7815,203486], [10638,8016,272598], [6553,5598,223435], [6914,11431,141876], - [4660,9596,145234], [4788,10257,143923], [11467,7479,276453], [4628,10489,137736], [4551,6395,212964], - [3815,8948,132069], [3804,8925,132182], [11957,9120,261904], [12031,9158,261252], [12057,9103,261945], - [12227,9518,256625], [12237,9493,262727], [12256,9508,262732], [12275,9479,262631], [3064,7975,172476], - [3055,7855,172835], [12742,9593,259691], [11254,12210,236245], [12780,10128,257815], [12805,10089,258268], - [12803,10119,258288], [11251,4274,353940], [13100,7177,297715], [7098,2738,966951], [6817,2702,966613], - [6379,2791,965644], [6414,2760,965688], [6371,2747,965657], [6386,2735,965658], [6410,2716,965659], - [6383,2691,965643], [6899,2561,969372], [6854,2556,969371], [6770,2525,968272], [6901,2484,969736], - [6783,2485,968116], [6507,2532,967694], [6835,2388,969223], [6578,2402,968509], [6661,2345,968949], - [6679,2302,969332], [2587,5069,188570], [6537,2302,968797], [10424,2562,362226], [10420,2368,363222], - [10443,2345,363318], [10481,2358,363308], [10365,2241,363748], [10518,2288,364628], [10457,2256,363454], - [10174,1810,366820], [3589,2175,328944] -]; + _building = _this select 0; + _part = _this select 1; + _dmgLvl = 1 min (_this select 2); + _who = _this select 3; + _ammo = _this select 4; + if (_part != 'glass' && _dmgLvl > 0.01) then { + if (isServer) then { + diag_log ['Log building damage', _this]; + } else { + if (isNull _who) then { + if (_ammo != "" && _ammo isKindOf "HelicopterExploSmall") then { + _who = player; + _dist = round (_who distance _building); + PVDZ_sec_atp = toArray (format ["UID#%1 d4maged %2 %5 to %3pct with ammo %4 at dist4nce %6m.", + getPlayerUID _who, typeOf _building, round (100 * _dmgLvl), _ammo, _part, _dist]); + publicVariableServer "PVDZ_sec_atp"; + }; + } else { + if (_who == player) then { + _dist = round (_who distance _building); + PVDZ_sec_atp = toArray (format ["UID#%1 d4maged %2 %5 to %3pct with ammo %4 at dist4nce %6m.", + getPlayerUID _who, typeOf _building, round (100 * _dmgLvl), _ammo, _part, _dist]); + publicVariableServer "PVDZ_sec_atp"; + }; + }; + }; + }; + if ((!isNull _who) && {(_who distance _building < 150)}) then {_dmgLvl} else {0} + }; + _building = [_x select 0,_x select 1,0] nearestObject (_x select 2); + _building removeAllEventHandlers "handleDamage"; + _building addEventHandler ["handleDamage", _fckingcode]; + } forEach [ + [7069,7727,206458], [6009,7815,203486], [10638,8016,272598], [6553,5598,223435], [6914,11431,141876], + [4660,9596,145234], [4788,10257,143923], [11467,7479,276453], [4628,10489,137736], [4551,6395,212964], + [3815,8948,132069], [3804,8925,132182], [11957,9120,261904], [12031,9158,261252], [12057,9103,261945], + [12227,9518,256625], [12237,9493,262727], [12256,9508,262732], [12275,9479,262631], [3064,7975,172476], + [3055,7855,172835], [12742,9593,259691], [11254,12210,236245], [12780,10128,257815], [12805,10089,258268], + [12803,10119,258288], [11251,4274,353940], [13100,7177,297715], [7098,2738,966951], [6817,2702,966613], + [6379,2791,965644], [6414,2760,965688], [6371,2747,965657], [6386,2735,965658], [6410,2716,965659], + [6383,2691,965643], [6899,2561,969372], [6854,2556,969371], [6770,2525,968272], [6901,2484,969736], + [6783,2485,968116], [6507,2532,967694], [6835,2388,969223], [6578,2402,968509], [6661,2345,968949], + [6679,2302,969332], [2587,5069,188570], [6537,2302,968797], [10424,2562,362226], [10420,2368,363222], + [10443,2345,363318], [10481,2358,363308], [10365,2241,363748], [10518,2288,364628], [10457,2256,363454], + [10174,1810,366820], [3589,2175,328944] + ]; +}; // Server only if (isServer) then { diff --git a/SQF/dayz_server/eventHandlers/server_sendToClient.sqf b/SQF/dayz_server/eventHandlers/server_sendToClient.sqf index f067dfca9..fcffee0ac 100644 --- a/SQF/dayz_server/eventHandlers/server_sendToClient.sqf +++ b/SQF/dayz_server/eventHandlers/server_sendToClient.sqf @@ -124,4 +124,13 @@ switch (_variable) do { PVDZE_plr_FriendRQ = _arraytosend; _owner publicVariableClient "PVDZE_plr_FriendRQ"; }; + + case "RemoveObject": { + PVDZE_obj_Remove = _arraytosend; + { + if (isPlayer _x) then { + (owner _x) publicVariableClient "PVDZE_obj_Remove"; + }; + } forEach playableUnits; + }; }; \ No newline at end of file