Jump to content
KC Grimes

Grimes Building Occupation Script

Recommended Posts

Author: KC Grimes

Script: Grimes Building Occupation Script

Version: V1.21

The Grimes Building Occupation Script provides the ArmA 3 mission maker an extremely simple way to occupy a set of buildings within a radius with a random or fixed amount of AI (of any faction, including civilian), both chosen by the maker and limited by the number of official position inside the building. The spawned AI will fight back as a group, and can be easily manipulated further by adding lines in the right spot in this script. This script can be utilized in many ways, examples including but not limited to:
* Filler - Have a mission where a squad goes from A to C and you want non-mission critical AI at B? Use this script!
* Random Objective - Want to have 3 AI at C that could be ANYWHERE between dozens, hundreds of buildings? Use this script!
* Boredom Fixer - Want a quick CQB practice? Use this script!

 

This package includes an application of the script, in debug mode, as part of an example mission. 

 

This README is intended to provide detailed information as to the purpose, function, FAQs, and minor troubleshooting for this script in addition to installation, uninstallation, and maintenance tips. For further information or specifics in the code, the user should read the comments to the code within the script files. 

 

Author Information

 

KC Grimes is the author of the Grimes Building Occupation Script. The script was made in order to allow for quick yet proper "filling of space" in missions where combat in general is intended, without having to go through the headache of placing individual units and positioning them correctly. 

 

The purpose of this script is to save time while encouraging randomized gameplay and limitless mission construction. 

 

BI Forums Topic: https://forums.bohemia.net/forums/topic/164755-grimes-building-occupation-script/

 

Installation

 

At this time, there is no “installer” for the script, and it is instead a simple series of actions and file moves.  

1. Obtain the script files
    a. Armaholic: http://www.armaholic.com/page.php?id=25268

    b. github: https://github.com/kcgrimes/grimes-building-occupation-script/releases

    c. Steam Workshop: http://steamcommunity.com/sharedfiles/filedetails/?id=1313225489
2. Simply copy the file "G_Occupation.sqf" into your mission directory
3. Create a trigger in the area of where you want buildings occupied
4. Execute by putting this line of code in the trigger's On Activation field:

null = [thisTrigger,east,200,1,3,2,-1,0,true] execVM "G_Occupation.sqf";  

5. Modify execution parameters as desired using the following rules:

Parameters:
null = [thisTrigger, side, radius, spawnType, maxToSpawn, groupOption, maxGroups, buildingOrder, debug(optional)] execVM "G_Occupation.sqf";

(select 0) - thisTrigger - A command (not a name) returning the trigger. It must always be in the select 0 slot.
Value: thisTrigger

 

(select 1) - side - The side that you want the spawned AI to be on.
Value: west, east, resistance, civilian

 

(select 2) - radius - The radius of the "subject area" around the trigger, where all buildings inside it are "subject buildings". No relation to the radius of the editor-placed trigger.
Value: Integer greater than 0

 

(select 3) - spawnType - The method by which AI will spawn.
Value:
NOTE: For spawnType values of 0 or 1, maxToSpawn represents the max AI allowed to spawn per building (as opposed to the area) and groupOption can be any setting.
0 - AI spawn by a certain number per building depending on maxToSpawn and the available positions
1 - AI spawn per building depending on a random number between 0 and maxToSpawn, limited as well by available positions
NOTE: For spawnType values of 2 or 3, maxToSpawn represents the max AI allowed to spawn in the area (as opposed to building) and groupOption can only be 1 or 3+ (number per building can only be limited by available positions).
2 - Fixed number of AI spawning at random at positions inside the radius (boundary number set by select 4, maxToSpawn)
3 - Random number of AI spawning at random at positions inside the radius (boundary number set by select 4, maxToSpawn)

 

(select 4) - maxToSpawn - Used to limit the maximum number of AI to spawn per building or in the subject area, depending on the value of spawnType (described in spawnType section).
Value: Integer greater than 0

 

(select 5) - groupOption - The number of AI per AI "group". Due to game limitations, there can be only 288 groups per side. Because of this, in the event that this script exceeds 288 groups minus the number of AI groups you have already placed, the script will exit and the remaining spawns will not occur. 
Value:
1 - When spawned, AI are in their own group. 
2 - When spawned, AI are grouped per building. When spawnType is 2 or 3, AI are in their own group. 
3+ - When spawned, AI are grouped in groups the size of this variable. For instance, if you use 10, the AI will spawn and be placed in groups of 10, possibly between multiple buildings.

 

(select 6) - maxGroups - The maximum number of groups that the script will spawn before exiting. 
Value:
NOTE: Groups are divided up depending on the groupOption value.
-1 (value of -1) - Unlimited groups for the script, however groups will still be limited by the spawn system (288 per side).
>0 (any value over 0) - The maximum number of groups that will be created. Upon achieving this number, the script exits.

 

