From 6000646ce9f6f481267a8e851ea4960bdcec7b3f Mon Sep 17 00:00:00 2001 From: 3Mydlo3 Date: Wed, 6 Mar 2024 19:21:51 +0100 Subject: [PATCH] Add config for Chernarus scenario --- addons/common/XEH_PREP.hpp | 1 + .../functions/fnc_getTextFromConfig.sqf | 29 +++++++++++++++++++ addons/killers/XEH_preInit.sqf | 2 ++ addons/killers/functions/fnc_initConfig.sqf | 12 +------- .../CfgSerialKillers.hpp | 12 ++++++++ .../description.ext | 2 ++ addons/police/CfgSerialKillers.hpp | 2 +- addons/police/functions/fnc_initConfig.sqf | 12 +------- 8 files changed, 49 insertions(+), 23 deletions(-) create mode 100644 addons/common/functions/fnc_getTextFromConfig.sqf create mode 100644 addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/CfgSerialKillers.hpp diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index 18ba5837..df0ca2e9 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -12,6 +12,7 @@ PREP(getNearestLocationName); PREP(getNearestLocationWithAvailableName); PREP(getRandomEmptyPosition); PREP(getRandomPos); +PREP(getTextFromConfig); PREP(isHouseNearby); PREP(isRoadNearby); PREP(playMusicServer); diff --git a/addons/common/functions/fnc_getTextFromConfig.sqf b/addons/common/functions/fnc_getTextFromConfig.sqf new file mode 100644 index 00000000..122a8aec --- /dev/null +++ b/addons/common/functions/fnc_getTextFromConfig.sqf @@ -0,0 +1,29 @@ +#include "script_component.hpp" +/* + * Author: 3Mydlo3 + * Function loads config for killers stuff. + * + * Arguments: + * None + * + * Return Value: + * None + * + * Example: + * None + * + * Public: No + */ + +params ["_property", "_defaultConfig", "_missionConfig"]; + +private _result = getText (_missionConfig >> _property); + +if (_result isEqualTo "") then { + _result = getText (_defaultConfig >> _property); + TRACE_3("Loaded property %1 from %2. Retrieved value: %3",_property,str _defaultConfig,_result); +} else { + TRACE_3("Loaded property %1 from %2. Retrieved value: %3",_property,str _missionConfig,_result); +}; + +_result diff --git a/addons/killers/XEH_preInit.sqf b/addons/killers/XEH_preInit.sqf index 6ea6e34c..2e32f45e 100644 --- a/addons/killers/XEH_preInit.sqf +++ b/addons/killers/XEH_preInit.sqf @@ -10,4 +10,6 @@ if (!EGVAR(common,enabled)) exitWith {}; GVAR(killersRespawnMarker) = ""; GVAR(stashes) = []; +call FUNC(initConfig); + ADDON = true; diff --git a/addons/killers/functions/fnc_initConfig.sqf b/addons/killers/functions/fnc_initConfig.sqf index 3219cd23..f79dc5ef 100644 --- a/addons/killers/functions/fnc_initConfig.sqf +++ b/addons/killers/functions/fnc_initConfig.sqf @@ -18,14 +18,4 @@ private _killersConfig = (configFile >> "CfgSerialKillers" >> "Killers"); private _missionKillersConfig = (missionConfigFile >> "CfgSerialKillers" >> "Killers"); -private _fnc_getTextProperty = { - params ["_property"]; - - if (isClass (_missionKillersConfig >> _property)) exitWith { - getText (_missionKillersConfig >> _property) - }; - - getText (_killersConfig >> _property) -}; - -GVAR(flagClassName) = "FlagClassName" call _fnc_getTextProperty; +GVAR(flagClassName) = ["FlagClassName", _killersConfig, _missionKillersConfig] call EFUNC(common,getTextFromConfig); diff --git a/addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/CfgSerialKillers.hpp b/addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/CfgSerialKillers.hpp new file mode 100644 index 00000000..4c972693 --- /dev/null +++ b/addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/CfgSerialKillers.hpp @@ -0,0 +1,12 @@ +class CfgSerialKillers +{ + class Killers + { + FlagClassName = "FlagCarrierINS"; + }; + + class Police + { + FlagClassName = "FlagCarrierCDF"; + }; +}; diff --git a/addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/description.ext b/addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/description.ext index de177a13..7ee7b0bf 100644 --- a/addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/description.ext +++ b/addons/missions/SerialKillers_CUP_RHS.Chernarus_Winter/description.ext @@ -19,3 +19,5 @@ respawnDelay = 20; respawnOnStart = -1; respawnTemplatesWest[] = {"MenuPosition", "Counter"}; respawnTemplatesEast[] = {"Base", "Counter"}; + +#include "CfgSerialKillers.hpp" diff --git a/addons/police/CfgSerialKillers.hpp b/addons/police/CfgSerialKillers.hpp index 1816372f..605602aa 100644 --- a/addons/police/CfgSerialKillers.hpp +++ b/addons/police/CfgSerialKillers.hpp @@ -2,6 +2,6 @@ class CfgSerialKillers { class Police { - FlagClassName = "Flag_US_F"; + FlagClassName = "Flag_Gendarmerie_F"; }; }; diff --git a/addons/police/functions/fnc_initConfig.sqf b/addons/police/functions/fnc_initConfig.sqf index fe0cc058..f593c467 100644 --- a/addons/police/functions/fnc_initConfig.sqf +++ b/addons/police/functions/fnc_initConfig.sqf @@ -18,14 +18,4 @@ private _policeConfig = (configFile >> "CfgSerialKillers" >> "Police"); private _missionPoliceConfig = (missionConfigFile >> "CfgSerialKillers" >> "Police"); -private _fnc_getTextProperty = { - params ["_property"]; - - if (isClass (_missionPoliceConfig >> _property)) exitWith { - getText (_missionPoliceConfig >> _property) - }; - - getText (_policeConfig >> _property) -}; - -GVAR(flagClassName) = "FlagClassName" call _fnc_getTextProperty; +GVAR(flagClassName) = ["FlagClassName", _policeConfig, _missionPoliceConfig] call EFUNC(common,getTextFromConfig);