Merge pull request #1117 from acemod/waveHeightAtFunc

Added: waveHeightAt Function
This commit is contained in:
jaynus 2015-05-12 21:15:35 -07:00
commit ed2f73d4d9
4 changed files with 40 additions and 7 deletions

View File

@ -183,6 +183,7 @@ PREP(unmuteUnit);
PREP(useItem);
PREP(useMagazine);
PREP(waitAndExecute);
PREP(waveHeightAt);
PREP(translateToWeaponSpace);
PREP(translateToModelSpace);

View File

@ -0,0 +1,20 @@
/*
* Author: jaynus
*
* Gets the wave height at a specific location. Uses a logic, so may be performance iffy
*
* Arguments:
* 0: Position ASL to get height at
*
* Return Value:
* Wave height in meters
*
*/
#include "script_component.hpp"
if(isNil QGVAR(waveHeightLogic)) then {
GVAR(waveHeightLogic) = "Logic" createVehicleLocal [0,0,0];
};
GVAR(waveHeightLogic) setPosASL (_this select 0);
(((getPosASLW GVAR(waveHeightLogic)) select 2) - ((getPosASL GVAR(waveHeightLogic)) select 2))

View File

@ -64,6 +64,13 @@ if (GVAR(useCursorMenu)) then {
GVAR(selfMenuOffset) = ((positionCameraToWorld [0, 0, 2]) call EFUNC(common,positionToASL)) vectorDiff
((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL));
private ["_wavesAtOrigin", "_wavesAtVirtualPoint"];
_wavesAtOrigin = [(positionCameraToWorld [0, 0, 0])] call EFUNC(common,waveHeightAt);
_wavesAtVirtualPoint = [(positionCameraToWorld [0, 0, 2])] call EFUNC(common,waveHeightAt);
GVAR(selfMenuOffset) set [2, ((GVAR(selfMenuOffset) select 2) + _wavesAtOrigin - _wavesAtVirtualPoint)];
["interactMenuOpened", [_menuType]] call EFUNC(common,localEvent);
true

View File

@ -14,7 +14,7 @@
GVAR(currentOptions) = [];
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos"];
private ["_player","_numInteractObjects","_numInteractions","_actionsVarName","_classActions","_target","_player","_action","_cameraPos","_cameraDir", "_lambda", "_nearestObjects", "_pos", "_virtualPoint", "_wavesAtOrigin", "_wavesAtVirtualPoint"];
_player = ACE_player;
_fnc_renderNearbyActions = {
@ -101,14 +101,19 @@ _fnc_renderSelfActions = {
// Iterate through base level class actions and render them if appropiate
_actionsVarName = format [QGVAR(SelfAct_%1), typeOf _target];
_classActions = missionNamespace getVariable [_actionsVarName, []];
_pos = if !(GVAR(useCursorMenu)) then {
_virtualPoint = (((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition);
_wavesAtOrigin = [(positionCameraToWorld [0, 0, 0])] call EFUNC(common,waveHeightAt);
_wavesAtVirtualPoint = [_virtualPoint] call EFUNC(common,waveHeightAt);
_virtualPoint set [2, ((_virtualPoint select 2) - _wavesAtOrigin + _wavesAtVirtualPoint)];
_virtualPoint
} else {
[0.5, 0.5]
};
{
_action = _x;
_pos = if !(GVAR(useCursorMenu)) then {
(((positionCameraToWorld [0, 0, 0]) call EFUNC(common,positionToASL)) vectorAdd GVAR(selfMenuOffset)) call EFUNC(common,ASLToPosition)
} else {
[0.5, 0.5]
};
[_target, _action, _pos] call FUNC(renderBaseMenu);
} forEach _classActions;
};