Author Topic: Require Code for Gravity Bomb. (IE: Carpet Bomb)  (Read 833 times)

http://en.wikipedia.org/wiki/Carpet_bomb
http://en.wikipedia.org/wiki/Gravity_bomb

I need code for Something like this. Models are ready to be used, I just need the code. Can somone make this?

I wrote this code a long time ago. It makes a stunt plane drop five HE grenades (one per second) when the pilot presses Space with a twenty-second recharge time. This directly creates the projectiles rather than using a specific weapon to fire.

It could be modified to drop spear-like projectiles (gravity-based and exploding on impact) with a slight velocity in the direction of the plane, and maybe a safety check so it won't drop them while you are on the ground/near it.

Code: [Select]
function stuntplaneVehicle::onTrigger(%this, %obj, %num, %cli, %wha)
{
if(%cli $= 1 && !%obj.nofire)
{
%obj.nofire = 1;
bottomprint(%obj.getMountedObject(0).client,"\c0Bombs launching!",2,2,2);
schedule(20000,0,resetfire,%obj);
Bombs(0,%obj);
}
}

function resetFire(%obj)
{
%obj.nofire = 0;
if(isObject(%obj.getMountedObject(0).client)){bottomprint(%obj.getMountedObject(0).client,"\c0Bombs ready!",2,2,2);}
}

function Bombs(%num,%obj)
{
   %p = new (Projectile)() {
      dataBlock        = heGrenadeProjectile;
      initialVelocity  = vectorScale("0 0 -1",heGrenadeProjectile.muzzleVelocity);
      initialPosition  = vectorAdd(%obj.position,"0 0 -2");
      sourceObject     = %obj;
      sourceSlot       = 0;
      client           = %obj.getMountedObject(0).client;
      minigame = %obj.getMountedObject(0).client.minigame;
   };
if(%num<6){schedule(500,0,bombs,%num++,%obj);}
}

Amazing, but can it be applied to the Biplane as well, and how does it reference hegrenadeProjectile, from the HE-Grenade Script?
« Last Edit: July 29, 2008, 12:04:16 PM by yuki »

im no scripter....but I can see the he-grenade reference here.


I wrote this code a long time ago. It makes a stunt plane drop five HE grenades (one per second) when the pilot presses Space with a twenty-second recharge time. This directly creates the projectiles rather than using a specific weapon to fire.

It could be modified to drop spear-like projectiles (gravity-based and exploding on impact) with a slight velocity in the direction of the plane, and maybe a safety check so it won't drop them while you are on the ground/near it.

Code: [Select]
function stuntplaneVehicle::onTrigger(%this, %obj, %num, %cli, %wha)
{
if(%cli $= 1 && !%obj.nofire)
{
%obj.nofire = 1;
bottomprint(%obj.getMountedObject(0).client,"\c0Bombs launching!",2,2,2);
schedule(20000,0,resetfire,%obj);
Bombs(0,%obj);
}
}

function resetFire(%obj)
{
%obj.nofire = 0;
if(isObject(%obj.getMountedObject(0).client)){bottomprint(%obj.getMountedObject(0).client,"\c0Bombs ready!",2,2,2);}
}

function Bombs(%num,%obj)
{
   %p = new (Projectile)() {
      dataBlock        = he[b]GrenadeProjectile[/b];
      initialVelocity  = vectorScale("0 0 -1",[b]heGrenadeProjectile[/b].muzzleVelocity);
      initialPosition  = vectorAdd(%obj.position,"0 0 -2");
      sourceObject     = %obj;
      sourceSlot       = 0;
      client           = %obj.getMountedObject(0).client;
      minigame = %obj.getMountedObject(0).client.minigame;
   };
if(%num<6){schedule(500,0,bombs,%num++,%obj);}
}

what happens if HE grenades arent enabled?

Then I'd expect it would drop nothing.