Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Defense Module #429

Merged
merged 7 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions addons/wp/XEH_PREP.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ PREP(taskHunt);
PREP(taskPatrol);
PREP(taskReset);
PREP(taskRush);
PREP(taskDefend);

SUBPREP(Modules,moduleArtillery);
SUBPREP(Modules,moduleArtilleryRegister);
Expand All @@ -25,6 +26,7 @@ SUBPREP(Modules,modulePatrol);
SUBPREP(Modules,moduleReset);
SUBPREP(Modules,moduleRush);
SUBPREP(Modules,moduleTarget);
SUBPREP(Modules,moduleDefend);


SUBPREP(ZEN,setArtilleryRegister);
Expand All @@ -37,3 +39,4 @@ SUBPREP(ZEN,setPatrol);
SUBPREP(ZEN,setReset);
SUBPREP(ZEN,setRush);
SUBPREP(ZEN,setTarget);
SUBPREP(ZEN,setDefend);
4 changes: 4 additions & 0 deletions addons/wp/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ if (isServer) then {
_this spawn FUNC(taskRush);
}] call CBA_fnc_addEventhandler;

[QGVAR(taskDefend), {
_this spawn FUNC(taskDefend);
}] call CBA_fnc_addEventhandler;

[QGVAR(taskCampReset), {
params ["_unit"];
_unit enableAI 'ANIM';
Expand Down
4 changes: 3 additions & 1 deletion addons/wp/config.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,9 @@ class CfgPatches {
QGVAR(TaskGarrison),
QGVAR(TaskPatrol),
QGVAR(TaskRush),
QGVAR(TaskReset)
QGVAR(TaskReset),
QGVAR(ZeusTaskDefend),
QGVAR(TaskDefend)
};
weapons[] = {};
requiredVersion = REQUIRED_VERSION;
Expand Down
101 changes: 101 additions & 0 deletions addons/wp/functions/Modules/fnc_moduleDefend.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
#include "script_component.hpp"
/*
* Author: jokoho482, nkenny
* Makes the unit hold and defence a position near the position
*
* Arguments:
* Arma 3 Module Function Parameters
*
* Return Value:
* NONE
*
* Public: No
*/
params [["_mode", "", [""]], ["_input", [], [[]]]];

switch (_mode) do {
// Default object init
case "init": {
if (is3DEN) exitWith {};
_input params [["_logic", objNull, [objNull]], ["_isActivated", true, [true]], ["_isCuratorPlaced", false, [true]]];
if !(_isActivated && local _logic) exitWith {};
if (_isCuratorPlaced) then {
//--- Get unit under cursor
private _group = GET_CURATOR_GRP_UNDER_CURSOR;

//--- Check if the unit is suitable
if (isNull _group) then {
private _groups = allGroups;
_groups = _groups select { ((units _x) findIf { alive _x }) != -1; };
_groups = [_groups, [], {_logic distance (leader _x) }, "ASCEND"] call BIS_fnc_sortBy;
[LSTRING(Module_TaskGarrison_DisplayName),
[
[LSTRING(Groups_DisplayName), "DROPDOWN", LSTRING(Groups_ToolTip), _groups apply { format ["%1 - %2 (%3 m)", side _x, groupId _x, round ((leader _x) distance _logic)] }, 0],
[LSTRING(Module_TaskDefend_Radius_DisplayName), "SLIDER", LSTRING(Module_TaskDefend_Radius_Tooltip), [10, 500], [2, 1], TASK_DEFEND_SIZE, 2],
[LSTRING(Module_TaskDefend_UseCover_DisplayName), "DROPDOWN", LSTRING(Module_TaskDefend_UseCover_Tooltip), [LSTRING(All), LSTRING(Buildings), LSTRING(Walls), LSTRING(Vegetation), LSTRING(BuildingsAndVegetation), LSTRING(BuildingsAndWalls), LSTRING(WallsandVegetation)], TASK_DEFEND_USECOVER],
[LSTRING(Module_Teleport_DisplayName), "BOOLEAN", LSTRING(Module_TaskGarrison_Teleport_Tooltip), TASK_GARRISON_TELEPORT],
[LSTRING(Module_TaskDefend_Stealth_DisplayName), "BOOLEAN", LSTRING(Module_TaskDefend_Stealth_Tooltip), TASK_DEFEND_STEALTH],
[LSTRING(Module_TaskGarrison_Patrol_DisplayName), "BOOLEAN", LSTRING(Module_TaskGarrison_Patrol_Tooltip), TASK_DEFEND_PATROL]
], {
params ["_data", "_args"];
_args params ["_groups", "_logic"];
_data params ["_groupIndex", "_range", "_useCover", "_teleport", "_stealth", "_patrol"];
private _group = _groups select _groupIndex;
[QGVAR(taskDefend), [_group, getPos _logic, _range, nil, _teleport, _useCover, _stealth, _patrol], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
deleteVehicle _logic;
}, {
params ["", "_logic"];
deleteVehicle _logic;
}, [_groups, _logic]] call EFUNC(main,showDialog);
} else {
_logic setVehicleVarName LLSTRING(Self);
private _targets = [_logic];
GVAR(ModuleTargets) = GVAR(ModuleTargets) - [objNull];
_targets append GVAR(ModuleTargets);
_targets = [_targets, [], {_logic distance _x }, "ASCEND"] call BIS_fnc_sortBy;

[LSTRING(Module_TaskGarrison_DisplayName),
[
[LSTRING(Centers_DisplayName), "DROPDOWN", LSTRING(Centers_ToolTip), _targets apply { format ["%1 (%2 m)", vehicleVarName _x, round (_x distance _logic)] }, 0],
[LSTRING(Module_TaskDefend_Radius_DisplayName), "SLIDER", LSTRING(Module_TaskDefend_Radius_Tooltip), [10, 500], [2, 1], TASK_DEFEND_SIZE, 2],
[LSTRING(Module_TaskDefend_UseCover_DisplayName), "DROPDOWN", LSTRING(Module_TaskDefend_UseCover_Tooltip), [LSTRING(All), LSTRING(Buildings), LSTRING(Walls), LSTRING(Vegetation), LSTRING(BuildingsAndVegetation), LSTRING(BuildingsAndWalls), LSTRING(WallsandVegetation)], TASK_DEFEND_USECOVER],
[LSTRING(Module_Teleport_DisplayName), "BOOLEAN", LSTRING(Module_TaskGarrison_Teleport_Tooltip), TASK_GARRISON_TELEPORT],
[LSTRING(Module_TaskDefend_Stealth_DisplayName), "BOOLEAN", LSTRING(Module_TaskDefend_Stealth_Tooltip), TASK_DEFEND_STEALTH],
[LSTRING(Module_TaskGarrison_Patrol_DisplayName), "BOOLEAN", LSTRING(Module_TaskGarrison_Patrol_Tooltip), TASK_DEFEND_PATROL]

], {
params ["_data", "_args"];
_args params ["_group", "_logic", "_targets"];
_data params ["_targetIndex", "_range", "_useCover", "_teleport", "_stealth", "_patrol"];
private _target = _targets select _targetIndex;
[QGVAR(taskDefend), [_group, getPos _target, _range, nil, _teleport, _useCover, _stealth, _patrol], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
deleteVehicle _logic;
}, {
params ["", "_logic"];
deleteVehicle _logic;
}, [_group, _logic, _targets]
] call EFUNC(main,showDialog);
};
} else {
private _groups = synchronizedObjects _logic apply {group _x};
_groups = _groups arrayIntersect _groups;

private _area = _logic getVariable ["objectarea", [TASK_DEFEND_SIZE, TASK_DEFEND_SIZE, 0, false, -1]];
private _range = _area select ((_area select 0) < (_area select 1));
private _teleport = _logic getVariable [QGVAR(Teleport), TASK_DEFEND_TELEPORT];
private _useCover = _logic getVariable [QGVAR(useCover), TASK_DEFEND_USECOVER];
private _stealth = _logic getVariable [QGVAR(stealth), TASK_DEFEND_STEALTH];
private _patrol = _logic getVariable [QGVAR(Patrol), TASK_DEFEND_PATROL];
{
[QGVAR(taskDefend), [_x, getPos _logic, _range, _area, _teleport, _useCover, _stealth, _patrol], leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
deleteVehicle _logic;
};
};
};
9 changes: 9 additions & 0 deletions addons/wp/functions/ZEN/fnc_setDefend.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#include "script_component.hpp"

private _targets = [];
GET_GROUPS_CONTEXT(_targets);

{
private _leader = leader _x;
[QGVAR(taskDefend), [_x, getPos _leader], _leader] call CBA_fnc_targetEvent;
} forEach _targets;
Loading
Loading