Wirecutter - Replace fences with destroyed models when cut (#8106)

* Add more fence types for wirecutter

* Replace fences with destroyed models when cut

* Move fence destruction to server side
This commit is contained in:
BaerMitUmlaut 2021-02-23 18:03:55 +01:00 committed by GitHub
parent 5bc43fe247
commit 61e8ae3c8b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 94 additions and 7 deletions

View File

@ -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));
};
};

View File

@ -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;
};
};

View File

@ -1,3 +1,4 @@
PREP(cutDownFence);
PREP(destroyFence);
PREP(interactEH);
PREP(isFence);

View File

@ -1,5 +0,0 @@
#include "script_component.hpp"
if (!hasInterface) exitWith {};
["ace_interactMenuOpened", {_this call FUNC(interactEH)}] call CBA_fnc_addEventHandler;

View File

@ -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;
};

View File

@ -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;

View File

@ -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);
};

View File

@ -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 <OBJECT>
*
* 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);

View File

@ -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",\