From c5a10a15a22ce0e2f4308dd9fe5b9aff92d9e82a Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 16 Feb 2019 11:05:21 +0100 Subject: [PATCH 01/27] Additional getter functions for resources module --- .../fnc/fn_res_getStorageSpace.sqf | 31 +++++++++++++++++++ .../10_resources/fnc/fn_res_getStorages.sqf | 26 ++++++++++++++++ .../modules/10_resources/functions.hpp | 8 ++++- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 Missionframework/modules/10_resources/fnc/fn_res_getStorageSpace.sqf create mode 100644 Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf 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..6e7c80783 --- /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-16 + 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]] +]; + +_center nearEntities [KPLIB_res_storageClasses, _radius] 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 {}; From 5d0efcbd16f7f95e9efe700819dc3e3f4d3a4e23 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Mon, 18 Feb 2019 14:13:30 +0100 Subject: [PATCH 02/27] nearEntities doesn't work for buildings --- .../modules/10_resources/fnc/fn_res_getStorages.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf b/Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf index 6e7c80783..73573b701 100644 --- a/Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf +++ b/Missionframework/modules/10_resources/fnc/fn_res_getStorages.sqf @@ -4,7 +4,7 @@ File: fn_res_getStorages.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-16 - Last Update: 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: @@ -23,4 +23,4 @@ params [ ["_radius", 100, [0]] ]; -_center nearEntities [KPLIB_res_storageClasses, _radius] +nearestObjects [_center, KPLIB_res_storageClasses, _radius] From e3c741c9de758a0a6c6710242eec300981b8e6c1 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Mon, 18 Feb 2019 14:26:38 +0100 Subject: [PATCH 03/27] Example Module Template --- Missionframework/modules/04_adm/ui.hpp | 4 +- Missionframework/modules/99_example/README.md | 14 +++++ .../99_example/fnc/fn_example_loadData.sqf | 33 +++++++++++ .../99_example/fnc/fn_example_postInit.sqf | 40 ++++++++++++++ .../99_example/fnc/fn_example_preInit.sqf | 55 +++++++++++++++++++ .../99_example/fnc/fn_example_saveData.sqf | 29 ++++++++++ .../99_example/fnc/fn_example_settings.sqf | 37 +++++++++++++ .../modules/99_example/functions.hpp | 35 ++++++++++++ Missionframework/modules/99_example/ui.hpp | 14 +++++ .../modules/99_example/ui/KPLIB_example.hpp | 17 ++++++ 10 files changed, 276 insertions(+), 2 deletions(-) create mode 100644 Missionframework/modules/99_example/README.md create mode 100644 Missionframework/modules/99_example/fnc/fn_example_loadData.sqf create mode 100644 Missionframework/modules/99_example/fnc/fn_example_postInit.sqf create mode 100644 Missionframework/modules/99_example/fnc/fn_example_preInit.sqf create mode 100644 Missionframework/modules/99_example/fnc/fn_example_saveData.sqf create mode 100644 Missionframework/modules/99_example/fnc/fn_example_settings.sqf create mode 100644 Missionframework/modules/99_example/functions.hpp create mode 100644 Missionframework/modules/99_example/ui.hpp create mode 100644 Missionframework/modules/99_example/ui/KPLIB_example.hpp 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/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; +}; From a45acc9b1b5b215f9cee4c8d9ab090d113be4109 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Mon, 18 Feb 2019 16:51:27 +0100 Subject: [PATCH 04/27] Enemy module foundation --- Missionframework/KPLIB_functions.hpp | 3 +- Missionframework/modules/24_enemy/README.md | 15 +++++ .../24_enemy/fnc/fn_enemy_loadData.sqf | 36 +++++++++++ .../24_enemy/fnc/fn_enemy_postInit.sqf | 43 +++++++++++++ .../modules/24_enemy/fnc/fn_enemy_preInit.sqf | 60 +++++++++++++++++++ .../24_enemy/fnc/fn_enemy_saveData.sqf | 30 ++++++++++ .../24_enemy/fnc/fn_enemy_settings.sqf | 20 +++++++ 7 files changed, 206 insertions(+), 1 deletion(-) create mode 100644 Missionframework/modules/24_enemy/README.md create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_loadData.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_postInit.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_saveData.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_settings.sqf 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/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_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..9a29f47f9 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf @@ -0,0 +1,60 @@ +/* + 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-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] [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; +}; + +// 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_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_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 From d0624720a43b3edcf3621d64eccd9a635c243ff0 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Mon, 18 Feb 2019 16:51:45 +0100 Subject: [PATCH 05/27] Enemy module additional functions --- .../fnc/fn_enemy_getTransportClasses.sqf | 37 +++++++++++++++ .../fnc/fn_enemy_reinforceGarrison.sqf | 20 ++++++++ .../24_enemy/fnc/fn_enemy_strengthInc.sqf | 37 +++++++++++++++ .../fnc/fn_enemy_transferGarrison.sqf | 20 ++++++++ .../modules/24_enemy/functions.hpp | 47 +++++++++++++++++++ 5 files changed, 161 insertions(+) create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf create mode 100644 Missionframework/modules/24_enemy/functions.hpp 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..e3c3ae790 --- /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-18 + 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_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_reinforceGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf new file mode 100644 index 000000000..2bdaa0ae9 --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf @@ -0,0 +1,20 @@ +/* + 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-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + No description added yet. + + Parameter(s): + _localVariable - Description [DATATYPE, defaults to DEFAULTVALUE] + + 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..4f9b9f2e6 --- /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-18 + 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; +KPLIB_enemy_strength = KPLIB_enemy_strength + _increase; + +// 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..8d0aa68fc --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf @@ -0,0 +1,20 @@ +/* + 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-18 + License: GNU General Public License v3.0 - https://www.gnu.org/licenses/gpl-3.0.html + + Description: + No description added yet. + + Parameter(s): + _localVariable - Description [DATATYPE, defaults to DEFAULTVALUE] + + Returns: + Function reached the end [BOOL] +*/ + +true diff --git a/Missionframework/modules/24_enemy/functions.hpp b/Missionframework/modules/24_enemy/functions.hpp new file mode 100644 index 000000000..85d08a0e2 --- /dev/null +++ b/Missionframework/modules/24_enemy/functions.hpp @@ -0,0 +1,47 @@ +/* + 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 enemy { + file = "modules\24_enemy\fnc"; + + // Get valid transport vehicle for given amount of soldiers + class enemy_getTransportClasses {}; + + // 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 {}; + + // 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 {}; +}; From c208e63920c9613c72bc3c32f52a9f6100f7adba Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 07:45:09 +0100 Subject: [PATCH 06/27] Tweaked params order in common_createGroup --- .../modules/01_common/fnc/fn_common_createCrew.sqf | 4 ++-- .../modules/01_common/fnc/fn_common_createGroup.sqf | 6 +++--- .../16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf | 4 ++-- 3 files changed, 7 insertions(+), 7 deletions(-) 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/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf index 9f413a651..2e5d63422 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,7 +65,7 @@ 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 { From c0f2100e9ec7994073ae36f7adc4bc1bc52e17d0 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 07:45:34 +0100 Subject: [PATCH 07/27] added unarmed light to possible transports --- .../modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf index e3c3ae790..02c19aa04 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_getTransportClasses.sqf @@ -4,7 +4,7 @@ File: fn_enemy_getTransportClasses.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-18 - Last Update: 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: @@ -24,7 +24,7 @@ params [ ]; // Select ground or air transport array -private _toCheck = [KPLIB_preset_vehTransPlE, KPLIB_preset_heliTransPlE] select _air; +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 = []; From a96e703124b9957784f6b2b595c42e653ee4dc85 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 09:13:49 +0100 Subject: [PATCH 08/27] Change project inline comment tags !DEBUG! !TODO! !NOTE! --- .../modules/02_core/fnc/fn_core_areUnitsNear.sqf | 4 ++-- .../modules/02_core/fnc/fn_core_spawnPotato.sqf | 4 ++-- Missionframework/modules/02_core/ui/KPLIB_titles.hpp | 4 ++-- Missionframework/modules/10_resources/README.md | 2 +- .../modules/10_resources/fnc/fn_res_storeCrate.sqf | 4 ++-- .../modules/14_virtual/fnc/fn_virtual_addCurator.sqf | 4 ++-- .../modules/15_build/fnc/fn_build_changeQueueMode.sqf | 4 ++-- .../modules/15_build/fnc/fn_build_confirmAll.sqf | 4 ++-- .../modules/15_build/fnc/fn_build_confirmSingle.sqf | 4 ++-- .../modules/15_build/fnc/fn_build_handleMouse.sqf | 4 ++-- .../modules/15_build/fnc/fn_build_loadData.sqf | 4 ++-- .../modules/15_build/ui/KPLIB_buildDisplay.hpp | 4 ++-- .../modules/16_garrison/fnc/fn_garrison_despawn.sqf | 4 ++-- .../modules/16_garrison/fnc/fn_garrison_initSector.sqf | 4 ++-- .../16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf | 2 +- .../16_garrison/fnc/fn_garrison_spawnSectorVehicle.sqf | 8 ++++---- 16 files changed, 32 insertions(+), 32 deletions(-) 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_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/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/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_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/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/fnc/fn_garrison_despawn.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf index bbe16b8a7..80a773d9b 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. 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 2e5d63422..b856ca72b 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf @@ -72,7 +72,7 @@ _grp = [_classnames, _spawnPos, _side] call KPLIB_fnc_common_createGroup; _activeGarrisonRef pushBack _x; } forEach (units _grp); -// FOR DEBUG: Add group to Zeus +// !DEBUG! Add group to Zeus { _x addCuratorEditableObjects [units _grp, true] } forEach allCurators; 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. From e56548650e59d7dda055ccb0d15fb4c252f09c2e Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 12:30:51 +0100 Subject: [PATCH 09/27] Sector state handles --- .../modules/24_enemy/fnc/fn_enemy_preInit.sqf | 14 ++++++++++- .../24_enemy/fnc/fn_enemy_sectorAct.sqf | 24 +++++++++++++++++++ .../24_enemy/fnc/fn_enemy_sectorCapture.sqf | 24 +++++++++++++++++++ .../24_enemy/fnc/fn_enemy_sectorDeact.sqf | 24 +++++++++++++++++++ .../modules/24_enemy/functions.hpp | 14 ++++++++++- 5 files changed, 98 insertions(+), 2 deletions(-) create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_sectorAct.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_sectorCapture.sqf create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_sectorDeact.sqf diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf index 9a29f47f9..f74a00c6a 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf @@ -4,7 +4,7 @@ File: fn_enemy_preInit.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-02 - Last Update: 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: @@ -43,6 +43,18 @@ if (isServer) then { // 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 select 0] call KPLIB_fnc_enemy_handleConvoyEnd;}] call CBA_fnc_addEventHandler; }; // HC section 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/functions.hpp b/Missionframework/modules/24_enemy/functions.hpp index 85d08a0e2..bdb852171 100644 --- a/Missionframework/modules/24_enemy/functions.hpp +++ b/Missionframework/modules/24_enemy/functions.hpp @@ -4,7 +4,7 @@ File: functions.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-02 - Last Update: 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: @@ -17,6 +17,9 @@ class enemy { // 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 {}; @@ -36,6 +39,15 @@ class enemy { // 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 {}; From 1e9bc318aee00d86b04e7132668a84b0736de52e Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 14:18:13 +0100 Subject: [PATCH 10/27] Infantry transfer between sector garrisons --- .../modules/16_garrison/README.md | 1 + .../24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf | 39 +++++++ .../modules/24_enemy/fnc/fn_enemy_preInit.sqf | 2 +- .../fnc/fn_enemy_transferGarrison.sqf | 103 +++++++++++++++++- 4 files changed, 140 insertions(+), 5 deletions(-) create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf 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/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf new file mode 100644 index 000000000..ac14106df --- /dev/null +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf @@ -0,0 +1,39 @@ +/* + 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-23 + 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]; + +[_destination, count _units] call KPLIB_fnc_garrison_addInfantry; + +{ + deleteVehicle (vehicle _x); + deleteVehicle _x; +} forEach (units _grp); + +true diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf index f74a00c6a..0f237e105 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_preInit.sqf @@ -54,7 +54,7 @@ if (isServer) then { ["KPLIB_sector_deactivated", {[_this select 0] call KPLIB_fnc_enemy_sectorDeact;}] call CBA_fnc_addEventHandler; // Register convoy arrival event handler - ["KPLIB_transferConvoy_end", {[_this select 0] call KPLIB_fnc_enemy_handleConvoyEnd;}] call CBA_fnc_addEventHandler; + ["KPLIB_transferConvoy_end", {_this call KPLIB_fnc_enemy_handleConvoyEnd;}] call CBA_fnc_addEventHandler; }; // HC section diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf index 8d0aa68fc..8a3b26e17 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf @@ -4,17 +4,112 @@ File: fn_enemy_transferGarrison.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-18 - Last Update: 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: - No description added yet. + 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): - _localVariable - Description [DATATYPE, defaults to DEFAULTVALUE] + _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: - Function reached the end [BOOL] + 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 == "" || _destination == "") 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 = []; + +// Handle requested infantry +if !(_troops > (([_origin] call KPLIB_fnc_garrison_getGarrison) 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 + ]; + + // 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 { + // Create infantry group + _nearRoad = selectRandom ((markerPos _origin) nearRoads 100); + _grp = [_squadComp select [0, 8 min _troops], getPosATL _nearRoad] 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, getPosATL _nearRoad, _nearRoad getDir ((roadsConnectedTo _nearRoad) select 0)] 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 for transfer", _troops, _origin];}; +}; + +// Send created units to destination +{ + // Get group + private _grp = _x; + if !(_x isEqualType grpNull) then { + _grp = group ((crew _x) select 0); + }; + + // Remove possible initialization waypoints + while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);}; + + // Add waypoint for destination + private _waypoint = _grp addWaypoint [getPosATL (selectRandom ((markerPos _destination) nearRoads 50)), 1]; + _waypoint setWaypointType "MOVE"; + _waypoint setWaypointBehaviour "SAFE"; + _waypoint setWaypointCombatMode "GREEN"; + _waypoint setWaypointSpeed "LIMITED"; + _waypoint setWaypointCompletionRadius 50; + _waypoint setWaypointStatements ["true", format ["['KPLIB_transferConvoy_end', [thislist, ""%1""]] call CBA_fnc_localEvent;", _destination]]; +} forEach (_infantry + _vehicles); + true From 579cc04d9cebd777d03917c9dbd40e8f15c12e40 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 16:32:01 +0100 Subject: [PATCH 11/27] Handle reinforcement convoy for active sector --- .../16_garrison/fnc/fn_garrison_despawn.sqf | 2 +- .../fnc/fn_garrison_getGarrison.sqf | 4 +-- .../24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf | 36 ++++++++++++++++--- 3 files changed, 34 insertions(+), 8 deletions(-) diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf index 80a773d9b..ab0e6b81b 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf @@ -49,7 +49,7 @@ private _heavyVeh = []; // Despawn garrison light vehicles { - if ((alive _x) && !((crew _x) isEqualTo []) && !(_x getVariable ["KPLIB_captured", false])) then { + if ((alive _x) && !((crew _x) isEqualTo []) && !(_x getVariable ["KPLIB_captured", false]) && !(_x in (KPLIB_preset_vehTransPlE + KPLIB_preset_vehLightUnarmedPlE))) then { _vehicle = _x; _lightVeh pushBack (typeOf _x); {_handledCrew pushBack _x; _vehicle deleteVehicleCrew _x;} forEach (crew _x); 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/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf index ac14106df..7dd66fd55 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf @@ -29,11 +29,37 @@ private _grp = group (_units select 0); // !DEBUG! hint format ["Arrived: %1\nUnits: %2\nDestination: %3 (%4)", units _grp, _units, markerText _destination, _destination]; -[_destination, count _units] call KPLIB_fnc_garrison_addInfantry; +private _garrisonRef = [_destination, true] call KPLIB_fnc_garrison_getGarrison; -{ - deleteVehicle (vehicle _x); - deleteVehicle _x; -} forEach (units _grp); +if (_garrisonRef isEqualTo []) then { + // Delete units and add to garrison, if sector isn't active + [_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 _parent = objectParent _x; + + // Assign to active garrison arrays according to arrived type of reinforcement + switch (true) do { + case ((typeOf _parent) in KPLIB_preset_vehLightArmedPlE): {(_garrisonRef select 3) pushBackUnique _parent;}; + case ((typeOf _parent) in (KPLIB_preset_vehHeavyApcPlE + KPLIB_preset_vehHeavyPlE)): {(_garrisonRef select 4) pushBackUnique _parent;}; + default { + (_garrisonRef select 2) pushBackUnique _x; + // If it's infantry with a transport vehicle, let them disembark + if !(isNull _parent) then { + _grp leaveVehicle _parent; + (_garrisonRef select 3) pushBackUnique _parent; + }; + }; + }; + } forEach (units _grp); + + // Add patrol task to arrived group + [_grp, markerPos _destination, 150, 3, 1, 0.6] call CBA_fnc_taskDefend; +}; true From e48f9f8f0d2912895bb6eb56e4ca1240bbdf3b0e Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 17:02:42 +0100 Subject: [PATCH 12/27] Proper despawn of transport vehicles upon sector despawn --- .../16_garrison/fnc/fn_garrison_despawn.sqf | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf index ab0e6b81b..ccdfbc626 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf @@ -49,11 +49,18 @@ private _heavyVeh = []; // Despawn garrison light vehicles { - if ((alive _x) && !((crew _x) isEqualTo []) && !(_x getVariable ["KPLIB_captured", false]) && !(_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 _vehicle; + if ((alive _x) && !(_x getVariable ["KPLIB_captured", false])) then { + // A combat-capable vehicle + 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 _vehicle; + }; + // An unarmed and empty transport vehicle + if (((crew _x) isEqualTo []) && (_x in (KPLIB_preset_vehTransPlE + KPLIB_preset_vehLightUnarmedPlE))) then { + deleteVehicle _x; + }; }; } forEach (_activeGarrisonRef select 3); From 2dfbbb7e961cb8917fd2fdcc4c0abc1e60314338 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 17:03:09 +0100 Subject: [PATCH 13/27] Tweaks initial waypoint removal --- .../modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf index b856ca72b..9d86242d7 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_spawnSectorInfantry.sqf @@ -78,7 +78,7 @@ _grp = [_classnames, _spawnPos, _side] call KPLIB_fnc_common_createGroup; } 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); From 4e60709ff283def377fd86749ad492cda12c678f Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 17:04:03 +0100 Subject: [PATCH 14/27] Tweaked transfer to handle no available road objects --- .../fnc/fn_enemy_transferGarrison.sqf | 35 +++++++++++++++---- 1 file changed, 29 insertions(+), 6 deletions(-) diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf index 8a3b26e17..e73999cf3 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf @@ -46,8 +46,11 @@ if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] Transferr private _infantry = []; private _vehicles = []; +// Origin garrison reference +private _garrison = [_origin] call KPLIB_fnc_garrison_getGarrison; + // Handle requested infantry -if !(_troops > (([_origin] call KPLIB_fnc_garrison_getGarrison) select 2)) then { +if !(_troops > (_garrison select 2)) then { // Define one infantry squad for transport private _squadComp = [ KPLIB_preset_rsSquadLeaderE, @@ -69,16 +72,24 @@ if !(_troops > (([_origin] call KPLIB_fnc_garrison_getGarrison) select 2)) then private _grp = grpNull; while {_troops > 0} do { - // Create infantry group + // Get spawn position _nearRoad = selectRandom ((markerPos _origin) nearRoads 100); - _grp = [_squadComp select [0, 8 min _troops], getPosATL _nearRoad] call KPLIB_fnc_common_createGroup; + private _spawnPos = ((markerPos _origin) getPos [(random 100), random 360]) findEmptyPosition [10, 50, "B_T_VTOL_01_armed_F"]; + private _spawnDir = random 360; + if !(isNil "_nearRoad") then { + _spawnPos = getPosATL _nearRoad; + _spawnDir = _nearRoad getDir ((roadsConnectedTo _nearRoad) select 0); + }; + + // Create infantry group + _grp = [_squadComp select [0, 8 min _troops], _spawnPos] 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, getPosATL _nearRoad, _nearRoad getDir ((roadsConnectedTo _nearRoad) select 0)] call KPLIB_fnc_common_createVehicle; + _transport = [selectRandom _transportClasses, _spawnPos, _spawnDir] call KPLIB_fnc_common_createVehicle; _grp addVehicle _transport; }; @@ -91,6 +102,11 @@ if !(_troops > (([_origin] call KPLIB_fnc_garrison_getGarrison) select 2)) then if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] %1 exceeds garrison strength of %2 for transfer", _troops, _origin];}; }; +// Handle requested vehicles +if !(_vehicleClasses isEqualTo []) then { + +}; + // Send created units to destination { // Get group @@ -100,10 +116,17 @@ if !(_troops > (([_origin] call KPLIB_fnc_garrison_getGarrison) select 2)) then }; // Remove possible initialization waypoints - while {(count (waypoints _grp)) != 0} do {deleteWaypoint ((waypoints _grp) select 0);}; + {deleteWaypoint [_grp, 0];} forEach (waypoints _grp); + + // Get destination position + private _nearRoad = selectRandom ((markerPos _destination) nearRoads 50); + private _destPos = ((markerPos _destination) getPos [(random 100), random 360]) findEmptyPosition [10, 50, "B_T_VTOL_01_armed_F"]; + if !(isNil "_nearRoad") then { + _destPos = getPosATL _nearRoad; + }; // Add waypoint for destination - private _waypoint = _grp addWaypoint [getPosATL (selectRandom ((markerPos _destination) nearRoads 50)), 1]; + private _waypoint = _grp addWaypoint [_destPos, 1]; _waypoint setWaypointType "MOVE"; _waypoint setWaypointBehaviour "SAFE"; _waypoint setWaypointCombatMode "GREEN"; From e4f7b992e2b594001e4a72699076e6c361fc20f0 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 17:35:43 +0100 Subject: [PATCH 15/27] Simplified transport despawn --- .../modules/16_garrison/fnc/fn_garrison_despawn.sqf | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf index ccdfbc626..7eee7b141 100644 --- a/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf +++ b/Missionframework/modules/16_garrison/fnc/fn_garrison_despawn.sqf @@ -50,17 +50,12 @@ private _heavyVeh = []; // Despawn garrison light vehicles { if ((alive _x) && !(_x getVariable ["KPLIB_captured", false])) then { - // A combat-capable vehicle 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 _vehicle; - }; - // An unarmed and empty transport vehicle - if (((crew _x) isEqualTo []) && (_x in (KPLIB_preset_vehTransPlE + KPLIB_preset_vehLightUnarmedPlE))) then { - deleteVehicle _x; }; + deleteVehicle _x; }; } forEach (_activeGarrisonRef select 3); From 42d6e5a1b6d369d04c55b63fe1b12e7ee1c54834 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 18:11:37 +0100 Subject: [PATCH 16/27] Spawn garrison vehicle on road, when available --- .../16_garrison/fnc/fn_garrison_getVehSpawnPos.sqf | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) 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] From 39635e09b80ec675dbc3b42fae9afe7069595c63 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 18:11:56 +0100 Subject: [PATCH 17/27] Prevent spawning on same road object -> boom --- .../modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf index e73999cf3..6d1efddd7 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf @@ -78,6 +78,10 @@ if !(_troops > (_garrison select 2)) then { private _spawnDir = random 360; if !(isNil "_nearRoad") then { _spawnPos = getPosATL _nearRoad; + while {!((_spawnPos nearEntities 5) isEqualTo [])} do { + _nearRoad = selectRandom ((markerPos _origin) nearRoads 100); + _spawnPos = getPosATL _nearRoad; + }; _spawnDir = _nearRoad getDir ((roadsConnectedTo _nearRoad) select 0); }; From 251b8540047d5d05c7a87ff3f080f8ac5048b193 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 18:20:17 +0100 Subject: [PATCH 18/27] Small format tweak --- .../modules/02_core/scripts/server/sectorMonitor.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 = { From 171fcaf1c9c99cb479e8d8070080249a2ab21525 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 18:25:32 +0100 Subject: [PATCH 19/27] Dev tags for transferGarrison --- .../modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf index 6d1efddd7..c3755a9bb 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf @@ -11,7 +11,8 @@ 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. + + !NOTE! Maybe this could be moved to the garrison module. Parameter(s): _origin - Sector from which the troops should be transfered [STRING, defaults to ""] @@ -108,7 +109,7 @@ if !(_troops > (_garrison select 2)) then { // Handle requested vehicles if !(_vehicleClasses isEqualTo []) then { - + // !TODO! }; // Send created units to destination From be2db050022d4355d7909d6af6a53f804c8b6582 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 23:37:51 +0100 Subject: [PATCH 20/27] FOB alphabet tweak --- .../modules/01_common/fnc/fn_common_getFobAlphabetName.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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 { "" From 39158a881b9b0cf6677d1bf9da8cb37cc83cb2b0 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sat, 23 Feb 2019 23:39:44 +0100 Subject: [PATCH 21/27] Another findIf to find --- .../modules/02_core/fnc/fn_core_changeSectorOwner.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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"; From d9983d8b0170cd7f56ba105c34f5c6043004bab0 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sun, 24 Feb 2019 09:00:16 +0100 Subject: [PATCH 22/27] Garrison vehicle transfer --- .../24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf | 28 ++++-- .../fnc/fn_enemy_transferGarrison.sqf | 85 +++++++++++++------ 2 files changed, 77 insertions(+), 36 deletions(-) diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf index 7dd66fd55..cacac2b32 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_handleConvoyEnd.sqf @@ -4,7 +4,7 @@ File: fn_enemy_handleConvoyEnd.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-23 - Last Update: 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: @@ -32,8 +32,18 @@ hint format ["Arrived: %1\nUnits: %2\nDestination: %3 (%4)", units _grp, _units, private _garrisonRef = [_destination, true] call KPLIB_fnc_garrison_getGarrison; if (_garrisonRef isEqualTo []) then { - // Delete units and add to garrison, if sector isn't active - [_destination, count _units] call KPLIB_fnc_garrison_addInfantry; + // 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; @@ -41,18 +51,18 @@ if (_garrisonRef isEqualTo []) then { } else { // Add infantry and vehicles to active garrison array for a possible later despawn { - private _parent = objectParent _x; + private _vehicle = objectParent _x; // Assign to active garrison arrays according to arrived type of reinforcement switch (true) do { - case ((typeOf _parent) in KPLIB_preset_vehLightArmedPlE): {(_garrisonRef select 3) pushBackUnique _parent;}; - case ((typeOf _parent) in (KPLIB_preset_vehHeavyApcPlE + KPLIB_preset_vehHeavyPlE)): {(_garrisonRef select 4) pushBackUnique _parent;}; + 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 _parent) then { - _grp leaveVehicle _parent; - (_garrisonRef select 3) pushBackUnique _parent; + if !(isNull _vehicle) then { + _grp leaveVehicle _vehicle; + (_garrisonRef select 3) pushBackUnique _vehicle; }; }; }; diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf index c3755a9bb..572eee81a 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_transferGarrison.sqf @@ -4,7 +4,7 @@ File: fn_enemy_transferGarrison.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-18 - Last Update: 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: @@ -34,7 +34,7 @@ params [ ]; // Exit, if no origin or destination is given -if (_origin == "" || _destination == "") exitWith {[]}; +if (_origin isEqualTo "" || _destination isEqualTo "") exitWith {[]}; // Exit, if origin sector is currently active if (_origin in KPLIB_garrison_active) exitWith {[]}; @@ -46,10 +46,33 @@ if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] Transferr // 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 @@ -61,6 +84,8 @@ if !(_troops > (_garrison select 2)) then { KPLIB_preset_rsRiflemanE, KPLIB_preset_rsRiflemanE, KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, + KPLIB_preset_rsRiflemanE, KPLIB_preset_rsRiflemanE ]; @@ -74,27 +99,17 @@ if !(_troops > (_garrison select 2)) then { while {_troops > 0} do { // Get spawn position - _nearRoad = selectRandom ((markerPos _origin) nearRoads 100); - private _spawnPos = ((markerPos _origin) getPos [(random 100), 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 5) isEqualTo [])} do { - _nearRoad = selectRandom ((markerPos _origin) nearRoads 100); - _spawnPos = getPosATL _nearRoad; - }; - _spawnDir = _nearRoad getDir ((roadsConnectedTo _nearRoad) select 0); - }; + private _spawnData = [markerPos _origin] call _getPosDir; // Create infantry group - _grp = [_squadComp select [0, 8 min _troops], _spawnPos] call KPLIB_fnc_common_createGroup; + _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, _spawnPos, _spawnDir] call KPLIB_fnc_common_createVehicle; + _transport = [selectRandom _transportClasses, _spawnData select 0, _spawnData select 1] call KPLIB_fnc_common_createVehicle; _grp addVehicle _transport; }; @@ -104,13 +119,29 @@ if !(_troops > (_garrison select 2)) then { } forEach allCurators; }; } else { - if (KPLIB_param_debug) then {diag_log format ["[KP LIBERATION] [ENEMY] %1 exceeds garrison strength of %2 for transfer", _troops, _origin];}; + 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 !(_vehicleClasses isEqualTo []) then { - // !TODO! -}; +{ + 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 { @@ -120,24 +151,24 @@ if !(_vehicleClasses isEqualTo []) then { _grp = group ((crew _x) select 0); }; + _groups pushBack _grp; + // Remove possible initialization waypoints {deleteWaypoint [_grp, 0];} forEach (waypoints _grp); // Get destination position - private _nearRoad = selectRandom ((markerPos _destination) nearRoads 50); - private _destPos = ((markerPos _destination) getPos [(random 100), random 360]) findEmptyPosition [10, 50, "B_T_VTOL_01_armed_F"]; - if !(isNil "_nearRoad") then { - _destPos = getPosATL _nearRoad; - }; + 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"; - _waypoint setWaypointSpeed "LIMITED"; - _waypoint setWaypointCompletionRadius 50; + 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); -true +_groups From 2bb5eb44f3a73e1fc9fa9c2078a1680dd5795711 Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sun, 24 Feb 2019 09:33:45 +0100 Subject: [PATCH 23/27] Enemy addStrength function --- .../24_enemy/fnc/fn_enemy_addStrength.sqf | 30 +++++++++++++++++++ .../modules/24_enemy/functions.hpp | 5 +++- 2 files changed, 34 insertions(+), 1 deletion(-) create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_addStrength.sqf 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/functions.hpp b/Missionframework/modules/24_enemy/functions.hpp index bdb852171..8fb65a831 100644 --- a/Missionframework/modules/24_enemy/functions.hpp +++ b/Missionframework/modules/24_enemy/functions.hpp @@ -4,7 +4,7 @@ File: functions.hpp Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-02 - Last Update: 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: @@ -14,6 +14,9 @@ class enemy { file = "modules\24_enemy\fnc"; + // Add/Remove strength amount + class enemy_addStrength {}; + // Get valid transport vehicle for given amount of soldiers class enemy_getTransportClasses {}; From 73ed8796b33e6e81659b2b74a579b2e68ed18a2f Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sun, 24 Feb 2019 09:35:18 +0100 Subject: [PATCH 24/27] strengthInc use addStrength --- .../modules/24_enemy/fnc/fn_enemy_strengthInc.sqf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf index 4f9b9f2e6..c5ba283cd 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_strengthInc.sqf @@ -4,7 +4,7 @@ File: fn_enemy_strengthInc.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-18 - Last Update: 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: @@ -19,7 +19,7 @@ // Increase strength by remaining enemy military bases private _increase = (count (KPLIB_sectors_military select {!(_x in KPLIB_sectors_blufor)})) * 10; -KPLIB_enemy_strength = KPLIB_enemy_strength + _increase; +[_increase] call KPLIB_fnc_enemy_addStrength; // Enforce cap for strength if (KPLIB_enemy_strength > 1000) then { From 9c31c98d87dd5c41965661ccc04b6514be2d406b Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sun, 24 Feb 2019 10:04:16 +0100 Subject: [PATCH 25/27] addAwareness function --- .../24_enemy/fnc/fn_enemy_addAwareness.sqf | 29 +++++++++++++++++++ .../modules/24_enemy/functions.hpp | 3 ++ 2 files changed, 32 insertions(+) create mode 100644 Missionframework/modules/24_enemy/fnc/fn_enemy_addAwareness.sqf 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/functions.hpp b/Missionframework/modules/24_enemy/functions.hpp index 8fb65a831..ba27618bd 100644 --- a/Missionframework/modules/24_enemy/functions.hpp +++ b/Missionframework/modules/24_enemy/functions.hpp @@ -14,6 +14,9 @@ class enemy { file = "modules\24_enemy\fnc"; + // Add/Remove awareness amount + class enemy_addAwareness {}; + // Add/Remove strength amount class enemy_addStrength {}; From 1ffa47c71c448ec6a3c01a1f68bccae98ce28afd Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sun, 24 Feb 2019 10:04:40 +0100 Subject: [PATCH 26/27] reinforceGarrison function --- .../fnc/fn_enemy_reinforceGarrison.sqf | 43 ++++++++++++++++--- 1 file changed, 38 insertions(+), 5 deletions(-) diff --git a/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf b/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf index 2bdaa0ae9..63ed96bc0 100644 --- a/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf +++ b/Missionframework/modules/24_enemy/fnc/fn_enemy_reinforceGarrison.sqf @@ -4,17 +4,50 @@ File: fn_enemy_reinforceGarrison.sqf Author: KP Liberation Dev Team - https://github.com/KillahPotatoes Date: 2019-02-18 - Last Update: 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: - No description added yet. + Generates units/vehicles via the KPLIB_enemy_strength resource and send it to given sector from given military base. Parameter(s): - _localVariable - Description [DATATYPE, defaults to DEFAULTVALUE] + _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: - Function reached the end [BOOL] + Array of created groups [ARRAY] */ -true +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 From 1523a8b96ec3c1f8df8c5615eb9b75740e622d3b Mon Sep 17 00:00:00 2001 From: Wyqer Date: Sun, 24 Feb 2019 19:04:20 +0100 Subject: [PATCH 27/27] bind addAction JIP to object instead of true --- .../02_core/fnc/fn_core_handleVehicleSpawn.sqf | 8 ++++---- .../02_core/fnc/fn_core_spawnStartFobBox.sqf | 4 ++-- .../modules/10_resources/fnc/fn_res_addActions.sqf | 14 +++++++------- .../modules/10_resources/fnc/fn_res_loadCrate.sqf | 4 ++-- 4 files changed, 15 insertions(+), 15 deletions(-) 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_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/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_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]; };