initial files

This commit is contained in:
Samuele Lorefice
2025-05-24 16:17:33 +02:00
commit 9e023649ac
477 changed files with 118566 additions and 0 deletions

View File

@@ -0,0 +1,63 @@
waitUntil {!isNil "save_is_loaded"};
waitUntil {!isNil "KP_liberation_civ_rep"};
waitUntil {save_is_loaded};
if (KP_liberation_asymmetric_debug > 0) then {[format ["Loop spawned on: %1", debug_source], "ASYMMETRIC"] call KPLIB_fnc_log;};
KP_liberation_asymmetric_sectors = [];
while {GRLIB_endgame == 0} do {
private _sectors_to_remove = [];
{
if (!(_x in blufor_sectors) || (KP_liberation_civ_rep > -25)) then {
_sectors_to_remove pushBack _x;
};
} forEach KP_liberation_asymmetric_sectors;
KP_liberation_asymmetric_sectors = KP_liberation_asymmetric_sectors - _sectors_to_remove;
if (KP_liberation_civ_rep <= -25) then {
{
private _sector = _x;
private _blocked = false;
private _units_at_sector = [markerPos _sector, GRLIB_sector_size, GRLIB_side_friendly] call KPLIB_fnc_getUnitsCount;
{
if ((_x select 0) == _sector) exitWith {
if ((((_x select 1) + 1800) < time) && (_units_at_sector == 0)) then {
asymm_blocked_sectors = asymm_blocked_sectors - [_x];
if (KP_liberation_asymmetric_debug > 0) then {[format ["Sector %1 removed from blocked sectors", markerText (_x select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
} else {
_blocked = true;
if (KP_liberation_asymmetric_debug > 0) then {[format ["Sector %1 still blocked for ambush", markerText (_x select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
};
};
} forEach asymm_blocked_sectors;
if ((_units_at_sector > 0) && !(_sector in KP_liberation_asymmetric_sectors) && !_blocked) then {
KP_liberation_asymmetric_sectors pushBack _sector;
if ((random 100) <= KP_liberation_resistance_ambush_chance) then {
private _hc = [] call KPLIB_fnc_getLessLoadedHC;
private _ieds = round (([] call KPLIB_fnc_crGetMulti) * GRLIB_difficulty_modifier);
if (isNull _hc) then {
[_sector, _ieds] spawn manage_asymIED;
[_sector] spawn asym_sector_ambush;
} else {
[_sector, _ieds] remoteExec ["manage_asymIED", _hc];
[_sector] remoteExec ["asym_sector_ambush",_hc];
};
};
};
if (!(_units_at_sector > 0) && (_sector in KP_liberation_asymmetric_sectors)) then {
KP_liberation_asymmetric_sectors = KP_liberation_asymmetric_sectors - [_sector];
};
} forEach ((sectors_capture + sectors_bigtown) select {_x in blufor_sectors});
};
publicVariable "KP_liberation_asymmetric_sectors";
publicVariable "asymm_blocked_sectors";
sleep 10;
};

View File

@@ -0,0 +1,140 @@
params ["_convoy"];
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1: spawning ambush", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
private _pos = [0,0,0];
switch ((_convoy select 7)) do {
case 2: {_pos = (_convoy select 3) getPos [(_convoy select 8) * 400, (_convoy select 3) getDir (_convoy select 2)]};
case 4: {_pos = (_convoy select 2) getPos [(_convoy select 8) * 400, (_convoy select 2) getDir (_convoy select 3)]};
default {[format ["Logistic convoy %1 ambush: convoy is not travelling", (_convoy select 0)], "ERROR"] call KPLIB_fnc_log;};
};
if (_pos isEqualTo [0,0,0]) exitWith {[format ["Logistic convoy %1 ambush: no position", (_convoy select 0)], "ERROR"] call KPLIB_fnc_log;};
private _roadObj = [_pos, 400, []] call BIS_fnc_nearestRoad;
if (isNull _roadObj) exitWith {
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1 ambush: no road near current convoy position", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
KP_liberation_convoy_ambush_check = 1;
};
KP_liberation_convoy_ambush_check = 2;
KP_liberation_convoy_ambush_inProgress = true;
[0, getPos _roadObj] remoteExec ["asymm_notifications"];
private _vehicleArray = [];
for "_i" from 1 to (_convoy select 1) do {
private _veh = createVehicle [KP_liberation_truck_classname, getPos _roadObj, [], 50, "NONE"];
_veh setDir (getDir _roadObj);
{
private _damage = random 0.6;
if ((_x find "Wheel") != -1) then {
_damage = _damage + 0.6;
} else {
_damage = _damage + 0.3;
};
if (_damage > 1) then {_damage = 1.0};
_veh setHitPointDamage [_x, _damage];
} forEach ((getAllHitPointsDamage _veh) select 0);
_vehicleArray pushBack _veh;
private _driver = createVehicle [crewman_classname, getPos _veh, [], 12, "NONE"];
_driver setDamage 1;
};
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1 ambush: truck spawning done", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
private _supplies = (_convoy select 6) select 0;
private _ammo = (_convoy select 6) select 1;
private _fuel = (_convoy select 6) select 2;
private _crateArray = [];
while {_supplies > 0} do {
private _amount = 100;
if ((_supplies / 100) < 1) then {
_amount = _supplies;
};
_supplies = _supplies - _amount;
private _crate = [KP_liberation_supply_crate, _amount, getPos _roadObj] call KPLIB_fnc_createCrate;
_crate setPos (_crate getPos [random 60, random 360]);
_crateArray pushBack [_crate];
};
while {_ammo > 0} do {
private _amount = 100;
if ((_ammo / 100) < 1) then {
_amount = _ammo;
};
_ammo = _ammo - _amount;
private _crate = [KP_liberation_ammo_crate, _amount, getPos _roadObj] call KPLIB_fnc_createCrate;
_crate setPos (_crate getPos [random 60, random 360]);
_crateArray pushBack [_crate];
};
while {_fuel > 0} do {
private _amount = 100;
if ((_fuel / 100) < 1) then {
_amount = _fuel;
};
_fuel = _fuel - _amount;
private _crate = [KP_liberation_fuel_crate, _amount, getPos _roadObj] call KPLIB_fnc_createCrate;
_crate setPos (_crate getPos [random 60, random 360]);
_crateArray pushBack [_crate];
};
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1 ambush: resource spawning done", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
private _grp = [getPos _roadObj] call KPLIB_fnc_spawnGuerillaGroup;
private _waypoint = _grp addWaypoint [getPos _roadObj, 150];
_waypoint setWaypointType "SAD";
_waypoint setWaypointCompletionRadius 10;
_waypoint = _grp addWaypoint [getPos _roadObj, 150];
_waypoint setWaypointType "SAD";
_waypoint setWaypointCompletionRadius 10;
_waypoint = _grp addWaypoint [getPos _roadObj, 150];
_waypoint setWaypointType "SAD";
_waypoint setWaypointCompletionRadius 10;
_waypoint = _grp addWaypoint [getPos _roadObj, 150];
_waypoint setWaypointType "CYCLE";
_waypoint setWaypointCompletionRadius 10;
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1 ambush: guerillas spawning done", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
private _waitingTime = KP_liberation_convoy_ambush_duration;
while {(({alive _x} count (units _grp)) > 0) && (_waitingTime > 0)} do {
uiSleep 1;
private _player_near = false;
{
if (((_x distance _roadObj) < 250) && (alive _x)) exitWith {_player_near = true};
} foreach allPlayers;
if !(_player_near) then {
_waitingTime = _waitingTime - 1;
};
};
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1 ambush: ambush finished", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
KP_liberation_convoy_ambush_inProgress = false;
if ((_waitingTime <= 0) && (({alive _x} count (units _grp)) > 0)) then {
[2] remoteExec ["asymm_notifications"];
private _gain = 0;
{
if (alive _x) then {
deleteVehicle _x;
_gain = _gain + 2;
};
} forEach (units _grp);
{
if ((typeOf (_x select 0)) == KP_liberation_ammo_crate) then {
_gain = _gain + 3;
} else {
_gain = _gain + 2;
};
deleteVehicle (_x select 0);
} forEach _crateArray;
KP_liberation_guerilla_strength = KP_liberation_guerilla_strength + _gain;
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1 ambush: guerillas escaped", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
} else {
[1] remoteExec ["asymm_notifications"];
if (KP_liberation_asymmetric_debug > 0) then {[format ["Logistic convoy %1 ambush: guerillas defeated", (_convoy select 0)], "ASYMMETRIC"] call KPLIB_fnc_log;};
};

View File

@@ -0,0 +1,51 @@
params ["_sector", "_count"];
if (_count <= 0) exitWith {};
if (KP_liberation_asymmetric_debug > 0) then {[format ["manage_asymIED.sqf for %1 spawned on: %2", markerText _sector, debug_source], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
waitUntil {sleep 1; _sector in KP_liberation_asymmetric_sectors};
if (KP_liberation_asymmetric_debug > 0) then {[format ["manage_asymIED.sqf -> spawning IED %1 at %2", _count, markerText _sector], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
private _activation_radius_infantry = 6.66;
private _activation_radius_vehicles = 10;
private _spread = 7;
private _infantry_trigger = 1 + (ceil (random 2));
private _vehicle_trigger = 1;
private _ied_type = selectRandom ["IEDLandBig_F","IEDLandSmall_F","IEDUrbanBig_F","IEDUrbanSmall_F"];
private _ied_obj = objNull;
private _roadobj = [(markerPos (_sector) getPos [random (200), random (360)]), 200, []] call BIS_fnc_nearestRoad;
private _goes_boom = false;
private _ied_marker = "";
if (_count > 0) then {
[_sector, _count - 1] spawn manage_asymIED;
};
if (!(isnull _roadobj)) then {
private _roadpos = getpos _roadobj;
_ied_obj = createMine [_ied_type, _roadpos getPos [_spread, random (360)], [], 0];
_ied_obj setdir (random 360);
if (KP_liberation_asymmetric_debug > 0) then {[format ["manage_asymIED.sqf -> IED %1 spawned at %2", _count, markerText _sector], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
while {(_sector in KP_liberation_asymmetric_sectors) && (mineActive _ied_obj) && !_goes_boom} do {
_nearinfantry = ((getpos _ied_obj) nearEntities ["Man", _activation_radius_infantry]) select {side _x == GRLIB_side_friendly};
_nearvehicles = ((getpos _ied_obj) nearEntities [["Car", "Tank", "Air"], _activation_radius_vehicles]) select {side _x == GRLIB_side_friendly};
if (count _nearinfantry >= _infantry_trigger || count _nearvehicles >= _vehicle_trigger) then {
_ied_obj setDamage 1;
stats_ieds_detonated = stats_ieds_detonated + 1; publicVariable "stats_ieds_detonated";
_goes_boom = true;
};
sleep 1;
};
} else {
if (KP_liberation_asymmetric_debug > 0) then {[format ["manage_asymIED.sqf -> _roadobj is Null for IED %1 at %2", _count, markerText _sector], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
};
if ((KP_liberation_asymmetric_debug > 0) && !(isNull _roadobj)) then {[format ["manage_asymIED.sqf -> exit IED %1 loop at %2", _count, markerText _sector], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
sleep 60;
if (!(isNull _ied_obj)) then {deleteVehicle _ied_obj;};

View File

@@ -0,0 +1,17 @@
// Scripts
// Logistic convoy ambush
logistic_convoy_ambush = compileFinal preprocessFileLineNumbers "scripts\server\asymmetric\convoy\logistic_convoy_ambush.sqf";
// IED spawner for blufor sectors
manage_asymIED = compileFinal preprocessFileLineNumbers "scripts\server\asymmetric\ied\manage_asymIED.sqf";
// Spawner for guerilla ambushes in blufor sectors
asym_sector_ambush = compileFinal preprocessFileLineNumbers "scripts\server\asymmetric\random\asym_sector_ambush.sqf";
// Spawner for guerilla forces who join a fight at an opfor sector
sector_guerilla = compileFinal preprocessFileLineNumbers "scripts\server\asymmetric\random\sector_guerilla.sqf";
// Globals
// List sectors which are just liberated. Preventing direct ambush spawn.
asymm_blocked_sectors = [];
publicVariable "asymm_blocked_sectors";
// Start module loop
execVM "scripts\server\asymmetric\asymmetric_loop.sqf";

View File

@@ -0,0 +1,74 @@
params ["_sector"];
if (KP_liberation_asymmetric_debug > 0) then {[format ["asym_sector_ambush.sqf for %1 spawned on: %2 - Time: %3", markerText _sector, debug_source, diag_tickTime], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
waitUntil {sleep 1; _sector in KP_liberation_asymmetric_sectors};
private _buildings = (nearestObjects [(markerPos _sector), ["House"], 75]) select {(alive _x) && !((typeOf _x) in KP_liberation_cr_ign_buildings)};
private _positions = [];
{
_positions = _positions + ([_x] call BIS_fnc_buildingPositions);
} forEach _buildings;
if (KP_liberation_asymmetric_debug > 0) then {[format ["asym_sector_ambush.sqf -> Found %1 suitable buildings in %2 - Time: %3", count _buildings, markerText _sector, diag_tickTime], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
private _position_indexes = [];
private _position_count = count _positions;
while {count _position_indexes < 10} do {
private _nextposit = floor (random _position_count);
if !(_nextposit in _position_indexes) then {
_position_indexes pushback _nextposit;
};
};
private _grp = [(markerPos _sector)] call KPLIB_fnc_spawnGuerillaGroup;
_grp setBehaviour "STEALTH";
private _idxposit = 0;
{
_x setpos (_positions select (_position_indexes select _idxposit));
_x setUnitPos "UP";
doStop _x;
_idxposit = _idxposit + 1;
} forEach (units _grp);
if (KP_liberation_asymmetric_debug > 0) then {[format ["asym_sector_ambush.sqf -> Units spawned in %1 - Time: %2", markerText _sector, diag_tickTime], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
private _attack = false;
while {(_sector in KP_liberation_asymmetric_sectors) && (!isNull _grp)} do {
private _blufor_near = {alive _x && side _x == GRLIB_side_friendly} count ((getpos (leader _grp)) nearEntities [["LAND"], 140]);
if ((_blufor_near > 0) && !_attack) then {
_attack = true;
{
_x setUnitPos "AUTO";
} forEach (units _grp);
(units _grp) doFollow (leader _grp);
_grp setBehaviour "COMBAT";
_grp setCombatMode "RED";
private _waypoint = _grp addWaypoint [markerpos _sector, 20];
_waypoint setWaypointType "SAD";
_waypoint setWaypointSpeed "FULL";
_waypoint = _grp addWaypoint [markerpos _sector, 150];
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 150];
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 150];
_waypoint setWaypointType "SAD";
};
sleep 1;
};
if (KP_liberation_asymmetric_debug > 0) then {[format ["asym_sector_ambush.sqf -> Exit Loop in %1 - Time: %2", markerText _sector, diag_tickTime], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
sleep 60;
if (!isNull _grp) then {
{
if (alive _x) then {
deleteVehicle _x;
};
} forEach (units _grp);
};
if (KP_liberation_asymmetric_debug > 0) then {[format ["asym_sector_ambush.sqf -> Ambush dropped in %1 - Time: %2", markerText _sector, diag_tickTime], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};

View File

@@ -0,0 +1,131 @@
params ["_sector"];
if (KP_liberation_asymmetric_debug > 0) then {[format ["Sector %1 (%2) - sector_guerilla spawned on: %3", (markerText _sector), _sector, debug_source], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};
private _startpos = (markerPos _sector) getPos [(1200 + (round (random 400))), (random 360)];
while {(([_startpos, 500, GRLIB_side_friendly] call KPLIB_fnc_getUnitsCount) > 0) || (surfaceIsWater _startpos)} do {
_startpos = (markerPos _sector) getPos [(1200 + (round (random 400))), (random 360)];
};
private _incDir = (markerPos _sector) getDir _startpos;
private _incString = "unknown";
if (_incDir < 23) then {
_incString = "N";
} else {
if (_incDir < 68) then {
_incString = "NE";
} else {
if (_incDir < 113) then {
_incString = "E";
} else {
if (_incDir < 158) then {
_incString = "SE";
} else {
if (_incDir < 203) then {
_incString = "S";
} else {
if (_incDir < 248) then {
_incString = "SW";
} else {
if (_incDir < 293) then {
_incString = "W";
} else {
if (_incDir < 338) then {
_incString = "NW";
} else {
_incString = "N";
};
};
};
};
};
};
};
};
[5, [(markerText _sector), _incString]] remoteExec ["KPLIB_fnc_crGlobalMsg"];
private _spawnedGroups = [];
private _grp = [_startpos] call KPLIB_fnc_spawnGuerillaGroup;
while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);};
{_x doFollow (leader _grp)} forEach (units _grp);
private _waypoint = _grp addWaypoint [markerpos _sector, 100];
_waypoint setWaypointType "MOVE";
_waypoint setWaypointSpeed "FULL";
_waypoint setWaypointBehaviour "AWARE";
_waypoint setWaypointCombatMode "YELLOW";
_waypoint setWaypointCompletionRadius 30;
_waypoint = _grp addWaypoint [markerpos _sector, 200];
_waypoint setWaypointSpeed "NORMAL";
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 200];
_waypoint setWaypointSpeed "NORMAL";
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 200];
_waypoint setWaypointSpeed "NORMAL";
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 200];
_waypoint setWaypointSpeed "NORMAL";
_waypoint setWaypointType "CYCLE";
_spawnedGroups pushBack _grp;
sleep 30;
if (((random 100) <= 25) && !(KP_liberation_guerilla_vehicles isEqualTo [])) then {
private _vehicle = (selectRandom KP_liberation_guerilla_vehicles) createVehicle _startpos;
[_vehicle] call KPLIB_fnc_allowCrewInImmobile;
private _grp = [_startpos, 2] call KPLIB_fnc_spawnGuerillaGroup;
((units _grp) select 0) moveInDriver _vehicle;
((units _grp) select 1) moveInGunner _vehicle;
_waypoint = _grp addWaypoint [markerpos _sector, 100];
_waypoint setWaypointType "MOVE";
_waypoint setWaypointSpeed "LIMITED";
_waypoint setWaypointBehaviour "AWARE";
_waypoint setWaypointCombatMode "YELLOW";
_waypoint setWaypointCompletionRadius 30;
_waypoint = _grp addWaypoint [markerpos _sector, 300];
_waypoint setWaypointSpeed "LIMITED";
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 300];
_waypoint setWaypointSpeed "LIMITED";
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 300];
_waypoint setWaypointSpeed "LIMITED";
_waypoint setWaypointType "SAD";
_waypoint = _grp addWaypoint [markerpos _sector, 300];
_waypoint setWaypointSpeed "LIMITED";
_waypoint setWaypointType "CYCLE";
_spawnedGroups pushBack _grp;
};
waitUntil {sleep 60; !(_sector in active_sectors)};
sleep 60;
private _strengthChanged = false;
{
if (!isNull _x) then {
{
if (alive _x) then {
deleteVehicle _x;
KP_liberation_guerilla_strength = KP_liberation_guerilla_strength + 2;
_strengthChanged = true;
};
} forEach (units _x);
};
} forEach _spawnedGroups;
if (!isServer && _strengthChanged) then {
publicVariableServer "KP_liberation_guerilla_strength";
};
if (KP_liberation_asymmetric_debug > 0) then {[format ["Sector %1 (%2) - sector_guerilla dropped on: %3", (markerText _sector), _sector, debug_source], "ASYMMETRIC"] remoteExecCall ["KPLIB_fnc_log", 2];};