Jump to content
zorilya

Garrison on the fly script

Recommended Posts

Here is my Garrison script project. It allows you to task a group with garrisoning a building, where they will stay quite well underfire but will engage if not pushed on.

you define the unit it is used on and the radius within which he will search for buildings. This building list is then chosen from randomly for garrisoning. adding a much needed random element to the placement of units in urban environments. I use it to make towns a little more lethal. having to check every window and door before clearing out a building adds a real edge to urban and cqb gameplay.

I hope you enjoy it as much as i do

https://rapidshare.com/files/2881858049/Garrison_script.rar

Full readme is enclosed in the file.

p.s: I forgot to add that the script only covers Zargabad, Takistan, Lingor and Fallujah so far as they have the most enterable buildings. (Fallujah i'm sure was around 10000 hehe)

requires Jayarma2lib_new

Edited by zorilya

Share this post


Link to post
Share on other sites

Hi, I tried it and have run into a problem, only a few units enter a building and all the units seem to go to the same location in each building, units lefts outside the building seem to move to a location and group together. There are plenty of empty positions in the area.

Share this post


Link to post
Share on other sites

hmmm could you detail the issue a little more. i.e world, area name, and so on so i could try and reproduce?

Share this post


Link to post
Share on other sites

Takistan Airport Control tower, Bottom Middle of the map and the units placed near the T Junction.

I have about 12 AI units in a group right in the middle of the group of buildings

calling with nul = [this,300] execVM "Garrison_script.sqf"

Mostly 1 unit enters the barracks and goes to room 3, a few go to the hanger but the rest hide by the side of one of the buildings.

Share this post


Link to post
Share on other sites

how are you executing the world_build_list.sqf?

actually just tested .. it shouldn't matter whether it's in the init or in a triggger set to go off immediately. I've tested a group of 13 at the T just north of that tower with a radius of 300 like you had and all 7 of the times they chose different buildings and garrisoned successfully.... so i forced them to go into the tower by setting the radius to 30 and placing the leader who is calling the script, next to the tower. They garrisoned successfully 4 times ( aside from a few pathing problem causing units to push one another off the top. hehe) no one hung around outside. i usually find the tell tale mark of the script not working properly is when units return to formation on the leader.

but still how are you executing the "world_build_list.sqf"?

Edited by zorilya

Share this post


Link to post
Share on other sites

I'm a little confused I renamed "world_build_list.sqf" as init,sqf but it still does the same thing.

I've been through the script and it seems your using an addon to get the string function, I don't have it so that's why it's messing up the building list I think.

Share this post


Link to post
Share on other sites

the string functions are part of Jayarmalib_new..... are you not using it? it's very handy hehe

i completely overlooked mentioning that also... thankyou

Edited by zorilya

Share this post


Link to post
Share on other sites

Odd I am using CBA but still not working.

I don't see these functions listed in CBA as all those functions begin with CBA

The ones your using are jayarma2lib_fnc_stringTrim;

Edited by F2k Sel

Share this post


Link to post
Share on other sites

yeah i was hoping that i would've editted that fast enough.. i meant jayaramlib :)

Share this post


Link to post
Share on other sites

What are you trying to do with that function just return the building ID number?

Share this post


Link to post
Share on other sites

those two functions are removing the hash tag from the building name. so that it is in the correct formant for the find function

Share this post


Link to post
Share on other sites

Couldn't this be done without an addon. It finds the first space and then deletes all the characters up to and including the space leaving you with.

"5169: mil_barracks.p3d"

This could be made into a function but I really suck at that.

_build = ["185c3200# 5169: mil_barracks.p3d","185c3230# 53169: mil_barracks.p3d"];

for "_i" from 0 to count _build do {


_BuildArray = toarray (_build select _i);
_inc = (_BuildArray find 32);

for "_i" from 0 to _inc  do
{
_BuildArray set [0, -1];
_BuildArray = _BuildArray - [-1]; 
};

sleep 2;
hint str toString _BuildArray;

};

Share this post


Link to post
Share on other sites

that is what the jayarma2lib functions are for. i'll look into writing a new function for this though.

Share this post


Link to post
Share on other sites

I still don't see why there is a need to create the buildings array in the first place, I'm sure this could be done in the script. I must be missing some reason for doing it this way.

Share this post


Link to post
Share on other sites

the reason there is a global buildings array is so that (as yet unimplimented) groups can talk to each other to avoid garrisoing the same building. The reason for the buildings array that gets collected by the unit is so that the unit knows what buildings are within the radius, which he can then reference to the global buildings list and get the number of positions, so that the units may then garrison it without any errors.

in short, to lay the ground work for a larger scale script that works more efficiently.

Share this post


Link to post
Share on other sites

Nice, I've had a few runs with it and had no errors.

But when Testing at Zargabad,radius 200 meters, group of 14 units.

In the area I suspect there are over a hundred building positions but the units still tend to bunch usually in room 1

I've not seen a single unit move up stairs.

Any ideas?

I enabled the hints

sleep 1;

hint (str(_buildingnumber));

sleep 1;

hint (str(_localbuilding));

sleep 2;

only hint (str(_localbuilding)); returns just a single building, get nothing from hint (str(_buildingnumber));

Edited by F2k Sel

Share this post


Link to post
Share on other sites

it sounds like your not running the over arching world_build_list.

it would explain why the _localbuilding variable is returning but not the _buildingsnumber and...

the units are set to go to the nearest building and stand there if they cannot find a building so it would explain that too.

are you getting a silent hint at the mission start saying "loading zargabad building list" or something to that effect? if not check the running of the world_build_list.sqf in the Init

Share this post


Link to post
Share on other sites

Ha your right well almost, I made the init but just placed "world_build_list.sqf"; in it I forgot the [] execvm part.

Working now thanks.

Share this post


Link to post
Share on other sites

Wouldn't it be easier to just set a variable on the house to indicate that it's occupied instead of pushing them all into huge sqf files? I've used that before and it worked quite well :)

e.g

_house setVariable ["TAG_occupied",true];

and then later

if (!(_someOtherHouse getVariable ["TAG_occupied",false])) then {
 _someOtherHouse setVariable ["TAG_occupied",true];
 // code to insert units into house
};

Share this post


Link to post
Share on other sites

are you meaning just to mark the houses as occupied so that i can avoid overlaps or for something else?

Share this post


Link to post
Share on other sites

You were talking earlier about not putting the same groups in the same house, that's what I meant.

Share this post


Link to post
Share on other sites

cool i'm unfarmiliar with your method but i'll do a bit of reading and see what i can do thanks man

Share this post


Link to post
Share on other sites

reading over your example again .. shouldn't the condition be a check for if the house is not occupeid i.e. (!(_someotherhouse getvariable ["TAG_occupied", true])) because if it's not occupied they can move in else they should find another house. or am i misunderstanding your code?

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

×