mirror of
https://github.com/acemod/ACE3.git
synced 2024-08-30 18:23:18 +00:00
Zeus - Show where trench will go (#9462)
* Zeus - Show where trench will go * Update fnc_moduleLayTrench.sqf
This commit is contained in:
parent
bd43c32334
commit
e8d1695c83
@ -8,6 +8,7 @@
|
|||||||
* 1: Position <ARRAY>
|
* 1: Position <ARRAY>
|
||||||
* 2: Force - ignoring saftey checks (optional: false) <BOOL>
|
* 2: Force - ignoring saftey checks (optional: false) <BOOL>
|
||||||
* 3: Cut Grass (optional: false) <BOOL>
|
* 3: Cut Grass (optional: false) <BOOL>
|
||||||
|
* 4: Dry Run - Just test if possible (can run on clients) <BOOL>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* <ARRAY>
|
* <ARRAY>
|
||||||
@ -21,10 +22,10 @@
|
|||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if (!isServer) exitWith { ERROR("function must be called on server"); [false, "server-only"]; };
|
params [["_start2d", [], [[]]], ["_end2d", [], [[]]], ["_force", false, [false]], ["_cutGrass", false, [false]], ["_dryRun", false, [false]]];
|
||||||
|
TRACE_4("blockTrench_place",_start2d,_end2d,_force,_dryRun);
|
||||||
|
|
||||||
params [["_start2d", [], [[]]], ["_end2d", [], [[]]], ["_force", false, [false]], ["_cutGrass", false, [false]]];
|
if ((!isServer) && {!_dryRun}) exitWith { ERROR("function must be called on server"); [false, "server-only"]; };
|
||||||
TRACE_3("blockTrench_place",_start2d,_end2d,_force);
|
|
||||||
|
|
||||||
scopeName "main";
|
scopeName "main";
|
||||||
|
|
||||||
@ -71,6 +72,14 @@ if (_east) then {
|
|||||||
TRACE_3("",_east,_origin2D,_length);
|
TRACE_3("",_east,_origin2D,_length);
|
||||||
if (_length < 2) exitWith { [false, "too short"] breakOut "main" };
|
if (_length < 2) exitWith { [false, "too short"] breakOut "main" };
|
||||||
|
|
||||||
|
if (_dryRun) exitWith { // return an array of block positions
|
||||||
|
private _positions = [];
|
||||||
|
for "_i" from 0 to _length do { // intentionally inclusive
|
||||||
|
_positions pushBack (_origin2D vectorAdd (if (_east) then {[(_i + 0.5) * _cellsize, 0]} else {[0, (_i + 0.5) * _cellsize]}));
|
||||||
|
};
|
||||||
|
[true, "dry run", _positions]
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// Test and get block data
|
// Test and get block data
|
||||||
private _blockData = [];
|
private _blockData = [];
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
* 1: Code to run when position is ready (will be passed the following array) <CODE>
|
* 1: Code to run when position is ready (will be passed the following array) <CODE>
|
||||||
* - 0: Successful <BOOL>
|
* - 0: Successful <BOOL>
|
||||||
* - 1: Object <OBJECT>
|
* - 1: Object <OBJECT>
|
||||||
* - 2: Position ASL <ARRAY>
|
* - 2: Mouse Pos ASL <ARRAY>
|
||||||
* - 3: State of Shift <BOOL>
|
* - 3: State of Shift <BOOL>
|
||||||
* - 4: State of Ctrl <BOOL>
|
* - 4: State of Ctrl <BOOL>
|
||||||
* - 5: State of Alt <BOOL>
|
* - 5: State of Alt <BOOL>
|
||||||
@ -16,6 +16,9 @@
|
|||||||
* 3: Icon image file <STRING> (default: "\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa")
|
* 3: Icon image file <STRING> (default: "\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa")
|
||||||
* 4: Icon color <ARRAY> (default: [1,0,0,1])
|
* 4: Icon color <ARRAY> (default: [1,0,0,1])
|
||||||
* 5: Icon Angle <NUMBER> (default: 0)
|
* 5: Icon Angle <NUMBER> (default: 0)
|
||||||
|
* 6: Draw Code <CODE> (default: {})
|
||||||
|
* - 0: Object <OBJECT>
|
||||||
|
* - 1: Mouse Pos ASL <ARRAY>
|
||||||
*
|
*
|
||||||
* Return Value:
|
* Return Value:
|
||||||
* None
|
* None
|
||||||
@ -26,7 +29,7 @@
|
|||||||
* Public: No
|
* Public: No
|
||||||
*/
|
*/
|
||||||
|
|
||||||
params ["_object", "_code", ["_text", ""], ["_icon", "\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa"], ["_color", [1,0,0,1]], ["_angle", 0]];
|
params ["_object", "_code", ["_text", ""], ["_icon", "\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa"], ["_color", [1,0,0,1]], ["_angle", 0], ["_drawCode", {}]];
|
||||||
|
|
||||||
if (missionNamespace getVariable [QGVAR(moduleDestination_running), false]) exitWith {
|
if (missionNamespace getVariable [QGVAR(moduleDestination_running), false]) exitWith {
|
||||||
[false, _object, [0,0,0], false, false, false] call _code;
|
[false, _object, [0,0,0], false, false, false] call _code;
|
||||||
@ -95,7 +98,7 @@ GVAR(moduleDestination_mapDrawEH) = [((findDisplay 312) displayCtrl 50), "draw",
|
|||||||
|
|
||||||
// Add draw EH for 3D camera view - draws the 3D icon and line
|
// Add draw EH for 3D camera view - draws the 3D icon and line
|
||||||
[{
|
[{
|
||||||
(_this select 0) params ["_object", "_code", "_text", "_icon", "_color", "_angle"];
|
(_this select 0) params ["_object", "_code", "_text", "_icon", "_color", "_angle", "_drawCode"];
|
||||||
if ((isNull _object) || {isNull findDisplay 312} || {!isNull findDisplay 49}) then {
|
if ((isNull _object) || {isNull findDisplay 312} || {!isNull findDisplay 49}) then {
|
||||||
TRACE_3("null-exit",isNull _object,isNull findDisplay 312,isNull findDisplay 49);
|
TRACE_3("null-exit",isNull _object,isNull findDisplay 312,isNull findDisplay 49);
|
||||||
GVAR(moduleDestination_running) = false;
|
GVAR(moduleDestination_running) = false;
|
||||||
@ -104,6 +107,7 @@ GVAR(moduleDestination_mapDrawEH) = [((findDisplay 312) displayCtrl 50), "draw",
|
|||||||
if (GVAR(moduleDestination_running)) then {
|
if (GVAR(moduleDestination_running)) then {
|
||||||
// Draw the 3d icon and line
|
// Draw the 3d icon and line
|
||||||
private _mousePosAGL = screenToWorld getMousePosition;
|
private _mousePosAGL = screenToWorld getMousePosition;
|
||||||
|
[_object, AGLToASL _mousePosAGL] call _drawCode;
|
||||||
drawIcon3D [_icon, _color, _mousePosAGL, 1.5, 1.5, _angle, _text];
|
drawIcon3D [_icon, _color, _mousePosAGL, 1.5, 1.5, _angle, _text];
|
||||||
drawLine3D [_mousePosAGL, ASLtoAGL (getPosASL _object), _color];;
|
drawLine3D [_mousePosAGL, ASLtoAGL (getPosASL _object), _color];;
|
||||||
} else {
|
} else {
|
||||||
@ -116,4 +120,4 @@ GVAR(moduleDestination_mapDrawEH) = [((findDisplay 312) displayCtrl 50), "draw",
|
|||||||
GVAR(moduleDestination_displayEHKeyboard) = nil;
|
GVAR(moduleDestination_displayEHKeyboard) = nil;
|
||||||
GVAR(moduleDestination_mapDrawEH) = nil;
|
GVAR(moduleDestination_mapDrawEH) = nil;
|
||||||
};
|
};
|
||||||
}, 0, [_object, _code, _text, _icon, _color, _angle]] call CBA_fnc_addPerFrameHandler;
|
}, 0, [_object, _code, _text, _icon, _color, _angle, _drawCode]] call CBA_fnc_addPerFrameHandler;
|
||||||
|
@ -27,24 +27,31 @@ if !(["ace_trenches"] call EFUNC(common,isModLoaded)) exitWith {
|
|||||||
[LSTRING(RequiresAddon)] call FUNC(showMessage);
|
[LSTRING(RequiresAddon)] call FUNC(showMessage);
|
||||||
};
|
};
|
||||||
|
|
||||||
private _startPos = getPosASL _logic; // change position of logic to be aligned with grid
|
private _drawCode = {
|
||||||
getTerrainInfo params ["", "", "_cellsize"];
|
params ["_object", "_mousePos"];
|
||||||
_startPos = (_startPos select [0,2]) apply {_cellsize * round (_x / _cellsize)};
|
private _startPos = getPos _object;
|
||||||
_logic setPos _startPos;
|
([_startPos, _mousePos, false, false, true] call EFUNC(trenches,blockTrench_place)) params ["_valid", "_reason", "_extra"];
|
||||||
|
if (_valid) then {
|
||||||
|
{
|
||||||
|
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [0,0,1,1], (_x select [0,2]) + [0], 1.5, 1.5, 0, ""];
|
||||||
|
} forEach _extra;
|
||||||
|
} else {
|
||||||
|
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,1,1], (_startPos select [0,2]) + [0], 1.5, 1.5, 0, ""];
|
||||||
|
drawIcon3D ["\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [1,0,1,1], (_mousePos select [0,2]) + [0], 1.5, 1.5, 0, ""];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
// todo: it would be nice to show visually that trenches can only be dug north/south or east/west
|
|
||||||
private _text = format ["%1 %2", LELSTRING(trenches,ConfirmDig), LLSTRING(ModuleLayTrenchline_Tooltip)];
|
private _text = format ["%1 %2", LELSTRING(trenches,ConfirmDig), LLSTRING(ModuleLayTrenchline_Tooltip)];
|
||||||
[_logic, {
|
[_logic, {
|
||||||
params ["_successful", "_logic", "_mousePosASL", "_shift"];
|
params ["_successful", "_logic", "_mousePosASL", "_shift"];
|
||||||
TRACE_4("getModuleDestination",_successful,_logic,_mousePosASL,_shift);
|
TRACE_4("getModuleDestination",_successful,_logic,_mousePosASL,_shift);
|
||||||
|
|
||||||
|
if (isNull _logic) exitWith { WARNING("logic missing"); };
|
||||||
private _startPosASL = getPosASL _logic;
|
private _startPosASL = getPosASL _logic;
|
||||||
deleteVehicle _logic;
|
deleteVehicle _logic;
|
||||||
if (isNull _logic) exitWith { TRACE_1("exit",isNull _logic); };
|
|
||||||
if (!_successful) exitWith { TRACE_1("exit",_successful); };
|
if (!_successful) exitWith { TRACE_1("exit",_successful); };
|
||||||
|
|
||||||
private _args = [_startPosASL, _mousePosASL, _shift];
|
private _args = [_startPosASL, _mousePosASL, _shift];
|
||||||
TRACE_1("sending event",_args);
|
TRACE_1("sending event",_args);
|
||||||
[QEGVAR(trenches,layTrenchline), [ace_player, _args]] call CBA_fnc_serverEvent;
|
[QEGVAR(trenches,layTrenchline), [ace_player, _args]] call CBA_fnc_serverEvent;
|
||||||
}, _text, "\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [0, 1, 0, 1], 45] call FUNC(getModuleDestination);
|
}, _text, "\a3\ui_f\data\IGUI\Cfg\Cursors\select_target_ca.paa", [0, 1, 0, 1], 45, _drawCode] call FUNC(getModuleDestination);
|
||||||
|
Loading…
Reference in New Issue
Block a user