Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rework position commands #341

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion addons/danger/functions/fnc_tacticsAssess.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ if !(_enemies isEqualTo [] || {_unitCount < random 4}) then {
if (EGVAR(main,Loaded_WP) && {[side _unit] call EFUNC(WP,sideHasArtillery)}) then {
private _artilleryTarget = _enemies findIf {
_unit distance2D _x > RANGE_MID
&& {([_unit, getPos _x, RANGE_NEAR] call EFUNC(main,findNearbyFriendlies)) isEqualTo []}
&& {([_unit, POSITIONAGL(_x), RANGE_NEAR] call EFUNC(main,findNearbyFriendlies)) isEqualTo []}
};
if (_artilleryTarget != -1) then {
[_unit, _unit getHideFrom (_enemies select _artilleryTarget)] call EFUNC(main,doCallArtillery); // possibly add delay? ~ nkenny
Expand Down
2 changes: 1 addition & 1 deletion addons/danger/functions/fnc_tacticsFlank.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if (_overwatch isEqualTo []) then {
_overwatch = _overwatch select {!(surfaceIsWater (_x select 1))};
_overwatch sort true;
_overwatch = _overwatch apply {_x select 1};
if (_overwatch isEqualTo []) then {_overwatch pushBack ([getPos _unit, _distance2D, 100, 8, _target] call EFUNC(main,findOverwatch));};
if (_overwatch isEqualTo []) then {_overwatch pushBack ([POSITIONAGL(_unit), _distance2D, 100, 8, _target] call EFUNC(main,findOverwatch));};
_overwatch = _overwatch select 0;
};

Expand Down
4 changes: 2 additions & 2 deletions addons/danger/scripts/lambs_danger.fsm
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class FSM
itemno = 23;
init = /*%FSM<STATEINIT""">*/"// has living cqb target" \n
"if (_engage && {_dangerCausedBy call lambs_main_fnc_isAlive} && {_this distance2D _dangerCausedBy < 35}) then {" \n
" _queue pushBack [0, getPos _dangerCausedBy, time + lambs_danger_dangerUntil, _dangerCausedBy];" \n
" _queue pushBack [0, ASLtoAGL (getPosASL _dangerCausedBy), time + lambs_danger_dangerUntil, _dangerCausedBy];" \n
"};" \n
"" \n
"//_text = format [""%1 : %2 : %3"", name _this, _dangerCause call lambs_main_fnc_debugDangerType,_queue apply{[(_x select 0) call lambs_main_fnc_debugDangerType]}];" \n
Expand Down Expand Up @@ -518,7 +518,7 @@ class FSM
init = /*%FSM<STATEINIT""">*/"" \n
"// has group memory" \n
"if (_queue isEqualTo [] && {((group _this) getVariable [""lambs_main_groupMemory"", []]) isNotEqualTo []} ) then {" \n
" _queue pushBack [10, getPos _this, time + lambs_danger_dangerUntil, _dangerCausedBy];" \n
" _queue pushBack [10, ASLtoAGL (getPosASL _this), time + lambs_danger_dangerUntil, _dangerCausedBy];" \n
"};" \n
"" \n
""/*%FSM</STATEINIT""">*/;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private _EH = _gunner addEventHandler ["WeaponAssembled", {

// find position ~ kept simple for now!
if (_weaponPos isEqualTo []) then {
_weaponPos = [getPos (leader _gunner), 0, 15, 2, 0, 0.19, 0, [], [getPos _assistant, getPos _assistant]] call BIS_fnc_findSafePos;
_weaponPos = [POSITIONAGL((leader _gunner)), 0, 15, 2, 0, 0.19, 0, [], [POSITIONAGL(_assistant), POSITIONAGL(_assistant)]] call BIS_fnc_findSafePos;
_weaponPos set [2, 0];
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ _assistant setUnitPosWeak "MIDDLE";
_assistant forceSpeed 24;
_assistant setVariable [QEGVAR(danger,forceMove), true];
_assistant setVariable [QGVAR(currentTask), "Pack Static Weapon", GVAR(debug_functions)];
_assistant setVariable [QGVAR(currentTarget), getPos _gunner, GVAR(debug_functions)];
_assistant setVariable [QGVAR(currentTarget), POSITIONAGL(_gunner), GVAR(debug_functions)];
_assistant doMove getPosATL (vehicle _gunner);

// do it
Expand Down
2 changes: 1 addition & 1 deletion addons/main/functions/UnitAction/fnc_doAssaultCQB.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ if (_buildingPos isEqualTo []) then {

// repeat
if (_buildingPos isNotEqualTo []) then {
[{_this call FUNC(doAssaultCQB)}, [_unit, getPos _unit], 7] call CBA_fnc_waitAndExecute;
[{_this call FUNC(doAssaultCQB)}, [_unit, POSITIONAGL(_unit)], 7] call CBA_fnc_waitAndExecute;
// or end
} else {
// remove force move!
Expand Down
2 changes: 1 addition & 1 deletion addons/main/functions/UnitAction/fnc_doUGL.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ _unit setVariable [QGVAR(currentTarget), objNull, GVAR(debug_functions)];
// dummy ~ seems necessary to get the AI to shoot up! -nkenny
private _flarePos = [_pos, (_unit getPos [80, getDir leader _unit]) vectorAdd [0, 0, 200]] select (_pos isEqualTo []);
private _dummy = "CBA_buildingPos" createVehicle _flarePos;
_dummy setPos _flarePos;
SETPOSITIONAGL(_dummy, _flarePos); // getPos syntax 3 returns positionAGL
_unit reveal _dummy;

// store - remove
Expand Down
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_findClosestTarget.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ _units = _units select {
};
if (_area isNotEqualTo []) then {
_area params ["_a", "_b", "_angle", "_isRectangle", ["_c", -1]];
_units = _units select { (getPos _x) inArea [_pos, _a, _b, _angle, _isRectangle, _c] };
_units = _units select { (POSITIONAGL(_x)) inArea [_pos, _a, _b, _angle, _isRectangle, _c] };
};
if (_units isEqualTo []) exitWith { objNull };

Expand Down
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_findCover.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ if (_dangerPos isNotEqualTo [0, 0, 1.8]) then {
_buildingPos = [_obj, 5] call CBA_fnc_buildingPositions;
if (_buildingPos isEqualTo []) then {
(boundingBox _obj) params ["_boundA", "_boundB"];
_pos = (getPos _obj) vectorAdd (selectRandom [_boundA, _boundB]);
_pos = (POSITIONAGL(_obj)) vectorAdd (selectRandom [_boundA, _boundB]);
// there is no building pos, so this is either vegetation or some building without building pos
// set height to 0 otherwise the pos will be right above the object
_pos set [2, 0.1];
Expand Down
2 changes: 1 addition & 1 deletion addons/main/functions/fnc_isNight.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ if (behaviour _unit isEqualTo "STEALTH"
) exitWith {false};

// night check
(getPos _unit) getEnvSoundController "night" isEqualTo 1
(POSITIONAGL(_unit)) getEnvSoundController "night" isEqualTo 1
3 changes: 3 additions & 0 deletions addons/main/script_macros.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@
_unit \
}

#define POSITIONAGL(object) ASLtoAGL (getPosASL object)
#define SETPOSITIONAGL(object,position) object setPosASL (AGLtoASL position)

// #define DISABLE_COMPILE_CACHE

#ifdef DISABLE_COMPILE_CACHE
Expand Down
2 changes: 1 addition & 1 deletion addons/wp/functions/Modules/fnc_moduleArtillery.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ switch (_mode) do {
}, {
params ["_side", "_salvo", "_spread", "_skipCheckround", "_pos"];
[_side, _pos, objNull, _salvo, _spread, _skipCheckround] call FUNC(taskArtillery);
}, [_side, _salvo, _spread, _skipCheckround, getPos _logic]] call CBA_fnc_waitUntilAndExecute;
}, [_side, _salvo, _spread, _skipCheckround, POSITIONAGL(_logic)]] call CBA_fnc_waitUntilAndExecute;
};
if (_isCuratorPlaced) then {
[LSTRING(Module_TaskArtillery_DisplayName),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ switch (_mode) do {
private _area = _logic getVariable ["objectarea", [10, 10, 0, false, -1]];
_area params ["_a", "_b", "_angle", "_isRectangle", ["_c", -1]];

_groups = allGroups select { (leader _x) inArea [(getPos _logic), _a, _b, _angle, _isRectangle, _c] };
_groups = allGroups select { (leader _x) inArea [(POSITIONAGL(_logic)), _a, _b, _angle, _isRectangle, _c] };
};
_groups = _groups arrayIntersect _groups;
{
Expand Down
6 changes: 3 additions & 3 deletions addons/wp/functions/Modules/fnc_moduleAssault.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ switch (_mode) do {
_deleteAfterStartup = true;
[objNull, format [LLSTRING(SettingIsOnlyForLocalGroups), LLSTRING(Module_TaskAssault_DeleteOnStartup_DisplayName)]] call BIS_fnc_showCuratorFeedbackMessage;
};
[QGVAR(taskAssault), [_group, [_logic, getPos _logic] select _deleteAfterStartup, _retreat, _threshold, _cycle, false], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskAssault), [_group, [_logic, POSITIONAGL(_logic)] select _deleteAfterStartup, _retreat, _threshold, _cycle, false], leader _group] call CBA_fnc_targetEvent;

if (_deleteAfterStartup) then {
deleteVehicle _logic;
Expand Down Expand Up @@ -77,7 +77,7 @@ switch (_mode) do {
_data params ["_targetIndex", "_retreat", "_threshold", "_cycle"];
private _target = _targets select _targetIndex;
if !(local _group) then {
_target = getPos _target;
_target = POSITIONAGL(_target);
};
[QGVAR(taskAssault), [_group, _target, _retreat, _threshold, _cycle, false], leader _group] call CBA_fnc_targetEvent;
if (_target isNotEqualTo _logic) then {
Expand All @@ -101,7 +101,7 @@ switch (_mode) do {
private _threshold = _logic getVariable [QGVAR(DistanceThreshold), TASK_ASSAULT_DISTANCETHRESHOLD];
private _cycle = _logic getVariable [QGVAR(CycleTime), TASK_ASSAULT_CYCLETIME];
{
[QGVAR(taskAssault), [_x, [_logic, getPos _logic] select _deleteAfterStartup, _retreat, _threshold, _cycle, false], leader _x] call CBA_fnc_targetEvent;
[QGVAR(taskAssault), [_x, [_logic, POSITIONAGL(_logic)] select _deleteAfterStartup, _retreat, _threshold, _cycle, false], leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
if (_deleteAfterStartup) then {
deleteVehicle _logic;
Expand Down
6 changes: 3 additions & 3 deletions addons/wp/functions/Modules/fnc_moduleCQB.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ switch (_mode) do {
_deleteAfterStartup = true;
[objNull, format [LLSTRING(SettingIsOnlyForLocalGroups), LLSTRING(Module_TaskCQB_DeleteOnStartUp_DisplayName)]] call BIS_fnc_showCuratorFeedbackMessage;
};
[QGVAR(taskCQB), [_group, [_logic, getPos _logic] select _deleteAfterStartup, _radius, _cycle, nil, false], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskCQB), [_group, [_logic, POSITIONAGL(_logic)] select _deleteAfterStartup, _radius, _cycle, nil, false], leader _group] call CBA_fnc_targetEvent;
if (_deleteAfterStartup) then {
deleteVehicle _logic;
};
Expand Down Expand Up @@ -73,7 +73,7 @@ switch (_mode) do {
_data params ["_targetIndex", "_radius", "_cycle"];
private _target = _targets select _targetIndex;
if !(local _group) then {
_target = getPos _target;
_target = POSITIONAGL(_target);
};
[QGVAR(taskCQB), [_group, _target, _radius, _cycle, nil, false], leader _group] call CBA_fnc_targetEvent;
if (_logic isNotEqualTo _target) then {
Expand All @@ -100,7 +100,7 @@ switch (_mode) do {
{
private _target = _logic;
if !(local _x) then {
_target = getPos _target;
_target = POSITIONAGL(_target);
};
[QGVAR(taskCQB), [_x, _target, _radius, _cycle, _area, false], leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
Expand Down
6 changes: 3 additions & 3 deletions addons/wp/functions/Modules/fnc_moduleCamp.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ switch (_mode) do {
_args params ["_groups", "_logic"];
_data params ["_groupIndex", "_range", "_exitWP", "_teleport", "_patrol"];
private _group = _groups select _groupIndex;
[QGVAR(taskCamp), [_group, getPos _logic, _range, nil, _teleport, _patrol, _exitWP - 1], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskCamp), [_group, POSITIONAGL(_logic), _range, nil, _teleport, _patrol, _exitWP - 1], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
Expand Down Expand Up @@ -69,7 +69,7 @@ switch (_mode) do {
params ["_data", "_args"];
_args params ["_group", "_logic", "_targets"];
_data params ["_targetIndex", "_range", "_exitWP", "_teleport", "_patrol"];
[QGVAR(taskCamp), [_group, getPos (_targets select _targetIndex), _range, nil, _teleport, _patrol, _exitWP - 1], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskCamp), [_group, POSITIONAGL((_targets select _targetIndex)), _range, nil, _teleport, _patrol, _exitWP - 1], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
Expand All @@ -90,7 +90,7 @@ switch (_mode) do {
private _patrol = _logic getVariable [QGVAR(Patrol), TASK_CAMP_PATROL];
private _exitWP = _logic getVariable [QGVAR(exitWP), TASK_CAMP_EXITWP];
{
[QGVAR(taskCamp), [_x, getPos _logic, _range, _area, _teleport, _patrol, _exitWP - 1], leader _x] call CBA_fnc_targetEvent;
[QGVAR(taskCamp), [_x, POSITIONAGL(_logic), _range, _area, _teleport, _patrol, _exitWP - 1], leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
deleteVehicle _logic;
};
Expand Down
4 changes: 2 additions & 2 deletions addons/wp/functions/Modules/fnc_moduleCreep.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ switch (_mode) do {
params ["_data", "_args"];
_args params ["_group", "_logic"];
_data params ["_range", "_cycle", "_movingCenter", "_playerOnly"];
private _args = [[_group, _range, _cycle, nil, getPos _logic, _playerOnly], [_group, _range, _cycle, nil, nil, _playerOnly]] select _movingCenter;
private _args = [[_group, _range, _cycle, nil, POSITIONAGL(_logic), _playerOnly], [_group, _range, _cycle, nil, nil, _playerOnly]] select _movingCenter;
[QGVAR(taskCreep), _args, leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
Expand All @@ -64,7 +64,7 @@ switch (_mode) do {
private _movingCenter = _logic getVariable [QGVAR(MovingCenter), TASK_CREEP_MOVINGCENTER];
private _playerOnly = _logic getVariable [QGVAR(PlayersOnly), TASK_CREEP_PLAYERSONLY];
{
private _args = [[_x, _range, _cycle, _area, getPos _logic, _playerOnly], [_x, _range, _cycle, _area, nil, _playerOnly]] select _movingCenter;
private _args = [[_x, _range, _cycle, _area, POSITIONAGL(_logic), _playerOnly], [_x, _range, _cycle, _area, nil, _playerOnly]] select _movingCenter;
[QGVAR(taskCreep), _args, leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
deleteVehicle _logic;
Expand Down
6 changes: 3 additions & 3 deletions addons/wp/functions/Modules/fnc_moduleGarrison.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ switch (_mode) do {
_args params ["_groups", "_logic"];
_data params ["_groupIndex", "_range", "_exitCondition", "_sortByHeight", "_teleport", "_patrol"];
private _group = _groups select _groupIndex;
[QGVAR(taskGarrison), [_group, getPos _logic, _range, nil, _teleport, _sortByHeight, _exitCondition - 2, _patrol], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskGarrison), [_group, POSITIONAGL(_logic), _range, nil, _teleport, _sortByHeight, _exitCondition - 2, _patrol], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
Expand Down Expand Up @@ -71,7 +71,7 @@ switch (_mode) do {
_args params ["_group", "_logic", "_targets"];
_data params ["_targetIndex", "_range", "_exitCondition", "_sortByHeight", "_teleport", "_patrol"];
private _target = _targets select _targetIndex;
[QGVAR(taskGarrison), [_group, getPos _target, _range, nil, _teleport, _sortByHeight, _exitCondition - 2, _patrol], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskGarrison), [_group, POSITIONAGL(_target), _range, nil, _teleport, _sortByHeight, _exitCondition - 2, _patrol], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
Expand All @@ -93,7 +93,7 @@ switch (_mode) do {
private _exitCondition = _logic getVariable [QGVAR(ExitConditions), TASK_GARRISON_EXITCONDITIONS];
private _patrol = _logic getVariable [QGVAR(Patrol), TASK_GARRISON_PATROL];
{
[QGVAR(taskGarrison), [_x, getPos _logic, _range, _area, _teleport, _sortByHeight, _exitCondition, _patrol], leader _x] call CBA_fnc_targetEvent;
[QGVAR(taskGarrison), [_x, POSITIONAGL(_logic), _range, _area, _teleport, _sortByHeight, _exitCondition, _patrol], leader _x] call CBA_fnc_targetEvent;
} forEach _groups;

deleteVehicle _logic;
Expand Down
4 changes: 2 additions & 2 deletions addons/wp/functions/Modules/fnc_moduleHunt.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ switch (_mode) do {
_data params ["_range", "_cycle", "_movingCenter", "_playerOnly", "_enableReinforcement", "_doUGL"];
private _args = [_group, _range, _cycle, nil, nil, _playerOnly, _enableReinforcement, _doUGL];
if !(_movingCenter) then {
_args set [4, getPos _logic];
_args set [4, POSITIONAGL(_logic)];
};
[QGVAR(taskHunt), _args, leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
Expand Down Expand Up @@ -75,7 +75,7 @@ switch (_mode) do {
{
private _args = [_x, _range, _cycle, _area, nil, _playerOnly, _enableReinforcement, _doUGL];
if !(_movingCenter) then {
_args set [4, getPos _logic];
_args set [4, POSITIONAGL(_logic)];
};
[QGVAR(taskHunt), _args, leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
Expand Down
6 changes: 3 additions & 3 deletions addons/wp/functions/Modules/fnc_modulePatrol.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ switch (_mode) do {
_args params ["_groups", "_logic"];
_data params ["_groupIndex", "_range", "_waypointCount", "_moveWaypoint", "_enableReinforcement"];
private _group = _groups select _groupIndex;
[QGVAR(taskPatrol), [_group, getPos _logic, _range, _waypointCount, [], _moveWaypoint, _enableReinforcement], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskPatrol), [_group, POSITIONAGL(_logic), _range, _waypointCount, [], _moveWaypoint, _enableReinforcement], leader _group] call CBA_fnc_targetEvent;
deleteVehicle _logic;
}, {
params ["", "_logic"];
Expand Down Expand Up @@ -69,7 +69,7 @@ switch (_mode) do {
_args params ["_targets", "_logic", "_group"];
_data params ["_targetIndex", "_range", "_waypointCount", "_moveWaypoint", "_enableReinforcement"];
private _target = _targets select _targetIndex;
[QGVAR(taskPatrol), [_group, getPos _target, _range, _waypointCount, [], _moveWaypoint, _enableReinforcement], leader _group] call CBA_fnc_targetEvent;
[QGVAR(taskPatrol), [_group, POSITIONAGL(_target), _range, _waypointCount, [], _moveWaypoint, _enableReinforcement], leader _group] call CBA_fnc_targetEvent;
if (_logic isNotEqualTo _target) then {
deleteVehicle _logic;
};
Expand All @@ -92,7 +92,7 @@ switch (_mode) do {
private _enableReinforcement = _logic getVariable [QGVAR(EnableReinforcement), TASK_PATROL_ENABLEREINFORCEMENT];
private _waypointCount =_logic getVariable [QGVAR(WaypointCount), TASK_PATROL_WAYPOINTCOUNT];
{
[QGVAR(taskPatrol), [_x, getPos _logic, _range, _waypointCount, _area, _moveWaypoint, _enableReinforcement], leader _x] call CBA_fnc_targetEvent;
[QGVAR(taskPatrol), [_x, POSITIONAGL(_logic), _range, _waypointCount, _area, _moveWaypoint, _enableReinforcement], leader _x] call CBA_fnc_targetEvent;
} forEach _groups;
deleteVehicle _logic;
};
Expand Down
Loading