Tweaks to AI behavior. Changed how waypoints are generated.

This commit is contained in:
Ghostrider-DbD- 2017-03-22 20:51:56 -04:00
parent ea11e3d65c
commit 8e19a65b94
10 changed files with 104 additions and 15 deletions

View File

@ -4,11 +4,15 @@
By Ghostrider-DbD-
3/18/17
*/
#ifdef blck_debugMode
if (blck_debugLevel > 2) then
{
diag_log format ["_fnc_cleanEmptyGroups:: -- >> group count = %1 ",(count allGroups)];
diag_log format ["_fnc_cleanEmptyGroups:: -- >> Group count AI side = %1", call blck_fnc_groupsOnAISide];
};
#endif
private _grp = allGroups;
{
//diag_log format["_fnc_cleanEmptyGroups:: - >> type of object _x = %1",typeName _x];

View File

@ -0,0 +1,74 @@
// Sets the WP type for WP for the specified group and updates other atributes accordingly.
/*
for DBD Clan
By Ghostrider-DBD-
Copyright 2016
Last modified 3/14/17
--------------------------
License
--------------------------
All the code and information provided here is provided under an Attribution Non-Commercial ShareAlike 4.0 Commons License.
http://creativecommons.org/licenses/by-nc-sa/4.0/
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private["_group","_wp","_index","_pattern","_mode","_arc","_dis","_wpPos"];
_group = group _this;
_group setVariable["timeStamp",diag_tickTime];
_wp = [_group, 0];
_pattern = _group getVariable["wpPattern",[]];
_index = _group getVariable["wpIndex",0];
_index = _index + 1;
_minDis = _group getVariable["minDis",0];
_maxDis = _group getVariable["maxDis",0];
_arc = (_group getVariable["arc",0]) + 70;
//diag_log format["_fnc_setNextWaypoint: -> _minDis = %1 | _maxDis = %2 | _arc = %3",_minDis,_maxDis,_arc];
if (_index >= (count _pattern)) then
{
_index = 0;
} else {
diag_log format["_fnc_setNextWaypoint: -> waypoint index for group %1 is currently %2 with _pattern = %4 and count _pattern = %3",_group,_index, count _pattern,_pattern];
};
_group setVariable["wpIndex",_index];
_type = _pattern select _index;
diag_log format["_fnc_setNextWaypoint: -> waypoint for group %1 to be updated to mode %2 at position %3 with index %4",_group,_type,waypointPosition _wp, _index];
// revisit this to account for dead units. use waypointPosition if possible.
_wpPos = waypointPosition _wp;
_wp setWaypointType _type;
_wp setWaypointName toLower _type;
if (true /*_type isEqualTo toLower "move"*/) then
{
_dis = (_minDis) + random( (_maxDis) - (_minDis) );
if (toLower (_group getVariable["wpMode","random"]) isEqualTo "random") then
{
_arc = random(360);
} else {
_group setVariable["arc",_arc];
};
_oldPos = waypointPosition _wp;
_newPos = (_group getVariable ["patrolCenter",_wpPos]) getPos[_dis,_arc];
_wp setWPPos _newPos;
diag_log format["_fnc_setNextWaypoint: -- > for group %5 | _dis = %1 | _arc = %2 _oldPos = %3 | _newPos = %4",_dis,_arc,_oldPos,_newPos,_group];
//_wp setWaypointTimeout [1.0,1.1,1.2];
_wp setWaypointTimeout [20,25,30];
} else {
_wp setWaypointTimeout [20,25,30];
_newPos = _wpPos;
_wp setWPPos _newPos;
diag_log format["_fnc_setNextWaypoint: - waypoint position for group %1 not changed",_group];
};
diag_log format["_fnc_setNextWaypoint: -> waypoint for group %1 set to mode %2 at position %3 with index %4",_group,_type,waypointPosition _wp, _index];
diag_log format["_fnc_setNextWaypoint:-> waypoint statements for group %1 = %2",_group, waypointStatements [_group,_index]];
//_wp setWaypointBehaviour "COMBAT";
//_wp setWaypointCombatMode "RED";
_group setCurrentWaypoint _wp;

View File

