Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add placeable and carryable flags #8943

Open
wants to merge 51 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 18 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
6a95746
Add ability to carry and place flags
Timi007 Jun 10, 2022
e607248
Add white icons
Timi007 Jun 10, 2022
4cafe0d
Fix cache
Timi007 Jun 10, 2022
434402e
Fix icon paths
Timi007 Jun 10, 2022
f6500a5
Fix action text
Timi007 Jun 10, 2022
e86fbf4
Fix placing and picking up flags
Timi007 Jun 10, 2022
cebc7c0
Disable debugging
Timi007 Jun 10, 2022
6fef624
Rename var
Timi007 Jun 10, 2022
d0f97f0
Remove hack
Timi007 Jun 10, 2022
8a78b1b
Casing
Timi007 Jun 10, 2022
37cd98a
Add setting to hide place or carry actions
Timi007 Jun 10, 2022
a7d5ba6
Refactor
Timi007 Jun 21, 2022
cee6fa0
Fix function rename
Timi007 Jun 21, 2022
e4d41ed
Add purple, black and orange flags
Timi007 Jun 21, 2022
65814f8
Add new flags to weapons array
Timi007 Jun 21, 2022
44511c5
Add description
Timi007 Jun 21, 2022
8a3c74d
Fix stringtable checks
Timi007 Jun 21, 2022
8318fef
Lazy eval
Timi007 Jun 22, 2022
78bfefb
Save CfgWeapons in var
Timi007 Jun 23, 2022
1322155
Refactor clamping height
Timi007 Jun 23, 2022
ae36edb
Fix docs
Timi007 Jun 30, 2022
b81988e
Add existing translation
Timi007 Jun 30, 2022
c011c66
Use macro
Timi007 Jul 2, 2022
c601f89
Remove obsolete line
Timi007 Jul 2, 2022
7ef33d5
Merge branch 'acemod:master' into flags
Timi007 Nov 10, 2024
00e2762
Fix hemtt build
Timi007 Nov 10, 2024
f82e676
Fix hemtt warnings
Timi007 Nov 10, 2024
2e5cd28
Fix floating
Timi007 Nov 10, 2024
8462536
Increase mass
Timi007 Nov 10, 2024
a64c744
Use new script_component path
Timi007 Nov 10, 2024
917078f
Use EFUNC and check canInteractWith
Timi007 Nov 10, 2024
88aea4a
Merge branch 'acemod:master' into flags
Timi007 Dec 20, 2024
94de944
Correct spelling
Timi007 Dec 20, 2024
69cc11a
Build item cache in preStart
Timi007 Dec 20, 2024
b7fe43e
Add private
Timi007 Dec 20, 2024
f8ac07e
Move config cache to fnc_scanConfig
Timi007 Dec 21, 2024
481790b
Make flag carrier customizable
Timi007 Dec 21, 2024
4bf9803
More descriptive var
Timi007 Dec 21, 2024
b06498b
Reduce round brackets
Timi007 Dec 21, 2024
c831818
Improve German translation
Timi007 Dec 21, 2024
33c2f02
Improve spelling
Timi007 Dec 21, 2024
c7a7712
Merge branch 'master' into pr/8943
johnb432 Jan 17, 2025
6c59408
Rename to isCarryingFlag
Timi007 Jan 17, 2025
491941c
Remove explicit _this
Timi007 Jan 17, 2025
0719455
Add check for already picked up flag
Timi007 Jan 17, 2025
c7f87b5
Formatting
Timi007 Jan 17, 2025
0de8d45
Use cancel STR from common
Timi007 Jan 17, 2025
394548d
Fix finding
Timi007 Jan 18, 2025
9635215
Add carrier for each flag
Timi007 Jan 18, 2025
557a6e6
Add editor previews
Timi007 Jan 18, 2025
9ca650f
Fix hook
Timi007 Jan 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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));
};
};
22 changes: 22 additions & 0 deletions addons/flags/CfgVehicles.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class CfgVehicles {
class Man;
class CAManBase: Man {
class ACE_SelfActions {
class ACE_Equipment {
class ADDON {
displayName = CSTRING(ActionCategory);
condition = QUOTE(_player call FUNC(hasFlag));
insertChildren = QUOTE(_this call FUNC(getActions));
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
icon = QPATHTOF(data\icons\place\white_place_icon.paa);

class GVAR(furlFlag) {
displayName = CSTRING(Furl);
condition = QUOTE(_player call FUNC(carriesFlag));
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
statement = QUOTE(_player call FUNC(furlFlag));
icon = QPATHTOF(data\icons\carry\white_furl_icon.paa);
};
};
};
};
};
};
78 changes: 78 additions & 0 deletions addons/flags/CfgWeapons.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
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(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;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Way too light, assault pack can carry 53 flags

};
};
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);
};
};
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.
8 changes: 8 additions & 0 deletions addons/flags/XEH_PREP.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
PREP(carriesFlag);
PREP(carryFlag);
PREP(furlFlag);
PREP(getActions);
PREP(getFlags);
PREP(handleScrollWheel);
PREP(pickupFlag);
PREP(placeFlag);
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
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
GVAR(isPlacing) = PLACE_CANCEL;
}];
39 changes: 39 additions & 0 deletions addons/flags/XEH_postInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#include "script_component.hpp"

if (!hasinterface) exitWith {};

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 _flagItems = (call (uiNamespace getVariable [QGVAR(allFlagItems), {[]}])) apply {configFile >> "CfgWeapons" >> _x};
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
{
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]];
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
} forEach _flagItems;
13 changes: 13 additions & 0 deletions addons/flags/XEH_preInit.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#include "script_component.hpp"

ADDON = false;

PREP_RECOMPILE_START;
#include "XEH_PREP.hpp"
PREP_RECOMPILE_END;

#include "initSettings.sqf"

GVAR(flagItemCache) = createHashMap;
Timi007 marked this conversation as resolved.
Show resolved Hide resolved

ADDON = true;
6 changes: 6 additions & 0 deletions addons/flags/XEH_preStart.sqf
Original file line number Diff line number Diff line change
@@ -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];
28 changes: 28 additions & 0 deletions addons/flags/config.cpp
Original file line number Diff line number Diff line change
@@ -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(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.
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.
21 changes: 21 additions & 0 deletions addons/flags/functions/fnc_carriesFlag.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include "script_component.hpp"
/*
* Author: Timi007
* Checks if the unit is carrying a flag.
*
* Arguments:
* 0: Unit <OBJECT>
*
* Return Value:
* True if unit is carrying a flag; otherwise flase <BOOLEAN>
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
*
* Example:
* [player] call ace_flags_fnc_carriesFlag
*
* Public: No
*/

params ["_unit"];

(_unit getVariable [QGVAR(carryingFlag), ""] isNotEqualTo "") &&
{(getForcedFlagTexture _unit) isNotEqualTo ""}
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;
26 changes: 26 additions & 0 deletions addons/flags/functions/fnc_furlFlag.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#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"];

// 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 EFUNC(common,addToInventory);
62 changes: 62 additions & 0 deletions addons/flags/functions/fnc_getActions.sqf
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#include "script_component.hpp"
/*
* Author: Timi007
* Gets the child actions for placing and carring flags.
*
* Arguments:
* 0: Player <OBJECT>
*
* Return Value:
* Actions <ARRAY>
*
* Example:
* [player] call ace_flags_fnc_getActions
*
* Public: No
*/

params ["_player"];

private _actions = [];

{
(GVAR(flagItemCache) get _x) params ["_flagName", "_texture", "_actionIconPlace", "_actionIconCarry"];

// Place flag
_actions pushBack [
[
"place_" + _x,
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
format [LLSTRING(Place), _flagName],
_actionIconPlace,
{
params ["_player", "", "_item"];
[_player, _item] call FUNC(placeFlag);
},
{GVAR(enablePlacing)},
{},
_x
] call EFUNC(interact_menu,createAction),
[],
_player
];

// Carry flag
_actions pushBack [
[
"carry_" + _x,
Timi007 marked this conversation as resolved.
Show resolved Hide resolved
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 EFUNC(interact_menu,createAction),
[],
_player
];
} forEach ([_player] call FUNC(getFlags));

_actions
Loading