Jump to content
Sign in to follow this  
TRexian

JTD Building Search script

Recommended Posts

JTD Building Search script (Updated to version .01g)

This is a WIP script that will send members of an AI squad into an enterable building, and sequentially search through the building positions. It was developed in an effort to take advantage of all the enterable buildings that have been introduced into ArmA, and cultivate more of a CQB atmosphere.

First - credits:

OFPEC - one of the best resources available IMHO

Rommel for CBA function searchNearby

Tophe for random house patrol

--- http://forums.bistudio.com/showthread.php?t=76423

Seriously, this script began by borrowing heavily from Rommel's CBA function, and was directly inspired by Tophe's house patrol. Any direct benefit people may get from this is really a product of those guys' work.

Second - methodology:

The script (which can be called as a function) receives at least one parameter - the group - with options for 3 other parameters - search distance, nearest building or a random one, and an initial position for the search for buildings. The script will create an array of buildings, select one, then create a waypoint for the group to a spot near that building. Upon reaching the waypoint, the leader of the group will remain outside, while members of the group enter the building, in combat mode. If there are more building positions than searchers, all available units other than the leader will enter the building.

The searchers will basically trail through the building - not bound/overwatch. When the last building position is reached, the searchers will rejoin the leader.

Third - a vid of a slightly older version of the script (the searching starts about a minute into it):

lc0ZFdGldzE

Finally - a download:

http://www.mediafire.com/file/e6wuq2e5c7v8tt6/JTD_buildingSearchPackage_0124.7z

(ArmaHolic)

http://www.armaholic.com/page.php?id=13130

And the script itself (somewhat heavy on comments):

/* JTD Building Search Script
by Trexian

Purpose: have an AI squad search a building.

Implementation: executed from trigger or script (can be as a function)
ooooooooooooooooooooooooooooooooooooooooooooooooooo
Usage:
Requires 1 parameter, with an option for 4 more: group(, searchRadius , "NEAREST" or "RANDOM", initial position, include leader, occupy building)
group = group that will be searching the building (required)
searchRadius = number that is radius around the leader to use to generate the array of buildings (default is 50) (optional)
NEAREST/RANDOM = string that tells the script which building, either the nearest to the position or a random one (default is random) (optional)
initial position = position array or object  around which to search (default is leader's position at script execution) (optional)
include leader = boolean, where 'true' includes the leader in the search (default is false, but if group has 2 or less, default is true) (optional)
occupy building = boolean, where 'true' means that the group will stay in the building positions (default is false)

ooooooooooooooooooooooooooooooooooooooooooooooooooo
Credits:
OFPEC
Rommel for CBA function searchNearby
Tophe for random house patrol

Testers/Feedback:
MadRussian
GvsE
Kremator
Manzilla
ooooooooooooooooooooooooooooooooooooooooooooooooooo
Version:
01a
POC (addWaypointHousePosition doesn't work)

01b
used CBA searchNearby by Rommel for commandMove instead of waypoints

01c
Improved methodology

01d - release version
Improved the rejoining of the searchers
Added ability to specify initial position of building search

01e
Added optional parameter to include leader in search, also an option to occupy the building
More robust error-checking
Can pass object instead of intialposition
Shuffles searcher array

01f - release version
Added server check
Added global JTD_lockedSearchGroups
Added time check to make sure script ends at some point

01g - release version
Added JTD_bldgsrchPath as variable for Manzilla
Array functionality wrapper

ooooooooooooooooooooooooooooooooooooooooooooooooooo
TTD:

ooooooooooooooooooooooooooooooooooooooooooooooooooo
*/

if !(isServer) exitWith {diag_log text "Not server, exiting building search.";};

//diag_log text "JTD bldg search activated";

