Waypoint and HC Updates

Errors with HC initialization resolved.
Reload event handler distributed to clients
Waypoint Logic redone.
This commit is contained in:
Chris Cardozo 2019-09-11 20:19:51 -04:00
parent 8999fef46c
commit 1f8f43ce95
16 changed files with 120 additions and 112 deletions

View File

@ -14,79 +14,76 @@
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private["_group","_wp","_index","_pattern","_mode","_arc","_dis","_wpPos"];
// TODO: Make sure waypoint positions are far enough away that vehicles/armor moves every minute or so and patrols a wide area
_group = group _this;
_group setVariable["timeStamp",diag_tickTime];
_group setcombatmode "RED";
_group setBehaviour "COMBAT";
_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];
dir = (_group getVariable["wpDir",0]) + _group getVariable["wpArc",360/5];
_group setVariable["wpDir",_dir];
diag_log format["_fnc_setNextWaypoint: -> _minDis = %1 | _maxDis = %2 | _arc = %3",_minDis,_maxDis,_arc];
if (_index >= (count _pattern)) then
private _group = group _this;
private _leader = _this;
private _pos = _group getVariable "patrolCenter"; // Center of the area to be patroleld.
private _minDis = _group getVariable "minDis"; // minimum distance between waypoints
private _maxDis = _group getVariable "maxDis"; // maximum distance between waypoints
// _group getVariable "timeStamp"; // used to check that waypoints are being completed
//private _wpRadisu _group getVariable "wpRadius"; // Always set to 0 to force groups to move a bit
private _patrolRadius = _group getVariable "patrolRadius"; // radius of the area to be patrolled
private _wpMode = _group getVariable "wpMode"; // The default mode used when the waypoint becomes active https://community.bistudio.com/wiki/AI_Behaviour
//_group getVariable "wpPatrolMode"; // Not used; the idea is to allow two algorythms: randomly select waypoints so groups move back and forth along the perimiter of the patrool area or sequenctioal, hoping along the perimeter
private _wpTimeout = _group getVariable "wpTimeout"; // Here to alow you to have the game engine pause before advancing to the next waypoing. a timout of 10-20 sec is recommended for infantry and land vehicles, and 1 sec for aircraft
private _wpDir = _group getVariable "wpDir"; // Used to note the degrees along the circumference of the patrol area at which the last waypoint was positioned.
private _arc = _group getVariable "wpArc"; // Increment in degrees to be used when advancing the position of the patrol to the next position along the patrol perimeter
//_group getVariable "soldierType"; // infantry, vehicle, air or emplaced. Note that there is no need to have more than one waypoint for emplaced units.
private _wp = [_group,0];
private _nearestEnemy = _leader findNearestEnemy (getPosATL _leader);
if (isNull _nearestEnemy) then
{
_index = 0;
// Use standard waypoint algorythms
private _vector = _wpDir + _arc + 180; // this should force units to cross back and forth across the zone being patrolled
_group setVariable["wpDir",_vector,true];
private _newWPPos = _pos getPos[_patrolRadius,_vector];
_wp setWaypointPosition [_newWPPos,0];
_group setBehaviour "SAFE"; // no enemies detected so lets put the group in a relaxed mode
_wp setWaypointBehaviour "SAFE";
_wp setWaypointCompletionRadius 0;
_wp setWaypointTimeout _wpTimeout;
_group setCurrentWaypoint _wp;
diag_log format["_fnc_setNextWaypoin[no enemies]t: _group = %1 | _newPos = %2 | waypointStatements = %3",_group,_newWPPos,waypointStatements _wp];
} 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];
};
// move toward that enemy using hunting logic
// possibly along patrol perimeter
// set mode to SAD / COMBAT
/*
_vector set to relative direction from leader to enemy +/- random adjustment of up to 33 degrees
_distance can be up to one patrol radius outside of the normal perimeter closer to enemy
_timout set to longer period
when coupled with SAD behavior should cause interesting behaviors
*/
// [point1, point2] call BIS_fnc_relativeDirTo
private _vector = ([(leader _group),_nearestEnemy] call BIS_fnc_relativeDirTo) + (random(33)*selectRandom[-1,1]);
_group setVariable["wpDir",_vector];
private ["_huntDistance"];
_group setVariable["wpIndex",_index];
_type = _pattern select _index;
#ifdef blck_debugMode
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];
#endif
// revisit this to account for dead units. use waypointPosition if possible.
_wpPos = waypointPosition _wp;
_wp setWaypointType _type;
_wp setWaypointName toLower _type;
if (_type isEqualTo (toLower "move")) then
{
_dis = (_minDis) + random( (_maxDis) - (_minDis) );
if (_group getVariable["wpMode",""] isEqualTo "random") then
if ((leader _group) distance _nearestEnemy > (_patrolRadius * 2)) then
{
_dir = random(360)
if (((leader _group) distance _pos) > (2 * _patrolRadius)) then
{
_huntdistance = 0;
} else {
_huntDistance = _patrolRadius;
};
} else {
_dir = _group getVariable["wpDir",0] + _group getVariable["wpArc",360/5];
_huntDistance = ((leader _group) distance _nearestEnemy) / 2;
};
_group setVariable["wpDir",_dir];
_oldPos = waypointPosition _wp;
_newPos = (_group getVariable ["patrolCenter",_wpPos]) getPos[_dis,_arc];
_wp setWPPos [_newPos select 0, _newPos select 1];
#ifdef blck_debugMode
diag_log format["_fnc_setNextWaypoint: -- > for group %5 | _dis = %1 | _arc = %2 _oldPos = %3 | _newPos = %4",_dis,_arc,_oldPos,_newPos,_group];
#endif
_wp setWaypointTimeout [1.0,1.1,1.2];
//_wp setWaypointTimeout [20,25,30];
} else {
_wp setWaypointTimeout [20,25,30];
_newPos = _wpPos;
_wp setWPPos _newPos;
#ifdef blck_debugMode
diag_log format["_fnc_setNextWaypoint: - waypoint position for group %1 not changed",_group];
#endif
private _newWPPos = _pos getPos[_huntDistance,_vector];
diag_log format["_fnc_setextWaypoint: _pos = %1 | _patrolRadius = %5 | _newWPPos = %2 | _huntDistance = %3 | _vector = %4",_pos,_newWPPos,_huntDistance,_vector,_patrolRadius];
_wp setWaypointPosition [_newWPPos,0];
_wp setWaypointBehaviour "SAD";
_group setBehaviour "AWARE";
_wp setWaypointCombatMode "RED";
_wp setWaypointTimeout[30,45,60];
_wp setWaypointCompletionRadius 0;
_group setCurrentWaypoint _wp;
// Assume the same waypoint statement will be available
diag_log format["_fnc_setNextWaypoin[enemies]t: _group = %1 | _newPos = %2 | _nearestEnemy = 54 | waypointStatements = %3",_group,_newWPPos,waypointStatements _wp,_nearestEnemy];
};
#ifdef blck_debugMode
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]];
#endif
_wp setWaypointBehaviour blck_groupBehavior;
_wp setWaypointCombatMode blck_combatMode;
_group setCurrentWaypoint _wp;

