diff --git a/Missionframework/CfgFunctions.hpp b/Missionframework/CfgFunctions.hpp index 2749daa07..32f71f175 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,6 +71,7 @@ class KPLIB { class log {}; class potatoScan {}; class protectObject {}; + class registerSectorObject {}; class secondsToTimer {}; class setDiscordState {}; class setFobMass {}; @@ -83,6 +86,7 @@ class KPLIB { class spawnMilitaryPostSquad {}; class spawnMilitiaCrew {}; class spawnRegularSquad {}; + class spawnStaticWeapon {}; class spawnVehicle {}; class swapInventory {}; }; diff --git a/Missionframework/KPLIB_config.sqf b/Missionframework/KPLIB_config.sqf index bae114c53..a306951a2 100644 --- a/Missionframework/KPLIB_config.sqf +++ b/Missionframework/KPLIB_config.sqf @@ -366,3 +366,6 @@ KPLIB_cleanup_delay = 1200; // Fill magazines on loading loadout? KP_liberation_fill_mags = true; + +// Max radius from an object to register to find the nearest sector +KPLIB_objectsGrabber_radius = 250; 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..d244e027f --- /dev/null +++ b/Missionframework/functions/fn_createSectorObjects.sqf @@ -0,0 +1,46 @@ +/* + File: fn_createSectorObjects.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-22 + Last Update: 2024-12-16 + 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 setPosATL _pos; + _object setDir _dir; + + // Vehicles + if (_object isKindOf "Allvehicles") then { + [_object, 0] remoteExec ["setFuel"]; + [_object, "LOCKEDPLAYER"] remoteExec ["setVehicleLock"]; + _object lockDriver true; + }; + + _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..9e233d5e1 --- /dev/null +++ b/Missionframework/functions/fn_createStaticWeapons.sqf @@ -0,0 +1,99 @@ +/* + File: fn_createStaticWeapons.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-22 + Last Update: 2025-04-09 + 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 [STRING, defaults to ""] + _objects - sector objects [ARRAY, defaults to []] + + Returns: + All static weapons created [ARRAY] +*/ + +if (!isServer) exitWith {}; + +params[ + ["_sector", "", [""]], + ["_objects", [], [[]]] +]; + +private _allStaticWeapons = []; +if (_sector isEqualTo "") exitWith {["No sector provided in fn_createStaticWeapons", "WARNING"] call KPLIB_fnc_log; _allStaticWeapons}; +if (_objects isEqualTo []) exitWith {["No objects in the sector found", "SECTOR"] call KPLIB_fnc_log; _allStaticWeapons}; + +// Find garrisons objects for static weapons in the activated sector +private _allGarrisons = _objects select {(typeOf _x) in KPLIB_staticConfigs_classes}; + +// 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; + if (!isNil "_weapon") then { + _allStaticWeapons pushBack _weapon; + }; + }; + }; + } + }forEach KPLIB_staticsConfigs; + }forEach _allGarrisons; +}; + +_allStaticWeapons diff --git a/Missionframework/functions/fn_registerSectorObject.sqf b/Missionframework/functions/fn_registerSectorObject.sqf new file mode 100644 index 000000000..b59ce37c4 --- /dev/null +++ b/Missionframework/functions/fn_registerSectorObject.sqf @@ -0,0 +1,111 @@ +/* + File: fn_registerSectorObject.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2025-12-20 + Last Update: 2025-02-17 + License: MIT License - http://www.opensource.org/licenses/MIT + + Description: + Register object near a sector into a hashmap and deletes them from the map, to later spawn it again when the sector is activated + Can be any object. Static weapons will spawn only in registered objects. + Put this code in the object's init to register as a sector object: + [this] call KPLIB_fnc_registerSectorObject + Only object close enough to sectors will be registered (KPLIB_objectsGrabber_radius). If the object isn't near any sectors, it will not be registered and it will be deleted from the map. + Objects classnames under KPLIB_staticsConfigs.sqf have an option to disable static weapons from spawning it + [this, false] call KPLIB_fnc_registerSectorObject + The registered object can be delete or not in the beginning of the mission. In this case a different variable will manage those objects. + This is crucial to be able to spawn static weapon in those buildings once the sectors activates + For default, map objects classnames that matches those in KPLIB_staticsConfigs.sqf will NOT spawn any static weapon. + To enable MAP objects classnames that are under KPLIB_staticsConfigs.sqf to spawn static weapons, you can do it indirectly by placing a logic near of the object and in its init field: + _objects = nearestObjects [getPos this, ["classname_of_object"], 75, false]; + {[this] call KPLIB_fnc_registerSectorObject}forEach _objects; + + Parameter(s): + _object - object that will be registered [OBJECT, defaults to objNull] + _canGarrison - Spawning of static weapons is enabled for this object? (provided if the object classname is refered in KPLIB_staticsConfigs.sqf) [BOOL, defaults to true] + + Returns: + - +*/ + +if (!isServer) exitWith {}; + +params [ + ["_object", objNull, [ObjNull]], + ["_canGarrison", true, [false]], // Only works for buildings or structures under KPLIB_staticsConfigs + ["_initDelete", true, [false]] // This will NOT work for map objects if it's TRUE +]; + +[{(!isNil "KPLIB_sectors_all")}, { + _this params ["_object", "_canGarrison", "_initDelete"]; + + // Find the nearest sector + private _sector = [KPLIB_objectsGrabber_radius, getPos _object] call KPLIB_fnc_getNearestSector; + if (_sector isEqualTo "") exitWith {[format ["%1 in position %2 is too far away from any sectors. Deleting the object.", (typeOf _object), (getPos _object)], "REGISTERING OBJECT FAILED"] call KPLIB_fnc_log; deleteVehicle _x;}; + + if (isNil "KPLIB_sectorObjects_hashMap") then { + // Creates the hashmap + KPLIB_sectorObjects_hashMap = createHashMap; + }; + + // 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 _object, [getPosATL _object, getDir _object]]]]; + } else { + // Update key values if key already exists + private _mapValue = KPLIB_sectorObjects_hashMap get _sector; + private _mapNewValues = _mapValue + [[typeOf _object, [getPosATL _object, getDir _object]]]; + KPLIB_sectorObjects_hashMap set [_sector, _mapNewValues]; + }; + + + + if (isNil "KPLIB_sectorMapObject_hashMap") then { + // Creates the hashmap + KPLIB_sectorMapObject_hashMap = createHashMap; + }; + + // This object will not be deleted from start (or it's a map object itself) + if !(_initDelete) then { + + // Check if the key (sector) is already in the hashmap + if !(_sector in KPLIB_sectorMapObject_hashMap) then { + // Create a new key with a value + KPLIB_sectorMapObject_hashMap set [_sector, [_object]]; + } else { + // Update key values if key already exists + private _mapValue = KPLIB_sectorMapObject_hashMap get _sector; + private _mapNewValues = _mapValue + [_object]; + KPLIB_sectorMapObject_hashMap set [_sector, _mapNewValues]; + }; + }; + + if (isNil "KPLIB_GarrisonsBlacklist_HashMap") then { + // Creates the hashmap + KPLIB_GarrisonsBlacklist_HashMap = createHashMap; + }; + + if (!_canGarrison) then { + if !(typeOf _object in KPLIB_allGarrionsConfigs_classe) exitWith {}; + // 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; + + 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]; + }; + }; + + // Delete the object to spawn it later when the sector is activated + if (_initDelete) then { + deleteVehicle _object; + }; + +}, [_object, _canGarrison, _initDelete]] call CBA_fnc_waitUntilAndExecute; \ No newline at end of file diff --git a/Missionframework/functions/fn_spawnStaticWeapon.sqf b/Missionframework/functions/fn_spawnStaticWeapon.sqf new file mode 100644 index 000000000..3b76919b3 --- /dev/null +++ b/Missionframework/functions/fn_spawnStaticWeapon.sqf @@ -0,0 +1,108 @@ +/* + File: fn_spawnStaticWeapon.sqf + Author: PiG13BR - https://github.com/PiG13BR + Date: 2024-11-22 + Last Update: 2025-04-09 + 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"]; + +private _weapon = createVehicle [_class, _relPos, [], 0, "CAN_COLLIDE"]; + +private _crewArray = []; +_weapon allowdamage false; +_weapon enableSimulation false; + +_crewGrp = createVehicleCrew _weapon; +_crewArray pushBack (units _crewGrp); + +{ + _checkSeat = _x select 0; // Unit - For empty seat must retun + _role = _x select 1; // Role - "driver", "gunner", "turret", "cargo", "commander" + _turretPath = _x select 3; // Turret Path - [number] + + if (isNull _checkSeat) then { + switch _role do { + case "gunner" : { + _crew = [KPLIB_o_rifleman, _weapon getPos [10, 180], _crewGrp] call KPLIB_fnc_createManagedUnit; + _crew assignAsGunner _weapon; + _crew moveInGunner _weapon; + _crewArray pushBack _crew; + }; + case "commander" : { + _crew = [KPLIB_o_rifleman, _weapon getPos [10, 180], _crewGrp] call KPLIB_fnc_createManagedUnit; + _crew assignAsCommander _weapon; + _crew moveInCommander _weapon; + _crewArray pushBack _crew; + }; + case "turret" : { + _crew = [KPLIB_o_rifleman, _weapon getPos [10, 180], _crewGrp] call KPLIB_fnc_createManagedUnit; + _crew assignAsTurret [_weapon, _turretPath]; + _crew moveInTurret [_weapon, _turretPath]; + _crewArray pushBack _crew; + }; + case "cargo" : { + _crew = [KPLIB_o_rifleman, _weapon getPos [10, 180], _crewGrp] call KPLIB_fnc_createManagedUnit; + _crew assignAsCargo _weapon; + _crew moveInCargo _weapon; + _crewArray pushBack _crew; + + }; + default {}; + } + }; + +}forEach (fullCrew [_weapon, "", true]); + +_weapon setDir _relDir; +_weapon setVectorUp surfaceNormal getPosASL _weapon; + +if (_crewArray isEqualTo []) exitWith {["No crew spawned in static weapon, deleting it", "WARNING"] call KPLIB_fnc_log; deleteVehicle _weapon; objNull}; + +{ + _x addMPEventHandler ["MPKilled", { + params ["_unit", "_killer"]; + ["KPLIB_manageKills", [_unit, _killer]] call CBA_fnc_localEvent; + if (_unit == gunner (vehicle _unit)) then { + if (count (crew (vehicle _unit)) > 0) then { + _nextGunner = selectRandom (crew (vehicle _unit)); + moveOut _nextGunner; + _nextGunner moveInGunner (vehicle _unit); + } + }; + }]; +} forEach _crewArray # 0; + +_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 allowdamage true; +_weapon enableSimulation true; + +_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/sector/manage_one_sector.sqf b/Missionframework/scripts/server/sector/manage_one_sector.sqf index 0d7e84829..bcc02b33b 100644 --- a/Missionframework/scripts/server/sector/manage_one_sector.sqf +++ b/Missionframework/scripts/server/sector/manage_one_sector.sqf @@ -43,6 +43,24 @@ 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 + private _objects = [_sector] call KPLIB_fnc_createSectorObjects; + {_managed_units pushback _x}forEach _objects; + + // Check for not deleted registered objects + private _initObjects = []; + if (_sector in KPLIB_sectorMapObject_hashMap) then { + _initObjects = KPLIB_sectorMapObject_hashMap get _sector; + }; + _objects = _objects + _initObjects; + + // Create static weapons + private _staticWeapons = [_sector, _objects] 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";};