froggyluv 2136 Posted July 11, 2015 I understand it now -works great. Thanks gents. Share this post Link to post Share on other sites
jandrews 116 Posted July 12, 2015 (edited) hey, great script here. very nice to upgrade missions. My question is whats wrong with this line? trying this from trigger. grp0 = [getMarkerPos "mkr2", east, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfSquad_Weapons")] call BIS_fnc_spawnGroup; null = [this, units grp0, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; tried these too null = [(leader grp0), units grp0, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; null = [(getPosATL leader grp0), units grp0, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; I guess after more testing and attempting to use code in leader initbox, this script does not work with office buildings or airport buildings?? 0 = [getPosATL this, units group this, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf" null = [this, units group this, -1, false, false] execVM "Zen_OccupyHouse.sqf"; Edited July 12, 2015 by JAndrews1 Share this post Link to post Share on other sites
Zenophon 110 Posted July 13, 2015 hey, great script here. very nice to upgrade missions. My question is whats wrong with this line? trying this from trigger. grp0 = [getMarkerPos "mkr2", east, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfSquad_Weapons")] call BIS_fnc_spawnGroup; null = [this, units grp0, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; tried these too null = [(leader grp0), units grp0, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; null = [(getPosATL leader grp0), units grp0, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; I guess after more testing and attempting to use code in leader initbox, this script does not work with office buildings or airport buildings?? 0 = [getPosATL this, units group this, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf" null = [this, units group this, -1, false, false] execVM "Zen_OccupyHouse.sqf"; What exactly doesn't work? No units are moved or they're moved to the wrong building? The building distance is a little tricky, because buildings are detected from their center point. Even if the building appears to be within 10m of the group, the engine may not see it that way. In last line: [this, units group this, -1, false, false] execVM "Zen_OccupyHouse.sqf" the -1 will tell the script to use nearestBuilding, so it's guaranteed to find a building. This is better for filling just one building. The large office buildings (like in Kavala) are working; I use those to test the roof placement. However, it seems to not work with an airport control tower; nearestBuilding picks the next building away from that. nearestObjects is getting that building, as well as some airport lights (apparently those are a type of house). It looks like nearestBuilding misses some buildings, but nearestObjects detects some things that are not proper buildings. Share this post Link to post Share on other sites
jandrews 116 Posted July 14, 2015 Hey. thanks for the response. code below. units do not move. _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [this, units _grp13, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; //{_units pushBack _x} forEach units _grp13; RPT errors below. I // the pushback to see and no change. 21:36:19 Error in expression <ault")] call BIS_fnc_spawnGroup; nul = [this, units _grp13, 10, false, false] ex> 21:36:19 Error position: <this, units _grp13, 10, false, false] ex> 21:36:19 Error Undefined variable in expression: this 21:36:19 File C:\Users\Andrews\Documents\Arma 3\missions\COOP_20_[episode_1_].Altis\scripts\OpforGuer.sqf, line 51 AND 21:36:29 Error in expression <lse { _buildingsArray = nearestObjects [_center, ["house"], _buildingRadius]; };> 21:36:29 Error position: <_center, ["house"], _buildingRadius]; };> 21:36:29 Error Undefined variable in expression: _center 21:36:29 File C:\Users\Andrews\Documents\Arma 3\missions\COOP_20_[episode_1_].Altis\scripts\Zen_OccupyHouse.sqf, line 100 Share this post Link to post Share on other sites
Zenophon 110 Posted July 14, 2015 Hey. thanks for the response.code below. units do not move. _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [this, units _grp13, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; //{_units pushBack _x} forEach units _grp13; RPT errors below. I // the pushback to see and no change. 21:36:19 Error in expression <ault")] call BIS_fnc_spawnGroup; nul = [this, units _grp13, 10, false, false] ex> 21:36:19 Error position: <this, units _grp13, 10, false, false] ex> 21:36:19 Error Undefined variable in expression: this 21:36:19 File C:\Users\Andrews\Documents\Arma 3\missions\COOP_20_[episode_1_].Altis\scripts\OpforGuer.sqf, line 51 AND 21:36:29 Error in expression <lse { _buildingsArray = nearestObjects [_center, ["house"], _buildingRadius]; };> 21:36:29 Error position: <_center, ["house"], _buildingRadius]; };> 21:36:29 Error Undefined variable in expression: _center 21:36:29 File C:\Users\Andrews\Documents\Arma 3\missions\COOP_20_[episode_1_].Altis\scripts\Zen_OccupyHouse.sqf, line 100 'this' is the special value for the current object in an editor init field. Within a script/function run with execVM/call/spawn, '_this' is the arguments given; you just need to change the first argument to Occupy House to the position of the group: _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [_markerPos, units _grp13, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; You can also use (getPosATL leader _grp13), which should be very close to _markerPos. Share this post Link to post Share on other sites
jandrews 116 Posted July 14, 2015 (edited) I have tried these both and no results. units stand around. _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [(getPosATL leader _grp13),units _grp13, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; {_units pushBack _x} forEach units _grp13; _grp9 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [(_markerPos),units _grp9, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; {_units pushBack _x} forEach units _grp9; Edited July 15, 2015 by JAndrews1 Share this post Link to post Share on other sites
froggyluv 2136 Posted July 15, 2015 Tied this to an alert trigger and works awesome in getting startled ambushee's into cover insider. One problem, and I know this is an enginebug, is keeping them indoorss thru the firefight as they tend to come back outside and fight. Any chance to add a parameter to keep them inside longer such as Offense/Defense Bool? Share this post Link to post Share on other sites
Zenophon 110 Posted July 16, 2015 I have tried these both and no results. units stand around. _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [(getPosATL leader _grp13),units _grp13, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; {_units pushBack _x} forEach units _grp13; _grp9 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [(_markerPos),units _grp9, 10, false, false] execVM "scripts\Zen_OccupyHouse.sqf"; {_units pushBack _x} forEach units _grp9; Try -1 as the distance. The exact position of the building may not be within 10 meters of the group leader. Also, can you give me the exact value of _markerPos, so I can test this on the same building. Tied this to an alert trigger and works awesome in getting startled ambushee's into cover insider. One problem, and I know this is an enginebug, is keeping them indoorss thru the firefight as they tend to come back outside and fight. Any chance to add a parameter to keep them inside longer such as Offense/Defense Bool? If only there was a true/false switch to make the AI smart...unfortunately, I don't have control over the AI at a low enough level to change their tactics like that. Units moving to a position are monitored by the script and told to stop once they get there; however, being unitReady at the correct position isn't a sure thing, especially in combat. If they decide to run off before they get to the final position and are forced to stop by the script, it's difficult to detect that. You can try: { _x disableAI "FSM"; } forEach _units; to stop them from doing some things, but the group leader will likely still give targeting and attack orders. There's also things like setCombatMode and setBehaviour that are able to control their aggressiveness. I don't use those commands in the script, so they'll remain in effect if you apply them before/after the script runs. Share this post Link to post Share on other sites
jandrews 116 Posted July 18, 2015 (edited) Ok, so thats the thing. the radius. it works now. For peeps wanting this to spawn in via scripting. I added some random radius hopefully and with some testing it works. So random 300 is 150x150 from center. I almost want it more to cover buildings farther out. But good so far. The units do double / triple up on spots when using false to place units one by one, evenly seems to spread them out more with LESS doubling. There is still doubling of units in same positions. Filling from top down seems to spread them out more too. _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [(getPosATL leader _grp13),units _grp13,(random(300)+25), true, true, true] execVM "scripts\Zen_OccupyHouse.sqf"; {_units pushBack _x} forEach units _grp13; I guess another question is... would having units walk to position in place of teleport possibly change the doubling of units in 1 position?. I will test some more. after testing = NOPE! Edited July 19, 2015 by JAndrews1 Share this post Link to post Share on other sites
johnnyboy 3791 Posted July 19, 2015 @JAndrews1: I think your doubling up problem occurs because you are calling the script separately for each group. If you put all the units from multiple groups in one array, and call the script once passing that array, then there should be no doubling up on positions. @Zeno and all: I believe this is the magic combination of commands to keep a unit from leaving his position: unit1 forcespeed 0; unit1 disableai "TARGET"; dostop unit1 ; I use this for stationary snipers I've put on roofs and in towers, and they never move. DisableAI "TARGET" is key, as this makes them ignore any Engage orders. The value "TARGET" is misleading, because they will effectively target and shoot known enemies, and will also turn around if they sense you are behind them. But they will not leave the position. When I place a unit somewhere that the AI can't navigate to (on a roof without AI paths, or in castle tower window, etc.), then they must not move, or they will fall to their deaths. But for Zenophon's house occupy script, I personally like the fact that they sometimes move during combat. It happens infrequently enough that it makes it less predictable and more interesting, IMO. Share this post Link to post Share on other sites
jandrews 116 Posted July 19, 2015 @JAndrews1: I think your doubling up problem occurs because you are calling the script separately for each group. If you put all the units from multiple groups in one array, and call the script once passing that array, then there should be no doubling up on positions.Do you have an example of how do that? Not sure if you can use spawnGroup in array. I have about 6 groups doing this. _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [(getPosATL leader _grp13),units _grp13,(random(300)+25), true, true, true] execVM "scripts\Zen_OccupyHouse.sqf"; {_units pushBack _x} forEach units _grp13; Share this post Link to post Share on other sites
Zenophon 110 Posted July 20, 2015 @JAndrews1: I think your doubling up problem occurs because you are calling the script separately for each group. If you put all the units from multiple groups in one array, and call the script once passing that array, then there should be no doubling up on positions.@Zeno and all: I believe this is the magic combination of commands to keep a unit from leaving his position: unit1 forcespeed 0; unit1 disableai "TARGET"; dostop unit1 ; I use this for stationary snipers I've put on roofs and in towers, and they never move. DisableAI "TARGET" is key, as this makes them ignore any Engage orders. The value "TARGET" is misleading, because they will effectively target and shoot known enemies, and will also turn around if they sense you are behind them. But they will not leave the position. When I place a unit somewhere that the AI can't navigate to (on a roof without AI paths, or in castle tower window, etc.), then they must not move, or they will fall to their deaths. But for Zenophon's house occupy script, I personally like the fact that they sometimes move during combat. It happens infrequently enough that it makes it less predictable and more interesting, IMO. 'Target' is group leader orders and 'AutoTarget' is the AI's own individual attack logic, so your code will solve the issue of them receiving attack orders while walking to the position as well as try to move away from their position. I'm going to update the script with your suggestion as well as use the new param/params commands on the arguments; the new params commands will be much faster than a scripted solution and make the script easier to use. @JAndrews1: I think your doubling up problem occurs because you are calling the script separately for each group. If you put all the units from multiple groups in one array, and call the script once passing that array, then there should be no doubling up on positions. Do you have an example of how do that? Not sure if you can use spawnGroup in array. I have about 6 groups doing this. _grp13 = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; nul = [(getPosATL leader _grp13),units _grp13,(random(300)+25), true, true, true] execVM "scripts\Zen_OccupyHouse.sqf"; {_units pushBack _x} forEach units _grp13; Something like this: _units = []; for "_i" from 1 to 6 do { _grp = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; _units append (units _grp); }; nul = [_markerPos, units,(random(300)+25), true, true, true] execVM "scripts\Zen_OccupyHouse.sqf"; If you need more features than simple repetition (e.g. the group changes each iteration), I can add that. If _markerPos is changing, that requires a different approach. Share this post Link to post Share on other sites
froggyluv 2136 Posted July 20, 2015 I'm going to update the script with your suggestion as well as use the new param/params commands on the arguments; the new params commands will be much faster than a scripted solution and make the script easier to use. Thats great news! Love this script and having some of the best CQB to date for as well as Arma engine can produce anyways. Share this post Link to post Share on other sites
jandrews 116 Posted July 21, 2015 (edited) Something like this: _units = []; for "_i" from 1 to 6 do { _grp = [_markerPos, _side, (configfile >> "CfgGroups" >> "West" >> "Guerilla" >> "Infantry" >> "IRG_InfAssault")] call BIS_fnc_spawnGroup; _units append (units _grp); }; nul = [_markerPos, units,(random(300)+25), true, true, true] execVM "scripts\Zen_OccupyHouse.sqf"; If you need more features than simple repetition (e.g. the group changes each iteration), I can add that. If _markerPos is changing, that requires a different approach. I updated my code. this works some much better. thanks. I did get an error with this _units append (units _grp); So i // that line. I think it still works. will test. thanks again for example. Edited July 21, 2015 by JAndrews1 Share this post Link to post Share on other sites
johnnyboy 3791 Posted July 21, 2015 Note that Zeno made a typo error in the last line. He forgot the underscore (_) in _units in the call to Zen_OccupyHouse.sqf. So that line should read: nul = [_markerPos, _units,(random(300)+25), true, true, true] execVM "scripts\Zen_OccupyHouse.sqf"; Share this post Link to post Share on other sites
Zenophon 110 Posted July 21, 2015 Summary Greetings fellow scripters, I've added some new usabilty improvements to this script. All of the arguments are now checked for the correct type. If the first two arguments aren't right (or aren't given), the script stops and prints an error. For the rest of the arguments, the script will substitute a default value if necessary and continue onwards. It will also print an error (to local chat and to the log) and stop if no buildings have been found, this should tell users why things aren't working in some cases. Finally, thanks to a suggestion by JohnnyBoy, the AI no longer respond to orders from their group leader to move from their positions and attack enemy units (they'll stil target and fire individually). The new version is already hosted on Google Drive, and will be on Armaholic soon. All relevant sections of the original post have been updated. Changelog 7/21/15 Added: Error reporting for invalid position and unit array arguments Added: Error report if no buildings are found Improved: Parameters 3, 4, and 5 are now optional and check for the correct type Improved: Parameters 6 and 7 check for the correct type Improved: AI should now stay in place better (thanks to JohnnyBoy) Feedback I updated my code. this works some much better. thanks. I did get an error with this _units append (units _grp); So i // that line. I think it still works. will test. thanks again for example. Note that Zeno made a typo error in the last line. He forgot the underscore (_) in _units in the call to Zen_OccupyHouse.sqf. So that line should read: nul = [_markerPos, _units,(random(300)+25), true, true, true] execVM "scripts\Zen_OccupyHouse.sqf"; I think the '_units' thing must be the error; append is working on stable branch for me (it was only on dev branch for a while). Share this post Link to post Share on other sites
Guest Posted July 21, 2015 Thanks for informing us about the updated release :cool: Release frontpaged on the Armaholic homepage. Infantry Occupy House Script 7/21/15 Share this post Link to post Share on other sites
jandrews 116 Posted July 22, 2015 (edited) never mind. got it working. thanks again. Edited July 22, 2015 by JAndrews1 Share this post Link to post Share on other sites
judgerw 10 Posted September 1, 2015 Any chance of getting this working for editor placed buildings? Or does anyone know of another script/method that accomplishes that? Thanks! Share this post Link to post Share on other sites
Zenophon 110 Posted September 1, 2015 I don't really see many buildings in the editor, so I'm assuming it's equivalent to spawning them with createVehicle. Once the building is detected, it's preset positions will be accessible, so it's just a matter of getting the object.Did you try the fill radius argument as e.g. 50 or so meters? This will make the script use the nearestObjects command; using -1 will have it use nearestBuilding, which might be where the issue is. nearestObjects is working for me; try this in the debug console with a spawned building. buildingsArray0 = nearestObjects [getPosATL player, ["house"], 50]; buildingsArray1 = nearestObjects [getPosATL player, ["building"], 50]; hint str (buildingsArray0 arrayIntersect buildingsArray1) This is basically what the script uses; it just replaces the position and distance with its arguments. I can replace nearestBuilding when using '-1' with nearestObjects and just select the first one; but then I'd have to figure out a distance to search in that not inefficiently large or too small to find anything. 1 Share this post Link to post Share on other sites
scottb613 284 Posted September 2, 2015 Hi Folks, Brand new around here - anxious to try this script... I believe I performed the install correctly... No, but here is a five step guide to using it: Open a new mission in the editor and save it Put the script in the mission folder Place a group (F2) near a building (Optional) Make the group leader the player Copy this into his init: I placed the SQF in the following directory: C:\Program Files\Steam\steamapps\common\Arma 3\Missions *** I saved the mission PBO file to the same place... I added a group near some buildings and added the code 0 = [getPosATL X, units X] execVM "Zen_OccupyHouse.sqf"; to the team leaders "Initialization" field... ERROR: Is whenenver I run the mission - it starts off with an error stating "Zen_OccupyHouse.sqf" not found... Any ideas ??? I'm sure I must be doing something wrong... Thanks... Regards,Scott Share this post Link to post Share on other sites
cosmic10r 2331 Posted September 2, 2015 Hi Folks, Brand new around here - anxious to try this script... I believe I performed the install correctly... I placed the SQF in the following directory: C:\Program Files\Steam\steamapps\common\Arma 3\Missions *** I saved the mission PBO file to the same place... I added a group near some buildings and added the code 0 = [getPosATL X, units X] execVM "Zen_OccupyHouse.sqf"; to the team leaders "Initialization" field... ERROR: Is whenenver I run the mission - it starts off with an error stating "Zen_OccupyHouse.sqf" not found... Any ideas ??? I'm sure I must be doing something wrong... Thanks... Regards, Scott Hey Scott, You need the script in the actual mission folder... that's why the engine can't find it... if you pbo'd the mission then you need to unpbo it and add the .sqf to the mission folder and re-pbo C:\Program Files\Steam\steamapps\common\Arma 3\Missions\ScottsMission.altis the sqf needs to go in that type of folder structure. then be exported to pbo. edit -- Should be libraries\documents\Arma3\missions\\ScottsMission.altis 1 Share this post Link to post Share on other sites
scottb613 284 Posted September 2, 2015 Hi... Thanks - let me give it a try - I understand what you're saying - the mission folder logistics I need to figure out - I'm sure I'll get it... :) Regards,Scott Share this post Link to post Share on other sites
scottb613 284 Posted September 2, 2015 Hi... Jam'n - got it - THANK YOU again... I was looking for the mission and didn't realize there were two "Arma" directories in "My Docs" folder - I was looking in the default and not the one associated with my current profile... Now to test it... :) Regards,Scott Share this post Link to post Share on other sites
cosmic10r 2331 Posted September 2, 2015 Hi... Jam'n - got it - THANK YOU again... I was looking for the mission and didn't realize there were two "Arma" directories in "My Docs" folder - I was looking in the default and not the one associated with my current profile... Now to test it... :) Regards, Scott Lol ... well i quoted the wrong folder structure but Im glad you got the gist... generally the arma missions you make in the editor show up in documents/arma3/missions/ScottsAwesomeMission.altis the sqf goes in there and then you can export it in the editor and the sqf will be included in the exported pbo... :) 1 Share this post Link to post Share on other sites