(select 7) - buildingOrder - Determines whether or not the script will work from the center of the radius out, or at random.
Value:
0 - The script will proceed from the buildings nearest the center of the radius and expand outward
1 - The script will proceed from building to building at random within the radius

 

(select 😎 - debug - Debug is true or false (optional; can be left non-existent).
Value:
true - Provides text feedback via chat about what the script is resulting in.
false - No debug; for production.

 

Example Parameters:

null = [thisTrigger,east,200,1,3,2,-1,1,true] execVM "G_Occupation.sqf";  

This means the AI will be east, they will spawn in buildings within 200m from the trigger executing the script, they will spawn at a random number per building between 0 and 3, they will be grouped per building, the number of groups is not directly limited, buildings will be selected randomly, and debug is enabled.

 

Notes/Tips:
* Due to the nature of this script, the larger the desired numbers and spawn radius, the more time it takes to complete its process, and the more laggy the server will be during the process. This can be mediated by reducing the numbers or having multiple triggers executing this script with smaller radii, thus allowing multiple spawns to occur in parallel.
* The radius/dimensions of the trigger in the editor have no effect on this script, other than that trigger's activation. The radius that this script references is defined in the parameters as listed above. 
* It is recommended to run this script at mission start so that any potential lag does not occur during the mission. However, it can be done at any time, as long as it is via trigger with the above parameters. 
* You can add or remove classnames in the _sclasses arrays. The script is already setup to select 1 at random per individual spawn.
* To use the debug mode, which tells you exactly what is spawning and where, simply add a true at the end of the parameters, as mentioned above. At least one run with debug enabled is recommended in order to ensure a smooth and working production version.
* Unfortunately, ArmA is limited to 288 groups per side. Be sure to read about this further in the installation instructions. Group numbers are provided in the debug texts.
* On that note, the limiters to this script is the available buildings, the 288 group limit, and your values. 
* AI will maintain their spawned position if spawned in a group, until entering combat.
* This script contains various "checks" in order to ensure your success!
* All of the recommended limitations can be experimented with, of course. Make your mission as good as it can be!

 

Documentation

 

This README is intended to provide detailed information as to the purpose, function, FAQs, and minor troubleshooting for this script in addition to installation, uninstallation, and maintenance tips. For further information or specifics in the code, the user should read the comments to the code within the script files. Any further questions or comments can be directed to the author. 

 

Download

Grimes Building Occupation Script hosted on Armaholic

Grimes Building Occupation Script hosted on github

Grimes Building Occupation Script hosted on Steam Workshop

  • Like 2

Share this post


Link to post
Share on other sites

Looks like a very nice script to use in my missions, also nice description and explanation thanks, I'll try it out next opportunity.

Edit: Works perfect, although maybe im not quite getting how to reduce the amount of groups that spawn... currently i feels like it fills all buildings within the marker area, would it or is it possible to reduce how many buildings are occupied in a radius or specify how many groups exactly are too spawn? so that not every building has enemies?

Edited by Katipo66

Share this post


Link to post
Share on other sites

All buildings with 1 of more position in them that are within the radius set in the params (in the sample mission it is 300 I believe) will be listed. From there, there is an equal chance of the building having 0 enemies as there is a building having the max allowed (limited by the building position count or the param itself). This is done individually (per building). So if you run it, you'll see all "subject" buildings marked with a Black marker. All enemy spawn locations will be Red. I assure you that you will find buildings containing all amounts from 0 to whatever the max is.

That explained, the only way to reduce the actual number of enemies spawning (not groups, as you can see in the explanation that is managed in other ways) is to reduce the radius of the script.

I'll play around with it though, as a light bulb just went off. This script is really designed as what it does, a "filler". If you have a mission where the squad needs to go through a town, and the town itself is not the objective, this is perfect, as it very simply throws enemies in at random but in legitimate positions.

Share this post


Link to post
Share on other sites

Ahh sorry i misunderstood and thought the red markers were actual spawned enemies as opposed to potential spawn positions, also of course i can reduce the radius, ive had a few play throughs now and like it exactly for what its designed for.. a filler! thanks again :)

Share this post


Link to post
Share on other sites

Correct, red markers are ACTUAL spawns. There are plenty of potentials :P However, I took your idea and am running with it, so expect a new link to download here in a bit. Will reply to this thread when its ready.

Share this post


Link to post
Share on other sites

I am wondering if you could use a combination of doStop, setBehaviour, and setUnitPos to get them to stay grouped and stand apart from one another (adjusting setUnitPos with a trigger for once they come into contact with an enemy)? I will check it out today if I get a chance and get back to you.

