Jump to content
jshock

Shock's Building Garrison Function (SBGF)

Recommended Posts

Doesn't do anything? What am I doing wrong?

The SBGF folder in my mission directory along with the description.ext

Placed command below in group leader's init field:

0 = [this,"mrkName",200] spawn SBGF_fnc_groupGarrison;

Preview mission - units stand still.

Do you have a marker on the map named "mrkName"?

Share this post


Link to post
Share on other sites

Ah, newbie mistake. Probably should take a break from editor, esp. at 1am. Works well. Thanks!

Share this post


Link to post
Share on other sites

Is there any way to make the editor placed units garrison a building so that they remain at their garrison position. Everytime they seem to stay in the building for a couple of minuets and then start coming outside especially when any shooting starts. I would like to be able to have them remain at there posts no matter what. Is this possible.

Share this post


Link to post
Share on other sites
Is there any way to make the editor placed units garrison a building so that they remain at their garrison position. Everytime they seem to stay in the building for a couple of minuets and then start coming outside especially when any shooting starts. I would like to be able to have them remain at there posts no matter what. Is this possible.

In the SBGF folder open the file name "fn_groupGarrison.sqf", then you should see the following line in the code:

doStop _x;

See if changing that to the following helps:

commandStop _x;

Share this post


Link to post
Share on other sites

Hey JShock can groupGarrison take more than 1 "markername" in command line? I will try it too and see. Just wondering if it could handle.

//For editor placed units (in group leader's init field)
0 = [this,"mrkName","mrkName","mrkName","mrkName",200] spawn SBGF_fnc_groupGarrison;

updated. Doesn't look like it. ideas for multiple markers?

