Jump to content
kibaBG

Spawn script to fill buildings with garrisons.

Recommended Posts

Hi guys, 

I am bashing my head with something very easy (hopefully 🙂). I want to make a script to fill some buildings (sorted by classname or random)  with enemies in given location (town, village, etc.). The old way I used before was just making a trigger next to every big building in the location and pasting this in on activation: 

private _group = createGroup [WEST, true];  
_unit1 = _group createUnit ["CUP_B_US_Soldier_OEFCP",(nearestBuilding thisTrigger buildingPos 1),[],0,"CAN_COLLIDE"];  
_unit1 disableAI "PATH"; _unit1 setUnitPos "UP";
_unit2 = _group createUnit ["CUP_B_US_Soldier_MG_OEFCP",(nearestBuilding thisTrigger buildingPos 2),[],0,"CAN_COLLIDE"];  
_unit2 disableAI "PATH"; _unit2 setUnitPos "UP";
_unit3 = _group createUnit ["CUP_B_US_Soldier_GL_OEFCP",(nearestBuilding thisTrigger buildingPos 3),[],0,"CAN_COLLIDE"];  
_unit3 disableAI "PATH"; _unit3 setUnitPos "UP";
_unit4 = _group createUnit ["CUP_B_US_Soldier_OEFCP",(nearestBuilding thisTrigger buildingPos 4),[],0,"CAN_COLLIDE"];  
_unit4 disableAI "PATH"; _unit4 setUnitPos "UP";
_unit5 = _group createUnit ["CUP_B_US_Soldier_MG_OEFCP",(nearestBuilding thisTrigger buildingPos 5),[],0,"CAN_COLLIDE"];  
_unit5 disableAI "PATH"; _unit5 setUnitPos "UP";
_unit6 = _group createUnit ["CUP_B_US_Soldier_GL_OEFCP",(nearestBuilding thisTrigger buildingPos 6),[],0,"CAN_COLLIDE"];  
_unit6 disableAI "PATH"; _unit6 setUnitPos "UP";

Its terribly tedious and I want to change it to a proper script executed by the server. Any ideas?        

Share this post


Link to post
Share on other sites

you should describe what your "proper script" should do.

Share this post


Link to post
Share on other sites

Grab a script that does it out of the box, for example this one

 

Share this post


Link to post
Share on other sites
1 hour ago, _foley said:

Grab a script that does it out of the box, for example this one

 

 

The problem is I don't want all of the units to face a window so the player has to storm the building at some point. Otherwise he will kill everyone with a sniper rifle one by one circling the building from a distance.   

 

 

11 hours ago, sarogahtyp said:

you should describe what your "proper script" should do.

Quote

I want to fill the enterable buildings in a village with AI defenders by script. Sorry English is not my first language.    

 

I  am trying to make it work with nearObjects command, something like this

_list = (locationPosition _rLocation) nearObjects ["House", 20];

This will give me "array of objects", but how to make these objects (houses) fill with enemies with  buildingPos or nearestBuilding command?
 

_rLocation = selectRandom [location_1,location_2,location_3];     //find random village from all villages on the map 
_list = (locationPosition _rLocation) nearObjects ["House", 200]; //finding all the houses around the location marker as array 
_aslPos = getPosASL _list;					//converting the buildings array into array of positions? but it doesn't work with array
										// I am lost :( 

  

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

×