View File

@ -13,40 +13,41 @@
*/
#include "\q\addons\custom_server\Configs\blck_defines.hpp";
private["_dir","_arc","_noWp","_newpos","_wpradius","_wp"];
params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_wpPatrolMode","SAD"],["_soldierType","null"] ];
params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_wpPatrolMode","SAFE"],["_soldierType","null"],["_patrolRadius",30],["_wpTimeout",[5.0,7.5,10]]];
_wp = [_group, 0];
if !(_soldierType isEqualTo "emplaced") then
{
_arc = 360/5;
_group setcombatmode "YELLOW";
_group setBehaviour "COMBAT";
_group setVariable["patrolCenter",_pos];
_group setVariable["minDis",_minDis];
_group setVariable["maxDis",_maxDis];
_group setVariable["timeStamp",diag_tickTime];
_group setVariable["wpRadius",0];
_group setVariable["wpMode",_mode];
_group setVariable["wpPatrolMode",_wpPatrolMode];
_group setVariable["wpDir",0];
_group setVariable["wpArc",_arc];
_group setVariable["soldierType",_soldierType];
_group setcombatmode "RED";
_group setBehaviour "SAFE";
_group setVariable["patrolCenter",_pos,true]; // Center of the area to be patroleld.
_group setVariable["minDis",_minDis,true]; // minimum distance between waypoints
_group setVariable["maxDis",_maxDis,true]; // maximum distance between waypoints
_group setVariable["timeStamp",diag_tickTime]; // used to check that waypoints are being completed
_group setVariable["wpRadius",0]; // Always set to 0 to force groups to move a bit
_group setVariable["patrolRadius",_patrolRadius,true]; // radius of the area to be patrolled
_group setVariable["wpMode",_mode,true]; // The default mode used when the waypoint becomes active https://community.bistudio.com/wiki/AI_Behaviour
_group setVariable["wpPatrolMode",_wpPatrolMode]; // Not used; the idea is to allow two algorythms: randomly select waypoints so groups move back and forth along the perimiter of the patrool area or sequenctioal, hoping along the perimeter
_group setVariable["wpTimeout",_wpTimeout,true]; // Here to alow you to have the game engine pause before advancing to the next waypoing. a timout of 10-20 sec is recommended for infantry and land vehicles, and 1 sec for aircraft
_group setVariable["wpDir",0,true]; // Used to note the degrees along the circumference of the patrol area at which the last waypoint was positioned.
_group setVariable["wpArc",_arc,true]; // Increment in degrees to be used when advancing the position of the patrol to the next position along the patrol perimeter
_group setVariable["soldierType",_soldierType]; // infantry, vehicle, air or emplaced. Note that there is no need to have more than one waypoint for emplaced units.
_dir = 0;
_wpradius = 30;
_dis = (_minDis) + random( (_maxDis) - (_minDis) );
_newPos = _pos getPos[_dis,_dir];
_wp setWPPos [_newPos select 0, _newPos select 1];
_wp setWaypointCompletionRadius 0; //(_group getVariable["wpRadius",30]);
_wp setWaypointType "MOVE";
_wp setWaypointName "move";
_wp setWaypointBehaviour "COMBAT";
_wp setWaypointBehaviour "SAFE";
_wp setWaypointCombatMode "RED";
_wp setWaypointTimeout [1,1.1,1.2];
_wp setWaypointTimeout _wpTimeout;
_group setCurrentWaypoint _wp;
#ifdef blck_debugMode
_wp setWaypointStatements ["true","this call blck_fnc_changeToMoveWaypoint; diag_log format['====Updating timestamp for group %1 and changing its WP to a Move Waypoint',group this];"];
_wp setWaypointStatements ["true","this call blck_fnc_setNextWaypoint; diag_log format['====Updating timestamp for group %1 and changing its WP to a Move Waypoint',group this];"];
#else
_wp setWaypointStatements ["true","this call blck_fnc_changeToMoveWaypoint;"];
_wp setWaypointStatements ["true","this call blck_fnc_setNextWaypoint;"];
#endif
#ifdef blck_debugMode
if (blck_debugLevel >= 3) then

View File

@ -65,7 +65,10 @@ if !(isNull _group) then
if (_configureWaypoints) then
{
if (_scuba) then {_infantryType = "scuba"} else {_infantryType = "infantry"};
[_pos,_minDist,_maxDist,_group,"random","SAD",_infantryType] spawn blck_fnc_setupWaypoints;
// params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_wpPatrolMode","SAFE"],["_soldierType","null"],["_patrolRadius",30],["_wpTimeout",[5.0,7.5,10]]];
#define infantryPatrolRadius 30
#define infantryWaypointTimeout [5,7.5,10]
[_pos,_minDist,_maxDist,_group,"random","SAD",_infantryType,infantryPatrolRadius,infantryWaypointTimeout] spawn blck_fnc_setupWaypoints;
};
} else
{

View File

@ -15,5 +15,6 @@ _group = _this select 0;
{
_unit = _x;
_tempEH = _unit addEventHandler ["Reloaded", {_this call blck_EH_unitWeaponReloaded;}]; //Fires locally so add this again.
diag_log format["blckHC:: reloaded EH added to unit %1 after transfer to HC %2",_x,clientOwner];
}forEach (units _group);
diag_log format["blckHC:: group %1 transferred to HC %2",_group,clientOwner];

View File

@ -29,20 +29,21 @@ if !(blck_connectedHCs isEqualTo []) then
{
_idHC = [blck_connectedHCs] call blck_fnc_HC_leastBurdened;
{
diag_log format["_fnc_passToHCs: group = %1 | owner = %2 | blck_group = %3",_x, groupOwner _x, _x getVariable ["blck_group","undefined"]];
//diag_log format["_fnc_passToHCs: group = %1 | owner = %2 | blck_group = %3",_x, groupOwner _x, _x getVariable ["blck_group","undefined"]];
//if (_x getVariable["blck_group",false]) then
//{
if ((groupOwner _x) == 2) then
{
private _sgor = _x setGroupOwner (owner _idHC);
//diag_log format["_fnc_passToHCs: group = %1 | _sgor = %2 | _idHC = %3",_x,_sgor,_idHC];
if (_sgor) then
{
[_x] remoteExec["blck_fnc_HC_XferGroup",_idHC];
_numTransfered = _numTransfered + 1;
diag_log format["_fnc_passToHCs: group %1 Passed to HC %2",_x,_idHC];
//diag_log format["_fnc_passToHCs: group %1 Passed to HC %2",_x,_idHC];
};
};
//};
} forEach (_groups);
diag_log format["[blckeagls] _passToHCs:: %1 groups transferred to HC %2",_numTransfered,_idHC];
//diag_log format["[blckeagls] _passToHCs:: %1 groups transferred to HC %2",_numTransfered,_idHC];
};

View File

@ -44,7 +44,9 @@ if (_missionEmplacedWeapons isEqualTo []) then
[_empGroup,_pos,1,1,_difficulty,_pos,1,2,_uniforms,_headGear,false] call blck_fnc_spawnGroup;
_empGroup setcombatmode "RED";
_empGroup setBehaviour "COMBAT";
[_pos,0.01,0.02,_empGroup,"random","SAD","emplaced"] spawn blck_fnc_setupWaypoints;
// // params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_wpPatrolMode","SAFE"],["_soldierType","null"],["_patrolRadius",30],["_wpTimeout",[5.0,7.5,10]]];
// Not sure of the value of giving waypoints here
//[_pos,0.01,0.02,_empGroup,"random","SAD","emplaced"] spawn blck_fnc_setupWaypoints;
//if (isNull _empGroup) exitWith {_abort = _true};
_wep = [_wepnClassName,[0,0,0],false] call blck_fnc_spawnVehicle;
//_empGroup setVariable["groupVehicle",_wep];

View File

@ -41,7 +41,8 @@ if (_missionEmplacedWeapons isEqualTo []) then
__empGroup = [_pos,_pos,1,1,_difficulty,1,2,false,_uniforms,_headGear] call blck_fnc_spawnGroup;
_empGroup setcombatmode "RED";
_empGroup setBehaviour "COMBAT";
[_pos,0.01,0.02,_empGroup,"random","SAD","emplaced"] spawn blck_fnc_setupWaypoints;
// Not sure of the value of giving waypoints here.
//[_pos,0.01,0.02,_empGroup,"random","SAD","emplaced"] spawn blck_fnc_setupWaypoints;
//if (isNull _empGroup) exitWith {_abort = _true};
_wep = [_wepnClassName,[0,0,0],false] call blck_fnc_spawnVehicle;
//_empGroup setVariable["groupVehicle",_wep];

View File

@ -95,7 +95,7 @@ if (_missionGroups isEqualTo [] && _noAIGroups > 0) then
diag_log format["missionSpawner: Spawning Groups: case 1: _noAIGroups=1"];
};
#endif
_newGroup = [] call blck_fnc_createGroup;
_newGroup = [blck_AI_Side,true] call blck_fnc_createGroup;
_newGroup setVariable ["soldierType","infantry"];
#ifdef blck_debugMode
if (blck_debugLevel >= 2) then
@ -137,7 +137,7 @@ if (_missionGroups isEqualTo [] && _noAIGroups > 0) then
} else {
_adjusttedGroupSize = _unitsPerGroup;
};
_newGroup = [] call blck_fnc_createGroup;
_newGroup = [blck_AI_Side,true] call blck_fnc_createGroup;
_newGroup setVariable ["soldierType","infantry"];
if !(isNull _newGroup) then
{
@ -164,7 +164,7 @@ if (_missionGroups isEqualTo [] && _noAIGroups > 0) then
diag_log format["_fnc_spawnMissionAI (68): Spawning Groups: case 3: _noAIGroups=3"];
};
#endif
_newGroup = [] call blck_fnc_createGroup;
_newGroup = [blck_AI_Side,true] call blck_fnc_createGroup;
_newGroup setVariable ["soldierType","infantry"];
if !(isNull _newGroup) then
{
@ -180,7 +180,7 @@ if (_missionGroups isEqualTo [] && _noAIGroups > 0) then
_blck_AllMissionAI append _newAI;
_groupLocations = [_coords,2,20,35] call blck_fnc_findPositionsAlongARadius;
{
_newGroup = [] call blck_fnc_createGroup;
_newGroup = [blck_AI_Side,true] call blck_fnc_createGroup;
_newGroup setVariable ["soldierType","infantry"];
if !(isNull _newGroup) then
{
@ -207,7 +207,7 @@ if (_missionGroups isEqualTo [] && _noAIGroups > 0) then
};
#endif
_newGroup = [] call blck_fnc_createGroup;
_newGroup = [blck_AI_Side,true] call blck_fnc_createGroup;
_newGroup setVariable ["soldierType","infantry"];
if (isNull _newGroup) then
{
@ -224,7 +224,7 @@ if (_missionGroups isEqualTo [] && _noAIGroups > 0) then
};
_groupLocations = [_coords,(_noAIGroups - 1),20,40] call blck_fnc_findPositionsAlongARadius;
{
_newGroup = [] call blck_fnc_createGroup;
_newGroup = [blck_AI_Side,true] call blck_fnc_createGroup;
_newGroup setVariable ["soldierType","infantry"];
if !(isNull _newGroup) then
{

View File

@ -31,8 +31,9 @@ private _params = ["_pos","_numAI","_skillAI"];
#endif
_paraGroup = [blck_AI_Side,true] call blck_fnc_createGroup;
//diag_log format["_fnc_spawnParaUnits: _paraGroup = %1",_paraGroup];
// [_pos,_minDist,_maxDist,_groupSpawned,"random","SAD"] spawn blck_fnc_setupWaypoints;
[_pos,20,30,_paraGroup,"random","SAD","paraUnits"] call blck_fnc_setupWaypoints;
#define infantryPatrolRadius 30
#define infantryWaypointTimeout [5,7.5,10]
[_pos,20,30,_paraGroup,"random","SAD","paraUnits",infantryPatrolRadius,infantryWaypointTimeout] call blck_fnc_setupWaypoints;
#define launcherType "none"
private ["_arc","_spawnPos"];

View File

@ -61,10 +61,12 @@ if !(isNull _grpPilot) then
diag_log format["_fnc_spawnMissionHeli(59): _skillAI = %1 | _minDist = %2 | _maxDist = %3",_skillAI,_minDist,_maxDist];
};
#endif
[_coords,_minDist,_maxDist,_grpPilot,"random","SAD","aircraft"] call blck_fnc_setupWaypoints;
#define aircraftPatrolRadius 800
#define aircraftWaypointTimeout [1,1.5,2]
[_coords,_minDist,_maxDist,_grpPilot,"random","SAD","aircraft",aircraftPatrolRadius,aircraftWaypointTimeout] call blck_fnc_setupWaypoints;
blck_monitoredMissionAIGroups pushBack _grpPilot;
//create helicopter and spawn it
if (( typeName _helis) isEqualTo "ARRAY") then
{

View File

@ -39,7 +39,9 @@ if !(isNull _group) then {
if (_setWaypoints) then
{
// params["_pos","_minDis","_maxDis","_group",["_mode","random"],["_wpPatrolMode","SAD"],["_soldierType","null"] ];
[_center,_minDis,_maxDis,_group,"perimeter","SAD","vehicle"] spawn blck_fnc_setupWaypoints;
#define vehiclePatrolRadius 400
#defin vehicleWaypointTimout [6, 9, 12]
[_center,_minDis,_maxDis,_group,"perimeter","SAD","vehicle",vehiclePatrolRadius,vehicleWaypointTimout] spawn blck_fnc_setupWaypoints;
};
};

View File

@ -210,11 +210,7 @@ private _functions = [
missionnamespace setvariable [_name,compileFinal preprocessFileLineNumbers _path];
} foreach _functions;
#ifdef GRGserver
blck_fnc_broadcastServerFPS = compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\Functions\GMS_fnc_broadcastServerFPS.sqf";
diag_log "blck_functions loaded using GRGserver settings ---- >>>> ";
#endif
//onPlayerDisconnected {[_name,_owner] call blck_fnc_onPlayerDisconnected;};

View File

@ -16,9 +16,9 @@ if !(isNil "blck_Initialized") exitWith{};
private _blck_loadingStartTime = diag_tickTime;
#include "\q\addons\custom_server\init\build.sqf";
//call compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\blck_variables.sqf";
call compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\blck_functions.sqf";
call compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Compiles\blck_functions_HC.sqf";
//call compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Configs\blck_configs.sqf";
//call compileFinal preprocessFileLineNumbers "\q\addons\custom_server\Configs\blck_custom_config.sqf";
diag_log format["[blckeagls] Loading Headless Client Version %2 | Build Date %1 | loaded in %4 seconds",_blck_versionDate,blck_versionNumber,blck_buildNumber,diag_tickTime - _blck_loadingStartTime];
diag_log format["[blckeagls] Loading Headless Client Version %2 | Build Date %1 | Build %3 | loaded in %4 seconds",blck_buildDate,blck_versionNumber,blck_buildNumber,diag_tickTime - _blck_loadingStartTime];

View File

@ -109,8 +109,9 @@ if (blck_blacklistTraderCities) then
if (blck_ai_offload_to_client) then
{
publicVariable "blck_fnc_setNextWaypoint";
publicVariable "blck_fnc_changeToMoveWaypoint";
publicVariable "blck_fnc_changeToSADWaypoint";
//publicVariable "blck_fnc_changeToMoveWaypoint";
//publicVariable "blck_fnc_changeToSADWaypoint";
publicVariable "blck_EH_unitWeaponReloaded";
};
//Start the mission timers

View File

@ -1,4 +1,4 @@
#define blck_buildNumber 181
#define blck_versionNumber 6.92
#define blck_buildDate "9-10-19"
#define blck_buildDate "9-11-19"

View File

@ -23,11 +23,11 @@ blck_missionSystemRunning = true;
if (isServer) then
{
execVM "\q\addons\custom_server\init\blck_init_server.sqf";
[] execVM "\q\addons\custom_server\init\blck_init_server.sqf";
};
if (!isServer && !hasInterface) then
{
diag_log format["Loading blackeagls for headless clients"];
[] execVM "blck_init_HC.sqf";
[] execVM "\q\addons\custom_server\init\blck_init_HC.sqf";
};