7:14:43 Error in expression <","area_2","area_3","area_4",150] spawn SBGF_fnc_groupGarrison; 
{_units pushBac>
7:14:43   Error position: <SBGF_fnc_groupGarrison; 
{_units pushBac>
7:14:43   Error Undefined variable in expression: sbgf_fnc_groupgarrison
7:14:43 File C:\Users\Andrews\Documents\Arma 3\missions\AAAtestsidemissionJShock.Takistan\JSHK_fncs\fn_patrols.sqf, line 91

Edited by JAndrews1

Share this post


Link to post
Share on other sites

What would be the application? I can think of maybe one reason, but not too sure if there are other reasons.

Share this post


Link to post
Share on other sites
Hey JShock can groupGarrison take more than 1 "markername" in command line? I will try it too and see. Just wondering if it could handle.

//For editor placed units (in group leader's init field)
0 = [this,"mrkName","mrkName","mrkName","mrkName",200] spawn SBGF_fnc_groupGarrison;

updated. Doesn't look like it. ideas for multiple markers?

7:14:43 Error in expression <","area_2","area_3","area_4",150] spawn SBGF_fnc_groupGarrison; 
{_units pushBac>
7:14:43   Error position: <SBGF_fnc_groupGarrison; 
{_units pushBac>
7:14:43   Error Undefined variable in expression: sbgf_fnc_groupgarrison
7:14:43 File C:\Users\Andrews\Documents\Arma 3\missions\AAAtestsidemissionJShock.Takistan\JSHK_fncs\fn_patrols.sqf, line 91

Wouldn't you just make 2 separate groups and thus 2 separate markers?

Share this post


Link to post
Share on other sites
Wouldn't you just make 2 separate groups and thus 2 separate markers?

Yes, I am going to just use different call lines for different zones. It has to do with JSHK_fncs so.....

Share this post


Link to post
Share on other sites
Yes, I am going to just use different call lines for different zones. It has to do with JSHK_fncs so.....

If you need to execute on multiple markers and multiple groups all at once try the following template (may not be what your asking :confused:):

{
0 = _x spawn SBGF_fnc_groupGarrison;
sleep 2;
} forEach [[grpLead1,"mrkName1",200],[grpLead2,"mrkName2",200],[grpLead3,"mrkName3",200]];

Share this post


Link to post
Share on other sites

Thx for this script.

i love their reactivity... out of the box with no personal settings.

But i have an error:

17:21:39 Error in expression <_priorNew = _priors select _cause;

if (_priorNew > _priorCur) exitWith 
{
_oldD>
17:21:39   Error position: <_priorNew > _priorCur) exitWith 
{
_oldD>
17:21:39   Error Undefined variable in expression: _priornew

with a simple call:

_tango = [_target,EAST,75,0.3,["O_Soldier_F","O_Soldier_AR_F"],-1] spawn SBGF_fnc_garrison;

Share this post


Link to post
Share on other sites
i love their reactivity... out of the box with no personal settings.

Well I'm happy someone likes the vanilla AI reactivity (I haven't done anything to alter it :p).

And it seems the error is from a BIS function used inside the code, what is "_target" and where/how are you executing my function?

Share this post


Link to post
Share on other sites

lol i saw it when trying to fix the error. :D

_target is actually therisa... it's a marker.

i call your script with a simple function to launch different AI spawns and actions on a specific marker on the map. I just started it today in order to test a few AI scripts, so, for now, it's really simple.

_test = ["cm_to_therisa","WSG"] call fn_spawnAI;

//and the function:

private["_target","_type","_id","_groupId"];

_target = _this select 0;
_type = _this select 1;
...
switch (_type) do {
case "SBG" : {
	_tango = [_target,EAST,75,0.3,["O_Soldier_F","O_Soldier_AR_F"],-1] spawn SBGF_fnc_garrison; 
};
....
};

...

true

The error came when the tangos had an eye on me...

Share this post


Link to post
Share on other sites

Well this script doesn't do any alterations to any type of AI behavior, so if the error comes up when the AIs see you, it has to be another script/mod/addon causing the issue, or some BIS function that changed in the most recent A3 patch.

Share this post


Link to post
Share on other sites

Thx for this tool JShock.

You might correct your code to make it work properly if parameter 6 is used:

Remove the extra "s" in _positionsCount else you get an error and you don't get any garrison troops.

if ((_this select 5) isEqualTo -1) then
{
_positionCount = round(_buildCount * _pctFill);
}
else
{
_positionsCount = (_this select 5);
};

Also, line 53, you have an "off by one" error:

for "_i" from 0 to (_positionCount) step 1 do

If I specify I want 10 troops, I'll get 11 (from 0 to 10).

Thx.

  • Like 1

Share this post


Link to post
Share on other sites

Thanks for the information will try and update this in the coming days.

Share this post


Link to post
Share on other sites

Hey JShock. Thanks for this. Been using it and loving it in my upcoming mission designs. I run into a problem though. With Kunduz for example, some of the spawns happen right outside the buildings in midair causing the AI to fall to their death. Is this BIS fault or code fault? Wondering if this is because of ARMA2 building designs? KUNDUZ uses the JBAD buildings i believe. Anything to do to improve this? I mean either way its not a deal breaker i just ignore the dead bodies :P

Share this post


Link to post
Share on other sites
Hey JShock. Thanks for this. Been using it and loving it in my upcoming mission designs. I run into a problem though. With Kunduz for example, some of the spawns happen right outside the buildings in midair causing the AI to fall to their death. Is this BIS fault or code fault? Wondering if this is because of ARMA2 building designs? KUNDUZ uses the JBAD buildings i believe. Anything to do to improve this? I mean either way its not a deal breaker i just ignore the dead bodies :P

It could be that the buildings don't follow BI's building position system, in which case, this script won't work. And to be honest I neither have the time nor interest to see about an alternate way of combating that issue, you are more than welcome to explore options for it (i.e. a community building position(s) function).

Share this post


Link to post
Share on other sites
It could be that the buildings don't follow BI's building position system, in which case, this script won't work. And to be honest I neither have the time nor interest to see about an alternate way of combating that issue, you are more than welcome to explore options for it (i.e. a community building position(s) function).

Got it. Thanks man, best of luck.

Share this post


Link to post
Share on other sites

How to delete spawned units later in mission? Delete just units spawned by SBGF, infantry/static/cars/... and keep other units spawned by another script.

Share this post


Link to post
Share on other sites

How to delete spawned units later in mission? Delete just units spawned by SBGF, infantry/static/cars/... and keep other units spawned by another script.

Wow, after all this time I never realized my stupid mis-statement on the OP. I say the function must be spawned, but that was relative to where I was using it in my own scripts. If you call, instead of spawning the function, the return of that function is all the units spawned by the function.

To then delete, simply:

{deleteVehicle _x;} forEach arrayOfUnitsReturned;
I apologize to anyone else that may have been affected, but I do remeber these scripts coming out of a private project I was working on, which turned into being an sqf self-tutorial, in which I learned a lot, but missed a lot of simple things like this :p.
  • Like 1

Share this post


Link to post
Share on other sites

I am getting this error: http://postimg.org/image/4cjd9qd2d/

 

And this is my call line right after add task in my task.sqf:

_units = [_sidepos,WEST,_axis,0.3,["B_Soldier_F","B_Soldier_lite_F","B_Soldier_GL_F","B_soldier_AR_F","B_Soldier_SL_F","B_Soldier_TL_F","B_soldier_M_F","B_soldier_LAT_F","B_medic_F","B_Soldier_A_F","B_soldier_AT_F","B_soldier_AA_F"]] call SBGF_fnc_garrison; 

btw, _axis was defined earlier as a random number between 600-800 for radius.

 

And this I am using to delete the units at the end of task :

{deleteVehicle _x;} forEach _units;

Where could I be wrong J?

Share this post


Link to post
Share on other sites

In fn_garrison.sqf add the following on line 33:

_positionCount = [_this,5,-1,[0]] call BIS_fnc_param;

Replace lines 41-48 with:

if (_positionCount isEqualTo -1) then
{
    _positionCount = round(_buildCount * _pctFill);
};

In fn_buildingPositions line 37 change:

"House" to "Building"

See if doing that helps any.

Share this post


Link to post
Share on other sites

In fn_garrison.sqf add the following on line 33:

_positionCount = [_this,5,-1,[0]] call BIS_fnc_param;

Replace lines 41-48 with:

if (_positionCount isEqualTo -1) then
{
    _positionCount = round(_buildCount * _pctFill);
};

In fn_buildingPositions line 37 change:

"House" to "Building"

See if doing that helps any.

Works wonderfully well J !! Thank you.. ^^ Best garrison script ever ! :D

But you must update your script now to include this fix.

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

×