private ["_grpFM", "_FunctionsManager", "_group", "_leader", "_ldrPos", "_behaviour", "_srchRad", "_whichOne", "_initialPos", "_andOne", "_occupy", "_bldgArray", "_tempArray", "_bldgLoc", "_bldgSelect", "_searchersT", "_searchers", "_searcherCount", "_s", "_checkTime", "_wpArray", "_currWP", "_wpCnt", "_d", "_t", "_b", "_bldg", "_bldgPos", "_bldgCnt", "_nameMarker", "_marker", "_bldgBB", "_wpRad", "_wp", "_p", "_totTime", "_activeBP", "_loop", "_cycle", "_unitSelect", "_units"];

if (isNil "JTD_bldgsrchPath") then {JTD_bldgsrchPath = "";};

// check for functions
if (isNil "bis_fnc_init") then
{
createCenter sideLogic;
_grpFM = createGroup sideLogic;
_FunctionsManager = _grpFM createUnit ["FunctionsManager", [1, 1, 1], [], 0, "NONE"];
waitUntil {!isNil "bis_fnc_init"};
};

if (isNil "JTD_arrayShuffleFunc") then
{
JTD_arrayShuffleFunc = compile preprocessFileLineNumbers (JTD_bldgsrchPath +"JTD_arrayShuffle.sqf");
};

if (isNil "JTD_lockedSearchGroups") then {JTD_lockedSearchGroups = [];};

_group = _this select 0;
JTD_lockedSearchGroups = JTD_lockedSearchGroups + [_group];
if ((typeName _group) == "OBJECT") then {_group = group (_this select 0)};

//diag_log text format ["group searching: %1", _group];
_leader = leader _group;
//diag_log text format ["group leader: %1", _leader];
_ldrPos = getPos _leader;
_behaviour = behaviour _leader;
if ((count _this) >= 2) then {
_srchRad = _this select 1;}
else {
_srchRad = 50;};
if ((count _this) >= 3) then {
_whichOne = _this select 2;
} else {
_whichOne = "RANDOM";};
if ((count _this) >=4) then {
_initialPos = _this select 3;
} else {
_initialPos = _ldrPos;};
if ((count _this) >=5) then {
_andOne = _this select 4;
} else {
_andOne = false;};
if ((count _this) >=6) then {
_occupy = _this select 5;
} else {
_occupy = false;};

_bldgArray = [];
_tempArray = [];
_bldgLoc = [];
_bldgSelect = [];
_searchersT = [];
_searchers = [];
_searcherCount = 0;
_s = 0;

// error catching
if (isNil "_leader") exitWith
{
diag_log text "No valid leader selected!";
false
};
if (isNil "_srchRad") then {_srchRad = 50};
if (_srchRad < 1) then {_srchRad = 1};
if (isNil "_whichOne") then {_whichOne = "RANDOM"};
if ((_whichOne != "NEAREST") || (_whichOne != "RANDOM")) then {_whichOne = "RANDOM"};
if (isNil "_initialPos") then {_initialPos = _ldrPos};
if ((typeName _initialPos) == "OBJECT") then {_initialPos = getPos (this select 3)};
if ((typeName _initialPos) != "ARRAY") then {_initialPos = _ldrPos};
if (isNil "_andOne") then
{
if ((count (units _group)) < 3) then
{
	_andOne = true;
}
else
{
	_andOne = false;
};
};
if ((typeName _andOne) != "BOOL") then {_andOne = false};
if (isNil "_occupy") then {_occupy = false};
if ((typeName _occupy) != "BOOL") then {_occupy = false};

// gets time that script starts
_checkTime = daytime;

// remove group's waypoints
_wpArray = waypoints _group;
//_currWP = currentWaypoint _group;
_wpCnt = count _wpArray;

if (_wpCnt > 1) then
{
for [{_d = 0}, {_d <= _wpCnt}, {_d = _d + 1}] do
	{
		deleteWaypoint [_group, _d];
	};
};

// building check
_tempArray = nearestObjects [_initialPos, ["HOUSE"], _srchRad];
_t = count _tempArray;  // count number of buildings in array

//for each building, find building position
//this should serially select each building in the array, then remove it if position 0 (1) is 0,0,0

