Merge pull request #668 from KillahPotatoes/v0.96.6-dynamic-building-ai-range

V0.96.6 dynamic building ai range
This commit is contained in:
Christian 2019-09-07 07:24:35 +02:00 committed by GitHub
commit 8eb3251399
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 33 additions and 28 deletions

View File

@ -3,37 +3,40 @@ params ["_unit", ["_sector", ""]];
_unit setUnitPos "UP";
_unit disableAI "MOVE";
private _move_is_disabled = true;
private _resume_movement = false;
private _hostiles = 0;
private _ratio = 0.4;
private _range = 40;
while {_move_is_disabled && local _unit && alive _unit && !(captive _unit)} do {
private _hostilecount = {alive _x && side _x == GRLIB_side_friendly} count ((getpos _unit) nearEntities [["Man"], 40]);
if ((_hostilecount > 0) || (damage _unit > 0.25)) then {
_resume_movement = true;
};
if !(_sector isEqualTo "") then {
_ratio = [_sector] call F_getForceRatio;
};
if (_sector != "") then {
if (_sector in blufor_sectors) then {
_resume_movement = true;
};
};
_range = floor (linearConversion [0, 1, _ratio, 0, GRLIB_capture_size / 3 * 2, true]);
if (_resume_movement) then {
if (_move_is_disabled) then {
_move_is_disabled = false;
_unit enableAI "MOVE";
_unit setUnitPos "AUTO";
};
};
_hostiles = ((getPos _unit) nearEntities [["Man"], _range]) select {side _x == GRLIB_side_friendly};
if (_move_is_disabled) then {
private _target = assignedTarget _unit;
if(!(isnull _target)) then {
private _vd = (getPosASL _target) vectorDiff (getpos _unit);
private _newdir = (_vd select 0) atan2 (_vd select 1);
if (_newdir < 0) then {_dir = 360 + _newdir};
_unit setdir (_newdir);
};
};
sleep 5;
if (_move_is_disabled &&
{
(_sector in blufor_sectors) ||
{!(_hostiles isEqualTo [])} ||
{damage _unit > 0.25}
}
) then {
_move_is_disabled = false;
_unit enableAI "MOVE";
_unit setUnitPos "AUTO";
};
if (_move_is_disabled) then {
private _target = assignedTarget _unit;
if(!(isnull _target)) then {
private _vd = (getPosASL _target) vectorDiff (getpos _unit);
private _newdir = (_vd select 0) atan2 (_vd select 1);
if (_newdir < 0) then {_dir = 360 + _newdir};
_unit setdir (_newdir);
};
};
sleep 5;
};

View File

@ -9,8 +9,8 @@ params [
if (save_is_loaded && {(KP_liberation_clearances findIf {(_x select 0) isEqualTo _centerPos}) != -1}) exitWith {false};
{
_x switchLight "OFF";
_x hideObjectGlobal true;
_x enableSimulationGlobal false;
_x allowDamage false;
} forEach (nearestTerrainObjects [_centerPos, [], _radius, false, true]);

View File

@ -199,6 +199,7 @@ class Missions
* Tweaked: Initial FOB box doesn't have equipment in the inventory anmore.
* Tweaked: Height check for mobile respawn now relies on `isTouchingGround` instead of z value of position.
* Tweaked: Transport config heights on M977 vehicles. Thanks to [FishAI](https://github.com/FishAI)
* Tweaked: AI in building now has a dynamic radius to look for enemies until they start moving again depending on blufor/opfor ratio in sector.
* Fixed: Potato 01 was created after server restart, even if there was one saved.
* Fixed: Missing variable `stats_blufor_teamkills_by_players`. Also no separation between by players or not by players for teamkills anymore.
* Fixed: Factory storages could disappear randomly on save load.
@ -206,6 +207,7 @@ class Missions
* Fixed: CUP Presets still had the Nemmera in the support vehicle section. Thanks to [Eogos](https://github.com/Eogos)
* Fixed: FOB resources weren't updated in build dialog, when building infantry units.
* Fixed: Some missing parameter information in the map screens parameter overview.
* Fixed: After creating a clearance at a FOB some light sources could remain.
### 0.96.5 (26th July 2019 due to Contacts Release)
* Added: Contact DLC LDF preset.