diff --git a/addons/wp/functions/fnc_taskRush.sqf b/addons/wp/functions/fnc_taskRush.sqf index 50f48ebb..29b60ab2 100644 --- a/addons/wp/functions/fnc_taskRush.sqf +++ b/addons/wp/functions/fnc_taskRush.sqf @@ -38,13 +38,11 @@ params [ private _fnc_rushOrders = { params ["_group", "_target"]; - private _distance = (leader _group) distance2D _target; - // Helicopters -- supress it! - if ((_distance < 200) && {vehicle _target isKindOf "Air"}) exitWith { - { - _x commandSuppressiveFire _target; - true - } count (units _group); + private _distance = (leader _group) distance _target; + + // Helicopters -- suppress it! + if ((_distance < 200) && {(vehicle _target) isKindOf "Air"}) exitWith { + (units _group) commandSuppressiveFire _target; }; // Tank -- hide or ready AT @@ -56,17 +54,27 @@ private _fnc_rushOrders = { _x selectWeapon (secondaryWeapon _x); } else { _x setUnitPos "DOWN"; - _x commandSuppressiveFire _target; + _x doSuppressiveFire _target; }; true } count (units _group); _group enableGunLights "forceOff"; }; + // adjust pos + private _posMove = call { + private _posATL = getPosATL _target; + if ((insideBuilding _target) isEqualTo 1 || _distance < 20) exitWith {_posATL}; + private _posEmpty = _posATL findEmptyPosition [0, 20, "O_MRAP_02_F"]; + if (_posEmpty isEqualTo []) exitWith {_posATL}; + _posEmpty + }; + // Default -- run for it! { - _x setUnitPos "UP"; - _x doMove (getPosATL _target); + _x forceSpeed -1; + _x setUnitPos (["UP", "MIDDLE"] select ((unitPos _x) isEqualTo "Down")); + _x doMove _posMove; true } count (units _group); _group enableGunLights "forceOn"; @@ -81,8 +89,31 @@ if (_group isEqualType objNull) then { _group = group _group; }; _group setSpeedMode "FULL"; //_group setFormation "DIAMOND"; _group enableAttack false; +_group allowFleeing 0; { _x disableAI "AUTOCOMBAT"; + _x disableAI "FSM"; + + // fired EH + private _firedEH = _x addEventHandler ["Fired", { + params ["_unit"]; + _unit forceSpeed 3; + }]; + + // dodge + private _suppressedEH = _x addEventHandler ["Suppressed", { + params ["_unit", "", "_shooter"]; + private _unitPos = unitPos _unit; + + // tune stance + if (_unitPos isEqualTo "Down") exitWith {}; + if (_unitPos isEqualTo "Middle" && {_unit distance2D _shooter > 30}) exitWith {_unit setUnitPos "DOWN";}; + _unit setUnitPos "MIDDLE"; + }]; + + // variables + _x setVariable [QGVAR(eventhandlers), [["Fired", _firedEH], ["Suppressed", _suppressedEH]]]; + doStop _x; true } count (units _group); @@ -94,13 +125,13 @@ _group setVariable [QEGVAR(main,currentTactic), "taskRush", EGVAR(main,debug_fun waitUntil { // performance - waitUntil { sleep 1; simulationEnabled leader _group; }; + waitUntil { sleep 1; simulationEnabled (leader _group); }; // find private _target = [_group, _radius, _area, _pos, _onlyPlayers] call EFUNC(main,findClosestTarget); // act - if (!isNull _target) then { + if (!isNull _target) then { [_group, _target] call _fnc_rushOrders; if (EGVAR(main,debug_functions)) then { ["%1 taskRush: %2 targets %3 at %4M", side _group, groupID _group, name _target, floor (leader _group distance2D _target)] call EFUNC(main,debugLog); }; sleep (linearConversion [1000, 2000, (leader _group distance2D _target), _cycle, _cycle * 4, true]);