mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Add ability to carry and place flags
This commit is contained in:
parent
d8af7b34b7
commit
6a95746434
1
addons/flags/$PBOPREFIX$
Normal file
1
addons/flags/$PBOPREFIX$
Normal file
@ -0,0 +1 @@
|
||||
z\ace\addons\flags
|
23
addons/flags/CfgEventHandlers.hpp
Normal file
23
addons/flags/CfgEventHandlers.hpp
Normal file
@ -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));
|
||||
};
|
||||
};
|
20
addons/flags/CfgVehicles.hpp
Normal file
20
addons/flags/CfgVehicles.hpp
Normal file
@ -0,0 +1,20 @@
|
||||
class CfgVehicles {
|
||||
class Man;
|
||||
class CAManBase: Man {
|
||||
class ACE_SelfActions {
|
||||
class ACE_Equipment {
|
||||
class ADDON {
|
||||
displayName = CSTRING(action);
|
||||
condition = QUOTE(_player call FUNC(hasFlag));
|
||||
insertChildren = QUOTE(_this call FUNC(addActions));
|
||||
|
||||
class GVAR(furlFlag) {
|
||||
displayName = CSTRING(furlFlag);
|
||||
condition = QUOTE(_player call FUNC(carriesFlag));
|
||||
statement = QUOTE(_player call FUNC(furlFlag));
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
53
addons/flags/CfgWeapons.hpp
Normal file
53
addons/flags/CfgWeapons.hpp
Normal file
@ -0,0 +1,53 @@
|
||||
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\ui\flags\red_item_icon.paa);
|
||||
|
||||
GVAR(texture) = "\a3\data_f\flags\flag_white_co.paa";
|
||||
GVAR(actionIconPlace) = QPATHTOF(data\ui\flags\white_icon.paa);
|
||||
GVAR(actionIconCarry) = QPATHTOF(data\ui\flags\white_carry_icon.paa);
|
||||
|
||||
class ItemInfo: CBA_MiscItem_ItemInfo {
|
||||
mass = 3;
|
||||
};
|
||||
};
|
||||
class GVAR(red): GVAR(white) {
|
||||
displayName = CSTRING(red);
|
||||
picture = QPATHTOF(data\ui\flags\red_item_icon.paa);
|
||||
|
||||
GVAR(texture) = "\a3\data_f\flags\flag_red_co.paa";
|
||||
GVAR(actionIconPlace) = QPATHTOF(data\ui\flags\red_place_icon.paa);
|
||||
GVAR(actionIconCarry) = QPATHTOF(data\ui\flags\red_carry_icon.paa);
|
||||
};
|
||||
class GVAR(blue): GVAR(white) {
|
||||
displayName = CSTRING(blue);
|
||||
picture = QPATHTOF(data\ui\flags\blue_item_icon.paa);
|
||||
|
||||
GVAR(texture) = "\a3\data_f\flags\Flag_blue_co.paa";
|
||||
GVAR(actionIconPlace) = QPATHTOF(data\ui\flags\blue_place_icon.paa);
|
||||
GVAR(actionIconCarry) = QPATHTOF(data\ui\flags\blue_carry_icon.paa);
|
||||
};
|
||||
class GVAR(green): GVAR(white) {
|
||||
displayName = CSTRING(green);
|
||||
picture = QPATHTOF(data\ui\flags\green_item_icon.paa);
|
||||
|
||||
GVAR(texture) = "\a3\data_f\flags\flag_green_co.paa";
|
||||
GVAR(actionIconPlace) = QPATHTOF(data\ui\flags\green_place_icon.paa);
|
||||
GVAR(actionIconCarry) = QPATHTOF(data\ui\flags\green_carry_icon.paa);
|
||||
};
|
||||
class GVAR(yellow): GVAR(white) {
|
||||
displayName = CSTRING(yellow);
|
||||
picture = QPATHTOF(data\ui\flags\yellow_item_icon.paa);
|
||||
|
||||
GVAR(texture) = QPATHTOF(data\Flag_yellow_co.paa);
|
||||
GVAR(actionIconPlace) = QPATHTOF(data\ui\flags\yellow_place_icon.paa);
|
||||
GVAR(actionIconCarry) = QPATHTOF(data\ui\flags\yellow_carry_icon.paa);
|
||||
};
|
||||
};
|
4
addons/flags/README.md
Normal file
4
addons/flags/README.md
Normal file
@ -0,0 +1,4 @@
|
||||
ace_flags
|
||||
===================
|
||||
|
||||
Adds flags feature.
|
8
addons/flags/XEH_PREP.hpp
Normal file
8
addons/flags/XEH_PREP.hpp
Normal file
@ -0,0 +1,8 @@
|
||||
PREP(addActions);
|
||||
PREP(carriesFlag);
|
||||
PREP(carryFlag);
|
||||
PREP(furlFlag);
|
||||
PREP(getFlags);
|
||||
PREP(handleScrollWheel);
|
||||
PREP(pickupFlag);
|
||||
PREP(placeFlag);
|
17
addons/flags/XEH_missionDisplayLoad.sqf
Normal file
17
addons/flags/XEH_missionDisplayLoad.sqf
Normal file
@ -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;
|
||||
}];
|
41
addons/flags/XEH_postInit.sqf
Normal file
41
addons/flags/XEH_postInit.sqf
Normal file
@ -0,0 +1,41 @@
|
||||
#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(cache) get _item) params ["_displayName"];
|
||||
|
||||
private _pickupFlag = [
|
||||
QGVAR(pickup),
|
||||
format [LLSTRING(pickup), _displayName],
|
||||
QPATHTOF(data\ui\flags\pickup_icon.paa),
|
||||
{
|
||||
params ["_flag", "_unit", "_args"];
|
||||
_args params ["_item"];
|
||||
|
||||
[_unit, _item, _flag] call FUNC(pickupFlag);
|
||||
},
|
||||
{true},
|
||||
{},
|
||||
[_item],
|
||||
[0, 0, 0],
|
||||
PICKUP_RADIUS
|
||||
] 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};
|
||||
{
|
||||
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;
|
11
addons/flags/XEH_preInit.sqf
Normal file
11
addons/flags/XEH_preInit.sqf
Normal file
@ -0,0 +1,11 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
ADDON = false;
|
||||
|
||||
PREP_RECOMPILE_START;
|
||||
#include "XEH_PREP.hpp"
|
||||
PREP_RECOMPILE_END;
|
||||
|
||||
ADDON = true;
|
||||
|
||||
GVAR(cache) = createHashMap;
|
6
addons/flags/XEH_preStart.sqf
Normal file
6
addons/flags/XEH_preStart.sqf
Normal file
@ -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];
|
25
addons/flags/config.cpp
Normal file
25
addons/flags/config.cpp
Normal file
@ -0,0 +1,25 @@
|
||||
#include "script_component.hpp"
|
||||
|
||||
class CfgPatches {
|
||||
class ADDON {
|
||||
name = COMPONENT_NAME;
|
||||
units[] = {};
|
||||
weapons[] = {
|
||||
QGVAR(white),
|
||||
QGVAR(red),
|
||||
QGVAR(blue),
|
||||
QGVAR(green),
|
||||
QGVAR(yellow)
|
||||
};
|
||||
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"
|
BIN
addons/flags/data/Flag_yellow_co.paa
Normal file
BIN
addons/flags/data/Flag_yellow_co.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/blue_carry_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/blue_carry_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/blue_item_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/blue_item_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/blue_place_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/blue_place_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/furl_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/furl_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/green_carry_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/green_carry_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/green_item_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/green_item_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/green_place_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/green_place_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/pickup_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/pickup_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/red_carry_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/red_carry_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/red_item_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/red_item_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/red_place_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/red_place_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/white_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/white_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/yellow_carry_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/yellow_carry_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/yellow_item_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/yellow_item_icon.paa
Normal file
Binary file not shown.
BIN
addons/flags/data/ui/flags/yellow_place_icon.paa
Normal file
BIN
addons/flags/data/ui/flags/yellow_place_icon.paa
Normal file
Binary file not shown.
56
addons/flags/functions/fnc_addActions.sqf
Normal file
56
addons/flags/functions/fnc_addActions.sqf
Normal file
@ -0,0 +1,56 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Timi007
|
||||
* Adds the child actions for placing and carring flags.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Player <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Actions <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_flags_fnc_addActions
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_player"];
|
||||
|
||||
private _actions = [];
|
||||
|
||||
{
|
||||
(GVAR(flagItemCache) get _x) params ["_displayName", "_texture", "_actionIconPlace", "_actionIconCarry"];
|
||||
|
||||
// Place flag
|
||||
_actions pushBack [
|
||||
[
|
||||
"place_" + _x,
|
||||
format [LSTRING(place), _displayName],
|
||||
_actionIconPlace,
|
||||
{[_this select 0, _this select 2] call FUNC(placeFlag)},
|
||||
{true},
|
||||
{},
|
||||
_x
|
||||
] call EFUNC(interact_menu,createAction),
|
||||
[],
|
||||
_player
|
||||
];
|
||||
|
||||
// Carry flag
|
||||
_actions pushBack [
|
||||
[
|
||||
"carry_" + _x,
|
||||
format [LSTRING(carry), _displayName],
|
||||
_actionIconCarry,
|
||||
{[_this select 0, _this select 2] call FUNC(carryFlag)},
|
||||
{!([_this select 1] call FUNC(carriesFlag))}, // Should not carry flag already
|
||||
{},
|
||||
_x
|
||||
] call EFUNC(interact_menu,createAction),
|
||||
[],
|
||||
_player
|
||||
];
|
||||
} forEach ([_player] call FUNC(getFlags));
|
||||
|
||||
_actions
|
21
addons/flags/functions/fnc_carriesFlag.sqf
Normal file
21
addons/flags/functions/fnc_carriesFlag.sqf
Normal file
@ -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>
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_flags_fnc_carriesFlag
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
(_unit getVariable [QGVAR(carryingFlag), ""] isNotEqualTo "") &&
|
||||
{(getForcedFlagTexture _unit) isNotEqualTo ""}
|
37
addons/flags/functions/fnc_carryFlag.sqf
Normal file
37
addons/flags/functions/fnc_carryFlag.sqf
Normal file
@ -0,0 +1,37 @@
|
||||
#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"];
|
||||
|
||||
// Arma needs a flag proxy and some modded uniforms don't have them.
|
||||
// If we temporarily change the uniform to a vanilla one we can work around this problem.
|
||||
private _loadout = getUnitLoadout _unit;
|
||||
_unit forceAddUniform "U_B_CombatUniform_mcam";
|
||||
|
||||
private _texture = (GVAR(flagItemCache) get _item) param [1, ""];
|
||||
_unit forceFlagTexture _texture;
|
||||
|
||||
// We need to change loadout in the next frame otherwise it will not work
|
||||
[{
|
||||
params ["_unit", "_item", "_loadout"];
|
||||
|
||||
_unit setUnitLoadout _loadout;
|
||||
|
||||
_unit setVariable [QGVAR(carryingFlag), _item, true];
|
||||
_unit removeItem _item;
|
||||
}, [_unit, _item, _loadout]] call CBA_fnc_execNextFrame;
|
26
addons/flags/functions/fnc_furlFlag.sqf
Normal file
26
addons/flags/functions/fnc_furlFlag.sqf
Normal file
@ -0,0 +1,26 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Timi007
|
||||
* Stops carrying flag and add flag item 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);
|
20
addons/flags/functions/fnc_getFlags.sqf
Normal file
20
addons/flags/functions/fnc_getFlags.sqf
Normal file
@ -0,0 +1,20 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Timi007
|
||||
* Get the placeable and carryable flags in the unit's inventory.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Flag items <ARRAY>
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_flags_fnc_getFlags
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit"];
|
||||
|
||||
(_unit call EFUNC(common,uniqueItems)) arrayIntersect keys GVAR(flagItemCache)
|
33
addons/flags/functions/fnc_handleScrollWheel.sqf
Normal file
33
addons/flags/functions/fnc_handleScrollWheel.sqf
Normal file
@ -0,0 +1,33 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Timi007
|
||||
* Handles the flag object height.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Scroll amount <NUMBER>
|
||||
*
|
||||
* Return Value:
|
||||
* Handled <BOOLEAN>
|
||||
*
|
||||
* Example:
|
||||
* [5] call ace_flags_fnc_handleScrollWheel
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_scrollAmount"];
|
||||
|
||||
if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith {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;
|
||||
};
|
||||
|
||||
true
|
30
addons/flags/functions/fnc_pickupFlag.sqf
Normal file
30
addons/flags/functions/fnc_pickupFlag.sqf
Normal file
@ -0,0 +1,30 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Timi007
|
||||
* Picks up flag and adds item to unit.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Unit <OBJECT>
|
||||
* 1: Flag item <STRING>
|
||||
* 2: Flag pole (gets deleted later) <OBJECT>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player] call ace_flags_fnc_pickupFlag
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_unit", "_item", "_flag"];
|
||||
|
||||
[_unit, "PutDown"] call EFUNC(common,doGesture);
|
||||
|
||||
[{((animationState _unit) select [25,7]) isEqualTo "putdown"}, {
|
||||
params ["_unit", "_item", "_flag"];
|
||||
|
||||
[_unit, _item] call EFUNC(common,addToInventory);
|
||||
|
||||
deleteVehicle _flag;
|
||||
}, _this] call CBA_fnc_waitUntilAndExecute;
|
80
addons/flags/functions/fnc_placeFlag.sqf
Normal file
80
addons/flags/functions/fnc_placeFlag.sqf
Normal file
@ -0,0 +1,80 @@
|
||||
#include "script_component.hpp"
|
||||
/*
|
||||
* Author: Timi007
|
||||
* Starts the placing process of the flag for the player.
|
||||
* Flags can be placed with the special flag items.
|
||||
*
|
||||
* Arguments:
|
||||
* 0: Player <OBJECT>
|
||||
* 1: Flag item <STRING>
|
||||
*
|
||||
* Return Value:
|
||||
* Nothing
|
||||
*
|
||||
* Example:
|
||||
* [player, "ace_flags_white"] call ace_flags_fnc_pickupFlag
|
||||
*
|
||||
* Public: No
|
||||
*/
|
||||
|
||||
params ["_player", "_item"];
|
||||
|
||||
// Create local object
|
||||
private _flag = "FlagChecked_F" createVehicle [0, 0, 0];
|
||||
|
||||
// Set object start height
|
||||
GVAR(objectHeight) = MIN_HEIGHT;
|
||||
|
||||
GVAR(isPlacing) = PLACE_WAITING;
|
||||
|
||||
(GVAR(flagItemCache) get _x) params ["_flagName"];
|
||||
|
||||
// Add info dialog for the player which show the controls
|
||||
private _placeFlagText = format [LLSTRING(place), _flagName];
|
||||
[_placeFlagText, LLSTRING(cancel), LLSTRING(adjustHeight)] call EFUNC(interaction,showMouseHint);
|
||||
|
||||
private _mouseClickID = [_player, "DefaultAction", {
|
||||
GVAR(isPlacing) isEqualTo PLACE_WAITING
|
||||
}, {
|
||||
GVAR(isPlacing) = PLACE_APPROVE
|
||||
}] call EFUNC(common,addActionEventHandler);
|
||||
|
||||
[{ // Start of PFH
|
||||
params ["_args", "_handle"];
|
||||
_args params ["_player", "_item", "_flag", "_mouseClickID"];
|
||||
|
||||
if (isNull _flag || {!([_player, _flag] call EFUNC(common,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 EFUNC(common,removeActionEventHandler);
|
||||
|
||||
if (GVAR(isPlacing) isEqualTo PLACE_APPROVE) then {
|
||||
// End position of the object
|
||||
|
||||
GVAR(isPlacing) = PLACE_CANCEL;
|
||||
|
||||
[_player, "PutDown"] call EFUNC(common,doGesture);
|
||||
|
||||
[{(animationState _player select [25, 7]) isEqualTo "putdown"}, {
|
||||
params ["_player", "_item", "_flag"];
|
||||
|
||||
[QGVAR(flagPlaced), [_player, _item, _flag]] call CBA_fnc_globalEventJIP;
|
||||
[QGVAR(flagPlaced), _flag] call CBA_fnc_removeGlobalEventJIP;
|
||||
}, [_player, _item, _flag]] call CBA_fnc_waitUntilAndExecute;
|
||||
} 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;
|
1
addons/flags/functions/script_component.hpp
Normal file
1
addons/flags/functions/script_component.hpp
Normal file
@ -0,0 +1 @@
|
||||
#include "\z\ace\addons\flags\script_component.hpp"
|
28
addons/flags/script_component.hpp
Normal file
28
addons/flags/script_component.hpp
Normal file
@ -0,0 +1,28 @@
|
||||
#define COMPONENT flags
|
||||
#define COMPONENT_BEAUTIFIED Flags
|
||||
#include "\z\ace\addons\main\script_mod.hpp"
|
||||
|
||||
#define DEBUG_MODE_FULL
|
||||
#define DISABLE_COMPILE_CACHE
|
||||
// #define ENABLE_PERFORMANCE_COUNTERS
|
||||
|
||||
#ifdef DEBUG_ENABLED_FLAGS
|
||||
#define DEBUG_MODE_FULL
|
||||
#endif
|
||||
|
||||
#ifdef DEBUG_SETTINGS_FLAGS
|
||||
#define DEBUG_SETTINGS DEBUG_SETTINGS_FLAGS
|
||||
#endif
|
||||
|
||||
#include "\z\ace\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
|
||||
|
||||
#define PICKUP_RADIUS 2
|
61
addons/flags/stringtable.xml
Normal file
61
addons/flags/stringtable.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project name="ACE">
|
||||
<Package name="Flags">
|
||||
<Container name="displayNames">
|
||||
<Key ID="STR_ACE_Flags_white">
|
||||
<Original>Flag (White)</Original>
|
||||
<German>Flagge (Weiß)</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_red">
|
||||
<Original>Flag (Red)</Original>
|
||||
<German>Flagge (Rot)</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_blue">
|
||||
<Original>Flag (Blue)</Original>
|
||||
<German>Flagge (Blau)</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_green">
|
||||
<Original>Flag (Green)</Original>
|
||||
<German>Flagge (Grün)</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_yellow">
|
||||
<Original>Flag (Yellow)</Original>
|
||||
<German>Flagge (Gelb)</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_description">
|
||||
<Original>Can be carried or placed. Flags are used to mark a specific point in terrain or units.</Original>
|
||||
<German>Kann getragen oder platziert werden. Flaggen werden zur Kennzeichnung von bestimmten Geländepunkte oder Einheiten eingesetzt.</German>
|
||||
</Key>
|
||||
</Container>
|
||||
<Container name="actions">
|
||||
<Key ID="STR_ACE_Flags_action">
|
||||
<Original>Flags</Original>
|
||||
<German>Flaggen</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_carry">
|
||||
<Original>Carry %1</Original>
|
||||
<German>%1 tragen</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_furl">
|
||||
<Original>Furl Flag</Original>
|
||||
<German>Flagge einrollen</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_place">
|
||||
<Original>Place %1</Original>
|
||||
<German>%1 platzieren</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_pickup">
|
||||
<Original>Pickup %1</Original>
|
||||
<German>%1 aufnehmen</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_cancel">
|
||||
<Original>Cancel</Original>
|
||||
<German>Abbrechen</German>
|
||||
</Key>
|
||||
<Key ID="STR_ACE_Flags_adjustHeight">
|
||||
<Original>Adjust height</Original>
|
||||
<German>Höhe anpassen</German>
|
||||
</Key>
|
||||
</Container>
|
||||
</Package>
|
||||
</Project>
|
Loading…
Reference in New Issue
Block a user