Fixes + Tweaks + Features

#### September 13, 2015 (11:45 PM CST-America):
* NEW CONFIG VALUES: DMS_MaxAIDistance and DMS_AIDistanceCheckFrequency
* You can now use the above config values to kill AI that flee from
their spawn position. Only "Soldier" AI will be killed.
* Removed "O_HMG_01_F" from AI Static Weapons. AI were pretty useless on
it... unless the AI were facing the right direction.
* Reduced AI count and removed the "playerNear" parameter from
testmission for easier testing.
* NEW: When an AI vehicle gunner is killed, and the driver is still
alive, after a little delay, the driver is then switched to the gunner
seat. You should no longer have AI vehicles with a dead gunner that's
driving around aimlessly :) There is a 5-8 second delay to simulate
reaction time. Then the driver is ejected, then after 1.5 seconds the AI
is then forced into the  gunner seat.
* NOTE: The above feature only works when the AI is still local (not
offloaded). If the AI is offloaded, the AI is simply ejected and becomes
a foot soldier.
* AI assigned vehicles are destroyed when the crew is empty. Simulation
is also disabled on them.
* Reduced some of the "params" RPT spam, from DMS_fnc_SetGroupBehavior.
* Tweaked AI Vehicle spawning logic. The AI are initially assigned to a
temporary group and then behavior is set, then they join the assigned
group to prevent overriding behavior of other ground units.
* Non-persistent vehicles should now be fit properly to the terrain.
This commit is contained in:
eraser1
2015-09-16 22:37:17 -05:00
parent 395a1d2ba7
commit afb4833a65
11 changed files with 89 additions and 30 deletions

View File

