Skip to content

Commit 8553d0a

Browse files
authored
Improvements to unstuck, switch weapon, etc
1 parent 193defa commit 8553d0a

File tree

3 files changed

+76
-32
lines changed

3 files changed

+76
-32
lines changed

addons/AIO_AIMENU/Menus.sqf

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,10 @@ AIO_flyAround_subMenu =
9090
AIO_switchweapon_subMenu =
9191
[
9292
["Switch Weapon",true],
93+
["Reload", [], "", -5, [["expression", "[(groupSelectedUnits player), 0] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"],
9394
["Rifle", [2], "", -5, [["expression", "[(groupSelectedUnits player), 1] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"],
94-
["Handgun", [3], "", -5, [["expression", "[(groupSelectedUnits player), 2] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"]
95+
["Handgun", [3], "", -5, [["expression", "[(groupSelectedUnits player), 2] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"],
96+
["Launcher", [4], "", -5, [["expression", "[(groupSelectedUnits player), 4] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"]
9597
];
9698

9799
AIO_unitTargeting_subMenu =

addons/AIO_AIMENU/switchWeapon.sqf

Lines changed: 57 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,24 +7,72 @@ _AIO_switchWeapon_fnc =
77
_unit disableAI "AUTOTARGET";
88
_unit doTarget objNull;
99
_unit doWatch objNull;
10-
if (_weapon == 1) then {
11-
_unit selectWeapon (primaryWeapon _unit);
12-
} else {
13-
_unit selectWeapon (handgunWeapon _unit);
10+
_stance = stance _unit;
11+
_ln_STAND_NON_Anim = "amovpercmstpsraswlnrdnon";
12+
_ln_PRONE_NON_Anim = "amovppnemstpsraswrfldnon";
13+
_ln_CROUCH_NON_Anim = "amovpknlmstpsraswlnrdnon";
14+
_ln_UNDEFINED_NON_Anim = "";
15+
_rfl_STAND_NON_Anim = "amovpercmstpsraswrfldnon";
16+
_rfl_PRONE_NON_Anim = "amovppnemstpsraswrfldnon";
17+
_rfl_CROUCH_NON_Anim = "amovpknlmstpsraswrfldnon";
18+
_rfl_UNDEFINED_NON_Anim = "";
19+
_pst_STAND_NON_Anim = "amovpercmstpsraswpstdnon";
20+
_pst_PRONE_NON_Anim = "amovppnemstpsraswpstdnon";
21+
_pst_CROUCH_NON_Anim = "amovpknlmstpsraswpstdnon";
22+
_pst_UNDEFINED_NON_Anim = "";
23+
switch (_weapon) do {
24+
case 1:
25+
{
26+
if !((primaryWeapon _unit) isKindOf ["Rifle", configFile >> "CfgWeapons"]) exitWith {};
27+
_unit selectWeapon (primaryWeapon _unit);
28+
_move = call compile format ["_rfl_%1_NON_Anim", _stance];
29+
_unit playMoveNow _move;
30+
};
31+
case 2:
32+
{
33+
if !((handgunWeapon _unit) isKindOf ["Pistol", configFile >> "CfgWeapons"]) exitWith {};
34+
_unit selectWeapon (handgunWeapon _unit);
35+
_move = call compile format ["_pst_%1_NON_Anim", _stance];
36+
_unit playMoveNow _move;
37+
};
38+
case 4:
39+
{
40+
if !((secondaryWeapon _unit) isKindOf ["Launcher", configFile >> "CfgWeapons"]) exitWith {};
41+
_unit selectWeapon (secondaryWeapon _unit);
42+
_move = call compile format ["_ln_%1_NON_Anim", _stance];
43+
_unit playMoveNow _move;
44+
};
45+
case 0:
46+
{
47+
reload _unit;
48+
};
1449
};
1550
sleep 0.5;
1651
_unit enableAI "TARGET";
1752
_unit enableAI "AUTOTARGET";
1853
};
1954

20-
if (_weapon == 1 OR _weapon == 2) then {
55+
if (_weapon == 1 OR _weapon == 2 OR _weapon == 4 OR _weapon == 0) then {
2156
{
2257
[_x, _weapon] spawn _AIO_switchWeapon_fnc;
2358
} forEach _selectedUnits;
24-
if (_weapon == 1) then {player groupChat (selectRandom ["Switch to your main weapon.", "Switch to your rifle.", "Switch to rifle."])}
25-
else {player groupChat (selectRandom ["Switch to your secondary weapon.", "Switch to your handgun.", "Switch to handgun."])};
26-
};
27-
if (_weapon == 3) then {
59+
private _commsArray = [];
60+
switch (_weapon) do {
61+
case 1:
62+
{
63+
_commsArray = ["Switch to your main weapon.", "Switch to your rifle.", "Switch to rifle."];
64+
};
65+
case 2:
66+
{
67+
_commsArray = ["Switch to your side weapon.", "Switch to your handgun.", "Switch to handgun."];
68+
};
69+
case 4:
70+
{
71+
_commsArray = ["Switch to your secondary weapon.", "Switch to your launcher.", "Switch to launcher."];
72+
};
73+
};
74+
player groupChat (selectRandom _commsArray);
75+
} else {
2876
_LauncherRemoveFnc =
2977
{
3078
params ["_unit"];

addons/AIO_AIMENU/unstuckUnit.sqf

Lines changed: 16 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,10 @@ _selectedVehicles = [];
77
AIO_unstuckPlayer =
88
{
99
private ["_position", "_playerGrp", "_leader", "_tempGrp"];
10-
_position = (getPos player) findEmptyPosition[ 0.5 , 10 , typeOf player ];
10+
_position = (getPosATL player) findEmptyPosition[ 0.1 , 10 , typeOf player ];
1111
player switchMove "";
1212
[player, [_position select 0, _position select 1], 0.1] call AIO_fnc_setPosAGLS;
13-
player setPos _position;
13+
player setVelocity [0,0,0];
1414
_playerGrp = group player;
1515
_leader = leader _playerGrp;
1616
_tempGrp = createGroup (side player);
@@ -23,34 +23,28 @@ AIO_unstuckPlayer =
2323
AIO_unstuckUnit =
2424
{
2525
private ["_unit","_position"];
26-
26+
_pos = if (surfaceIsWater (getPosASLVisual _unit) && (_unit distance2D player) <= 50) then {getPosATL player} else {getPosATL _unit};
2727
_unit = _this select 0;
28-
29-
if(player distance _unit < 50) then
30-
{
31-
_position = (getPos player) findEmptyPosition[ 5 , 50 , typeOf _unit ];
32-
33-
_unit doWatch objNull;
34-
_unit selectWeapon primaryWeapon _unit;
35-
_unit switchMove "";
36-
[_unit, [_position select 0, _position select 1], 0.1] call AIO_fnc_setPosAGLS;
37-
}
38-
else
39-
{
40-
hint "You are too far away from unit. Move closer than 50m to unstuck the unit.";
41-
sleep 2;
42-
};
28+
_position = _pos findEmptyPosition[ 0.1 , 20 , typeOf _unit];
29+
_unit doWatch objNull;
30+
_unit selectWeapon (primaryWeapon _unit);
31+
_unit switchMove "";
32+
[_unit, [_position select 0, _position select 1], 0.1] call AIO_fnc_setPosAGLS;
33+
_unit setVelocity [0,0,0];
4334
};
4435

4536
AIO_unstuckVehicle =
4637
{
47-
private ["_vehicle","_position"];
38+
private ["_vehicle","_position", "_dir", "_height"];
4839

4940
_vehicle = _this select 0;
50-
_height = if (_vehicle isKindOf "Air") then {((getPos _vehicle) select 2)+ 0.1} else {0.1};
41+
_height = if (_vehicle isKindOf "Air") then {((getPosATL _vehicle) select 2)+ 0.1} else {0.1};
5142
if (_height > 20) exitWith {hint "Can't unstuck vehicles in flight."};
52-
_position = (getPos player) findEmptyPosition[ 5 , 50 , typeOf _vehicle ];
43+
_dir = vectorDir _vehicle;
44+
_vehicle setVectorDirAndUp [_dir, [0,0,1]];
45+
_position = (getPosATL _vehicle) findEmptyPosition[ 0.1 , 20 , typeOf _vehicle ];
5346
[_vehicle, [_position select 0, _position select 1], _height] call AIO_fnc_setPosAGLS;
47+
_vehicle setVelocity [0,0,0];
5448
};
5549

5650
{
@@ -84,5 +78,5 @@ if(count _selectedUnits == 0) then
8478

8579
{
8680
[_x] spawn AIO_unstuckVehicle;
87-
sleep 2;
81+
sleep 1;
8882
} foreach _selectedVehicles;

0 commit comments

Comments
 (0)