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,18 @@
GRLIB_conflicting_objects = [];
GRLIB_buildoverlay_icon = "\A3\ui_f\data\map\markers\handdrawn\objective_CA.paa";
GRLIB_buildoverlay_color = [ 1, 0, 0, 1 ];
GRLIB_buildoverlay_cfg = configFile >> "cfgVehicles";
["build_overlay", "onEachFrame", {
if ( build_confirmed == 1 ) then {
if ( count GRLIB_conflicting_objects > 0 ) then {
{
if ( alive _x ) then {
drawIcon3D [ GRLIB_buildoverlay_icon, GRLIB_buildoverlay_color, [ (getpos _x) select 0, (getpos _x) select 1, 1.5],
1, 1, 0, format [ "%1", getText (GRLIB_buildoverlay_cfg >> typeof _x >> "displayName") ], 2, 0.04, "puristaMedium"];
};
} foreach GRLIB_conflicting_objects;
};
};
}] call BIS_fnc_addStackedEventHandler;

View File

@@ -0,0 +1,373 @@
// TODO This needs absolutely a code refactoring, flamethrower or nuke
private [ "_maxdist", "_truepos", "_built_object_remote", "_pos", "_grp", "_classname", "_idx", "_unitrank", "_posfob", "_ghost_spot", "_vehicle", "_dist", "_actualdir", "_near_objects", "_near_objects_25", "_debug_colisions" ];
build_confirmed = 0;
_maxdist = GRLIB_fob_range;
_truepos = [];
_debug_colisions = false;
KP_vector = true;
private _object_spheres = [];
private _fob_spheres = [];
for "_i" from 1 to 36 do {
_object_spheres pushBack ("Sign_Sphere100cm_F" createVehicleLocal [0, 0, 0]);
_fob_spheres pushBack ("Sign_Sphere100cm_F" createVehicleLocal [0, 0, 0]);
};
{ _x setObjectTexture [0, "#(rgb,8,8,3)color(0,1,0,1)"]; } foreach _object_spheres;
if (isNil "manned") then { manned = false };
if (isNil "gridmode" ) then { gridmode = 0 };
if (isNil "repeatbuild" ) then { repeatbuild = false };
if (isNil "build_rotation" ) then { build_rotation = 0 };
if (isNil "build_elevation" ) then { build_elevation = 0 };
waitUntil { sleep 0.2; !isNil "dobuild" };
while { true } do {
waitUntil { sleep 0.2; dobuild != 0 };
build_confirmed = 1;
build_invalid = 0;
_classname = "";
if ( buildtype == 99 ) then {
_classname = FOB_typename;
} else {
_classname = ((KPLIB_buildList select buildtype) select buildindex) select 0;
_price_s = ((KPLIB_buildList select buildtype) select buildindex) select 1;
_price_a = ((KPLIB_buildList select buildtype) select buildindex) select 2;
_price_f = ((KPLIB_buildList select buildtype) select buildindex) select 3;
_nearfob = [] call KPLIB_fnc_getNearestFob;
_storage_areas = (_nearfob nearobjects (GRLIB_fob_range * 2)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0};
[_price_s, _price_a, _price_f, _classname, buildtype, _storage_areas] remoteExec ["build_remote_call",2];
};
if(buildtype == 1) then {
_pos = [(getpos player select 0) + 1,(getpos player select 1) + 1, 0];
_grp = group player;
if ( manned ) then {
_grp = createGroup GRLIB_side_friendly;
};
_classname createUnit [_pos, _grp,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]", 0.5, "private"];
build_confirmed = 0;
} else {
if ( buildtype == 8 ) then {
_pos = [(getpos player select 0) + 1,(getpos player select 1) + 1, 0];
_grp = createGroup GRLIB_side_friendly;
_grp setGroupId [format ["%1 %2",squads_names select buildindex, groupId _grp]];
_idx = 0;
{
_unitrank = "private";
if(_idx == 0) then { _unitrank = "sergeant"; };
if(_idx == 1) then { _unitrank = "corporal"; };
if (_classname isEqualTo blufor_squad_para) then {
_x createUnit [_pos, _grp,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}]; removeBackpackGlobal this; this addBackpackGlobal ""B_parachute""", 0.5, _unitrank];
} else {
_x createUnit [_pos, _grp,"this addMPEventHandler [""MPKilled"", {_this spawn kill_manager}];", 0.5, _unitrank];
};
_idx = _idx + 1;
} foreach _classname;
_grp setBehaviour "SAFE";
build_confirmed = 0;
} else {
_posfob = getpos player;
if (buildtype != 99) then {
_posfob = [] call KPLIB_fnc_getNearestFob;
};
_idactcancel = -1;
_idactsnap = -1;
_idactplacebis = -1;
_idactvector = -1;
if (buildtype != 99 ) then {
_idactcancel = player addAction ["<t color='#B0FF00'>" + localize "STR_CANCEL" + "</t> <img size='2' image='res\ui_cancel.paa'/>",{build_confirmed = 3; GRLIB_ui_notif = ""; hint localize "STR_CANCEL_HINT";},"",-725,false,true,"","build_confirmed == 1"];
};
if (buildtype == 6 ) then {
_idactplacebis = player addAction ["<t color='#B0FF00'>" + localize "STR_PLACEMENT_BIS" + "</t> <img size='2' image='res\ui_confirm.paa'/>",{build_confirmed = 2; repeatbuild = true; hint localize "STR_CONFIRM_HINT";},"",-785,false,false,"","build_invalid == 0 && build_confirmed == 1"];
};
if (buildtype == 6 || buildtype == 99 || (toLower _classname) in KPLIB_storageBuildings || _classname isEqualTo KP_liberation_recycle_building || _classname isEqualTo KP_liberation_air_vehicle_building) then {
_idactsnap = player addAction ["<t color='#B0FF00'>" + localize "STR_GRID" + "</t>",{gridmode = gridmode + 1;},"",-735,false,false,"","build_confirmed == 1"];
_idactvector = player addAction ["<t color='#B0FF00'>" + localize "STR_VECACTION" + "</t>",{KP_vector = !KP_vector;},"",-800,false,false,"","build_confirmed == 1"];
};
_idactrotate = player addAction ["<t color='#B0FF00'>" + localize "STR_ROTATION" + "</t> <img size='2' image='res\ui_rotation.paa'/>",{build_rotation = build_rotation + 90;},"",-750,false,false,"","build_confirmed == 1"];
_idactraise = player addAction ["<t color='#B0FF00'>" + localize "STR_RAISE" + "</t>",{build_elevation = build_elevation + 0.2;},"",-765,false,false,"","build_confirmed == 1"];
_idactlower = player addAction ["<t color='#B0FF00'>" + localize "STR_LOWER" + "</t>",{build_elevation = build_elevation - 0.2;},"",-766,false,false,"","build_confirmed == 1"];
_idactplace = player addAction ["<t color='#B0FF00'>" + localize "STR_PLACEMENT" + "</t> <img size='2' image='res\ui_confirm.paa'/>",{build_confirmed = 2; hint localize "STR_CONFIRM_HINT";},"",-775,false,true,"","build_invalid == 0 && build_confirmed == 1"];
_ghost_spot = (markerPos "ghost_spot") findEmptyPosition [0,100];
_vehicle = _classname createVehicleLocal _ghost_spot;
_vehicle allowdamage false;
_vehicle setVehicleLock "LOCKED";
_vehicle enableSimulationGlobal false;
_vehicle setVariable ["KP_liberation_preplaced", true, true];
_dist = 0.6 * (sizeOf _classname);
if (_dist < 3.5) then { _dist = 3.5 };
_dist = _dist + 1;
for [{_i=0}, {_i<5}, {_i=_i+1}] do {
_vehicle setObjectTextureGlobal [_i, '#(rgb,8,8,3)color(0,1,0,0.8)'];
};
{_x setObjectTexture [0, "#(rgb,8,8,3)color(0,1,0,1)"];} foreach _object_spheres;
while { build_confirmed == 1 && alive player } do {
_truedir = 90 - (getdir player);
if ((toLower (typeOf _vehicle)) in KPLIB_b_static_classes) then {
_truepos = [((getposATL player) select 0) + (_dist * (cos _truedir)), ((getposATL player) select 1) + (_dist * (sin _truedir)),((getposATL player) select 2)];
} else {
_truepos = [((getpos player) select 0) + (_dist * (cos _truedir)), ((getpos player) select 1) + (_dist * (sin _truedir)),0];
};
_actualdir = ((getdir player) + build_rotation);
if ( _classname == "Land_Cargo_Patrol_V1_F" || _classname == "Land_PortableLight_single_F" ) then { _actualdir = _actualdir + 180 };
if ( _classname == FOB_typename ) then { _actualdir = _actualdir + 270 };
while { _actualdir > 360 } do { _actualdir = _actualdir - 360 };
while { _actualdir < 0 } do { _actualdir = _actualdir + 360 };
if ( ((buildtype == 6) || (buildtype == 99)) && ((gridmode % 2) == 1) ) then {
if ( _actualdir >= 22.5 && _actualdir <= 67.5 ) then { _actualdir = 45 };
if ( _actualdir >= 67.5 && _actualdir <= 112.5 ) then { _actualdir = 90 };
if ( _actualdir >= 112.5 && _actualdir <= 157.5 ) then { _actualdir = 135 };
if ( _actualdir >= 157.5 && _actualdir <= 202.5 ) then { _actualdir = 180 };
if ( _actualdir >= 202.5 && _actualdir <= 247.5 ) then { _actualdir = 225 };
if ( _actualdir >= 247.5 && _actualdir <= 292.5 ) then { _actualdir = 270 };
if ( _actualdir >= 292.5 && _actualdir <= 337.5 ) then { _actualdir = 315 };
if ( _actualdir <= 22.5 || _actualdir >= 337.5 ) then { _actualdir = 0 };
};
{
_x setPos (_truepos getPos [_dist, 10 * _forEachIndex]);
} foreach _object_spheres;
if !(buildtype isEqualTo 99) then {
{
_x setPos (_posfob getPos [GRLIB_fob_range, 10 * _forEachIndex])
} forEach _fob_spheres;
};
_vehicle setdir _actualdir;
_truepos = [_truepos select 0, _truepos select 1, (_truepos select 2) + build_elevation];
_near_objects = (_truepos nearobjects ["AllVehicles", _dist]) ;
_near_objects = _near_objects + (_truepos nearobjects [FOB_box_typename, _dist]);
_near_objects = _near_objects + (_truepos nearobjects [Arsenal_typename, _dist]);
_near_objects_25 = (_truepos nearobjects ["AllVehicles", 50]) ;
_near_objects_25 = _near_objects_25 + (_truepos nearobjects [FOB_box_typename, 50]);
_near_objects_25 = _near_objects_25 + (_truepos nearobjects [Arsenal_typename, 50]);
if( buildtype != 6 ) then {
_near_objects = _near_objects + (_truepos nearobjects ["Static", _dist]);
_near_objects_25 = _near_objects_25 + (_truepos nearobjects ["Static", 50]);
};
private _remove_objects = [];
{
private _typeOfX = typeOf _x;
if ((_x isKindOf "Animal") || (_typeOfX in GRLIB_ignore_colisions_when_building) || (_typeOfX isKindOf "CAManBase") || (isPlayer _x) || (_x == _vehicle) || ((toLower (typeOf _vehicle)) in KPLIB_b_static_classes)) then {
_remove_objects pushback _x;
};
} foreach _near_objects;
private _remove_objects_25 = [];
{
private _typeOfX = typeOf _x;
if ((_x isKindOf "Animal") || (_typeOfX in GRLIB_ignore_colisions_when_building) || (_typeOfX isKindOf "CAManBase") || (isPlayer _x) || (_x == _vehicle) || ((toLower (typeOf _vehicle)) in KPLIB_b_static_classes)) then {
_remove_objects_25 pushback _x;
};
} foreach _near_objects_25;
_near_objects = _near_objects - _remove_objects;
_near_objects_25 = _near_objects_25 - _remove_objects_25;
if ( count _near_objects == 0 ) then {
{
_dist22 = 0.6 * (sizeOf (typeof _x));
if ( _dist22 < 1 ) then { _dist22 = 1 };
if (_truepos distance _x < _dist22) then {
_near_objects pushback _x;
};
} foreach _near_objects_25;
};
if ( count _near_objects != 0 ) then {
GRLIB_conflicting_objects = _near_objects;
} else {
GRLIB_conflicting_objects = [];
};
if (count _near_objects == 0 && ((_truepos distance _posfob) < _maxdist) && ( ((!surfaceIsWater _truepos) && (!surfaceIsWater getpos player)) || (_classname in boats_names) ) ) then {
if ( ((buildtype == 6) || (buildtype == 99)) && ((gridmode % 2) == 1) ) then {
_vehicle setpos [round (_truepos select 0),round (_truepos select 1), _truepos select 2];
} else {
if ((toLower (typeOf _vehicle)) in KPLIB_b_static_classes) then {
_vehicle setPosATL _truepos;
} else {
_vehicle setpos _truepos;
};
};
if (buildtype == 6 || buildtype == 99 || (toLower _classname) in KPLIB_storageBuildings || _classname isEqualTo KP_liberation_recycle_building || _classname isEqualTo KP_liberation_air_vehicle_building) then {
if (KP_vector) then {
_vehicle setVectorUp [0,0,1];
} else {
_vehicle setVectorUp surfaceNormal position _vehicle;
};
} else {
_vehicle setVectorUp surfaceNormal position _vehicle;
};
if(build_invalid == 1) then {
GRLIB_ui_notif = "";
{_x setObjectTexture [0, "#(rgb,8,8,3)color(0,1,0,1)"];} foreach _object_spheres;
};
build_invalid = 0;
} else {
if ( build_invalid == 0 ) then {
{_x setObjectTexture [0, "#(rgb,8,8,3)color(1,0,0,1)"];} foreach _object_spheres;
};
_vehicle setpos _ghost_spot;
build_invalid = 1;
if(count _near_objects > 0) then {
GRLIB_ui_notif = format [localize "STR_PLACEMENT_IMPOSSIBLE",count _near_objects, round _dist];
if (_debug_colisions) then {
private [ "_objs_classnames" ];
_objs_classnames = [];
{ _objs_classnames pushback (typeof _x) } foreach _near_objects;
hint format [ "Colisions : %1", _objs_classnames ];
};
};
if( ((surfaceIsWater _truepos) || (surfaceIsWater getpos player)) && !(_classname in boats_names)) then {
GRLIB_ui_notif = localize "STR_BUILD_ERROR_WATER";
};
if((_truepos distance _posfob) > _maxdist) then {
GRLIB_ui_notif = format [localize "STR_BUILD_ERROR_DISTANCE",_maxdist];
};
};
sleep 0.05;
};
GRLIB_ui_notif = "";
{_x setPos [0, 0, 0];} forEach (_object_spheres + _fob_spheres);
if ( !alive player || build_confirmed == 3 ) then {
private ["_price_s", "_price_a", "_price_f", "_nearfob", "_storage_areas"];
_price_s = ((KPLIB_buildList select buildtype) select buildindex) select 1;
_price_a = ((KPLIB_buildList select buildtype) select buildindex) select 2;
_price_f = ((KPLIB_buildList select buildtype) select buildindex) select 3;
_nearfob = [] call KPLIB_fnc_getNearestFob;
_storage_areas = (_nearfob nearobjects (GRLIB_fob_range * 2)) select {(_x getVariable ["KP_liberation_storage_type",-1]) == 0};
_supplyCrates = ceil (_price_s / 100);
_ammoCrates = ceil (_price_a / 100);
_fuelCrates = ceil (_price_f / 100);
_crateSum = _supplyCrates + _ammoCrates + _fuelCrates;
_spaceSum = 0;
{
if (typeOf _x == KP_liberation_large_storage_building) then {
_spaceSum = _spaceSum + (count KP_liberation_large_storage_positions) - (count (attachedObjects _x));
};
if (typeOf _x == KP_liberation_small_storage_building) then {
_spaceSum = _spaceSum + (count KP_liberation_small_storage_positions) - (count (attachedObjects _x));
};
} forEach _storage_areas;
deleteVehicle _vehicle;
if (_spaceSum < _crateSum) then {
hint localize "STR_CANCEL_ERROR";
} else {
[_price_s, _price_a, _price_f, _storage_areas] remoteExec ["cancel_build_remote_call",2];
};
};
if ( build_confirmed == 2 ) then {
_vehpos = getpos _vehicle;
_vehdir = getdir _vehicle;
deleteVehicle _vehicle;
sleep 0.1;
_vehicle = _classname createVehicle _truepos;
_vehicle allowDamage false;
_vehicle setdir _vehdir;
if ((toLower (typeOf _vehicle)) in KPLIB_b_static_classes) then {
_vehicle setPosATL _truepos;
} else {
_vehicle setpos _truepos;
};
[_vehicle] call KPLIB_fnc_addObjectInit;
[_vehicle] call KPLIB_fnc_clearCargo;
if (buildtype == 6 || buildtype == 99 || (toLower _classname) in KPLIB_storageBuildings || _classname isEqualTo KP_liberation_recycle_building || _classname isEqualTo KP_liberation_air_vehicle_building) then {
if (KP_vector) then {
_vehicle setVectorUp [0,0,1];
} else {
_vehicle setVectorUp surfaceNormal position _vehicle;
};
} else {
_vehicle setVectorUp surfaceNormal position _vehicle;
};
if ( (unitIsUAV _vehicle) || manned ) then {
[ _vehicle ] call KPLIB_fnc_forceBluforCrew;
};
sleep 0.3;
_vehicle allowDamage true;
_vehicle setDamage 0;
if(buildtype != 6) then {
_vehicle addMPEventHandler ["MPKilled", {_this spawn kill_manager}];
{ _x addMPEventHandler ["MPKilled", {_this spawn kill_manager}]; } foreach (crew _vehicle);
};
};
if ( _idactcancel != -1 ) then {
player removeAction _idactcancel;
};
if ( _idactsnap != -1 ) then {
player removeAction _idactsnap;
};
if ( _idactplacebis != -1 ) then {
player removeAction _idactplacebis;
};
if ( _idactvector != -1 ) then {
player removeAction _idactvector;
};
player removeAction _idactrotate;
player removeAction _idactplace;
player removeAction _idactraise;
player removeAction _idactlower;
if(buildtype == 99) then {
_new_fob = getpos player;
[_new_fob, false] remoteExec ["build_fob_remote_call",2];
buildtype = 1;
};
build_confirmed = 0;
};
};
if ( repeatbuild ) then {
dobuild = 1;
repeatbuild = false;
} else {
dobuild = 0;
};
manned = false;
};

View File

@@ -0,0 +1,51 @@
private [ "_minfobdist", "_minsectordist", "_distfob", "_clearedtobuildfob", "_distsector", "_clearedtobuildsector", "_idx" ];
if ( count GRLIB_all_fobs >= GRLIB_maximum_fobs ) exitWith {
hint format [ localize "STR_HINT_FOBS_EXCEEDED", GRLIB_maximum_fobs ];
};
_minfobdist = 1000;
_minsectordist = GRLIB_capture_size + GRLIB_fob_range;
_distfob = 1;
_clearedtobuildfob = true;
_distsector = 1;
_clearedtobuildsector = true;
FOB_build_in_progress = true;
publicVariable "FOB_build_in_progress";
_idx = 0;
while { (_idx < (count GRLIB_all_fobs)) && _clearedtobuildfob } do {
if ( player distance (GRLIB_all_fobs select _idx) < _minfobdist ) then {
_clearedtobuildfob = false;
_distfob = player distance (GRLIB_all_fobs select _idx);
};
_idx = _idx + 1;
};
_idx = 0;
if(_clearedtobuildfob) then {
while { (_idx < (count sectors_allSectors)) && _clearedtobuildsector } do {
if ( player distance (markerPos (sectors_allSectors select _idx)) < _minsectordist ) then {
_clearedtobuildsector = false;
_distsector = player distance (markerPos (sectors_allSectors select _idx));
};
_idx = _idx + 1;
};
};
if (!_clearedtobuildfob) then {
hint format [localize "STR_FOB_BUILDING_IMPOSSIBLE",floor _minfobdist,floor _distfob];
FOB_build_in_progress = false;
publicVariable "FOB_build_in_progress";
} else {
if ( !_clearedtobuildsector ) then {
hint format [localize "STR_FOB_BUILDING_IMPOSSIBLE_SECTOR",floor _minsectordist,floor _distsector];
FOB_build_in_progress = false;
publicVariable "FOB_build_in_progress";
} else {
buildtype = 99;
dobuild = 1;
deleteVehicle (_this select 0);
};
};

View File

@@ -0,0 +1,106 @@
private ["_vector", "_idactcancel", "_idactplace", "_idactvector", "_ghost_spot", "_truedir", "_dist", "_truepos", "_sectorpos", "_building"];
if (((_this select 3) select 0) == KP_liberation_small_storage_building) then {
_truepos = [];
build_confirmed = 1;
build_invalid = 0;
KP_vector = true;
_sectorpos = markerPos ([100] call KPLIB_fnc_getNearestSector);
_idactcancel = player addAction ["<t color='#B0FF00'>" + localize "STR_CANCEL" + "</t> <img size='2' image='res\ui_cancel.paa'/>",{build_confirmed = 3;},"",-725,false,true,"","build_confirmed == 1"];
_idactplace = player addAction ["<t color='#B0FF00'>" + localize "STR_PLACEMENT" + "</t> <img size='2' image='res\ui_confirm.paa'/>",{build_confirmed = 2;},"",-775,false,true,"","build_invalid == 0 && build_confirmed == 1"];
_idactvector = player addAction ["<t color='#B0FF00'>" + localize "STR_VECACTION" + "</t>",{KP_vector = !KP_vector;},"",-800,false,false,"","build_confirmed == 1"];
_ghost_spot = (markerPos "ghost_spot") findEmptyPosition [0,100];
_building = ((_this select 3) select 0) createVehicleLocal _ghost_spot;
_building allowdamage false;
_building setVehicleLock "LOCKED";
_building enableSimulationGlobal false;
_dist = 0.6 * (sizeOf ((_this select 3) select 0));
if (_dist < 3.5) then { _dist = 3.5 };
_dist = _dist + 0.5;
for [{_i=0}, {_i<5}, {_i=_i+1}] do {
_building setObjectTextureGlobal [_i, '#(rgb,8,8,3)color(0,1,0,0.8)'];
};
while {build_confirmed == 1 && alive player} do {
_truedir = 90 - (getdir player);
_truepos = [((getpos player) select 0) + (_dist * (cos _truedir)), ((getpos player) select 1) + (_dist * (sin _truedir)),0];
if ((surfaceIsWater _truepos) || (surfaceIsWater getpos player) || ((_truepos distance _sectorpos) > 100)) then {
_building setpos _ghost_spot;
build_invalid = 1;
if(((surfaceIsWater _truepos) || (surfaceIsWater getpos player))) then {
GRLIB_ui_notif = localize "STR_BUILD_ERROR_WATER";
};
if((_truepos distance _sectorpos) > 100) then {
GRLIB_ui_notif = format [localize "STR_BUILD_ERROR_DISTANCE",100];
};
} else {
_building setdir (getDir player);
_building setpos _truepos;
if (KP_vector) then {
_building setVectorUp [0,0,1];
} else {
_building setVectorUp surfaceNormal position _building;
};
if (build_invalid == 1) then {
GRLIB_ui_notif = "";
};
build_invalid = 0;
};
sleep 0.05;
};
GRLIB_ui_notif = "";
if (!alive player || build_confirmed == 3) then {
deleteVehicle _building;
};
if (build_confirmed == 2) then {
_vehpos = getpos _building;
_vehdir = getdir _building;
deleteVehicle _building;
sleep 0.1;
_building = ((_this select 3) select 0) createVehicle _truepos;
_building allowDamage false;
_building setdir _vehdir;
_building setpos _truepos;
if (KP_vector) then {
_building setVectorUp [0,0,1];
} else {
_building setVectorUp surfaceNormal position _building;
};
_building setVariable ["KP_liberation_storage_type", 1, true];
sleep 0.3;
_building allowDamage true;
_building setDamage 0;
};
player removeAction _idactcancel;
player removeAction _idactplace;
player removeAction _idactvector;
recalculate_sectors = true;
publicVariable "recalculate_sectors";
build_confirmed = 0;
} else {
[player getVariable ["KPLIB_nearProd", []], ((_this select 3) select 0), clientOwner] remoteExec ["build_fac_remote_call",2];
};

View File

@@ -0,0 +1,206 @@
private [ "_oldbuildtype", "_cfg", "_initindex", "_dialog", "_iscommandant", "_squadname", "_buildpages", "_build_list", "_classnamevar", "_entrytext", "_icon", "_affordable", "_affordable_crew", "_selected_item", "_linked", "_linked_unlocked", "_base_link", "_link_color", "_link_str", "_nearfob", "_actual_fob"];
if (([ getpos player , 500 , GRLIB_side_enemy ] call KPLIB_fnc_getUnitsCount ) > 4 ) exitWith { hint localize "STR_BUILD_ENEMIES_NEARBY";};
if (isNil "buildtype") then {buildtype = 1};
if (isNil "buildindex") then {buildindex = -1};
dobuild = 0;
_oldbuildtype = -1;
_cfg = configFile >> "cfgVehicles";
_initindex = buildindex;
_dialog = createDialog "liberation_build";
waitUntil { dialog };
_iscommandant = false;
if (player == [] call KPLIB_fnc_getCommander) then {
_iscommandant = true;
};
ctrlShow [108, _iscommandant];
ctrlShow [1085, _iscommandant];
ctrlShow [121, _iscommandant];
_squadname = "";
_buildpages = [
localize "STR_BUILD1",
localize "STR_BUILD2",
localize "STR_BUILD3",
localize "STR_BUILD4",
localize "STR_BUILD5",
localize "STR_BUILD6",
localize "STR_BUILD7",
localize "STR_BUILD8"
];
_nearfob = [] call KPLIB_fnc_getNearestFob;
_actual_fob = KP_liberation_fob_resources select {((_x select 0) distance _nearfob) < GRLIB_fob_range};
while {dialog && alive player && (dobuild == 0 || buildtype == 1)} do {
_build_list = KPLIB_buildList select buildtype;
if (_oldbuildtype != buildtype || synchro_done) then {
synchro_done = false;
_oldbuildtype = buildtype;
_actual_fob = KP_liberation_fob_resources select {((_x select 0) distance _nearfob) < GRLIB_fob_range};
lbClear 110;
{
ctrlSetText [151, _buildpages select ( buildtype - 1)];
if (buildtype != 8) then {
_classnamevar = (_x select 0);
_entrytext = getText (_cfg >> _classnamevar >> "displayName");
switch (_classnamevar) do {
case FOB_box_typename: {_entrytext = localize "STR_FOBBOX";};
case Arsenal_typename: {if (KP_liberation_mobilearsenal) then {_entrytext = localize "STR_ARSENAL_BOX";};};
case Respawn_truck_typename: {if (KP_liberation_mobilerespawn) then {_entrytext = localize "STR_RESPAWN_TRUCK";};};
case FOB_truck_typename: {_entrytext = localize "STR_FOBTRUCK";};
case "Flag_White_F": {_entrytext = localize "STR_INDIV_FLAG";};
case KP_liberation_small_storage_building: {_entrytext = localize "STR_SMALL_STORAGE";};
case KP_liberation_large_storage_building: {_entrytext = localize "STR_LARGE_STORAGE";};
case KP_liberation_recycle_building: {_entrytext = localize "STR_RECYCLE_BUILDING";};
case KP_liberation_air_vehicle_building: {_entrytext = localize "STR_HELI_BUILDING";};
case KP_liberation_heli_slot_building: {_entrytext = localize "STR_HELI_SLOT";};
case KP_liberation_plane_slot_building: {_entrytext = localize "STR_PLANE_SLOT";};
default {};
};
((findDisplay 5501) displayCtrl (110)) lnbAddRow [ _entrytext, format [ "%1" ,_x select 1], format [ "%1" ,_x select 2], format [ "%1" ,_x select 3]];
_icon = getText ( _cfg >> (_x select 0) >> "icon");
if(isText (configFile >> "CfgVehicleIcons" >> _icon)) then {
_icon = (getText (configFile >> "CfgVehicleIcons" >> _icon));
};
lnbSetPicture [110, [((lnbSize 110) select 0) - 1, 0],_icon];
} else {
if ( ((lnbSize 110) select 0) <= count squads_names ) then {
_squadname = squads_names select ((lnbSize 110) select 0);
} else {
_squadname = "";
};
((findDisplay 5501) displayCtrl (110)) lnbAddRow [_squadname, format [ "%1" ,_x select 1], format [ "%1" ,_x select 2], format [ "%1" ,_x select 3]];
};
_affordable = true;
if (
((_x select 1 > 0) && ((_x select 1) > ((_actual_fob select 0) select 1))) ||
((_x select 2 > 0) && ((_x select 2) > ((_actual_fob select 0) select 2))) ||
((_x select 3 > 0) && ((_x select 3) > ((_actual_fob select 0) select 3)))
) then {
_affordable = false;
};
if ( _affordable ) then {
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 0], [1,1,1,1]];
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 1], [1,1,1,1]];
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 2], [1,1,1,1]];
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 3], [1,1,1,1]];
} else {
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 0], [0.4,0.4,0.4,1]];
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 1], [0.4,0.4,0.4,1]];
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 2], [0.4,0.4,0.4,1]];
((findDisplay 5501) displayCtrl (110)) lnbSetColor [[((lnbSize 110) select 0) - 1, 3], [0.4,0.4,0.4,1]];
};
} foreach _build_list;
};
if(_initindex != -1) then {
lbSetCurSel [110, _initindex];
_initindex = -1;
};
_selected_item = lbCurSel 110;
_affordable = false;
_squad_full = false;
if ((buildtype == 1) && (count (units group player) >= GRLIB_max_squad_size)) then {
_squad_full = true;
};
_linked = false;
_linked_unlocked = true;
_base_link = "";
if (dobuild == 0 && _selected_item != -1 && (_selected_item < (count _build_list))) then {
_build_item = _build_list select _selected_item;
if (
((_build_item select 1 == 0 ) || ((_build_item select 1) <= ((_actual_fob select 0) select 1))) &&
((_build_item select 2 == 0 ) || ((_build_item select 2) <= ((_actual_fob select 0) select 2))) &&
((_build_item select 3 == 0 ) || ((_build_item select 3) <= ((_actual_fob select 0) select 3)))
) then {
if !((_build_item select 0) isEqualType []) then {
if ((toLower (_build_item select 0)) in KPLIB_b_air_classes && !([_build_item select 0] call KPLIB_fnc_isClassUAV)) then {
if (KP_liberation_air_vehicle_building_near &&
((((_build_item select 0) isKindOf "Helicopter") && (KP_liberation_heli_count < KP_liberation_heli_slots)) ||
(((_build_item select 0) isKindOf "Plane") && (KP_liberation_plane_count < KP_liberation_plane_slots)))
) then {
_affordable = true;
};
} else {
if (!((toLower (_build_item select 0)) in KPLIB_airSlots) || (((toLower (_build_item select 0)) in KPLIB_airSlots) && KP_liberation_air_vehicle_building_near)) then {
_affordable = true;
};
};
} else {
_affordable = true;
};
};
if ( buildtype != 8 ) then {
{ if ( ( _build_item select 0 ) == ( _x select 0 ) ) exitWith { _base_link = _x select 1; _linked = true; } } foreach GRLIB_vehicle_to_military_base_links;
if ( _linked ) then {
if ( !(_base_link in blufor_sectors) ) then { _linked_unlocked = false };
};
};
};
_affordable_crew = _affordable;
if ( unitcap >= ([] call KPLIB_fnc_getLocalCap)) then {
_affordable_crew = false;
if (buildtype == 1 || buildtype == 8) then {
_affordable = false;
};
};
ctrlEnable [ 120, _affordable && _linked_unlocked && !(_squad_full) ];
ctrlEnable [ 121, _affordable_crew && _linked_unlocked ];
ctrlSetText [131, format [ "%1 : %2" , localize "STR_MANPOWER", (floor KP_liberation_supplies)]] ;
ctrlSetText [132, format [ "%1 : %2" , localize "STR_AMMO", (floor KP_liberation_ammo)]];
ctrlSetText [133, format [ "%1 : %2" , localize "STR_FUEL", (floor KP_liberation_fuel)]];
((findDisplay 5501) displayCtrl (134)) ctrlSetStructuredText formatText [
"%1/%2 %3 - %4/%5 %6 - %7/%8 %9",
unitcap,
([] call KPLIB_fnc_getLocalCap),
image "\a3\Ui_F_Curator\Data\Displays\RscDisplayCurator\modeGroups_ca.paa",
KP_liberation_heli_count,
KP_liberation_heli_slots,
image "\A3\air_f_beta\Heli_Transport_01\Data\UI\Map_Heli_Transport_01_base_CA.paa",
KP_liberation_plane_count,
KP_liberation_plane_slots,
image "\A3\Air_F_EPC\Plane_CAS_01\Data\UI\Map_Plane_CAS_01_CA.paa"
];
_link_color = "#0040e0";
_link_str = localize "STR_VEHICLE_UNLOCKED";
if (!_linked_unlocked) then { _link_color = "#e00000"; _link_str = localize "STR_VEHICLE_LOCKED"; };
if ( _linked ) then {
((findDisplay 5501) displayCtrl (161)) ctrlSetStructuredText parseText ( "<t color='" + _link_color + "' align='center'>" + _link_str + "<br/>" + ( markerText _base_link ) + "</t>" );
} else {
((findDisplay 5501) displayCtrl (161)) ctrlSetStructuredText parseText "";
};
buildindex = _selected_item;
if(buildtype == 1 && dobuild != 0) then {
ctrlEnable [120, false];
ctrlEnable [121, false];
sleep 1;
dobuild = 0;
};
sleep 0.1;
};
if (!alive player || dobuild != 0) then { closeDialog 0 };