Jump to content
Sign in to follow this  
TRexian

JTD Building Search script

Recommended Posts

@ FH-

haha Sorry - was interrupted in my PM'ing. :)

Is it possible to organize the files in to a folder structure? May like a JTD_Building folder.

Yeah, what I'll probably do is module-ize it. That is, have a script setup that people can just copy/paste, and have a module that can be placed on the map that allows access to the scripts.

I think that will solve what you want? :)

Share this post


Link to post
Share on other sites

That would be fine too. I personally like script form better so I can keep it contained in the mission. That way people don't have to DL any content for the missions I make. It's not a big deal though.

Share this post


Link to post
Share on other sites

Heya Manzy-

I was thinking more about this, and I think I have an idea how to implement it. I could have a global variable that basically contains the path prefix - JTD_bldgsrchPath or somesuch. It could be defined either in an init.sqf or even the init field of a unit, probably. It would default to "", so it would presume that it was in the mission folder. But, if you set it to "\scripts\" then I *think* it would look in the scripts subfolder of the mission.

I'll test this idea, and look to implement it in the next version, if you think it would fit your requirements. :thumbsup:

Share this post


Link to post
Share on other sites

You could maybe use a logic unit that defines the script as internal (PBO) or external (script with path)? That way you could use default PBO settings as default for some areas and custom search scripts in others.

Share this post


Link to post
Share on other sites

I like the new version. Few things, it seems the fired EH only works when I stand in front of the AI and shoot then they react and start to building search.(maybe it is just me) Is it possible to use the firednear so if I fire close enough from the enemy they will react? Also with the 'all units occupy', do they occupy my 5 last known positions? Can I have them occupy a certain radius or specific buildings? All these possiblities would be great to add to the immersion. I look forward to 50% or more of zargabad buildings being occupied and 'controlled' by enemy forces. Patrols on foot in the streets while occasionaly entering buildings to clear them. If shots are fired the units that hear will respond to the area and start occupying and clearing buildings

So far all the building search stuff is working great. I dont see the 'blockSearchers' doing anything anymore.

Share this post


Link to post
Share on other sites

First - thanks for the feedback! :)

... it seems the fired EH only works when I stand in front of the AI and shoot then they react and start to building search.(maybe it is just me) Is it possible to use the firednear so if I fire close enough from the enemy they will react?

Well, the way I opted to set it up uses the findNearestEnemy command. So, it may take a second for it to register that you 'know' about an enemy group. However, what I would do is go into a building and wait for a group to come near. I would just watch them, then shoot into a wall, not really toward them. The script would trigger them to start searching for me.

Also with the 'all units occupy', do they occupy my 5 last known positions?

Sorta - it is based on time. So, if you stay in one position for too long, all the array slots will be the same position. :) You have an interesting point, though.... I could probably impose a check to only increment the array if the last point is far enough away. I kinda like the idea of staying in one place too long poses a risk. Anti-camping, I guess. :)

Can I have them occupy a certain radius or specific buildings?

Yes. By specifying a specific building position, with a very small search radius, you can get to very specific buildings.

I am working on a version where you can send an array of groups to an array of buildings. That might be more what you are interested in. If there are more groups than buildings, then a random selection of the groups will go to the buildings. If more buildings than groups, the groups will sequentially search the buildings. (When I get it to work.) ;)

So far all the building search stuff is working great. I dont see the 'blockSearchers' doing anything anymore.

Well, it may make a comeback!

Share this post


Link to post
Share on other sites

Working up the documentation for this, as I continue to test different aspects. Last night's testing went well, so I am comfortable that this is what the next iteration will include. Just need to finalize a few things (like whether to modularize it or not at this point).

Building Search Script Suite documentation

Background:

The basic element of this script is JTD_buildingSearch.sqf (and a function upon which it relies, JTD_arrayShuffle.sqf). The fundamental goal of that script is to have a single AI group search all the building positions in a single enterable building, in a way that appears 'lifelike.'

Built upon that script are various 'wrappers' that allow for a greater range of AI activity. This activity includes:

- an eventhandler that sends a nearby enemy group to a building near the shooter

- a script that sends a single group, systematically, into buildings around a central point

- a script that sends an array of groups to search an array of buildings

- the basic building search script that started this whole thing

Usage:

JTD_buildingSearch.sqf (requires JTD_arrayShuffle.sqf in the same folder)

Parameters:

group = group (or unit) - the group which will conduct the search (required)

search Radius = number - radius around which to generate an array of buildings (default is 50m) (optional)

"NEAREST"/"RANDOM" = string - specifies whether to use the building nearest to the passed 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 - '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 when the script ends (default is false) (optional)

This script can be used as a function, in which case it returns 'true' if it completes, or 'false' if it has to exit due to some error. Check the rpt for errors.

JTD_searchFiredEH.sqf

This eventhandler can be assigned to units. Upon firing, there is a random chance that nearby enemy units will be tasked to search a building near the shooter. If the group is already tasked with a building search, it will exit that iteration of the script. It will wait approximately 1 minute between checks, so fully automatic fire will not repeatedly trigger the eventhandler.

JTD_blockSearch.sqf

Parameters (all required):

group = group (or unit) - the group which will search all the buildings in an area

start position = position array (or object) - the position upon which to search

search radius = number - the radius within which to find enterable buildings

This script builds on the basic building search script by taking a single group and ordering it to sequentially search enterable buildings within a specified radius.

JTD_arraySearch.sqf (requires JTD_searchersOccupied.sqf in the same folder)

Parameters (all required):

group array = array of groups - the groups that will be assigned

building array = array of buildings - the buildings that will be searched

This script takes the groups in the passed array and assigns them to buildings from the other array. If there are more groups than buildings, random groups from the passed array will be assigned. If there are more buildings than groups, the buildings will be searched sequentially, re-using groups as they become available.

Global variables:

JTD_lockedSearchGroups - [array] as groups are assigned to buildings, they are added to this global variable, as they finish the search, they are removed. That array can be checked to determine whether to assign new waypoints to a group. (Created and monitored by JTD_buildingSearch.sqf.)

JTD_searchAvailables - [array] from the array search script, as groups are removed from the locked search groups, they are added to this array. (Created within JTD_arraySearch.sqf, and JTD_searchersOccupied.)

JTD_bldgsrchPath - [string] can be set in a unit init or the init.sqf, it allows mission makers to put these scripts in a different folder than the mission root folder. Just assign the path in the variable, and it will be prepended to the script execution commands.

JTD_searchDebug - [boolean] this will spam your rpt with all sorts of information that may or may not be useful to you. :) Needs to be set in init line of unit or init.sqf.

Share this post


Link to post
Share on other sites

Good work. I look forward to the JTD_arraySearch.sqf so I can populate zargabad with baddies :P

Share this post


Link to post
Share on other sites

New version available.

This is more of a package form, with separate directories for the scripts and test missions. TestMission1 is the same as the last testmission, with addactions for block search and building searches. TestMission2 is the more recent mission that displays the arraySearch implementation.

Main changes:

01g

Added JTD_bldgsrchPath as variable for Manzilla

Array functionality wrapper

Mediafire link-

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

ArmAholic d/l link (thanks to Foxhound!)-

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

And DankTank - I've been thinking more about your idea of populating buildings in a town with badguys. I think an init line in the leader of an editor placed group might work. Give the guy a rather large placement radius, so you aren't sure where he actually will be, then something like:

_bldgScript = [(group this), 50, "RANDOM", (getPos this), true, true] execVM "JTD_buildingSearch.sqf"

That should have the group look 50m around the leader for a random enterable building, and then occupy it (including the leader).

Share this post


Link to post
Share on other sites

Ive played with the demo, and managed to kill a fair few of them off, but it sure is hard. Heres the real issue. I got no idea how to implement this myself, and when i tried to fire up the missions in the editor to have a look, they appear to be read only.

Ive looked through the SQF's and still got no idea. Im a script nub. :(

Share this post


Link to post
Share on other sites

haha

No worries. :)

What do you want to try to accomplish? We can start small and work up. :)

Share this post


Link to post
Share on other sites

Not a whole lot to be honest my "missions" usually ends with me placing disproportional forces around some town/city and clearing them out without rhyme or reason.

Having just adding gl4 to my extensive mod list I discovered the enemy will garrison buildings. This has been a blast, though disappointed that my troops don't flush them out.

Step in Jtd building search.

They kicked my ass out of the buildings, so this could lead to some very fun gameplay for me.

So basically if I could have a couple of friendly spec op squads moving ahead of my armored contingent clearing out those pesky at troops I would be very happy.

Thanks for the reply!

Anywhere you would recommend me looking to get the basic understanding of scripting ?

Share this post


Link to post
Share on other sites

Anywhere you would recommend me looking to get the basic understanding of scripting ?

I found that OFPEC worked for me. There is ALOT of information here, but it can be overwhelming sometimes. There was a thread here that had a sort of basic scripting tutorial feel to it, you might look for that.

As for your mission - first it sounds very cool. :) I see the most difficult part being how you determine where to have the AI start the search.

Would it help if you could open your map, click a spot, and have your nearest AI group search the buildings in that area?

Share this post


Link to post
Share on other sites

Would it ever! I'm used to either trying to call all the shots of a single squad or play the backseat as a grunt, having control of where other squads start, or how they play a little would be great.

Thanks for the link, I'll start researching, hope I can find that thread!

Share this post


Link to post
Share on other sites

Hey Trexian,

Trying to get your house patrol scripts to integrate with VTS but it's hard going.

The way VTS operates is that you create a group with the house patrol task (and the radius you set) and away it goes. I successfully integrated Haroon1992 AHP scripts but yours seems more elaborate !

sleep 1;

_unite = _this select 0;

//_posmap = [spawn_x2,spawn_y2,spawn_z2];

_posmap = [_this select 1,_this select 2,0];

private ["_grpunit"];

if (typeName _unite != "GROUP") then

{

_grpunit = group _unite;

}else{

_grpunit = _unite;

};

_class=(typeOf (vehicle (leader _unite)));

//////////////For AHP

//[_grpunit,[radius],[5,15],99,[0,0],0.1,FALSE,["Land_Water_Tank","Land_Vez"]] execVM "AHP\AHP.sqf";

//For JTD_BuildingSearch

private ["_bldgArray", "_randArray", "_tempBldgs", "_initialPos", "_srchRad", "_t2", "_tempArray", "_b", "_bldg", "_bldgPos", "_scripto", "_groupsArray"];

_bldgArray = [];

// pick 2 groups, put into array

_groupsArray = [JTD_opforGroups select 0, JTD_opforGroups select 1];

// pick 3 random buildings, put into array

_tempBldgs = nearestObjects [(getPos _grpunit), ["HOUSE"], 100];

_t2 = count _tempBldgs; // 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

_t2 = _t2 - 1;

for [{_b = 0},{_b <= _t2},{_b = _b+1}] do

{

_bldg = _tempBldgs select _b;

_bldgPos = _bldg buildingPos 0;

if (((_bldgPos select 0) != 0) && ((_bldgPos select 1) != 0)) then

{

_bldgArray = _bldgArray + [_bldg];

};

};

_newArray = [_bldgArray select 0, _bldgArray select 1, _bldgArray select 2];

_scripto = [_groupsArray, _newArray] execVM "JTD_arraySearch.sqf";

This is from the patrolbuildings.sqf inside VTS. The commented bits are where I disabled AHP. Any idea how I can get your scripts to work? It should be initd properly ...

//////JTD Building Search init

JTD_gameOn = false;

_srchEH = player addEventHandler ["fired", {_this execVM "JTD_searchFiredEH.sqf";}];

_plyTrckr = [] execVM "JTD_bldgSearchTracker.sqf";

_grpMntrAI = [] execVM "JTD_bldgSearchGrpMonitor.sqf";

Cheers mate. If you need the WHOLE mission uploaded to have a little peek please ask. It's weighty at 10mb but there are no addons required :)

PS one final thing - could you package your scripts in a folder (with paths to the right file), as currently I have to put them into the mission root directory.

Edited by Kremator

Share this post


Link to post
Share on other sites

Hmmm... I'll take the easier one first. :)

You can set the global variable JTD_bldgsrchPath to the string that is whatever folder you want. So, if you want to have a <mission root>\scripts folder, if you have JTD_bldgsrchPath = "\scripts\" in your init then it should prepend to all the scripts calls\execVMs. (The leading \ might not be necessary, I haven't thoroughly tested it yet.)

With regard to VTS, I guess I need more information on whether you want the VTS group to either search a specific building, or a group of buildings? It looks like you are using the array search, which is fine.

But, if VTS already searches houses, then....?

Edit: I'm researching VTS... so I'm probably missing something. :)

Edited by TRexian

Share this post


Link to post
Share on other sites

Hey trexian,

With VTS I will want the AI to search a series of buildings within a radius I set on the dialog.

However when I use your scripts the AI just stand there.

I want the BEST AI house patroling script ... so evaluating them all :)

Share this post


Link to post
Share on other sites

Hmmm... it seems like the VTS UI would need to know what setting to send to the script, and I'm not sure it is set up that way.

With VTS, can you designate a script to be run when a certain waypoint is reached?

Share this post


Link to post
Share on other sites

AFAIK VTS passes the radius selected to the newly created group. So the group spawns in the middle of a group of houses and should enter them randomly (or on purpose if a shooter is spotted (AI and player types)

I'm sure I had your house patrol scripts running with an earlier version - but you have gone and made them more complicated :) just kidding

Does that help any ?

Share this post


Link to post
Share on other sites

haha

I didn't make them more complicated on purpose, I can assure you! :)

If the group spawns, and immediately executes the script, they should seek a random house within 50m. If there are none, it'll just stay there.... I think.

I'll do some testing. You might check the rpt and see if there are any errors?

I've de-pbo'd VTS, I'll see if I can sort out how it assigns stuff to execute. It is... complicated! :D

Share this post


Link to post
Share on other sites

The main error I get is ....

Error in expression <ect 1];

_tempBldgs = nearestObjects [(getPos _grpunit), ["HOUSE"], 100];

_t2 =>

Error position: <getPos _grpunit), ["HOUSE"], 100];

_t2 =>

Error getpos: Type Group, expected Object,Location

I'm running this on Fallujah map. _grpunit is the unit created by VTS

Share this post


Link to post
Share on other sites
Type Group, expected Object,Location
whole group(more than one unit?) don't give one position//

getPos leader _grpunit will be usefull

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  

×