diff --git a/Missionframework/KPLIB_functions.hpp b/Missionframework/KPLIB_functions.hpp index 9d051bb25..764ae1c9b 100644 --- a/Missionframework/KPLIB_functions.hpp +++ b/Missionframework/KPLIB_functions.hpp @@ -4,7 +4,7 @@ File: KPLIB_functions.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2017-10-16 - Last Update: 2018-12-13 + Last Update: 2019-02-02 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html @@ -26,4 +26,5 @@ class KPLIB { #include "modules\14_virtual\functions.hpp" #include "modules\15_build\functions.hpp" #include "modules\16_garrison\functions.hpp" + #include "modules\24_enemy\functions.hpp" }; diff --git a/Missionframework/modules/01_common/fnc/fn_common_createCrew.sqf b/Missionframework/modules/01_common/fnc/fn_common_createCrew.sqf index 14e6b57a4..eaed39c68 100644 --- a/Missionframework/modules/01_common/fnc/fn_common_createCrew.sqf +++ b/Missionframework/modules/01_common/fnc/fn_common_createCrew.sqf @@ -4,7 +4,7 @@ File: fn_common_createCrew.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-25 - Last Update: 2018-12-17 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -53,7 +53,7 @@ private _crewClasses = _turrets apply { }; // Spawn group and move into to vehicle -private _grp = [_side, _driverClass + _crewClasses, getPos _vehicle] call KPLIB_fnc_common_createGroup; +private _grp = [_driverClass + _crewClasses, getPos _vehicle, _side] call KPLIB_fnc_common_createGroup; // Move the units into the vehicle, -1 indicates driver { if (_forEachIndex isEqualTo 0) then { diff --git a/Missionframework/modules/01_common/fnc/fn_common_createGroup.sqf b/Missionframework/modules/01_common/fnc/fn_common_createGroup.sqf index 285e47eff..e66748c26 100644 --- a/Missionframework/modules/01_common/fnc/fn_common_createGroup.sqf +++ b/Missionframework/modules/01_common/fnc/fn_common_createGroup.sqf @@ -4,16 +4,16 @@ File: fn_common_createGroup.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-24 - Last Update: 2018-12-08 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: Creates a group at given side with units according to given array of classnames and fires the Liberation group created event. Parameter(s): - _side - Side of the group [SIDE, defaults to KPLIB_preset_sideE] _units - Array of classnames to spawn as group members [ARRAY, defaults to []] _spawnPos - Position to spawn the group and units [POSITION, defaults to KPLIB_zeroPos] + _side - Side of the group [SIDE, defaults to KPLIB_preset_sideE] _addition - Additional argument for unit creation [STRING, defaults to "NONE"] Returns: @@ -21,9 +21,9 @@ */ params [ - ["_side", KPLIB_preset_sideE, [sideEmpty]], ["_units", [], [[]]], ["_spawnPos", [KPLIB_zeroPos], [[]], [3]], + ["_side", KPLIB_preset_sideE, [sideEmpty]], ["_addition", "NONE", [""]] ]; diff --git a/Missionframework/modules/01_common/fnc/fn_common_getFobAlphabetName.sqf b/Missionframework/modules/01_common/fnc/fn_common_getFobAlphabetName.sqf index 17899990e..6acfb1502 100644 --- a/Missionframework/modules/01_common/fnc/fn_common_getFobAlphabetName.sqf +++ b/Missionframework/modules/01_common/fnc/fn_common_getFobAlphabetName.sqf @@ -4,7 +4,7 @@ File: fn_common_getFobAlphabetName.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-11-27 - Last Update: 2018-12-08 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -20,7 +20,7 @@ params [ ["_fob", "", [""]] ]; -private _index = KPLIB_sectors_fobs findIf {_x == _fob}; +private _index = KPLIB_sectors_fobs find _fob; if (_index isEqualTo -1) then { "" diff --git a/Missionframework/modules/02_core/fnc/fn_core_areUnitsNear.sqf b/Missionframework/modules/02_core/fnc/fn_core_areUnitsNear.sqf index 03d56b895..b81e256aa 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_areUnitsNear.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_areUnitsNear.sqf @@ -4,7 +4,7 @@ File: fn_core_areUnitsNear.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-05-07 - Last Update: 2018-12-08 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -19,7 +19,7 @@ Result [BOOL] */ -// TODO +// !TODO! // Guess we can move this to common params [ diff --git a/Missionframework/modules/02_core/fnc/fn_core_changeSectorOwner.sqf b/Missionframework/modules/02_core/fnc/fn_core_changeSectorOwner.sqf index 263c9a6f4..22fe8dbee 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_changeSectorOwner.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_changeSectorOwner.sqf @@ -4,7 +4,7 @@ File: fn_core_changeSectorOwner.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-05-07 - Last Update: 2018-11-27 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -27,7 +27,7 @@ if (_toPlayerSide) then { KPLIB_sectors_blufor pushBack _sectorToChange; [] call KPLIB_fnc_core_checkWinCond; } else { - KPLIB_sectors_blufor deleteAt (KPLIB_sectors_blufor findIf {_x isEqualTo _sectorToChange}); + KPLIB_sectors_blufor deleteAt (KPLIB_sectors_blufor find _sectorToChange); }; publicVariable "KPLIB_sectors_blufor"; diff --git a/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf b/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf index b15b9b6d5..bbeea3a17 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_handleVehicleSpawn.sqf @@ -4,7 +4,7 @@ File: fn_core_handleVehicleSpawn.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-09-10 - Last Update: 2018-12-11 + Last Update: 2019-02-24 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -29,7 +29,7 @@ switch (typeOf _vehicle) do { _vehicle, "STR_KPLIB_ACTION_DEPLOY", [{["KPLIB_fob_build_requested", _this select 0] call CBA_fnc_localEvent}, true, -800, false, true, "", "[_target, _this] call KPLIB_fnc_core_canBuildFob", 10] - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _vehicle]; }; case KPLIB_preset_respawnTruckF; @@ -41,7 +41,7 @@ switch (typeOf _vehicle) do { _vehicle, "STR_KPLIB_ACTION_REDEPLOY", [{["KPLIB_respawn_requested", _this] call CBA_fnc_localEvent}, nil, -801, false, true, "", "_this == vehicle _this", 10] - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _vehicle]; }; case KPLIB_preset_addHeliF: { @@ -52,7 +52,7 @@ switch (typeOf _vehicle) do { "STR_KPLIB_ACTION_HELIMOVE", [{[_this select 0] call KPLIB_fnc_core_heliToDeck;}, nil, 10, true, true, "", "(_target distance KPLIB_eden_startbase) < 20", 4], "#FF8000" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _vehicle]; }; }; }; diff --git a/Missionframework/modules/02_core/fnc/fn_core_spawnPotato.sqf b/Missionframework/modules/02_core/fnc/fn_core_spawnPotato.sqf index 07a99f470..da55080ff 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_spawnPotato.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_spawnPotato.sqf @@ -4,7 +4,7 @@ File: fn_core_spawnPotato.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2017-05-01 - Last Update: 2018-12-08 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -18,7 +18,7 @@ */ // Check if there wasn't a Potato 01 already spawned or if the spawned one is destroyed. -// NOTE: As the loading will happen before this function is called, it won't interfere with a loaded Potato 01. +// !NOTE! As the loading will happen before this function is called, it won't interfere with a loaded Potato 01. if(!isServer || alive KPLIB_core_potato01) exitWith {}; // If Potato 01 wreck is too close to respawn we should delete it. diff --git a/Missionframework/modules/02_core/fnc/fn_core_spawnStartFobBox.sqf b/Missionframework/modules/02_core/fnc/fn_core_spawnStartFobBox.sqf index 21ba413b4..41bee94a7 100644 --- a/Missionframework/modules/02_core/fnc/fn_core_spawnStartFobBox.sqf +++ b/Missionframework/modules/02_core/fnc/fn_core_spawnStartFobBox.sqf @@ -4,7 +4,7 @@ File: fn_core_spawnStartFobBox.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-05-09 - Last Update: 2018-12-11 + Last Update: 2019-02-24 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -41,7 +41,7 @@ private _fobBox = [KPLIB_preset_fobBoxF, [_spawnPos select 0, _spawnPos select 1 "STR_KPLIB_ACTION_DEPLOYRANDOM", [{[_this select 0] call KPLIB_fnc_core_buildFobRandom;}, true, -800, false, true, "", "(_target distance KPLIB_eden_boxspawn) < 3 && KPLIB_sectors_fobs isEqualTo []", 4], "#FF0000" -] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; +] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _fobBox]; // Add event handler to call this script again if box was destroyed. _fobBox addMPEventHandler ["MPKilled", {[_this select 0] call KPLIB_fnc_core_spawnStartFobBox}]; diff --git a/Missionframework/modules/02_core/scripts/server/sectorMonitor.sqf b/Missionframework/modules/02_core/scripts/server/sectorMonitor.sqf index 38dbde1a3..ac61c7b4e 100644 --- a/Missionframework/modules/02_core/scripts/server/sectorMonitor.sqf +++ b/Missionframework/modules/02_core/scripts/server/sectorMonitor.sqf @@ -4,7 +4,7 @@ File: sectorMonitor.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-05-05 - Last Update: 2018-11-09 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -15,7 +15,7 @@ scriptName "KPLIB_sectorMonitor"; if(isServer) then { // Update sector markers every time sector state was changed - {[_x, {call KPLIB_fnc_core_updateSectorMarkers}] call CBA_fnc_addEventHandler;} forEach ["KPLIB_sector_activated", "KPLIB_sector_deactivated"]; + {[_x, {[] call KPLIB_fnc_core_updateSectorMarkers}] call CBA_fnc_addEventHandler;} forEach ["KPLIB_sector_activated", "KPLIB_sector_deactivated"]; // Init function, executed every time whole list of sectors was iterated private _initFunction = { diff --git a/Missionframework/modules/02_core/ui/KPLIB_titles.hpp b/Missionframework/modules/02_core/ui/KPLIB_titles.hpp index 5bac7cad7..9ad5cd7f1 100644 --- a/Missionframework/modules/02_core/ui/KPLIB_titles.hpp +++ b/Missionframework/modules/02_core/ui/KPLIB_titles.hpp @@ -4,7 +4,7 @@ File: KPLIB_defines.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2017-10-28 - Last Update: 2018-11-27 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -71,7 +71,7 @@ class RscTitles }; }; -// TODO: Rework and implementation of the Status Overlay +// !TODO! Rework and implementation of the Status Overlay /* class statusoverlay { diff --git a/Missionframework/modules/04_adm/ui.hpp b/Missionframework/modules/04_adm/ui.hpp index acf644249..ab6ffb5c9 100644 --- a/Missionframework/modules/04_adm/ui.hpp +++ b/Missionframework/modules/04_adm/ui.hpp @@ -1,10 +1,10 @@ /* KP LIBERATION MODULE UI FILE - File: KPLIB_ui.hpp + File: ui.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-08-02 - Last Update: 2018-11-10 + Last Update: 2019-02-18 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: diff --git a/Missionframework/modules/10_resources/README.md b/Missionframework/modules/10_resources/README.md index 36b822782..24e829380 100644 --- a/Missionframework/modules/10_resources/README.md +++ b/Missionframework/modules/10_resources/README.md @@ -1,7 +1,7 @@ # KP Liberation Module Description ## Resources Module -TODO Description +!TODO! Description ### Dependencies * Init diff --git a/Missionframework/modules/10_resources/fnc/fn_res_addActions.sqf b/Missionframework/modules/10_resources/fnc/fn_res_addActions.sqf index 26e072a0e..2533106bb 100644 --- a/Missionframework/modules/10_resources/fnc/fn_res_addActions.sqf +++ b/Missionframework/modules/10_resources/fnc/fn_res_addActions.sqf @@ -4,7 +4,7 @@ File: fn_res_addActions.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-12-15 - Last Update: 2018-12-16 + Last Update: 2019-02-24 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -32,7 +32,7 @@ if ((typeOf _object) in KPLIB_res_crateClasses) then { "STR_KPLIB_ACTION_CHECKCRATE", [{[_this select 0] call KPLIB_fnc_res_checkCrate;}, nil, -500, false, true, "", "isNull attachedTo _target", 4], "#FFFF00" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _object]; // Add push action to crate [ @@ -40,7 +40,7 @@ if ((typeOf _object) in KPLIB_res_crateClasses) then { "STR_KPLIB_ACTION_PUSHCRATE", [{[_this select 0] call KPLIB_fnc_res_pushCrate;}, nil, -501, false, false, "", "isNull attachedTo _target", 4], "#FFFF00" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _object]; // Add store action to crate [ @@ -48,7 +48,7 @@ if ((typeOf _object) in KPLIB_res_crateClasses) then { "STR_KPLIB_ACTION_STORECRATE", [{[_this select 0] call KPLIB_fnc_res_storeCrate;}, nil, -502, false, true, "", "isNull attachedTo _target", 4], "#FFFF00" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _object]; // Add load to transport action to crate [ @@ -56,7 +56,7 @@ if ((typeOf _object) in KPLIB_res_crateClasses) then { "STR_KPLIB_ACTION_LOADCRATE", [{[_this select 0] call KPLIB_fnc_res_loadCrate;}, nil, -503, false, true, "", "isNull attachedTo _target", 4], "#FFFF00" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _object]; }; // Storage actions @@ -71,7 +71,7 @@ if ((typeOf _object) in KPLIB_res_storageClasses) then { "STR_KPLIB_ACTION_UNSTORE" + (toUpper _x), [{[_this select 0, _this select 3] call KPLIB_fnc_res_unstoreCrate;}, _x, -500 - _forEachIndex, false, true, "", "", 10], "#FFFF00" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _object]; } forEach ["Supply", "Ammo", "Fuel"]; // Stack and Sort action for storage @@ -80,7 +80,7 @@ if ((typeOf _object) in KPLIB_res_storageClasses) then { "STR_KPLIB_ACTION_STACKNSORT", [{[_this select 0] call KPLIB_fnc_res_stackNsort;}, nil, -503, false, false, "", "", 10], "#FFFF00" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _object]; }; true diff --git a/Missionframework/modules/10_resources/fnc/fn_res_getStorageSpace.sqf b/Missionframework/modules/10_resources/fnc/fn_res_getStorageSpace.sqf new file mode 100644 index 000000000..dec8594ee --- /dev/null +++ b/Missionframework/modules/10_resources/fnc/fn_res_getStorageSpace.sqf @@ -0,0 +1,31 @@ +/* + KPLIB_fnc_res_getStorageSpace + + File: fnc_res_getStorageSpace.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-16 + Last Update: 2019-02-16 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Returns the amount of free storage space of a given storage. + + Parameter(s): + _storage - Storage to check for free space [OBJECT, defaults to objNull] + + Returns: + Amount of free storage spaces [NUMBER] +*/ + +params [ + ["_storage", objNull, [objNull]] +]; + +// Get the storage positions amount +private _allSpaces = count ([typeOf _storage] call KPLIB_fnc_res_getAttachArray); + +// Get amount of already stored crates +private _attachedCrates = count (attachedObjects _storage); + +// Return free space amount +_allSpaces - _attachedCrates diff --git a/Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf b/Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf new file mode 100644 index 000000000..73573b701 --- /dev/null +++ b/Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf @@ -0,0 +1,26 @@ +/* + KPLIB_fnc_res_getStorages + + File: fn_res_getStorages.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-16 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Returns all storages inside given radius of a given position. + + Parameter(s): + _center - Position AGL from where to look for storages [POSITION AGL, defaults to KPLIB_zeroPos] + _radius - Radius from the center [NUMBER, defaults to 100] + + Returns: + All found storage objects [ARRAY] +*/ + +params [ + ["_center", KPLIB_zeroPos, [[]], 3], + ["_radius", 100, [0]] +]; + +nearestObjects [_center, KPLIB_res_storageClasses, _radius] diff --git a/Missionframework/modules/10_resources/fnc/fn_res_loadCrate.sqf b/Missionframework/modules/10_resources/fnc/fn_res_loadCrate.sqf index fcdc047cb..d64f43be7 100644 --- a/Missionframework/modules/10_resources/fnc/fn_res_loadCrate.sqf +++ b/Missionframework/modules/10_resources/fnc/fn_res_loadCrate.sqf @@ -4,7 +4,7 @@ File: fn_res_loadCrate.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-12-16 - Last Update: 2018-12-16 + Last Update: 2019-02-24 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -61,7 +61,7 @@ if !(_nearTransport getVariable ["KPLIB_res_unloadAction", false]) then { "STR_KPLIB_ACTION_UNLOADCRATE", [{[_this select 0] call KPLIB_fnc_res_unloadCrate;}, nil, -500, false, true, "", "!((_target getVariable ['KPLIB_res_usedSlots', 0]) isEqualTo 0)", 10], "#FFFF00" - ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, true]; + ] remoteExecCall ["KPLIB_fnc_common_addAction", 0, _nearTransport]; _nearTransport setVariable ["KPLIB_res_unloadAction", true, true]; }; diff --git a/Missionframework/modules/10_resources/fnc/fn_res_storeCrate.sqf b/Missionframework/modules/10_resources/fnc/fn_res_storeCrate.sqf index e6e1e8942..0cf53f922 100644 --- a/Missionframework/modules/10_resources/fnc/fn_res_storeCrate.sqf +++ b/Missionframework/modules/10_resources/fnc/fn_res_storeCrate.sqf @@ -4,7 +4,7 @@ File: fn_res_storeCrate.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-12-15 - Last Update: 2018-12-16 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -60,7 +60,7 @@ _crate attachTo [_nearStorage, [ [typeOf _crate] call KPLIB_fnc_res_getCrateZ ]]; -// TODO: We need to test, if this on/off is really necessary. +// !TODO! We need to test, if this on/off is really necessary. // [_crate, false] remoteExecCall ["enableRopeAttach", true]; true diff --git a/Missionframework/modules/10_resources/functions.hpp b/Missionframework/modules/10_resources/functions.hpp index f36144f28..0d01071f3 100644 --- a/Missionframework/modules/10_resources/functions.hpp +++ b/Missionframework/modules/10_resources/functions.hpp @@ -4,7 +4,7 @@ File: functions.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-12-13 - Last Update: 2018-12-16 + Last Update: 2019-02-16 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -35,6 +35,12 @@ class res { // Gets array with amounts of all resources at given location class res_getResTotal {}; + // Gets array with all storage objects in given radius of given position + class res_getStorages {}; + + // Gets amount of free storage space of given storage + class res_getStorageSpace {}; + // Gets array with resource values of given storage class res_getStorageValue {}; diff --git a/Missionframework/modules/14_virtual/fnc/fn_virtual_addCurator.sqf b/Missionframework/modules/14_virtual/fnc/fn_virtual_addCurator.sqf index c044c1901..5482184df 100644 --- a/Missionframework/modules/14_virtual/fnc/fn_virtual_addCurator.sqf +++ b/Missionframework/modules/14_virtual/fnc/fn_virtual_addCurator.sqf @@ -4,7 +4,7 @@ File: fn_virtual_addCurator.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-11-18 - Last Update: 2018-12-11 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -32,7 +32,7 @@ unassignCurator _oldCurator; [{isNull getAssignedCuratorLogic (_this select 0)}, { params ["_unit", "_mode", "_oldCurator"]; - // TODO + // !TODO! // This causes rpt spam about not existing objects // Disable for now //deleteVehicle _oldCurator; diff --git a/Missionframework/modules/15_build/fnc/fn_build_changeQueueMode.sqf b/Missionframework/modules/15_build/fnc/fn_build_changeQueueMode.sqf index 288247048..0e6e46407 100644 --- a/Missionframework/modules/15_build/fnc/fn_build_changeQueueMode.sqf +++ b/Missionframework/modules/15_build/fnc/fn_build_changeQueueMode.sqf @@ -6,7 +6,7 @@ File: fn_build_changeQueueMode.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-11-29 - Last Update: 2018-12-17 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -25,7 +25,7 @@ params [ private _display = ctrlParent _control; private _confirmBtnControl = _display displayCtrl KPLIB_IDC_BUILD_CONFIRM; -// TODO preserve and restore current build queue +// !TODO! preserve and restore current build queue switch (LGVAR_D(buildMode, 0)) do { case 0: { _control ctrlSetText "Move mode"; diff --git a/Missionframework/modules/15_build/fnc/fn_build_confirmAll.sqf b/Missionframework/modules/15_build/fnc/fn_build_confirmAll.sqf index 07c5ac196..632ff5914 100644 --- a/Missionframework/modules/15_build/fnc/fn_build_confirmAll.sqf +++ b/Missionframework/modules/15_build/fnc/fn_build_confirmAll.sqf @@ -5,7 +5,7 @@ File: fn_build_confirmAll.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-11-28 - Last Update: 2018-11-29 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -21,7 +21,7 @@ private _validItems = LGVAR(buildQueue) select {_x getVariable ["KPLIB_validPos", true]}; LSVAR("buildQueue", LGVAR(buildQueue) - _validItems); -// TODO implement build queue handling (resource check etc.) +// !TODO! implement build queue handling (resource check etc.) systemChat "buildConfirm: Resource check not implemented yet!"; { private _dirAndUp = [vectorDir _x, vectorUp _x]; diff --git a/Missionframework/modules/15_build/fnc/fn_build_confirmSingle.sqf b/Missionframework/modules/15_build/fnc/fn_build_confirmSingle.sqf index 48d09543b..321bb19bc 100644 --- a/Missionframework/modules/15_build/fnc/fn_build_confirmSingle.sqf +++ b/Missionframework/modules/15_build/fnc/fn_build_confirmSingle.sqf @@ -4,7 +4,7 @@ File: fn_build_confirmSingle.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-11-29 - Last Update: 2018-12-17 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -27,7 +27,7 @@ _createParams params ["_className", "_pos", "_dir", "_justBuild"]; private ["_obj"]; -// TODO save only builings via Build module, units and vehicles should be moved to persistence module +// !TODO! save only builings via Build module, units and vehicles should be moved to persistence module switch true do { case (_className isKindOf "Man"): { _obj = [createGroup KPLIB_preset_sideF, _className] call KPLIB_fnc_common_createUnit; diff --git a/Missionframework/modules/15_build/fnc/fn_build_handleMouse.sqf b/Missionframework/modules/15_build/fnc/fn_build_handleMouse.sqf index b6a0672a9..33fd8299f 100644 --- a/Missionframework/modules/15_build/fnc/fn_build_handleMouse.sqf +++ b/Missionframework/modules/15_build/fnc/fn_build_handleMouse.sqf @@ -6,7 +6,7 @@ File: fn_build_handleMouse.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-09-09 - Last Update: 2018-12-11 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -115,7 +115,7 @@ switch toLower _mode do { case "onmousezchanged_buildcategorylist"; case "onmousezchanged_buildlist": { // Disable camera movement when scrolling over build dialog - // TODO is there any better solution? + // !TODO! is there any better solution? LGVAR(camera) camCommand "manual off"; [{ diff --git a/Missionframework/modules/15_build/fnc/fn_build_loadData.sqf b/Missionframework/modules/15_build/fnc/fn_build_loadData.sqf index d82f5ef53..d4f8863c3 100644 --- a/Missionframework/modules/15_build/fnc/fn_build_loadData.sqf +++ b/Missionframework/modules/15_build/fnc/fn_build_loadData.sqf @@ -4,7 +4,7 @@ File: fn_build_loadData.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-11-04 - Last Update: 2018-12-08 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -49,7 +49,7 @@ if (_moduleData isEqualTo []) then { private ["_object"]; - // TODO proper deserialization/serialization with groups and vehicle crews handling + // !TODO! proper deserialization/serialization with groups and vehicle crews handling switch true do { case (_className isKindOf "Man"): { _object = [createGroup KPLIB_preset_sideF, _className] call KPLIB_fnc_common_createUnit; diff --git a/Missionframework/modules/15_build/ui/KPLIB_buildDisplay.hpp b/Missionframework/modules/15_build/ui/KPLIB_buildDisplay.hpp index 7e3080364..b2b033da6 100644 --- a/Missionframework/modules/15_build/ui/KPLIB_buildDisplay.hpp +++ b/Missionframework/modules/15_build/ui/KPLIB_buildDisplay.hpp @@ -4,7 +4,7 @@ File: KPLIB_defines.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-07-01 - Last Update: 2018-12-12 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -110,7 +110,7 @@ class KPLIB_build { // Toolbox Controls class Controls { - // TODO move toolbox items creation to script + // !TODO! move toolbox items creation to script class KPLIB_Toolbox_MoveItems: KPGUI_PRE_ActiveText { text = "Build mode"; idc = KPLIB_IDC_BUILD_TOOLBOX_MOVEITEMS; diff --git a/Missionframework/modules/16_garrison/README.md b/Missionframework/modules/16_garrison/README.md index ac34b3f9d..2f24ad524 100644 --- a/Missionframework/modules/16_garrison/README.md +++ b/Missionframework/modules/16_garrison/README.md @@ -9,6 +9,7 @@ It'll also provide functions to change garrison data and a garrison management d * Init * Common * Core +* Garrison ### Functions * KPLIB_fnc_garrison_changeOwner diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf index bbe16b8a7..7eee7b141 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf @@ -4,7 +4,7 @@ File: fn_garrison_despawn.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-20 - Last Update: 2018-11-27 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -41,7 +41,7 @@ private _heavyVeh = []; }; } forEach (_activeGarrisonRef select 2); -/* NOTE: +/* !NOTE! With the current despawn checks for the vehicles, the vehicle won't be deleted if it's a wreck or the crew bailed out due to damage. This leads to the behaviour that it would be deleted if there is a blufor unit or a player in the vehicle (if the enemy is opfor). We'll address the "capture enemy vehicle" with a variable which will be set to the vehicle like "KPLIB_captured" in a later iteration. @@ -49,11 +49,13 @@ private _heavyVeh = []; // Despawn garrison light vehicles { - if ((alive _x) && !((crew _x) isEqualTo []) && !(_x getVariable ["KPLIB_captured", false])) then { - _vehicle = _x; - _lightVeh pushBack (typeOf _x); - {_handledCrew pushBack _x; _vehicle deleteVehicleCrew _x;} forEach (crew _x); - deleteVehicle _vehicle; + if ((alive _x) && !(_x getVariable ["KPLIB_captured", false])) then { + if (!((crew _x) isEqualTo []) && !(_x in (KPLIB_preset_vehTransPlE + KPLIB_preset_vehLightUnarmedPlE))) then { + _vehicle = _x; + _lightVeh pushBack (typeOf _x); + {_handledCrew pushBack _x; _vehicle deleteVehicleCrew _x;} forEach (crew _x); + }; + deleteVehicle _x; }; } forEach (_activeGarrisonRef select 3); diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_getGarrison.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_getGarrison.sqf index 2d236b50e..58ec35547 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_getGarrison.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_getGarrison.sqf @@ -4,7 +4,7 @@ File: fn_garrison_getGarrison.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-24 - Last Update: 2018-11-18 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -27,7 +27,7 @@ private _array = [KPLIB_garrison_array, KPLIB_garrison_active] select _active; private _index = (_array findIf {_x select 0 == _sector}); if(_index isEqualTo -1) then { - [[], [], [], [], []] + [] } else { _array select _index } diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_getVehSpawnPos.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_getVehSpawnPos.sqf index 6d6d00e11..39426d445 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_getVehSpawnPos.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_getVehSpawnPos.sqf @@ -4,7 +4,7 @@ File: fn_garrison_getVehSpawnPos.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-23 - Last Update: 2018-12-19 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -22,9 +22,13 @@ params [ ]; private _spawnPos = (_center getPos [50 + (random 200), random 360]) findEmptyPosition [0, 100, "B_T_VTOL_01_armed_F"]; +private _nearRoad = selectRandom (_center nearRoads 150); +if !(isNil "_nearRoad") then { + _spawnPos = getPos _nearRoad; +}; // Avoid spawn position on water or empty position by findEmptyPosition -if (_spawnPos isEqualTo [] || {surfaceIsWater _spawnPos}) exitWith {_this call KPLIB_fnc_garrison_getVehSpawnPos}; +if (_spawnPos isEqualTo [] || surfaceIsWater _spawnPos || !((_spawnPos nearEntities 20) isEqualTo [])) exitWith {_this call KPLIB_fnc_garrison_getVehSpawnPos}; // Return position with a slight z Offset [_spawnPos select 0, _spawnPos select 1, 0.25] diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_initSector.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_initSector.sqf index 34324fa30..208d1ecf3 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_initSector.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_initSector.sqf @@ -4,7 +4,7 @@ File: fn_garrison_initSector.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-24 - Last Update: 2018-12-09 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -25,7 +25,7 @@ if (_sector isEqualTo "") exitWith {[]}; // Initialize general sector garrisons private _tempMarker = toArray _sector; -private _side = 0; // 0 - Enemy Military Troops; 1 - Local Militia Troops; 2 - Players (NOTE: It's very possible that this will change, so consider it as placeholder) +private _side = 0; // 0 - Enemy Military Troops; 1 - Local Militia Troops; 2 - Players (!NOTE! It's very possible that this will change, so consider it as placeholder) private _soldiers = 0; // Amount of soldiers private _lVehicles = []; // Array of light vehicle classnames private _hVehicles = []; // Array of heavy vehicle classnames diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf index 9f413a651..9d86242d7 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf @@ -4,7 +4,7 @@ File: fn_garrison_spawnSectorInfantry.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-20 - Last Update: 2018-12-21 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -65,20 +65,20 @@ for "_i" from 1 to _amount do { }; // Create group -_grp = [_side, _classnames, _spawnPos] call KPLIB_fnc_common_createGroup; +_grp = [_classnames, _spawnPos, _side] call KPLIB_fnc_common_createGroup; // Add units of created group to active garrison array { _activeGarrisonRef pushBack _x; } forEach (units _grp); -// FOR DEBUG: Add group to Zeus +// !DEBUG! Add group to Zeus { _x addCuratorEditableObjects [units _grp, true] } forEach allCurators; // Remove possible initialization waypoints -while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);}; +{deleteWaypoint [_grp, 0];} forEach (waypoints _grp); // Make sure every soldier is following the leader {_x doFollow (leader _grp)} forEach (units _grp); diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorVehicle.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorVehicle.sqf index 9105ac518..547545978 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorVehicle.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorVehicle.sqf @@ -4,7 +4,7 @@ File: fn_garrison_spawnSectorVehicle.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2018-10-21 - Last Update: 2018-12-19 + Last Update: 2019-02-23 License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html Description: @@ -35,7 +35,7 @@ private _sectorPos = getMarkerPos _sector; private _spawnPos = [_sectorPos] call KPLIB_fnc_garrison_getVehSpawnPos; private _activeGarrisonRef = [_sector, true] call KPLIB_fnc_garrison_getGarrison; -/* NOTE +/* !NOTE! This works totally fine and also adds e.g. a CSAT vehicle classname as Blufor side, if ordered. The "problem" is, that it has the normal config crew, so it's manned by CSAT soldiers which belong to Blufor side. Maybe we have to replace it with an own function, especially as some AAF vehicles (resistance side) are also in the blufor preset. @@ -45,12 +45,12 @@ private _vehicle = [_classname, _spawnPos, random 360, true, true] call KPLIB_fn _vehicle setDamage 0; private _crew = crew _vehicle; -// FOR DEBUG: Add group to Zeus +// !DEBUG! Add group to Zeus { _x addCuratorEditableObjects [[_vehicle], true] } forEach allCurators; -/* NOTE +/* !NOTE! Adding a patrol waypoint pattern to the vehicle let it move like the infantry squads, which is the same like in the old framework. Unfortunately this leads to the behaviour that they can get stuck and drive over their homies with no regrets. So we could let them spawn standing still and just "scan the area" or we keep it like in the old framework and let them drive around. diff --git a/Missionframework/modules/24_enemy/README.md b/Missionframework/modules/24_enemy/README.md new file mode 100644 index 000000000..13618030e --- /dev/null +++ b/Missionframework/modules/24_enemy/README.md @@ -0,0 +1,15 @@ +# KP Liberation Module Description + +## Enemy Module + + +### Dependencies +* Init +* Common +* Core + +### Functions + + +### Scripts +No scripts will be started by this module diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_addAwareness.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_addAwareness.sqf new file mode 100644 index 000000000..39110c445 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_addAwareness.sqf @@ -0,0 +1,29 @@ +/* + KPLIB_fnc_enemy_addAwareness + + File: fn_enemy_addAwareness.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-24 + Last Update: 2019-02-24 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Adds given amount to enemy awareness value. + + Parameter(s): + _amount - Positive or negative amount to add [NUMBER, defaults to 0] + + Returns: + Function reached the end [BOOL] +*/ + +params [ + ["_amount", 0, [0]] +]; + +KPLIB_enemy_awareness = KPLIB_enemy_awareness + _amount; +if (KPLIB_enemy_awareness < 0) then {KPLIB_enemy_awareness = 0;}; +if (KPLIB_enemy_awareness > 100) then {KPLIB_enemy_awareness = 100;}; +publicVariable "KPLIB_enemy_awareness"; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_addStrength.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_addStrength.sqf new file mode 100644 index 000000000..76b077415 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_addStrength.sqf @@ -0,0 +1,30 @@ +/* + KPLIB_fnc_enemy_addStrength + + File: fn_enemy_addStrength.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-24 + Last Update: 2019-02-24 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Adds given amount to enemy strength value. + + Parameter(s): + _amount - Positive or negative amount to add [NUMBER, defaults to 0] + + Returns: + Function reached the end [BOOL] +*/ + +params [ + ["_amount", 0, [0]] +]; + +// Exit, if not enough strength available +if (_amount < 0 && _amount > KPLIB_enemy_strength) exitWith {false}; + +KPLIB_enemy_strength = KPLIB_enemy_strength + _amount; +publicVariable "KPLIB_enemy_strength"; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf new file mode 100644 index 000000000..02c19aa04 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf @@ -0,0 +1,37 @@ +/* + KPLIB_fnc_enemy_getTransportClasses + + File: fn_enemy_getTransportClasses.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-18 + Last Update: 2019-02-23 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Gets all transport classnames of preset vehicles which are capable to transport given amount of soldiers. + + Parameter(s): + _amount - Amount of soldiers which should be transported [NUMBER, defaults to 0] + _air - Should it be an air vehicle [BOOL, defaults to false] + + Returns: + Array of valid vehicle classnames [ARRAY] +*/ + +params [ + ["_amount", 0, [0]], + ["_air", false, [false]] +]; + +// Select ground or air transport array +private _toCheck = [(KPLIB_preset_vehTransPlE + KPLIB_preset_vehLightUnarmedPlE), KPLIB_preset_heliTransPlE] select _air; + +// Check via config for enough transport seats and return resulting array +private _validVeh = []; +{ + if ((getNumber (configfile >> "CfgVehicles" >> _x >> "transportSoldier")) >= _amount) then { + _validVeh pushBack _x; + }; +} forEach _toCheck; + +_validVeh diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf new file mode 100644 index 000000000..cacac2b32 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf @@ -0,0 +1,75 @@ +/* + KPLIB_fnc_enemy_handleConvoyEnd + + File: fn_enemy_handleConvoyEnd.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-23 + Last Update: 2019-02-24 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Handles convoy processing, after it reached the destination. + + Parameter(s): + _units - Arrived units of convoy [ARRAY, defaults to []] + _destination - Destination of the convoy [STRING, defaults to ""] + + Returns: + Function reached the end [BOOL] +*/ + +params [ + ["_units", [], [[]]], + ["_destination", "", [""]] +]; + +// Get group +private _grp = group (_units select 0); + +// !DEBUG! +hint format ["Arrived: %1\nUnits: %2\nDestination: %3 (%4)", units _grp, _units, markerText _destination, _destination]; + +private _garrisonRef = [_destination, true] call KPLIB_fnc_garrison_getGarrison; + +if (_garrisonRef isEqualTo []) then { + // Determine kind of arrived vehicle + private _vehicle = objNull; + { + if !(objectParent _x isEqualTo objNull) exitWith {_vehicle = objectParent _x}; + } forEach (units _grp); + + switch (true) do { + case ((typeOf _vehicle) in KPLIB_preset_vehLightArmedPlE): {[_destination, typeOf _vehicle] call KPLIB_fnc_garrison_addVeh;}; + case ((typeOf _vehicle) in (KPLIB_preset_vehHeavyApcPlE + KPLIB_preset_vehHeavyPlE)): {[_destination, typeOf _vehicle, true] call KPLIB_fnc_garrison_addVeh;}; + default {[_destination, count _units] call KPLIB_fnc_garrison_addInfantry;}; + }; + + { + deleteVehicle (vehicle _x); + deleteVehicle _x; + } forEach (units _grp); +} else { + // Add infantry and vehicles to active garrison array for a possible later despawn + { + private _vehicle = objectParent _x; + + // Assign to active garrison arrays according to arrived type of reinforcement + switch (true) do { + case ((typeOf _vehicle) in KPLIB_preset_vehLightArmedPlE): {(_garrisonRef select 3) pushBackUnique _vehicle;}; + case ((typeOf _vehicle) in (KPLIB_preset_vehHeavyApcPlE + KPLIB_preset_vehHeavyPlE)): {(_garrisonRef select 4) pushBackUnique _vehicle;}; + default { + (_garrisonRef select 2) pushBackUnique _x; + // If it's infantry with a transport vehicle, let them disembark + if !(isNull _vehicle) then { + _grp leaveVehicle _vehicle; + (_garrisonRef select 3) pushBackUnique _vehicle; + }; + }; + }; + } forEach (units _grp); + + // Add patrol task to arrived group + [_grp, markerPos _destination, 150, 3, 1, 0.6] call CBA_fnc_taskDefend; +}; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_loadData.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_loadData.sqf new file mode 100644 index 000000000..544bf2135 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_loadData.sqf @@ -0,0 +1,36 @@ +/* + KPLIB_fnc_enemy_loadData + + File: fn_enemy_loadData.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Loads data which is bound to this module from the given save data or initializes needed data for a new campaign. + + Parameter(s): + NONE + + Returns: + Function reached the end [BOOL] +*/ + +if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Enemy module loading...";}; + +private _moduleData = ["enemy"] call KPLIB_fnc_init_getSaveData; + +// Check if there is a new campaign +if (_moduleData isEqualTo []) then { + if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Enemy module data empty, creating new data...";}; + // Nothing to do here +} else { + // Otherwise start applying the saved data + if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Enemy module data found, applying data...";}; + + KPLIB_enemy_strength = _moduleData select 0; + KPLIB_enemy_awareness = _moduleData select 1; +}; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_postInit.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_postInit.sqf new file mode 100644 index 000000000..b1ee98743 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_postInit.sqf @@ -0,0 +1,43 @@ +/* + KPLIB_fnc_enemy_postInit + + File: fn_enemy_postInit.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + The postInit function of a module takes care of starting/executing the modules functions or scripts. + Basically it starts/initializes the module functionality to make all provided features usable. + + Parameter(s): + NONE + + Returns: + Module postInit finished [BOOL] +*/ + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [POST] [ENEMY] Module initializing...", diag_tickTime];}; + +// Server section (dedicated and player hosted) +if (isServer) then { + + // Start strength increase events + [] call KPLIB_fnc_enemy_strengthInc; + +}; + +// HC section +if (!hasInterface && !isDedicated) then { + +}; + +// Player section +if (hasInterface) then { + +}; + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [POST] [ENEMY] Module initialized", diag_tickTime];}; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf new file mode 100644 index 000000000..0f237e105 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf @@ -0,0 +1,72 @@ +/* + KPLIB_fnc_enemy_preInit + + File: fn_enemy_preInit.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-23 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + The preInit function defines global variables, adds event handlers and set some vital settings which are used in this module. + + Parameter(s): + NONE + + Returns: + Module preInit finished [BOOL] +*/ + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [ENEMY] Module initializing...", diag_tickTime];}; + +/* + ----- Module Globals ----- +*/ + +// Strength of the enemy (0-1000) +KPLIB_enemy_strength = 500; + +// Awareness of the enemy (0-100) +KPLIB_enemy_awareness = 0; + +/* + ----- Module Initialization ----- +*/ + +// Process CBA Settings +[] call KPLIB_fnc_enemy_settings; + +// Server section (dedicated and player hosted) +if (isServer) then { + // Register load event handler + ["KPLIB_doLoad", {[] call KPLIB_fnc_enemy_loadData;}] call CBA_fnc_addEventHandler; + + // Register save event handler + ["KPLIB_doSave", {[] call KPLIB_fnc_enemy_saveData;}] call CBA_fnc_addEventHandler; + + // Register sector activation event handler + ["KPLIB_sector_activated", {[_this select 0] call KPLIB_fnc_enemy_sectorAct;}] call CBA_fnc_addEventHandler; + + // Register sector captured event handler + ["KPLIB_sector_captured", {[_this select 0] call KPLIB_fnc_enemy_sectorCapture;}] call CBA_fnc_addEventHandler; + + // Register sector deactivation event handler + ["KPLIB_sector_deactivated", {[_this select 0] call KPLIB_fnc_enemy_sectorDeact;}] call CBA_fnc_addEventHandler; + + // Register convoy arrival event handler + ["KPLIB_transferConvoy_end", {_this call KPLIB_fnc_enemy_handleConvoyEnd;}] call CBA_fnc_addEventHandler; +}; + +// HC section +if (!hasInterface && !isDedicated) then { + +}; + +// Player section +if (hasInterface) then { + +}; + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [ENEMY] Module initialized", diag_tickTime];}; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf new file mode 100644 index 000000000..63ed96bc0 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf @@ -0,0 +1,53 @@ +/* + KPLIB_fnc_enemy_reinforceGarrison + + File: fn_enemy_reinforceGarrison.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-18 + Last Update: 2019-02-24 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Generates units/vehicles via the KPLIB_enemy_strength resource and send it to given sector from given military base. + + Parameter(s): + _base - Military base sector to send reinforcements from [STRING, defaults to ""] + _destination - Sector which should receive the reinforcements [STRING, defaults to ""] + _infantry - Amount of infantry which should be send [NUMBER, defaults to 0] + _vehicleClasses - Array of vehicle classnames which should be send [ARRAY, defaults to []] + + Returns: + Array of created groups [ARRAY] +*/ + +params [ + ["_base", "", [""]], + ["_destination", "", [""]], + ["_troops", 0, [0]], + ["_vehicleClasses", [], [[]]] +]; + +// Exit, if no military base or destination is given +if (_base isEqualTo "" || !(_base in KPLIB_sectors_military) || _destination isEqualTo "") exitWith {[]}; + +// Calculate costs and exit, if not enough strength +// !NOTE! Values are placeholder +private _costs = _troops * 2 + (count _vehicleClasses) * 10; +if (_costs > KPLIB_enemy_strength) exitWith {[]}; + +if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] Reinfore garrison of %1 (%2) for %3 strength with [%4, %5]", markerText _destination, _destination, _costs, _troops, _vehicleClasses];}; + +[-_costs] call KPLIB_fnc_enemy_addStrength; + +// Add infantry and vehicles to base garrison +[_base, _troops] call KPLIB_fnc_garrison_addInfantry; +{ + if (_x in (KPLIB_preset_vehHeavyApcPlE + KPLIB_preset_vehHeavyPlE)) then { + [_base, _x, true] call KPLIB_fnc_garrison_addVeh; + } else { + [_base, _x] call KPLIB_fnc_garrison_addVeh; + }; +} forEach _vehicleClasses; + +// Start garrison transfer convoy +[_base, _destination, _troops, _vehicleClasses] call KPLIB_fnc_enemy_transferGarrison diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_saveData.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_saveData.sqf new file mode 100644 index 000000000..5d2a603a3 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_saveData.sqf @@ -0,0 +1,30 @@ +/* + KPLIB_fnc_enemy_saveData + + File: fn_enemy_saveData.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Fetches data which is bound to this module and send it to the global save data array. + + Parameter(s): + NONE + + Returns: + Function reached the end [BOOL] +*/ + +if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Enemy module saving...";}; + +// Set module data to save and send it to the global save data array +["enemy", + [ + KPLIB_enemy_strength, + KPLIB_enemy_awareness + ] +] call KPLIB_fnc_init_setSaveData; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorAct.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorAct.sqf new file mode 100644 index 000000000..2989c6c7d --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorAct.sqf @@ -0,0 +1,24 @@ +/* + KPLIB_fnc_enemy_sectorAct + + File: fn_enemy_sectorAct.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-20 + Last Update: 2019-02-23 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Handles sector activation event. + + Parameter(s): + _sector - Markername of the sector [STRING, defaults to ""] + + Returns: + Function reached the end [BOOL] +*/ + +params [ + ["_sector", "", [""]] +]; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorCapture.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorCapture.sqf new file mode 100644 index 000000000..3925e5320 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorCapture.sqf @@ -0,0 +1,24 @@ +/* + KPLIB_fnc_enemy_sectorCapture + + File: fn_enemy_sectorCapture.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-20 + Last Update: 2019-02-23 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Handles sector capture event. + + Parameter(s): + _sector - Markername of the sector [STRING, defaults to ""] + + Returns: + Function reached the end [BOOL] +*/ + +params [ + ["_sector", "", [""]] +]; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorDeact.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorDeact.sqf new file mode 100644 index 000000000..15c267406 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_sectorDeact.sqf @@ -0,0 +1,24 @@ +/* + KPLIB_fnc_enemy_sectorDeact + + File: fn_enemy_sectorDeact.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-20 + Last Update: 2019-02-23 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Handles sector deactivation event. + + Parameter(s): + _sector - Markername of the sector [STRING, defaults to ""] + + Returns: + Function reached the end [BOOL] +*/ + +params [ + ["_sector", "", [""]] +]; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_settings.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_settings.sqf new file mode 100644 index 000000000..b0cf17007 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_settings.sqf @@ -0,0 +1,20 @@ +/* + KPLIB_fnc_enemy_settings + + File: fn_enemy_settings.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-17 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + CBA Settings initialization for this module + + Parameter(s): + NONE + + Returns: + Function reached the end [BOOL] +*/ + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf new file mode 100644 index 000000000..c5ba283cd --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf @@ -0,0 +1,37 @@ +/* + KPLIB_fnc_enemy_strengthInc + + File: fn_enemy_strengthInc.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-18 + Last Update: 2019-02-24 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + CBA loop to increase the enemy strength in given interval depending on the remaining military bases. + + Parameter(s): + NONE + + Returns: + Function reached the end [BOOL] +*/ + +// Increase strength by remaining enemy military bases +private _increase = (count (KPLIB_sectors_military select {!(_x in KPLIB_sectors_blufor)})) * 10; +[_increase] call KPLIB_fnc_enemy_addStrength; + +// Enforce cap for strength +if (KPLIB_enemy_strength > 1000) then { + KPLIB_enemy_strength = 1000; + if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [ENEMY] Strength reached cap of 1000";}; +} else { + if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] Strength increased from %1 to %2", KPLIB_enemy_strength - _increase, KPLIB_enemy_strength];}; +}; + +// Schedule the next call +if (KPLIB_campaignRunning) then { + [{[] call KPLIB_fnc_enemy_strengthInc;}, [], 1800] call CBA_fnc_waitAndExecute; +}; + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf new file mode 100644 index 000000000..572eee81a --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf @@ -0,0 +1,174 @@ +/* + KPLIB_fnc_enemy_transferGarrison + + File: fn_enemy_transferGarrison.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-18 + Last Update: 2019-02-24 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Transfer given amount of infantry or vehicle classes from one sector to another. + Given the condition, that the amount of infantry or the specific classname is available at the origin sector. + The origin sector also has to be inactive. + + !NOTE! Maybe this could be moved to the garrison module. + + Parameter(s): + _origin - Sector from which the troops should be transfered [STRING, defaults to ""] + _destination - Sector to which the troops should be transfered [STRING, defaults to ""] + _infantry - Amount of infantry which should be transfered [NUMBER, defaults to 0] + _vehicleClasses - Array of vehicle classnames which should be transfered [ARRAY, defaults to []] + _onFoot - True if soldiers should walk instead of being transported by a truck [BOOL, defaults to false] + + Returns: + Array of created groups [ARRAY] +*/ + +params [ + ["_origin", "", [""]], + ["_destination", "", [""]], + ["_troops", 0, [0]], + ["_vehicleClasses", [], [[]]], + ["_onFoot", false, [false]] +]; + +// Exit, if no origin or destination is given +if (_origin isEqualTo "" || _destination isEqualTo "") exitWith {[]}; + +// Exit, if origin sector is currently active +if (_origin in KPLIB_garrison_active) exitWith {[]}; + +if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] Transferring garrison from %1 (%2) to %3 (%4) with [%5, %6]", markerText _origin, _origin, markerText _destination, _destination, _troops, _vehicleClasses];}; + +["KPLIB_transferConvoy_start", [_origin, _destination]] call CBA_fnc_localEvent; + +// Arrays for created units +private _infantry = []; +private _vehicles = []; +private _groups = []; + +// Origin garrison reference +private _garrison = [_origin] call KPLIB_fnc_garrison_getGarrison; + +// Spawn Pos and Dir function +private _getPosDir = { + params [ + ["_pos", [], [[]]], + ["_radius", 150, [0]] + ]; + + private _nearRoad = selectRandom (_pos nearRoads _radius); + private _spawnPos = (_pos getPos [(random _radius), random 360]) findEmptyPosition [10, 50, "B_T_VTOL_01_armed_F"]; + private _spawnDir = random 360; + if !(isNil "_nearRoad") then { + _spawnPos = getPosATL _nearRoad; + while {!((_spawnPos nearEntities 20) isEqualTo [])} do { + _nearRoad = selectRandom (_pos nearRoads _radius); + _spawnPos = getPosATL _nearRoad; + }; + _spawnDir = _nearRoad getDir ((roadsConnectedTo _nearRoad) select 0); + }; + + [_spawnPos, _spawnDir] +}; + +// Handle requested infantry +if !(_troops > (_garrison select 2)) then { + // Define one infantry squad for transport + private _squadComp = [ + KPLIB_preset_rsSquadLeaderE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE + ]; + + // Remove infantry from origin garrison + [_origin, -_troops] call KPLIB_fnc_garrison_addInfantry; + + // Other local variables for infantry transport handling + private _nearRoad = objNull; + private _transport = objNull; + private _grp = grpNull; + + while {_troops > 0} do { + // Get spawn position + private _spawnData = [markerPos _origin] call _getPosDir; + + // Create infantry group + _grp = [_squadComp select [0, 10 min _troops], _spawnData select 0] call KPLIB_fnc_common_createGroup; + _infantry pushBack _grp; + _troops = _troops - (count (units _grp)); + + // Add vehicle, if needed + if (!_onFoot) then { + private _transportClasses = [count (units _grp)] call KPLIB_fnc_enemy_getTransportClasses; + _transport = [selectRandom _transportClasses, _spawnData select 0, _spawnData select 1] call KPLIB_fnc_common_createVehicle; + _grp addVehicle _transport; + }; + + // !DEBUG! + { + _x addCuratorEditableObjects [units _grp + [_transport]]; + } forEach allCurators; + }; +} else { + if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] %1 exceeds garrison strength of %2 (%3) for transfer", _troops, markerText _origin, _origin];}; +}; + +// Handle requested vehicles +{ + if (_x in (_garrison select 3) || _x in (_garrison select 4)) then { + // Remove from garrison + if (isNil {(_garrison select 3) deleteAt ((_garrison select 3) find _x)}) then { + (_garrison select 4) deleteAt ((_garrison select 4) find _x); + }; + + // Spawn vehicle + private _spawnData = [markerPos _origin] call _getPosDir; + _vehicles pushBack ([_x, _spawnData select 0, _spawnData select 1, false, true] call KPLIB_fnc_common_createVehicle); + } else { + if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] %1 not available at garrison of %2 (%3)", _x, markerText _origin, _origin];}; + }; +} forEach _vehicleClasses; + +// !DEBUG! +{ + _x addCuratorEditableObjects [_vehicles, true]; +} forEach allCurators; + +// Send created units to destination +{ + // Get group + private _grp = _x; + if !(_x isEqualType grpNull) then { + _grp = group ((crew _x) select 0); + }; + + _groups pushBack _grp; + + // Remove possible initialization waypoints + {deleteWaypoint [_grp, 0];} forEach (waypoints _grp); + + // Get destination position + private _destPos = ([markerPos _destination, 100] call _getPosDir) select 0; + + // Add waypoint for destination + private _waypoint = _grp addWaypoint [_destPos, 1]; + _waypoint setWaypointType "MOVE"; + _waypoint setWaypointBehaviour "SAFE"; + _waypoint setWaypointCombatMode "GREEN"; + if !((objectParent ((units _grp) select 0)) isKindOf "Tank") then { + _waypoint setWaypointSpeed "LIMITED"; + }; + _waypoint setWaypointCompletionRadius 25; + _waypoint setWaypointStatements ["true", format ["['KPLIB_transferConvoy_end', [thislist, ""%1""]] call CBA_fnc_localEvent;", _destination]]; +} forEach (_infantry + _vehicles); + +_groups diff --git a/Missionframework/modules/24_enemy/functions.hpp b/Missionframework/modules/24_enemy/functions.hpp new file mode 100644 index 000000000..ba27618bd --- /dev/null +++ b/Missionframework/modules/24_enemy/functions.hpp @@ -0,0 +1,65 @@ +/* + KP LIBERATION MODULE FUNCTIONS + + File: functions.hpp + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-24 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Defines for all functions, which are brought by this module. +*/ + +class enemy { + file = "modules\24_enemy\fnc"; + + // Add/Remove awareness amount + class enemy_addAwareness {}; + + // Add/Remove strength amount + class enemy_addStrength {}; + + // Get valid transport vehicle for given amount of soldiers + class enemy_getTransportClasses {}; + + // Handles transfer convoy arrival + class enemy_handleConvoyEnd {}; + + // Loads module specific data from the save + class enemy_loadData {}; + + // Module post initialization + class enemy_postInit { + postInit = 1; + }; + + // Module pre initialization + class enemy_preInit { + preInit = 1; + }; + + // Send given troops from nearest military base to sector + class enemy_reinforceGarrison {}; + + // Saves module specific data for the save + class enemy_saveData {}; + + // Handle sector activation + class enemy_sectorAct {}; + + // Handle sector capture + class enemy_sectorCapture {}; + + // Handle sector deactivation + class enemy_sectorDeact {}; + + // CBA Settings for this module + class enemy_settings {}; + + // Strength increase event function + class enemy_strengthInc {}; + + // Transfer given troops from one sector to another + class enemy_transferGarrison {}; +}; diff --git a/Missionframework/modules/99_example/README.md b/Missionframework/modules/99_example/README.md new file mode 100644 index 000000000..00dcb874c --- /dev/null +++ b/Missionframework/modules/99_example/README.md @@ -0,0 +1,14 @@ +# KP Liberation Module Description + +## Example Module +This is an example module description. +Used as template for new modules. Make sure to replace the `example` everywhere accordingly. + +### Dependencies +* None + +### Functions + + +### Scripts +No scripts will be started by this module diff --git a/Missionframework/modules/99_example/fnc/fn_example_loadData.sqf b/Missionframework/modules/99_example/fnc/fn_example_loadData.sqf new file mode 100644 index 000000000..05c01f763 --- /dev/null +++ b/Missionframework/modules/99_example/fnc/fn_example_loadData.sqf @@ -0,0 +1,33 @@ +/* + KPLIB_fnc_example_loadData + + File: fn_example_loadData.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Loads data which is bound to this module from the given save data or initializes needed data for a new campaign. + + Parameter(s): + NONE + + Returns: + Function reached the end [BOOL] +*/ + +if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Example module loading...";}; + +private _moduleData = ["example"] call KPLIB_fnc_init_getSaveData; + +// Check if there is a new campaign +if (_moduleData isEqualTo []) then { + if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Example module data empty, creating new data...";}; + // Nothing to do here +} else { + // Otherwise start applying the saved data + if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Example module data found, applying data...";}; +}; + +true diff --git a/Missionframework/modules/99_example/fnc/fn_example_postInit.sqf b/Missionframework/modules/99_example/fnc/fn_example_postInit.sqf new file mode 100644 index 000000000..364a66275 --- /dev/null +++ b/Missionframework/modules/99_example/fnc/fn_example_postInit.sqf @@ -0,0 +1,40 @@ +/* + KPLIB_fnc_example_postInit + + File: fn_example_postInit.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + The postInit function of a module takes care of starting/executing the modules functions or scripts. + Basically it starts/initializes the module functionality to make all provided features usable. + + Parameter(s): + NONE + + Returns: + Module postInit finished [BOOL] +*/ + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [POST] [EXAMPLE] Module initializing...", diag_tickTime];}; + +// Server section (dedicated and player hosted) +if (isServer) then { + +}; + +// HC section +if (!hasInterface && !isDedicated) then { + +}; + +// Player section +if (hasInterface) then { + +}; + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [POST] [EXAMPLE] Module initialized", diag_tickTime];}; + +true diff --git a/Missionframework/modules/99_example/fnc/fn_example_preInit.sqf b/Missionframework/modules/99_example/fnc/fn_example_preInit.sqf new file mode 100644 index 000000000..f546df9a9 --- /dev/null +++ b/Missionframework/modules/99_example/fnc/fn_example_preInit.sqf @@ -0,0 +1,55 @@ +/* + KPLIB_fnc_example_preInit + + File: fn_example_preInit.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + The preInit function defines global variables, adds event handlers and set some vital settings which are used in this module. + + Parameter(s): + NONE + + Returns: + Module preInit finished [BOOL] +*/ + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [EXAMPLE] Module initializing...", diag_tickTime];}; + +/* + ----- Module Globals ----- +*/ + + +/* + ----- Module Initialization ----- +*/ + +// Process CBA Settings +[] call KPLIB_fnc_example_settings; + +// Server section (dedicated and player hosted) +if (isServer) then { + // Register load event handler + ["KPLIB_doLoad", {[] call KPLIB_fnc_example_loadData;}] call CBA_fnc_addEventHandler; + + // Register save event handler + ["KPLIB_doSave", {[] call KPLIB_fnc_example_saveData;}] call CBA_fnc_addEventHandler; +}; + +// HC section +if (!hasInterface && !isDedicated) then { + +}; + +// Player section +if (hasInterface) then { + +}; + +if (isServer) then {diag_log format ["[KP LIBERATION] [%1] [PRE] [EXAMPLE] Module initialized", diag_tickTime];}; + +true diff --git a/Missionframework/modules/99_example/fnc/fn_example_saveData.sqf b/Missionframework/modules/99_example/fnc/fn_example_saveData.sqf new file mode 100644 index 000000000..547234d1e --- /dev/null +++ b/Missionframework/modules/99_example/fnc/fn_example_saveData.sqf @@ -0,0 +1,29 @@ +/* + KPLIB_fnc_example_saveData + + File: fn_example_saveData.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Fetches data which is bound to this module and send it to the global save data array. + + Parameter(s): + NONE + + Returns: + Function reached the end [BOOL] +*/ + +if (KPLIB_param_debug) then {diag_log "[KP LIBERATION] [SAVE] Example module saving...";}; + +// Set module data to save and send it to the global save data array +["example", + [ + + ] +] call KPLIB_fnc_init_setSaveData; + +true diff --git a/Missionframework/modules/99_example/fnc/fn_example_settings.sqf b/Missionframework/modules/99_example/fnc/fn_example_settings.sqf new file mode 100644 index 000000000..c4a51a8e8 --- /dev/null +++ b/Missionframework/modules/99_example/fnc/fn_example_settings.sqf @@ -0,0 +1,37 @@ +/* + KPLIB_fnc_example_settings + + File: fn_example_settings.sqf + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + CBA Settings initialization for this module + + Parameter(s): + NONE + + Returns: + Function reached the end [BOOL] +*/ + +/* + ----- EXAMPLE SETTINGS ----- +*/ + +// KPLIB_param_example +// This is an example setting. +// Default: true +[ + "KPLIB_param_example", + "CHECKBOX", + ["Example Setting Name", "Example Setting Tooltip"], + "Example Setting Category", + true, + 1, + {} +] call CBA_Settings_fnc_init; + +true diff --git a/Missionframework/modules/99_example/functions.hpp b/Missionframework/modules/99_example/functions.hpp new file mode 100644 index 000000000..d2ae02ae1 --- /dev/null +++ b/Missionframework/modules/99_example/functions.hpp @@ -0,0 +1,35 @@ +/* + KP LIBERATION MODULE FUNCTIONS + + File: functions.hpp + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-02 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Defines for all functions, which are brought by this module. +*/ + +class example { + file = "modules\99_example\fnc"; + + // Loads module specific data from the save + class example_loadData {}; + + // Module post initialization + class example_postInit { + postInit = 1; + }; + + // Module pre initialization + class example_preInit { + preInit = 1; + }; + + // Saves module specific data for the save + class example_saveData {}; + + // CBA Settings for this module + class example_settings {}; +}; diff --git a/Missionframework/modules/99_example/ui.hpp b/Missionframework/modules/99_example/ui.hpp new file mode 100644 index 000000000..04495c479 --- /dev/null +++ b/Missionframework/modules/99_example/ui.hpp @@ -0,0 +1,14 @@ +/* + KP LIBERATION MODULE UI FILE + + File: ui.hpp + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-18 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Initializes the ui defines, dialogs and elements which are brought by this module. +*/ + +#include "ui\KPLIB_example.hpp" diff --git a/Missionframework/modules/99_example/ui/KPLIB_example.hpp b/Missionframework/modules/99_example/ui/KPLIB_example.hpp new file mode 100644 index 000000000..d4555f008 --- /dev/null +++ b/Missionframework/modules/99_example/ui/KPLIB_example.hpp @@ -0,0 +1,17 @@ +/* + KP Liberation example dialog + + File: KPLIB_example.hpp + Author: KP Liberation Dev Team - https://github.com/KillahPotatoes + Date: 2019-02-18 + Last Update: 2019-02-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + Just a placeholder file for the example module. +*/ + + +class KPLIB_example { + idd = 758099; +};