-
Notifications
You must be signed in to change notification settings - Fork 739
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Marker Flags - Add placing system & icons (#8951)
- Loading branch information
Showing
23 changed files
with
203 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
PREP(addActions); | ||
PREP(canPlace); | ||
PREP(getFlags); | ||
PREP(handleScrollWheel); | ||
PREP(pickUpFlag); | ||
PREP(placeFlag); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
}]; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: Timi007 | ||
* Handles the marker flag object height. | ||
* | ||
* Arguments: | ||
* 0: Scroll amount <NUMBER> | ||
* | ||
* Return Value: | ||
* Handled <BOOLEAN> | ||
* | ||
* Example: | ||
* [5] call ace_marker_flags_fnc_handleScrollWheel | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params ["_scrollAmount"]; | ||
|
||
if (GVAR(isPlacing) isNotEqualTo PLACE_WAITING) exitWith { | ||
false | ||
}; | ||
|
||
// Move object height 5cm per scroll | ||
GVAR(objectHeight) = GVAR(objectHeight) + (_scrollAmount * 0.05); | ||
|
||
// Clamp height between MIN_HEIGHT and MAX_HEIGHT | ||
GVAR(objectHeight) = MIN_HEIGHT max (GVAR(objectHeight) min MAX_HEIGHT); | ||
|
||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,74 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: Brett Mayson | ||
* Places a flag in front of the unit. | ||
* Author: Timi007 | ||
* Starts the placing process of the marker flag for the player. | ||
* Flags can be placed with the special marker flag items. | ||
* | ||
* Arguments: | ||
* 0: Unit <OBJECT> | ||
* 1: Flag <STRING> | ||
* 0: Player <OBJECT> | ||
* 1: Flag item <STRING> | ||
* | ||
* Return Value: | ||
* Flag <OBJECT> | ||
* Nothing | ||
* | ||
* Example: | ||
* [player, "ace_marker_flags_white"] call ace_marker_flags_fnc_placeFlag | ||
* | ||
* Public: No | ||
*/ | ||
|
||
params [["_unit", objNull, [objNull]], ["_flag", QGVAR(white), [""]]]; | ||
params [["_player", objNull, [objNull]], ["_item", QGVAR(white), [""]]]; | ||
TRACE_2("Placing flag", _player, _item); | ||
|
||
_unit removeItem _flag; | ||
_flag = GVAR(flagCache) get _flag; // convert to vehicle type | ||
private _pos = _unit modelToWorld [0, 1, 0]; | ||
private _flag = _flag createVehicle _pos; | ||
_flag setPos _pos; | ||
[QGVAR(placed), [_unit, _flag]] call CBA_fnc_localEvent; | ||
[_unit, "PutDown"] call EFUNC(common,doGesture); | ||
(GVAR(flagCache) get _item) params ["_vehicleClass"]; | ||
|
||
private _flag = _vehicleClass createVehicle [0, 0, 0]; | ||
|
||
TRACE_1("Created flag", _flag); | ||
|
||
// 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; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.