DaveP 66 Posted June 5, 2009 (edited) In a nutshell, this script will let you quickly and easily fill out enterable urban buildings with AI without having to go through loads of tedious waypoint making. Makes for some very tense close quarters fighting. Don't see why it shouldn't work in MP. Also now got a retreat script, whereby units that are fighting in built up areas, rather than running away, will flee to the nearest building and hold up inside Example mission: http://www.sendspace.com/file/vaqy03 Video: Code (+Howto) RetreatToBuilding.sqs ; **************************************************************** ; Infantry retreat into buildings script, by DaveP (BIStudio forum PM for help/info) ; ; Free to use it in whatever and enjoy! Chop and change as you wish (credit is appreciated), BIStudio forum PM me if you use it in anything, so I can try it out =D ; ; Place soldier near building of choice, then: ; syntax: ; [unit name, courage (0-1, 1 = Low, 0 = High, 0.8~ is best for this script)] exec "RetreatToBuilding.sqs" ; ; example: ; (unit's init field, run like little girly girls) ; [this,0.9] exec "RetreatToBuilding.sqs" ; ;Extra info: ;-Removes hand grenades, otherwise dumb infantry try and throw a grenade from inside a building and frag themselves ; **************************************************************** _FISHman = _this select 0 _Scaredness = _this select 1 _x = 0 _y = 0 _FISHman allowFleeing _Scaredness #Wait @(fleeing _FISHman)=true _FISHman allowFleeing 0 [_FISHman] joinsilent grpnull; #FindBuilding _buildings = nearestObjects [_FISHman, ["HOUSE"], 50] _buildingcount = count _buildings #SelectBuilding _buildingselected = _buildings select _y _y = _y + 1 ?_y > _buildingcount:goto "nofind" _z = 0 _Positionarray = [] #Positionfinder _thisposition = (_buildingSelected buildingPos _z) _positionsum = (_thisposition select 0) + (_thisposition select 1) + (_thisposition select 2) ? _positionsum==0:goto "PositionsChecked" _Positionarray = _Positionarray + [_thisposition] _z = _z + 1 goto "Positionfinder" #Positionschecked _MaxPos = count _positionarray ?_MaxPos==0:goto "SelectBuilding" _randomnumber = round random _MaxPos _MovePos = _positionarray select _randomnumber _FISHman DoMove [(_MovePos select 0),(_MovePos select 1),(_MovePos select 2)] _FISHman removeWeapon "HandGrenade_East"; _FISHman removeMagazines "HandGrenade_East"; _FISHman removeWeapon "HandGrenade_West"; _FISHman removeMagazines "HandGrenade_West"; _FISHman removeWeapon "HandGrenade"; _FISHman removeMagazines "HandGrenade"; _FISHman setunitpos "UP" #nofind exit PlaceInBuilding.sqs ; **************************************************************** ; Place infantry in buildings script, by DaveP (BIStudio forum PM for help/info) ; ; Free to use it in whatever and enjoy! Chop and change as you wish (credit is appreciated), BIStudio forum PM me if you use it in anything, so I can try it out =D ; ; Place soldier near building of choice, then: ; syntax: ; [unit name] exec "PlaceInBuilding.sqs" ; ; example: ; (unit's init field) ; [this] exec "PlaceInBuilding.sqs" ; ;Extra info: ;-Removes hand grenades, otherwise dumb infantry try and throw a grenade from inside a building and frag themselves ;-Will delete unit if no building position is found ; **************************************************************** _FISHman = _this select 0 _x = 0 _y = 0 #FindBuilding _buildings = nearestObjects [_FISHman, ["HOUSE"], 200] _buildingcount = count _buildings #SelectBuilding _buildingselected = _buildings select _y _y = _y + 1 ?_y > _buildingcount:goto "nofind" _z = 0 _Positionarray = [] #Positionfinder _thisposition = (_buildingSelected buildingPos _z) _positionsum = (_thisposition select 0) + (_thisposition select 1) + (_thisposition select 2) ? _positionsum==0:goto "PositionsChecked" _Positionarray = _Positionarray + [_thisposition] _z = _z + 1 goto "Positionfinder" #Positionschecked _MaxPos = count _positionarray ?_MaxPos==0:goto "SelectBuilding" _randomnumber = round random _MaxPos _MovePos = _positionarray select _randomnumber _FISHman Setpos [(_MovePos select 0),(_MovePos select 1),(_MovePos select 2)] _FISHman setdir random 360 _FISHman removeWeapon "HandGrenade_East"; _FISHman removeMagazines "HandGrenade_East"; _FISHman removeWeapon "HandGrenade_West"; _FISHman removeMagazines "HandGrenade_West"; _FISHman removeWeapon "HandGrenade"; _FISHman removeMagazines "HandGrenade"; _FISHman setunitpos "UP" exit #nofind DeleteVehicle _FISHman exit My wish would be to integrate these into a Game Logic module, but I have no idea how to do that; if anyone does and would like to, please do! Free to use it in whatever and enjoy! Chop and change as you wish (credit is appreciated), BIStudio forum PM me if you use it in anything, so I can try it out =D Edited June 7, 2009 by DaveP Share this post Link to post Share on other sites
manzilla 1 Posted June 6, 2009 (edited) Yes. Thank you. This is nice to have so soon. EDIT: Wait what do you mean by this. find out the number of positions in the building using the create waypoint window Edited June 6, 2009 by Manzilla Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 Yes. Thank you. This is nice to have so soon.EDIT: Wait what do you mean by this. Enterable buildings usually have a number of set 'positions' inside for AI to use as a position to move to. These are the positions I use for the script. If you make a "move" waypoint on a building an extra option on the waypoint screen comes up specifying what position the AI should occupy Share this post Link to post Share on other sites
manzilla 1 Posted June 6, 2009 Enterable buildings usually have a number of set 'positions' inside for AI to use as a position to move to. These are the positions I use for the script. If you make a "move" waypoint on a building an extra option on the waypoint screen comes up specifying what position the AI should occupy Jesus after all this time I never saw that. Thanks and sorry for my blindness. Share this post Link to post Share on other sites
Binkowski 26 Posted June 6, 2009 Awesome! I just ran the test mission, great work! I'm going to implement this into missions soon! Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 Interesting tidbit: The factory at 114,078 has a building with 59 different positions for soldiers, by far the most 'enterable' building in the game.. a deathtrap to try to take alive, though, would be great for two MP fireteams to try to tackle Jesus after all this time I never saw that. Thanks and sorry for my blindness. It was implemented in OFP:Resistance :p Share this post Link to post Share on other sites
manzilla 1 Posted June 6, 2009 Interesting tidbit: The factory at 114,078 has a building with 59 different positions for soldiers, by far the most 'enterable' building in the game.. a deathtrap to try to take alive, though, would be great for two MP fireteams to try to tackleIt was implemented in OFP:Resistance :p I was afraid that may be the case. Damn I've been making missions for that and ArmA since the releases so the fact that I've never noticed that is remarkable, pretty damn funny too. ;) Share this post Link to post Share on other sites
Maddmatt 1 Posted June 6, 2009 Interesting tidbit: The factory at 114,078 has a building with 59 different positions for soldiers, by far the most 'enterable' building in the game.. a deathtrap to try to take alive, though, would be great for two MP fireteams to try to tackle All you need is a tank and some HEAT shells ;) Or an airstrike. Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 All you need is a tank and some HEAT shells ;)Or an airstrike. Haha, funny you should say that, every time I've tried calling in an LGB bombing run, I'll go in to check the damages and one or two crafty buggers are lying there waiting for me among the rubble, that building's a bunker in disguise Share this post Link to post Share on other sites
-)rStrangelove 0 Posted June 6, 2009 (edited) Nice script. So a commandStop doesn't make them stop inside the building? Can't believe they always try to come out. If you tell them to halt when you're the leader it works ingame. I tried that with 2 of my heli crew members on a skycraper. Just dont tell them to mount the chopper again, they will gladly jump from the building lol. [Edit] Looks like it works when every unit has its own group: [_unit] joinsilent grpnull; _unit setPos _buildingpos; _unit move _buildingspos; They dont get a command to return to formation afterwards, so they dont leave their pos in the house. Edited June 6, 2009 by ])rStrangelove Share this post Link to post Share on other sites
cross 1 Posted June 6, 2009 There is a script by Raven for Arma1 .. TakeBuilding Script.. It places soldiers into building using the parameters you give like radius, building % and fill % etc... Very nice script for quick CQC. http://www.armaholic.com/page.php?id=3095 I think would be good if you can convert to Arma2 & combine both....don't forget to give credits or get permission before modifying ;) GJ Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 (edited) )rStrangelove;1300586']Nice script. So a commandStop doesn't make them stop inside the building? Can't believe they always try to come out. If you tell them to halt when you're the leader it works ingame. I tried that with 2 of my heli crew members on a skycraper. Just dont tell them to mount the chopper again' date=' they will gladly jump from the building lol.[Edit'] Looks like it works when every unit has its own group: [_unit] joinsilent grpnull; _unit setPos _buildingpos; _unit move _buildingspos; They dont get a command to return to formation afterwards, so they dont leave their pos in the house. Yeah, that's one of the major limitations, kinda funny seeing 60 people charge into a building and then walk straight back out again, mind. I considered using DisableAI "Move" on them, but CommandStop sounds like a far cleaner method There is a script by Raven for Arma1 .. TakeBuilding Script..It places soldiers into building using the parameters you give like radius, building % and fill % etc... Very nice script for quick CQC. http://www.armaholic.com/page.php?id=3095 I think would be good if you can convert to Arma2 & combine both....don't forget to give credits or get permission before modifying ;) GJ Interesting, this uses some methods I'd considered but not really thought too much detail into; the advantage I'd say my script has it's a bit more controllable in terms of specifying how many people in each building and what unit type, something you may want as a mission editor (eg. Hostage rescue from a building, make sure there's a few civvies and one commander and so on) Edited June 6, 2009 by DaveP Share this post Link to post Share on other sites
CarlGustaffa 4 Posted June 6, 2009 All you need is a tank and some HEAT shells ;)Or an airstrike. Sometimes what you need is not available. Maybe the mission designer didn't want to use these things :) Share this post Link to post Share on other sites
sabre4809 0 Posted June 6, 2009 I really think something like this in module/game logic form, would be a awesome addition, link it to groups you want to use it. With specified req for them to use it, like they 'retreat' to buildings when overwhelmed, or just all the time. Can you imagine Urban fights where the enemy starts to fall back into buildings. :eek: Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 I really think something like this in module/game logic form, would be a awesome addition, link it to groups you want to use it. With specified req for them to use it, like they 'retreat' to buildings when overwhelmed, or just all the time. Can you imagine Urban fights where the enemy starts to fall back into buildings. :eek: Hmm, I'm working on it but having a problem with my conditional; If I use @ it never continues, regardless of the allowFleeing level, and if I use WaitUntil it always continues! _FISHman allowFleeing 1 @{fleeing _FISHman==true} hint "Screw this ahh" Any ideas at all? Share this post Link to post Share on other sites
Mike84 1 Posted June 6, 2009 I was thinking of making something like this as well when reading the comref (I haven't seen buildingPos before, although it was in arma1). Anyhow, I haven't gotten far yet, only the algorithm to find enterable buildings and save the number of positions in a building so far. Maybe you can find us for it as well: _radius = 250; buildingArray = []; { if (((_x buildingPos 0) select 0) != 0) then { _i = 0; while { ((_x buildingPos _i) select 0) != 0 } do { _i = _i + 1; }; buildingArray = buildingArray + [[_x, _i]]; }; }forEach (nearestObjects [player,["House"], _radius]); and it will spit out (1st element = house object, 2nd element = number of positions): [[10827000# 10909: mil_house.p3d,2], [1094dc00# 10880: ss_hangar.p3d,10], [107a6000# 10660: mil_controltower.p3d,21], [10944800# 10887: mil_guardhouse.p3d,3]] Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 I was thinking of making something like this as well when reading the comref (I haven't seen buildingPos before, although it was in arma1). Anyhow, I haven't gotten far yet, only the algorithm to find enterable buildings and save the number of positions in a building so far. Maybe you can find us for it as well: _radius = 250; buildingArray = []; { if (((_x buildingPos 0) select 0) != 0) then { _i = 0; while { ((_x buildingPos _i) select 0) != 0 } do { _i = _i + 1; }; buildingArray = buildingArray + [[_x, _i]]; }; }forEach (nearestObjects [player,["House"], _radius]); and it will spit out (1st element = house object, 2nd element = number of positions): [[10827000# 10909: mil_house.p3d,2], [1094dc00# 10880: ss_hangar.p3d,10], [107a6000# 10660: mil_controltower.p3d,21], [10944800# 10887: mil_guardhouse.p3d,3]] Already ahead of ya, heh, I've now got it so AI will enter the nearest enterable building in a 50m radius and automatically randomly choose any of the available positions without having to even tell it how many there are. Any ideas on the conditional at all? It's holding back progress Share this post Link to post Share on other sites
cross 1 Posted June 6, 2009 Interesting, this uses some methods I'd considered but not really thought too much detail into; the advantage I'd say my script has it's a bit more controllable in terms of specifying how many people in each building and what unit type, something you may want as a mission editor (eg. Hostage rescue from a building, make sure there's a few civvies and one commander and so on) you can specify the intensity on each soldier type as well. But in general...not per building. You can set the soldier type according to height tho .. like put snipers/MG on top of the buildings. You also don't need to create many groups and it is randomized so that it is different everytime you play.. Take a look into it. Share this post Link to post Share on other sites
Mike84 1 Posted June 6, 2009 i dont think you need the comparision operator, a waitUntil waits until it's true anyway Share this post Link to post Share on other sites
imutep 0 Posted June 6, 2009 Thx for this nice script, DaveP :) Put it on our script section at Assault Mission Studio AI Urban Building/Combat Positioning Script by DaveP Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 i dont think you need the comparision operator, a waitUntil waits until it's true anyway You'd think that, but even with allowFleeing 0 it's letting the script pass :confused: Share this post Link to post Share on other sites
sabre4809 0 Posted June 6, 2009 Would it be possible to check where the enemy presence is, directional, (or main enemy presence). Then check which positions in the building face that direction and make the AI have a priority to occupy those positions. Mostly usefull for higher floors in buildings. Another thing though, can the AI even shoot out of building windows. Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 (edited) Another thing though, can the AI even shoot out of building windows. Very much so. They'll shoot, fire RPGs, and generally make your life hell. Building positions don't have information on what side of the building they're facing; It could be possible by comparing distance between the positions, but another consideration is that often, even with it random as it is multiple men will end up taking the same positions, and if you increase the chances of going to one position over another you're always raising the chance that you have around 5 people at one window, which looks a bit dumb After much cajouling I've got it working, mission soonish Edited June 6, 2009 by DaveP Share this post Link to post Share on other sites
runforrest 10 Posted June 6, 2009 hi i stumbled over this thread and i thought u might find this script interesting too (if u dont know it already): Random House Patrol Script by Tophe http://www.armaholic.com/page.php?id=936 Share this post Link to post Share on other sites
DaveP 66 Posted June 6, 2009 Here we go, updated latest version: http://www.sendspace.com/file/vaqy03 ; **************************************************************** ; Place infantry in buildings script, by DaveP (BIStudio forum PM for help/info) ; ; Free to use it in whatever and enjoy! Chop and change as you wish (credit is appreciated), BIStudio forum PM me if you use it in anything, so I can try it out =D ; ; Place soldier near building of choice, then: ; syntax: ; [unit name] exec "PlaceInBuilding.sqs" ; ; example: ; (unit's init field) ; [this] exec "PlaceInBuilding.sqs" ; ;Extra info: ;-Removes hand grenades, otherwise dumb infantry try and throw a grenade from inside a building and frag themselves ;-Will delete unit if no building position is found ; **************************************************************** ; **************************************************************** ; Infantry retreat into buildings script, by DaveP (BIStudio forum PM for help/info) ; ; Free to use it in whatever and enjoy! Chop and change as you wish (credit is appreciated), BIStudio forum PM me if you use it in anything, so I can try it out =D ; ; Place soldier near building of choice, then: ; syntax: ; [unit name, courage (0-1, 1 = Low, 0 = High, 0.8~ is best for this script)] exec "RetreatToBuilding.sqs" ; ; example: ; (unit's init field, run like little girly girls) ; [this,0.9] exec "RetreatToBuilding.sqs" ; ;Extra info: ;-Removes hand grenades, otherwise dumb infantry try and throw a grenade from inside a building and frag themselves ; **************************************************************** Share this post Link to post Share on other sites