From 3533c3aa9393fc6350178b196c813dc636ec9cf6 Mon Sep 17 00:00:00 2001 From: hybrid Date: Thu, 11 Jun 2026 19:57:23 +0300 Subject: init --- Server/AI/Orders/AI_MoveTo.sqf | 17 +++++++++ Server/AI/Orders/AI_Patrol.sqf | 34 ++++++++++++++++++ Server/AI/Orders/AI_TownPatrol.sqf | 71 ++++++++++++++++++++++++++++++++++++++ Server/AI/Orders/AI_WPAdd.sqf | 39 +++++++++++++++++++++ Server/AI/Orders/AI_WPRemove.sqf | 6 ++++ 5 files changed, 167 insertions(+) create mode 100644 Server/AI/Orders/AI_MoveTo.sqf create mode 100644 Server/AI/Orders/AI_Patrol.sqf create mode 100644 Server/AI/Orders/AI_TownPatrol.sqf create mode 100644 Server/AI/Orders/AI_WPAdd.sqf create mode 100644 Server/AI/Orders/AI_WPRemove.sqf (limited to 'Server/AI/Orders') diff --git a/Server/AI/Orders/AI_MoveTo.sqf b/Server/AI/Orders/AI_MoveTo.sqf new file mode 100644 index 0000000..e372393 --- /dev/null +++ b/Server/AI/Orders/AI_MoveTo.sqf @@ -0,0 +1,17 @@ +private ["_destination","_mission","_radius","_team","_update"]; +_team = _this select 0; +_destination = _this select 1; +_mission = _this select 2; +_radius = if (count _this > 3) then {_this select 3} else {30}; + +_update = true; +if (side _team == west || side _team == east) then { + _update = (_team) Call CanUpdateTeam; +}; + +//--- Override. +if (_update) then {_team Call UpdateTeam}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_MoveTo: The %1 %2 Team is moving to %3",side _team,_team,_destination,diag_frameno,diag_tickTime]; + +[_team,true,[[_destination, _mission, _radius, 20, "", []]]] Call AIWPAdd; \ No newline at end of file diff --git a/Server/AI/Orders/AI_Patrol.sqf b/Server/AI/Orders/AI_Patrol.sqf new file mode 100644 index 0000000..8cff904 --- /dev/null +++ b/Server/AI/Orders/AI_Patrol.sqf @@ -0,0 +1,34 @@ +Private ["_destination","_maxWaypoints","_pos","_radius","_rand1","_rand2","_team","_type","_update","_wps","_z"]; +_team = _this select 0; +_destination = _this select 1; +_radius = if (count _this > 2) then {_this select 2} else {30}; +if (typeName _destination == 'OBJECT') then {_destination = getPos _destination}; + +_update = true; +if (side _team == west || side _team == east) then { + _update = (_team) Call CanUpdateTeam; +}; + +//--- Override. +if (_update) then {_team Call UpdateTeam}; + +_maxWaypoints = 8; +_wps = []; +for [{_z=0},{_z<=_maxWaypoints},{_z=_z+1}] do { + _rand1 = (random _radius) - (random _radius); + _rand2 = (random _radius) - (random _radius); + _pos = [(_destination select 0)+_rand1,(_destination select 1)+_rand2,0]; + _tries = 100; + while {surfaceIsWater _pos && _tries > 0} do { + _tries = _tries - 1; + _rand1 = (random _radius) - (random _radius); + _rand2 = (random _radius) - (random _radius); + _pos = [(_destination select 0)+_rand1,(_destination select 1)+_rand2,0]; + }; + _type = if (_z != _maxWaypoints) then {'MOVE'} else {'CYCLE'}; + _wps = _wps + [[_pos,_type,35,40,"",[]]]; +}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_Patrol: The %1 %2 Team is patrolling at %3",side _team,_team,_destination,diag_frameno,diag_tickTime]; + +[_team, true, _wps] Call AIWPAdd; \ No newline at end of file diff --git a/Server/AI/Orders/AI_TownPatrol.sqf b/Server/AI/Orders/AI_TownPatrol.sqf new file mode 100644 index 0000000..15122d3 --- /dev/null +++ b/Server/AI/Orders/AI_TownPatrol.sqf @@ -0,0 +1,71 @@ +/* + Author: Benny + Name: AI_TownPatrol.sqf + Parameters: + 0 - Team + 1 - Town + 2 - (Radius) + Description: + This file is called upon a resistance / occupation patrol, AI will randomly patrol in towns, including the camps and the depots. +*/ + +Private ['_camps','_insert','_insertObject','_insertStep','_maxWaypoints','_pos','_radius','_rand1','_rand2','_team','_town','_townPos','_type','_update','_usable','_wpcompletionRadius','_wpradius','_wps','_z']; +_team = _this select 0; +_town = _this select 1; +_radius = if (count _this > 2) then {_this select 2} else {30}; +if (typeName _town != 'OBJECT') exitWith {diag_log Format ["[WFBE (ERROR)] AI_TownPatrol: Object expected, %1 given",_town]}; +if (isNull _team) exitWith {diag_log Format ["[WFBE (ERROR)] AI_TownPatrol: Null Groups cannot be used (Town: %1)",_town]}; +_townPos = getPos _town; + +_camps = _town getVariable 'camps'; + +_usable = [_town] + _camps; +_maxWaypoints = ('WFBE_TOWNPATROLHOPS' Call GetNamespace) + count(_usable); +_wps = []; + +//--- Randomize the behaviours. +if (random 100 > 50) then {_team setFormation "DIAMOND"} else {_team setFormation "STAG COLUMN"}; +if (random 100 > 50) then {_team setCombatMode "YELLOW"} else {_team setCombatMode "RED"}; +if (random 100 > 50) then {_team setBehaviour "AWARE"} else {_team setBehaviour "COMBAT"}; +if (random 100 > 50) then {_team setSpeedMode "NORMAL"} else {_team setSpeedMode "LIMITED"}; + +//--- Dyn insert. +_insertStep = if (count(_usable) != 0) then {floor(_maxWaypoints / count(_usable))} else {-1}; +_insert = _insertStep; +_insertObject = objNull; +_wpradius = -1; +_wpcompletionRadius = -1; + +for [{_z=0},{_z<=_maxWaypoints},{_z=_z+1}] do { + if (_z == _insert && count _usable > 0) then { + _insert = _insert + _insertStep; + _insertObject = _usable select (round(random((count _usable)-1))); + _usable = _usable - [_insertObject]; + }; + + if (isNull _insertObject) then { + _rand1 = random _radius; + _rand2 = random _radius; + _pos = [(_townPos select 0)+_rand1,(_townPos select 1)+_rand2,0]; + _tries = 100; + while {surfaceIsWater _pos && _tries > 0} do { + _tries = _tries - 1; + _rand1 = random _radius; + _rand2 = random _radius; + _pos = [(_townPos select 0)+_rand1,(_townPos select 1)+_rand2,0]; + }; + _wpradius = 32; + _wpcompletionRadius = 44; + } else { + _pos = getPos _insertObject; + _wpradius = 35; + _wpcompletionRadius = 68; + }; + + _type = if (_z != _maxWaypoints) then {'MOVE'} else {'CYCLE'}; + _wps = _wps + [[_pos,_type,_wpradius,_wpcompletionRadius, "", []]]; +}; + +diag_log Format["[WFBE (INFORMATION)][frameno:%4 | ticktime:%5] AI_TownPatrol: The %1 %2 Team is patrolling the %3 town",side _team,_team,_town,diag_frameno,diag_tickTime]; + +[_team, true, _wps] Call AIWPAdd; \ No newline at end of file diff --git a/Server/AI/Orders/AI_WPAdd.sqf b/Server/AI/Orders/AI_WPAdd.sqf new file mode 100644 index 0000000..ad04518 --- /dev/null +++ b/Server/AI/Orders/AI_WPAdd.sqf @@ -0,0 +1,39 @@ +/* + Author: Benny + Name: AI_WPAdd.sqf + Parameters: + 0 - Team + 1 - Clear (Remove WPs) + 2 - Waypoints (given in an Array) + Description: + This file is used to give a detailed WP system. + Exemple: + [_team, true, [[getPos _camp, 'MOVE', 10, 20, "", []],[[1560,2560,0], 'SAD', 50, 70, "", ["canComplete", "this sidechat 'lets roll'"]]...]] Call AddWP; +*/ + +Private ['_clear','_completionRadius','_position','_radius','_scripted','_statements','_team','_type','_waypoint','_waypoints','_WPCount']; +_team = _this select 0; +_clear = _this select 1; +_waypoints = _this select 2; + +if (_clear) then {_team Call AIWPRemove}; + +{ + _position = _x select 0; + _type = _x select 1; + _radius = _x select 2; + _completionRadius = _x select 3; + _scripted = _x select 4; + _statements = _x select 5; + if (typeName _position == 'OBJECT') then {_position = getPos _position}; + + _WPCount = count (waypoints _team); + + _team addWaypoint [_position,_radius]; + [_team, _WPCount] setWaypointType _type; + [_team, _WPCount] setWaypointCompletionRadius _completionRadius; + if (_type == 'SCRIPTED') then {[_team, _WPCount] setWaypointScript _scripted}; + if (count _statements > 0) then {[_team, _WPCount] setWaypointStatements [_statements select 0, _statements select 1]}; + + if (_WPCount == 0) then {_team setCurrentWaypoint [_team, _WPCount]}; +} forEach _waypoints; \ No newline at end of file diff --git a/Server/AI/Orders/AI_WPRemove.sqf b/Server/AI/Orders/AI_WPRemove.sqf new file mode 100644 index 0000000..a02a1e2 --- /dev/null +++ b/Server/AI/Orders/AI_WPRemove.sqf @@ -0,0 +1,6 @@ +Private ['_team','_z']; +_team = _this; + +for [{_z = (count (waypoints _team))-1},{_z > -1},{_z = _z - 1}] do { + deleteWaypoint [_team, _z]; +}; \ No newline at end of file -- cgit v1.3.1