Share this post


Link to post
Share on other sites
I am wondering if you could use a combination of doStop, setBehaviour, and setUnitPos to get them to stay grouped and stand apart from one another (adjusting setUnitPos with a trigger for once they come into contact with an enemy)? I will check it out today if I get a chance and get back to you.

Unfortunately, that is not very reliable if we are talking about a use of dozens of enemies, potentially in their own group OR in fixed groups, and while still trying to maintain the "realism" of detection. Fortunately though, I fixed my problem in this latest re-launch by simply adding a doStop after a quick search. Does the trick! Thank you for the input though, definitely would've tried if I hadn't found out about it earlier.

That said, I have updated the original download link with a very re-worked script. I recommend to anybody that has downloaded it to redownload it and reread the information, as it includes new features from before, namely the ability to set a fixed number of enemies in an area. Enjoy! Again, thank you Katipo for the suggestion!

Share this post


Link to post
Share on other sites

Thanks man, i dont think the download link has updated yet? the description is different to whats posted in first post? ill try again later.

Share this post


Link to post
Share on other sites
Thanks man, i dont think the download link has updated yet? the description is different to whats posted in first post? ill try again later.

Probably me hitting "replace" on MediaFire instead of deleting and recreating. Worked for me, but it may be a cookie issue. Deleted the file and just made a whole new one. OP updated. Sorry for the trouble. Once Armaholic comes around I'll get the good mirror up there!

Share this post


Link to post
Share on other sites

Haha Awesome, very nice update! thanks for this script, it ticks all these boxes "Filler-Random Objective-Boredom Fixer" :D

Share this post


Link to post
Share on other sites

Hi Grimes, I had checked out your script here, it works good.

I found the mil_objective marker to be to big and clutter the map, so i replaced it with mil_dot, makes it look cleaner.

I would like to ask for testing sake or maybe in general is how and where can i add delete marker so that when you kill an enemy marked red that, that marker representing them disappears, i would assume too that some tracking script or code would be needed to make the marker more "dynamic" so that if the AI moves that if they were indeed killed that the actual marker representing them and their position would be deleted.

I have a script that does that however i dont know how to implement it or use in inconjunction with your script.

heres the script btw:

track_units.sqf

/*
Simple tracking of foot units.
by Demonized.
*/

private ["_marker_fnc"];
DMZ_TU_marker_num = 0;
DMZ_TU_marker_arr = [];

_marker_fnc = {
private ["_name","_mar","_color"];

DMZ_TU_marker_num = DMZ_TU_marker_num + 1;
_name = format["marker_%1",DMZ_TU_marker_num];
_mar = createMarker[_name,(getPos _this)];
_mar setMarkerShape "ICON";
_mar setMarkerType "Dot";

_color = switch (side (group _this)) do {
	case west: {"ColorBlue"};
	case east: {"ColorRed"};
	case resistance: {"ColorGreen"};
	case civilian: {"ColorWhite"};
};
_mar setMarkerColor _color;

[_this,_mar] spawn {
	private ["_unit","_mar"];
	_unit = _this select 0;
	_mar = _this select 1;
	while {!isNull _unit AND alive _unit} do {
		_mar setMarkerPos (getPos _unit);
		sleep 1;
	};
	_mar setMarkerColor "ColorBlack";
	if (!isNull _unit) then {sleep 60};
	deleteMarker _mar;
	_mar = nil;
	DMZ_TU_marker_arr = DMZ_TU_marker_arr - [_unit];
};
true
};

sleep 1;
while {true} do {
{
	if (alive _x  AND !(_x in DMZ_TU_marker_arr)) then {
		DMZ_TU_marker_arr = DMZ_TU_marker_arr + [_x];
		_x call _marker_fnc;
	};
} foreach allUnits;
sleep 5;
};

this script, tracks infantry units, they are represented by a red dot on the map, and when they are killed the dot turns black.

Now this script is from arma2CO, and the marker classname for dot in the script is dot, not mil_dot as in arma3.

Your thoughts.

Share this post


Link to post
Share on other sites

I had mentioned it in the descriptions, but perhaps not so well. At any rate, the markers, as seen in the example mission, were implemented strictly for testing purposes. IE, you want to see if you have the radius right, so you run the mission with the debug argument set to true in order to see what buildings are used. Once satisfied with the radius you've set, you would then disable debug, thus keeping the markers from ever being created.

Edited by Grimes [3rd ID]

Share this post


Link to post
Share on other sites

Ok, understand, think I knew that already, just wondering, in general it makes it a fun little mission to mess around with having markers to represent where the possible AI are at.

Let me understand this correctly the code nul = [thisTrigger,EAST,200,0,3,1,true] execVM "G_Occupation.sqf";

