Skip to content

Commit

Permalink
Add placeable and carryable flags (#8943)
Browse files Browse the repository at this point in the history
* Add ability to carry and place flags

* Add white icons

* Fix cache

* Fix icon paths

* Fix action text

* Fix placing and picking up flags

* Disable debugging

* Rename var

* Remove hack

* Casing

* Add setting to hide place or carry actions

* Refactor

* Fix function rename

* Add purple, black and orange flags

* Add new flags to weapons array

* Add description

* Fix stringtable checks

* Lazy eval

Co-authored-by: Jouni Järvinen <[email protected]>

* Save CfgWeapons in var

* Refactor clamping height

* Fix docs

* Add existing translation

* Use macro

* Remove obsolete line

* Fix hemtt build

* Fix hemtt warnings

* Fix floating

* Increase mass

* Use new script_component path

* Use EFUNC and check canInteractWith

* Correct spelling

Co-authored-by: Grim <[email protected]>

* Build item cache in preStart

* Add private

* Move config cache to fnc_scanConfig

* Make flag carrier customizable

* More descriptive var

* Reduce round brackets

* Improve German translation

* Improve spelling

* Rename to isCarryingFlag

* Remove explicit _this

* Add check for already picked up flag

* Formatting

* Use cancel STR from common

* Fix finding

* Add carrier for each flag

* Add editor previews

* Fix hook

* Apply suggestions from code review

---------

Co-authored-by: Jouni Järvinen <[email protected]>
Co-authored-by: Grim <[email protected]>
Co-authored-by: johnb432 <[email protected]>
Co-authored-by: PabstMirror <[email protected]>
  • Loading branch information
5 people authored Jan 28, 2025
1 parent 9010fe5 commit d2e0494
Show file tree
Hide file tree
Showing 63 changed files with 809 additions and 0 deletions.
1 change: 1 addition & 0 deletions addons/flags/$PBOPREFIX$
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
z\ace\addons\flags
23 changes: 23 additions & 0 deletions addons/flags/CfgEventHandlers.hpp
Original file line number Diff line number Diff line change
@@ -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));
};
};
81 changes: 81 additions & 0 deletions addons/flags/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
class CBA_Extended_EventHandlers;

class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_SelfActions {
class ACE_Equipment {
class ADDON {
displayName = CSTRING(ActionCategory);
insertChildren = QUOTE(call FUNC(getActions));
icon = QPATHTOF(data\icons\place\white_place_icon.paa);
exceptions[] = {"isNotSwimming", "isNotOnLadder"};

class GVAR(furlFlag) {
displayName = CSTRING(Furl);
condition = QUOTE(_player call FUNC(isCarryingFlag));
exceptions[] = {"isNotSwimming", "isNotOnLadder"};
statement = QUOTE(_player call FUNC(furlFlag));
icon = QPATHTOF(data\icons\carry\white_furl_icon.paa);
};
};
};
};
};

class FlagChecked_F;
class GVAR(carrier_white): FlagChecked_F {
scope = 2;
scopeCurator = 2;
author = ECSTRING(common,ACETeam);

displayName = CSTRING(White);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_white.jpg);

class EventHandlers {
class CBA_Extended_EventHandlers: CBA_Extended_EventHandlers {}; // Required for ACE_Actions
init = QUOTE([_this select 0] call FUNC(setFlagTexture));
};

class ACE_Actions {
class GVAR(pickup) {
displayName = CSTRING(Pickup);
icon = QPATHTOF(data\icons\place\white_pickup_icon.paa);
position = "[0, -0.45, 0.75]";
distance = 2.0;
condition = QUOTE((typeOf _target) in GVAR(carrierItemMapping));
statement = QUOTE([ARR_3(_player,(GVAR(carrierItemMapping) get (typeOf _target)),_target)] call FUNC(pickupFlag));
modifierFunction = QUOTE(call FUNC(modifyPickupAction));
exceptions[] = {"isNotSwimming", "isNotOnLadder"};
};
};
};
class GVAR(carrier_red): GVAR(carrier_white) {
displayName = CSTRING(Red);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_red.jpg);
};
class GVAR(carrier_blue): GVAR(carrier_white) {
displayName = CSTRING(Blue);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_blue.jpg);
};
class GVAR(carrier_green): GVAR(carrier_white) {
displayName = CSTRING(Green);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_green.jpg);
};
class GVAR(carrier_yellow): GVAR(carrier_white) {
displayName = CSTRING(Yellow);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_yellow.jpg);
};
class GVAR(carrier_orange): GVAR(carrier_white) {
displayName = CSTRING(Orange);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_orange.jpg);
};
class GVAR(carrier_purple): GVAR(carrier_white) {
displayName = CSTRING(Purple);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_purple.jpg);
};
class GVAR(carrier_black): GVAR(carrier_white) {
displayName = CSTRING(Black);
editorPreview = QPATHTOF(data\editorpreviews\ace_flags_carrier_black.jpg);
};
};
86 changes: 86 additions & 0 deletions addons/flags/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
class CfgWeapons {
class ACE_ItemCore;
class CBA_MiscItem_ItemInfo;

class GVAR(white): ACE_ItemCore {
scope = 2;
author = ECSTRING(common,ACETeam);
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(carrier) = QGVAR(carrier_white);
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 = 6.6; // Assuming 300g
};
};
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(carrier) = QGVAR(carrier_red);
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(carrier) = QGVAR(carrier_blue);
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(carrier) = QGVAR(carrier_green);
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(carrier) = QGVAR(carrier_yellow);
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(carrier) = QGVAR(carrier_orange);
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(carrier) = QGVAR(carrier_purple);
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(carrier) = QGVAR(carrier_black);
GVAR(actionIconPlace) = QPATHTOF(data\icons\place\black_place_icon.paa);
GVAR(actionIconCarry) = QPATHTOF(data\icons\carry\black_carry_icon.paa);
};
};
4 changes: 4 additions & 0 deletions addons/flags/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
ace_flags
===================

