Jump to content
kityatyi

Random spawn inside building

Recommended Posts

Hello all,

I am a fresh spawn in the world of Arma - and a total newbie to anything scripting related. I would like to make a very, very simple scenario - for learning purposes - where an enemy officer spawns inside a two storey house. However, I don't want him to always spawn at the same spot, I want him to spawn at one of the few pre-defined but randomly selected locations. I can already set up as many random spawn points as I want by using Markers / System / Empty and then linking this empty marker to the unit via Set Random Start.

However, this does not allow me to define a spawn point on the second floor. Even if I place the marker on the second floor, the guy will still spawn on the ground floor, although horizontally he'll be at the right place.

Could you please kindly explain - using simple, easy to follow steps - if it's possible to include among my random spawn points some that are not on the ground floor, and how to achieve this? 

I want to define roughly five possible starting positions for the enemy officer. Let's say. three on the ground floor, and two upstairs. So when I start the game, the enemy guy will not always be at the same place, adding some variety to the scenario. Then I can go in and kill him. :-)

Thank you for your attention and help!

Share this post


Link to post
Share on other sites

yourOfficer setpos (selectRandom (yourBuilding buildingPos -1));

 

If yourBuilding is a map object, you can use nearestBuilding yourOfficer instead,

or nearestTerrainObjects type "house". See BIKI.

 

  • Like 1

Share this post


Link to post
Share on other sites
33 minutes ago, pierremgi said:

yourOfficer setpos (selectRandom (yourBuilding buildingPos -1));

 

If yourBuilding is a map object, you can use nearestBuilding yourOfficer instead,

or nearestTerrainObjects type "house". See BIKI.

 


Thank you for your response, greatly appreciate it!

The building is part of the map.

But where should I write the code? In the Init of the officer?

Share this post


Link to post
Share on other sites

If SP , where you want.

If MP, in initServerLocal.sqf:

    yourOfficer setpos ( selectRandom (nearestBuilding yourOfficer buildingPos -1)); // if your unit is named yourOfficer

or in init field of the officer like this:

    if (isServer) then {this setPos (selectRandom (nearestBuilding this buildingPos -1))};

 

Make sure you choose a building with positions (generally with doors and/or ladders). Tanoa has plenty of poorly implemented buildings.

 

If you need something more precise without predefined positions, you can place your officer in 3den, then right click on it / log / log position to clipboard.

You can build your array of positions arrays this way, and selectRandom it, instead of the buildingPos.

Share this post


Link to post
Share on other sites
20 minutes ago, pierremgi said:

If SP , where you want.

If MP, in initServerLocal.sqf:

    yourOfficer setpos ( selectRandom (nearestBuilding yourOfficer buildingPos -1)); // if your unit is named yourOfficer

or in init field of the officer like this:

    if (isServer) then {this setPos (selectRandom (nearestBuilding this buildingPos -1))};

 

Make sure you choose a building with positions (generally with doors and/or ladders). Tanoa has plenty of poorly implemented buildings.


Thank you so much, it works like a charm! The guy even spawn on the rooftop, lol! :-)

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

×