Jump to content
Sign in to follow this  
Sgt_SyphonX

Placing Soldiers in Guard Towers

Recommended Posts

How is it possible to do this? I am setting up a FOB in Takistan, with guard towers (specifically 'Bunker Towers'), and I'd like to put soldiers in them for ambiance and for mission purposes.

However, I can't seem to figure out how to place them in the tower, i.e., the "2nd floor". They either end up outside the tower, on the ground floor, or just dead somewhere around it.

.. and for that matter, how do you place characters on a 2nd/3rd/4th/Roof at all..?

Share this post


Link to post
Share on other sites

usmg1 setpos [getPos usmg1 select 0, getPos usmg1 select 1, +2.75];

this is an example of how its done usmg1 is my machine gun It is 2.75 meters above the ground level wherever you see usmg1 replace it with your units name and change height from 2.75 to whatever you like this is the height of one of the bunkers my guy is in.

I think this should help you.

Share this post


Link to post
Share on other sites

Thanks, I'm pretty new to coding, but it's not rocket science.. just need a good reference. I'll give it a whirl.

I should have an authentic looking FOB in no time.

Share this post


Link to post
Share on other sites

I would try using the RTE Real Time Editor if you are doing that. It's way easier than the 3d editor and then you can change little things in the 2d. That way you can place anyone wherever you want AND you can change weapon loadouts and a lot of other stuff way easier.

Share this post


Link to post
Share on other sites

Hi.

Place the following to the unit init line:

this setPos ((nearestBuilding this) buildingPos X);

Where X is the number of position inside the building. Remember the first position is 0, the 1 etc.

You can check in the editor how many positions a building has.

_neo_

Edited by neokika

Share this post


Link to post
Share on other sites

Sorry for the thread hijack - but neokika, I had no idea you could use setPos in conjunction with buildingPos. My experience with using setPos to position AI in buildings with xyz coordinates has been negative - when the AI get move orders, they almost seem to fail to realize that they are in a building, and get stuck.

Does using buildingPos result in better manoeuvring for AI?

Share this post


Link to post
Share on other sites
Sorry for the thread hijack - but neokika, I had no idea you could use setPos in conjunction with buildingPos. My experience with using setPos to position AI in buildings with xyz coordinates has been negative - when the AI get move orders, they almost seem to fail to realize that they are in a building, and get stuck.

Does using buildingPos result in better manoeuvring for AI?

Yes. You will get really better results like that.

The AI inside buildings walks by paths, that connect all positions of the building.

So if you use this, the AI will spawn on the building position and will be aware that they are in one.

You can also use waypoints to make them get in, but if you want the units to start inside the building on the mission start this way is better.

For example, you want a unit to start in a random position inside a building.

So in the editor you put that unit very close to the building you want it to spawn. And for example, you know the building has 15 available positions:

On the init line of the unit:

this setPos ((nearestBuilding this) buildingPos (random 14));

Remember, building positions start with 0. So, if in the editor, waypoint shows that the building has 15 positions, you use 14, because it starts with 0.

_neo_

Share this post


Link to post
Share on other sites

Very interesting, thanks. I was having some problems in another thread: http://forums.bistudio.com/showthread.php?t=102607

After some testing earlier today, I am beginning to think that my problems may be due to the way that the hostage is placed in one of three possible buildings selected at random - though scripted waypoints in init.sqf. setPos at least offers a much cleaner solution. I will give it a shot.

Thanks again.

Share this post


Link to post
Share on other sites

I use this

this setPos ((nearestBuilding this) buildingPos 2);

for towers.

Share this post


Link to post
Share on other sites

Ok Then I have a question is there anyway to see where these positions are for each building they must be different?

Share this post


Link to post
Share on other sites
Ok Then I have a question is there anyway to see where these positions are for each building they must be different?

Yeah I am wondering this too. its a lot of trial and error right now.

Share this post


Link to post
Share on other sites

A simple trick to put a soldier in the tower correctly: just place a waypoint to the position 1 and then to position 3 (press shift to select the building again while giving the second waypoint). I just did this last evening but you gotta make sure that the waypoint has a completion radius. I used a completion radius of 5 and it did the trick. Also to prevent the unit from going to a prone position put this to the init line: this setunitpos "up"

Share this post


Link to post
Share on other sites

Have a look at my Random House Patrol script (link in my signature).

