2023-09-12 18:58:10 +00:00
|
|
|
#include "..\script_component.hpp"
|
2022-05-10 01:28:10 +00:00
|
|
|
/*
|
2022-08-31 04:17:31 +00:00
|
|
|
* Author: Timi007
|
|
|
|
* Starts the placing process of the marker flag for the player.
|
|
|
|
* Flags can be placed with the special marker flag items.
|
2022-05-10 01:28:10 +00:00
|
|
|
*
|
|
|
|
* Arguments:
|
2022-08-31 04:17:31 +00:00
|
|
|
* 0: Player <OBJECT>
|
|
|
|
* 1: Flag item <STRING>
|
2022-05-10 01:28:10 +00:00
|
|
|
*
|
|
|
|
* Return Value:
|
2022-08-31 04:17:31 +00:00
|
|
|
* Nothing
|
2022-05-10 01:28:10 +00:00
|
|
|
*
|
|
|
|
* Example:
|
|
|
|
* [player, "ace_marker_flags_white"] call ace_marker_flags_fnc_placeFlag
|
|
|
|
*
|
|
|
|
* Public: No
|
|
|
|
*/
|
|
|
|
|
2022-08-31 04:17:31 +00:00
|
|
|
params [["_player", objNull, [objNull]], ["_item", QGVAR(white), [""]]];
|
2024-02-05 17:04:24 +00:00
|
|
|
TRACE_2("Placing flag",_player,_item);
|
2022-05-10 01:28:10 +00:00
|
|
|
|
2022-08-31 04:17:31 +00:00
|
|
|
(GVAR(flagCache) get _item) params ["_vehicleClass"];
|
|
|
|
|
|
|
|
private _flag = _vehicleClass createVehicle [0, 0, 0];
|
|
|
|
|
2024-02-05 17:04:24 +00:00
|
|
|
TRACE_1("Created flag",_flag);
|
2022-08-31 04:17:31 +00:00
|
|
|
|
|
|
|
// Set flag start height
|
|
|
|
GVAR(objectHeight) = MAX_HEIGHT;
|
|
|
|
|
|
|
|
GVAR(isPlacing) = PLACE_WAITING;
|
|
|
|
|
|
|
|
// Add info dialog for the player which show the controls
|
|
|
|
[LLSTRING(ActionPlace), LLSTRING(ActionCancel), LLSTRING(ActionAdjustHeight)] call EFUNC(interaction,showMouseHint);
|
|
|
|
|
|
|
|
private _mouseClickID = [_player, "DefaultAction", {
|
|
|
|
GVAR(isPlacing) isEqualTo PLACE_WAITING
|
|
|
|
}, {
|
|
|
|
GVAR(isPlacing) = PLACE_APPROVE
|
|
|
|
}] call EFUNC(common,addActionEventHandler);
|
|
|
|
|
|
|
|
[{
|
|
|
|
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 EFUNC(interaction,hideMouseHint);
|
|
|
|
[_player, "DefaultAction", _mouseClickID] call EFUNC(common,removeActionEventHandler);
|
|
|
|
|
|
|
|
if (GVAR(isPlacing) isEqualTo PLACE_APPROVE) then {
|
|
|
|
// End position of the flag
|
|
|
|
GVAR(isPlacing) = PLACE_CANCEL;
|
|
|
|
[_player, "PutDown"] call EFUNC(common,doGesture);
|
|
|
|
_player removeItem _item;
|
|
|
|
[QGVAR(placed), [_player, _flag, _item]] call CBA_fnc_localEvent;
|
|
|
|
} 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 - 90);
|
|
|
|
}, 0, [_player, _item, _flag, _mouseClickID]] call CBA_fnc_addPerFrameHandler;
|