Zenophon 110 Posted July 24, 2014 Overview This script teleports AI units into nearby buildings at appropriate window positions. Units will stand and face the window so they can fire out of it. Units are moved to random windows every time. If there are enough units, every possible window will be covered; otherwise, you won't know where they are watching. When there are multiple possible windows to face, units will face one at random. Units will not face a windows more than 5 meters away, and the windows will have a reasonable field of view. By using this script, you no longer have to manually place units at windows and struggle with the 2d editor. This script allows you to easily simulate the AI occupying buildings and defending their position realistically. It works for just a few units to surprise players, and on a large scale to put dozens of enemies into defensive positions all across a city. The function is carefully optimized for almost no performance impact, allowing it to dynamically examine each position for the best possible results. There is no debug, argument checking, or defensive code, to make it as simple and fast as possible, so make sure the arguments are correct. Download Google Drive: https://drive.google.com/file/d/0B-QFvxyAVKTUX0lTWHNBYWVHN3M/edit?usp=sharing Usage Place the script somewhere in your mission folder. Function parameters: 1. Array, the building(s) nearest this position is used 2. Array of objects, the units that will garrison the building(s) (opt.) 3. Scalar, radius in which to fill building(s), -1 for only nearest building, (default: -1) (opt.) 4. Boolean, true to put units on the roof, false for only inside, (default: false) (opt.) 5. Boolean, true to fill all buildings in radius evenly, false for one by one, (default: false) (opt.) 6. Boolean, true to fill from the top of the building down, (default: false) (opt.) 7. Boolean, true to order AI units to move to the position instead of teleporting, (default: false) The complete documentation is also commented at the top of the file. You can run it from anywhere with execVM: 0 = [getPosATL X, units X] execVM "Zen_OccupyHouse.sqf"; You can also compile it into a function if you plan on using it many times: Zen_OccupyHouse = compileFinal preprocessFileLineNumbers "Zen_OccupyHouse.sqf"; _units = [(getMarkerPos "mkHouse"), [X, Y, Z], 50, false, true] call Zen_OccupyHouse; When using the compile and call method, the function returns the array of units that did not fit in the building. 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) 7/6/15 Added: AI now take cover when fired upon (credit to JohnnyBoy) Added: Parameter to order the AI to move to their position Improved: The order of buildings filled is now random Improved: A few minor optimizations 6/30/15 Added: Parameter to fill buildings from top to bottom Improved: Optimized 7/31/14 Added: Parameter to cycle through each building in the radius, giving units to each one Improved: Units on roof are only placed at the edge, and face the edge Improved: Optimized roof check Improved: General script cleanup 7/28/14 Fixed: Units facing the wrong window Added: Parameter for distance to select multiple buildings Added: Parameter for units being on a roof Improved: Now checks that unit has a good FOV from the windows Improved: Units can no longer face a windows greater than 5 meters away Improved: Units on a roof now crouch Tweaked: Height of human eye to the exact value in ArmA 7/24/14 Initial Release Known Issues None Feedback If you liked/disliked it or have any suggestions for improvement, I would like to hear your thoughts. Either this thread, PM, or email is fine. Contact the author: ZenophonArmAFramework@gmail.com Legal This software is released under Creative Commons Attribution-NonCommercial 4.0 International (CC BY-NC 4.0). http://creativecommons.org/licenses/by-nc/4.0/ Credits JohnnyBoy (AI take cover) 7 3 Share this post Link to post Share on other sites
Guest Posted July 24, 2014 Thanks for informing us about the release :cool: Release frontpaged on the Armaholic homepage. Infantry Occupy House Script 7/24/14 ================================================ 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
Zenophon 110 Posted July 24, 2014 Thanks Foxhound, I've edited the post with the link to Armaholic. Share this post Link to post Share on other sites
Beerkan 71 Posted July 24, 2014 Erm.. Some of them ended up on the roof. init used for group leader null = [this , units group this] execVM "Zen_OccupyHouse.sqf"; Share this post Link to post Share on other sites
Zenophon 110 Posted July 24, 2014 Erm.. Some of them ended up on the roof. That was inevitable, as I can't test every building. Fortunately I think I know how to fix that without preventing units from being on balconies, etc. Unfortunately, it might prevent units from being on a roof that is actually reachable. Therefore, I will make a parameter to enable/disable putting units on the roof. Until then, I will add this as a known issue. I will probably also fix the the first known issue next release as well. That too involves a similar modification to the current position checking system. Share this post Link to post Share on other sites
tinter 186 Posted July 25, 2014 If you think that roof is unreachable, you are mistaken. There's a ladder on the opposite side of the one with the stairs. Share this post Link to post Share on other sites
Rath 10 Posted July 25, 2014 Sounds cool - not at home to test it, but does it still place units in buildings without windows? Share this post Link to post Share on other sites
Zenophon 110 Posted July 25, 2014 If you think that roof is unreachable, you are mistaken. There's a ladder on the opposite side of the one with the stairs. I didn't know that; still, some mission makers might prefer that all units are inside the building. It would also be good to make units on the roof crouch/prone, which I can do if I check for them being on the roof. Sounds cool - not at home to test it, but does it still place units in buildings without windows? No it should not; it will only use a building position if the unit would have an unobstructed line of sight 15m in the direction they are facing. I can tweak that number based upon feedback. There might be a few buildings with 1 large room and no windows, but it works fine for most of the small residential buildings on Altis. Share this post Link to post Share on other sites
Daggett 1 Posted July 26, 2014 No time to test it, but it does sound pretty cool... Nice work! Share this post Link to post Share on other sites
froggyluv 2136 Posted July 26, 2014 Great job - I love it already. Now alls we need is zooloo75's side step, evasive maneuver and it's game on indoors. Share this post Link to post Share on other sites
sttosin 67 Posted July 26, 2014 Nice script! Two questions: 1. Is there a way to have the group spawn dynamically instead of placing them in the editor already? 2: The AI don't always stay in their position. They sometimes take the fight outdoors. I am using bCombat mod as well. Anyway to get the effect of being shot through windows but AI staying in position but also be able to turn their head/body and weapon when they get attacked indoors? Share this post Link to post Share on other sites
Zenophon 110 Posted July 26, 2014 Nice script! Two questions:1. Is there a way to have the group spawn dynamically instead of placing them in the editor already? 2: The AI don't always stay in their position. They sometimes take the fight outdoors. I am using bCombat mod as well. Anyway to get the effect of being shot through windows but AI staying in position but also be able to turn their head/body and weapon when they get attacked indoors? You can dynamically spawn AI with functions like BIS_fnc_SpawnGroup and other spawning scripts people have written (including my co-op framework, see my sig). You can also just use createUnit to do it manually. You would then get the group the function spawned as a return value and use the units command to get the array of units to put in a building. The only thing the script does to make the AI stay there is use doStop. Anything that tells them to move again will override that. You can force them to stay in place with disableAI. Something like: { _x disableAI "Move"; } forEach units group this; You can change 'this' to a spawned object, or 'group this' to the group returned by a spawning function. Share this post Link to post Share on other sites
sttosin 67 Posted July 27, 2014 Thanks Zenophon. That was helpful. I will play around with those suggestions. Sent from my GT-P7510 using Tapatalk Share this post Link to post Share on other sites
coolfact 10 Posted July 27, 2014 This is a really nice script Zenophon, one feature that would be nice, would be the option to occupy several random buildings within a certain range from the marker, so the lets say group of 8 is spread out in those buildings Share this post Link to post Share on other sites
Zenophon 110 Posted July 28, 2014 Summary Greetings fellow scripters, I have finally coded and tested a lot of new logic and improvements for the script. These changes will improve its overall quality and reliability, as well as provide new options to make it easier to use than ever. All of the known issues have been fixed, and some user suggestions have been adapted and incorporated into the script. I want to thank everyone who gave feedback and helped with the development process; your suggestions will improve the experience for all users. 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. While the script has become much more complex, from an optimization standpoint all of the new features only increase processing time by about 50%. This is not really an issue because the script only took a couple dozen milliseconds in the first place. Also note that some buildings will take a little longer than others. With all the new features might be bugs, even though I made a reasonable effort to test things on various buildings and with different combinations of the new parameters. If you find something, post here or PM me and I can get a hotfix out in a day or two. Changelog 7/28/14 Fixed: Units facing the wrong window Added: Parameter for distance to select multiple buildings Added: Parameter for units being on a roof Improved: Now checks that unit has a good FOV from the windows Improved: Units can no longer face a windows greater than 5 meters away Improved: Units on a roof now crouch Tweaked: Height of human eye to the exact value in ArmA Share this post Link to post Share on other sites
wiggum2 31 Posted July 28, 2014 Thanks for the update ! I will start using this in all my missions. 1 Share this post Link to post Share on other sites
Guest Posted July 28, 2014 Thanks for informing us about the updated release, much appreciated :cool: Release frontpaged on the Armaholic homepage. Infantry Occupy House Script 7/28/14 ================================================ 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
ligthert 21 Posted July 29, 2014 How does this script compare to the garrison script? Share this post Link to post Share on other sites
VinCe_FSF 10 Posted July 29, 2014 Have you a mission exemple for that ? Thank you for your work Share this post Link to post Share on other sites
Zenophon 110 Posted July 29, 2014 (edited) How does this script compare to the garrison script? I don't know which garrison script you mean, there have been several made over the years. I will highlight why I think my script is unique: It does not spawn any units It only places units at windows they can see out of It has an option for putting them on the roof You are in control of which buildings it fills Have you a mission exemple for that ?Thank you for your work 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: 0 = [getPosATL this, units group this, -1, true] execVM "Zen_OccupyHouse.sqf" Edited July 30, 2014 by Zenophon Share this post Link to post Share on other sites
coolfact 10 Posted July 29, 2014 You work fast Zenophon ;) it looks nice with the option to garrison an area, however it basically just fills max 5 AI's in the nearest building and then begins to fill the second nearest building, it would be nice if you could spread the units out to as many building as posible. Share this post Link to post Share on other sites
Zenophon 110 Posted July 30, 2014 You work fast Zenophon ;) it looks nice with the option to garrison an area, however it basically just fills max 5 AI's in the nearest building and then begins to fill the second nearest building, it would be nice if you could spread the units out to as many building as posible. I see what you mean now...this is not that hard to do. It would either be completely random, with no preference given to any building, or rotate through all the buildings, giving one unit to each in turn. It will also probably be a parameter, as some users might prefer to be more certain about which buildings the units will fill. I'll try to think of some other improvements as well; a changelog with just one item looks somewhat sad. Something like checking that units are on the edge of a roof so they can shoot down. Share this post Link to post Share on other sites
sttosin 67 Posted July 30, 2014 ^^A changelog with one thing means you could not wait to get it in the hands of the users? Share this post Link to post Share on other sites
coolfact 10 Posted July 30, 2014 I see what you mean now...this is not that hard to do. It would either be completely random, with no preference given to any building, or rotate through all the buildings, giving one unit to each in turn. It will also probably be a parameter, as some users might prefer to be more certain about which buildings the units will fill.I'll try to think of some other improvements as well; a changelog with just one item looks somewhat sad. Something like checking that units are on the edge of a roof so they can shoot down. sweet, but don't make it too complicated. One of the coolest feature of this script is its simplicity and low process time ;) Share this post Link to post Share on other sites
Zenophon 110 Posted July 31, 2014 Summary Greetings fellow scripters, by user request I am adding a new feature that allows the script to fill multiple buildings differently. As a parameter, you can now choose to evenly distribute units between all the buildings in the radius, or continue to use the method of filling each building completely one by one. Also, putting units on roofs has been improved so that the script only places them at the edge. The new features have a minimal performance impact, and optimizations have been made where possible. For the typical small building with no roof positions, the time will not have changed very much (20-50ms). Of course, increasing the size and number of buildings and adding more units will add to this time. Also, giving a ridiculous radius of e.g. 1000 meters will result in about a half-second wait as the script tries to process each building. 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/31/14 Added: Parameter to cycle through each building in the radius, giving units to each one Improved: Units on roof are only placed at the edge, and face the edge Improved: Optimized roof check Improved: General script cleanup 1 Share this post Link to post Share on other sites