Jump to content
Sign in to follow this  
A-SUICIDAL

Magic Runway -repair,rearm,refuel,heal

Recommended Posts

I'm almost done making a coop jet flying mission, but I wanted to add a trigger covering the runway at our base that when players fly less than 30m over the runway - it will instantly repair, rearm and refuel the plane and also heal the player. Much like in Battlefield 2. I put this in another mission months ago, but it only rearmed the vehicle and the trigger failed to work after the player and vehicle respawned.

So far I have a trigger covering the runway, set to be activated by BLUFOR, repeatedly and this in the condition field:

this && {((getPosATL _x) select 2) < 30} count thislist > 0

Now I just need to figure out how to script things correctly for:

_unit setDamage 0;

_veh setDamage 0;

_veh setFuel 1;

_veh setVehicleAmmo 1;

...and make sure that it works for vehicles/players after they respawn.

Any help with this would be appreciated. It's not a bad idea for flying missions.

Share this post


Link to post
Share on other sites

Yeah I've used that. Thanks, but I don't think it will work in this case, since vehicle is still in the air moving fast.

Share this post


Link to post
Share on other sites

Nothing in the vehicle's init or player's init, or any init.sqf, right? If so, as long as the trigger is on Repeatedly I don't see why this wouldn't work after respawn.

I also suggest General Carver's Vehicle Rearm Script. A bit old school now I guess, but it gets the job done.

Share this post


Link to post
Share on other sites

How would I put...

setDamage 0; //for player

setDamage 0; //for vehicle

setFuel 1; //for vehicle

setVehicleAmmo 1; //for vehicle

in a trigger and have it effect any player and their vehicle that enters the trigger? Or have it exec a script to to do the same?

Usually I use actions to do this stuff, but in this case, I just want it to instantly occur with out the need of performing an action.

Share this post


Link to post
Share on other sites

Change the condition to simply "this." Then, the following activation should produce the desired results:

{if ((getPosATL _x select 2) < 30) then {_x setDamage 0;(vehicle _x) setDamage 0;(vehicle _x) setFuel 1;(vehicle _x) setVehicleAmmo 1}} forEach thisList

Edited by ST_Dux
Simpler/better solution

Share this post


Link to post
Share on other sites

exec a script is the likely way to go - like this

add 2 sensors in mission

		class Item0
	{
		position[]={18055.271,8.6999998,18374.492};
		a=480;
		b=180;
		angle=77;
		rectangular=1;
		activationBy="ANY";
		repeating=1;
		age="UNKNOWN";
		text="airport";
		name="AirportIn";
		class Effects
		{
		};
	};
	class Item1
	{
		position[]={12882.666,0.20005792,2010.6289};
		timeoutMin=1;
		timeoutMid=1;
		timeoutMax=1;
		interruptable=1;
		age="UNKNOWN";
		text="repair";
		name="repair";
		expCond="isServer";
		expActiv="plays = [] execVM ""repair.sqf"";";
		class Effects
		{
		};
	};

then a script called repair.sqf

EGG_Repair = 
{
_vec = (vehicle player);
if( (getDammage _vec > 0 or fuel _vec < 0.98) and (_vec in list AirportIn) and not (_vec isKindOf "Man") ) then
{
	if( (_vec != player)  and (position _vec select 2 < 30.0) and (local _vec) ) then
	{
		 titleText [localize "STR_M04t83", "PLAIN DOWN",0.3];//Servicing
		 for [{_loop3=0}, {_loop3<1}, {_loop3=_loop3}] do
		 {
		    sleep 0.200;	    		    
		    if (getDammage _vec > 0) then {_vec setDammage ((getDammage _vec)-0.5);};
		    if (Fuel _vec < 1) then {_vec setFuel ((Fuel _vec)+0.5);};
		_vec setVehicleAmmo 1;	
		_player setdammage 0;	

		    if (getDammage _vec == 0 and Fuel _vec == 1) then {_loop3=1;};
		    if(_vec != vehicle player or position _vec select 2 > 30.0) then {_loop3=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];
		};
	};
};
};

for [{_loop=0}, {_loop<1}, {_loop=_loop}] do
{
[] call EGG_Repair;
sleep 1.011;
};

this does a fairly rapid repair/refuel etc - you can modify the 0.5 value in there to make it work faster...

Share this post


Link to post
Share on other sites

when you first mentioned this in the other thread, Xenos vehicle rearm script imediatly came to mind.

