Jump to content
Sign in to follow this  
exentenzed

Jet engine shutdown after a certain damage threshold is reached.

Recommended Posts

I've been searching around on Armaholic, Bis forums and Google trying to find a script that disables the engines on jets after a certain damage threshold (0.4-0.6), but not luck so far. I even tried making one, but due to my ineptitude i didnt get very far with that either.

What i am specifically looking for, is a script that makes a jets engine turn off without beeing able to turn them back on after a certain amount of damage is reached, but also be able to turn them back on if it manages to emergency land and get repaired. Since jets only have the Hull damage sector it seems that it will either get blown up or continue flying with max power.

Can anyone help me with this? I would settle for something as simple as all fuel beeing removed after said damage threshold was reached, as i believe it should accomplish the same thing.

Share this post


Link to post
Share on other sites

And in a script it would look like:

damageThreshold = 0.4;
damageEH =  {

   _vehicle    = _this select 0;
   _engineOn = _this select 1;

   if (count _this > 2) then
   {
       // called upon hit
       _engineOn = true;
   };

   if (_engineOn && damage _vehicle > damageThreshold) then
   {
       (driver _vehicle) action ["EngineOff", _vehicle];
   };

};

yourVehicle addEventHandler ["Engine", damageEH];
yourVehicle addEventHandler ["Hit", damageEH];

Edited by XxAnimusxX

Share this post


Link to post
Share on other sites

Wow, i wasn't even close. :P

You have my gratitude for your assistance, I will try it out in a bit.

Edit: It works quite well, only thing is that it is only ammunition with splash damage that activates it, regular 14.7mm rounds and smaller do damage, but does not make the engine shutdown kick in, anyway to fix that?

Either way, Thanks again for your help. Even if this last little issue cannot be fixed, this little script will help both me and my group. :)

Edited by Exentenzed
Additional information after testing.

Share this post


Link to post
Share on other sites

Well according to BIKI the Hit-Event won't kick in for minor damages nor very big ones, so the only other option would be a "live-long"-script.

Let's assume you've created a file named "engineFailure.sqf", and put the following code in it:

if (isNil "engineFailureDamageEH") then
{
engineFailureDamageEH = {
	private ["_vehicle", "_engineOn"];

	_vehicle    = _this select 0;
	_engineOn 	= _this select 1;

	if (_engineOn && damage _vehicle > (_vehicle getVariable ["engineFailureThreshold", 1.00])) then
	{
		(driver _vehicle) action ["EngineOff", _vehicle];
	};
};
};

_vehicle	= _this select 0;
_threshold	= _this select 1;

_vehicle	setVariable ["engineFailureThreshold", _threshold];
_eventID	= _vehicle addEventHandler ["Engine", engineFailureDamageEH];

while {alive _vehicle} do
{
// Do nothing until the damage exceeds the threshold
waitUntil {damage _vehicle > _threshold};

// Check wheather the vehicle has been destroyed by the last damage it took
if (alive _vehicle) then
{
	[_vehicle, isEngineOn _vehicle] call engineFailureDamageEH;

	// Now do nothing until either the damage has been repaired or the vehicle gets destroyed
	waitUntil {damage _vehicle <= _threshold || !alive _vehicle};
};
};

// do some cleanup nevertheless
_vehicle removeEventHandler ["Engine", _eventID];
_vehicle setVariable 		["engineFailureThreshold", nil];

So you can do this in another script (like init.sqf or the init-field of the jet):

[yourPlane, 0.4] execVM "engineFailure.sqf";

Well basically now you can even individually set the threshold for every vehicle of your choice.

I didn't test the code though so I need a feedback to search for bugs etc.

Share this post


Link to post
Share on other sites

I havent tested it in Multiplayer yet, but tests during singleplayer was perfect. the only thing was that i had to type in:

[color="#0000FF"]_efs[/color] [color="#00FF00"]=[/color] [color="#0000FF"][yourPlane, 0.4] execVM[/color] [color="#FF0000"]"engineFailure.sqf"[/color];

or else it just returned "Type script, expected nothing."

But yea, worked perfectly. Will test in Multiplayer later on and will also check it on a dedicated on monday.

You're Amazing. :yay:

Edit: Works fine in multiplayer. :)

Edited by Exentenzed
Additional information after testing.

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  

×