@ -105,6 +105,9 @@ DMS_DEBUG = false;
DMS_remove_roadkill_chance = 50; // Percentage chance that roadkilled AI bodies will be deleted
DMS_RemoveNVG = false; // Remove NVGs from AI bodies
DMS_MaxAIDistance = 500; // The maximum distance an AI unit can be from a mission before he is killed. Helps with AI running away and forcing the mission to keep running. Set to 0 if you don't want it.
DMS_AIDistanceCheckFrequency = 60; // How often to check within DMS_fnc_TargetsKilled whether or not the AI is out of the maximum radius. Lower values increase frequency and increase server load, greater values decrease frequency and may cause longer delays for "runaway" AI.
DMS_ai_offload_to_client = true; // Offload spawned AI groups to random clients. Helps with server performance.
DMS_ai_share_info = true; // Share info about killer
@ -127,7 +130,6 @@ DMS_DEBUG = false;
DMS_AI_WP_Radius_base = 5; // Waypoint radius for AI in bases
DMS_static_weapons = [ // Static weapons for AI
"O_HMG_01_F",
"O_HMG_01_high_F"
];
@ -579,8 +581,8 @@ DMS_DEBUG = false;
// Debug Overwrites
if(DMS_DEBUG) then
{
DMS_TimeBetweenMissions = [30,60];
DMS_MissionTimeOut = [60,90];
DMS_TimeBetweenMissions = [30,40];
DMS_MissionTimeOut = [60,70];
DMS_MissionTypes = [["testmission",1]];
//DMS_MissionTypes = [["mercbase",1]];
diag_log format ["DMS_DEBUG CONFIG :: Overriding DMS_TimeBetweenMissions (%1) and DMS_MissionTimeOut (%2)",DMS_TimeBetweenMissions,DMS_MissionTimeOut];

View File

@ -1,13 +1,13 @@
/*
DMS Pre-init
Written by eraser1 (trainwreckdayz.com)
This will be completely deprecated soon...
*/
/* Future stuff
DMS_HeliPara = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\HeliPara.sqf";
DMS_HeliPatrol = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\HeliPatrol.sqf";
DMS_VehPatrol = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\VehPatrol.sqf";
DMS_VehMonitor = compileFinal preprocessFileLineNumbers "\x\addons\dms\scripts\VehMonitor.sqf";
*/
DMS_HC_Object = objNull;

View File

@ -22,7 +22,7 @@ _difficulty = "moderate";
// Create AI
// TODO: Spawn AI only when players are nearby
_AICount = 4 + (round (random 2));
_AICount = 1;
_group =
[
@ -37,8 +37,7 @@ _dir = random 180;
_staticGuns =
[
[
[_pos,5+random 5,_dir] call DMS_fnc_SelectOffsetPos,
[_pos,5+random 5,_dir+180] call DMS_fnc_SelectOffsetPos
[_pos,5+random 5,_dir] call DMS_fnc_SelectOffsetPos
],
_group,
"assault",
@ -65,6 +64,7 @@ _crate_loot_values =
3 // Backpacks
];
_veh =
[
[
[_pos,100,random 360] call DMS_fnc_SelectOffsetPos,
@ -86,7 +86,7 @@ _missionAIUnits =
// Define mission-spawned objects and loot values
_missionObjs =
[
_staticGuns, // We only spawn the static guns
_staticGuns+[_veh],
[_vehicle],
[[_crate,"Sniper"]]
];
@ -122,10 +122,6 @@ _added =
[
"kill",
_group
],
[
"playerNear",
[_pos,DMS_playerNearRadius]
]
],
[

View File

@ -88,32 +88,56 @@ if (!isNull _av) then
// Destroy the vehicle and add it to cleanup if there are no active crew members of the vehicle.
if (_memCount<1) then
{
moveOut _unit;
_av setDamage 1;
DMS_CleanUpList pushBack [_av,diag_tickTime,DMS_AIVehCleanUpTime];
_av spawn {sleep 1;_this enableSimulationGlobal false;};
if (DMS_DEBUG) then
{
diag_log format["DMS_DEBUG OnKilled :: Destroying used AI vehicle %1 and adding to cleanup.",typeOf _av];
diag_log format["DMS_DEBUG OnKilled :: Destroying used AI vehicle %1, disabling simulation, and adding to cleanup.",typeOf _av];
};
}
else
{
// Only check for this stuff for ground vehicles that have guns...
if (_av isKindOf "LandVehicle" && {(count (weapons _av))>1}) then
if ((_av isKindOf "LandVehicle") && {(count (weapons _av))>0}) then
{
_gunner = gunner _av;
_driver = driver _av;
// If the gunner is dead but the driver is alive, then the driver becomes the gunner.
// Helps with troll AI vehicles driving around aimlessly after the gunner is shot off. More realistic imo
// Yes, I know, so many nested conditions. eraser is a scrublord. blah blah blah. Deal with it
if (((isNull _gunner) || {!(alive _gunner)}) && {!(isNull _driver) && {alive _driver}}) then
{
_driver moveInGunner _av;
if (DMS_DEBUG) then
[_driver,_av] spawn
{
diag_log format["DMS_DEBUG OnKilled :: Switching driver of AI Vehicle (%1) to gunner.",typeOf _av];
_driver = _this select 0;
_av = _this select 1;
_av setVehicleAmmoDef 1;
sleep 5+(random 3); // 3 to 6 seconds delay after gunner death, to simulate reaction/switching time.
// The unit has to be local or else some of the commands won't work. Might as well eject the driver from the vehicle and make him useful.
moveOut _driver;
if (!local _driver) exitWith {};
//doGetOut _driver;
//unassignVehicle _driver;
waitUntil {(vehicle _driver)==_driver};
_driver assignAsGunner _av;
[_driver] orderGetIn true;
sleep 1.5;
_driver moveInGunner _av;
if (DMS_DEBUG) then
{
diag_log format["DMS_DEBUG OnKilled :: Switching driver of AI Vehicle (%1) to gunner.",typeOf _av];
};
};
};
};
@ -131,7 +155,7 @@ if (isPlayer _player) then
if (DMS_ai_share_info) then
{
{
if (((position _x) distance (position _unit)) <= DMS_ai_share_info_distance ) then
if (((position _x) distance2D (position _unit)) <= DMS_ai_share_info_distance ) then
{
_x reveal [_player, 4.0];
};

View File

@ -107,7 +107,7 @@ _group setFormation "WEDGE";
if(_pos_z == 0) then
{
[_group,_pos,_difficulty] call DMS_fnc_SetGroupBehavior;
[_group,_pos,_difficulty,"COMBAT"] call DMS_fnc_SetGroupBehavior;
};

View File

@ -195,7 +195,7 @@ if (!_useCustomGear) then
// Infinite Ammo
// This will NOT work if AI unit is offloaded to client
_unit addeventhandler ["Fired", {(_this select 0) setvehicleammo 1;}];
_unit addeventhandler ["Fired", {(vehicle (_this select 0)) setvehicleammo 1;}];
};
}
else
@ -319,6 +319,12 @@ _unit enableAI "MOVE";
_unit enableAI "ANIM";
_unit enableAI "FSM";
if (_type=="Soldier") then
{
_unit setVariable ["DMS_AISpawnPos",_pos];
_unit setVariable ["DMS_LastAIDistanceCheck",time];
};
if (DMS_DEBUG) then
{
diag_log format ["DMS_DEBUG SpawnAISoldier :: Spawned a %1 %2 %6 AI at %3 with %4 difficulty to group %5",_class,_side,_pos,_difficulty,_group,_type];

View File

@ -18,7 +18,7 @@
Returns the spawned vehicle.
*/
private ["_OK", "_positions", "_veh", "_spawnPos", "_gotoPos", "_vehClass", "_driver", "_gunner", "_group", "_class", "_difficulty", "_side"];
private ["_OK", "_positions", "_veh", "_spawnPos", "_gotoPos", "_vehClass", "_driver", "_gunner", "_tmpGroup", "_group", "_class", "_difficulty", "_side"];
_OK = params
@ -56,16 +56,16 @@ if (_vehClass == "random") then
_vehClass = DMS_ArmedVehicles call BIS_fnc_selectRandom;
};
_tmpGroup = createGroup (missionNamespace getVariable [format ["DMS_%1Side",_side],EAST]);
_veh = createVehicle [_vehClass, _spawnPos, [], 0, "NONE"];
_veh setDir (random 360);
_veh setPosATL _spawnPos;
_veh addEventHandler ["GetOut",{(_this select 0) setDamage 1;}];
_veh lock 2;
_driver = [_group,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier;
_gunner = [_group,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier;
_driver = [_tmpGroup,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier;
_gunner = [_tmpGroup,_spawnPos,_class,_difficulty,_side,"Vehicle"] call DMS_fnc_SpawnAISoldier;
_driver moveInDriver _veh;
_gunner moveInGunner _veh;
@ -73,7 +73,10 @@ _gunner moveInGunner _veh;
_driver setVariable ["DMS_AssignedVeh",_veh];
_gunner setVariable ["DMS_AssignedVeh",_veh];
[_group,_gotoPos,_difficulty,"AWARE"] call DMS_fnc_SetGroupBehavior;
[_tmpGroup,_gotoPos,_difficulty,"AWARE"] call DMS_fnc_SetGroupBehavior;
[_driver,_gunner] joinSilent _group;
if (DMS_DEBUG) then
{

View File

@ -45,6 +45,7 @@ _vehObj = [_vehicleClass, _vehpos, (random 360), true] call ExileServer_object_v
_vehObj allowDamage false;
_vehObj setFuel 1;
_vehObj lock 2;
_vehObj setVectorUp (surfaceNormal _vehpos);
if (DMS_DEBUG) then
{

View File

@ -31,16 +31,30 @@ try
{
if (((typeName _x) == "OBJECT") && {!isNull _x && {alive _x}}) then
{
throw _x;
// It only seems long... but it's only evaluating 3 conditions.
if ((DMS_MaxAIDistance>0) && {((time - (_x getVariable ["DMS_LastAIDistanceCheck",time]))>DMS_AIDistanceCheckFrequency) && {((getPosWorld _x) distance2D (_x getVariable ["DMS_AISpawnPos",getPosWorld _x]))>DMS_MaxAIDistance}}) then
{
_x setDamage 1;
diag_log format ["Killed a runaway unit! |%1| was more than %2m away from its spawn position %3!",_x,DMS_MaxAIDistance,_x getVariable "DMS_AISpawnPos"];
}
else
{
throw _x;
};
}
else
{
if !((typeName _x) == "GROUP") exitWith
if ((typeName _x) != "GROUP") exitWith
{
diag_log format ["DMS ERROR :: %1 is neither OBJECT nor GROUP!",_x];
};
{
if (!isNull _x && {alive _x}) exitWith
if ((DMS_MaxAIDistance>0) && {((time - (_x getVariable ["DMS_LastAIDistanceCheck",time]))>DMS_AIDistanceCheckFrequency) && {((getPosWorld _x) distance2D (_x getVariable ["DMS_AISpawnPos",getPosWorld _x]))>DMS_MaxAIDistance}}) then
{
_x setDamage 1;
diag_log format ["Killed a runaway unit! |%1| was more than %2m away from its spawn position %3!",_x,DMS_MaxAIDistance,_x getVariable "DMS_AISpawnPos"];
}
else
{
throw _x;
};

Binary file not shown.

View File

@ -78,6 +78,19 @@ if (!hasInterface && !isServer) then
## Changelog:
#### September 16, 2015 (10:30 PM CST-America):
* NEW CONFIG VALUES: DMS_MaxAIDistance and DMS_AIDistanceCheckFrequency
* You can now use the above config values to kill AI that flee from their spawn position. Only "Soldier" AI will be killed.
* Removed "O_HMG_01_F" from AI Static Weapons. AI were pretty useless on it... unless the AI were facing the right direction.
* Reduced AI count and removed the "playerNear" parameter from testmission for easier testing.
* NEW: When an AI vehicle gunner is killed, and the driver is still alive, after a little delay, the driver is then switched to the gunner seat. You should no longer have AI vehicles with a dead gunner that's driving around aimlessly :) There is a 5-8 second delay to simulate reaction time. Then the driver is ejected, then after 1.5 seconds the AI is then forced into the gunner seat.
* NOTE: The above feature only works when the AI is still local (not offloaded). If the AI is offloaded, the AI is simply ejected and becomes a foot soldier.
* AI assigned vehicles are destroyed when the crew is empty. Simulation is also disabled on them.
* Reduced some of the "params" RPT spam, from DMS_fnc_SetGroupBehavior.
* Tweaked AI Vehicle spawning logic. The AI are initially assigned to a temporary group and then behavior is set, then they join the assigned group to prevent overriding behavior of other ground units.
* Non-persistent vehicles should now be fit properly to the terrain.
#### September 14, 2015 (11:00 PM CST-America):
* NEW CONFIG VALUES: DMS_AIVehCleanUpTime, DMS_MinWaterDepth, DMS_Bandit_Vehicle_MoneyGain, DMS_Bandit_Vehicle_RepGain.
* Changed default value of DMS_Bandit_Static_MoneyGain to 75, DMS_Bandit_Static_RepGain to 15.