here is a crude working version of this, (just tested in SP editor) i just wanted to post it before i go into the code and start changing it for the issues descibed in notes:

Xenos vehicle rearm script is unmodified, exept for i removed the setfuel 0 at start and commented a few other lines, i also changed the text displayed.

Notes:

* Should work fine in MP aswell, since Xenos script already do.

* the obvious one, once activated the plane will rearm fully no matter if its keeping its speed or altitude, also death/crash is not accounted in. added

* only planes will be rearmed by this.

* added heal of all crew of plane at end of the rearm provess. - this is now also timed in steps while flying low over trigger.

place your trigger and have it cover the runway for example, set it to rectangle and adjust size.

make it anyone or side present, repeated, 0 delay.

in on act:

_null = thisTrigger execVM "flybyRearm.sqf";

in the top of script adjust the minSpeed and minHeight options, its what is minimum for start of rearm.

flybyRearm.sqf

*snip*

new code in my next post.

edit: note to self, press refresh button before posting.

btw, i flyed my a10, unloaded all the weapons made a slow pass over the runway and was fully rearmed at the end of the runway good to go.

however i could just dive in start the rearm and go wherever i wanted, since the script does not care yet if i stay inside the trigger area.

Edited by Demonized
removed script, updated version in my next post.

Share this post


Link to post
Share on other sites

I experimented with each script. They all seem to work well.

ST_Dux, your script seemed the most simplified, but the player was not healing at all, so I tried changing it a little. I also decided to set the height to 50m and add a vehicleChat message with it.

condition: this

on activation:

{if ((getPosATL _x select 2) < 50) then {player setDamage 0;(vehicle _x) setDamage 0;(vehicle _x) setFuel 1;(vehicle _x) setVehicleAmmo 1}} forEach thisList; vehicle player vehicleChat "Your Fighter is eady..."

I also created a trigger with radius 0, activation "NONE" with...

condition:

vehicle player != player

on activation:

hint composeText [parsetext format["<t size='1.2' align='center' color='#FFA500'>Reminder%1</t><br/><br/><t size='0.9' align='center' color='#FFFFFF'>To rearm, repair, refuel and heal mid-air, simply fly less than 50m over the runway at your Air Base.%1</t>"]];

Now when anybody hops in a fighter, they will get a reminder message telling them that they can low fly-by over the runway to service their vehicle and heal.

---------- Post added at 02:49 PM ---------- Previous post was at 02:34 PM ----------

I use zeno's script in a few of my other missions, it works awesome. I also have a mission where I equipped a couple of littlebirds with 14 additional rockets, and the littlebirds use a vehicle respawn script that adds an additional 14 rockets when they respawn, but I also had to add tell zeno's script to add 14 additional rockets as well, because his script normally removes all weapons and the adds back the default amount. I also have a couple of Bradleys and a couple of Stryker MGS that have additional ammo too, so right at the near the bottom of Zeno's script, where it says "_object setFuel 1;" I then added these lines below it:

_object addMagazineTurret ["14RND_FFAR",[-1]]; //for Littlebird

_object addMagazineTurret ["2RND_TOW2",[0]]; // for Bradley

_object addMagazineTurret ["2RND_TOW2",[0]]; // for Bradley

_object addMagazineTurret ["2RND_TOW2",[0]]; // for Bradley

_object addMagazineTurret ["2RND_TOW2",[0]]; // for Bradley

_object addMagazineTurret ["210RND_25MM_M242_APDS",[0]]; // for Stryker MGS

_object addMagazineTurret ["210RND_25MM_M242_HEI",[0]]; // for Stryker MGS

This tries to add the weapons to any vehicle that uses the vehicle service trigger, but I figure it can't hurt because if the the vehicle can't use the added weapons, then it obviously can't equip them and fire them, lol. So it works well.

Share this post


Link to post
Share on other sites

here is a updated version of my take on this with xenos script.

works quite well in SP tests.

/*
Rearm Planes BF style
by Demonized.

using unmodified version of Xeno´s vehicle rearm script.

rearm script is unmodified, exept for the setfuel 0 at start.


*/

_minSpeed = 200;  // this is the minimum speed the plane must be under to start rearming.
_minHeight = 50;  // this is the minimum height the plane needs to be under to start rearming.

//if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight AND _veh in (list _trigger)) then {

