fubarno1 0 Posted January 25, 2007 Hi guys, any way I can automatically get AI units to re-man a static weapon once the operator has been killed, I think grouping a static with an AI group would work but I need it to be more general even if it means a new AI being spawned specifically for the task, but would prefer it to use one of the AI already on the map. I was thinking that maybe there is a script that would check the unit is still alive if dead then make an AI unit nearby take his place, seems more natural having AI re-man undamaged static weapons than having them sit there doing nothing, but I could not find anything that looked like it would do what i need unless I'm going blind? Anyone able to help? I have about 20 static weapons that need to be maned if the op dies or else it becomes too easy for the Enemy AI to complete their mission because the stupid Friendly AI like to still fire all their AT's at destroyed armour and men until they run out of rockets so we end up with no heavy weapons support Share this post Link to post Share on other sites
johnnyboy 3797 Posted January 25, 2007 Here is a handy script written by General Barron for OFP. It works for ARMA too (I've tried it). The comments explain how it works and how to call it. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE"> ;----------------------------------------------------------------------------------------- ----------------------------------------- ;manMG1.sqs ;By General Barron ;aw_barron@hotmail.com ;3/29/03 ;This script is used to make units man a machine gun when its gunner gets killed. ;A unit from a group you specify will go to man the machine gun after its gunner gets killed. ;This unit will always be the lowest-ranking unit in the group, so that it doesn't interfere ;with waypoints of the group (unless there is only one unit left in the group). ; It is called as follows: ;[mg,group] exec "manMG1.sqs" ;"mg" is the name of the machine gun you want manned. ;"group" is the name of the group that will be manning the machine gun. ;You can end all manMG scripts that are running by setting the variable manMG_end to TRUE ;----------------------------------------------------------------------------------------- ----------------------------------------- manMG_end = FALSE _gun = _this select 0 _group = _this select 1 #Loop @NOT alive gunner _gun OR NOT alive _gun OR manMG_end ?NOT alive _gun OR manMG_end : exit ;wait until the gunner dies ;?"alive _x" count units _group <= 0 : exit ?{alive _x} count units _group <= 0 : exit ;if the group manning the machine gun has no units left, exit the script _gunner = units _group select (count units _group - 1) ;select the last unit in the group _gunner assignAsGunner _gun [_gunner] orderGetIn TRUE ;make him get in the gun goto "Loop" Share this post Link to post Share on other sites
fubarno1 0 Posted January 25, 2007 Nice one  I'll try it later and see if it works the way I hope it will. this is what I like about this part of the forum, there are many other users that are willing to help those that are stuck with something in the editor, if one person dont know the answer there is sure to be someone else that does  Share this post Link to post Share on other sites
RN Malboeuf 12 Posted January 26, 2007 There was a bunch of the ofp ai scripts at the ofpec. they all should work in Arma too (but i think have to be modified in case of new arma possibilities ). it's a pity but data base seems to be lost there were General Barron's manMG2.sqs for ex. and many more. Share this post Link to post Share on other sites
the unknown 0 Posted January 26, 2007 Well I still had manMG2.sqs on my pc, hope you are a bit more happy now :P <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">;----------------------------------------------------------------------------------------- ----------------------------------------- ;manMG2.sqs ;By General Barron ;aw_barron@hotmail.com ;3/29/03 ;This script is used to make units man a machine gun when its gunner gets killed. ;The closest unit to the machine gun will go to man it, as long as they are within the ;reach of the trigger. If no units are currently in the area, the next unit to enter the range ; of the trigger will go to man the MG. If you wish, you can make it so only units of a certain ; side will be affected by this script. ; It is called as follows: ;[mg,trigger,side(optional)] exec "manMG2.sqs" ;"mg" is the name of the machine gun you want manned. ;"trigger" is the name of a trigger. It must be set to "activation ANYBODY". ;Only units within the area of this trigger will be affected by this script. ;(Make sure it is activated by "anybody", NOT "west", "east", etc. It will ONLY work with "anybody"!!!) ;"side" is optional. Placing WEST (no quotes!) here will allow only west units to be affected ;by this script. Other options are EAST and RESISTANCE. You cannot specify the side "civilian". ;If you leave this blank, any unit, regardless of side will be affected by this script. ;You can end all manMG scripts that are running by setting the variable manMG_end to TRUE ;----------------------------------------------------------------------------------------- ----------------------------------------- manMG_end = FALSE ;set this variable to TRUE to end the script _gun = _this select 0 ;name of the machine gun to be manned _trigger = _this select 1 ;name of trigger covering the area _side = _this select 2 ;side you want to man the gun with (optional). If nothing is entered, any side can man the gun ?_side == west OR _side == east OR _side == resistance : goto "Top" _side = civilian ;this makes civilian the default _side (if nothing is entered when calling the script) #Top @NOT alive gunner _gun OR NOT alive _gun OR manMG_end ?NOT alive _gun OR manMG_end : exit @"vehicle _x == _x" count list _trigger > 0 OR NOT alive _gun ?NOT alive _gun OR manMG_end : exit ;wait until the gunner is dead, and there are people around who aren't in vehicles _units = list _trigger _i = -1 _max = count _units _minDist = 99999 ;set up variables for loop #Loop _i = _i + 1 ?_max <= _i : goto "Bottom" ;exit loop when end of list is reached _man = _units select _i _dist = _man distance _gun ;find distance between selected man and gun ?_dist >= _minDist OR vehicle _man != _man OR _man == player OR vehicle _man == _gun OR (_side != civilian AND side _man != _side) : goto "Loop" ;move on to the next man if they are further away from the gun than the closest person, or if they are in a vehicle, or if it is the player, or if they are on the wrong side (unless _side = civilian) _closestUnit = _i _minDist = _dist ;if they pass, then they are the current closest man to the mg, and their element # and distance is saved goto "Loop" #Bottom _gunner = _units select _closestUnit _gunner assignAsGunner _gun [_gunner] orderGetIn TRUE ;once the loop is finished, the closest man is selected, assigned to the gun, and ordered in goto "Top" Share this post Link to post Share on other sites