Adds placeable and carryable flags with a variety of colors.
11 changes: 11 additions & 0 deletions addons/flags/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
PREP(carryFlag);
PREP(furlFlag);
PREP(getActions);
PREP(getFlags);
PREP(handleScrollWheel);
PREP(isCarryingFlag);
PREP(modifyPickupAction);
PREP(pickupFlag);
PREP(placeFlag);
PREP(scanConfig);
PREP(setFlagTexture);
17 changes: 17 additions & 0 deletions addons/flags/XEH_missionDisplayLoad.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#include "script_component.hpp"

if (!hasInterface) exitWith {};

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;
}];
6 changes: 6 additions & 0 deletions addons/flags/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#include "script_component.hpp"

if (hasInterface) then {
GVAR(isPlacing) = PLACE_CANCEL;
["ace_interactMenuOpened", {GVAR(isPlacing) = PLACE_CANCEL;}] call CBA_fnc_addEventHandler;
};
14 changes: 14 additions & 0 deletions addons/flags/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#include "initSettings.inc.sqf"

GVAR(flagItemCache) = +(uiNamespace getVariable [QGVAR(flagItemCache), createHashMap]);
GVAR(carrierItemMapping) = +(uiNamespace getVariable [QGVAR(carrierItemMapping), createHashMap]);

ADDON = true;
5 changes: 5 additions & 0 deletions addons/flags/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#include "script_component.hpp"

#include "XEH_PREP.hpp"

call FUNC(scanConfig);
37 changes: 37 additions & 0 deletions addons/flags/config.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
#include "script_component.hpp"

class CfgPatches {
class ADDON {
name = COMPONENT_NAME;
units[] = {
QGVAR(carrier_white),
QGVAR(carrier_red),
QGVAR(carrier_blue),
QGVAR(carrier_green),
QGVAR(carrier_yellow),
QGVAR(carrier_orange),
QGVAR(carrier_purple),
QGVAR(carrier_black)
};
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(common,ACETeam);
authors[] = {"Timi007"};
url = ECSTRING(main,URL);
VERSION_CONFIG;
};
};

#include "CfgEventHandlers.hpp"
#include "CfgVehicles.hpp"
#include "CfgWeapons.hpp"
Binary file added addons/flags/data/Flag_yellow_co.paa
Binary file not shown.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added addons/flags/data/flag_black_co.paa
Binary file not shown.
Binary file added addons/flags/data/flag_orange_co.paa
Binary file not shown.
Binary file added addons/flags/data/flag_purple_co.paa
Binary file not shown.
Binary file not shown.
Binary file added addons/flags/data/icons/carry/blue_carry_icon.paa
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added addons/flags/data/icons/carry/red_carry_icon.paa
Binary file not shown.
Binary file not shown.
Binary file added addons/flags/data/icons/carry/white_furl_icon.paa
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added addons/flags/data/icons/place/blue_place_icon.paa
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added addons/flags/data/icons/place/red_place_icon.paa
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file added addons/flags/data/pictures/black_item.paa
Binary file not shown.
Binary file added addons/flags/data/pictures/blue_item.paa
Binary file not shown.
Binary file added addons/flags/data/pictures/green_item.paa
Binary file not shown.
Binary file added addons/flags/data/pictures/orange_item.paa
Binary file not shown.
Binary file added addons/flags/data/pictures/purple_item.paa
Binary file not shown.
Binary file added addons/flags/data/pictures/red_item.paa
Binary file not shown.
Binary file added addons/flags/data/pictures/white_item.paa
Binary file not shown.
Binary file added addons/flags/data/pictures/yellow_item.paa
Binary file not shown.
26 changes: 26 additions & 0 deletions addons/flags/functions/fnc_carryFlag.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "..\script_component.hpp"
/*
* Author: Timi007
* Attaches flag to the back of the unit and removes his flag item.
*
* Arguments:
* 0: Unit <OBJECT>
* 1: Flag item <STRING>
*
* Return Value:
* Nothing
*
* Example:
* [player, "ace_flags_white"] call ace_flags_fnc_carryFlag
*
* Public: No
*/

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;
25 changes: 25 additions & 0 deletions addons/flags/functions/fnc_furlFlag.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#include "..\script_component.hpp"
/*
* Author: Timi007
* Stops carrying flag and adds flag item back to unit.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* Nothing
*
* Example:
* [player] call ace_flags_fnc_furlFlag
*
* Public: No
*/

params ["_unit"];

private _item = _unit getVariable [QGVAR(carryingFlag), ""];

_unit setVariable [QGVAR(carryingFlag), nil, true];
_unit forceFlagTexture ""; // Remove flag

[_unit, _item] call EFUNC(common,addToInventory);
Loading

0 comments on commit d2e0494

Please sign in to comment.