Author Topic: Firework Launcher problem...  (Read 518 times)

I believe i've found why the Firework Launcher doesn't work for most people, and so i've been trying to fix it, but have reached a bit of an impasse...

The console gives me this error when i exec it
Code: [Select]
==>exec("Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs");
Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs Line: 582 - Syntax error.
>>> Some error context, with ## on sides of error halt:
   echo("initialPosition:"@%initPos);

   echo("sourceObject:"@%obj);

   echo("sourceSlot:"@%slot);

   echo("client:"@%obj.client);

 echo(%projectile);

   %projectile.schedule(4000,MakeExplosion, %p, %projectile);

   %projectile.schedule(1000,MakeExplosion, %p);

}##
##


function fireworklauncherProjectile::MakeExplosion2(%this, %obj, %projectile) {   

if(isObject(%obj))

{

  %pos = %obj.getPosition();



  %p = new explosion() {       

         dataBlock = fireworklauncherExplosion;         

         position = %pos;   };
>>> Error report complete.

Executing Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs.
Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs Line: 582 - Syntax error.
>>> Some error context, with ## on sides of error halt:
   echo("initialPosition:"@%initPos);

   echo("sourceObject:"@%obj);

   echo("sourceSlot:"@%slot);

   echo("client:"@%obj.client);

 echo(%projectile);

   %projectile.schedule(4000,MakeExplosion, %p, %projectile);

   %projectile.schedule(1000,MakeExplosion, %p);

}##
##


function fireworklauncherProjectile::MakeExplosion2(%this, %obj, %projectile) {   

if(isObject(%obj))

{

  %pos = %obj.getPosition();



  %p = new explosion() {       

         dataBlock = fireworklauncherExplosion;         

         position = %pos;   };
>>> Error report complete.

Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs (0): Unable to find object: '' attempting to call function 'getMuzzlePoint'
Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs (0): Unable to find object: '' attempting to call function 'getMuzzleVector'
Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs (0): Unable to find object: '' attempting to call function 'getVelocity'
Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs (0): Unable to instantiate non-conobject class .
Set::add: Object "0" doesn't exist
Projectile Type:
dataBlock:
initialVelocity:0 0 0
initialPosition:
sourceObject:
sourceSlot:
client:

Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs (0): Unable to find object: '' attempting to call function 'schedule'
Add-Ons/Weapon_Firework_Launcher/Weapon_Firework_Launcher.cs (0): Unable to find object: '' attempting to call function 'schedule'

How do i fix this...? The Firework Launcher needs to do those MakeExplosion scripts so the projectiles can explode in mid-air :(

If i remember correctly, i got most of this script from the RTB 1.x FWRockets, so i guess there would be trouble with the scripts...

If you're wondering why the .cs is called Weapon_Firework_Launcher.cs, it's cause the server.cs has the script that requires the Rocket Launcher on so it can work
« Last Edit: June 03, 2009, 04:15:38 AM by Masterlegodude »

Code: [Select]
  %projectile = %this.projectile;
  %initPos = %obj.getMuzzlePoint(%slot);
  %muzzleVector = %obj.getMuzzleVector(%slot);
  %objectVelocity = %obj.getVelocity();
  %muzzleVelocity = VectorAdd(VectorScale(%muzzleVector, %projectile.muzzleVelocity),VectorScale(%objectVelocity, 
%projectile.velInheritFactor));
  %p = new (%this.projectileType)() 
   {
          dataBlock        = %projectile;
          initialVelocity  = %muzzleVelocity;
          initialPosition  = %initPos;
          sourceObject     = %obj;
          sourceSlot       = %slot;
          client           = %obj.client;
     };
     MissionCleanup.add(%p);
   echo("Projectile Type:"@%this.ProjectileType);
   echo("dataBlock:"@%projectile);
   echo("initialVelocity:"@%muzzleVelocity);
   echo("initialPosition:"@%initPos);
   echo("sourceObject:"@%obj);
   echo("sourceSlot:"@%slot);
   echo("client:"@%obj.client);
 echo(%projectile);
   %projectile.schedule(4000,MakeExplosion, %p, %projectile);
   %projectile.schedule(1000,MakeExplosion, %p);
}

This is just sitting in the script, not in a function at all. The last bracket is causing a syntax error, but you need to gut this script and stitch it into the onfire function just above it.

This is just sitting in the script, not in a function at all. The last bracket is causing a syntax error, but you need to gut this script and stitch it into the onfire function just above it.
Code: [Select]
   // Initial start up state
stateName[0]                     = "Activate";
stateTimeoutValue[0]             = 0.1;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateAllowImageChange[1]         = true;
   stateTransitionOnNoAmmo[1]       = "NoAmmo";
stateSequence[1] = "Ready";

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.1;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = fireworklauncherFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "tailNode";
stateSound[2] = fireworklauncherFireSound;
   stateSequence[2]                = "Fire";
//stateEjectShell[2]       = true;

stateName[3] = "Smoke";
stateEmitter[3] = fireworklauncherSmokeEmitter;
stateEmitterTime[3] = 0.05;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0.1;
   stateSequence[3]                = "TrigDown";
stateTransitionOnTimeout[3]     = "Reload";

   //stateName[5] = "CoolDown";
   //stateTimeoutValue[5]            = 0.5;
//stateTransitionOnTimeout[5]     = "Reload";
   //stateSequence[5]                = "TrigDown";


stateName[4] = "Reload";
stateAllowImageChange[4]        = false;
stateTimeoutValue[4]            = 0.3;
stateWaitForTimeout[4] = true;
stateTransitionOnTimeout[4]     = "Check";
//stateTransitionOnTriggerUp[4]     = "Ready";
stateSequence[4] = "TrigDown";

stateName[5] = "Check";
stateTransitionOnTriggerUp[5] = "StopFire";
stateTransitionOnTriggerDown[5] = "Ready";

stateName[6]                    = "StopFire";
stateTransitionOnTimeout[6]     = "Ready";
stateTimeoutValue[6]            = 0.5;
stateAllowImageChange[6]        = false;
stateWaitForTimeout[6]     = true;
//stateSequence[6]                = "Reload";
stateScript[6]                  = "onStopFire";

   stateName[7]   = "NoAmmo";
   stateTransitionOnAmmo[7] = "Ready";

};

function fireworklauncherImage::onFire(%this, %obj, %slot)
{
%projectile = %this.projectile;
%spread = 0.0015;
%shellcount = 6;

for(%shell=0; %shell<%shellcount; %shell++)
{
%vector = %obj.getMuzzleVector(%slot);
%objectVelocity = %obj.getVelocity();
%vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
%vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
%velocity = VectorAdd(%vector1,%vector2);
%x = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%y = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%z = (getRandom() - 0.5) * 10 * 3.1415926 * %spread;
%mat = MatrixCreateFromEuler(%x @ " " @ %y @ " " @ %z);
%velocity = MatrixMulVector(%mat, %velocity);

%p = new (%this.projectileType)()
{
dataBlock = %projectile;
initialVelocity = %velocity;
initialPosition = %obj.getMuzzlePoint(%slot);
sourceObject = %obj;
sourceSlot = %slot;
client = %obj.client;
};
MissionCleanup.add(%p);
}
return %p;
}

// Parent::onFire(%this, %obj, %slot);

  %projectile = %this.projectile;
  %initPos = %obj.getMuzzlePoint(%slot);
  %muzzleVector = %obj.getMuzzleVector(%slot);
  %objectVelocity = %obj.getVelocity();
  %muzzleVelocity = VectorAdd(VectorScale(%muzzleVector, %projectile.muzzleVelocity),VectorScale(%objectVelocity, 
%projectile.velInheritFactor));
  %p = new (%this.projectileType)() 
   {
          dataBlock        = %projectile;
          initialVelocity  = %muzzleVelocity;
          initialPosition  = %initPos;
          sourceObject     = %obj;
          sourceSlot       = %slot;
          client           = %obj.client;
     };
     MissionCleanup.add(%p);
   echo("Projectile Type:"@%this.ProjectileType);
   echo("dataBlock:"@%projectile);
   echo("initialVelocity:"@%muzzleVelocity);
   echo("initialPosition:"@%initPos);
   echo("sourceObject:"@%obj);
   echo("sourceSlot:"@%slot);
   echo("client:"@%obj.client);
 echo(%projectile);
   %projectile.schedule(4000,MakeExplosion, %p, %projectile);
   %projectile.schedule(1000,MakeExplosion, %p);
}

function fireworklauncherProjectile::MakeExplosion2(%this, %obj, %projectile) {   
if(isObject(%obj))
{
  %pos = %obj.getPosition();

  %p = new explosion() {       
         dataBlock = fireworklauncherExplosion;         
         position = %pos;   };


}

function fireworklauncherProjectile::MakeExplosion(%this, %obj, %projectile) {   
if(isObject(%obj))
{
  %pos = %obj.getPosition();
  %obj.delete();
  %p = new explosion() {       
         dataBlock = fireworklauncherExplosion;         
         position = %pos;   };
  // %projectile.schedule(500,MakeExplosion, %obj, %projectile);

}

How? ._.;

Wouldn't it just be easier to set lifetime for a projectile and make it explode and spawn particles when the lifetime runs out?