// by Xeno, modified by Demonized.
_trigger = _this;
_running = [];
while {(count (list _trigger)) != 0} do {
{
	_veh = vehicle _x;
	if (_veh iskindOf "Plane" AND !(_veh in _running) AND (speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight) then {
		_running = _running + [_veh];

		// hint part.
		_null = [_veh,_trigger,_minSpeed,_minHeight] spawn {
			_veh = _this select 0;
			_drv = driver _veh;
			if (_drv != player) exitWith {};
			_trigger = _this select 1;
			_minSpeed = _this select 2;
			_minHeight = _this select 3;
			while {(_veh in (list _trigger))} do {
				if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight) then {
					hintSilent format["player health is %1 \n vehicle damage is %2 \n vehicle fuel is %3 \n vehicle ammo is %4",(getDammage _drv),(getDammage _veh),(fuel _veh),(_veh getVariable ["ammo", 0])];
					sleep 0.1;
				} else {
					waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
				};
			};
		};

		// rearm part, mostly code is Xenos vehicle rearm script.
		_null = [_veh,_trigger,_minSpeed,_minHeight] spawn {
			_trigger = _this select 1;
			_minSpeed = _this select 2;
			_minHeight = _this select 3;

			private ["_config","_count","_i","_magazines","_veh","_type","_type_name"];
			_veh = _this select 0;
			_type = typeof _veh;

			// timed rearm part.
			_null = [_veh,_trigger,_minSpeed,_minHeight] spawn {
				_run = true;
				_veh = _this select 0;
				_trigger = _this select 1;
				_minSpeed = _this select 2;
				_minHeight = _this select 3;
				_ammo = 0;
				while {_run AND (_veh in (list _trigger))} do {
					if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight) then {
						_ammo = _ammo + 0.1;
						if (_ammo == 1) then {_run = false};
						_veh setVehicleAmmo _ammo;
						_veh setVariable ["ammo", _ammo, true];
						sleep 0.9;
					} else {
						waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
					};
					sleep 0.1;
				};
			};

			if (isNil "x_reload_time_factor") then {x_reload_time_factor = 1;};
			if (!alive _veh) exitWith {};
			_type_name = typeOf _veh;
			_veh vehicleChat format ["Servicing %1... maintain speed and height...", _type];
			_magazines = getArray(configFile >> "CfgVehicles" >> _type >> "magazines");
			if (count _magazines > 0) then {
				_removed = [];
				{
					if (!(_x in _removed) AND (speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight AND _veh in (list _trigger)) then {
						_veh removeMagazines _x;
						_removed set [count _removed, _x];
					} else {
						waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
					};
				} forEach _magazines;
				{
					sleep x_reload_time_factor;
					if (!alive _veh) exitWith {};
					if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight AND _veh in (list _trigger)) then {
						_veh addMagazine _x;
					} else {
						waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
					};
				} forEach _magazines;
			};

			_count = count (configFile >> "CfgVehicles" >> _type >> "Turrets");
			if (_count > 0) then {
				for "_i" from 0 to (_count - 1) do {
					scopeName "xx_reload2_xx";
					_config = (configFile >> "CfgVehicles" >> _type >> "Turrets") select _i;
					_magazines = getArray(_config >> "magazines");
					_removed = [];
					{
						if (!(_x in _removed) AND (speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight AND _veh in (list _trigger)) then {
							_veh removeMagazines _x;
							_removed set [count _removed, _x];
						} else {
							waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
						};
					} forEach _magazines;
					{
						sleep x_reload_time_factor;
						if (!alive _veh) then {breakOut "xx_reload2_xx"};
						if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight AND _veh in (list _trigger)) then {
							_veh addMagazine _x;
						} else {
							waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
						};
						sleep x_reload_time_factor;
						if (!alive _veh) then {breakOut "xx_reload2_xx"};
					} forEach _magazines;

					// check if the main turret has other turrets
					_count_other = count (_config >> "Turrets");
					// this code doesn't work, it's not possible to load turrets that are part of another turret :(
					// nevertheless, I leave it here
					if (_count_other > 0) then {
						for "_i" from 0 to (_count_other - 1) do {
							_config2 = (_config >> "Turrets") select _i;
							_magazines = getArray(_config2 >> "magazines");
							_removed = [];
							{
								if (!(_x in _removed)) then {
									_veh removeMagazines _x;
									_removed set [count _removed, _x];
								};
							} forEach _magazines;
							{
								sleep x_reload_time_factor;
								if (!alive _veh) then {breakOut "xx_reload2_xx"};
								if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight AND _veh in (list _trigger)) then {
									_veh addMagazine _x;
								} else {
									waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
								};
								sleep x_reload_time_factor;
								if (!alive _veh) then {breakOut "xx_reload2_xx"};
							} forEach _magazines;
						};
					};
				};
			};
			_veh setVehicleAmmo 1;	// Reload turrets / drivers magazine
		};

		//repair part.
		_null = [_veh,_trigger,_minSpeed,_minHeight] spawn {
			_run = true;
			_veh = _this select 0;
			_trigger = _this select 1;
			_minSpeed = _this select 2;
			_minHeight = _this select 3;
			while {_run AND (_veh in (list _trigger))} do {
				if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight) then {
					_dam = getDammage _veh;
					if ((_dam - 0.1) < 0) then {_dam = 0.1; _run = false};
					_veh setDammage (_dam - 0.1);
					sleep 0.9;
				} else {
					waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
				};
				sleep 0.1;
			};
		};

		// refuel part.
		_null = [_veh,_trigger,_minSpeed,_minHeight] spawn {
			_run = true;
			_veh = _this select 0;
			_trigger = _this select 1;
			_minSpeed = _this select 2;
			_minHeight = _this select 3;
			while {_run AND (_veh in (list _trigger))} do {
				if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight) then {
					_fuel = fuel _veh;
					if ((_fuel + 0.1) > 1) then {_fuel = 0.9; _run = false};
					_veh setFuel (_fuel + 0.1);
					sleep 0.9;
				} else {
					waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
				};
				sleep 0.1;
			};
		};

		// heal crew part.
		_null = [_veh,_trigger,_minSpeed,_minHeight] spawn {
			_run = true;
			_veh = _this select 0;
			_trigger = _this select 1;
			_minSpeed = _this select 2;
			_minHeight = _this select 3;
			while {_run AND (_veh in (list _trigger))} do {
				{
					if ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight) then {
						_dam = getDammage _x;
						if ((_dam - 0.1) < 0) then {_dam = 0.1; _run = false};
						_x setDammage (_dam - 0.1);
					} else {
						waitUntil {!(_veh in (list _trigger)) OR ((speed _veh) < _minSpeed AND (getPos _veh select 2) < _minHeight)};
					};
				} foreach crew _veh;
				sleep 1;
			};
		};
	};
} foreach (list _trigger);

