Jump to content
autigergrad

Looking for a simple vehicle repair/rearm/refuel script

Recommended Posts

We do a lot of ALiVE persistent campaigns that last quite a long time.  The biggest issue we run into is a lack of consistent rearm/refuel/repair zones/facilities that will work with all of the mods we use.  Is there a simple script out there that can allow us to create one that will work on any vehicle (ACE compatible, Vanilla, RHS, etc.)?

Share this post


Link to post
Share on other sites

here you go (from our arma2 missions)

 

//in mission.sqm
	class Sensors
	{
		items=3;
		class Item0
		{
			position[]={4619.7158,0.19623651,-1617.5906};
			timeoutMin=1;
			timeoutMid=1;
			timeoutMax=1;
			interruptable=1;
			age="UNKNOWN";
			text="pinit";
			name="pinit";
			expCond="local player";
			expActiv="plays = [] execVM ""scripts\pinit.sqf"";";
			class Effects
			{
			};
		};
		class Item1
		{
			position[]={9645.6133,13,2998.0623};
			a=400;
			b=180;
			angle=90;
			rectangular=1;
			activationBy="ANY";
			age="UNKNOWN";
			text="airport";
			name="AirportIn";
			class Effects
			{
			};
		};
		class Item2
		{
			position[]={8441.6699,678.59814,10571.127};
			a=40;
			b=40;
			angle=50;
			activationBy="WEST";
			repeating=1;
			interruptable=1;
			age="UNKNOWN";
			name="farp1";
			class Effects
			{
			};
		};
	};
};

make a folder in your mission folder called "scripts" and place these into it

//scripts\pinit.sqf
_cthread = [] execVM "scripts\MainThreadC.sqf";
//and any other player clientside scripts you care to run at player join
//scripts\mainthreadC.sqf
EGG_EVO_Repair = 
{
	_vec = (vehicle player);
	_type = typeOf vehicle player;

	if(getDammage _vec > 0 or fuel _vec < 0.98 and not (_vec isKindOf "Man")) then
	{
		_inrepairzone = ((_vec in list AirportIn) or (_vec in list farp1) );//your sensor zones in the mission named "Airportin" or "farp1" etc
		if(((_vec in list AirportIn) or (_vec in list farp1) ) and _vec != player and speed _vec > -2 and speed _vec < 2 and position _vec select 2 < 2.0 and (local _vec)) then
		{
			 titleText [localize "STR_M04t83", "PLAIN DOWN",0.3];
			 for [{_loop2=0}, {_loop2<1}, {_loop2=_loop2}] do
			 {
			    sleep 0.200;	    		    
			    if (getDammage _vec > 0) then {_vec setDammage ((getDammage _vec)-0.0125);};
			    if (Fuel _vec < 1) then {_vec setFuel ((Fuel _vec)+0.0125);};
			    if (getDammage _vec == 0 and Fuel _vec == 1) then {_loop2=1;};
			    if(_vec != vehicle player or speed _vec < -2 or speed _vec > 2 or position _vec select 2 > 2.0) then {_loop2=1;titleText [localize "STR_M04t84", "PLAIN DOWN",0.3];};
			    _dam = (getDammage _vec)*100;
			    _ful = (Fuel _vec)*100;
			    hint format["Damage: %1\nFuel: %2",Round _dam,Round _ful];
			};
			_vec setVehicleAmmo 1;	
		};
	};
};

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
	[] call EGG_EVO_Repair;
	sleep 1.01;
};

this is the standard repair/refuel/rearm function for Arma1 and2 for us

just go into your mission in the editor and move the trigger/sensors about until they are where you want them

i'll be polishing this up for use at all fuel stations too soon (repair not rearm!)

 

Share this post


Link to post
Share on other sites

AuTigerGrad, I use the one by Xeno: http://www.armaholic.com/page.php?id=19139

It's super super easy to use and automatically repairs/refuels/rearms everything I've thrown at it. The process is trigger based so what I do is lightly decorate the area surrounding the triggers to at least make this process as believable as possible.

There are seperate trigger codes for air vehicles and ground vehicles.

If the above snippet doesn't work for you definitely investigate this one if you're willing to suspend reality a bit. It works perfectly with everything I've tried, both modded and vanilla and on a dedicated server too.

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

×