_t = _t - 1;

for [{_b = 0},{_b <= _t},{_b = _b+1}] do
{
_bldg = _tempArray select _b;
_bldgPos = _bldg buildingPos 0;

if (((_bldgPos select 0) != 0) && ((_bldgPos select 1) != 0)) then
 {
 _bldgArray = _bldgArray + [_bldg];
 };
};

_bldgCnt = count _bldgArray;
if (_bldgCnt == 0) exitWith 
{
diag_log text "No buildings to search!";
false
};

// select building - either the nearest or the randomest
if (_whichOne == "NEAREST") then
{
_bldgSelect = _bldgArray select 0;		// need to do a real distance check?
//_bldgSelect = nearestBuilding (getPos _leader);
}
else
{
_bldgSelect = _bldgArray call BIS_fnc_selectRandom;
};

_bldgLoc = getPos _bldgSelect;

if (JTD_searchDebug) then
{
_nameMarker = format ["srch_%1", str _bldgSelect];
_marker = createMarkerLocal [_nameMarker, [_bldgLoc select 0, _bldgLoc select 1]];
_marker setMarkerShapeLocal "ICON";
_marker setMarkerTypeLocal "dot";
_marker setMarkerColor "ColorRed";
};

// set new waypoint for near the building for the group
_bldgBB = boundingBox _bldgSelect;		// [[minX, minY, minZ], [maxX, maxY, maxZ]] 
_wpRad = ((abs((_bldgBB select 0) select 0) + abs((_bldgBB select 1) select 0)) max (abs((_bldgBB select 0) select 1) + abs((_bldgBB select 1) select 1))) + 10;	// gets the longest side of the building + 10
_wp = _group addWaypoint [_bldgLoc, _wpRad];
_wp setWaypointPosition [_bldgLoc, 1];
_wp setWaypointType "MOVE";
_group setCurrentWaypoint _wp;

//_group lockwp true;
waituntil {unitready _leader};

_group setbehaviour "combat";

// find building position max
_p = 0;		// will end up being the total number of building positions
while {str(_bldgSelect buildingPos _p) != "[0,0,0]"} do {_p = _p + 1;};

// check if more units than positions (or equal), if so, select which ones to search
// gets the lesser of available units or positions

_totTime = _p * .009;		// roughly 30 seconds per position
scopeName "bldgSearchMainScope";
// loop through each unit to identify the searchers
if (_andOne) then
{
_searcherCount = (count (units _group)) min _p;
_s = 0;
}
else
{
_searcherCount = ((count (units _group)) - 1) min _p;
_s = 1;
};
//diag_log text format ["searchers = %1  (%2, %3)", _searcherCount, ((count (units _group)) - 1), _p];
while {_s <= _searcherCount} do
{
	if !(isNull ((units _group) select _s)) then
	{
		// start at #2 (which is select 1) and add searchers up to number of house positions
		_searchersT = _searchersT + [(units _group) select _s];
	};
	_s = _s + 1;
};

// shuffle
//diag_log text format ["searcher temp array = %1", _searchersT];
_searchers = [_searchersT] call JTD_arrayShuffleFunc;
//diag_log text format ["searcher array = %1", _searchers];
// loop to string out the units

_activeBP = 0;		// building position iterator
while {_activeBP < _p} do
{
_s = 0;			// searcher iterator
_loop = 0;
// searcher assignment loop
_cycle = _activeBP;	// cycle through searchers based on house position number
while {_loop <= _activeBP} do
{
	_bldgPos = _bldgSelect buildingPos _cycle;
	_unitSelect = _searchers select _s;
	//diag_log text format ["unit select %1 bpos %2 %3", _unitSelect, _bldgPos, _cycle];
	 if (unitready _unitSelect) then
	{
		_unitSelect commandmove _bldgPos;
		//_unitSelect domove _bldgPos;
		_unitSelect spawn 
		{
			sleep 5;
			waituntil {unitready _this};		// try without this, too?
		};
	};
	_s = _s + 1;
	if (_s >= (count _searchers)) then {_loop = _activeBP};	// break out of loop if out of searchers
	_cycle = _cycle - 1;
	_loop = _loop + 1;

	// time check
	if (daytime > (_checkTime + _totTime)) then
	{
		breakTo "bldgSearchMainScope";
		if (JTD_searchDebug) then
		{
			diag_log text "Building search taking too long, exiting";
		};
	};
	if (! alive (leader group (_searchers select _s))) then
	{
		breakTo "bldgSearchMainScope";
		_occupy = false;
		if (JTD_searchDebug) then
		{
			diag_log text "No leader of search group";
		};
	};
};
_activeBP = _activeBP + 1;
};