as seen in your OP, the 200 is representing the radius of the trigger correct, so that number even though the trigger itself is not actually set at 200m, it creates or fills

the buildings with AI within 200m of the center of the placed trigger? and this number can be changed, and the AI will spawn within the given radius?

Share this post


Link to post
Share on other sites

Yessir, the number listed in the execution argument is the radius. The value of the radius set in the trigger itself only relates to the trigger properties (activation, etc.), and is not referenced in any way in the script. I would have done this, but unfortunately I don't know how to call that radius. So I just did it the next simplest way. And you are again correct, the 200 can be changed to whatever you'd like as you can see with the debug mode. Also, a circle is drawn representing the radius.

Share this post


Link to post
Share on other sites

Great, I seen that on the map after the Ai spawned in you can see the radius created, wonderful, thanks for your work!

Share this post


Link to post
Share on other sites
Great, I seen that on the map after the Ai spawned in you can see the radius created, wonderful, thanks for your work!

No problem, I'm glad you're putting it to good use. As well, thank you for the suggestion earlier about tracking with markers. It is a good idea, but is something that I believe people should implement on their own. As you can see, it is simple to do in this script. I created this script for the intent of having an effective filler, in place of mission editors placing units at random and hoping they "do stuff". Having the script you posted in this thread will help others achieve the tracking goal if they want it, however. So again, thanks!

Share this post


Link to post
Share on other sites

Hi Grimes, I still use this script in most of my little setups, I'm embarrassed to ask but could you give an example line on how to have for example 3 groups of 6 units occupy 3 random buildings only within a 200mtr radius. I cannot seem to get this right? I always have specified number of units occupy a building on there own, so 8 single units in 8 separate buildings.

Share this post


Link to post
Share on other sites

No need to be embarrassed, glad you asked. What you're trying to do isn't a direct option in the script due to your wanting to limit it to 3 groups. However, you could go in and edit the script and get it to max out at 3. That said, you can try this:

nul = [thisTrigger,EAST,200,0,6,2,true] execVM "G_Occupation.sqf";

That will do all that you want, except for limiting it to 3 groups/buildings. However, again, you can limit it in the script. Or, make the radius smaller.

To limit the group number, just move the variable _numgroupsvar out of the debug if/thens, then have it exit the forEach if the count is greater than what you set. I'll go ahead and re-upload the script with this and possibly other stuff done by Friday perhaps, though no promises on that. School is crazy this week. Sorry I couldn't be of too much help!

Share this post


Link to post
Share on other sites

Ok thanks man, i will have a look at zee code and do some experimenting :)

Share this post


Link to post
Share on other sites
Ok thanks man, i will have a look at zee code and do some experimenting :)

Feel free to post up any changes you make for others to take advantage of. I'm all for y'all doing what you need to do to accomplish your goal!

Share this post


Link to post
Share on other sites

Ok will do if anything worth posting, great attitude! Look forward to any updates :)

Share this post


Link to post
Share on other sites

I have updated the original post of this thread with a new description and download link to V1.1 of Grimes' Building Occupation Script. If you have used this script in the past, or are yet to try it, I strongly suggest you download the latest version! See the OP for a detailed change log. Thank you for those who offered ideas & suggestions! Keep 'em coming!

@ Katipo66 - To accomplish your goal, use the following while using V1.1:

nul = [thisTrigger,EAST,200,0,6,2,3,1,true] execVM "G_Occupation.sqf";  

EAST AI spawned at buildings within 200m of the trigger with 6 men per building, grouped per building, with a max group number of 3, and the buildings selected at random in the radius. Please note, as you will see in the sample mission, do to the building's limitations this will not always work unless you find the right radius/location for your application. For playability, there are no errors/conflicts in the event that positions run out, the script simply exits like normal. To get around this, again I suggest finding the right radius/location, as well as picking a lower number.

Enjoy!

Share this post


Link to post
Share on other sites
Legend! Much appreciated :)

Give it a go at some point and make sure it is what you're looking for, though I am pretty sure it is. Again though, you'll need to play with it a bit to get it in the right spot if you truly want 6 per building. As well, again thank you for the suggestion. I'm trying to keep the "Simple" aspect of this script still a dominant feature, but there are some things like your suggestion that truly benefit everyone. What is funny is I essentially had the setup of it in the script already, but was using it to count the number of groups for debug purposes. Never even thought of making it a limiter. Heck, in hind sight, I probably should have made it so that it pops up an alert if you exceeded the 144 group limit. Oh well, that is explained well enough. I'll save that for the next update.

Share this post


Link to post
Share on other sites

Hey Grimes, just tested it, perfect bro... excellent! it was kinda too easy before knowing that only one unit will be in the building... now we got all sorts of options!

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

×