diff --git a/Missionframework/CfgFunctions.hpp b/Missionframework/CfgFunctions.hpp index 2749daa07..920a28203 100644 --- a/Missionframework/CfgFunctions.hpp +++ b/Missionframework/CfgFunctions.hpp @@ -21,6 +21,8 @@ class KPLIB { class createClearanceConfirm {}; class createCrate {}; class createManagedUnit {}; + class createSectorObjects {}; + class createStaticWeapons {}; class crGetMulti {}; class crGlobalMsg {}; class doSave {}; @@ -69,7 +71,9 @@ class KPLIB { class log {}; class potatoScan {}; class protectObject {}; + class registerSectorObjects {}; class secondsToTimer {}; + class sectorObjectBlacklist {}; class setDiscordState {}; class setFobMass {}; class setLoadableViV {}; @@ -83,6 +87,7 @@ class KPLIB { class spawnMilitaryPostSquad {}; class spawnMilitiaCrew {}; class spawnRegularSquad {}; + class spawnStaticWeapon {}; class spawnVehicle {}; class swapInventory {}; }; diff --git a/Missionframework/KPLIB_staticsConfigs.sqf b/Missionframework/KPLIB_staticsConfigs.sqf new file mode 100644 index 000000000..c20dbb2c4 --- /dev/null +++ b/Missionframework/KPLIB_staticsConfigs.sqf @@ -0,0 +1,46 @@ +/* + - Place here the structures that you want the enemy static weapons to spawn. For that, you need: + The classname of the building [STRING], followed by an bigger array; + The type of the static weapon ("RAISED-HMG", "LOWERED-HMG", "RAISED-GMG", "LOWERED-GMG", "AT", "AA") [ARRAY], related to ones in the presets. Can be more than one. Recommended: one type per position; + The PositionRelative coordinates [ARRAY] where the static weapon will spawn, relative to the structure; + The direction of the weapon [NUMBER] (it will be relative to the object). + - Example: + - [STRING, [[[STRING], ARRAY, NUMBER]]] + - ["building_classname", [[["type"], [relative position], relative direction], [["RAISED-HMG", "AT", "AA"], [x,y,z], (+/- dir)], [["RAISED-HMG"], [-1.14307,-1.2998,-0.55952], (180)]]] + - To get positionRelative, stand your character where you want to static weapon to spawn and run the code below in debug, it will return a [x,y,z] array. + (varNameOfTheObject or cursorObject) worldToModel ASLToAGL getPosASL player + - Using modded static weapons may require small adjustments in relative positions. + - To open the possibility of spawning static weapons, it requires more editing by placing those buildings classnames referenced below in the map. Some building classes may be already in the map. + - The static weapons will only spawn near sectors, so place the garrisons buildings near them. + - Don't duplicate classnames. + - Be careful when making a new array. Copy an example and change the values, and then check for missing or additional commas. +*/ + +KPLIB_staticsConfigs = [ + // Vanilla + ["Land_Cargo_Patrol_V1_F", [[["RAISED-HMG"], [-1.14307,-1.2998,-0.55952], (180)]]], + ["Land_Cargo_Patrol_V2_F", [[["RAISED-HMG"], [-1,-1.3,-0.5], (180)]]], + ["Land_Cargo_Patrol_V3_F", [[["RAISED-HMG"], [-1,-1.3,-0.5], (180)]]], + ["Land_Cargo_HQ_V1_F", [[["AA"], [1.54492,0.740723,-0.747444], (0)], [["RAISED-HMG"], [-1.57813,-4.04639,-0.747444], (180)], [["RAISED-HMG"], [-2.64551,3.2,-0.747444], (- 45)], [["RAISED-HMG"], [5.88232,1.84473,-0.747444], (- 45)]]], + ["Land_Cargo_HQ_V2_F", [[["AA"], [1.54492,0.740723,-0.747444], (0)], [["RAISED-HMG"], [-1.57813,-4.04639,-0.747444], (180)], [["RAISED-HMG"], [-2.64551,3.2,-0.747444], (- 45)], [["RAISED-HMG"], [5.88232,1.84473,-0.747444], (- 45)]]], + ["Land_Cargo_HQ_V3_F", [[["AA"], [1.54492,0.740723,-0.747444], (0)], [["RAISED-HMG"], [-1.57813,-4.04639,-0.747444], (180)], [["RAISED-HMG"], [-2.64551,3.2,-0.747444], (- 45)], [["RAISED-HMG"], [5.88232,1.84473,-0.747444], (- 45)]]], + ["Land_Cargo_Tower_V1_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V2_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V3_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V1_No1_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V1_No2_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V1_No3_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V1_No4_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V1_No5_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V1_No6_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_Cargo_Tower_V1_No7_F", [[["RAISED-HMG"], [4.61279,3.98389,5.00471], (45)], [["RAISED-HMG"], [4.8584,-2.90234,5.00471], (140)], [["RAISED-HMG"], [-4.18359,-3.16211,5.00471], (- 90)], [["RAISED-HMG"], [-3.07178,4.40283,5.00471], (0)]]], + ["Land_BagFence_Round_F", [[["AT"], [0,1.5,0], (180)]]], + ["Land_BagFence_Long_F", [[["AA"], [0,1.5,0], (180)]]], + ["Land_HBarrierTower_F", [[["RAISED-HMG"], [0,-1.2793,0.0967188], (180)]]], + ["Land_BagBunker_Small_F", [[["RAISED-HMG"], [0,0,-0.9], (180)]]], + ["Land_BagBunker_Large_F", [[["RAISED-HMG"], [0.0717773,-3.24316,-0.709913], (180)], [["RAISED-HMG"], [2.7627,-1.0293,-0.709913], (90)]]], + ["Land_BagBunker_Tower_F", [[["AA", "AT"], [0.163086,1.16992,0.571415], (0)], [["RAISED-HMG", "RAISED-GMG"], [-0.599121,-1.44092,0.571415], (180)]]], + ["Land_ClutterCutter_medium_F", [[["LOWERED-HMG", "LOWERED-GMG"], [0,0,0], (0)]]] +]; + +KPLIB_staticConfigs_classes = KPLIB_staticsConfigs apply { _x select 0 }; diff --git a/Missionframework/functions/fn_createSectorObjects.sqf b/Missionframework/functions/fn_createSectorObjects.sqf new file mode 100644 index 000000000..bdda4b902 --- /dev/null +++ b/Missionframework/functions/fn_createSectorObjects.sqf @@ -0,0 +1,38 @@ +/* + File: fn_createSectorObjects.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-22 + Last Update: 2024-11-30 + License: MIT License - http://www.opensource.org/licenses/MIT + + Description: + Create registered objects in the designated sector + + Parameter(s): + _sector - sector where the objects will be created [STRING] + + Returns: + All objects created in this sector [ARRAY] +*/ + +if (!isServer) exitWith {}; + +params ["_sector"]; + +private _allGarrisons = []; + +private _structures = KPLIB_sectorObjects_hashMap get _sector; +if ((isNil "_structures") || {count _structures < 1}) exitWith {_allGarrisons}; + +{ + _class = _x # 0; + _pos = ((_x # 1) # 0); + _dir = ((_x # 1) # 1); + + _object = createVehicle [_class, _pos, [], 0, "CAN_COLLIDE"]; + _object setDir _dir; + + _allGarrisons pushBack _object; +}forEach _structures; + +_allGarrisons diff --git a/Missionframework/functions/fn_createStaticWeapons.sqf b/Missionframework/functions/fn_createStaticWeapons.sqf new file mode 100644 index 000000000..4240565e7 --- /dev/null +++ b/Missionframework/functions/fn_createStaticWeapons.sqf @@ -0,0 +1,106 @@ +/* + File: fn_createStaticWeapons.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-22 + Last Update: 2024-11-30 + License: MIT License - http://www.opensource.org/licenses/MIT + + Description: + Create static weapons on available structures in the sector, provided the structures are defined in KPLIB_staticsConfig.sqf file + + Parameter(s): + _sector - sector to search for buildings to spawn static weapons + _radius - radius of search + + Returns: + All static weapons created [ARRAY] +*/ + +if (!isServer) exitWith {}; + +params[ + ["_sector", "", [""]], + ["_radius", 500, [0]] +]; + +private _allStaticWeapons = []; +private _sectorpos = markerPos _sector; + +// Find garrisons objects for static weapons in the activated sector +private _allGarrisons = (nearestObjects [_sectorpos, KPLIB_staticConfigs_classes, (_radius * 1.5)]) select {alive _x}; + +private _blacklistGarrisons = (KPLIB_GarrisonsBlacklist_HashMap get _sector); +if (!isNil "_blacklistGarrisons") then { + { + _pos = _x; + _allGarrisons = _allGarrisons select {!(_pos distance2d _x < 2)}; + }forEach _blacklistGarrisons; +}; + +// Create a group for the static weapons for the sector +private _staticGroup = createGroup KPLIB_side_enemy; + +if (count _allGarrisons > 0) then { + // Loop the garrison objects found + { + private _garrison = _x; + + // Loop statics configuration provided in KPLIB_staticsConfigs.sqf + { + // Check if the object type matches one of the configuration + if (_x # 0 == typeOf _garrison) then { + // Count how many positions are available for static weapons by counting the second element of the main array + private _positions = count (_x # 1); + if (_positions > 0) then { + for "_index" from 0 to (_positions - 1) do { + // The provided _index number in this loop will select each array that contains the necessary values to spawn correctly the static weapon for each relative position provided in the configuration + private _type = (((_x # 1) # _index) # 0); // Get the types + private _relPos = (((_x # 1) # _index) # 1); // Get the relativePosition + private _relDir = (((_x # 1) # _index) # 2); // Get the rotation + + private _typeSel = ""; + // It will select randomly the type if more than one is provided. + if (count _type > 1) then { + _typeSel = selectRandom _type; + } else { + _typeSel = _type # 0; + }; + + // For the selected type, it will check the static weapons presets + private _staticClass = ""; + switch _typeSel do { + case "RAISED-HMG" : { + _staticClass = selectRandom KPLIB_o_statics_raisedHMG; + }; + case "LOWERED-HMG" : { + _staticClass = selectRandom KPLIB_o_statics_loweredHMG; + }; + case "RAISED-GMG" : { + _staticClass = selectRandom KPLIB_o_statics_raisedGMG; + }; + case "LOWERED-GMG" : { + _staticClass = selectRandom KPLIB_o_statics_loweredGMG; + }; + case "AT" : { + _staticClass = selectRandom KPLIB_o_statics_AT; + }; + case "AA" : { + _staticClass = selectRandom KPLIB_o_statics_AA; + } + }; + + if (_staticClass isEqualTo "") then {[format ["No static weapon classname found in type %1", _typeSel], "WARNING"] call KPLIB_fnc_log; continue}; + + // Create the static weapon and it's crew + _weapon = [(_garrison modelToWorld _relPos), _staticClass, (getDir _garrison + (_relDir))] call KPLIB_fnc_spawnStaticWeapon; + // Group the static weapons to share information easily. + (crew _weapon) joinSilent _staticGroup; + _allStaticWeapons pushBack _weapon; + }; + }; + } + }forEach KPLIB_staticsConfigs; + }forEach _allGarrisons; +}; + +_allStaticWeapons diff --git a/Missionframework/functions/fn_registerSectorObjects.sqf b/Missionframework/functions/fn_registerSectorObjects.sqf new file mode 100644 index 000000000..a1d86fb66 --- /dev/null +++ b/Missionframework/functions/fn_registerSectorObjects.sqf @@ -0,0 +1,69 @@ +/* + File: fn_registerSectorObjects.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-23 + Last Update: 2024-12-15 + License: MIT License - http://www.opensource.org/licenses/MIT + + Description: + Registers pre-placed objects from a sector into a hashmap and deletes them from the map. + Only objects close enough to sectors will be registered. + + Parameter(s): + - + + Returns: + - +*/ + +if (!isServer) exitWith {}; + +[{(!isNil "KPLIB_sectors_all") && {!isNil "KPLIB_sector_ObjectsBlacklist"}}, { + private _radius = KPLIB_range_sectorCapture; + private _allObjects = []; + // Get all placed objects near sectors + { + _editedObjs = nearestObjects [(markerPos _x), ["Static", "Thing"], _radius]; + // Get the terrain objects. It will also get simple objects set up from attributes. + _terrainObjs = nearestTerrainObjects [(markerPos _x), [], _radius, false]; + + // Protect terrain objects, radio towers and production objects + _onlyEditedObjs = (_editedObjs - _terrainObjs); + + _allObjects append _onlyEditedObjs; + + }forEach KPLIB_sectors_all; + + if (isNil "KPLIB_sectorObjects_hashMap") then { + // Creates the hashmap + KPLIB_sectorObjects_hashMap = createHashMap; + }; + + { + // Ignore object from blacklist (the object will not be deleted in game start and will retain any attributes from editor) + if (_x in KPLIB_sector_ObjectsBlacklist) then { continue }; + // Ignore objects from config and player presets + if ((typeOf _x) in KPLIB_radioTowerClassnames) then { continue }; + if ((typeOf _x) in [KPLIB_b_smallStorage, KPLIB_b_largeStorage, KPLIB_b_crateSupply, KPLIB_b_crateAmmo, KPLIB_b_crateFuel]) then { continue }; + + private _sector = [_radius, getPos _x] call KPLIB_fnc_getNearestSector; // Nearest sector will be the key for the hashmap + if (_sector isEqualTo "") then {[format ["%1 in position %2 is too far away from any sectors. Deleting the object.", (typeOf _x), (getPos _x)], "WARNING"] call KPLIB_fnc_log; deleteVehicle _x; continue}; + + // Check if the key (sector) is already in the hashmap + if !(_sector in KPLIB_sectorObjects_hashMap) then { + // Create a new key with a value + KPLIB_sectorObjects_hashMap set [_sector, [[typeOf _x, [getPosATL _x, getDir _x]]]]; + } else { + // Update key values if key already exists + private _mapValue = KPLIB_sectorObjects_hashMap get _sector; + private _mapNewValues = _mapValue + [[typeOf _x, [getPosATL _x, getDir _x]]]; + KPLIB_sectorObjects_hashMap set [_sector, _mapNewValues]; + }; + + // Delete the object to spawn it later when the sector is activated + deleteVehicle _x; + }forEach _allObjects; + + KPLIB_sector_ObjectsBlacklist = nil; + +}, []] call CBA_fnc_waitUntilAndExecute; diff --git a/Missionframework/functions/fn_sectorObjectBlacklist.sqf b/Missionframework/functions/fn_sectorObjectBlacklist.sqf new file mode 100644 index 000000000..3e7b7e039 --- /dev/null +++ b/Missionframework/functions/fn_sectorObjectBlacklist.sqf @@ -0,0 +1,78 @@ +/* + File: fn_sectorObjectBlacklist.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-23 + Last Update: 2024-12-16 + License: MIT License - http://www.opensource.org/licenses/MIT + + Description: + This is where the object have the option to remain in the map and not be spawned/despawned in designated sector. + Adds the object in a blacklist. The object in the blacklist will not be deleted in the game start and will retain any attributes from editor. If the object is a simple object, it will be automatic ignored in the fn_registerSectorObjects.sqf file. + Also, if the object classname is in KPLIB_staticsConfigs, the spawning of static weapons for this building object can be disabled (NOT THE ENTIRE CLASS) and it will be managed in a different blacklist. + To add an object in the blacklist, put this code in its init field. Follow the examples below: + [this] call KPLIB_fnc_sectorObjectBlacklist - object blacklisted, static weapons can spawn in garrison buildings as default + [this, false, false] call KPLIB_fnc_sectorObjectBlacklist - object not blacklisted and static weapon spawn disabled + [this, true, false] call KPLIB_fnc_sectorObjectBlacklist - object blacklisted and static weapon spawn disabled + [this, false, true] call KPLIB_fnc_sectorObjectBlacklist - Normal behaviour without calling this function + This function must be put in the init field of the objects to run before any liberation script (https://community.bistudio.com/wiki/Initialisation_Order) + + If some of those buildings already exists in the map (as terrain) and you want to disable the spawning of static weapons, for example, place a logic near the object and in its init field: + {[_x, true, false] call KPLIB_fnc_sectorObjectBlacklist}forEach (nearestObjects [getPos this, ["classname_object"], 25, false]) + Find the correct classname of the object and change the radius of search if needed. Those terrain objects can't be deleted, so leave the second parameter of the function as TRUE. + + Parameter(s): + _object - structure that will be registered [OBJECT] + _blacklisted - true for blacklisting the object [BOOL, defaults as true] + _canGarrison - if the object is a garrison building (KPLIB_staticsConfigs.sqf), false for disabling any static weapon spawning on it [BOOL, defaults as true] + + Returns: + - +*/ +if (!isServer) exitWith {}; + +params[ + ["_object", objNull, [objNull]], + ["_blacklisted", true, [FALSE]], + ["_canGarrison", true, [FALSE]] // To work, the structure classname must be under KPLIB_staticsConfigs. This will not enable a structure to accept static weapons spawn by magic. +]; + +if (isNull _object) exitWith {}; + +// General blacklist variable +if (isNil "KPLIB_sector_ObjectsBlacklist") then { + KPLIB_sector_ObjectsBlacklist = []; +}; + +// Add object to the general blacklist +if (_blacklisted) then { + KPLIB_sector_ObjectsBlacklist pushBack _object; +}; + +// This is for the buildings/structures that the spawning of static weapons is disabled. +if (isNil "KPLIB_GarrisonsBlacklist_HashMap") then { + // Creates the hashmap + KPLIB_GarrisonsBlacklist_HashMap = createHashMap; +}; + +private _radius = KPLIB_range_sectorCapture; + +if (!_canGarrison) then { + [{!isNil "KPLIB_sectors_all"}, { + _this params ["_object", "_canGarrison"]; + // Because a deleted object will give a in the garrison array, save the position of the object instead to find a match later. + private _objectPos = [round parseNumber (((getPosATL _object) # 0) toFixed 2), round parseNumber (((getPosATL _object) # 1) toFixed 2), round parseNumber (((getPosATL _object) # 2) toFixed 2)]; + private _sector = [_radius, getPos _object] call KPLIB_fnc_getNearestSector; + //private _objectPos = _object worldToModel (markerPos _sector); + + if !(_sector in KPLIB_GarrisonsBlacklist_HashMap) then { + // Create a new key with a value + KPLIB_GarrisonsBlacklist_HashMap set [_sector, [_objectPos]]; + } else { + // Update key values if key already exists + private _mapValue = KPLIB_GarrisonsBlacklist_HashMap get _sector; + private _mapNewValues = _mapValue + [_objectPos]; + KPLIB_GarrisonsBlacklist_HashMap set [_sector, _mapNewValues]; + }; + + }, [_object, _canGarrison]] call CBA_fnc_waitUntilAndExecute; +}; diff --git a/Missionframework/functions/fn_spawnStaticWeapon.sqf b/Missionframework/functions/fn_spawnStaticWeapon.sqf new file mode 100644 index 000000000..71a9a4c08 --- /dev/null +++ b/Missionframework/functions/fn_spawnStaticWeapon.sqf @@ -0,0 +1,48 @@ +/* + File: fn_spawnStaticWeapon.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-22 + Last Update: 2024-12-18 + License: MIT License - http://www.opensource.org/licenses/MIT + + Description: + Handles the spawning of a static weapon + + Parameter(s): + _relPos - relative position to a object [POSITION, PositionRelative] + _class - classname of the static weapon to spawn [STRING] + _relDir - relative direction to a object [NUMBER] + + Returns: + All static weapons [ARRAY] +*/ + +params ["_relPos", "_class", "_relDir"]; + +_weapon = createVehicle [_class, _relPos, [], 0, "CAN_COLLIDE"]; +_weapon setDir _relDir; +_weapon setVectorUp surfaceNormal getPosASL _weapon; +_crewGrp = createVehicleCrew _weapon; + +{ + _x addMPEventHandler ["MPKilled", { + params ["_unit", "_killer"]; + ["KPLIB_manageKills", [_unit, _killer]] call CBA_fnc_localEvent; + }]; +} forEach (units _crewGrp); + +_weapon addMPEventHandler ["MPKilled", { + params ["_unit", "_killer"]; + ["KPLIB_manageKills", [_unit, _killer]] call CBA_fnc_localEvent; +}]; + +// Infinite ammo. +_weapon addEventHandler ["Reloaded", { + params ["_unit", "_weapon", "_muzzle", "_newMagazine", "_oldMagazine"]; + if !(isPlayer (gunner _unit)) then {_unit setVehicleAmmo 1}; +}]; + +[_weapon] call KPLIB_fnc_clearCargo; +[_weapon] call KPLIB_fnc_addObjectInit; + +_weapon diff --git a/Missionframework/init.sqf b/Missionframework/init.sqf index 11c65b5ba..37a753c93 100644 --- a/Missionframework/init.sqf +++ b/Missionframework/init.sqf @@ -15,6 +15,7 @@ if (!isServer) then {waitUntil {!isNil "KPLIB_initServerDone"};}; [] call compile preprocessFileLineNumbers "KPLIB_config.sqf"; [] call compile preprocessFileLineNumbers "KPLIB_whitelists.sqf"; [] call compile preprocessFileLineNumbers "KPLIB_transportConfigs.sqf"; +[] call compile preprocessFileLineNumbers "KPLIB_staticsConfigs.sqf"; [] call compile preprocessFileLineNumbers "KPLIB_classnameLists.sqf"; [] call compile preprocessFileLineNumbers "scripts\shared\fetch_params.sqf"; [] call compile preprocessFileLineNumbers "presets\init_presets.sqf"; diff --git a/Missionframework/presets/enemies/custom.sqf b/Missionframework/presets/enemies/custom.sqf index c6cee9085..907de94a1 100644 --- a/Missionframework/presets/enemies/custom.sqf +++ b/Missionframework/presets/enemies/custom.sqf @@ -149,3 +149,33 @@ KPLIB_o_planes = [ "O_Plane_CAS_02_dynamicLoadout_F", // To-199 Neophron (CAS) "O_Plane_Fighter_02_F" // To-201 Shikra ]; + +// Static HMG (Only raised) +KPLIB_o_statics_raisedHMG = [ + "O_HMG_01_high_F" //Mk30 HMG .50 (Raised) +]; + +// Static HMG (Only lowered) +KPLIB_o_statics_loweredHMG = [ + "O_HMG_01_F" //Mk30 HMG .50 +]; + +// Static HMG (Only raised) +KPLIB_o_statics_raisedGMG = [ + "O_GMG_01_high_F" //Mk32 GMG 20mm (Raised) +]; + +// Static HMG (Only lowered) +KPLIB_o_statics_loweredGMG = [ + "O_GMG_01_F" //Mk32 GMG 20mm +]; + +// Static AT +KPLIB_o_statics_AT = [ + "O_static_AT_F" // Static Titan Launcher (AT) +]; + +// Static AA +KPLIB_o_statics_AA = [ + "O_static_AA_F" // Static Titan Launcher (AA) +]; diff --git a/Missionframework/presets/init_presets.sqf b/Missionframework/presets/init_presets.sqf index 2fac49860..dde4c067c 100644 --- a/Missionframework/presets/init_presets.sqf +++ b/Missionframework/presets/init_presets.sqf @@ -136,6 +136,12 @@ KPLIB_o_battleGrpVehiclesLight = KPLIB_o_battleGrpVehiclesLight select {[_x] KPLIB_o_troopTransports = KPLIB_o_troopTransports select {[_x] call KPLIB_fnc_checkClass}; KPLIB_o_helicopters = KPLIB_o_helicopters select {[_x] call KPLIB_fnc_checkClass}; KPLIB_o_planes = KPLIB_o_planes select {[_x] call KPLIB_fnc_checkClass}; +KPLIB_o_statics_raisedHMG = KPLIB_o_statics_raisedHMG select {[_x] call KPLIB_fnc_checkClass}; +KPLIB_o_statics_loweredHMG = KPLIB_o_statics_loweredHMG select {[_x] call KPLIB_fnc_checkClass}; +KPLIB_o_statics_raisedGMG = KPLIB_o_statics_raisedGMG select {[_x] call KPLIB_fnc_checkClass}; +KPLIB_o_statics_loweredGMG = KPLIB_o_statics_loweredGMG select {[_x] call KPLIB_fnc_checkClass}; +KPLIB_o_statics_AT = KPLIB_o_statics_AT select {[_x] call KPLIB_fnc_checkClass}; +KPLIB_o_statics_AA = KPLIB_o_statics_AA select {[_x] call KPLIB_fnc_checkClass}; // Resistance KPLIB_r_units = KPLIB_r_units select {[_x] call KPLIB_fnc_checkClass}; @@ -239,6 +245,19 @@ KPLIB_o_allVeh_classes = []; KPLIB_o_allVeh_classes = KPLIB_o_allVeh_classes apply {toLower _x}; KPLIB_o_allVeh_classes = KPLIB_o_allVeh_classes arrayIntersect KPLIB_o_allVeh_classes; +// All opfor turrets classnames +KPLIB_o_allTurrets_classes = []; +{ + KPLIB_o_allTurrets_classes append _x; +}forEach [ + KPLIB_o_statics_raisedHMG, + KPLIB_o_statics_loweredHMG, + KPLIB_o_statics_raisedGMG, + KPLIB_o_statics_loweredGMG, + KPLIB_o_statics_AT, + KPLIB_o_statics_AA +]; + // All regular opfor soldier classnames KPLIB_o_inf_classes = [KPLIB_o_sentry, KPLIB_o_rifleman, KPLIB_o_grenadier, KPLIB_o_squadLeader, KPLIB_o_teamLeader, KPLIB_o_marksman, KPLIB_o_machinegunner, KPLIB_o_heavyGunner, KPLIB_o_medic, KPLIB_o_riflemanLAT, KPLIB_o_atSpecialist, KPLIB_o_aaSpecialist, KPLIB_o_officer, KPLIB_o_sharpshooter, KPLIB_o_sniper,KPLIB_o_engineer]; KPLIB_o_inf_classes = KPLIB_o_inf_classes apply {toLower _x}; diff --git a/Missionframework/scripts/server/init_server.sqf b/Missionframework/scripts/server/init_server.sqf index 693e9b134..4922a9999 100644 --- a/Missionframework/scripts/server/init_server.sqf +++ b/Missionframework/scripts/server/init_server.sqf @@ -31,6 +31,7 @@ attack_in_progress_sector = compile preprocessFileLineNumbers "scripts\server\se ied_manager = compile preprocessFileLineNumbers "scripts\server\sector\ied_manager.sqf"; manage_one_sector = compile preprocessFileLineNumbers "scripts\server\sector\manage_one_sector.sqf"; wait_to_spawn_sector = compile preprocessFileLineNumbers "scripts\server\sector\wait_to_spawn_sector.sqf"; +[] call KPLIB_fnc_registerSectorObjects; // Globals KPLIB_sectors_active = []; publicVariable "KPLIB_sectors_active"; diff --git a/Missionframework/scripts/server/sector/manage_one_sector.sqf b/Missionframework/scripts/server/sector/manage_one_sector.sqf index 0d7e84829..8cfe816a9 100644 --- a/Missionframework/scripts/server/sector/manage_one_sector.sqf +++ b/Missionframework/scripts/server/sector/manage_one_sector.sqf @@ -43,6 +43,17 @@ private _opforcount = [] call KPLIB_fnc_getOpforCap; if ((!(_sector in KPLIB_sectors_player)) && (([markerPos _sector, [_opforcount] call KPLIB_fnc_getSectorRange, KPLIB_side_player] call KPLIB_fnc_getUnitsCount) > 0)) then { + // Create objects + _garrisons = [_sector] call KPLIB_fnc_createSectorObjects; + {_managed_units pushback _x}forEach _garrisons; + + // Create static weapons + _staticWeapons = [_sector, (_local_capture_size * 1.5)] call KPLIB_fnc_createStaticWeapons; + { + _managed_units pushback _x; + {_managed_units pushback _x}forEach (crew _x) + } foreach _staticWeapons; + if (_sector in KPLIB_sectors_capital) then { if (KPLIB_enemyReadiness < 30) then {_infsquad = "militia";};