//diag_log text "Out of bldgSearch loop";

_group setbehaviour _behaviour;

// check if occupy is specified
if !(_occupy) then
{

// need some sort of wait to make sure they are ready
//waituntil {sleep 3; {unitready _x} count _units == count (units _group) - 1};
_ldrPos = getPos _leader;
{
	//diag_log text format ["srcher loop  %1", _x];
	_x doMove _ldrPos;
	waitUntil {moveToCompleted _x};
	_x doFollow _leader;

} foreach _searchers;
};
// waituntil ??

//_group lockwp false;
JTD_lockedSearchGroups = JTD_lockedSearchGroups - [_group];
//diag_log text "bldg srch ended";
true

Edit:

The arrayShuffle script that is also necessary now:

// JTD_arrayShuffle

private ["_array", "_count", "_arrayT", "_arrayN", "_c", "_r"];

_array = _this select 0;
_count = count _array;
_arrayN = [];
_arrayT = [];
_c = 0;
_r = 0;

while {_c < (count _array)} do
{
while {_r in _arrayT} do
{_r = floor (random (count _array));
};
_arrayT = _arrayT + [_r];
_arrayN set [_c, _array select _r];
_c = _c + 1;
};

_arrayN

Block search script:

// JTD block search

private ["_groupSelect", "_posSelect", "_radSrch", "_houseArray", "_c", "_searchFunc", "_nameMarker", "_marker"];

diag_log "Block search started";

if (isNil "JTD_bldgSearchFunc") then
{
JTD_bldgSearchFunc = compile preprocessFileLineNumbers "JTD_buildingSearch.sqf";
};

// needs group, position and radius
_groupSelect = _this select 0;
if ((typeName (_groupSelect)) == "OBJECT") then {_groupSelect = group (_this select 0)};
_posStart = _this select 1;
_radSrch = _this select 2;
_houseArray = [];
_c = 0;
diag_log text format ["groupSelect: %1", _groupSelect];


while {alive (leader _groupSelect)} do
{
// building check
_houseArray = nearestObjects [_posStart, ["HOUSE"], _radSrch];

{
	_posSelect = getPos _x;
		diag_log text format ["selected position: %1", _posSelect];
	_searchFunc = [_groupSelect, 10, "NEAREST", _posSelect, true, false] execVM "JTD_buildingSearch.sqf";
	if (JTD_searchDebug) then
	{
		_c = _c + 1;
		_nameMarker = format ["srch_%1", str _c];
		_marker = createMarkerLocal [_nameMarker, [_posStart select 0, _posStart select 1]];
		_marker setMarkerShapeLocal "ICON";
		_marker setMarkerTypeLocal "dot";
		_marker setMarkerSizeLocal [10, 10];
		_marker setMarkerColor "ColorGreenAlpha";
	};		
	waituntil {scriptDone _searchFunc};
} forEach _houseArray;
sleep (random 60) + 60;
};

This is very much a Work In Progress, but the 7z contains a test mission and the current version of the script. With the test mission, the player has a couple minutes to move around. An array of his positions is created. The 6 opfor groups will randomly select one of those positions and search a nearby building. The mission is rather slow (there is also a playable civilian, if you want to watch), but you can get an idea of how it works.

The parameters used in the mission are:

