Skip to content

Commit

Permalink
Handle reinforcement convoy for active sector
Browse files Browse the repository at this point in the history
  • Loading branch information
Wyqer committed Feb 23, 2019
1 parent 1e9bc31 commit 579cc04
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ private _heavyVeh = [];

// Despawn garrison light vehicles
{
if ((alive _x) && !((crew _x) isEqualTo []) && !(_x getVariable ["KPLIB_captured", false])) then {
if ((alive _x) && !((crew _x) isEqualTo []) && !(_x getVariable ["KPLIB_captured", false]) && !(_x in (KPLIB_preset_vehTransPlE + KPLIB_preset_vehLightUnarmedPlE))) then {
_vehicle = _x;
_lightVeh pushBack (typeOf _x);
{_handledCrew pushBack _x; _vehicle deleteVehicleCrew _x;} forEach (crew _x);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
File: fn_garrison_getGarrison.sqf
Author: KP Liberation Dev Team - https://github.com/KillahPotatoes
Date: 2018-10-24
Last Update: 2018-11-18
Last Update: 2019-02-23
License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html
Description:
Expand All @@ -27,7 +27,7 @@ private _array = [KPLIB_garrison_array, KPLIB_garrison_active] select _active;
private _index = (_array findIf {_x select 0 == _sector});

if(_index isEqualTo -1) then {
[[], [], [], [], []]
[]
} else {
_array select _index
}
36 changes: 31 additions & 5 deletions Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,37 @@ private _grp = group (_units select 0);
// !DEBUG!
hint format ["Arrived: %1\nUnits: %2\nDestination: %3 (%4)", units _grp, _units, markerText _destination, _destination];

[_destination, count _units] call KPLIB_fnc_garrison_addInfantry;
private _garrisonRef = [_destination, true] call KPLIB_fnc_garrison_getGarrison;

{
deleteVehicle (vehicle _x);
deleteVehicle _x;
} forEach (units _grp);
if (_garrisonRef isEqualTo []) then {
// Delete units and add to garrison, if sector isn't active
[_destination, count _units] call KPLIB_fnc_garrison_addInfantry;
{
deleteVehicle (vehicle _x);
deleteVehicle _x;
} forEach (units _grp);
} else {
// Add infantry and vehicles to active garrison array for a possible later despawn
{
private _parent = objectParent _x;

// Assign to active garrison arrays according to arrived type of reinforcement
switch (true) do {
case ((typeOf _parent) in KPLIB_preset_vehLightArmedPlE): {(_garrisonRef select 3) pushBackUnique _parent;};
case ((typeOf _parent) in (KPLIB_preset_vehHeavyApcPlE + KPLIB_preset_vehHeavyPlE)): {(_garrisonRef select 4) pushBackUnique _parent;};
default {
(_garrisonRef select 2) pushBackUnique _x;
// If it's infantry with a transport vehicle, let them disembark
if !(isNull _parent) then {
_grp leaveVehicle _parent;
(_garrisonRef select 3) pushBackUnique _parent;
};
};
};
} forEach (units _grp);

// Add patrol task to arrived group
[_grp, markerPos _destination, 150, 3, 1, 0.6] call CBA_fnc_taskDefend;
};

true

0 comments on commit 579cc04

Please sign in to comment.