diff --git a/.gitignore b/.gitignore index 64dca67..aefb6f4 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,5 @@ releases/* keys/* .hemtt/local #### + +.vscode/ diff --git a/README.md b/README.md index 7cdb2e4..02ef454 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@

- Metis Enhanced Version + Metis Enhanced Version Metis Enhanced Downloads @@ -31,11 +31,13 @@ ## Components: - **Armory**: Allows you to save and load loadouts from a database across all server and missions. -- **Common**: Grass and bush cutter ACE action and chat commands for logged in admins. +- **Common**: Chat commands for logged in admins. - **Cords**: Cords for PBW uniforms (BW Kleiderkammer). +- **Cutter**: Grass and bush cutter ACE actions allowing to remove grass and bushes. - **Drill**: Animation and actions for exercise. - **Engineer**: Equipment for engineers like a Mine Clearing Line Charge (MICLIC). -- **Items**: Flags in different colors and markers/signs which are carryable and placable. +- **Flags**: Flags with various colors which can be placed or carried by players. +- **Items**: Markers/signs which are placable. - **Map**: Actions for the player to place his current map on the ground and on vehicles for others to look into. - **Remove Snakes**: Removes snakes from all maps. - **Whistle**: Adds a FOX 40 whistle. diff --git a/addons/common/XEH_PREP.hpp b/addons/common/XEH_PREP.hpp index b73855b..8ad7513 100644 --- a/addons/common/XEH_PREP.hpp +++ b/addons/common/XEH_PREP.hpp @@ -1,7 +1,4 @@ -PREP(addBushCutter); PREP(addChatCommands); -PREP(addGrassCutter); PREP(areModsLoaded); PREP(arsenalPBWFix); PREP(parseNameToPlayer); -PREP(seesBush); diff --git a/addons/common/XEH_postInit.sqf b/addons/common/XEH_postInit.sqf index 12495d2..4fe3673 100644 --- a/addons/common/XEH_postInit.sqf +++ b/addons/common/XEH_postInit.sqf @@ -1,6 +1,4 @@ #include "script_component.hpp" -call FUNC(addBushCutter); -call FUNC(addGrassCutter); call FUNC(arsenalPBWFix); call FUNC(addChatCommands); diff --git a/addons/common/XEH_preInit.sqf b/addons/common/XEH_preInit.sqf index a6780b1..b47cf66 100644 --- a/addons/common/XEH_preInit.sqf +++ b/addons/common/XEH_preInit.sqf @@ -6,10 +6,4 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; -// Print version to rpt log -private _version = getText (configFile >> "CfgPatches" >> "mts_main" >> "versionStr"); -INFO_1("Metis Enhanced version: %1.", _version); - -#include "initSettings.hpp" - ADDON = true; diff --git a/addons/common/config.cpp b/addons/common/config.cpp index 308b262..6637d67 100644 --- a/addons/common/config.cpp +++ b/addons/common/config.cpp @@ -6,7 +6,7 @@ class CfgPatches { units[] = {}; weapons[] = {}; requiredVersion = REQUIRED_VERSION; - requiredAddons[] = {"mts_main", "ace_common", "ace_interact_menu"}; + requiredAddons[] = {"mts_main", "ace_common"}; author = ECSTRING(main,authors); authors[] = {"PhILoX", "Timi007"}; url = ECSTRING(main,URL); diff --git a/addons/common/stringtable.xml b/addons/common/stringtable.xml index 1ef76b3..7cdb253 100644 --- a/addons/common/stringtable.xml +++ b/addons/common/stringtable.xml @@ -1,74 +1,6 @@ - - - Grass cutter - Grasschneider - - - Add grass cutter - Grasschneider hinzufügen - - - Adds the grass cutter to ACE interaction menu. - Fügt den Grasschneider zu dem ACE Interaktionmenu hinzu. - - - Remove grass - Gras entfernen - - - Grass cutter size - Grasschneidergröße - - - Changes the size of the grass cutter. - Ändert die Größe des Grasschneiders. - - - Large - Groß - - - Medium - Mittel - - - Duration - Dauer - - - Time it takes in seconds to remove grass. - Zeit in Sekunden, um Gras zu enfernen. - - - - - Bush cutter - Buschschere - - - Add bush cutter - Buschschere hinzufügen - - - Adds the bush cutter to ACE interaction menu. - Fügt die Buschschere zu dem ACE Interaktionmenu hinzu. - - - Remove bush - Busch entfernen - - - Duration - Dauer - - - Time it takes in seconds to remove a bush. - Zeit in Sekunden, um einen Busch zu enfernen. - - You can now use zeus. diff --git a/addons/cords/XEH_preInit.sqf b/addons/cords/XEH_preInit.sqf index bf0bf20..ce66aa6 100644 --- a/addons/cords/XEH_preInit.sqf +++ b/addons/cords/XEH_preInit.sqf @@ -15,7 +15,8 @@ GVAR(PBWLoaded) = [["PBW_German_Uniform", "PBW_German_Common"]] call EFUNC(commo [LELSTRING(main,category), LLSTRING(subCategory)], true, 0, - {} + {}, + true ] call CBA_fnc_addSetting; [ @@ -25,7 +26,8 @@ GVAR(PBWLoaded) = [["PBW_German_Uniform", "PBW_German_Common"]] call EFUNC(commo [LELSTRING(main,category), LLSTRING(subCategory)], "[""""]", 1, - {} + {}, + true ] call CBA_fnc_addSetting; ADDON = true; diff --git a/addons/cutter/$PBOPREFIX$ b/addons/cutter/$PBOPREFIX$ new file mode 100644 index 0000000..d501441 --- /dev/null +++ b/addons/cutter/$PBOPREFIX$ @@ -0,0 +1 @@ +z\mts_enhanced\addons\cutter diff --git a/addons/cutter/CfgEventHandlers.hpp b/addons/cutter/CfgEventHandlers.hpp new file mode 100644 index 0000000..f6503c2 --- /dev/null +++ b/addons/cutter/CfgEventHandlers.hpp @@ -0,0 +1,17 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_postInit)); + }; +}; diff --git a/addons/cutter/CfgWeapons.hpp b/addons/cutter/CfgWeapons.hpp new file mode 100644 index 0000000..c26d2b7 --- /dev/null +++ b/addons/cutter/CfgWeapons.hpp @@ -0,0 +1,20 @@ +class CfgWeapons { + class CBA_MiscItem; + class CBA_MiscItem_ItemInfo; + + class GVAR(folding_saw): CBA_MiscItem { + scope = 2; + author = CSTRING(authors); + descriptionShort = CSTRING(foldingSawDescription); + descriptionUse = CSTRING(foldingSawDescription); + + displayName = CSTRING(foldingSaw); + picture = QPATHTOF(data\pictures\folding_saw_item.paa); + + GVAR(canCutBushes) = 1; + + class ItemInfo: CBA_MiscItem_ItemInfo { + mass = 1; + }; + }; +}; diff --git a/addons/cutter/XEH_PREP.hpp b/addons/cutter/XEH_PREP.hpp new file mode 100644 index 0000000..c033e2a --- /dev/null +++ b/addons/cutter/XEH_PREP.hpp @@ -0,0 +1,4 @@ +PREP(addBushCutter); +PREP(addGrassCutter); +PREP(canCutBush); +PREP(seesBush); diff --git a/addons/cutter/XEH_postInit.sqf b/addons/cutter/XEH_postInit.sqf new file mode 100644 index 0000000..75c1583 --- /dev/null +++ b/addons/cutter/XEH_postInit.sqf @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +CHECK(!hasinterface); + +private _cfgWeapons = configFile >> "CfgWeapons"; +private _itemsAbleToCutBushes = (call (uiNamespace getVariable [QGVAR(itemsAbleToCutBushes), {[]}])) apply {_cfgWeapons >> _x}; +{ + private _name = configName _x; + + GVAR(bushCutterCache) set [_name, 1]; +} forEach _itemsAbleToCutBushes; + +// Support for other tools able to cut bushes without mod dependency +GVAR(bushCutterCache) set ["ACE_EntrenchingTool", 1]; + + +call FUNC(addBushCutter); +call FUNC(addGrassCutter); diff --git a/addons/cutter/XEH_preInit.sqf b/addons/cutter/XEH_preInit.sqf new file mode 100644 index 0000000..4b69d5f --- /dev/null +++ b/addons/cutter/XEH_preInit.sqf @@ -0,0 +1,13 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +#include "initSettings.hpp" + +GVAR(bushCutterCache) = createHashMap; + +ADDON = true; diff --git a/addons/cutter/XEH_preStart.sqf b/addons/cutter/XEH_preStart.sqf new file mode 100644 index 0000000..098a70a --- /dev/null +++ b/addons/cutter/XEH_preStart.sqf @@ -0,0 +1,6 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" + +private _itemsAbleToCutBushes = (configProperties [configfile >> "CfgWeapons", QUOTE(isClass _x && {(getNumber (_x >> QQGVAR(canCutBushes))) isEqualTo 1}), true]) apply {configName _x}; +uiNamespace setVariable [QGVAR(itemsAbleToCutBushes), compileFinal str _itemsAbleToCutBushes]; diff --git a/addons/cutter/config.cpp b/addons/cutter/config.cpp new file mode 100644 index 0000000..c644f0d --- /dev/null +++ b/addons/cutter/config.cpp @@ -0,0 +1,18 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = {}; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"mts_main", "ace_common", "ace_interact_menu"}; + author = ECSTRING(main,authors); + authors[] = {"PhILoX", "Timi007"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgWeapons.hpp" diff --git a/addons/common/ui/mts_bushcutter.paa b/addons/cutter/data/icons/bushcutter_icon.paa similarity index 100% rename from addons/common/ui/mts_bushcutter.paa rename to addons/cutter/data/icons/bushcutter_icon.paa diff --git a/addons/common/ui/mts_grasscutter.paa b/addons/cutter/data/icons/grasscutter_icon.paa similarity index 100% rename from addons/common/ui/mts_grasscutter.paa rename to addons/cutter/data/icons/grasscutter_icon.paa diff --git a/addons/cutter/data/pictures/folding_saw_item.paa b/addons/cutter/data/pictures/folding_saw_item.paa new file mode 100644 index 0000000..ccb3bb5 Binary files /dev/null and b/addons/cutter/data/pictures/folding_saw_item.paa differ diff --git a/addons/cutter/data/sounds/bush_cutting_1.ogg b/addons/cutter/data/sounds/bush_cutting_1.ogg new file mode 100644 index 0000000..3c6054d Binary files /dev/null and b/addons/cutter/data/sounds/bush_cutting_1.ogg differ diff --git a/addons/cutter/data/sounds/bush_cutting_2.ogg b/addons/cutter/data/sounds/bush_cutting_2.ogg new file mode 100644 index 0000000..82327c6 Binary files /dev/null and b/addons/cutter/data/sounds/bush_cutting_2.ogg differ diff --git a/addons/cutter/data/sounds/bush_cutting_3.ogg b/addons/cutter/data/sounds/bush_cutting_3.ogg new file mode 100644 index 0000000..ff9f4e8 Binary files /dev/null and b/addons/cutter/data/sounds/bush_cutting_3.ogg differ diff --git a/addons/cutter/data/sounds/bush_cutting_4.ogg b/addons/cutter/data/sounds/bush_cutting_4.ogg new file mode 100644 index 0000000..d527976 Binary files /dev/null and b/addons/cutter/data/sounds/bush_cutting_4.ogg differ diff --git a/addons/common/functions/fnc_addBushCutter.sqf b/addons/cutter/functions/fnc_addBushCutter.sqf similarity index 66% rename from addons/common/functions/fnc_addBushCutter.sqf rename to addons/cutter/functions/fnc_addBushCutter.sqf index 03bef0c..99f0dec 100644 --- a/addons/common/functions/fnc_addBushCutter.sqf +++ b/addons/cutter/functions/fnc_addBushCutter.sqf @@ -12,16 +12,20 @@ * Nothing * * Example: - * call mts_common_fnc_addBushCutter + * call mts_cutter_fnc_addBushCutter * */ -CHECK(!GVAR(bushcutter_enabled) || !hasinterface); +CHECK(!hasinterface); + +#define SOUND_DISTANCE 30 +#define SOUND_VOLUME 5 +#define SOUND_DELAY_FACTOR 0.2 private _action = [ QGVAR(bushcutter), LLSTRING(bushcutter_removeBush), - QPATHTOF(ui\mts_bushcutter.paa), + QPATHTOF(data\icons\bushcutter_icon.paa), { params ["", "_player"]; @@ -35,6 +39,15 @@ private _action = [ _player playMove "AinvPknlMstpSnonWnonDnon_medic0"; }; + private _soundDelay = GVAR(bushcutter_duration) * SOUND_DELAY_FACTOR; + [{ + params ["_bush"]; + + private _soundFile = format [QPATHTO_R(data\sounds\bush_cutting_%1.ogg), (floor random 4) + 1]; + + playSound3D [_soundFile, _bush, false, getPosASL _bush, SOUND_VOLUME, 1, SOUND_DISTANCE]; + }, [_bush], _soundDelay] call CBA_fnc_waitAndExecute; + [GVAR(bushcutter_duration), [_bush], { (_this select 0) params ["_bush"]; @@ -45,8 +58,7 @@ private _action = [ }, { params ["", "_player"]; - [_player, objNull] call ace_common_fnc_canInteractWith && - {!isNull ([_player, BUSH_CUTTING_DISTANCE] call FUNC(seesBush))} + ([_player, BUSH_CUTTING_DISTANCE] call FUNC(canCutBush)) } ] call ace_interact_menu_fnc_createAction; [(typeOf ACE_player), 1, ["ACE_SelfActions", "ACE_Equipment"], _action] call ace_interact_menu_fnc_addActionToClass; diff --git a/addons/common/functions/fnc_addGrassCutter.sqf b/addons/cutter/functions/fnc_addGrassCutter.sqf similarity index 85% rename from addons/common/functions/fnc_addGrassCutter.sqf rename to addons/cutter/functions/fnc_addGrassCutter.sqf index 7d77011..da257ee 100644 --- a/addons/common/functions/fnc_addGrassCutter.sqf +++ b/addons/cutter/functions/fnc_addGrassCutter.sqf @@ -12,16 +12,16 @@ * Nothing * * Example: - * call mts_common_fnc_addGrassCutter + * call mts_cutter_fnc_addGrassCutter * */ -CHECK(!GVAR(grasscutter_enabled) || !hasinterface); +CHECK(!hasinterface); private _action = [ QGVAR(grasscutter), LLSTRING(grasscutter_removeGrass), - QPATHTOF(ui\mts_grasscutter.paa), + QPATHTOF(data\icons\grasscutter_icon.paa), { params ["", "_player"]; @@ -43,7 +43,8 @@ private _action = [ }, { params ["", "_player"]; - [_player, objNull] call ace_common_fnc_canInteractWith + GVAR(grasscutter_enabled) && + {[_player, objNull] call ace_common_fnc_canInteractWith} } ] call ace_interact_menu_fnc_createAction; [(typeOf ACE_player), 1, ["ACE_SelfActions", "ACE_Equipment"], _action] call ace_interact_menu_fnc_addActionToClass; diff --git a/addons/cutter/functions/fnc_canCutBush.sqf b/addons/cutter/functions/fnc_canCutBush.sqf new file mode 100644 index 0000000..bf9c1d9 --- /dev/null +++ b/addons/cutter/functions/fnc_canCutBush.sqf @@ -0,0 +1,31 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Checks if the given unit can cut the bush in front of him. + * + * Parameter(s): + * 0: OBJECT - Unit. + * 1: NUMBER - Max distance the unit can be away from the bush. + * + * Returns: + * BOOLEAN - Can cut the bush. + * + * Example: + * [player, 6] call mts_cutter_fnc_canCutBush; + * + */ + +params ["_player", ["_maxDistance", 5, [0]]]; + +if (!GVAR(bushcutter_enabled)) exitwith {false}; +if (!([_player, objNull] call ace_common_fnc_canInteractWith)) exitwith {false}; + +private _hasItem = if (GVAR(bushcutter_requireItem)) then { + count (([_player] call ace_common_fnc_uniqueItems) arrayIntersect keys GVAR(bushCutterCache)) > 0 +} else { + true +}; + +_hasItem && {!isNull ([_player, _maxDistance] call FUNC(seesBush))} diff --git a/addons/common/functions/fnc_seesBush.sqf b/addons/cutter/functions/fnc_seesBush.sqf similarity index 95% rename from addons/common/functions/fnc_seesBush.sqf rename to addons/cutter/functions/fnc_seesBush.sqf index 9f2c3f8..a5b91f4 100644 --- a/addons/common/functions/fnc_seesBush.sqf +++ b/addons/cutter/functions/fnc_seesBush.sqf @@ -13,7 +13,7 @@ * OBJECT - Bush that the given unit sees or objNull if there is no bush. * * Example: - * [player] call mts_common_fnc_seesBush; + * [player] call mts_cutter_fnc_seesBush; * */ diff --git a/addons/cutter/functions/script_component.hpp b/addons/cutter/functions/script_component.hpp new file mode 100644 index 0000000..8d68cdb --- /dev/null +++ b/addons/cutter/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\mts_enhanced\addons\cutter\script_component.hpp" diff --git a/addons/common/initSettings.hpp b/addons/cutter/initSettings.hpp similarity index 84% rename from addons/common/initSettings.hpp rename to addons/cutter/initSettings.hpp index 23c5f31..d6dc8e7 100644 --- a/addons/common/initSettings.hpp +++ b/addons/cutter/initSettings.hpp @@ -59,3 +59,13 @@ [MIN_DURATION, MAX_DURATION, DEFAULT_BUSHCUTTER_DURATION, TRAILING_DECIMALS], 1 // Server setting ] call CBA_fnc_addSetting; + +// Bushcutter: Require designated item to cut down a bush +[ + QGVAR(bushcutter_requireItem), + "CHECKBOX", + [LLSTRING(bushcutter_requireItem), LLSTRING(bushcutter_requireItem_tooltip)], + [LELSTRING(main,category), LLSTRING(bushcutter_subCategory)], + false, + 1 // Server setting +] call CBA_fnc_addSetting; diff --git a/addons/cutter/script_component.hpp b/addons/cutter/script_component.hpp new file mode 100644 index 0000000..46458c6 --- /dev/null +++ b/addons/cutter/script_component.hpp @@ -0,0 +1,19 @@ +#define COMPONENT cutter +#define COMPONENT_BEAUTIFIED Cutter +#include "\z\mts_enhanced\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS + +#ifdef DEBUG_ENABLED_CUTTER + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_CUTTER + #define DEBUG_SETTINGS DEBUG_SETTINGS_CUTTER +#endif + +#include "\z\mts_enhanced\addons\main\script_macros.hpp" + +#define BUSH_CUTTING_DISTANCE 2 diff --git a/addons/cutter/stringtable.xml b/addons/cutter/stringtable.xml new file mode 100644 index 0000000..80b3e31 --- /dev/null +++ b/addons/cutter/stringtable.xml @@ -0,0 +1,97 @@ + + + + + + Timi007 + Timi007 + + + + + Grass cutter + Grasschneider + + + Add grass cutter + Grasschneider hinzufügen + + + Adds the grass cutter to ACE interaction menu. + Fügt den Grasschneider zu dem ACE Interaktionmenu hinzu. + + + Remove grass + Gras entfernen + + + Grass cutter size + Grasschneidergröße + + + Changes the size of the grass cutter. + Ändert die Größe des Grasschneiders. + + + Large + Groß + + + Medium + Mittel + + + Duration + Dauer + + + Time it takes in seconds to remove grass. + Zeit in Sekunden, um Gras zu enfernen. + + + + + Bush cutter + Buschschere + + + Add bush cutter + Buschschere hinzufügen + + + Adds the bush cutter to ACE interaction menu. + Fügt die Buschschere zu dem ACE Interaktionmenu hinzu. + + + Remove bush + Busch entfernen + + + Duration + Dauer + + + Time it takes in seconds to remove a bush. + Zeit in Sekunden, um einen Busch zu enfernen. + + + Require item + Benötigt Gegenstand + + + Require a saw to remove bushes. + Benötigt eine Säge, um Büsche zu entfernen. + + + + + Folding Saw + Klappsäge + + + Blade length 18 cm<br />Can be used to prune and remove bushes. + Sägelänge 18 cm<br />Kann benutzt werden, um Äste und Büsche zu entfernen. + + + + diff --git a/addons/engineer/stringtable.xml b/addons/engineer/stringtable.xml index 6cb5e49..82f8811 100644 --- a/addons/engineer/stringtable.xml +++ b/addons/engineer/stringtable.xml @@ -2,7 +2,7 @@ - + Timi007, Mishkar Timi007, Mishkar diff --git a/addons/flags/$PBOPREFIX$ b/addons/flags/$PBOPREFIX$ new file mode 100644 index 0000000..e70bd7e --- /dev/null +++ b/addons/flags/$PBOPREFIX$ @@ -0,0 +1 @@ +z\mts_enhanced\addons\flags diff --git a/addons/flags/CfgEventHandlers.hpp b/addons/flags/CfgEventHandlers.hpp new file mode 100644 index 0000000..b468b9e --- /dev/null +++ b/addons/flags/CfgEventHandlers.hpp @@ -0,0 +1,23 @@ +class Extended_PreStart_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preStart)); + }; +}; + +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; + +class Extended_PostInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_postInit)); + }; +}; + +class Extended_DisplayLoad_EventHandlers { + class RscDisplayMission { + ADDON = QUOTE(_this call COMPILE_SCRIPT(XEH_missionDisplayLoad)); + }; +}; diff --git a/addons/flags/CfgVehicles.hpp b/addons/flags/CfgVehicles.hpp new file mode 100644 index 0000000..7de5023 --- /dev/null +++ b/addons/flags/CfgVehicles.hpp @@ -0,0 +1,21 @@ +class CfgVehicles { + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class ACE_Equipment { + class ADDON { + displayName = CSTRING(ActionCategory); + insertChildren = QUOTE(_this call FUNC(getActions)); + icon = QPATHTOF(data\icons\place\white_place_icon.paa); + + class GVAR(furlFlag) { + displayName = CSTRING(Furl); + condition = QUOTE(_player call FUNC(carriesFlag)); + statement = QUOTE(_player call FUNC(furlFlag)); + icon = QPATHTOF(data\icons\carry\white_furl_icon.paa); + }; + }; + }; + }; + }; +}; diff --git a/addons/flags/CfgWeapons.hpp b/addons/flags/CfgWeapons.hpp new file mode 100644 index 0000000..ce4cb6d --- /dev/null +++ b/addons/flags/CfgWeapons.hpp @@ -0,0 +1,78 @@ +class CfgWeapons { + class CBA_MiscItem; + class CBA_MiscItem_ItemInfo; + + class GVAR(white): CBA_MiscItem { + scope = 2; + author = CSTRING(Authors); + descriptionShort = CSTRING(Description); + descriptionUse = CSTRING(Description); + + displayName = CSTRING(White); + picture = QPATHTOF(data\pictures\white_item.paa); + + GVAR(texture) = "\a3\data_f\flags\flag_white_co.paa"; + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\white_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\white_carry_icon.paa); + + class ItemInfo: CBA_MiscItem_ItemInfo { + mass = 3; + }; + }; + class GVAR(red): GVAR(white) { + displayName = CSTRING(Red); + picture = QPATHTOF(data\pictures\red_item.paa); + + GVAR(texture) = "\a3\data_f\flags\flag_red_co.paa"; + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\red_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\red_carry_icon.paa); + }; + class GVAR(blue): GVAR(white) { + displayName = CSTRING(Blue); + picture = QPATHTOF(data\pictures\blue_item.paa); + + GVAR(texture) = "\a3\data_f\flags\Flag_blue_co.paa"; + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\blue_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\blue_carry_icon.paa); + }; + class GVAR(green): GVAR(white) { + displayName = CSTRING(Green); + picture = QPATHTOF(data\pictures\green_item.paa); + + GVAR(texture) = "\a3\data_f\flags\flag_green_co.paa"; + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\green_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\green_carry_icon.paa); + }; + class GVAR(yellow): GVAR(white) { + displayName = CSTRING(Yellow); + picture = QPATHTOF(data\pictures\yellow_item.paa); + + GVAR(texture) = QPATHTOF(data\flag_yellow_co.paa); + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\yellow_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\yellow_carry_icon.paa); + }; + class GVAR(orange): GVAR(white) { + displayName = CSTRING(Orange); + picture = QPATHTOF(data\pictures\orange_item.paa); + + GVAR(texture) = QPATHTOF(data\flag_orange_co.paa); + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\orange_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\orange_carry_icon.paa); + }; + class GVAR(purple): GVAR(white) { + displayName = CSTRING(Purple); + picture = QPATHTOF(data\pictures\purple_item.paa); + + GVAR(texture) = QPATHTOF(data\flag_purple_co.paa); + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\purple_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\purple_carry_icon.paa); + }; + class GVAR(black): GVAR(white) { + displayName = CSTRING(Black); + picture = QPATHTOF(data\pictures\black_item.paa); + + GVAR(texture) = QPATHTOF(data\flag_black_co.paa); + GVAR(actionIconPlace) = QPATHTOF(data\icons\place\black_place_icon.paa); + GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\black_carry_icon.paa); + }; +}; diff --git a/addons/flags/XEH_PREP.hpp b/addons/flags/XEH_PREP.hpp new file mode 100644 index 0000000..0ddfcdd --- /dev/null +++ b/addons/flags/XEH_PREP.hpp @@ -0,0 +1,8 @@ +PREP(carriesFlag); +PREP(carryFlag); +PREP(furlFlag); +PREP(getActions); +PREP(getFlags); +PREP(handleScrollWheel); +PREP(pickupFlag); +PREP(placeFlag); diff --git a/addons/flags/XEH_missionDisplayLoad.sqf b/addons/flags/XEH_missionDisplayLoad.sqf new file mode 100644 index 0000000..e276b73 --- /dev/null +++ b/addons/flags/XEH_missionDisplayLoad.sqf @@ -0,0 +1,17 @@ +#include "script_component.hpp" + +CHECK(!hasInterface); + +params ["_display"]; + +_display displayAddEventHandler ["MouseZChanged", { + params ["", "_scroll"]; + [_scroll] call FUNC(handleScrollWheel); +}]; + +_display displayAddEventHandler ["MouseButtonDown", { + params ["", "_button"]; + if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith {false}; + if (_button isNotEqualTo 1) exitWith {false}; // 1 = Left mouse button + GVAR(isPlacing) = PLACE_CANCEL; +}]; diff --git a/addons/flags/XEH_postInit.sqf b/addons/flags/XEH_postInit.sqf new file mode 100644 index 0000000..545ff58 --- /dev/null +++ b/addons/flags/XEH_postInit.sqf @@ -0,0 +1,40 @@ +#include "script_component.hpp" + +CHECK(!hasinterface); + +GVAR(isPlacing) = PLACE_CANCEL; +["ace_interactMenuOpened", {GVAR(isPlacing) = PLACE_CANCEL;}] call CBA_fnc_addEventHandler; + +[QGVAR(flagPlaced), { + params ["_unit", "_item", "_flag"]; + + (GVAR(flagItemCache) get _item) params ["_flagName"]; + + private _pickupFlag = [ + QGVAR(pickup), + format [LLSTRING(Pickup), _flagName], + QPATHTOF(data\icons\place\white_pickup_icon.paa), + { + params ["_flag", "_unit", "_item"]; + [_unit, _item, _flag] call FUNC(pickupFlag); + }, + {true}, + {}, + _item, + [0, -0.45, 0.75], + 2 + ] call ace_interact_menu_fnc_createAction; + [_flag, 0, [], _pickupFlag] call ace_interact_menu_fnc_addActionToObject; +}] call CBA_fnc_addEventHandler; + +private _cfgWeapons = configFile >> "CfgWeapons"; +private _flagItems = (call (uiNamespace getVariable [QGVAR(allFlagItems), {[]}])) apply {_cfgWeapons >> _x}; +{ + private _name = configName _x; + private _displayName = getText (_x >> "displayName"); + private _texture = getText (_x >> QGVAR(texture)); + private _actionIconPlace = getText (_x >> QGVAR(actionIconPlace)); + private _actionIconCarry = getText (_x >> QGVAR(actionIconCarry)); + + GVAR(flagItemCache) set [_name, [_displayName, _texture, _actionIconPlace, _actionIconCarry]]; +} forEach _flagItems; diff --git a/addons/flags/XEH_preInit.sqf b/addons/flags/XEH_preInit.sqf new file mode 100644 index 0000000..8b0f742 --- /dev/null +++ b/addons/flags/XEH_preInit.sqf @@ -0,0 +1,13 @@ +#include "script_component.hpp" + +ADDON = false; + +PREP_RECOMPILE_START; +#include "XEH_PREP.hpp" +PREP_RECOMPILE_END; + +#include "initSettings.hpp" + +GVAR(flagItemCache) = createHashMap; + +ADDON = true; diff --git a/addons/flags/XEH_preStart.sqf b/addons/flags/XEH_preStart.sqf new file mode 100644 index 0000000..8b172c6 --- /dev/null +++ b/addons/flags/XEH_preStart.sqf @@ -0,0 +1,6 @@ +#include "script_component.hpp" + +#include "XEH_PREP.hpp" + +private _flagItems = (configProperties [configfile >> "CfgWeapons", QUOTE(isClass _x && {isText (_x >> QQGVAR(texture))}), true]) apply {configName _x}; +uiNamespace setVariable [QGVAR(allFlagItems), compileFinal str _flagItems]; diff --git a/addons/flags/config.cpp b/addons/flags/config.cpp new file mode 100644 index 0000000..fb01163 --- /dev/null +++ b/addons/flags/config.cpp @@ -0,0 +1,28 @@ +#include "script_component.hpp" + +class CfgPatches { + class ADDON { + name = COMPONENT_NAME; + units[] = {}; + weapons[] = { + QGVAR(white), + QGVAR(red), + QGVAR(blue), + QGVAR(green), + QGVAR(yellow), + QGVAR(orange), + QGVAR(purple), + QGVAR(black) + }; + requiredVersion = REQUIRED_VERSION; + requiredAddons[] = {"ace_common", "ace_interact_menu", "ace_interaction"}; + author = ECSTRING(main,authors); + authors[] = {"Timi007"}; + url = ECSTRING(main,URL); + VERSION_CONFIG; + }; +}; + +#include "CfgEventHandlers.hpp" +#include "CfgVehicles.hpp" +#include "CfgWeapons.hpp" diff --git a/addons/flags/data/flag_black_co.paa b/addons/flags/data/flag_black_co.paa new file mode 100644 index 0000000..4a9ead5 Binary files /dev/null and b/addons/flags/data/flag_black_co.paa differ diff --git a/addons/flags/data/flag_orange_co.paa b/addons/flags/data/flag_orange_co.paa new file mode 100644 index 0000000..2398005 Binary files /dev/null and b/addons/flags/data/flag_orange_co.paa differ diff --git a/addons/flags/data/flag_purple_co.paa b/addons/flags/data/flag_purple_co.paa new file mode 100644 index 0000000..4aaf635 Binary files /dev/null and b/addons/flags/data/flag_purple_co.paa differ diff --git a/addons/items/data/Flag_yellow_co.paa b/addons/flags/data/flag_yellow_co.paa similarity index 100% rename from addons/items/data/Flag_yellow_co.paa rename to addons/flags/data/flag_yellow_co.paa diff --git a/addons/flags/data/icons/carry/black_carry_icon.paa b/addons/flags/data/icons/carry/black_carry_icon.paa new file mode 100644 index 0000000..3cd6671 Binary files /dev/null and b/addons/flags/data/icons/carry/black_carry_icon.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_blue_carry_icon.paa b/addons/flags/data/icons/carry/blue_carry_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_blue_carry_icon.paa rename to addons/flags/data/icons/carry/blue_carry_icon.paa diff --git a/addons/items/data/ui/flags/mts_flag_green_carry_icon.paa b/addons/flags/data/icons/carry/green_carry_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_green_carry_icon.paa rename to addons/flags/data/icons/carry/green_carry_icon.paa diff --git a/addons/flags/data/icons/carry/orange_carry_icon.paa b/addons/flags/data/icons/carry/orange_carry_icon.paa new file mode 100644 index 0000000..67e1ef3 Binary files /dev/null and b/addons/flags/data/icons/carry/orange_carry_icon.paa differ diff --git a/addons/flags/data/icons/carry/purple_carry_icon.paa b/addons/flags/data/icons/carry/purple_carry_icon.paa new file mode 100644 index 0000000..944677f Binary files /dev/null and b/addons/flags/data/icons/carry/purple_carry_icon.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_red_carry_icon.paa b/addons/flags/data/icons/carry/red_carry_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_red_carry_icon.paa rename to addons/flags/data/icons/carry/red_carry_icon.paa diff --git a/addons/flags/data/icons/carry/white_carry_icon.paa b/addons/flags/data/icons/carry/white_carry_icon.paa new file mode 100644 index 0000000..9949907 Binary files /dev/null and b/addons/flags/data/icons/carry/white_carry_icon.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_furl_icon.paa b/addons/flags/data/icons/carry/white_furl_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_furl_icon.paa rename to addons/flags/data/icons/carry/white_furl_icon.paa diff --git a/addons/items/data/ui/flags/mts_flag_yellow_carry_icon.paa b/addons/flags/data/icons/carry/yellow_carry_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_yellow_carry_icon.paa rename to addons/flags/data/icons/carry/yellow_carry_icon.paa diff --git a/addons/flags/data/icons/place/black_place_icon.paa b/addons/flags/data/icons/place/black_place_icon.paa new file mode 100644 index 0000000..6b7a359 Binary files /dev/null and b/addons/flags/data/icons/place/black_place_icon.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_blue_place_icon.paa b/addons/flags/data/icons/place/blue_place_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_blue_place_icon.paa rename to addons/flags/data/icons/place/blue_place_icon.paa diff --git a/addons/items/data/ui/flags/mts_flag_green_place_icon.paa b/addons/flags/data/icons/place/green_place_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_green_place_icon.paa rename to addons/flags/data/icons/place/green_place_icon.paa diff --git a/addons/flags/data/icons/place/orange_place_icon.paa b/addons/flags/data/icons/place/orange_place_icon.paa new file mode 100644 index 0000000..1851439 Binary files /dev/null and b/addons/flags/data/icons/place/orange_place_icon.paa differ diff --git a/addons/flags/data/icons/place/purple_place_icon.paa b/addons/flags/data/icons/place/purple_place_icon.paa new file mode 100644 index 0000000..371fff0 Binary files /dev/null and b/addons/flags/data/icons/place/purple_place_icon.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_red_place_icon.paa b/addons/flags/data/icons/place/red_place_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_red_place_icon.paa rename to addons/flags/data/icons/place/red_place_icon.paa diff --git a/addons/items/data/ui/flags/mts_flag_pickup_icon.paa b/addons/flags/data/icons/place/white_pickup_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_pickup_icon.paa rename to addons/flags/data/icons/place/white_pickup_icon.paa diff --git a/addons/items/data/ui/flags/mts_flag_white_icon.paa b/addons/flags/data/icons/place/white_place_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_white_icon.paa rename to addons/flags/data/icons/place/white_place_icon.paa diff --git a/addons/items/data/ui/flags/mts_flag_yellow_place_icon.paa b/addons/flags/data/icons/place/yellow_place_icon.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_yellow_place_icon.paa rename to addons/flags/data/icons/place/yellow_place_icon.paa diff --git a/addons/flags/data/pictures/black_item.paa b/addons/flags/data/pictures/black_item.paa new file mode 100644 index 0000000..fe2b818 Binary files /dev/null and b/addons/flags/data/pictures/black_item.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_blue_item_icon.paa b/addons/flags/data/pictures/blue_item.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_blue_item_icon.paa rename to addons/flags/data/pictures/blue_item.paa diff --git a/addons/items/data/ui/flags/mts_flag_green_item_icon.paa b/addons/flags/data/pictures/green_item.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_green_item_icon.paa rename to addons/flags/data/pictures/green_item.paa diff --git a/addons/flags/data/pictures/orange_item.paa b/addons/flags/data/pictures/orange_item.paa new file mode 100644 index 0000000..665fb8d Binary files /dev/null and b/addons/flags/data/pictures/orange_item.paa differ diff --git a/addons/flags/data/pictures/purple_item.paa b/addons/flags/data/pictures/purple_item.paa new file mode 100644 index 0000000..70a7539 Binary files /dev/null and b/addons/flags/data/pictures/purple_item.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_red_item_icon.paa b/addons/flags/data/pictures/red_item.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_red_item_icon.paa rename to addons/flags/data/pictures/red_item.paa diff --git a/addons/flags/data/pictures/white_item.paa b/addons/flags/data/pictures/white_item.paa new file mode 100644 index 0000000..e0353f2 Binary files /dev/null and b/addons/flags/data/pictures/white_item.paa differ diff --git a/addons/items/data/ui/flags/mts_flag_yellow_item_icon.paa b/addons/flags/data/pictures/yellow_item.paa similarity index 100% rename from addons/items/data/ui/flags/mts_flag_yellow_item_icon.paa rename to addons/flags/data/pictures/yellow_item.paa diff --git a/addons/flags/functions/fnc_carriesFlag.sqf b/addons/flags/functions/fnc_carriesFlag.sqf new file mode 100644 index 0000000..4b3a82d --- /dev/null +++ b/addons/flags/functions/fnc_carriesFlag.sqf @@ -0,0 +1,22 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Checks if the unit is carrying a flag. + * + * Parameter(s): + * 0: OBJECT - Unit. + * + * Returns: + * BOOLEAN - True if unit is carrying a flag; otherwise flase. + * + * Example: + * [player] call mts_flags_fnc_carriesFlag + * + */ + +params ["_unit"]; + +(_unit getVariable [QGVAR(carryingFlag), ""] isNotEqualTo "") && +{(getForcedFlagTexture _unit) isNotEqualTo ""} diff --git a/addons/flags/functions/fnc_carryFlag.sqf b/addons/flags/functions/fnc_carryFlag.sqf new file mode 100644 index 0000000..58af100 --- /dev/null +++ b/addons/flags/functions/fnc_carryFlag.sqf @@ -0,0 +1,27 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Attaches flag to the back of the unit and removes his flag item. + * + * Parameter(s): + * 0: OBJECT - Unit. + * 1: STRING - Flag item. + * + * Returns: + * Nothing. + * + * Example: + * [player, "mts_flags_white"] call mts_flags_fnc_carryFlag + * + */ + +params ["_unit", "_item"]; +TRACE_2("Carry flag", _unit, _item); + +(GVAR(flagItemCache) get _item) params ["", "_texture"]; +_unit forceFlagTexture _texture; + +_unit setVariable [QGVAR(carryingFlag), _item, true]; +_unit removeItem _item; diff --git a/addons/flags/functions/fnc_furlFlag.sqf b/addons/flags/functions/fnc_furlFlag.sqf new file mode 100644 index 0000000..8b66fe4 --- /dev/null +++ b/addons/flags/functions/fnc_furlFlag.sqf @@ -0,0 +1,27 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Stops carrying flag and adds flag item back to unit. + * + * Parameter(s): + * 0: OBJECT - Unit. + * + * Returns: + * Nothing. + * + * Example: + * [player] call mts_flags_fnc_furlFlag + * + */ + +params ["_unit"]; + +// Stop carrying flag and add flag item to unit. +_item = _unit getVariable [QGVAR(carryingFlag), ""]; +_unit setVariable [QGVAR(carryingFlag), nil, true]; + +_unit forceFlagTexture ""; // Remove flag + +[_unit, _item] call ace_common_fnc_addToInventory; diff --git a/addons/flags/functions/fnc_getActions.sqf b/addons/flags/functions/fnc_getActions.sqf new file mode 100644 index 0000000..34d1a29 --- /dev/null +++ b/addons/flags/functions/fnc_getActions.sqf @@ -0,0 +1,63 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Gets the child actions for placing and carring flags. + * + * Parameter(s): + * 0: OBJECT - Player. + * + * Returns: + * ARRAY - Actions. + * + * Example: + * [player] call mts_flags_fnc_getActions + * + */ + +params ["_player"]; + +private _actions = []; + +{ + (GVAR(flagItemCache) get _x) params ["_flagName", "_texture", "_actionIconPlace", "_actionIconCarry"]; + + // Place flag + _actions pushBack [ + [ + "place_" + _x, + format [LLSTRING(Place), _flagName], + _actionIconPlace, + { + params ["_player", "", "_item"]; + [_player, _item] call FUNC(placeFlag); + }, + {GVAR(enablePlacing)}, + {}, + _x + ] call ace_interact_menu_fnc_createAction, + [], + _player + ]; + + // Carry flag + _actions pushBack [ + [ + "carry_" + _x, + format [LLSTRING(Carry), _flagName], + _actionIconCarry, + { + params ["_player", "", "_item"]; + [_player, _item] call FUNC(carryFlag); + }, + {GVAR(enableCarrying) && {!([_this select 0] call FUNC(carriesFlag))}}, // Should not carry flag already + {}, + _x + ] call ace_interact_menu_fnc_createAction, + [], + _player + ]; +} forEach ([_player] call FUNC(getFlags)); + +_actions diff --git a/addons/flags/functions/fnc_getFlags.sqf b/addons/flags/functions/fnc_getFlags.sqf new file mode 100644 index 0000000..f22405a --- /dev/null +++ b/addons/flags/functions/fnc_getFlags.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Get the placeable and carryable flags in the unit's inventory. + * + * Parameter(s): + * 0: OBJECT - Unit + * + * Returns: + * ARRAY - Flag items. + * + * Example: + * [player] call mts_flags_fnc_getFlags + * + */ + +params ["_unit"]; + +(_unit call ace_common_fnc_uniqueItems) arrayIntersect keys GVAR(flagItemCache) diff --git a/addons/flags/functions/fnc_handleScrollWheel.sqf b/addons/flags/functions/fnc_handleScrollWheel.sqf new file mode 100644 index 0000000..1b2f995 --- /dev/null +++ b/addons/flags/functions/fnc_handleScrollWheel.sqf @@ -0,0 +1,31 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Handles the flag object height. + * + * Parameter(s): + * 0: NUMBER - Scroll amount + * + * Returns: + * BOOLEAN - Handled + * + * Example: + * [5] call mts_flags_fnc_handleScrollWheel + * + */ + +params [["_scrollAmount", 0, [0]]]; + +if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith { + false +}; + +// Move object height 10cm per scroll +GVAR(objectHeight) = GVAR(objectHeight) + (_scrollAmount * 0.1); + +// Clamp height between MIN_HEIGHT and MAX_HEIGHT +GVAR(objectHeight) = (MIN_HEIGHT max (GVAR(objectHeight) min MAX_HEIGHT)); + +true diff --git a/addons/flags/functions/fnc_pickupFlag.sqf b/addons/flags/functions/fnc_pickupFlag.sqf new file mode 100644 index 0000000..71f0243 --- /dev/null +++ b/addons/flags/functions/fnc_pickupFlag.sqf @@ -0,0 +1,31 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Picks up flag and adds item to unit. + * + * Parameter(s): + * 0: OBJECT - Unit. + * 1: STRING - Flag item. + * 2: OBJECT - Flag pole (gets deleted later). + * + * Returns: + * Nothing. + * + * Example: + * [player, "mts_flags_white", my_flag] call mts_flags_fnc_pickupFlag + * + */ + +params ["_unit", "_item", "_flag"]; +TRACE_3("Flag pickup", _unit, _item, _flag); + +[_unit, "PutDown"] call ace_common_fnc_doGesture; + +[{ + params ["_unit", "_item", "_flag"]; + + [_unit, _item] call ace_common_fnc_addToInventory; + deleteVehicle _flag; +}, [_unit, _item, _flag], 0.7] call CBA_fnc_waitAndExecute; diff --git a/addons/flags/functions/fnc_placeFlag.sqf b/addons/flags/functions/fnc_placeFlag.sqf new file mode 100644 index 0000000..ab83505 --- /dev/null +++ b/addons/flags/functions/fnc_placeFlag.sqf @@ -0,0 +1,81 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Starts the placing process of the flag for the player. + * Flags can be placed with the special flag items. + * + * Parameter(s): + * 0: OBJECT - Player. + * 1: STRING - Flag item. + * + * Returns: + * Nothing. + * + * Example: + * [player, "mts_flags_white"] call mts_flags_fnc_placeFlag + * + */ + +params ["_player", "_item"]; +TRACE_2("Placing flag", _player, _item); + +private _flag = "FlagChecked_F" createVehicle [0, 0, 0]; + +// Set flag start height +GVAR(objectHeight) = MIN_HEIGHT; + +GVAR(isPlacing) = PLACE_WAITING; + +(GVAR(flagItemCache) get _item) params ["_flagName", "_texture"]; + +_flag setFlagTexture _texture; + +// Add info dialog for the player which show the controls +private _placeFlagText = format [LLSTRING(Place), _flagName]; +[_placeFlagText, LLSTRING(Cancel), LLSTRING(AdjustHeight)] call ace_interaction_fnc_showMouseHint; + +private _mouseClickID = [_player, "DefaultAction", { + GVAR(isPlacing) isEqualTo PLACE_WAITING +}, { + GVAR(isPlacing) = PLACE_APPROVE +}] call ace_common_fnc_addActionEventHandler; + +[{ // Start of PFH + params ["_args", "_handle"]; + _args params ["_player", "_item", "_flag", "_mouseClickID"]; + + if (isNull _flag || {!([_player, _flag] call ace_common_fnc_canInteractWith)}) then { + GVAR(isPlacing) = PLACE_CANCEL; + }; + + if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + call ace_interaction_fnc_hideMouseHint; + [_player, "DefaultAction", _mouseClickID] call ace_common_fnc_removeActionEventHandler; + + if (GVAR(isPlacing) isEqualTo PLACE_APPROVE) then { + // End position of the flag + + GVAR(isPlacing) = PLACE_CANCEL; + + [_player, "PutDown"] call ace_common_fnc_doGesture; + + _player removeItem _item; + + private _jipID = [QGVAR(flagPlaced), [_player, _item, _flag]] call CBA_fnc_globalEventJIP; + [_jipID, _flag] call CBA_fnc_removeGlobalEventJIP; + } else { + // Action is canceled + deleteVehicle _flag; + }; + }; + + private _pos = ((eyePos _player) vectorAdd ((getCameraViewDirection _player) vectorMultiply FLAG_PLACING_DISTANCE)); + // Adjust height of flag with the scroll wheel + _pos set [2, ((getPosWorld _player) select 2) + GVAR(objectHeight)]; + + _flag setPosWorld _pos; + _flag setDir (getDir _player); +}, 0, [_player, _item, _flag, _mouseClickID]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/flags/functions/script_component.hpp b/addons/flags/functions/script_component.hpp new file mode 100644 index 0000000..4aec1f6 --- /dev/null +++ b/addons/flags/functions/script_component.hpp @@ -0,0 +1 @@ +#include "\z\mts_enhanced\addons\flags\script_component.hpp" diff --git a/addons/flags/initSettings.hpp b/addons/flags/initSettings.hpp new file mode 100644 index 0000000..bfe56ef --- /dev/null +++ b/addons/flags/initSettings.hpp @@ -0,0 +1,17 @@ +private _category = [LELSTRING(main,category), LLSTRING(SettingCategory)]; + +[ + QGVAR(enablePlacing), "CHECKBOX", + [LSTRING(AllowPlacingFlags), LSTRING(AllowPlacingFlagsTooltip)], + _category, + true, + 0 +] call CBA_fnc_addSetting; + +[ + QGVAR(enableCarrying), "CHECKBOX", + [LSTRING(AllowCarryingFlags), LSTRING(AllowCarryingFlagsTooltip)], + _category, + true, + 0 +] call CBA_fnc_addSetting; diff --git a/addons/flags/script_component.hpp b/addons/flags/script_component.hpp new file mode 100644 index 0000000..0c332d5 --- /dev/null +++ b/addons/flags/script_component.hpp @@ -0,0 +1,26 @@ +#define COMPONENT flags +#define COMPONENT_BEAUTIFIED Flags +#include "\z\mts_enhanced\addons\main\script_mod.hpp" + +// #define DEBUG_MODE_FULL +// #define DISABLE_COMPILE_CACHE +// #define CBA_DEBUG_SYNCHRONOUS + +#ifdef DEBUG_ENABLED_FLAGS + #define DEBUG_MODE_FULL +#endif + +#ifdef DEBUG_SETTINGS_FLAGS + #define DEBUG_SETTINGS DEBUG_SETTINGS_FLAGS +#endif + +#include "\z\mts_enhanced\addons\main\script_macros.hpp" + +#define PLACE_WAITING -1 +#define PLACE_CANCEL 0 +#define PLACE_APPROVE 1 + +#define MIN_HEIGHT -0.5 +#define MAX_HEIGHT 2 + +#define FLAG_PLACING_DISTANCE 2 diff --git a/addons/flags/stringtable.xml b/addons/flags/stringtable.xml new file mode 100644 index 0000000..056f4b8 --- /dev/null +++ b/addons/flags/stringtable.xml @@ -0,0 +1,101 @@ + + + + + + Timi007 + Timi007 + + + + + Flags + Flaggen + + + Allow placing flags + Erlaube Flaggen zu platzieren + + + Adds the actions to place flags when the corresponding item is in the inventory. + Fügt Aktionen zum Platzieren von Flaggen hinzu, wenn das jeweilige Item im Inventar ist. + + + Allow carrying flags + Erlaube Flaggen zu tragen + + + Adds the actions to carry flags when the corresponding item is in the inventory. + Fügt Aktionen zum Tragen von Flaggen hinzu, wenn das jeweilige Item im Inventar ist. + + + + + Flag (White) + Flagge (Weiß) + + + Flag (Red) + Flagge (Rot) + + + Flag (Blue) + Flagge (Blau) + + + Flag (Green) + Flagge (Grün) + + + Flag (Yellow) + Flagge (Gelb) + + + Flag (Orange) + Flagge (Orange) + + + Flag (Purple) + Flagge (Violett) + + + Flag (Black) + Flagge (Schwarz) + + + Can be carried or placed. Flags are used to mark a specific point in terrain or units. + Kann getragen oder platziert werden. Flaggen werden zur Kennzeichnung von bestimmten Geländepunkte oder Einheiten eingesetzt. + + + + + Flags + Flaggen + + + Carry %1 + %1 tragen + + + Furl Flag + Flagge einrollen + + + Place %1 + %1 platzieren + + + Pickup %1 + %1 aufnehmen + + + Cancel + Abbrechen + + + Adjust height + Höhe anpassen + + + + diff --git a/addons/items/CfgVehicles.hpp b/addons/items/CfgVehicles.hpp index 9e899e5..ceb5ee6 100644 --- a/addons/items/CfgVehicles.hpp +++ b/addons/items/CfgVehicles.hpp @@ -1,6 +1,30 @@ class CfgVehicles { - class Item_Base_F; + class Man; + class CAManBase: Man { + class ACE_SelfActions { + class ACE_Equipment { + class ADDON { + displayName = CSTRING(marker); + insertChildren = QUOTE(_this call FUNC(getActions)); + icon = QPATHTOF(data\ui\icons\marker_white_icon.paa); + }; + }; + }; + }; + + class FlagSmall_F; + class GVAR(marker_yellow): FlagSmall_F { + author = CSTRING(authors); + displayName = CSTRING(markerYellowDisplayName); + }; + + class Land_Sign_MinesTall_English_F; + class GVAR(marker_mines): Land_Sign_MinesTall_English_F { + author = CSTRING(authors); + displayName = CSTRING(markerMinesDisplayName); + }; + class Item_Base_F; class GVAR(item_base): Item_Base_F { author = CSTRING(authors); scope = 0; @@ -11,54 +35,6 @@ class CfgVehicles { model = "\A3\Weapons_F\DummyItemHorizontal.p3d"; class TransportItems {}; }; - class GVAR(flag_red_item): GVAR(item_base) { - author = CSTRING(authors); - displayName = CSTRING(flagRedDisplayName); - scope = 2; - scopeCurator = 2; - class TransportItems { - class GVAR(red) { - name = QGVAR(red); - count = 1; - }; - }; - }; - class GVAR(flag_blue_item): GVAR(item_base) { - author = CSTRING(authors); - displayName = CSTRING(flagBlueDisplayName); - scope = 2; - scopeCurator = 2; - class TransportItems { - class GVAR(blue) { - name = QGVAR(blue); - count = 1; - }; - }; - }; - class GVAR(flag_green_item): GVAR(item_base) { - author = CSTRING(authors); - displayName = CSTRING(flagGreenDisplayName); - scope = 2; - scopeCurator = 2; - class TransportItems { - class GVAR(green) { - name = QGVAR(green); - count = 1; - }; - }; - }; - class GVAR(flag_yellow_item): GVAR(item_base) { - author = CSTRING(authors); - displayName = CSTRING(flagYellowDisplayName); - scope = 2; - scopeCurator = 2; - class TransportItems { - class GVAR(yellow) { - name = QGVAR(yellow); - count = 1; - }; - }; - }; class GVAR(marker_yellow_item): GVAR(item_base) { author = CSTRING(authors); diff --git a/addons/items/CfgWeapons.hpp b/addons/items/CfgWeapons.hpp index 3dd271f..4ac0e41 100644 --- a/addons/items/CfgWeapons.hpp +++ b/addons/items/CfgWeapons.hpp @@ -2,38 +2,6 @@ class CfgWeapons { class CBA_MiscItem; class CBA_MiscItem_ItemInfo; - class GVAR(flag_base): CBA_MiscItem { - author = CSTRING(authors); - scope = 0; - descriptionShort = CSTRING(flagDescription); - descriptionUse = CSTRING(flagDescription); - class ItemInfo: CBA_MiscItem_ItemInfo { - mass = 3; - }; - }; - - class GVAR(flag_red): GVAR(flag_base) { - scope = 2; - displayName = CSTRING(flagRedDisplayName); - picture = QPATHTOF(data\ui\flags\mts_flag_red_item_icon.paa); - }; - class GVAR(flag_blue): GVAR(flag_base) { - scope = 2; - displayName = CSTRING(flagBlueDisplayName); - picture = QPATHTOF(data\ui\flags\mts_flag_blue_item_icon.paa); - }; - class GVAR(flag_green): GVAR(flag_base) { - scope = 2; - displayName = CSTRING(flagGreenDisplayName); - picture = QPATHTOF(data\ui\flags\mts_flag_green_item_icon.paa); - }; - class GVAR(flag_yellow): GVAR(flag_base) { - scope = 2; - displayName = CSTRING(flagYellowDisplayName); - picture = QPATHTOF(data\ui\flags\mts_flag_yellow_item_icon.paa); - }; - - class GVAR(marker_base): CBA_MiscItem { author = CSTRING(authors); scope = 0; @@ -45,13 +13,17 @@ class CfgWeapons { }; class GVAR(marker_yellow): GVAR(marker_base) { + GVAR(vehicle) = QGVAR(marker_yellow); + GVAR(icon) = QPATHTOF(data\ui\icons\marker_yellow_place_icon.paa); scope = 2; displayName = CSTRING(markerYellowDisplayName); - picture = QPATHTOF(data\ui\markers\mts_marker_yellow_item_icon.paa); + picture = QPATHTOF(data\ui\pictures\marker_yellow_item.paa); }; class GVAR(marker_mines): GVAR(marker_base) { + GVAR(vehicle) = QGVAR(marker_mines); + GVAR(icon) = QPATHTOF(data\ui\icons\marker_mines_place_icon.paa); scope = 2; displayName = CSTRING(markerMinesDisplayName); - picture = QPATHTOF(data\ui\markers\mts_marker_mines_item_icon.paa); + picture = QPATHTOF(data\ui\pictures\marker_mines_item.paa); }; }; diff --git a/addons/items/XEH_PREP.hpp b/addons/items/XEH_PREP.hpp index f7cf255..44afcb1 100644 --- a/addons/items/XEH_PREP.hpp +++ b/addons/items/XEH_PREP.hpp @@ -1,6 +1,5 @@ -PREP(addFlagACEActions); -PREP(addMarkerACEActions); -PREP(carryFlag); +PREP(getActions); +PREP(getMarkers); PREP(handleScrollWheel); -PREP(pickupItem); -PREP(placeItem); +PREP(pickupMarker); +PREP(placeMarker); diff --git a/addons/items/XEH_missionDisplayLoad.sqf b/addons/items/XEH_missionDisplayLoad.sqf index 09f0846..3b2b097 100644 --- a/addons/items/XEH_missionDisplayLoad.sqf +++ b/addons/items/XEH_missionDisplayLoad.sqf @@ -11,7 +11,7 @@ _display displayAddEventHandler ["MouseZChanged", { _display displayAddEventHandler ["MouseButtonDown", { params ["", "_button"]; - CHECKRET(GVAR(isPlacing) != PLACE_WAITING, false); - CHECKRET(_button != 1, false); //1 = Left mouse button + CHECKRET(GVAR(isPlacing) isNotEqualTo PLACE_WAITING, false); + CHECKRET(_button isNotEqualTo 1, false); //1 = Left mouse button GVAR(isPlacing) = PLACE_CANCEL; }]; diff --git a/addons/items/XEH_postInit.sqf b/addons/items/XEH_postInit.sqf index 2ea26a0..b3f755c 100644 --- a/addons/items/XEH_postInit.sqf +++ b/addons/items/XEH_postInit.sqf @@ -2,10 +2,29 @@ CHECK(!hasinterface); -GVAR(pickupItemActionCounter) = 0; - GVAR(isPlacing) = PLACE_CANCEL; ["ace_interactMenuOpened", {GVAR(isPlacing) = PLACE_CANCEL;}] call CBA_fnc_addEventHandler; -call FUNC(addFlagACEActions); -call FUNC(addMarkerACEActions); +private _cfgWeapons = configFile >> "CfgWeapons"; +private _weapons = (call (uiNamespace getVariable [QGVAR(markerItems), {[]}])) apply {_cfgWeapons >> _x}; + +{ + private _name = configName _x; + private _vehicleClass = getText (_x >> QGVAR(vehicle)); + private _displayName = getText (_x >> "displayName"); + private _icon = getText (_x >> QGVAR(icon)); + GVAR(markerCache) set [_name, [_vehicleClass, _displayName, _icon]]; + + private _action = [ + QGVAR(pickup), + format [LLSTRING(pickupMarker), _displayName], + QPATHTOF(data\ui\icons\marker_pickup_icon.paa), + {call FUNC(pickupMarker)}, + {[_player, _target, []] call ace_common_fnc_canInteractWith}, + {}, + [_name], + [0, 0.072, 0.2], + 2 + ] call ace_interact_menu_fnc_createAction; + [_vehicleClass, 0, [], _action] call ace_interact_menu_fnc_addActionToClass; +} forEach _weapons; diff --git a/addons/items/XEH_preInit.sqf b/addons/items/XEH_preInit.sqf index b47cf66..9e175c3 100644 --- a/addons/items/XEH_preInit.sqf +++ b/addons/items/XEH_preInit.sqf @@ -6,4 +6,6 @@ PREP_RECOMPILE_START; #include "XEH_PREP.hpp" PREP_RECOMPILE_END; +GVAR(markerCache) = createHashMap; + ADDON = true; diff --git a/addons/items/XEH_preStart.sqf b/addons/items/XEH_preStart.sqf index 0228885..ef7432b 100644 --- a/addons/items/XEH_preStart.sqf +++ b/addons/items/XEH_preStart.sqf @@ -1,3 +1,6 @@ #include "script_component.hpp" #include "XEH_PREP.hpp" + +private _weapons = (configProperties [configfile >> "CfgWeapons", QUOTE(isClass _x && {isText (_x >> QQGVAR(vehicle))}), true]) apply {configName _x}; +uiNamespace setVariable [QGVAR(markerItems), compileFinal str _weapons]; diff --git a/addons/items/config.cpp b/addons/items/config.cpp index dcf946d..6e8c4b5 100644 --- a/addons/items/config.cpp +++ b/addons/items/config.cpp @@ -4,18 +4,12 @@ class CfgPatches { class ADDON { name = COMPONENT_NAME; units[] = { - QGVAR(item_base), - QGVAR(red_item), - QGVAR(blue_item), - QGVAR(green_item), - QGVAR(yellow_item) + QGVAR(marker_yellow_item), + QGVAR(marker_mines_item) }; weapons[] = { - QGVAR(base), - QGVAR(red), - QGVAR(blue), - QGVAR(green), - QGVAR(yellow) + QGVAR(marker_yellow), + QGVAR(marker_mines) }; requiredVersion = REQUIRED_VERSION; requiredAddons[] = {"mts_main", "ace_interact_menu", "ace_common", "ace_interaction"}; diff --git a/addons/items/data/ui/markers/mts_marker_mines_place_icon.paa b/addons/items/data/ui/icons/marker_mines_place_icon.paa similarity index 100% rename from addons/items/data/ui/markers/mts_marker_mines_place_icon.paa rename to addons/items/data/ui/icons/marker_mines_place_icon.paa diff --git a/addons/items/data/ui/markers/mts_marker_pickup_icon.paa b/addons/items/data/ui/icons/marker_pickup_icon.paa similarity index 100% rename from addons/items/data/ui/markers/mts_marker_pickup_icon.paa rename to addons/items/data/ui/icons/marker_pickup_icon.paa diff --git a/addons/items/data/ui/markers/mts_marker_white_icon.paa b/addons/items/data/ui/icons/marker_white_icon.paa similarity index 100% rename from addons/items/data/ui/markers/mts_marker_white_icon.paa rename to addons/items/data/ui/icons/marker_white_icon.paa diff --git a/addons/items/data/ui/markers/mts_marker_yellow_place_icon.paa b/addons/items/data/ui/icons/marker_yellow_place_icon.paa similarity index 100% rename from addons/items/data/ui/markers/mts_marker_yellow_place_icon.paa rename to addons/items/data/ui/icons/marker_yellow_place_icon.paa diff --git a/addons/items/data/ui/markers/mts_marker_mines_item_icon.paa b/addons/items/data/ui/pictures/marker_mines_item.paa similarity index 100% rename from addons/items/data/ui/markers/mts_marker_mines_item_icon.paa rename to addons/items/data/ui/pictures/marker_mines_item.paa diff --git a/addons/items/data/ui/markers/mts_marker_yellow_item_icon.paa b/addons/items/data/ui/pictures/marker_yellow_item.paa similarity index 100% rename from addons/items/data/ui/markers/mts_marker_yellow_item_icon.paa rename to addons/items/data/ui/pictures/marker_yellow_item.paa diff --git a/addons/items/functions/fnc_addFlagACEActions.sqf b/addons/items/functions/fnc_addFlagACEActions.sqf deleted file mode 100644 index d1d379f..0000000 --- a/addons/items/functions/fnc_addFlagACEActions.sqf +++ /dev/null @@ -1,141 +0,0 @@ -#include "script_component.hpp" -/** - * Author: Timi007 - * - * Description: - * Adds ACE interactions for flag actions to the player. - * - * Parameter(s): - * None. - * - * Returns: - * Nothing. - * - * Example: - * call mts_items_fnc_addFlagACEActions - * - */ - -CHECK(!hasInterface); - -private _flagAction = [ - QGVAR(flagAction), - LLSTRING(flags), - QPATHTOF(data\ui\flags\mts_flag_white_icon.paa), - {}, - { - params ["", "_player"]; - - private _items = [_player, false, true, true, true, false] call CBA_fnc_uniqueUnitItems; - - [_player, objNull] call ace_common_fnc_canInteractWith && - ( - - (QGVAR(flag_red) in _items) || - (QGVAR(flag_blue) in _items) || - (QGVAR(flag_green) in _items) || - (QGVAR(flag_yellow) in _items) || - !((getForcedFlagTexture _player) isEqualTo "") - ) - } -] call ace_interact_menu_fnc_createAction; -[(typeOf ACE_player), 1, ["ACE_SelfActions", "ACE_Equipment"], _flagAction] call ace_interact_menu_fnc_addActionToClass; - -private _furlFlagAction = [ - QGVAR(furlFlagAction), - LLSTRING(furlFlag), - QPATHTOF(data\ui\flags\mts_flag_furl_icon.paa), - { - [""] call FUNC(carryFlag); - }, - { - params ["", "_player"]; - - !((getForcedFlagTexture _player) isEqualTo "") - } -] call ace_interact_menu_fnc_createAction; -[(typeOf ACE_player), 1, ["ACE_SelfActions", "ACE_Equipment", QGVAR(flagAction)], _furlFlagAction] call ace_interact_menu_fnc_addActionToClass; - -{ - private _color = toLower _x; - private _displayName = localize format [LSTRING(flag%1DisplayName), _x]; - - private _carryFlagAction = [ - format [QGVAR(carry%1FlagAction), _x], - format [LLSTRING(carryItem), _displayName], - format [QPATHTOF(data\ui\flags\mts_flag_%1_carry_icon.paa), _color], - { - params ["", "", "_color"]; - - [_color] call FUNC(carryFlag); - }, - { - params ["", "_player", "_color"]; - - (format [QGVAR(flag_%1), _color] in ([_player, false, true, true, true, false] call CBA_fnc_uniqueUnitItems)) && - ((getForcedFlagTexture _player) isEqualTo "") - }, - {}, - _color - ] call ace_interact_menu_fnc_createAction; - [(typeOf ACE_player), 1, ["ACE_SelfActions", "ACE_Equipment", QGVAR(flagAction)], _carryFlagAction] call ace_interact_menu_fnc_addActionToClass; -} forEach ["Red", "Blue", "Green", "Yellow"]; - -{ - private _color = toLower _x; - private _displayName = localize format [LSTRING(flag%1DisplayName), _x]; - - private _placeFlagAction = [ - format [QGVAR(place%1FlagAction), _x], - format [LLSTRING(placeItem), _displayName], - format [QPATHTOF(data\ui\flags\mts_flag_%1_place_icon.paa), _color], - { - params ["", "", "_args"]; - _args params ["_color", "_displayName"]; - - [ - "FlagChecked_F", - _displayName, - { - params ["_flag", "", "_color"]; - - if (_color isEqualTo "yellow") then { - _flag setFlagTexture QPATHTOF(data\Flag_yellow_co.paa); - } else { - _flag setFlagTexture format ["\A3\Data_F\Flags\Flag_%1_co.paa", _color]; - }; - }, - { - params ["_flag", "_player", "_color"]; - - if (_color isEqualTo "yellow") then { - _flag setFlagTexture QPATHTOF(data\Flag_yellow_co.paa); - } else { - _flag setFlagTexture format ["\A3\Data_F\Flags\Flag_%1_co.paa", _color]; - }; - - _player removeItem format [QGVAR(flag_%1), _color]; - }, - { - params ["", "_player", "_color"]; - - _player addItem format [QGVAR(flag_%1), _color]; - }, - _color, - nil, - QPATHTOF(data\ui\flags\mts_flag_pickup_icon.paa), - [0, -0.45, 1.25], - 2 - ] call FUNC(placeItem); - }, - { - params ["", "_player", "_args"]; - _args params ["_color"]; - - format [QGVAR(flag_%1), _color] in ([_player, false, true, true, true, false] call CBA_fnc_uniqueUnitItems) - }, - {}, - [_color, _displayName] - ] call ace_interact_menu_fnc_createAction; - [(typeOf ACE_player), 1, ["ACE_SelfActions", "ACE_Equipment", QGVAR(flagAction)], _placeFlagAction] call ace_interact_menu_fnc_addActionToClass; -} forEach ["Red", "Blue", "Green", "Yellow"]; diff --git a/addons/items/functions/fnc_addMarkerACEActions.sqf b/addons/items/functions/fnc_addMarkerACEActions.sqf deleted file mode 100644 index 9a30628..0000000 --- a/addons/items/functions/fnc_addMarkerACEActions.sqf +++ /dev/null @@ -1,102 +0,0 @@ -#include "script_component.hpp" -/** - * Author: Timi007 - * - * Description: - * Adds ACE interactions for marker actions to the player. - * - * Parameter(s): - * None. - * - * Returns: - * Nothing. - * - * Example: - * call mts_items_fnc_addMarkerACEActions - * - */ - -CHECK(!hasInterface); - -private _markerAction = [ - QGVAR(markerAction), - LLSTRING(marker), - QPATHTOF(data\ui\markers\mts_marker_white_icon.paa), - {}, - { - params ["", "_player"]; - - private _items = [_player, false, true, true, true, false] call CBA_fnc_uniqueUnitItems; - - [_player, objNull] call ace_common_fnc_canInteractWith && - ( - (QGVAR(marker_yellow) in _items) || - (QGVAR(marker_mines) in _items) - ) - } -] call ace_interact_menu_fnc_createAction; -[(typeOf player), 1, ["ACE_SelfActions", "ACE_Equipment"], _markerAction] call ace_interact_menu_fnc_addActionToClass; - -private _placeMarkerYellowAction = [ - QGVAR(placeMarkerYellowAction), - format [LLSTRING(placeItem), LLSTRING(markerYellowDisplayName)], - QPATHTOF(data\ui\markers\mts_marker_yellow_place_icon.paa), - { - [ - "FlagSmall_F", - LLSTRING(markerYellowDisplayName), - nil, - { - params ["", "_player"]; - _player removeItem QGVAR(marker_yellow); - }, - { - params ["", "_player"]; - _player addItem QGVAR(marker_yellow); - }, - nil, - 0, - QPATHTOF(data\ui\markers\mts_marker_pickup_icon.paa), - [0, 0, 0.6], - 2 - ] call FUNC(placeItem); - }, - { - params ["", "_player"]; - - QGVAR(marker_yellow) in ([_player, false, true, true, true, false] call CBA_fnc_uniqueUnitItems) - } -] call ace_interact_menu_fnc_createAction; -[(typeOf player), 1, ["ACE_SelfActions", "ACE_Equipment", QGVAR(markerAction)], _placeMarkerYellowAction] call ace_interact_menu_fnc_addActionToClass; - -private _placeMarkerMinesAction = [ - QGVAR(placeMarkerMinesAction), - format [LLSTRING(placeItem), LLSTRING(markerMinesDisplayName)], - QPATHTOF(data\ui\markers\mts_marker_mines_place_icon.paa), - { - [ - "Land_Sign_MinesTall_English_F", - LLSTRING(markerMinesDisplayName), - nil, - { - params ["", "_player"]; - _player removeItem QGVAR(marker_mines); - }, - { - params ["", "_player"]; - _player addItem QGVAR(marker_mines); - }, - nil, - 0, - QPATHTOF(data\ui\markers\mts_marker_pickup_icon.paa), - [0, 0, 0.55], - 2 - ] call FUNC(placeItem); - }, - { - params ["", "_player"]; - - QGVAR(marker_mines) in ([_player, false, true, true, true, false] call CBA_fnc_uniqueUnitItems) - } -] call ace_interact_menu_fnc_createAction; -[(typeOf player), 1, ["ACE_SelfActions", "ACE_Equipment", QGVAR(markerAction)], _placeMarkerMinesAction] call ace_interact_menu_fnc_addActionToClass; diff --git a/addons/items/functions/fnc_carryFlag.sqf b/addons/items/functions/fnc_carryFlag.sqf deleted file mode 100644 index 59d1010..0000000 --- a/addons/items/functions/fnc_carryFlag.sqf +++ /dev/null @@ -1,51 +0,0 @@ -#include "script_component.hpp" -/** - * Author: Timi007 - * - * Description: - * Attaches colored flag to the back of the player and removes his flag item. - * - * Parameter(s): - * 0: STRING - Color of the flag. - * - * Returns: - * Nothing. - * - * Example: - * ["red"] call mts_items_fnc_carryFlag - * - */ - -params [["_color", "", [""]]]; - -_color = toLower _color; - -if (_color in ["red", "blue", "green", "yellow"]) then { - //arma need a flag proxy & some modded uniforms don't have them so we use a trick - private _loadout = getUnitLoadout ACE_player; - ACE_player forceAddUniform "U_B_CombatUniform_mcam"; - - if (_color isEqualTo "yellow") then { - ACE_player forceFlagTexture QPATHTOF(data\Flag_yellow_co.paa); - } else { - ACE_player forceFlagTexture format ["\A3\Data_F\Flags\Flag_%1_co.paa", _color]; - }; - - //execute it in the next frame otherwise it will not work - [{ - params ["_loadout", "_color"]; - - ACE_player setUnitLoadout _loadout; - ACE_player removeItem format [QGVAR(%1), _color]; - }, [_loadout, _color]] call CBA_fnc_execNextFrame; -} else { - //remove carried flag - private _flagTexture = getForcedFlagTexture ACE_player; - if !(_flagTexture isEqualTo "") then { - ACE_player forceFlagTexture ""; - private _flagColorPath = _flagTexture splitString "_"; - reverse _flagColorPath; - private _flagColor = _flagColorPath select 1; - ACE_player addItem format [QGVAR(%1), _flagColor]; - }; -}; diff --git a/addons/items/functions/fnc_getActions.sqf b/addons/items/functions/fnc_getActions.sqf new file mode 100644 index 0000000..16821d8 --- /dev/null +++ b/addons/items/functions/fnc_getActions.sqf @@ -0,0 +1,41 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Gets the child actions for placing markers. + * + * Parameter(s): + * 0: OBJECT - Player. + * + * Returns: + * ARRAY - Actions. + * + * Example: + * [player] call mts_items_fnc_getActions + * + */ + +params ["_player"]; + +private _actions = []; + +{ + (GVAR(markerCache) get _x) params ["_vehicle", "_displayName", "_icon"]; + + _actions pushBack [ + [ + _x, + _displayName, + _icon, + {[_this select 0, _this select 2] call FUNC(placeMarker)}, + {true}, + {}, + _x + ] call ace_interact_menu_fnc_createAction, + [], + _player + ]; +} forEach ([_player] call FUNC(getMarkers)); + +_actions diff --git a/addons/items/functions/fnc_getMarkers.sqf b/addons/items/functions/fnc_getMarkers.sqf new file mode 100644 index 0000000..9640cc6 --- /dev/null +++ b/addons/items/functions/fnc_getMarkers.sqf @@ -0,0 +1,21 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Get the placeable markers in the player's inventory. + * + * Parameter(s): + * 0: OBJECT - Player + * + * Returns: + * ARRAY - Markers + * + * Example: + * [player] call mts_items_fnc_getMarkers + * + */ + +params ["_player"]; + +(_player call ace_common_fnc_uniqueItems) arrayIntersect keys GVAR(markerCache) diff --git a/addons/items/functions/fnc_handleScrollWheel.sqf b/addons/items/functions/fnc_handleScrollWheel.sqf index ab4e04c..314af1e 100644 --- a/addons/items/functions/fnc_handleScrollWheel.sqf +++ b/addons/items/functions/fnc_handleScrollWheel.sqf @@ -18,17 +18,12 @@ params ["_scrollAmount"]; -CHECKRET(GVAR(isPlacing) != PLACE_WAITING, false); +CHECKRET(GVAR(isPlacing) isNotEqualTo PLACE_WAITING, false); //move object height 10cm per scroll GVAR(objectHeight) = GVAR(objectHeight) + (_scrollAmount * 0.1); -if (GVAR(objectHeight) < MIN_HEIGHT) then { - GVAR(objectHeight) = MIN_HEIGHT; -}; - -if (GVAR(objectHeight) > MAX_HEIGHT) then { - GVAR(objectHeight) = MAX_HEIGHT; -}; +// Clamp height between MIN_HEIGHT and MAX_HEIGHT +GVAR(objectHeight) = (MIN_HEIGHT max (GVAR(objectHeight) min MAX_HEIGHT)); true diff --git a/addons/items/functions/fnc_pickupItem.sqf b/addons/items/functions/fnc_pickupItem.sqf deleted file mode 100644 index cea88db..0000000 --- a/addons/items/functions/fnc_pickupItem.sqf +++ /dev/null @@ -1,78 +0,0 @@ -#include "script_component.hpp" -/** - * Author: Timi007 - * - * Description: - * Adds an action for the object to pick it up (delete). - * This funtion has a local effect. - * - * Parameter(s): - * 0: OBJECT - Object on which the action will be placed. - * 1: STRING - Display name of the object for info and pickup text.(Optional, default: Config display name) - * 2: CODE - Code executed before the object is deleted. (Optional) - * 3: ANY - Arguments passed to every custom code. (Optional) - * 4: STRING - Icon path for ACE pickup action. (Optional, default: Arma take icon) - * 5: ARRAY - Relative positon of ACE pickup action on the object. (Optional, default: Object center) - * 6: NUMBER - Max distance player can be from ACE pickup action point. (Optional, default: 2) - * - * Following arguments are passed to the custom code: - * 0: OBJECT - Object the action is attached to. - * 1: OBJECT - Player. - * 2: ANY - Custom arguments given in parameter 3. - * - * Returns: - * Nothing - * - * Example: - * [_obj, "Flag (green)", {systemChat str _this}, ["green"], nil, [0, -0.45, 1.25]] call mts_items_fnc_pickupItem - * - */ - -params [ - ["_obj", objNull, [objNull]], - ["_objName", "", [""]], - ["_userCode", nil, [{}]], - ["_args", []], - ["_icon", "A3\Ui_f\data\IGUI\Cfg\Actions\take_ca.paa", [""]], - ["_actionPos", [0, 0, 0], [[]]], - ["_actionRad", 2, [0]] -]; - -CHECK(isNull _obj); - -// Get display name of object from config -if (_objName isEqualTo "") then { - _objName = getText (configFile >> "CfgWeapons" >> (typeOf _obj) >> "displayName"); -}; - -private _pickupItem = [ - format [QGVAR(pickupItem%1), GVAR(pickupItemActionCounter)], - format [LLSTRING(pickupItem), _objName], - _icon, - { - params ["_obj", "", "_ACEargs"]; - _ACEargs params ["_userCode", "_args"]; - - ACE_player playAction "PutDown"; - - [{((animationState ACE_player) select [25,7]) isEqualTo "putdown"}, { - params ["_obj", "_userCode", "_args"]; - - // Call custom code - if !(isNil "_userCode") then { - [_obj, ACE_player, _args] call _userCode; - }; - - // Remove the object - deleteVehicle _obj; - }, [_obj, _userCode, _args]] call CBA_fnc_waitUntilAndExecute; - }, - {true}, - {}, - [_userCode, _args], - _actionPos, - _actionRad -] call ace_interact_menu_fnc_createAction; -[_obj, 0, [], _pickupItem] call ace_interact_menu_fnc_addActionToObject; - -GVAR(pickupItemActionCounter) = GVAR(pickupItemActionCounter) + 1; diff --git a/addons/items/functions/fnc_pickupMarker.sqf b/addons/items/functions/fnc_pickupMarker.sqf new file mode 100644 index 0000000..4f8229f --- /dev/null +++ b/addons/items/functions/fnc_pickupMarker.sqf @@ -0,0 +1,36 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Adds an action for the object to pick it up (delete). + * This funtion has a local effect. + * + * Parameter(s): + * 0: OBJECT - Marker. + * 1: OBJECT - Player picking up marker. + * 2: ARRAY - Action args. + * 0: STRING - Marker item classname. + * + * Returns: + * Nothing + * + * Example: + * [_marker, player, ["mts_items_marker_yellow"]] call mts_items_fnc_pickupMarker + * + */ + +params [["_marker", objNull, [objNull]], ["_player", objNull, [objNull]], ["_args", [""], [[]]]]; +_args params ["_item"]; +TRACE_3("Pickup marker",_player,_marker,_itemName); + +CHECK(isNull _marker); + +[_player, "PutDown"] call ace_common_fnc_doGesture; + +[{ + params ["_marker", "_player", "_item"]; + + [_player, _item] call ace_common_fnc_addToInventory; + deleteVehicle _marker; +}, [_marker, _player, _item], 0.7] call CBA_fnc_waitAndExecute; diff --git a/addons/items/functions/fnc_placeItem.sqf b/addons/items/functions/fnc_placeItem.sqf deleted file mode 100644 index 9dfb9af..0000000 --- a/addons/items/functions/fnc_placeItem.sqf +++ /dev/null @@ -1,132 +0,0 @@ -#include "script_component.hpp" -/** - * Author: Timi007 - * - * Description: - * Creates an object of given classname and makes it placable for the player. - * - * Parameter(s): - * 0: STRING - Classname of object which should be placed. - * 1: STRING - Display name of the object for info and pickup text.(Optional, default: Config display name) - * 2: CODE - Code executed before the placing but after the creation of the local object. (Optional) - * 3: CODE - Code executed after the placing is approved and the global object is created but before object is moved. (Optional) - * 4: CODE - Code executed if ACE pickup action is executed. (Optional) - * 5: ANY - Arguments passed to every custom code. (Optional) - * 6: NUMBER - Object start placing height (Optional, default -0.5) - * 7: STRING - Icon path for ACE pickup action. (Optional, default: Arma take icon) - * 8: ARRAY - Relative positon of ACE pickup action on the object. (Optional, default: Object center) - * 9: NUMBER - Max distance player can be from ACE pickup action point. (Optional, default: 2) - * - * Following arguments are passed to every custom code (param 2, 3, 4): - * 0: OBJECT - Local (for param 2) or global (for param 3, 4) object created. - * 1: OBJECT - Player. - * 2: ANY - Custom arguments given in parameter 5. - * - * Returns: - * Nothing. - * - * Example: - * ["FlagChecked_F", {systemChat str _this}, {}, {}, ["green"]] call mts_items_fnc_placeItem - * - */ - -params [ - ["_classname", "", [""]], - ["_objName", "", [""]], - ["_beforeCode", nil, [{}]], - ["_afterCode", nil, [{}]], - ["_pickupCode", nil, [{}]], - ["_args", []], - ["_startHeight", MIN_HEIGHT, [0]], - ["_pickupIcon", "A3\Ui_f\data\IGUI\Cfg\Actions\take_ca.paa", [""]], - ["_pickupAcPos", [0, 0, 0], [[]]], - ["_pickupAcRad", 2, [0]] -]; - -CHECK(_classname isEqualTo ""); - -// Create local object -private _obj = _classname createVehicleLocal [0, 0, 0]; -_obj disableCollisionWith ACE_player; - -// Set object start height -GVAR(objectHeight) = _startHeight; - -// Call custom code -if !(isNil "_beforeCode") then { - [_obj, ACE_player, _args] call _beforeCode; -}; - -GVAR(isPlacing) = PLACE_WAITING; - -// Get display name of object from config -if (_objName isEqualTo "") then { - _objName = getText (configFile >> "CfgWeapons" >> (typeOf _obj) >> "displayName"); -}; - -// Add info dialog for the player which show the controls -private _placeItemText = format [LLSTRING(placeItem), _objName]; -[_placeItemText, LLSTRING(cancel), LLSTRING(adjustHeight)] call ace_interaction_fnc_showMouseHint; - -private _mouseClickID = [ACE_player, "DefaultAction", {GVAR(isPlacing) isEqualTo PLACE_WAITING}, {GVAR(isPlacing) = PLACE_APPROVE}] call ace_common_fnc_addActionEventHandler; - -// Leave index 0 free for global object -private _pickupArgs = [objNull, _objName, _pickupCode, _args, _pickupIcon, _pickupAcPos, _pickupAcRad]; - -[{ - params ["_PFHArgs", "_PFHID"]; - _PFHArgs params ["_obj", "_classname", "_afterCode", "_mouseClickID", "_pickupArgs"]; - - if ((isNull _obj) || {!([ACE_player, _obj] call ace_common_fnc_canInteractWith)}) then { - GVAR(isPlacing) = PLACE_CANCEL; - }; - - if !(GVAR(isPlacing) isEqualTo PLACE_WAITING) exitWith { - [_PFHID] call CBA_fnc_removePerFrameHandler; - call ace_interaction_fnc_hideMouseHint; - [ACE_player, "DefaultAction", _mouseClickID] call ace_common_removeActionEventHandler; - - if (GVAR(isPlacing) isEqualTo PLACE_APPROVE) then { - GVAR(isPlacing) = PLACE_CANCEL; - - // End position of the object - ACE_player playAction "putdown"; - - [{(animationState ACE_player select [25, 7]) isEqualTo "putdown"}, { - params ["_obj", "_classname", "_afterCode", "_pickupArgs"]; - - // Save positon and direction - private _posObj = getPosWorld _obj; - private _dirObj = getDir _obj; - deleteVehicle _obj; - - private _globalObj = _classname createVehicle [0, 0, 0]; - - // Call custom code - if !(isNil "_afterCode") then { - private _args = _pickupArgs select 3; - [_globalObj, ACE_player, _args] call _afterCode; - }; - - // Apply same positon and direction as local object - _globalObj setPosWorld _posObj; - _globalObj setDir _dirObj; - - // Add ACE pickup action - _pickupArgs set [0, _globalObj]; - _pickupArgs remoteExecCall [QFUNC(pickupItem), 0, _globalObj]; - }, [_obj, _classname, _afterCode, _pickupArgs]] call CBA_fnc_waitUntilAndExecute; - } else { - // Action is canceled - deleteVehicle _obj; - }; - }; - - // Alternativ to "player getRelPos [MAX_DISTANCE, 0]" because flag wasn't in the center of the view - private _pos = ((eyePos ACE_player) vectorAdd ((getCameraViewDirection ACE_player) vectorMultiply MAX_DISTANCE)); - // Adjust height of flag with the scroll wheel - _pos set [2, ((getPosWorld ACE_player) select 2) + GVAR(objectHeight)]; - - _obj setPosWorld _pos; - _obj setDir (getDir ACE_player); -}, 0, [_obj, _classname, _afterCode, _mouseClickID, _pickupArgs]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/items/functions/fnc_placeMarker.sqf b/addons/items/functions/fnc_placeMarker.sqf new file mode 100644 index 0000000..b5be01a --- /dev/null +++ b/addons/items/functions/fnc_placeMarker.sqf @@ -0,0 +1,82 @@ +#include "script_component.hpp" +/** + * Author: Timi007 + * + * Description: + * Starts the placing process of the marker for the player. + * Markers can be placed with the special marker items. + * + * Parameter(s): + * 0: OBJECT - Player. + * 1: STRING - Marker item. + * + * Returns: + * Nothing. + * + * Example: + * [player, "mts_items_marker_yellow"] call mts_items_fnc_placeMarker + * + */ + +params [["_player", objNull, [objNull]], ["_item", "", [""]]]; +TRACE_2("Placing marker", _player, _item); + +CHECK(_item isEqualTo ""); + +(GVAR(markerCache) get _item) params ["_vehicleClass", "_displayName"]; + +private _marker = _vehicleClass createVehicle [0, 0, 0]; + +TRACE_1("Created marker", _marker); + +// Set marker start height +GVAR(objectHeight) = MAX_HEIGHT; + +GVAR(isPlacing) = PLACE_WAITING; + +// Add info dialog for the player which show the controls +private _placeMarkerText = format [LLSTRING(placeMarker), _displayName]; +[_placeMarkerText, LLSTRING(cancel), LLSTRING(adjustHeight)] call ace_interaction_fnc_showMouseHint; + +private _mouseClickID = [_player, "DefaultAction", { + GVAR(isPlacing) isEqualTo PLACE_WAITING +}, { + GVAR(isPlacing) = PLACE_APPROVE +}] call ace_common_fnc_addActionEventHandler; + +[{ // Start of PFH + params ["_args", "_handle"]; + _args params ["_player", "_item", "_marker", "_mouseClickID"]; + + if (isNull _marker || {!([_player, _marker] call ace_common_fnc_canInteractWith)}) then { + GVAR(isPlacing) = PLACE_CANCEL; + }; + + if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith { + [_handle] call CBA_fnc_removePerFrameHandler; + call ace_interaction_fnc_hideMouseHint; + [_player, "DefaultAction", _mouseClickID] call ace_common_fnc_removeActionEventHandler; + + if (GVAR(isPlacing) isEqualTo PLACE_APPROVE) then { + // End position of the marker + + GVAR(isPlacing) = PLACE_CANCEL; + + [_player, "PutDown"] call ace_common_fnc_doGesture; + + _player removeItem _item; + + [QGVAR(placed), [_player, _marker, _item]] call CBA_fnc_localEvent; + } else { + // Action is canceled + deleteVehicle _marker; + }; + }; + + private _pos = ((eyePos _player) vectorAdd ((getCameraViewDirection _player) vectorMultiply MARKER_PLACING_DISTANCE)); + // Adjust height of marker with the scroll wheel + _pos set [2, ((getPosWorld _player) select 2) + GVAR(objectHeight)]; + + _marker setPosWorld _pos; + _marker setDir (getDir _player); +}, 0, [_player, _item, _marker, _mouseClickID]] call CBA_fnc_addPerFrameHandler; diff --git a/addons/items/script_component.hpp b/addons/items/script_component.hpp index b09695b..14526cc 100644 --- a/addons/items/script_component.hpp +++ b/addons/items/script_component.hpp @@ -20,7 +20,7 @@ #define PLACE_CANCEL 0 #define PLACE_APPROVE 1 -#define MIN_HEIGHT -0.5 -#define MAX_HEIGHT 2 +#define MIN_HEIGHT -0.4 +#define MAX_HEIGHT 0.6 -#define MAX_DISTANCE 2 +#define MARKER_PLACING_DISTANCE 2 diff --git a/addons/items/stringtable.xml b/addons/items/stringtable.xml index e5d1968..b5978ad 100644 --- a/addons/items/stringtable.xml +++ b/addons/items/stringtable.xml @@ -7,28 +7,6 @@ Timi007, Dan - - - Flag (Red) - Flagge (Rot) - - - Flag (Blue) - Flagge (Blau) - - - Flag (Green) - Flagge (Grün) - - - Flag (Yellow) - Flagge (Gelb) - - - Can be carried or placed. Flags are used to mark a specific point in terrain or units. - Kann getragen oder platziert werden. Flaggen werden zur Kennzeichnung von bestimmten Geländepunkte oder Einheiten eingesetzt. - - Marker (Yellow) @@ -44,23 +22,11 @@ - - Flags - Flaggen - Markers Markierungen - - Carry %1 - %1 tragen - - - Furl Flag - Flagge einrollen - - + Place %1 %1 platzieren @@ -72,7 +38,7 @@ Adjust height Höhe anpassen - + Pickup %1 %1 aufnehmen diff --git a/addons/main/CfgEventHandlers.hpp b/addons/main/CfgEventHandlers.hpp new file mode 100644 index 0000000..9b160c1 --- /dev/null +++ b/addons/main/CfgEventHandlers.hpp @@ -0,0 +1,5 @@ +class Extended_PreInit_EventHandlers { + class ADDON { + init = QUOTE(call COMPILE_SCRIPT(XEH_preInit)); + }; +}; diff --git a/addons/main/XEH_preInit.sqf b/addons/main/XEH_preInit.sqf new file mode 100644 index 0000000..8fde31b --- /dev/null +++ b/addons/main/XEH_preInit.sqf @@ -0,0 +1,5 @@ +#include "script_component.hpp" + +// Print version to rpt log +private _version = getText (configFile >> "CfgPatches" >> QUOTE(ADDON) >> "versionStr"); +INFO_1("Metis Enhanced version: %1.", _version); diff --git a/addons/main/config.cpp b/addons/main/config.cpp index cec5678..8ac2c84 100644 --- a/addons/main/config.cpp +++ b/addons/main/config.cpp @@ -26,3 +26,6 @@ class CfgSettings { }; }; }; + + +#include "CfgEventHandlers.hpp" diff --git a/addons/main/script_version.hpp b/addons/main/script_version.hpp index bd5624d..ad833ec 100644 --- a/addons/main/script_version.hpp +++ b/addons/main/script_version.hpp @@ -1,4 +1,4 @@ #define MAJOR 1 -#define MINOR 5 +#define MINOR 6 #define PATCHLVL 0 -#define BUILD 220822 +#define BUILD 230325