_searchFunc = [_grpSelect, 20, "NEAREST", _posSelect] call JTD_bldgSearchFunc;

Edit: there are several now!

Oh, and the mission will spam your rpt with information. That's why it is a test mission. ;)

Feedback is greatly appreciated. :)

============================

JTD:

-- DMarkwick

-- ReconPathFinder

-- TRexian

Edited by TRexian

Share this post


Link to post
Share on other sites

That depends on certain AI settings, but from my own experience, they sure shoot me!

Now, having said that, I usually run the betas, and some betas have the AI more aggressive than others. With one of the recent patches, I could (as blufor) walk around and through a group of opfor for several seconds before getting shot. With the most recent one, though (the one from yesterday), I was shot almost immediately.

This script will put the group into combat mode. However, it is also dependent on the ROE/weapons free status, which this script does not change. Also, if they are engaged from outside the building during the search, they will react according to the BI FSMs for contact.

I have not explored all the permutations of what happens during significant contact during the search. With the test mission, I am eventually tracked down, and can take out a couple of the searchers, but am relatively soon afterward killed.

But, I am not a particularly good player. :)

Share this post


Link to post
Share on other sites

haha

Thanks, but don't worry - that feeling will wear off. ;)

When you get to the point where you have ideas on how to improve it, let us know. :D

Share this post


Link to post
Share on other sites

great! Will this be initialised by default in any misison or does it have to be activated by the creator of the mission?

Share this post


Link to post
Share on other sites

Thanks Foxhound!

It must be initiated by the mission creator. In fact, I'd say it is probably for somewhat advanced mission makers, although I tried to make it as easy as possible.

The main problem is, what to do with groups after the search? Any existing waypoints are deleted, so new ones have to be re-generated.

I suspect that one thing I will need to develop is a 'wrapper' of some sort that allows mission makers to easily craft after-search behavior. Perhaps the easiest way is to have a waypoint that runs the script, after which the group returns to the waypoint system.

Or, as DMarkwick has tried, I believe it can integrate rather well with DAC3 behavior.

Share this post


Link to post
Share on other sites

I suspect it will work very well with ups and upsmon aswell since those create their own wps in runtime, when current wp/wps are completed.

Share this post


Link to post
Share on other sites

This is great. I tried this with the latest Arma2OA beta 157.077007 and all works very well. They found me on the top room of a building in Zargabad. Scared the shit out of me, when they came up the stairs.

Thanks for the hard work.

Share this post


Link to post
Share on other sites

@ Demonized

If it does, please let me know - I'd be very interested!

The script itself does have some waituntil logic built in, so it should not 'end' until the searchers are back in proximity to the leader of the group. So, a strategically placed scriptDone can be very effective at determining when the searchers are 'free'. :)

@ the chief

Thanks! Glad you like it.

Share this post


Link to post
Share on other sites

Very nice! IIRC, in Tophe's the AI were just placed into a building and were restricted simply to that building. This appears much more versatile!

The searchers will basically trail through the building - not bound/overwatch. When the last building position is reached, the searchers will rejoin the leader.

So when you say "trail through the building", do the AI go to the building positions in order, or is it random? Also, any chance of getting the leader to enter the buildings too? That would be really useful, but harder to get it scripted I assume.

Share this post


Link to post
Share on other sites

Once a group has searched the building, is the group meant to continue to sweep other buildings (if placed on Random) ? If not that search radius would be VERY useful.

Share this post


Link to post
Share on other sites

@ MadRussian-

Tophe's would basically have AI dedicated to a building, and patrol within that building. Yeah, I needed something that would have them search a building, then leave. The trail is basically set up so that one guy will have 'point.' He will sequentially go through each building position. The next unit in the group will follow him, and be 1 building position behind him. And so on, until there are no more units (only the leader), or there are no more building positions. When the point guy gets to the last waypoint, they all leave. The last guy would never make it to the last waypoint, if that makes sense.

I could probably include another element to make the leader search, too, but I'm not sure that makes sense? :) Convince me! Why would you want the leader to search, too? :D

