Skip to content

Commit

Permalink
update waypoint delete method
Browse files Browse the repository at this point in the history
Use forEachReversed introduced in Arma3 v2.14
  • Loading branch information
Apricot-ale committed Jul 18, 2024
1 parent db977ea commit 9fc67ee
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ if (alive _unit) then {
unAssignVehicle _unit;
};

while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
{doStop _x; _x doFollow leader _grp} foreach units _grp;

_possible_sectors = (KPLIB_sectors_all - KPLIB_sectors_player);
Expand Down
2 changes: 1 addition & 1 deletion Missionframework/scripts/server/ai/add_civ_waypoints.sqf
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
private _grp = _this select 0;
private _basepos = getpos (leader _grp);

while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
{doStop _x; _x doFollow leader _grp} foreach units _grp;

private _wpPositions = [
Expand Down
4 changes: 2 additions & 2 deletions Missionframework/scripts/server/ai/add_defense_waypoints.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (isNull _grp) exitWith {};
if (vehicle (leader _grp) == (leader _grp)) then {_is_infantry = true;};

sleep 5;
while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
sleep 1;
{doStop _x; _x doFollow leader _grp} foreach units _grp;
sleep 1;
Expand Down Expand Up @@ -63,7 +63,7 @@ waitUntil {
};

if (((units _grp) findIf {alive _x}) != -1) then {
while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0)};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
sleep 1;
{doStop _x; _x doFollow leader _grp} foreach units _grp;
sleep 1;
Expand Down
4 changes: 2 additions & 2 deletions Missionframework/scripts/server/ai/patrol_ai.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ while { count (units _grp) > 0 } do {

if ( reinforcements_sector_under_attack != "" ) then {

while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
{doStop _x; _x doFollow leader _grp} foreach units _grp;

_waypoint = _grp addWaypoint [markerpos reinforcements_sector_under_attack, 50];
Expand Down Expand Up @@ -39,7 +39,7 @@ while { count (units _grp) > 0 } do {
};
} foreach (KPLIB_sectors_all - KPLIB_sectors_player);

while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
{doStop _x; _x doFollow leader _grp} foreach units _grp;

{
Expand Down
4 changes: 2 additions & 2 deletions Missionframework/scripts/server/ai/troup_transport.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ if ((alive _transVeh) && (alive (driver _transVeh))) then {

{_x moveInCargo _transVeh} forEach (units _infGrp);

while {(count (waypoints _infGrp)) != 0} do {deleteWaypoint ((waypoints _infGrp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _infGrp;

sleep 3;

Expand All @@ -53,7 +53,7 @@ if ((alive _transVeh) && (alive (driver _transVeh))) then {

sleep 5;

while {(count (waypoints _transGrp)) != 0} do {deleteWaypoint ((waypoints _transGrp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _transGrp;

_transVehWp = _transGrp addWaypoint [_objPos, 100];
_transVehWp setWaypointType "SAD";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ if (_incDir < 23) then {
private _spawnedGroups = [];
private _grp = [_startpos] call KPLIB_fnc_spawnGuerillaGroup;

while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
{doStop _x; _x doFollow leader _grp} foreach units _grp;

private _waypoint = _grp addWaypoint [markerpos _sector, 100];
Expand Down
2 changes: 1 addition & 1 deletion Missionframework/scripts/server/battlegroup/spawn_air.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for "_i" from 1 to _planes_number do {
sleep 1;
};

while {!((waypoints _grp) isEqualTo [])} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
sleep 1;
{_x doFollow leader _grp} forEach (units _grp);
sleep 1;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ while { KPLIB_endgame == 0 } do {

};

while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
{doStop _x; _x doFollow leader _grp} foreach units _grp;

{
Expand Down
4 changes: 2 additions & 2 deletions Missionframework/scripts/server/secondary/convoy_hijack.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ _convoy_group setBehaviour "SAFE";
_convoy_group setCombatMode "GREEN";
_convoy_group setSpeedMode "LIMITED";

while {(count (waypoints _convoy_group)) != 0} do {deleteWaypoint ((waypoints _convoy_group) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _convoy_group;
{doStop _x; _x doFollow leader _convoy_group} foreach units _convoy_group;

_waypoint = _convoy_group addWaypoint [_convoy_destinations select 1, 0];
Expand Down Expand Up @@ -124,7 +124,7 @@ while { _mission_in_progress } do {
private _troop_driver_group = createGroup [KPLIB_side_enemy, true];
[ driver _troop_vehicle ] joinSilent _troop_driver_group;
sleep 1;
while {(count (waypoints _troop_driver_group)) != 0} do {deleteWaypoint ((waypoints _troop_driver_group) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _troop_driver_group;
_waypoint = _troop_driver_group addWaypoint [getpos _troop_vehicle, 0];
_waypoint setWaypointType "MOVE";
sleep 3;
Expand Down
2 changes: 1 addition & 1 deletion Missionframework/scripts/server/secondary/fob_hunting.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ for [{_idx=0}, {_idx < _sentryMax}, {_idx=_idx+1}] do {
[KPLIB_o_sentry, _base_sentry_pos, _grpsentry, "PRIVATE", 0.5] call KPLIB_fnc_createManagedUnit;
};

while {(count (waypoints _grpsentry)) != 0} do {deleteWaypoint ((waypoints _grpsentry) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grpsentry;
private _waypoint = [];
{
_waypoint = _grpsentry addWaypoint [[((_base_position select 0) + (_x select 0)), ((_base_position select 1) + (_x select 1)), 0], -1];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ private _patrolcorners = [
[_x, _patrolcorners select 0, _grppatrol, "PRIVATE", 0.5] call KPLIB_fnc_createManagedUnit;
} foreach ([] call KPLIB_fnc_getSquadComp);

while {(count (waypoints _grppatrol)) != 0} do {deleteWaypoint ((waypoints _grppatrol) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grppatrol;
{
private _nextcorner = _x;
_waypoint = _grppatrol addWaypoint [_nextcorner,0];
Expand Down Expand Up @@ -105,7 +105,7 @@ if ( _alive_crew_count == 0 ) then {
[8] remoteExec ["remote_call_intel"];
private _grp = createGroup [KPLIB_side_player, true];
{ [_x ] joinSilent _grp; } foreach _pilotUnits;
while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{ deleteWaypoint _x } forEachReversed waypoints _grp;
{doStop _x; _x doFollow leader _grp} foreach units _grp;
{ [ _x ] spawn {
sleep 600;
Expand Down

0 comments on commit 9fc67ee

Please sign in to comment.