diff --git a/addons/logistics_wirecutter/CfgEventHandlers.hpp b/addons/logistics_wirecutter/CfgEventHandlers.hpp index 36c0fca8a3..0d3301d6e0 100644 --- a/addons/logistics_wirecutter/CfgEventHandlers.hpp +++ b/addons/logistics_wirecutter/CfgEventHandlers.hpp @@ -12,6 +12,6 @@ class Extended_PreInit_EventHandlers { class Extended_PostInit_EventHandlers { class ADDON { - clientInit = QUOTE(call COMPILE_FILE(XEH_clientInit)); + init = QUOTE(call COMPILE_FILE(XEH_postInit)); }; }; diff --git a/addons/logistics_wirecutter/CfgVehicles.hpp b/addons/logistics_wirecutter/CfgVehicles.hpp index 7dd57f207f..ab27440384 100644 --- a/addons/logistics_wirecutter/CfgVehicles.hpp +++ b/addons/logistics_wirecutter/CfgVehicles.hpp @@ -80,4 +80,19 @@ class CfgVehicles { class Land_BackAlley_01_l_1m_F: Wall_F { GVAR(isFence) = 1; }; + class Land_GameProofFence_01_l_5m_F: Wall_F { + GVAR(isFence) = 1; + }; + class Land_NetFence_03_m_3m_F: Wall_F { + GVAR(isFence) = 1; + }; + class Land_NetFence_03_m_3m_corner_F: Wall_F { + GVAR(isFence) = 1; + }; + class Land_NetFence_03_m_3m_hole_F: Wall_F { + GVAR(isFence) = 1; + }; + class Land_NetFence_03_m_9m_F: Wall_F { + GVAR(isFence) = 1; + }; }; diff --git a/addons/logistics_wirecutter/XEH_PREP.hpp b/addons/logistics_wirecutter/XEH_PREP.hpp index 6ab95824ff..09cbc1c05d 100644 --- a/addons/logistics_wirecutter/XEH_PREP.hpp +++ b/addons/logistics_wirecutter/XEH_PREP.hpp @@ -1,3 +1,4 @@ PREP(cutDownFence); +PREP(destroyFence); PREP(interactEH); PREP(isFence); diff --git a/addons/logistics_wirecutter/XEH_clientInit.sqf b/addons/logistics_wirecutter/XEH_clientInit.sqf deleted file mode 100644 index 45e93bc6bd..0000000000 --- a/addons/logistics_wirecutter/XEH_clientInit.sqf +++ /dev/null @@ -1,5 +0,0 @@ -#include "script_component.hpp" - -if (!hasInterface) exitWith {}; - -["ace_interactMenuOpened", {_this call FUNC(interactEH)}] call CBA_fnc_addEventHandler; diff --git a/addons/logistics_wirecutter/XEH_postInit.sqf b/addons/logistics_wirecutter/XEH_postInit.sqf new file mode 100644 index 0000000000..a22479e7e1 --- /dev/null +++ b/addons/logistics_wirecutter/XEH_postInit.sqf @@ -0,0 +1,9 @@ +#include "script_component.hpp" + +if (hasInterface) then { + ["ace_interactMenuOpened", {_this call FUNC(interactEH)}] call CBA_fnc_addEventHandler; +}; + +if (isServer) then { + [QGVAR(destroyFence), {_this call FUNC(destroyFence)}] call CBA_fnc_addEventHandler; +}; diff --git a/addons/logistics_wirecutter/XEH_preInit.sqf b/addons/logistics_wirecutter/XEH_preInit.sqf index b47cf6628d..cd05369d60 100644 --- a/addons/logistics_wirecutter/XEH_preInit.sqf +++ b/addons/logistics_wirecutter/XEH_preInit.sqf @@ -6,4 +6,28 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +if (isServer) then { + GVAR(replacements) = createHashMapFromArray [ + ["gameprooffence_01_l_5m_f.p3d", [["Land_GameProofFence_01_l_d_F", [0, 0, 0], 0]]], + ["indfnc_3_f.p3d", [["Land_IndFnc_3_D_F", [0.039, -0.221, 0], 0]]], + ["indfnc_3_hole_f.p3d", [["Land_IndFnc_3_D_F", [0.042, -0.252, 0], 0]]], + ["indfnc_9_f.p3d", [["Land_IndFnc_3_F", [-3, -0.06, 0], 0], ["Land_IndFnc_3_D_F", [0.039, -0.281, 0], 0], ["Land_IndFnc_3_F", [3, -0.06, 0], 0]]], + ["indfnc_corner_f.p3d", [["Land_IndFnc_3_D_F", [0.116, -0.223, 0], 0]]], + ["mil_wiredfence_f.p3d", [["Land_Mil_WiredFenceD_F", [0, 0, 0], 0]]], + ["net_fence_8m_f.p3d", [["Land_Net_FenceD_8m_F", [0, 0.1, 0], 0]]], + ["netfence_01_m_4m_f.p3d", [["Land_NetFence_01_m_d_F", [0, 0, 0], 0]]], + ["netfence_01_m_8m_f.p3d", [["Land_NetFence_01_m_4m_F", [-2, 0, 0], 0], ["Land_NetFence_01_m_d_F", [2, 0, 0], 0]]], + ["netfence_03_m_3m_corner_f.p3d", [["Land_NetFence_03_m_3m_d_F", [0.104, -0.183, 0], 0]]], + ["netfence_03_m_3m_f.p3d", [["Land_NetFence_03_m_3m_d_F", [0.042, -0.236, 0], 0]]], + ["netfence_03_m_3m_hole_f.p3d", [["Land_NetFence_03_m_3m_d_F", [0.045, -0.273, 0], 0]]], + ["netfence_03_m_9m_f.p3d", [["Land_NetFence_03_m_3m_F", [-3.006, -0.073, 0], 0], ["Land_NetFence_03_m_3m_d_F", [0.038, -0.309, 0], 0], ["Land_NetFence_03_m_3m_F", [2.995, -0.073, 0], 0]]], + ["plasticnetfence_01_long_f.p3d", [["Land_PlasticNetFence_01_long_d_F", [0, 0, -0.1], 0]]], + ["wired_fence_4m_f.p3d", [["Land_Wired_Fence_4mD_F", [0, 0, 0], 0]]], + ["wired_fence_8m_f.p3d", [["Land_Wired_Fence_4m_F", [-2, 0, 0], 0], ["Land_Wired_Fence_4mD_F", [3, 0, 0], 0]]], + ["wiredfence_01_16m_f.p3d", [["Land_WiredFence_01_4m_F", [-6, 0, 0], 0], ["Land_WiredFence_01_8m_d_F", [0.34, -0.1, 0], 0]]], + ["wiredfence_01_4m_f.p3d", [["Land_WiredFence_01_pole_F", [-2, 0, 0], 150]]], + ["wiredfence_01_8m_f.p3d", [["Land_WiredFence_01_4m_F", [-2, 0, 0], 0], ["Land_WiredFence_01_pole_F", [0, 0, 0], 0]]] + ]; +}; + ADDON = true; diff --git a/addons/logistics_wirecutter/functions/fnc_cutDownFence.sqf b/addons/logistics_wirecutter/functions/fnc_cutDownFence.sqf index 79da93cf79..170c628d18 100644 --- a/addons/logistics_wirecutter/functions/fnc_cutDownFence.sqf +++ b/addons/logistics_wirecutter/functions/fnc_cutDownFence.sqf @@ -35,7 +35,7 @@ if !(_unit call EFUNC(common,isSwimming)) then { TRACE_1("Fence cutting successful",_this); (_this select 0) params ["_unit", "_fence"]; - _fence setDamage 1; + [QGVAR(destroyFence), [_fence]] call CBA_fnc_serverEvent; if !(_unit call EFUNC(common,isSwimming)) then { [_unit, "AmovPknlMstpSrasWrflDnon", 1] call EFUNC(common,doAnimation); }; diff --git a/addons/logistics_wirecutter/functions/fnc_destroyFence.sqf b/addons/logistics_wirecutter/functions/fnc_destroyFence.sqf new file mode 100644 index 0000000000..9098acb743 --- /dev/null +++ b/addons/logistics_wirecutter/functions/fnc_destroyFence.sqf @@ -0,0 +1,42 @@ +#include "script_component.hpp" +/* + * Author: BaerMitUmlaut + * Destroys the given fence and replaces it with a destroyed fence if possible. + * + * Arguments: + * 0: Fence + * + * Return Value: + * None + * + * Example: + * [fence] call ace_logistics_wirecutter_fnc_destroyFence + * + * Public: No + */ + +params ["_fence"]; + +private _fenceModel = toLower ((getModelInfo _fence)#0); + +// If fence cannot be replaced with destroyed model, just knock it over +if !(_fenceModel in GVAR(replacements)) exitWith { + _fence setDamage 1; +}; + +// Remove old fence +if ([_fence] call CBA_fnc_isTerrainObject) then { + _fence setDamage 1; + _fence hideObjectGlobal true; +} else { + deleteVehicle _fence; +}; + +// Create replacement(s) +{ + _x params ["_type", "_position", "_dir"]; + + private _replacement = _type createVehicle [0, 0, 0]; + _replacement setPosWorld (_fence modelToWorldWorld _position); + _replacement setDir (direction _fence + _dir); +} forEach (GVAR(replacements) get _fenceModel); diff --git a/addons/logistics_wirecutter/script_component.hpp b/addons/logistics_wirecutter/script_component.hpp index be397a8519..38ed1dd077 100644 --- a/addons/logistics_wirecutter/script_component.hpp +++ b/addons/logistics_wirecutter/script_component.hpp @@ -70,6 +70,7 @@ "gm_gc_g501_sm70_02.p3d",\ "gm_gc_g501_sm70_03.p3d",\ "netfence_03_m_3m_f.p3d",\ + "netfence_03_m_3m_hole_f.p3d",\ "netfence_03_m_3m_corner_f.p3d",\ "netfence_03_m_9m_f.p3d",\ "vineyardfence_01_f.p3d",\