Skip to content

Commit

Permalink
Update to v1.3.0
Browse files Browse the repository at this point in the history
Bug fixes and improvements
  • Loading branch information
Leopard20 authored Sep 2, 2018
1 parent 8553d0a commit f056ce3
Show file tree
Hide file tree
Showing 24 changed files with 167 additions and 142 deletions.
4 changes: 2 additions & 2 deletions addons/AIO_AIMENU/Functions/Assemble.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ AIO_staticAssemble_Fnc = {
_unit1 doMove _pos;
_unit2 doMove _pos;
sleep 1;
while {!(unitReady _unit1) && !(unitReady _unit2) && (alive _unit1) && (alive _unit2)} do {sleep 1};
waitUntil {sleep 1; !(!(unitReady _unit1) && !(unitReady _unit2) && (alive _unit1) && (alive _unit2))};
if (_unit1 distance _pos > 10 OR _unit2 distance _pos > 10) exitWith {_units doMove (getpos _unit1)};
_base = unitBackpack _unit2;
_unit2 action ["PutBag"];
Expand All @@ -46,7 +46,7 @@ AIO_staticAssemble_Fnc = {
_unit1 = _units select 0;
if (vehicle _unit1 != _unit1) exitWith {};
_unit1 doMove _pos;
while {!(unitReady _unit1) && (alive _unit1)} do {sleep 1;};
waitUntil {sleep 1; !(!(unitReady _unit1) && (alive _unit1))};
if (_unit1 distance _pos > 10) exitWith {_units doMove (getpos _unit1)};
_array = nearestObjects [_unit1, ["WeaponHolder"], 10];
_base = firstBackpack (_array select 0);
Expand Down
5 changes: 3 additions & 2 deletions addons/AIO_AIMENU/Functions/CopyMyStance.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -125,14 +125,15 @@ AIO_copy_my_stance_fnc =
};
} forEach AIO_copyStanceUnits;
};
while {AIO_copy_my_stance} do {
waitUntil {
sleep 1;
_pos = stance player;
_posIndex = _stanceArray find _pos;
_pos = _posArray select _posIndex;
{
_x setUnitPos _pos;
} forEach AIO_copyStanceUnits;
sleep 1;
!(AIO_copy_my_stance)
};
player groupChat "Stop copying my stance.";
{
Expand Down
47 changes: 23 additions & 24 deletions addons/AIO_AIMENU/Functions/General.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -28,51 +28,50 @@ AIO_getUnitNumber =
//Returns a list of nearby weapons according to their class (for taking weapons)
AIO_getName_weapons =
{
private ["_allItem","_ItemCnt","_dist","_className", "_displayName", "_dispNm", "_typeA", "_type", "_emptySlot", "_cntW"];
private ["_allItem","_ItemCnt","_dist","_className", "_displayName", "_dispNm", "_typeA", "_type", "_cntW"];
_allItem = _this select 0;
_ItemCnt = _this select 1;
_typeA = _this select 2;
_type = ["Rifle", "Pistol", "Launcher"] select _typeA;
_dispNm = [[""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""], [""]];
for "_i" from 0 to 12 do
_dispNm = [];
for "_i" from 0 to _ItemCnt-1 do
{
if (_ItemCnt > _i) then {
_dist = floor (player distance (_allItem select _i));
_cntW = count (weaponsItemsCargo (_allItem select _i)) - 1;
for "_k" from 0 to 12 do {
if ((_dispNm select _k) select 0 == "") exitWith {_emptySlot = _k};
};
for "_j" from 0 to _cntW do {
if (isNil "_emptySlot") exitWith {};
_className = ((weaponsItemsCargo (_allItem select _i)) select _j) select 0;
if (_className isKindOf [_type, configFile >> "CfgWeapons"] && _className != "") then {
_displayName = Format ["%1, %2 m",(getText (configFile >> "CfgWeapons" >>_className >> "displayName")), _dist];
_dispNm set [_emptySlot + _j, [_displayName, _allItem select _i, _className]];
};
_dist = floor (player distance (_allItem select _i));
_cntW = count (weaponsItemsCargo (_allItem select _i)) - 1;
for "_j" from 0 to _cntW do {
_className = ((weaponsItemsCargo (_allItem select _i)) select _j) select 0;
if (_className isKindOf [_type, configFile >> "CfgWeapons"] && _className != "") then {
_displayName = Format ["%1, %2 m",(getText (configFile >> "CfgWeapons" >>_className >> "displayName")), _dist];
_dispNm pushBack [_displayName, _allItem select _i, _className];
};
};
_emptySlot = nil;
};
_dispNm
for "_i" from 0 to 11 do
{
_dispNm pushBack [""]
};
_dispNm
};

//Returns a list of nearby vehicles according to their class (for mount menu, disassemble menus and slingloading)
AIO_getName_vehicles =
{
private ["_allItem","_ItemCnt","_dist","_className", "_dispNm", "_displayName"];
_dispNm = ["", "", "", "", "", "", "", "", ""];
_dispNm = [];
_allItem = _this select 0;
_ItemCnt = _this select 1;
for "_i" from 0 to 11 do
for "_i" from 0 to _ItemCnt-1 do
{
if (_ItemCnt > _i) then {
_dist = floor (player distance (_allItem select _i));
_className = typeOf (vehicle (_allItem select _i));
_displayName = Format ["%1, %2 m",(getText (configFile >> "CfgVehicles" >>_className >> "displayName")), _dist];
_dispNm set [_i, _displayName];
};
_dispNm pushBack _displayName;
};
for "_i" from 0 to 11 do
{
_dispNm pushBack ""
};
_dispNm
_dispNm
};

//Used for updating AIO_DriverSettings_subMenu when one of its settings are changed
Expand Down
3 changes: 2 additions & 1 deletion addons/AIO_AIMENU/Functions/HighCommand.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,7 @@ AIO_fnc_spawnHCGroups =
{
private ["_groups", "_cntGrps", "_menuNum", "_cntMenus", "_text"];
_groups = allGroups select {(side _x) == (side player)};
_groups = [_groups,[],{player distance (leader _x)},"ASCEND"] call BIS_fnc_sortBy;
_cntGrps = count _groups;
_cntMenus = floor (_cntGrps/11) + 1;
_menuNum = 1;
Expand All @@ -483,7 +484,7 @@ AIO_fnc_spawnHCGroups =
{
private "_name";
_unit = _groups select _i;
_dist = floor (player distance2D (leader _unit));
_dist = floor (player distance (leader _unit));
_mod = (_i + 1) mod 11;
if (_mod == 0) then {_mod = 11};
_text = format ["%1 - %2 m", _unit, _dist];
Expand Down
19 changes: 9 additions & 10 deletions addons/AIO_AIMENU/Functions/Rearm.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ AIO_rearmList_fnc =
_rearmTargets = [];
{
private _unit = _x;
_allWeapons = nearestObjects [_unit, ["ReammoBox_F", "Car", "Tank", "Helicopter", "Plane"], 100];
_allWeapons = nearestObjects [_unit, ["ReammoBox_F", "Car", "Tank", "Helicopter", "Plane", "WeaponHolderSimulated","LandVehicle","CAManbase"], 100];
for "_i" from 0 to ((count _allWeapons) -1) do {
_cond = (count (weaponsItemsCargo (_allWeapons select _i)) > 0 OR count ((getMagazineCargo (_allWeapons select _i)) select 0) > 0);
if (!((_allWeapons select _i) in _rearmTargets) && _cond) then {
Expand Down Expand Up @@ -49,18 +49,16 @@ AIO_rearmList_fnc =
AIO_getName_weapons_fnc =
{
private _unit = (_this select 0) select 0;
AIO_Rifle_subMenu = nil;
AIO_Hgun_subMenu = nil;
AIO_launcher_subMenu = nil;
private _allWeapons = nearestObjects [_unit, ["ReammoBox", "ReammoBox_F"], 200];
AIO_menuLoadingDone = false;
private _allWeapons = nearestObjects [_unit, ["ReammoBox", "ReammoBox_F", "WeaponHolderSimulated","LandVehicle","CAManbase"], 200];
_allWeapons = [_allWeapons,[],{player distance _x},"ASCEND"] call BIS_fnc_sortBy;
//_allWeapons = _allWeapons apply {((weaponsItemsCargo _x) select 0) select 0};
AIO_weaponType_subMenu =
[
["Take Weapon",true],
["Rifle", [2], "#USER:AIO_Rifle_subMenu", -5, [["expression", ""]], "1", "1"],
["Handgun", [3], "#USER:AIO_Hgun_subMenu", -5, [["expression", ""]], "1", "1"],
["Launcher", [4], "#USER:AIO_launcher_subMenu", -5, [["expression", ""]], "1", "1"]
["Take Weapon",true],
["Rifle", [2], "#USER:AIO_Rifle_subMenu", -5, [["expression", ""]], "1", "1"],
["Handgun", [3], "#USER:AIO_Hgun_subMenu", -5, [["expression", ""]], "1", "1"],
["Launcher", [4], "#USER:AIO_launcher_subMenu", -5, [["expression", ""]], "1", "1"]
];
AIO_nearRifle = [_allWeapons, count _allWeapons, 0] call AIO_getName_weapons;
AIO_Rifle_subMenu =
Expand Down Expand Up @@ -98,9 +96,10 @@ AIO_getName_weapons_fnc =
[(AIO_selectedunits select 0), AIO_nearLaunch select %1] execVM ""AIO_AIMENU\takeWeapon.sqf"" ']], '1', '1']", _i];
call compile _text;
};
if (_i == 12) then {AIO_menuLoadingDone = true};
};
[] spawn {
waitUntil {!(isNil "AIO_Rifle_subMenu") && !(isNil "AIO_Hgun_subMenu") && !(isNil "AIO_launcher_subMenu")};
waitUntil {AIO_menuLoadingDone};
{
player groupSelectUnit [_x, true];
} forEach AIO_selectedunits;
Expand Down
2 changes: 1 addition & 1 deletion addons/AIO_AIMENU/Functions/Retreat.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ AIO_retreatMapCMD =

{
_x spawn {
while {!(moveToCompleted _this) && (alive _this) && (currentCommand _this == "STOP")} do {sleep 1};
waitUntil {sleep 1; !(!(moveToCompleted _this) && (alive _this) && (currentCommand _this == "STOP"))};
[[_this], 0] execVM "AIO_AIMENU\sprintModeFull.sqf";
_this enableAI "AUTOCOMBAT";
_this enableAI "AUTOTARGET";
Expand Down
12 changes: 12 additions & 0 deletions addons/AIO_AIMENU/Functions/Taxi.sqf
Original file line number Diff line number Diff line change
@@ -1,3 +1,15 @@
/*
_cfg = configfile >> "CfgWorlds" >> worldName;
_allAirPorts = [[(getArray (_cfg >> "ilsDirection")), (getArray (_cfg >> "ilsPosition")), (getArray (_cfg >> "ilsTaxiIn")), (getArray (_cfg >> "ilsTaxiOff"))]];
_arr = "true" configclasses (_cfg >> "SecondaryAirports");
{
_cfg = _x;
_allAirPorts pushBack [(getArray (_cfg >> "ilsDirection")), (getArray (_cfg >> "ilsPosition")), (getArray (_cfg >> "ilsTaxiIn")), (getArray (_cfg >> "ilsTaxiOff"))]
} forEach _arr;
*/

AIO_Plane_Taxi_move =
{
params ["_veh", "_pointA", "_pointB", "_centPos", "_radius"];
Expand Down
2 changes: 1 addition & 1 deletion addons/AIO_AIMENU/XEH_preInit.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ Finally, to bind your function to a key, call CBA_fnc_addKeybind:
["AIO_DriverFixWatchDir", "LIST", "Player Watch Direction During Adv. Driving Ctrl", "All-In-One Command Menu" ,[[false, true], ["Watch Ahead", "Fixed"], 0], 1] call CBA_Settings_fnc_init;
["AIO_useExactCopyStance", "LIST", "Copy My Stance Mode", "All-In-One Command Menu" ,[[true, false], ["Exact Stance", "Standard Stance"], 0], 1] call CBA_Settings_fnc_init;

["All-In-One Command Menu","AIO_AIMenu_initKey", "Show Menu", {_this call AIO_keyspressed}, "", [21, [false, false, false]], false] call CBA_fnc_addKeybind;
["All-In-One Command Menu","AIO_AIMENU_initKey", "Show Menu", {_this call AIO_keyspressed}, "", [21, [false, false, false]], false] call CBA_fnc_addKeybind;
["All-In-One Command Menu","AIO_follow_stance_key", "Toggle Copy My Stance", {if !(AIO_copy_my_stance) then {[(groupSelectedUnits player)] spawn AIO_copy_my_stance_fnc} else {AIO_copy_my_stance = false; {_x setUnitPos "AUTO"} forEach ((units group player) - [player]);}}, "", [DIK_C, [true, true, false]], false] call CBA_fnc_addKeybind;
["All-In-One Command Menu","AIO_driver_move_forward_key", "Driver - Command Forward", {if (AIO_driver_mode_enabled && !AIO_Advanced_Ctrl) then {[0] call AIO_driver_call_fnc}}, {}, [DIK_W, [false, false, false]], false] call CBA_fnc_addKeybind;
["All-In-One Command Menu","AIO_driver_move_left_key", "Driver - Command Left", {if (AIO_driver_mode_enabled && !AIO_Advanced_Ctrl) then {[2] call AIO_driver_call_fnc}}, {}, [DIK_A, [false, false, false]], false] call CBA_fnc_addKeybind;
Expand Down
12 changes: 6 additions & 6 deletions addons/AIO_AIMENU/allRoundDefense.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ AIO_360_defense_fnc =
_unit setUnitPos "MIDDLE";
sleep 0.2;
_unit moveTo _pos;
while {alive _unit && !(moveToCompleted _unit)} do {sleep 1};
waitUntil {sleep 1; (!alive _unit || moveToCompleted _unit || currentCommand _unit != "STOP")};
_unit doWatch _watchPos;
while {currentCommand _unit == "STOP" && alive _unit} do {sleep 2};
waitUntil {sleep 1; (!alive _unit || currentCommand _unit != "STOP")};
_unit doWatch objNull;
_unit setUnitPos "AUTO";
};
Expand Down Expand Up @@ -68,10 +68,10 @@ AIO_fortify_pos_fnc =
_unit1 doMove _pos;
[_unit1] spawn {
params ["_unit1"];
if (_unit1 == effectiveCommander (vehicle _unit1)) then{
while {!unitReady _unit1 && alive _unit1} do {sleep 1};
if (_unit1 == effectiveCommander (vehicle _unit1)) then {
waitUntil {sleep 1; (!alive _unit1 || unitReady _unit1)};
} else {
while {currentCommand _unit1 == "MOVE" && alive _unit1} do {sleep 1};
waitUntil {sleep 1; (!alive _unit1 || currentCommand _unit1 != "MOVE")};
};
doGetOut (driver (vehicle _unit1));
};
Expand All @@ -97,7 +97,7 @@ AIO_fortify_pos_fnc =
if (unitPos _unit == "AUTO") then {_unit setUnitPos "MIDDLE"};
sleep 0.2;
_unit moveTo _pos;
while {alive _unit && !moveToCompleted _unit} do {sleep 1};
waitUntil {sleep 1; !(alive _unit && !moveToCompleted _unit)};
_unit doWatch _watchPos;
_unit doMove (getPos _unit);
};
Expand Down
6 changes: 3 additions & 3 deletions addons/AIO_AIMENU/config.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
class CfgPatches
{
class AIO_AIMenu
class AIO_AIMENU
{
author="Leopard20";
name="All-In-One Command Menu";
Expand Down Expand Up @@ -32,14 +32,14 @@ class CfgPatches

class Extended_PreInit_EventHandlers
{
class AIO_AIMenu_Init
class AIO_AIMENU_Init
{
clientInit="call compile preProcessFileLineNumbers '\AIO_AIMENU\XEH_preInit.sqf'";
};
};
class Extended_PostInit_EventHandlers
{
class AIO_AIMenu
class AIO_AIMENU
{
clientInit="call compile preprocessFileLineNumbers '\AIO_AIMENU\init.sqf'";
};
Expand Down
7 changes: 4 additions & 3 deletions addons/AIO_AIMENU/disassemble.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,14 @@ if (count _units == 2) then {
_size = sizeOf (typeOf _static);
_distance = _size/3 + 5;
_posStatic = getPos _static;
while {!(unitReady _unit1) && (alive _unit1) && (alive _static)} do {
waitUntil {
sleep 1;
if (unitReady _unit2 OR (!alive _unit2)) exitWith {
_tempU = _unit2;
_unit2 = _unit1;
_unit1 = _tempU;
};
sleep 1;
!(!(unitReady _unit1) && (alive _unit1) && (alive _static))
};
if (_unit1 distance _static > _distance) exitWith {_units doMove (getpos _unit1)};
_pos1 = getPos _unit1;
Expand Down Expand Up @@ -68,7 +69,7 @@ if (count _units == 2) then {
_bb = [_bb,[],{_x distance _unit1},"ASCEND"] call BIS_fnc_sortBy;
_posStatic = (_bb select 0);
_unit1 doMove _posStatic;
while {!(unitReady _unit1) && (alive _unit1) && (alive _static)} do {sleep 1;};
waitUntil {sleep 1; !(!(unitReady _unit1) && (alive _unit1) && (alive _static))}
if (_unit1 distance _static > 10) exitWith {_units doMove (getpos _unit1)};
_unit1 action ["Disassemble", _static];
};
61 changes: 31 additions & 30 deletions addons/AIO_AIMENU/dropCargo.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,38 @@ AIO_Heli_dropCargo =

_resetDirFnc =
{
params ["_unit", "_dropPos"];
private ["_newDir", "_dir", "_right", "_adjust", "_vd" , "_vehPos" , "_dropPos", "_cond", "_multi"];
_veh = vehicle _unit;
_vehPos = (getPos _veh);
_vehPos set [2, 0];
_vd = _dropPos vectorDiff _vehPos;
_newDir = (_vd select 0) atan2 (_vd select 1); //_dir range from -180 to +180
if (_newDir < 0) then {_newDir = 360 + _newDir}; //_dir range from 0 to 360
_relDir = _veh getRelDir _dropPos;
_dir = getDir _veh;
_right = true;
_cond = false;
if ((_newDir - _dir) > 180 && (_newDir - _dir) < 360) then {_cond = true};
params ["_unit", "_carPos"];
private ["_newDir", "_dir", "_right", "_vd" , "_vehPos" , "_carPos", "_txt"];
_unit setVariable ["AIO_resetDir_done", false];
_veh = vehicle _unit;
_vehPos = (getPos _veh);
_vehPos set [2, 0];
//_carPos = (getPos _cargo);
_carPos set [2, 0];
_vd = _carPos vectorDiff _vehPos;
_newDir = (_vd select 0) atan2 (_vd select 1); //_dir range from -180 to +180
if (_newDir < 0) then {_newDir = 360 + _newDir}; //_dir range from 0 to 360
_relDir = _veh getRelDir _carPos;
_dir = getDir _veh;
_right = 1;

if (_relDir > 180) then {
_right = false;
};
_adjust = true;
while {_adjust} do {
_multi = accTime;
if (_multi == 1) then {_multi = 1.6};
if (!(alive _veh) OR !(alive _unit) OR ((getPosATL _veh) select 2) < 8 OR (_newDir == _dir)) exitWith {};
if (_right) then {
_veh setDir ((getDir _veh) + 0.4*_multi/1.6);
} else {
_veh setDir ((getDir _veh) - 0.4*_multi/1.6);
};
sleep 0.01;
if ((round (getDir _veh)) == (round _newDir)) then {_adjust = false};
};
if (_relDir > 180) then {_right = -1};
if (_newDir == _dir) exitWith {_unit setVariable ["AIO_resetDir_done", true]};

_txt = format ["AIO_heli%1_rotation", ([_unit] call AIO_getUnitNumber)];
[_txt, "onEachFrame", {
params ["_unit", "_veh", "_newDir", "_right", "_txt"];
if (abs((round (getDir _veh)) - (round _newDir)) < 1 || !(alive _veh) OR !(alive _unit) OR ((getPosATL _veh) select 2) < 8) exitWith {
_unit setVariable ["AIO_resetDir_done", true];
if ((alive _veh) && (alive _unit) && ((getPosATL _veh) select 2) > 8) then {_veh setDir _newDir};
[_txt, "onEachFrame"] call BIS_fnc_removeStackedEventHandler;
};
_multi = accTime;
if (_multi == 1) then {_multi = 1.6};
_veh setDir ((getDir _veh) + _right*0.4*_multi/1.6);
}, [_unit, _veh, _newDir, _right, _txt]] call BIS_fnc_addStackedEventHandler;
};

_diff = (_dropPos vectorDiff _vehPos);
_diff set [2, 0];
_normal = vectorNormalized _diff;
Expand Down Expand Up @@ -83,7 +84,7 @@ AIO_Heli_dropCargo =
_currentDir = (vectorDirVisual _veh) select 2;
};
_script_handle = [_unit, _dropPos] spawn _resetDirFnc;
waitUntil {(scriptDone _script_handle) OR !(alive _veh) OR !(alive _unit) OR (vehicle _unit == _unit) OR (_veh getVariable ["AIO_Heli_SlingLoadingAborted", 0]) == 1};
waitUntil {(_unit getVariable ["AIO_resetDir_done", false]) OR !(alive _veh) OR !(alive _unit) OR (vehicle _unit == _unit) OR (_veh getVariable ["AIO_Heli_SlingLoadingAborted", 0]) == 1};
_vehPos = (getPos _veh);
_vehPos set [2, 0];
_diff = (_dropPos vectorDiff _vehPos);
Expand Down
6 changes: 3 additions & 3 deletions addons/AIO_AIMENU/follow.sqf
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,14 @@ _AIO_followFnc =
sleep 0.5;
private _tarPos = getPos _target;
_unit moveTo _tarPos;
while {(alive _unit) && (alive _target) && (_unit distance _target > 0)} do
{
waitUntil {
sleep 1;
if (currentCommand _unit != "STOP") exitWith {_unit doFollow player};
if (_target distance _tarPos > 5) then {
_tarPos = getPos _target;
_unit moveTo _tarPos;
sleep 1;
};
!((alive _unit) && (alive _target))
};
};
{
Expand Down
Loading

0 comments on commit f056ce3

Please sign in to comment.