@ -3,7 +3,7 @@
for DBD Clan
By Ghostrider-DBD-
Copyright 2016
Last modified 3/17/17
Last modified 3/22/17
--------------------------
License
@ -16,7 +16,7 @@
private["_dir","_arc","_noWp","_newpos","_wpradius","_wp"];
params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_patrolMode","SAD"]];
params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_pattern",["MOVE","SAD"]]];
/*
_pos = _this select 0; // center of the patrol area
@ -33,6 +33,8 @@ _group setVariable["timeStamp",diag_tickTime];
_group setVariable["arc",0];
_group setVariable["wpRadius",30];
_group setVariable["wpMode",_mode];
_group setVariable["wpPattern",_pattern];
_group setVariable["wpIndex",0];
_dir = 0;
_arc = 30;
@ -45,12 +47,12 @@ _wp = [_group, 0];
_wp setWaypointType "MOVE";
_wp setWaypointName "move";
_wp setWaypointTimeout [1,1.1,1.2];
_wp setWaypointStatements ["true","this call blck_fnc_changeToSADWaypoint;diag_log format['====Updating waypoint to SAD for group %1',group this];"];
_wp setWaypointStatements ["true","this call blck_fnc_setNextWaypoint;diag_log format['====Updating waypoint to for group %1',group this];"];
#else
_wp setWaypointType "SAD";
_wp setWaypointName "sad";
_wp setWaypointTimeout [20,25,30];
_wp setWaypointStatements ["true","this call blck_fnc_changeToMoveWaypoint;diag_log format['====Updating waypoint to Move for group %1',group this];"];
_wp setWaypointStatements ["true","this call blck_fnc_setNextWaypoint;diag_log format['====Updating waypointfor group %1',group this];"];
#endif
_wp setWaypointBehaviour "COMBAT";

View File

@ -27,10 +27,13 @@ if (_numai2 > _numai1) then {
} else {
_numbertospawn = _numai2;
};
#ifdef blck_debugMode
if (blck_debugLevel > 2) then
{
diag_log format["spawnGroup.sqf: _numbertospawn = %1",_numbertospawn];
};
#endif
_groupSpawned = createGroup blck_AI_Side;
if !(isNull _groupSpawned) then
@ -77,12 +80,16 @@ if !(isNull _groupSpawned) then
[_safepos,_weaponList,_groupSpawned,_skillLevel,_launcherType,_uniforms,_headGear] call blck_fnc_spawnAI;
};
_groupSpawned selectLeader (units _groupSpawned select 0);
[_pos,_minDist,_maxDist,_groupSpawned] spawn blck_fnc_setupWaypoints;
// params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_pattern",["MOVE","SAD"]]];
[_pos,_minDist,_maxDist,_groupSpawned,"random",["SAD"]] spawn blck_fnc_setupWaypoints;
#ifdef blck_debugMode
if (blck_debugLevel > 2) then
{
diag_log format["fnc_spawnGroup:: Group spawned was %1 with units of %2",_groupSpawned, units _groupSpawned];
};
#endif
} else {
diag_log "_fnc_spawnGroup:: ERROR CONDITION : NULL GROUP CREATED";
};

View File

@ -6,7 +6,7 @@ private ["_unit","_instigator"];
//diag_log format["_EH_AIHit::-->> _this = %1",_this];
_unit = _this select 0 select 0;
_instigator = _this select 0 select 3;
//diag_log format["EH_AIHit:: _units = %1 and _instigator = %2 units damage is %3",_unit,_instigator, damage _unit];
diag_log format["EH_AIHit:: _units = %1 and _instigator = %2 units damage is %3",_unit,_instigator, damage _unit];
if (!(alive _unit)) exitWith {};
if (!(isPlayer _instigator)) exitWith {};
[_unit,_instigator] call blck_fnc_alertNearbyLeader;
@ -15,8 +15,8 @@ if ((damage _unit) > 0.1 ) then
{
//diag_log format["_EH_AIHit::-->> Healing unit %1",_unit];
_unit setVariable["hasHealed",true,true];
_unit addMagazine "SmokeShellOrange";
_unit fire "SmokeShellMuzzle";
//_unit addMagazine "SmokeShellOrange";
_unit fire ["SmokeShellMuzzle","SmokeShellMuzzle","SmokeShellRed"];
_unit addItem "FirstAidKit";
_unit action ["HealSoldierSelf", soldier1];
};

View File

@ -158,8 +158,8 @@ if !(isNull _grpPilot) then
[_coords,_skillAI,_weapons,_uniforms,_headGear,_grpParatroops,_patrolHeli] call blck_fnc_spawnMissionParatroops;
};
//set waypoint for helicopter
// params["_pos","_minDis","_maxDis","_group",["_mode","random"]];
[_coords,2,10,_grpPilot,"random"] call blck_fnc_setupWaypoints;
// params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_pattern",["MOVE","SAD"]]];
[_coords,2,10,_grpPilot,"random",["SENTRY"]] call blck_fnc_setupWaypoints;
private["_wpDestination"];
/*
[_grpPilot, 0] setWPPos _coords;
@ -189,4 +189,4 @@ if (blck_debugLevel > 1) then
};
#endif
_return;
_return;

View File

@ -56,6 +56,7 @@ if !(isNull _group) then
deleteWaypoint ((waypoints _group) select 0);
};
_count = 5;
_start = _center getDir _pos;
_angle = _start;

View File

@ -85,6 +85,7 @@ blck_fnc_setupWaypoints = compileFinal preprocessFileLineNumbers "\q\addons\cus
blck_fnc_missionGroupMonitor = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Groups\GMS_fnc_missionGroupMonitor.sqf"; // Monitors active groups for those that are stuck in an SAD waypoint but not in combat
blck_fnc_changeToSADWaypoint = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Groups\GMS_fnc_changeToSADWaypoint.sqf";
blck_fnc_changeToMoveWaypoint = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Groups\GMS_fnc_changeToMoveWaypoint.sqf";
blck_fnc_setNextWaypoint = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Groups\GMS_fnc_setNextWaypoint.sqf";
blck_fnc_cleanEmptyGroups = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Groups\GMS_fnc_cleanEmptyGroups.sqf"; // GMS_fnc_cleanEmptyGroups
// Functions specific to vehicles, whether wheeled, aircraft or static

View File

@ -12,8 +12,8 @@
*/
#include"\q\addons\custom_server\Configs\blck_defines.hpp";
blck_debugON = true;
blck_debugLevel = 3; // Sets level of detail for debugging info - WIP.
blck_debugON = false;
blck_debugLevel = 0; // Sets level of detail for debugging info - WIP.
blck_minFPS = 10;
////////////////////////////////////////////////

View File

@ -1,3 +1,3 @@
private ["_version","_versionDate"];
_blck_version = "6.58 Build 45";
_blck_versionDate = "3-21-17 8:00 PM";
_blck_version = "6.58 Build 46";
_blck_versionDate = "3-22-17 8:00 PM";