@ Kremator-

This script would need an additional 'overlay' script to search an array of buildings. I am working up one of those, and will share it here. :)

Share this post


Link to post
Share on other sites

Wow! Guess I'll see for myself when I get a chance to fire it up, but from your description it more or less sounds like they really storm the building!

Couple of other quick suggestion I can think of:

1. How about shuffling the order of building positions upon each call, so we don't start to recognize the sequence that particular buildings get stormed?

2. Maybe an optional parameter that upon sending the men into the building, they stay there and occupy it indefinitely? Perhaps for indefinite occupation, another function call causes them to exit?

Regarding having the leader go in too, there are plenty of times where I only have one man in a group, for instance when creating a bunch of small groups in DAC and then releasing them from DAC. Many of those groups end up with only 1 man, and it would be nice to have him go in too. Maybe make it an optional parameter? Because I can also see how if you do have a group with more than one, that the leader might indeed want to "order his men in" and keep himself out of danger, etc. In any event, optional seems best to me. :)

btw- Thanks for putting this together. I think it's really going to come in handy.

Share this post


Link to post
Share on other sites

Hmmm... Ok MR, you've gotten me thinking more deeply about this. ;)

1 - In terms of building position sequence, my ideal solution would be to work out a true ordering of them, in a pathfinding context, that would make sense. Something like, clear all the first level positions, then second, etc. In the absence of that, I'm afraid that any random ordering of the building positions would have the AI cross paths with each other too much. My first attempts had the AI bumping into each other and getting confused.

2 - I think that behavior can be achieved by integrating this with Tophe's building patrol script to get them to occupy the building. Then, to get them to leave, it would be a matter of having them rejoin the leader, then receiving their new waypoints. Since this script envisions having a 'wrapper' script (or some other mission structure), I can probably work up some way to do this - similar to the neighborhood search wrapper that I'm planning.

3 - The Leader Question. :) Your point about very small groups is pretty compelling actually. I'm a big fan of dynamic missions, so I see your point about 1 or 2-man groups. What I can probably do is check the size of the group, if it is less than 2, then the leader will automatically be included in the searchers. Or, have another boolean that can force the leader to be included.

Edit:

Oh - does it matter to you if the leader actually leads the search, if he is going to take part in it? I think that would be a bad policy IRL, but, at the same time, if it is only 2 guys, I could also see a leader wanting to lead....

Edited by TRexian

Share this post


Link to post
Share on other sites

Well as we discussed in another place Tom, I think that not only should the leader not be part of the search, but that he not remain alone outside while it's done :) however I acknowledge the small-group problem, maybe a cut-off of 4-man groups would separate leader-led searches from leader-excluded searches. So 4 man groups would search a house with all it's members, a 5 man group would use 3 searchers and a leader with one defending unit. Maybe it starts to get a little complicated :)

On the other hand, DAC might represent a specific situation requiring a specific solution. One representative unit (which DAC engineers at distance) would need to be built up just for the search. On the other hand, a DAC unit only needs to be built up when in the presence of enemy, so maybe it's a moot point :D why even make a distant reduced DAC group search? Maybe it should be built-up behavior only. Tell you what, you do the building search logic and I'll apply the DAC logic :D

Edited by DMarkwick

Share this post


Link to post
Share on other sites

Hello,

I thank you kindly for the script and the mission which in itself was really fun!

And here's my question (and I apologize for it's noobish nature as I'm only a beginner mission maker):

Could the script be initialized via a trigger? Say, when blufor detected, opfor AI starts searching all available buildings?

I also think this script could work well with UPSMON: they already have a "reinforcement" function where AI go to the area where enemy was detected. Your script could really nicely complement that.

Again, sorry if what Im saying is gibberish. Anyways, great job!

Share this post


Link to post
Share on other sites

@ DM

haha Yeah, but I'm trying to avoid a complicated DAC-esque paramter set! :) I have modified (subject to testing) the ability to include the leader as a searcher. Optional is good. I figure the leader is a combat soldier, too, so he can f'n fend for himself. :)