Look through the code and you'll get an idea what you can do with building positions...

When I want to find a specific buildingposition I usually set up a couple of radio controlled triggers. Then look through the building I want to put a unit in.

Put a player unit and name him s1

Put 2 radio controlled triggers

One that goes:

Radio Alpha

On Act: a = a + 1; s1 setPos ((nearestBuilding s1) buildingPos a)

And a second that goes:

Radio Bravo

On Act: a = a - 1; s1 setPos ((nearestBuilding s1) buildingPos a)

Might be a good idea to also put a trigger that goes:

Condition: true

On Act.: a = 0:

I only slept 2 hours tonight, so I might be missing something.

Share this post


Link to post
Share on other sites

this setPos ((nearestBuilding this) buildingPos (random 14)); worked great for me :) thank you

Share this post


Link to post
Share on other sites
Have a look at my Random House Patrol script (link in my signature).

Look through the code and you'll get an idea what you can do with building positions...

When I want to find a specific buildingposition I usually set up a couple of radio controlled triggers. Then look through the building I want to put a unit in.

Put a player unit and name him s1

Put 2 radio controlled triggers

One that goes:

Radio Alpha

On Act: a = a + 1; s1 setPos ((nearestBuilding s1) buildingPos a)

And a second that goes:

Radio Bravo

On Act: a = a - 1; s1 setPos ((nearestBuilding s1) buildingPos a)

Might be a good idea to also put a trigger that goes:

Condition: true

On Act.: a = 0:

I only slept 2 hours tonight, so I might be missing something.

Your script is the best.....works well for towers too. We use it all the time. Just sloppily throw this into a players init and place him near a tower. most of time it works like a charm. Boom, hes in the tower: :D

guard = [this] execVM "HousePatrol.sqf" 

Share this post


Link to post
Share on other sites

When I place AI in guard posts via setPos, the AI behave as if they don't know they are in a guard tower.

I've found best results happen when you place a move waypoint directly on the guard post, then specify which position they should take inside the move waypoint.

Share this post


Link to post
Share on other sites

Hello,

I ave found that allowFleeing 1 and disableAI "MOVE" is good for guards in towers. However, they only stay looking in the one direction no matter what danger is around them.

On the other hand, if you enableAI MOVE then as soon as they see you they climb down the ladder and pursue. This isnt what I want either.

Any suggestions for how to make them stay up there but still look reasonably intelligent?

Share this post


Link to post
Share on other sites

Hmm, in the comref it says "Set if leader can issue attack commands." Might not be all that relevant...

Share this post


Link to post
Share on other sites

That command, obviously, prevents AI leaders from issuing attack commands to his team, which means they will stay in position rather than go hunting for an enemy. A single AI unit is his own leader, so it may work for that.

Alternatively, try forceSpeed 0. The AI unit usually stays put unless they get shot.

EDIT: by the way, allowFleeing 1 means they will run away. That is why they climb down the ladder.

Edited by 2nd Ranger

Share this post


Link to post
Share on other sites

I simply use this in the init line of a unit:

0=this spawn { while {alive _this} do { hintSilent str (getPosATL _this); copyToClipboard str (getPosATL _this); };};

I walk my unit to the exact spot I want the guard or static or whatever to be, pause, and then put in it's init line:

this setPosATL [color="Red"][xxx,xxx,xxx][/color];

Where the last part is simply the coordinates of my units position at the time I paused it, so the red part is just pressing ctrl+v. Real easy and fast.

Ofcourse, as neo said, the AI could have some problems with his pathfinding, but myself I haven't encountered any yet. But I try not to put the AI in some silly positions, so that might help.

Share this post


Link to post
Share on other sites

Even easier than that is to just keep this in a radio trigger while making your mission:

copyToClipboard format ["this setPosATL %1; this setDir %2;", getPosATL player, getDir player]

So you can use it for any unit at any time. Also it sets the direction so the unit will be in the exact position and azimuth you were when you called it.

Share this post


Link to post
Share on other sites

Why group a unit if you want him to stay in a tower anyway. You can always regroup him when needed.

Forcespeed won't quite work either as the unit can still climb down the tower but then stops when he tries to run.

Share this post


Link to post
Share on other sites

In a test I did earlier the guy stayed in the tower anyway, without any help except for setUnitPos "UP". AllowFleeing 1 seems to be Funkman's problem.

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  

×