Author Topic: Explosion that only adds vertical velocity  (Read 2190 times)

Is there a way to edit explosionData to make the explosion only add vertical velocity and not any x or y velocity? It mainly needs to work for when the projectile hits a vehicle.

This is the explosionData
Code: [Select]
datablock ExplosionData(strongMissileExplosion : gravityRocketExplosion)
{
   explosionShape = "add-ons/weapon_rocket_launcher/explosionSphere1.dts";

   damageRadius = 8;
   radiusDamage = 220;

   impulseRadius = 5;
   impulseForce = 4000;           //This will be removed since it adds x and y velocity

   burnTime = 0;
};



If it can't be done in the explosionData, can it be done by editing function strongMissileProjectile::damage (which should be called when the projectile collides with something).  I actually had problems getting this function to run- the echoes within it never showed up in console, maybe because I had weapon damage disabled in the minigame (but I still had vehicle damage enabled).

This is the function strongMissileProjectile::damage
Code: [Select]
function strongMissileProjectile::damage(%this,%obj,%col,%fade,%pos,%normal)
{

   echo("MADE IT INSIDE DAMAGE TRIGGER");                            //These 6 lines are my attempt at adding z velocity to the vehicle
   if(%obj.getType() & $Typemasks::VehicleObjectType)
{
echo("HEY IT WORKED THUS FAR");
%obj.setVelocity(vectorAdd(%obj.getVelocity(),"0 0 35"));
}


   if(%this.directDamage <= 0)
      return;

   %damageType = $DamageType::Direct;
   if(%this.DirectDamageType)
      %damageType = %this.DirectDamageType;

   %scale = getWord(%obj.getScale(), 2);
   %directDamage = mClampF(%this.directDamage, -100, 100) * %scale;

   if(%col.getType() & $TypeMasks::PlayerObjectType)
   {
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
   else
   {
      %col.damage(%obj, %pos, %directDamage, %damageType);
   }
}
« Last Edit: August 01, 2015, 03:51:23 AM by Farad »

looking at the RL's explosion code, I see
impulseRadius = 6;
impulseForce = 4000;

and in the projectile code I see
impactImpulse      = 1000;
verticalImpulse      = 1000;

but it doesn't seem like the explosion launches people upward, just outward
I know with radius impulses you can do things like this, and with zones, but there might be some unused fields in the explosions that could be set to do this similar to radius impulse on bricks

looking at the RL's explosion code, I see
impulseRadius = 6;
impulseForce = 4000;

and in the projectile code I see
impactImpulse      = 1000;
verticalImpulse      = 1000;

but it doesn't seem like the explosion launches people upward, just outward
I know with radius impulses you can do things like this, and with zones, but there might be some unused fields in the explosions that could be set to do this similar to radius impulse on bricks
How do you find all the fields that can be used in explosionData?
or, how do you use radius impulse?
« Last Edit: August 01, 2015, 04:48:25 AM by Farad »

You may have to write your own explosion function.

You may have to write your own explosion function.
Which means do a radius search the size of the explosion and add velocity to the players found.

Code: [Select]
package swol_rltest
{
function rocketLauncherProjectile::radiusImpulse(%this,%projectile,%hit,%a,%pos,%force,%b)
{
%dist = vectorDist(%hit.getPosition(),%pos);
%prcnt = %this.explosion.impulseRadius/%dist;

%hit.addVelocity("0 0 " @ (%force/400)*%prcnt);
}
};
activatePackage(swol_rltest);
try something like this

try something like this

I tried and got an error because addVelocity can't be used on vehicles, so I changed it to use setVelocity (in the code below) and it gets no console errors, but it looks like no velocity is added when the vehicle is hit- the vehicle doesn't move at all.

Code: [Select]
package swol_missileTest
{
function strongMissileProjectile::radiusImpulse(%this,%projectile,%hit,%a,%pos,%force,%b)
{
echo("Successfully reached radiusImpulse function");
%dist = vectorDist(%hit.getPosition(),%pos);
%prcnt = %this.explosion.impulseRadius/%dist;

%hit.setVelocity(vectorAdd(%hit.getVelocity() , "0 0 " @ (%force)*%prcnt));           //I tried it with %force/400 and just %force, but neither way appears to give any velocity to the vehicle.
}                                                                                                                                      //%hit is the vehicle being hit
};
activatePackage(swol_missileTest);

By the way, what does %force represent in the function?

I tried and got an error because addVelocity can't be used on vehicles, so I changed it to use setVelocity (in the code below) and it gets no console errors, but it looks like no velocity is added when the vehicle is hit- the vehicle doesn't move at all.

i discovered that setting velocity to a vehicle is /very/ strange. if you set it too high, it'll just won't apply anything to the vehicle. we're going to have to see how much force you're applying to the vehicle, it might be too high or whatever
it would be nice if we could get the mass of the vehicle too so we could calculate the max amount of velocity you can set onto your vehicles

How do you find all the fields that can be used in explosionData?
you can use .dump(); to get a list of fields and methods of an object/type

it would be nice if we could get the mass of the vehicle too so we could calculate the max amount of velocity you can set onto your vehicles
The vehicle mass is 200, and the tire mass is 10.

The vehicle mass is 200, and the tire mass is 10.
make sure that the velocity you're adding to the vehicle is under 130. it should work if the force is under 130

Echo the contents of setVelocity, see how much you're adding. It might be that %prcnt is 0.