Jump to content
Zenophon

Release - Infantry Occupy House Script

Recommended Posts

Guest

Thanks for informing us about the updated release :cool:

Release frontpaged on the Armaholic homepage.

================================================

We have also "connected" these pages to your account on Armaholic.

This means in the future you will be able to maintain these pages yourself if you wish to do so. Once this new feature is ready we will contact you about it and explain how things work and what options you have.

When you have any questions already feel free to PM or email me!

Share this post


Link to post
Share on other sites

Looks good Zenophon, however noticed that when having more than one group can solve in several units in one spot, it would also be nice if it could occupy editor placed bunkers(this is only wishful thinking ;) )

Share this post


Link to post
Share on other sites

Hey there Zenophon,

I need your help please.

I'm trying to use your script on a spawned group, but I just can't make it work for some reason. I'm activating it via trigger (On ACT:_nul=[]execvm "Files\ShapurSpwn.sqf"; ), I have a marker named "GrpM" in editor, then I have this inside "ShapurSpwn.sqf".

// First Squad

ShapurGP = Creategroup EAST;

ShapurGP createUnit ["CAF_AG_ME_T_GL", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"];

ShapurGP createUnit ["CAF_AG_me_t_AK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];

ShapurGP createUnit ["CAF_AG_me_t_AK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];

ShapurGP createUnit ["CAF_AG_me_t_AK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];

ShapurGP createUnit ["CAF_AG_me_t_RPK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];

ShapurGP createUnit ["CAF_AG_ME_T_SVD", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];

ShapurGP createUnit ["CAF_AG_ME_T_RPG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];

_nul=[(getMarkerPos "GrpM"), units group ShapurGp, 100, true,false] execVM "files\Zen_OccupyHouse.sqf"; //???????????

//[leader ShapurGP, units group ShapurGp, 100, true,false] execVM "files\Zen_OccupyHouse.sqf"; //Alternate//???????????

hint "Done"; //I only have this in here to tell when everything is done. Will remove once units are correctly placed in building

I have nothing related to this in my init.sqf, I need to spawn these guys later in the mission. I spawn them just fine, using the createunit command you recommended (instead of the BIS_fnc_spawnGroup method I usually use), however they are only spawned, not placed/teleported in positions in building. Please have a look at the lines commented with //??????????? in particular and tell me what I'm doing wrong please. In case there's ANY doubt(lol), yes I'm still NOOBISH.

Thanks to whomever ends up helping.

Share this post


Link to post
Share on other sites
Hey there Zenophon,

I need your help please.

I'm trying to use your script on a spawned group, but I just can't make it work for some reason. I'm activating it via trigger (On ACT:_nul=[]execvm "Files\ShapurSpwn.sqf"; ), I have a marker named "GrpM" in editor, then I have this inside "ShapurSpwn.sqf".

// First Squad
ShapurGP = Creategroup EAST;

ShapurGP createUnit ["CAF_AG_ME_T_GL", getMarkerPos "GrpM", ["GrpM"], 5, "FORM"];
ShapurGP createUnit ["CAF_AG_me_t_AK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];
ShapurGP createUnit ["CAF_AG_me_t_AK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];
ShapurGP createUnit ["CAF_AG_me_t_AK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];
ShapurGP createUnit ["CAF_AG_me_t_RPK74", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];
ShapurGP createUnit ["CAF_AG_ME_T_SVD", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];
ShapurGP createUnit ["CAF_AG_ME_T_RPG", getMarkerPos "GrpM", ["GrpM"], 1, "FORM"];

_nul=[(getMarkerPos "GrpM"), units group ShapurGp, 100, true,false] execVM "files\Zen_OccupyHouse.sqf";//??????????? 
//[leader ShapurGP, units group ShapurGp, 100, true,false] execVM "files\Zen_OccupyHouse.sqf";//Alternate//??????????? 

hint "Done";//I only have this in here to tell when everything is done. Will remove once units are correctly placed in building

I have nothing related to this in my init.sqf, I need to spawn these guys later in the mission. I spawn them just fine, using the createunit command you recommended (instead of the BIS_fnc_spawnGroup method I usually use), however they are only spawned, not placed/teleported in positions in building. Please have a look at the lines commented with //??????????? in particular and tell me what I'm doing wrong please. In case there's ANY doubt(lol), yes I'm still NOOBISH.

Thanks to whomever ends up helping.

Since 'ShapurGp' is already a group, you do not need to use the 'group' command. Try this:

_nul = [(getMarkerPos "GrpM"), units ShapurGp, 100, true, false] execVM "files\Zen_OccupyHouse.sqf";
// or
_nul = [(getPosATL leader ShapurGP), units ShapurGp, 100, true, false] execVM "files\Zen_OccupyHouse.sqf";

In the second usage you must directly get the position of the leader.

You only need 'group' to get the group of an object; 'units' can be used on just an object as well. I use 'units group' together in the usage example for clarity.

https://community.bistudio.com/wiki/group

https://community.bistudio.com/wiki/units

Share this post


Link to post
Share on other sites

Spot on bud!

Gods, when it's something that small...lesson learned though. Thanks.

I love how easy it is to use custom units and unit numbers with your script and now I can place them in building too. Cheers

ps., In case you were wondering why my parameter for evenly spaced units were set to false, it was only for testing this out, it's actually one of my favorite features.

Edited by Lost_Samurai

Share this post


Link to post
Share on other sites

Hi Zenophon !

Is this a good way to execute your script in MP (dedicated server) or should i remove the isServer check ?

Unit (placed in editor, not spawned) init line:

if (isServer) then {0 = [getPosATL this, units group this, -1, true, false] execVM "scripts\Zen_OccupyHouse.sqf";};

Share this post


Link to post
Share on other sites
Hi Zenophon !

Is this a good way to execute your script in MP (dedicated server) or should i remove the isServer check ?

Unit (placed in editor, not spawned) init line:

if (isServer) then {0 = [getPosATL this, units group this, -1, true, false] execVM "scripts\Zen_OccupyHouse.sqf";};

This should work fine for AI local to the server. You would not want to remove the isServer check because every client would run the function and do unnecessary work. Some of the commands on the units could work remotely, while others won't, leading to strange results. In general, the function should be executed where all the units are local, so if you use it on a group of players, some things may not work (like units facing the right direction). The script was designed to handle AI only groups on whichever machine they are local to.

Share this post


Link to post
Share on other sites

So I cant seem to get this to work, dropping the folder in my test mission and the exec vm in my init.sqf, is there some trick to this?

Share this post


Link to post
Share on other sites

hi Zenophon !

could you maybe add a function to your script that checks if another house position in x meters is already occupied ?

I often have two units in right next to each other which looks odd.

Or maybe add a parameter that makes the two nearest positions to a already occupied position unavailable for other units running your script.

Share this post


Link to post
Share on other sites
So I cant seem to get this to work, dropping the folder in my test mission and the exec vm in my init.sqf, is there some trick to this?

If you are using it in the init.sqf, then you need to get the name of the objects. For units placed in the editor, you can name them anything then use that to refer to the object. So if you placed a group of units and the leader object had the name 'X':

0 = [getPosATL X, units X, -1, true, false] execVM "Zen_OccupyHouse.sqf";

hi Zenophon !

could you maybe add a function to your script that checks if another house position in x meters is already occupied ?

I often have two units in right next to each other which looks odd.

Or maybe add a parameter that makes the two nearest positions to a already occupied position unavailable for other units running your script.

Each building position is removed as it is used, so units should not be spawning at exactly the same position. However, if a building has two positions very near each other, then two unit might end up looking out the same window. Sorting all the positions by which are nearest every time a unit is placed would significantly increase the processing time of the script for large buildings.

This could be a bug though, so if you can tell me what map and the coordinates of the building I will test it further.

Share this post


Link to post
Share on other sites
If you are using it in the init.sqf, then you need to get the name of the objects. For units placed in the editor, you can name them anything then use that to refer to the object. So if you placed a group of units and the leader object had the name 'X':

0 = [getPosATL X, units X, -1, true, false] execVM "Zen_OccupyHouse.sqf";

Ok, so I'd enter that string individually in the init.sqf, for each squad that I wanted to use the script. What if I wanted it to be a universal set that all infantry, AAF, CSAT and NATO, would follow automatically, but could be deactivated for certain squads. Is that possible? Thanks for the assist, in case it's not obvious, I'm fairly new to script/mod usage, the only activation method I've used thus far is through the init file.

Share this post


Link to post
Share on other sites
Ok, so I'd enter that string individually in the init.sqf, for each squad that I wanted to use the script. What if I wanted it to be a universal set that all infantry, AAF, CSAT and NATO, would follow automatically, but could be deactivated for certain squads. Is that possible? Thanks for the assist, in case it's not obvious, I'm fairly new to script/mod usage, the only activation method I've used thus far is through the init file.

You can loop through every group and check if the script should be used. For efficiency, I recommend compiling the script beforehand:

Zen_OccupyHouse = compileFinal preprocessFileLineNumbers "Zen_OccupyHouse.sqf";
_blackList = [group player, group Y];

{
   if ((side _x == WEST) && {!(_x in _blackList)}) then {
       0 = [getPosATL leader _x, units _x, -1, true, true] call Zen_OccupyHouse;
   };
} forEach allGroups;

You can use named units in the editor to get their groups and put them into the array of groups not to move. Then loop through all groups and decide based upon the side of the group and if it's blacklisted whether to garrison them. You can change 'WEST' to any side, or use '!=' instead of '==' to exclude that one side.

Edited by Zenophon
Code Error

Share this post


Link to post
Share on other sites

Ok, that seems much more straight forward. So the above code will run through each squad and check it against the blacklist, and if its close enough to garrison, and the blacklist is as easy as putting the group/unit name under _blackList = [group player, group Y];

Last question, and a good indication of how new I am at this, where would I put that code?

Thanks for all your assistance.

Share this post


Link to post
Share on other sites
Ok, that seems much more straight forward. So the above code will run through each squad and check it against the blacklist, and if its close enough to garrison, and the blacklist is as easy as putting the group/unit name under _blackList = [group player, group Y];

Last question, and a good indication of how new I am at this, where would I put that code?

Thanks for all your assistance.

I would put in the init.sqf, as it would be easier to find, change, and reuse. Also, if you decided to spawn some groups through scripting as well as in the editor, using allGroups in the editor would not include them.

If you are making a multiplayer mission, I highly recommend putting the code in an if statement that only runs on the server:

if (isServer) then {
   // ...
};

Share this post


Link to post
Share on other sites

Alright, so I have the script in my test mission folder, and

Zen_OccupyHouse = compileFinal preprocessFileLineNumbers "Zen_OccupyHouse.sqf";

_blackList = [group player, group Y];

{

if ((side _x == WEST) && {!(_x in _blackList})) then {

0 = [getPosATL leader _x, units _x, -1, true, true] call Zen_OccupyHouse;

};

} forEach allGroups;

copy pasted in my init.sqf. I've tried having a squad spawn on one of the flat square green miliary command huts, tried having the squad move to it, and even tried the script for the squad leaders init you suggested on page 2 of this forum, the squad will not move to or teleport to window locations, or the assignable squad points on the roof. I know I'm making some error in it's use, but I don't see where.

Share this post


Link to post
Share on other sites
Alright, so I have the script in my test mission folder, and

Zen_OccupyHouse = compileFinal preprocessFileLineNumbers "Zen_OccupyHouse.sqf";
_blackList = [group player, group Y];

{
   if ((side _x == WEST) && {!(_x in _blackList})) then {
       0 = [getPosATL leader _x, units _x, -1, true, true] call Zen_OccupyHouse;
   };
} forEach allGroups;  

copy pasted in my init.sqf. I've tried having a squad spawn on one of the flat square green miliary command huts, tried having the squad move to it, and even tried the script for the squad leaders init you suggested on page 2 of this forum, the squad will not move to or teleport to window locations, or the assignable squad points on the roof. I know I'm making some error in it's use, but I don't see where.

I apologize, the error is mine. In the code I posted, there is a parenthesis out of place; the if statement should have ')})' not '}))' at the end:

if ((side _x == WEST) && {!(_x in _blackList)}) then {

That's what happens when I don't test code. I thought these errors were always shown, but you might need -showScriptErrors in the launcher parameters.

Share this post


Link to post
Share on other sites

Ok, that did it! Squads that are place on the building in the editor will now pop to the appropriate window locations. Squads that are spawned elsewhere and move to the building won't, but that's probably just a few things in the script I'll have to set up. Thanks again for all your patient assistance getting this running, it'll be a huge help.

Share this post


Link to post
Share on other sites

It just doesn't work for me... Any ideas why?

I'm placing a group near a building,

throw your script into the missions folder,

copy this into the group leaders init(he isn't a player, just AI):0 = [getPosATL this, units group this, -1, true] execVM "Zen_OccupyHouse.sqf"

also tried that: if (isServer) then {0 = [getPosATL this, units group this, -1, true, false] execVM "Zen_OccupyHouse.sqf";};

I'm, playing with the following mods:

ACE 3 Unofficial PWS Version

Alive... (not using that much modules of it in that mission, tried it without them but Alive doesn't seem to cause it.)

Ares (Problem may be here, because as far as I know it uses your script to garison units with Zeus)

Bornholm (mission is on Bornholm)

Camofaces

CBA

JSRS2

KGB NoZeus

RHS AFRF

RHS USF

TFAR

Would be great if you have any Ides why it doesn't want to work. Will try some things myself now and post if I found out why it doesn't work.

Share this post


Link to post
Share on other sites
It just doesn't work for me... Any ideas why?

I'm placing a group near a building,

throw your script into the missions folder,

copy this into the group leaders init(he isn't a player, just AI):0 = [getPosATL this, units group this, -1, true] execVM "Zen_OccupyHouse.sqf"

also tried that: if (isServer) then {0 = [getPosATL this, units group this, -1, true, false] execVM "Zen_OccupyHouse.sqf";};

I'm, playing with the following mods:

ACE 3 Unofficial PWS Version

Alive... (not using that much modules of it in that mission, tried it without them but Alive doesn't seem to cause it.)

Ares (Problem may be here, because as far as I know it uses your script to garison units with Zeus)

Bornholm (mission is on Bornholm)

Camofaces

CBA

JSRS2

KGB NoZeus

RHS AFRF

RHS USF

TFAR

Would be great if you have any Ides why it doesn't want to work. Will try some things myself now and post if I found out why it doesn't work.

It works in the script's old test mission, which I've kept all this time, with this code in the leader of an AI group's init field:

0 = [getPosATL this, units group this, -1, true, false] execVM "Zen_OccupyHouse.sqf"

My first guess for why it doesn't work is the buildings in Bornholm. This script relies upon predefined building positions to place units (where you see lines drawn when commanding AI in a building). If there are too few or none of these (or the building isn't enterable), the script has nowhere to move the units. The script assumes that all buildings have some positions because enterable buildings are standard on Altis.

If this is the issue, for partially enterable buildings the solution is to generate valid positions manually. The point of this script is that the units look out windows. My framework's Zen_FindBuildingPositions function will generate positions, but you'd need to check each one for having a decent view outside the building. The time to compute positions and the success rate of the script would be significantly worse, as many predetermined building positions tend to be near windows.

Share this post


Link to post
Share on other sites

Thank you for your help, maybe that's it, haven't tried that out. Will test it on Altis, even if the buildings on bornholm are mostly the same as in altis. But it's to late for me today, will give feedback tomorrow.

Share this post


Link to post
Share on other sites

Okay, tried it on Altis and had no problems at all. So it has to be Bornholm, even if it uses the same buildings.

Share this post


Link to post
Share on other sites
Okay, tried it on Altis and had no problems at all. So it has to be Bornholm, even if it uses the same buildings.

If the buildings have the exact same 3D model and config, it may be detecting the buildings themselves that is failing. The script uses nearestBuilding and nearestObjects (with type 'house') to get possible buildings. I may be that those commands are unreliable for some reason; if so, only BIS can fix that.

Share this post


Link to post
Share on other sites

Zenophon, you might want to consider integrating these changes from AntonStruyks Ares(after asking and stuff, but I'm sure you would have done that):

https://github.com/astruyk/Ares/blob/master/src/addons/ares_zeusExtensions/functions/fn_ZenOccupyHouse.sqf

With his changes the script works everywhere. As long as there is a building close they just hop into it, doesn't matter what kind of building..and they appear mostly in good spots. And he tweaked it, that they are able to turn around and shoot back when you manage to enter the house.

Share this post


Link to post
Share on other sites
Zenophon, you might want to consider integrating these changes from AntonStruyks Ares(after asking and stuff, but I'm sure you would have done that):

https://github.com/astruyk/Ares/blob/master/src/addons/ares_zeusExtensions/functions/fn_ZenOccupyHouse.sqf

With his changes the script works everywhere. As long as there is a building close they just hop into it, doesn't matter what kind of building..and they appear mostly in good spots. And he tweaked it, that they are able to turn around and shoot back when you manage to enter the house.

He tweaked the angle to check for line of sight above the window from 15 to 10 degrees, and he use doWatch and forceSpeed instead of lookAt and doStop. lookAt could prevent units from turning around, but doStop should not.

Changing the angle, FOV_ANGLE, is the only thing that would improve the chance of placing a unit. The problem with changes like this is that different FOV values may be better for different buildings. There really isn't a single perfect value that I can make assurances on.

If doWatch works much better than lookAt, I can update the script. I'd also like to test the FOV angle more and figure out why a difference of 5 degrees is significant.

Share this post


Link to post
Share on other sites

So, if I understand it right, it only works on vanilla maps ?

I tried it on zargabad from AiA and it works to an extent, they'll occupy a building but only on a balcony and all pretty much on the same spot. If there's no building near with a balcony, they just won't move.

Oh well, back to Altis :)

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

×