// remove those that left the trigger, so they can be readded if entering again, also remove crashed vehicles from list..
{
	if (!(_x in (list _trigger) OR (getDammage _x) >= 1) then {_running = _running - [_x];
} foreach _running;
sleep 0.1;
};

Share this post


Link to post
Share on other sites

while (true) do {
[player] call makeEveryThingBetter;
};

:)

Share this post


Link to post
Share on other sites

The only issue with using "player" is that everyone will heal whenever one person flies over the runway.

Replace the old activation with the following, and all should be well:

{if ((getPosATL _x select 2) < 50) then {[b](driver _x)[/b] setDamage 0;_x setDamage 0;_x setFuel 1;_x setVehicleAmmo 1}} forEach thisList;(driver _x) vehicleChat "Your Fighter is ready..."

As it turns out, the trigger was returning the name of the vehicle passing through the trigger area, not the pilot of the vehicle. Thus, "vehicle _x" is unnecessary, but "driver _x" is required.

Share this post


Link to post
Share on other sites

Trying it now.

Oh, when I mentioned before...

I also created a trigger with radius 0, activation "NONE" with...

condition:

Code:

vehicle player != player

on activation:

Code:

hint composeText [parsetext format["<t size=1.2' align='center' color='#FFA500'>Reminder%1</t><br/><br/><t size='0.9' align='center' color='#FFFFFF'>To rearm, repair, refuel and heal mid-air, simply fly less than 50m over the runway at your Air Base.%1</t&gt]];

Now when anybody hops in a fighter, they will get a reminder message telling them that they can low fly-by over the runway to service their vehicle and heal.

The part where I use "vehicle player != player" as the condition, this works, but if the get in a support truck or a jeep, it gives them the same message. So I changed the condition to:

vehicle player isKindOf "GLT_Falcon_lg_cap"

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
Sign in to follow this  

×