@ GvsE

Actually, it can be initialized by a trigger, and that was really how I first intended it! But, the issue there is that once the group has finished the search, it would take some other sort of monitor script - or some fancy trigger-scripting that I'm not familiar with - to re-generate waypoints for them.

The method I used for the trigger was to have this on activation:

srch = [(group (thislist select 0)), 50, "NEAREST"] execVM "JTD_buildingSearch.sqf";

That will use the group of the first element to activate the trigger, get the leader's position, then search 50m around that position and use the nearest enterable building as the target for the search.

Hope that helps!

I'd also be very interested if anyone can post integration with things like UPS/UPSMON/DAC3.

Share this post


Link to post
Share on other sites

Oh, that was a quick response! :)

I think a temporary solution in a trigger activated script could be to have only one or two specified fireteams devoted solely to house-searching. Considering that, what do you think should be the activation code for a group called e.g. "team1"?

Share this post


Link to post
Share on other sites

I've tried to get my head around that, too.

If it is a single team, it is easier. You can get the position you want them to search from the detected by (I've never done that)? If so, I think it would be something like this, where _initialPosition is the position you want them to search near:

srch = [team1, 50, "NEAREST", _initialPosition] execVM "JTD_buildingSearch.sqf";

Now, the complication with having more than one search group, is that it is difficult to tell when one search group has finished. I don't think you want to interrupt a search to start a new search? The only way I know of to do that is to have some sort of script either monitoring the group itself, or monitoring the script to determine when it is finished running, then allowing that group to be used again.

I am open to suggestions, though! And, if you figure out some way to accomplish what you want, please post it so that I (and others) :) can learn from your experience!

Edit:

Oh, and to have one group search multiple buildings, you first have to generate an array of buildings, then have it loop through the array. I hope to have an example of that posted by the end of the coming weekend.

Share this post


Link to post
Share on other sites

So is it possible that an AI team could 'find' an enemy inside a building then instigate a further searching of that house, or others nearby ?

Looking forward to testing the latest version in my Fallujah VTS :)

Share this post


Link to post
Share on other sites

@ Kremator

Yes, theoretically.

However, in that case, the trick(s) would be:

- figuring out when an AI team 'finds' an enemy

- what radius to search

The only way I know of to do this is to have a script monitoring the knowsAbout value, or some sort of findNearestEnemy or nearEntities loop that catches when the group 'finds' the enemy.

Once that condition is met, you'd have a position and group, so the only thing is to figure out how big of a radius you want to search, let's say 100m.

I would then have the monitor script spawn another script to search all those areas. (This is a sketch of the 'wrapper' I'm going to try to make.)

- Create an array of all the buildings within that radius.

- Have a forEach loop of that array that uses the position of _x, and a very small search radius - like 5 - for the building search script, set to NEAREST. We know that there will be only 1 building near to that location, and we want it to be specific.

- Have the script either waitUntil the group is ready again, or scriptDone (not sure which at this point) before continuing to the next building in the forEach loop.

That should get the one unit to search a neighborhood.

Multiple search groups trying to search the same set of buildings would increase the complexity, but can be done. The way I would do that would be an array of available groups - take them out of the array when they are being tasked to search the building, then add them back in when they are done. Maybe even have the monitor script determine what building in the to-search array is closest to the group, and have them move on to that one.

Something like that.

BTW, part of the motivation for this script is a mission I'm creating in Fallujah. Great map! ;) One thing I've noticed, though, is that some of the building positions are... incomplete. There's one building that has the exterior stairs that go up to a covered terrace, then out to an open balcony area - I don't think there are any buildingPositions past the staircase. AI don't seem to want to go into the terrace or balcony area.

Share this post


Link to post
Share on other sites

Thanks again for the answer.

Another quick question:

Can I substitute _initialPosition with the ID number of the building I want AI to search (it's a pretty big building)?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×