Announcement

Collapse
No announcement yet.

Vehicle service station script

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

  • [GUIDE] Vehicle service station script

    I wanted to leave it here on the forums as a documentation to retrieve it later as well as share it for our avid mission makers.

    The difference in this service station is that not only does it repair and rearm vehicles, it also automatically adds infantry ammunition to certain types of vehicles. For example, ammo truck can have some common ammunition, unarmed UGV can get some small subset of that.

    Disclaimer: the script will require some tinkering to make it fit your needs.

    Credits:
    • Xeno for the original script
    • Ghost for improved script


    Usage:
    Create a trigger on editor with following settings:
    • Name: Rearmlist1
      **edited in Name by Unkl

    • Activation:
      • Independent/OPFOR/BLUFOR/Anybody - depending on the mission player side
    • Repeatedly
    • Present
    • Condition:
      • Code:
        this and ((getposatl (thislist select 0)) select 2 < 1)
    • ON ACT:
      • Code:
        _xhandle= [(thislist select 0),Rearmlist1] execVM "reload.sqf";
      • or in a function form:
      • Code:
        _tg_rearm = [(thislist select 0),Rearmlist1] spawn TG_fnc_reload;



    The important reload.sqf (This can be modified as the mission maker sees fit with the new classnames. Island 8 version):

    Code:
    //V1 by Ghost, added delay of 4 seconds if object moves out then no repair
    private ["_object","_Rearmlist","_reload_time","_type","_Object_name","_fuelstore","_removed","_f"];
    
    _object = _this select 0;
    _Rearmlist = _this select 1;
    _reload_time = 10;
    
    _type = typeof _object;
    
    if ((_object isKindOf "ParachuteBase") or (_object isKindOf "Man")) exitWith {};
    
    WaitUntil{_object in list _Rearmlist};
    sleep 4;
    if(!(_object in list _Rearmlist)) exitWith {_object vehiclechat "Repair Aborted"};
    
    if !(alive _object) exitWith {};
    _fuelstore = fuel _object;
    _object setFuel 0;
    
    _Object_name = (configFile >> "cfgVehicles" >> (_type) >> "displayName") call bis_fnc_getcfgdata;
    
    _object vehicleChat format ["Servicing %1... Please stand by...", _Object_name];
    
    
    While {alive _object} do 
    {
    	if(_object isKindOf "O_Truck_03_ammo_F") then 
    	{				
    		_object vehicleChat format ["Loading infantry ammo in %1 inventory.", _Object_name];
    
    		clearWeaponCargoGlobal      _object;
    		clearMagazineCargoGlobal    _object;
    		clearItemCargoGlobal         _object;
    
    		_object addMagazineCargoGlobal ["30Rnd_65x39_caseless_green", 50]; 		 
    		_object addMagazineCargoGlobal ["HandGrenade", 10];
    		_object addMagazineCargoGlobal ["MiniGrenade", 10];
    		_object addMagazineCargoGlobal ["SmokeShell", 5];
    		_object addMagazineCargoGlobal ["SmokeShellGreen", 5];
    		_object addMagazineCargoGlobal ["SmokeShellRed", 5];
    		_object addMagazineCargoGlobal ["150Rnd_762x51_Box", 10];		
    		_object addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 10];
    		_object addMagazineCargoGlobal ["1Rnd_SmokeRed_Grenade_shell", 5];		
    		_object addMagazineCargoGlobal ["RPG32_HE_F", 6];		
    		_object addMagazineCargoGlobal ["RPG32_F", 5];		
    		_object addMagazineCargoGlobal ["DemoCharge_Remote_Mag", 8];  
    		_object addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", 4];  
    		_object addItemCargoGlobal	  ["FirstAidKit", 30];		
    		
    		sleep _reload_time;
    	}
    	else
    	{
    		if(_object isKindOf "I_UGV_01_F") then 
    		{
    			if(isUavConnected _object) then 
    			{
    				_unit = (uavControl _object) select 0;
    				_unit sidechat "Putting ammo in UGV.";
    			};
    
    			clearWeaponCargoGlobal      _object;
    			clearMagazineCargoGlobal    _object;
    			clearItemCargoGlobal         _object;
    
    			_object addMagazineCargoGlobal ["30Rnd_556x45_Stanag", 15]; 
    			_object addMagazineCargoGlobal ["200Rnd_65x39_cased_Box", 4];
    			_object addMagazineCargoGlobal ["20Rnd_762x51_Mag", 4];
    			_object addMagazineCargoGlobal ["1Rnd_HE_Grenade_shell", 5];
    			_object addMagazineCargoGlobal ["NLAW_F", 2];	
    			_object addMagazineCargoGlobal ["Titan_AT", 2];
    			//_object addMagazineCargoGlobal ["Titan_AP", 2];
    			_object addMagazineCargoGlobal ["DemoCharge_Remote_Mag", 2];  
    			_object addMagazineCargoGlobal ["SatchelCharge_Remote_Mag", 1];  
    			_object addItemCargoGlobal	  ["FirstAidKit", 10];
    			
    			sleep _reload_time;
    
    			if(isUavConnected _object) then 
    			{
    				_unit = (uavControl _object) select 0;
    				_unit sidechat "Done. Vehicle has ammo in cargo";
    			};
    		};
    	};
    	
    
    	_object vehicleChat "Rearming...";
    	sleep _reload_time;
    	_object setVehicleAmmo 1;
    
    	_object vehicleChat "Repairing...";
    	sleep _reload_time;
    	_object setDamage 0;
    
    	_object vehicleChat "Refueling...";
    	sleep _reload_time;
    	_f = 0.01;
    	while {fuel _object < 0.99} do {
    		if(!(_object in list _Rearmlist)) exitWith {_object vehicleChat "Fueling Aborted";	_object setFuel _fuelstore + _f;};
    		_object setFuel _fuelstore + _f;
    		sleep 0.2;
    		_f = _f + 0.01;
    	};
    	_object vehicleChat format ["%1 is ready...", _Object_name];
    	if (true) exitWith {};
    };
    Last edited by Unkl; 02-15-2016, 11:40 AM. Reason: add in trigger name


  • #2
    Re: Vehicle service station script

    Awesome....love this script bin. Was searching far & wide for repair scripts and it was right here :D

    Well I want to add to this a nifty little function that I saw in the Evolution mission. The Engineer has the ability to deploy a Forward Ammunition and Repair/Rearming Point(FARP). I want to create our version of this as well. Should simplify the need to repair and rearm vehicles in the field. It should also be dependent on the proximity of a repair truck as well.

    What I like most about the idea is that now you must have the engineer and the repair truck in proximity but you don't need the ammo and fuel trucks as well. That used to mean you need two other players to drive them or your engineer ends up shuttling unguarded vehicles. Either way it added up to more role play and less trigger time for all.
    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member
    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

    Comment


    • #3
      Re: Vehicle service station script

      Also...this script doesn't check for support vehicles and reset their cargo capacity for fuel stores, ammunition or repair supplies. Will work on this too.

      _object setFuelCargo 1;
      _object setAmmoCargo 1;
      _object setRepairCargo 1;
      |TG-189th| Unkl
      ArmA 3 Game Officer
      Dean of Tactical Gamer University
      189th Infantry Brigade Member
      SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
      "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

      Comment


      • #4
        Re: Vehicle service station script

        Got it partly working. It's not working on my Ghosthawk when I test that. It won't seem to fire.
        1. I've created a trigger named "Rearmlist1" (which I will add to the OP by editing it). It has all the conditions and activation listed in the OP.
        2. To the TG folder I changed the "CfgFunctions.h__" to have the a class called reload
        3. Created a file called fn_reload in the TG folder and it's code is below. Just added the support vehicles in three arrays (_repairVics, _ammoVics, _fuelVics) and then the setRepairCargo ect...for each of those arrays.


        Apparently I can't put the code in here as it adds up to an sqf injection according to the TG security. So here is THE LINK to my fn_reload.sqf.


        Any reason it's not working on my ghosthawk. Worked on my test fuel truck. Worked on a Marshall and reloaded the turrets. No joy on the helo.
        Last edited by Unkl; 02-15-2016, 11:30 AM.
        |TG-189th| Unkl
        ArmA 3 Game Officer
        Dean of Tactical Gamer University
        189th Infantry Brigade Member
        SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
        "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

        Comment


        • #5
          Re: Vehicle service station script

          There is a check on height and delay. One must land and stay for like 4 secs... Dunno if that is what is causing it.

          Comment


          • #6
            Re: Vehicle service station script

            Yeah stayed longer than 4 seconds and I'm not seeing the check for height in this code although there should be indeed.

            edit: don't know what I did wrong but it's working
            Last edited by Unkl; 02-15-2016, 11:57 AM.
            |TG-189th| Unkl
            ArmA 3 Game Officer
            Dean of Tactical Gamer University
            189th Infantry Brigade Member
            SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
            "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

            Comment


            • #7
              Re: Vehicle service station script

              that's a good script. I often wondered why vehicles couldn't repair and rearm as well as fill up on gas.
              sigpic
              |TG-1st|Grunt
              ARMA Admin (retired)
              Pathfinder-Spartan 5

              Comment


              • #8
                Re: Vehicle service station script

                Originally posted by Unkl View Post
                Awesome....love this script bin. Was searching far & wide for repair scripts and it was right here :D

                Well I want to add to this a nifty little function that I saw in the Evolution mission. The Engineer has the ability to deploy a Forward Ammunition and Repair/Rearming Point(FARP). I want to create our version of this as well. Should simplify the need to repair and rearm vehicles in the field. It should also be dependent on the proximity of a repair truck as well.

                What I like most about the idea is that now you must have the engineer and the repair truck in proximity but you don't need the ammo and fuel trucks as well. That used to mean you need two other players to drive them or your engineer ends up shuttling unguarded vehicles. Either way it added up to more role play and less trigger time for all.
                the heavily armored and tracked "Bobcat" can be used as Support instead of trucks to rearm, refuel and repair all at once... don't hesitate to use this if it can replace the FARP well enough. It only has a 6.5mm turret (2000 rnds?) for armament and doesn't really require multiple crew... but maybe it isnt fitting to have in your missions, what do I know.
                - Current ArmA Pathfinder

                sigpic

                Comment


                • #9
                  Re: Vehicle service station script

                  Good tip! Was wondering why it was showing up as a support vehicle. Will add its classname to the script.
                  |TG-189th| Unkl
                  ArmA 3 Game Officer
                  Dean of Tactical Gamer University
                  189th Infantry Brigade Member
                  SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
                  "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

                  Comment


                  • #10
                    Re: Vehicle service station script

                    IMPORTANT UPDATE!!

                    I just finished fixing this to work with MP locality issues! Update immediately if you are using this.

                    SAME LINK TO PASTEBIN
                    |TG-189th| Unkl
                    ArmA 3 Game Officer
                    Dean of Tactical Gamer University
                    189th Infantry Brigade Member
                    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN
                    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

                    Comment

                    Connect

                    Collapse

                    TeamSpeak 3 Server

                    Collapse

                    Advertisement

                    Collapse

                    Twitter Feed

                    Collapse

                    Working...
                    X