Skip to content

Commit

Permalink
Improvements to unstuck, switch weapon, etc
Browse files Browse the repository at this point in the history
  • Loading branch information
Leopard20 authored Aug 19, 2018
1 parent 193defa commit 8553d0a
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 32 deletions.
4 changes: 3 additions & 1 deletion addons/AIO_AIMENU/Menus.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ AIO_flyAround_subMenu =
AIO_switchweapon_subMenu =
[
["Switch Weapon",true],
["Reload", [], "", -5, [["expression", "[(groupSelectedUnits player), 0] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"],
["Rifle", [2], "", -5, [["expression", "[(groupSelectedUnits player), 1] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"],
["Handgun", [3], "", -5, [["expression", "[(groupSelectedUnits player), 2] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"]
["Handgun", [3], "", -5, [["expression", "[(groupSelectedUnits player), 2] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"],
["Launcher", [4], "", -5, [["expression", "[(groupSelectedUnits player), 4] execVM ""AIO_AIMENU\switchweapon.sqf"" "]], "1", "1"]
];

AIO_unitTargeting_subMenu =
Expand Down
66 changes: 57 additions & 9 deletions addons/AIO_AIMENU/switchWeapon.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,72 @@ _AIO_switchWeapon_fnc =
_unit disableAI "AUTOTARGET";
_unit doTarget objNull;
_unit doWatch objNull;
if (_weapon == 1) then {
_unit selectWeapon (primaryWeapon _unit);
} else {
_unit selectWeapon (handgunWeapon _unit);
_stance = stance _unit;
_ln_STAND_NON_Anim = "amovpercmstpsraswlnrdnon";
_ln_PRONE_NON_Anim = "amovppnemstpsraswrfldnon";
_ln_CROUCH_NON_Anim = "amovpknlmstpsraswlnrdnon";
_ln_UNDEFINED_NON_Anim = "";
_rfl_STAND_NON_Anim = "amovpercmstpsraswrfldnon";
_rfl_PRONE_NON_Anim = "amovppnemstpsraswrfldnon";
_rfl_CROUCH_NON_Anim = "amovpknlmstpsraswrfldnon";
_rfl_UNDEFINED_NON_Anim = "";
_pst_STAND_NON_Anim = "amovpercmstpsraswpstdnon";
_pst_PRONE_NON_Anim = "amovppnemstpsraswpstdnon";
_pst_CROUCH_NON_Anim = "amovpknlmstpsraswpstdnon";
_pst_UNDEFINED_NON_Anim = "";
switch (_weapon) do {
case 1:
{
if !((primaryWeapon _unit) isKindOf ["Rifle", configFile >> "CfgWeapons"]) exitWith {};
_unit selectWeapon (primaryWeapon _unit);
_move = call compile format ["_rfl_%1_NON_Anim", _stance];
_unit playMoveNow _move;
};
case 2:
{
if !((handgunWeapon _unit) isKindOf ["Pistol", configFile >> "CfgWeapons"]) exitWith {};
_unit selectWeapon (handgunWeapon _unit);
_move = call compile format ["_pst_%1_NON_Anim", _stance];
_unit playMoveNow _move;
};
case 4:
{
if !((secondaryWeapon _unit) isKindOf ["Launcher", configFile >> "CfgWeapons"]) exitWith {};
_unit selectWeapon (secondaryWeapon _unit);
_move = call compile format ["_ln_%1_NON_Anim", _stance];
_unit playMoveNow _move;
};
case 0:
{
reload _unit;
};
};
sleep 0.5;
_unit enableAI "TARGET";
_unit enableAI "AUTOTARGET";
};

if (_weapon == 1 OR _weapon == 2) then {
if (_weapon == 1 OR _weapon == 2 OR _weapon == 4 OR _weapon == 0) then {
{
[_x, _weapon] spawn _AIO_switchWeapon_fnc;
} forEach _selectedUnits;
if (_weapon == 1) then {player groupChat (selectRandom ["Switch to your main weapon.", "Switch to your rifle.", "Switch to rifle."])}
else {player groupChat (selectRandom ["Switch to your secondary weapon.", "Switch to your handgun.", "Switch to handgun."])};
};
if (_weapon == 3) then {
private _commsArray = [];
switch (_weapon) do {
case 1:
{
_commsArray = ["Switch to your main weapon.", "Switch to your rifle.", "Switch to rifle."];
};
case 2:
{
_commsArray = ["Switch to your side weapon.", "Switch to your handgun.", "Switch to handgun."];
};
case 4:
{
_commsArray = ["Switch to your secondary weapon.", "Switch to your launcher.", "Switch to launcher."];
};
};
player groupChat (selectRandom _commsArray);
} else {
_LauncherRemoveFnc =
{
params ["_unit"];
Expand Down
38 changes: 16 additions & 22 deletions addons/AIO_AIMENU/unstuckUnit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@ _selectedVehicles = [];
AIO_unstuckPlayer =
{
private ["_position", "_playerGrp", "_leader", "_tempGrp"];
_position = (getPos player) findEmptyPosition[ 0.5 , 10 , typeOf player ];
_position = (getPosATL player) findEmptyPosition[ 0.1 , 10 , typeOf player ];
player switchMove "";
[player, [_position select 0, _position select 1], 0.1] call AIO_fnc_setPosAGLS;
player setPos _position;
player setVelocity [0,0,0];
_playerGrp = group player;
_leader = leader _playerGrp;
_tempGrp = createGroup (side player);
Expand All @@ -23,34 +23,28 @@ AIO_unstuckPlayer =
AIO_unstuckUnit =
{
private ["_unit","_position"];

_pos = if (surfaceIsWater (getPosASLVisual _unit) && (_unit distance2D player) <= 50) then {getPosATL player} else {getPosATL _unit};
_unit = _this select 0;

if(player distance _unit < 50) then
{
_position = (getPos player) findEmptyPosition[ 5 , 50 , typeOf _unit ];

_unit doWatch objNull;
_unit selectWeapon primaryWeapon _unit;
_unit switchMove "";
[_unit, [_position select 0, _position select 1], 0.1] call AIO_fnc_setPosAGLS;
}
else
{
hint "You are too far away from unit. Move closer than 50m to unstuck the unit.";
sleep 2;
};
_position = _pos findEmptyPosition[ 0.1 , 20 , typeOf _unit];
_unit doWatch objNull;
_unit selectWeapon (primaryWeapon _unit);
_unit switchMove "";
[_unit, [_position select 0, _position select 1], 0.1] call AIO_fnc_setPosAGLS;
_unit setVelocity [0,0,0];
};

AIO_unstuckVehicle =
{
private ["_vehicle","_position"];
private ["_vehicle","_position", "_dir", "_height"];

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

{
Expand Down Expand Up @@ -84,5 +78,5 @@ if(count _selectedUnits == 0) then

{
[_x] spawn AIO_unstuckVehicle;
sleep 2;
sleep 1;
} foreach _selectedVehicles;

0 comments on commit 8553d0a

Please sign in to comment.