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

Adds teleport option to taskPatrol #428

Merged
merged 3 commits into from
Jan 6, 2025
Merged
Show file tree
Hide file tree
Changes from 2 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
17 changes: 10 additions & 7 deletions addons/wp/functions/Modules/fnc_modulePatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,14 @@ switch (_mode) do {
[LSTRING(Module_TaskPatrol_Range_DisplayName), "SLIDER", LSTRING(Module_TaskPatrol_Range_ToolTip), [20, 2000], [1, 0.5], TASK_PATROL_SIZE, 1],
[LSTRING(Module_TaskPatrol_Waypoints_DisplayName), "SLIDER", LSTRING(Module_TaskPatrol_Waypoints_ToolTip), [2, 15], [2, 1], TASK_PATROL_WAYPOINTCOUNT, 0],
[LSTRING(Module_TaskPatrol_MoveWaypoints_DisplayName), "BOOLEAN", LSTRING(Module_TaskPatrol_MoveWaypoints_ToolTip), TASK_PATROL_MOVEWAYPOINTS],
[LSTRING(Module_Task_EnableReinforcement_DisplayName), "BOOLEAN", LSTRING(Module_Task_EnableReinforcement_ToolTip), TASK_PATROL_ENABLEREINFORCEMENT]
[LSTRING(Module_Task_EnableReinforcement_DisplayName), "BOOLEAN", LSTRING(Module_Task_EnableReinforcement_ToolTip), TASK_PATROL_ENABLEREINFORCEMENT],
[LSTRING(Module_TaskGarrison_Teleport_DisplayName), "BOOLEAN", LSTRING(Module_TaskGarrison_Teleport_Tooltip), TASK_PATROL_TELEPORT]
nk3nny marked this conversation as resolved.
Show resolved Hide resolved
], {
params ["_data", "_args"];
_args params ["_groups", "_logic"];
_data params ["_groupIndex", "_range", "_waypointCount", "_moveWaypoint", "_enableReinforcement"];
_data params ["_groupIndex", "_range", "_waypointCount", "_moveWaypoint", "_enableReinforcement", "_teleport"];
private _group = _groups select _groupIndex;
[QGVAR(taskPatrol), [_group, getPos _logic, _range, _waypointCount, [], _moveWaypoint, _enableReinforcement], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskPatrol), [_group, getPos _logic, _range, _waypointCount, [], _moveWaypoint, _enableReinforcement, _teleport], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
Expand All @@ -63,13 +64,14 @@ switch (_mode) do {
[LSTRING(Module_TaskPatrol_Range_DisplayName), "SLIDER", LSTRING(Module_TaskPatrol_Range_ToolTip), [20, 2000], [1, 0.5], TASK_PATROL_SIZE, 1],
[LSTRING(Module_TaskPatrol_Waypoints_DisplayName), "SLIDER", LSTRING(Module_TaskPatrol_Waypoints_ToolTip), [2, 15], [2, 1], TASK_PATROL_WAYPOINTCOUNT, 0],
[LSTRING(Module_TaskPatrol_MoveWaypoints_DisplayName), "BOOLEAN", LSTRING(Module_TaskPatrol_MoveWaypoints_ToolTip), TASK_PATROL_MOVEWAYPOINTS],
[LSTRING(Module_Task_EnableReinforcement_DisplayName), "BOOLEAN", LSTRING(Module_Task_EnableReinforcement_ToolTip), TASK_PATROL_ENABLEREINFORCEMENT]
[LSTRING(Module_Task_EnableReinforcement_DisplayName), "BOOLEAN", LSTRING(Module_Task_EnableReinforcement_ToolTip), TASK_PATROL_ENABLEREINFORCEMENT],
[LSTRING(Module_TaskGarrison_Teleport_DisplayName), "BOOLEAN", LSTRING(Module_TaskGarrison_Teleport_Tooltip), TASK_PATROL_TELEPORT]
], {
params ["_data", "_args"];
_args params ["_targets", "_logic", "_group"];
_data params ["_targetIndex", "_range", "_waypointCount", "_moveWaypoint", "_enableReinforcement"];
_data params ["_targetIndex", "_range", "_waypointCount", "_moveWaypoint", "_enableReinforcement", "_teleport"];
private _target = _targets select _targetIndex;
[QGVAR(taskPatrol), [_group, getPos _target, _range, _waypointCount, [], _moveWaypoint, _enableReinforcement], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskPatrol), [_group, getPos _target, _range, _waypointCount, [], _moveWaypoint, _enableReinforcement, _teleport], leader _group] call CBA_fnc_targetEvent;
if (_logic isNotEqualTo _target) then {
deleteVehicle _logic;
};
Expand All @@ -91,8 +93,9 @@ switch (_mode) do {
private _moveWaypoint = _logic getVariable [QGVAR(moveWaypoints), TASK_PATROL_MOVEWAYPOINTS];
private _enableReinforcement = _logic getVariable [QGVAR(EnableReinforcement), TASK_PATROL_ENABLEREINFORCEMENT];
private _waypointCount =_logic getVariable [QGVAR(WaypointCount), TASK_PATROL_WAYPOINTCOUNT];
private _teleport =_logic getVariable [QGVAR(Teleport), TASK_PATROL_TELEPORT];
{
[QGVAR(taskPatrol), [_x, getPos _logic, _range, _waypointCount, _area, _moveWaypoint, _enableReinforcement], leader _x] call CBA_fnc_targetEvent;
[QGVAR(taskPatrol), [_x, getPos _logic, _range, _waypointCount, _area, _moveWaypoint, _enableReinforcement, _teleport], leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
deleteVehicle _logic;
};
Expand Down
4 changes: 2 additions & 2 deletions addons/wp/functions/fnc_taskCamp.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,12 @@ if (_patrol) then {

// orders
if (_area isEqualTo []) then {
[_patrolGroup, _pos, _range * 2, 4, nil, true] call FUNC(taskPatrol);
[_patrolGroup, _pos, _range * 2, 4, nil, true, false, _teleport] call FUNC(taskPatrol);
} else {
private _area2 = +_area;
_area2 set [0, (_area2 select 0) * 2];
_area2 set [0, (_area2 select 1) * 2];
[_patrolGroup, _pos, _range * 2, 4, _area2, true] call FUNC(taskPatrol);
[_patrolGroup, _pos, _range * 2, 4, _area2, true, false, _teleport] call FUNC(taskPatrol);
};

// eventhandler
Expand Down
4 changes: 2 additions & 2 deletions addons/wp/functions/fnc_taskGarrison.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,12 @@ if (_patrol) then {

// orders
if (_area isEqualTo []) then {
[_patrolGroup, _pos, _radius, 4, nil, true] call FUNC(taskPatrol);
[_patrolGroup, _pos, _radius, 4, nil, true, false, _teleport] call FUNC(taskPatrol);
} else {
private _area2 = +_area;
_area2 set [0, (_area2 select 0) * 2];
_area2 set [1, (_area2 select 1) * 2];
[_patrolGroup, _pos, _radius, 4, _area2, true] call FUNC(taskPatrol);
[_patrolGroup, _pos, _radius, 4, _area2, true, false, _teleport] call FUNC(taskPatrol);
};

// eventhandler
Expand Down
14 changes: 13 additions & 1 deletion addons/wp/functions/fnc_taskPatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
* 4: Area the AI Camps in, default [] <ARRAY>
* 5: Dynamic patrol pattern, default false <BOOL>
* 6: enable dynamic reinforcement <BOOL>
* 7: Teleport group <BOOL>
nk3nny marked this conversation as resolved.
Show resolved Hide resolved
*
* Return Value:
* none
Expand All @@ -32,7 +33,8 @@ params [
["_waypointCount", TASK_PATROL_WAYPOINTCOUNT, [0]],
["_area", [], [[]]],
["_moveWaypoints", TASK_PATROL_MOVEWAYPOINTS, [false]],
["_enableReinforcement", TASK_PATROL_ENABLEREINFORCEMENT, [false]]
["_enableReinforcement", TASK_PATROL_ENABLEREINFORCEMENT, [false]],
["_teleport", TASK_PATROL_TELEPORT, [false]]
];

// sort grp
Expand Down Expand Up @@ -118,6 +120,16 @@ if (_moveWaypoints) then {
_wp setWaypointStatements ["true", format ["if (local this) then {(group this) enableGunLights 'forceOn'; (group this) setCurrentWaypoint [(group this), %1];};", _fistWPId]];
};

// teleport to random waypoint position
if (_teleport) then {

private _teleportDestination = waypointPosition (selectRandom (waypoints _group));
{
(vehicle _x) setVehiclePosition [_teleportDestination, [], precision (vehicle _x), "NONE"];
} forEach units _group;

};

// debug
if (EGVAR(main,debug_functions)) then {
["%1 taskPatrol: %2 Patrols", side _group, groupId _group] call EFUNC(main,debugLog);
Expand Down
13 changes: 13 additions & 0 deletions addons/wp/modules.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,19 @@ class GVAR(TaskPatrol) : GVAR(BaseModule) {
typeName = "BOOL";
defaultValue = QUOTE(TASK_PATROL_ENABLEREINFORCEMENT);
};

class GVAR(Teleport): Checkbox {
displayName = CSTRING(Module_TaskGarrison_Teleport_DisplayName);
tooltip = CSTRING(Module_TaskGarrison_Teleport_Tooltip);
property = QGVAR(teleport);
unique = 0;
validate = "none";
condition = "0";
typeName = "BOOL";
defaultValue = QUOTE(TASK_PATROL_TELEPORT);
};


class ModuleDescription: ModuleDescription {};
};
class ModuleDescription: ModuleDescription {
Expand Down
1 change: 1 addition & 0 deletions addons/wp/script_component.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
#define TASK_PATROL_MOVEWAYPOINTS false
#define TASK_PATROL_SIZE 200
#define TASK_PATROL_ENABLEREINFORCEMENT false
#define TASK_PATROL_TELEPORT false

#define TASK_CREEP_MOVINGCENTER false
#define TASK_CREEP_PLAYERSONLY false
Expand Down
2 changes: 1 addition & 1 deletion addons/wp/stringtable.xml
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@
<Chinesesimp>传送单位</Chinesesimp>
</Key>
<Key ID="STR_Lambs_WP_Module_TaskGarrison_Teleport_Tooltip">
<English>Teleport units instantly to position</English>
<English>Teleport units instantly into position</English>
<Czech>Teleportovat jednotky ihned na pozice</Czech>
<German>Teleportiert Einheiten sofort zur Position</German>
<Polish>Teleportuj jednostki od razu na pozycje</Polish>
Expand Down
Loading