-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added Vehicle Assault pattern. Allows armored vehicles to hunt down other vehicles or certain infantry Fixed vehicle in "ATTACK" stance getting stuck on targets Fixed mortar attacking air targets Fixed vehicles never calling tactics state (especially if group leader and vehicle commander were not identical) Fixed vehicles getting "stuck" in combat dismounting Fixed cases where doVehicleRotate would not correctly trigger Improved balance of mortar rate of fire Improved many cases where debug information were not assigned to vehicle commander
- Loading branch information
Showing
6 changed files
with
166 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
addons/main/functions/VehicleAction/fnc_doVehicleAssaultMove.sqf
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
#include "script_component.hpp" | ||
/* | ||
* Author: nkenny | ||
* Vehicle moves aggressively to superior position | ||
* | ||
* Arguments: | ||
* 0: _unit moving <OBJECT> | ||
* 1: dangerous position <ARRAY> | ||
* 2: dangerous object <OBJECT> | ||
* 3: distance to position and object <NUMBER> | ||
* | ||
* Return Value: | ||
* bool | ||
* | ||
* Example: | ||
* [bob, getPos angryJoe, angryJoe] call lambs_main_fnc_doVehicleAssaultMove; | ||
* | ||
* Public: No | ||
*/ | ||
params ["_unit", "_pos", ["_target", objNull], ["_distance", -1]]; | ||
|
||
// settings | ||
private _vehicle = vehicle _unit; | ||
|
||
// distance to position | ||
if (_distance < 0) then {_distance = _vehicle distance _pos}; | ||
if (isNull _target) then {_target = _vehicle;}; | ||
|
||
// cannot move or moving or enemy too close or too far away | ||
if ( | ||
!canMove _vehicle | ||
|| { (fuel _vehicle) < 0.1 } | ||
|| { (currentCommand _vehicle) in ["MOVE", "ATTACK"] } | ||
|| {_distance < (precision _vehicle)} | ||
|| {_distance > 200} | ||
) exitWith { | ||
_vehicle doMove (getPosASL _vehicle); | ||
false | ||
}; | ||
|
||
private _destination = call { | ||
|
||
// 25 meters ahead | ||
private _typeOf = typeOf _vehicle; | ||
private _distance = _vehicle distance _pos; | ||
private _movePos = _vehicle getPos [50 min _distance, _vehicle getDir _pos]; | ||
_movePos = _movePos findEmptyPosition [0, 15, _typeOf]; | ||
if (_movePos isNotEqualTo [] && {[vehicle _target, "VIEW", objNull] checkVisibility [(AGLToASL _movePos) vectorAdd [0, 0, 3], AGLToASL _pos] > 0}) exitWith { | ||
_movePos | ||
}; | ||
|
||
// random 200 + road adjustment | ||
_movePos = (_vehicle getPos [200 min _distance, (_vehicle getDir _pos) - 45 + random 90]) findEmptyPosition [10, 30, _typeOf]; | ||
if (_movePos isNotEqualTo [] && {[vehicle _target, "VIEW", objNull] checkVisibility [(AGLToASL _movePos) vectorAdd [0, 0, 3], AGLToASL _pos] > 0}) exitWith { | ||
|
||
// road adjust | ||
private _roads = _movePos nearRoads 20; | ||
if (_roads isNotEqualTo []) then {_movePos = (ASLToAGL (getPosASL (selectRandom _roads)));}; | ||
|
||
// return | ||
_movePos | ||
}; | ||
|
||
// On top of | ||
_movePos = _pos findEmptyPosition [5, 35, _typeOf]; | ||
if (_movePos isNotEqualTo []) exitWith { | ||
_movePos | ||
}; | ||
|
||
// none | ||
[] | ||
}; | ||
|
||
// check it! | ||
if (_destination isEqualTo []) exitWith { | ||
false | ||
}; | ||
|
||
// set task | ||
_unit setVariable [QGVAR(currentTarget), _destination, GVAR(debug_functions)]; | ||
_unit setVariable [QGVAR(currentTask), "Vehicle Assault Move", GVAR(debug_functions)]; | ||
|
||
// execute | ||
_vehicle doMove _destination; | ||
|
||
// debug | ||
if (GVAR(debug_functions)) then { | ||
[ | ||
"%1 assault move (%2 moves %3m | visiblity %4)", | ||
side _unit, getText (configOf _vehicle >> "displayName"), | ||
round (_unit distance _destination), | ||
[vehicle _target, "VIEW", objNull] checkVisibility [(AGLToASL _destination) vectorAdd [0, 0, 5], AGLToASL _pos] | ||
] call FUNC(debugLog); | ||
}; | ||
|
||
// exit | ||
true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters