Jump to content
Sign in to follow this  
celery

Get number of building positions?

Recommended Posts

If I want to make an AI go to a random position in a random house, how can I automatically find out the number of positions the building has? The buildingPos list is right there when you make a waypoint in the editor so there must be some way.

Share this post


Link to post
Share on other sites
If I want to make an AI go to a random position in a random house, how can I automatically find out the number of positions the building has? The buildingPos list is right there when you make a waypoint in the editor so there must be some way.

Yes Celery, that is the way. =P.

_neo_

Share this post


Link to post
Share on other sites

fn_getBuildingPositions:

/*
 Author: 
  rübe

 Description
  returns a list of all available building positions

 Parameter(s):
  _this: building (object)

 Example:
  _positions = _building call RUBE_getBuildingPositions; 

 Returns:
  array of positions (guaranteed to return at least one position; position building)
*/

private ["_building", "_positions", "_i"];

_building = _this;
_positions = [(position _building)];

// search more positions
_i = 1;
while {_i > 0} do
{
  _next = _building buildingPos _i;
  if (((_next select 0) == 0) && ((_next select 1) == 0) && ((_next select 2) == 0)) then
  {
     _i = 0;
  } else {
     _positions set [(count _positions), _next];
     _i = _i + 1;
  };
};

// return positions
_positions

Share this post


Link to post
Share on other sites

Check my Random House Patrol script to get a fairly simple solution to it.

Share this post


Link to post
Share on other sites
If I want to make an AI go to a random position in a random house, how can I automatically find out the number of positions the building has? The buildingPos list is right there when you make a waypoint in the editor so there must be some way.

How exactly or where exactly does it say the building position number when you make a way point. Are we talking about opening the mission file and scrolling to find it? I also am trying to figure out how to find positions as I am trying to use Big Dawg KS patrol script. Is yours the same one Tophe?

Edit: I noticed yours is much easier to use. Thanks for making that.

Edited by VISION1776

Share this post


Link to post
Share on other sites

If you put a waypoint on top of a building, you will see a "position in house" dropdown right above the Timeout section. That shows all the positions, which is what Celery was referring to.

Share this post


Link to post
Share on other sites

If you already have your building (_build) then :-

	
  _cnt = 0;
  _posarray = [];

//as long as building position _cnt not equal to "[0,0,0]" keep looping
while {format ["%1", _build buildingpos _cnt] != "[0,0,0]" } do {

	_pos = _build buildingpos _cnt;		//select building position _cnt
	_posarray = _posarray + [_pos];		//add the position to the list

       _cnt = _cnt + 1;		//increment counter
	sleep 0.01;
};

_posarray will contain all the positions...in position format. They can be added as Waypoints....or used for doMove.

Edited by twirly
Clarity

Share this post


Link to post
Share on other sites

Thanks for the info. Now how can you tell what position is which? What strategy would you guys use? For example, out of 30 positions how do I know which ones are on the roof?

Share this post


Link to post
Share on other sites

The highest and lowest and then all the points in between for each building wouldn't be that hard to find... but I don't think you can know for certain if a point is on the roof or not. That is....whether the building actually has roof positions.

It might be that most of the enterable buildings have roof positions... I don't know.

Share this post


Link to post
Share on other sites

This whole concept seems pretty complicated when it could be so much simplified. For example I use the move command to order a unit into a position and it does not enter the building. Im guessing the unit does not know how to open a door or better yet climb up a latter. What am I missing? Or should I just take the short cut and use an already created scrypt

Share this post


Link to post
Share on other sites

Hmmmm.... don't have that problem here. I can get them to go to all positions (generated from the script) in all buildings in my testing. They will use doors and ladders no problems.

I'm running OA with the latest beta.... not sure if that has anything to do with it. You just never know!

Share this post


Link to post
Share on other sites

Careful, some buildings are simply not placed properly and thus AI cannot path into them. Generally this will happen with many buildings placed on non-flat terrain.

You could consider setPos instead, but often this will cause units to clip through the building, and if they're AI, die as a result. The only way to reliably avoid it is to record your own building positions with getPosASL and then use setPosASL. Also, be careful if you ever want the units to walk out, they might jump off instead of take the door).

Of course using setPosASL to pre-defined positions is a lot more work, but is the only way to reliably get AI alive inside a misplaced buildings. And even BIS islands have plenty such buildings. Feruz Abad is a good example for a town that has many problematic buildings that AI cannot path into.

Share this post


Link to post
Share on other sites
....And even BIS islands have plenty such buildings. Feruz Abad is a good example for a town that has many problematic buildings that AI cannot path into.

Good to know. I didn't have problems.... but was using the few buildings on Utes and a lot of testing with Tigeria. Also towns generated with GITA seem to work OK.

I have a little search script I wrote that I was testing.... and eventually they will search how-many-ever hundred positions successfully!

EDIT: I did notice that in some buildings the same positions would be searched over and over again. The AI that was doing the searching would eventually finish though... and move on.

Edited by twirly
Addded some

Share this post


Link to post
Share on other sites

Just put yourself on the map with a subordinate in the group, hit the spacebar and move the pointer to the building in question. The interface will draw lines to each position as you move the pointer near it, giving the position # and location.....CAKE. If your using some kind of randomizer, the script should have the ability to generate a position randomly from only the positions you desire.

Edited by MajorModz

Share this post


Link to post
Share on other sites

Actually GITA towns are very likely to have issues since they often not only place buildings on non-flat terrain, but sometimes even place them on extremely non-flat terrain in a way that even human players can't enter the building!

Not sure about the building search... With which script?

Share this post


Link to post
Share on other sites

Something else I will add to this discussion for anyone who is reading this to get info on this topic...

Sometimes when you order AI to move from position to position for certain buildings in ArmA 2 they will run off balconies and roofs and fall to their death. So just keep that in mind. You might want to spectate the AI's movement before your release the map to make sure you don't have a situation like that.

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  

×