Jump to content
Sign in to follow this  
ligthert

lessExplosions.sqf: reducing the chance of exploding vehicles

Recommended Posts

I've made small script that should reduce the chances of vehicles exploding when hit with to many grenades or bullets. It is a basic eventHandler that limits damage to key components but is bypassed when a vehicle is damaged rockets, missiles and grenades etc and checks every so often (60secs) if there are any new vehicles spawned and adds the EH.

Usage is very easy:

1) save the following code as lessExplosions.sqf and place it in your mission folder

2) place null = [] execVM "lessExplosions.sqf"; in your init.sqf

// lessExplosions.sqf v0.2 by Sacha Ligthert aka /dev/urandom
// init: null = [] execVM "lessExplosions.sqf";

SL_lessExposions = {
   private ["_obj","_damage","_ammoTypes"];
   _obj = _this select 0;
   _obj addEventHandler ["HandleDamage", {
       _damage = _this select 2;
       _ammoTypes = ["MissileCore","BombCore","RocketCore","GrenadeCore","TimeBombCore"];
       // or ( isNull (_this select 3) and "Air" == typeOf _obj)
       if ( [_this select 4,_ammoTypes] call SL_checkKinds and !isNull (_this select 3) and (_this select 4) != "" ) then {
           if ( (_this select 1 == "") and (_damage > 0.1) ) then { _damage = 0.1 };
           if ( (_this select 1 == "telo") and (_damage > 0.9) ) then { _damage = 0.9 };
           if ( (_this select 1 == "fuel") and (_damage > 0.9) ) then { _damage = 0.9 };
       };
       _damage;
       }];
   _obj setVariable ["lessened", true, true];
};

SL_checkKinds = {
   private ["_ammoType","_ammoTypes","_return"];
   _ammoType = _this select 0;
   _ammoTypes = _this select 1;
   _return = true;

   {
       if (_ammoType isKindOf _x) then { _return = false; };
   } forEach _ammoTypes;

   _return
};

[] spawn {
   if (isserver) then {
       while {true} do {
           {
                if ((!(_x getVariable ["lessened", false]))) then {
                   [[_x], "SL_lessExposions", _x] call BIS_fnc_mp;
                   // player sideChat format["Lessened: %1",_x];
               };
           }foreach vehicles;
           sleep 60;
       }
   };
};

Known issues:

  • .50cals can't explode aircrafts
  • Damage is still taken from nearby burning vehicles
  • Doesn't use the new BIS_fnc_addEH function yet, so it can overwrite existing EHs
  • Ramming the sport car at full speed into a wall will still make the car go boom

Todo:

  • Clean up code a bit and make use of the new functions provided by BIS
  • Reduce damage from burning wrecks
  • exclude aircrafts entirely (??)
  • Test with Zeus

I made this because it annoyed me that given enough bullets every vehicle would explode for some reason.

Share this post


Link to post
Share on other sites

Looks great I tried the same thing in A2 but could never get tanks to stop exploding most of the time.

One little change you could add would be a parameter which lets you adjust the chance of exploding.

Share this post


Link to post
Share on other sites
Looks great I tried the same thing in A2 but could never get tanks to stop exploding most of the time.

I believe that these 3 variables are key in preventing your tanks from exploding. It seems that when you hit the fuel compartment things tend to blow up.

One little change you could add would be a parameter which lets you adjust the chance of exploding.

Doable. But I would rather parameterize the sleep. Since 60 secs can be pretty steep.

Share this post


Link to post
Share on other sites

This is incredibly necessary, great work!

I can imagine the future possibilities! Instead of instant fireball, brushing a tree with your tail rotor simply sends the helicopter into a spin and a particle effect of mangled metal sprays out.

Share this post


Link to post
Share on other sites

I know this was posted last year and all but it should still work right? Though i cant seem to get it working at all, Could someone maybe take a look at the original code and see if anything has changed since the recent arma 3 updates please?

Share this post


Link to post
Share on other sites

I haven't touched it since release. So I'll have to test this and see what happens.

Share this post


Link to post
Share on other sites
I haven't touched it since release. So I'll have to test this and see what happens.

Your a legend, thanks for the quick response.

Share this post


Link to post
Share on other sites

@ligthert did you manage to test your script to see if it was still working or not? Thanks.

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  

×