Announcement

Collapse
No announcement yet.

Garrison on the fly script

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Garrison on the fly script

    This script allows a unit or group of units (tested on upto 16 in one group) to pick a building from a user defined area and garrison it with the subordinates following suit. if the building becomes full the remaining units select another building from the list and garrison that and so on. there are 3 variables you can set

    1. the unit or group leader to run it on, player,object, whoever you want really.

    2. the radius of the circular area from which to collect your houses. format : number

    3 . whether or not the units are to stay there (units like to walk around when they hear gunfire. They may also break this should they be shot and healed, just a little issue.) True or just leave it blank

    so to run just type, nul = [(var1),(var2)] execVM "Garrison_script.sqf";
    or
    nul = [(var1),(var2),true] execVM "Garrison_script.sqf";

    if you get a hint message saying "full" this is simply saying that a unit or units from the squad have tried to enter a building that is full and cannot find an alternative to garrison. they will stand around outside hehe.
    if you get a zero divisor error i apologise what this means is that on of my variables is drawing from a value that is 0. this should not happen but does occasionally and i'm trying to narrow the cause down. usually happens in areas with few buildings and or few spaces in the buildings I.e. 1.

    have fun and let me know if there are any recurring problems,

    details of circumstances are always appreciated for debugging.

    Thanks
    zorilya


    //script
    Code:
    /* 
    run as  nul = [unit,radius,stationary(true or leave blank)] execVM "Garrison_script.sqf"
    I recommend not using the stationary just now as it's a little silly but you can try it to see what i mean
    units may, after being healed start moving around more than usual.	
    */ 
    
    private ["_unit","_radius","_buildingslist","_bwrlist","_nbuildpos","_cnt","_posarray","_build","_i","_nbuild","_building","_buildpos","_group","_buildingsleft","_npos","_bposleft"];
    
    	_unit = _this select 0;
    	_radius = _this select 1;
    
    	_buildingslist = nearestObjects [_unit,["House"],_radius];
    	_bwrlist = [];
    	_nbuildpos = [];
    
    // Populate the building list with occupiable buildings
    
    	for "_i" from 0 to ((count _buildingslist)-1) do {
    		 _build = _buildingslist select _i;
    	 
    	 	_cnt = 0;
    		 _posarray = [];
    	 
    		 while {format ["%1", _build buildingPos ((_cnt) + 1)] != "[0,0,0]" } do {
    	 		_pos = _build buildingPos ((_cnt) + 1);
    		 	_posarray set [count _posarray, _pos];
    		 	_cnt = _cnt + 1;
    		 	sleep 0.01;
    		 };
    
    		 if (count _posarray >= 1) then {
    			  _bwrlist set [count _bwrlist,_build];
    			  _nbuildpos set [(count _bwrlist) - 1,_cnt];
    		 };
    		 sleep 0.1;
    	};
    
    
    
    	_buildingsleft = + _bwrlist;
    
    	_group = group _unit;	
    
    	//hint (str(_nbuildpos));
    		sleep 1;
    
    
    // make group enter random building and occupy the positions
    
    // building select
    
    
    
    	_nbuild = round (random ((count _buildingsleft) - 1));
    	_building = _buildingsleft select _nbuild;
    		
    	_bposleft = [];
    
    	for "_i" from 1 to (_nbuildpos select _nbuild) do {
    	
    		_bposleft set [_i - 1,_i];
    	};
    
    // remove building details of current select building from list of possible buildings 
    
    	_nbuildpos = _nbuildpos - [_nbuildpos select (_buildingsleft find _building)];
    	_buildingsleft = _buildingsleft - [_building];
    
    // units select a position and go, if building fills up a new building is selected and then populated.
    
    	waitUntil {sleep 1,true};
    
    		{doStop _x;
    		sleep 0.1;
    	} foreach units _group;
    																																																																																				
    	{if ((count _bposleft) >= 1) then {
    		_buildpos = _bposleft select (round (random ((count _bposleft - 1))));
    
    		doStop _x;
    		_x moveTo (_building buildingPos _buildpos);
    		sleep 0.1;
    		_bposleft = _bposleft - [_buildpos];
    		sleep 0.1; 
    
    		} else {
    
    			_nbuild = round (random ((count _buildingsleft) - 1));
    			_building = _buildingsleft select _nbuild;
    
    		
    			_bposleft = [];
    	
    			for "_i" from 1 to (_nbuildpos select _nbuild) do {
    	
    			_bposleft set [_i - 1,_i];
    			};
    
    			_nbuildpos = _nbuildpos - [_nbuildpos select (_buildingsleft find _building)];
    			_buildingsleft = _buildingsleft - [_building];
    
    			if ((count _bposleft) >= 1) then {
    				_buildpos = _bposleft select (round (random ((count _bposleft - 1))));
    	
    				doStop _x;
    				_x moveTo (_building buildingPos _buildpos);
    				sleep 0.1;
    				_bposleft = _bposleft - [_buildpos];
    				sleep 0.1; 
    
    				} else {
    	
    				hint "full";
    
    				};
    	
    		};
    
    	} foreach units _group;
    
    sleep 60;
    
    _group setCombatMode "YELLOW";
    
    {
    if (_this select 2) then {
    	_x disableAI "MOVE";
    	doStop _x;
    	};
    } foreach units _group;
    
    ;

  • #2
    Re: Garrison on the fly script

    This would be handy, zorilya. Thanks

    TGU Instructor TG Pathfinder

    Former TGU Dean Former ARMA Admin Former Irregulars Officer

    "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

    Comment


    • #3
      Re: Garrison on the fly script

      no probs ... pair it up with a "closing doors in a given area" script and you've got some hot CQB action :)

      closing doors script not made by me i got it from a guy on the BI forums.... a nice guy called Rommel

      just place this in the init of a game logic and you should be sorted. second variable is the radius of the area where doors are closed.

      Code:
       0 = [getpos this,300] spawn {   sleep 1;   {    private "_b";     _b = _x;    for "_i" from 0 to 7 do {     _b animate ["dvere" + str _i,1]    };   } foreach ((_this select 0) nearobjects (_this select 1))  };
      props to Rommel.

      Comment


      • #4
        Re: Garrison on the fly script

        "Rommel" used to play here a lot, by the way. :)

        TGU Instructor TG Pathfinder

        Former TGU Dean Former ARMA Admin Former Irregulars Officer

        "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

        Comment


        • #5
          Re: Garrison on the fly script

          quick fix...call it v1.0000001

          Code:
          /* 
          run as  nul = [unit,radius,stationary(true or leave blank)] execVM "Garrison_script.sqf"
          I recommend not using the stationary just now as it's a little silly but you can try it to see what i mean
          units may, after being healed start moving around more than usual.	
          */ 
          
          private ["_unit","_radius","_buildingslist","_bwrlist","_nbuildpos","_cnt","_posarray","_build","_i","_nbuild","_building","_buildpos","_group","_buildingsleft","_npos","_bposleft"];
          
          	_unit = _this select 0;
          	_radius = _this select 1;
          
          	_buildingslist = nearestObjects [_unit,["House"],_radius];
          	_bwrlist = [];
          	_nbuildpos = [];
          
          // Populate the building list with occupiable buildings
          
          	for "_i" from 0 to ((count _buildingslist)-1) do {
          		 _build = _buildingslist select _i;
          	 
          	 	_cnt = 0;
          		 _posarray = [];
          	 
          		 while {format ["%1", _build buildingPos ((_cnt) + 1)] != "[0,0,0]" } do {
          	 		_pos = _build buildingPos ((_cnt) + 1);
          		 	_posarray set [count _posarray, _pos];
          		 	_cnt = _cnt + 1;
          		 	sleep 0.01;
          		 };
          
          		 if (count _posarray >= 1) then {
          			  _bwrlist set [count _bwrlist,_build];
          			  _nbuildpos set [(count _bwrlist) - 1,_cnt];
          		 };
          		 sleep 0.1;
          	};
          
          
          
          	_buildingsleft = + _bwrlist;
          
          	_group = group _unit;	
          
          	//hint (str(_nbuildpos));
          		//sleep 1;
          
          
          // make group enter random building and occupy the positions
          
          // building select
          
          
          
          	_nbuild = round (random ((count _buildingsleft) - 1));
          	_building = _buildingsleft select _nbuild;
          		
          	_bposleft = [];
          
          	for "_i" from 1 to (_nbuildpos select _nbuild) do {
          	
          		_bposleft set [_i - 1,_i];
          	};
          
          // remove building details of current select building from list of possible buildings 
          
          	_nbuildpos = _nbuildpos - [_nbuildpos select (_buildingsleft find _building)];
          	_buildingsleft = _buildingsleft - [_building];
          
          // units select a position and go, if building fills up a new building is selected and then populated.
          
          		{doStop _x;
          		sleep 0.1;
          	} foreach units _group;
          																																																																																				
          	{if ((count _bposleft) >= 1) then {
          		_buildpos = _bposleft select (round (random ((count _bposleft - 1))));
          
          		_x moveTo (_building buildingPos _buildpos);
          		sleep 0.1;
          		_bposleft = _bposleft - [_buildpos];
          		sleep 0.1; 
          
          		} else {
          
          			_nbuild = round (random ((count _buildingsleft) - 1));
          			_building = _buildingsleft select _nbuild;
          
          		
          			_bposleft = [];
          	
          			for "_i" from 1 to (_nbuildpos select _nbuild) do {
          	
          			_bposleft set [_i - 1,_i];
          			};
          
          			_nbuildpos = _nbuildpos - [_nbuildpos select (_buildingsleft find _building)];
          			_buildingsleft = _buildingsleft - [_building];
          
          			if ((count _bposleft) >= 1) then {
          				_buildpos = _bposleft select (round (random ((count _bposleft - 1))));
          	
          				doStop _x;
          				sleep 0.1;
          				_x moveTo (_building buildingPos _buildpos);
          				sleep 0.1;
          				_bposleft = _bposleft - [_buildpos];
          				sleep 0.1; 
          
          				} else {
          	
          				hint "full";
          
          				};
          	
          		};
          
          	} foreach units _group;
          
          sleep 60;
          
          _group setCombatMode "YELLOW";
          
          {
          if (_this select 2) then {
          	_x disableAI "MOVE";
          	doStop _x;
          	};
          } foreach units _group;
          
          
          ;
          changelog:
          removed unnecessary waitUntil
          removed unnecessary "doStop"
          added necessary "dostop line 105 or there about. this was stopping the first unit to select a new building from moving there.

          enjoy

          Comment


          • #6
            Re: Garrison on the fly script

            Right guys complete overhaul this time...

            Here is my Garrison script project. It allows you to task a group with garrisoning a building, where they will stay quite well underfire but will engage if not pushed on.

            you define the unit it is used on and the radius within which he will search for buildings. This building list is then chosen from randomly for garrisoning. adding a much needed random element to the placement of units in urban environments. I use it to make towns a little more lethal. having to check every window and door before clearing out a building adds a real edge to urban and cqb gameplay.
            I hope you enjoy it as much as i do

            https://rapidshare.com/files/2881858...son_script.rar

            Full readme is enclosed in the file.

            Comment


            • #7
              Re: Garrison on the fly script

              I will check this one out and let you know.

              Current ARMA Development Project: No Current Project

              "An infantryman needs a leader to be the standard against which he can judge all soldiers."

              Friend of |TG| Chief

              Comment


              • #8
                Re: Garrison on the fly script

                here is a version without the need for jayarma2lib.

                https://rapidshare.com/files/7495787...son_script.rar

                i realise we all pretty much use this anyway but it was upon request so i thought it might be useful
                also i think future builds will be based of this rather than relying on the jay arma function

                Comment


                • #9
                  When I tested this. I kept on getting "Buildings not loaded" on hint message.

                  Know the cause ?

                  TGU Instructor TG Pathfinder

                  Former TGU Dean Former ARMA Admin Former Irregulars Officer

                  "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

                  Comment


                  • #10
                    Re: Garrison on the fly script

                    the one with jay or not jay arma lib and also on what map?

                    Comment


                    • #11
                      Not jayarma. On Celle.

                      TGU Instructor TG Pathfinder

                      Former TGU Dean Former ARMA Admin Former Irregulars Officer

                      "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

                      Comment


                      • #12
                        Re: Garrison on the fly script

                        celle i haven't added yet... the maps i added there were zargabad takistan fallujha and lingor..... i have since added others so i'll do celle and upload here

                        Comment


                        • #13
                          Garrison on the fly script

                          Thanks

                          TGU Instructor TG Pathfinder

                          Former TGU Dean Former ARMA Admin Former Irregulars Officer

                          "Do not seek death. Death will find you. But seek the road which makes death a fulfillment." - Dag Hammarskjold

                          Comment


                          • #14
                            Re: Garrison on the fly script

                            just noticed i didn't actually upload these...

                            here is a more comprehensive pack of buildings for the arma maps. Maps now include ;

                            Cherno
                            Takistan
                            Celle
                            Shapur
                            Zargabad
                            Lingor
                            Fallujah
                            CLAfghan
                            Utes

                            Changelog. 1.1

                            Fixed : Changed stationary command from disableAI to forcespeed 0, Units now are aware when using the stationary option (variable 3) during execution and thus track targets unlike before. There are always more people to clear out of a building this way, which was my aim.

                            Added : A 30% chance that a unit will ignore the stationary check. After testing with all units "obeying" the stationary check thee town i was testing it on became a little predictable as i knew there would be noone in the street, so i didn't need to check. This now lets a few guys per squad go scouting if you will, and just generally causing you trouble.

                            download : https://rapidshare.com/files/4095712...ipt%20v1.1.rar

                            enjoy

                            Comment


                            • #15
                              Re: Garrison on the fly script

                              Updated to v1.2
                              pretty big changes like a system for units to check if a building is occupied and a new patrol script for when there are no buildings to occupy

                              link:

                              http://www.armaholic.com/forums.php?m=posts&q=18669&d=0

                              Comment

                              Connect

                              Collapse

                              TeamSpeak 3 Server

                              Collapse

                              Advertisement

                              Collapse

                              Twitter Feed

                              Collapse

                              Working...
                              X