Author Topic: Secondary Fire  (Read 2679 times)

The problem was, the armor class doesn't have a projectileType.

Still not working? here is the whole code if it helps


Code: [Select]
datablock ParticleData(flamerParticle)
{
dragCoefficient      = 2.9;
gravityCoefficient   = 0.1;
inheritedVelFactor   = 1.0;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 75;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.000000 0.000000 1.000000 1.000000";
colors[1]     = "1.000000 0.496063 0.000000 0.000000";
    colors[2]     = "1.000000 1.000000 1.000000 1.000000";
    colors[3]     = "1.000000 1.000000 1.000000 1.000000";

sizes[0]      = 0.0946103;
sizes[1]      = 0.897272;
  sizes[2]      = 1;
  sizes[3]      = 1;

    times[0] = 0;
    times[1] = 1;
    times[2] = 2;
  times[3] = 2;

useInvAlpha = false;
};

datablock ParticleEmitterData(flamerEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 20;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   orientOnVelocity = true;
   particles = "flamerParticle";
};

datablock ParticleData(flamerGasParticle)
{
dragCoefficient      = 0.0;
gravityCoefficient   = -1;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 100;
lifetimeVarianceMS   = 75;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.000000 0.000000 1.000000 0.500000";
colors[1]     = "0.000000 0.496063 1.000000 0.000000";

sizes[0]      = 0.04;
sizes[1]      = 0.01;

    times[0] = 0;
    times[1] = 1;

useInvAlpha = false;
};

datablock ParticleEmitterData(flamerGasEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   orientOnVelocity = true;
   particles = "flamerGasParticle";
};


datablock ParticleData(flamerExplosionParticle)
{
dragCoefficient      = 2;
gravityCoefficient   = 0.0;
windCoefficient    = 1;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 600;
lifetimeVarianceMS   = 200;
textureName          = "base/data/particles/cloud";
spinSpeed = 100.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "1.000000 0.496063 0.000000 0.496063";
colors[1]     = "1.000000 0.496063 0.000000 0.000000";
colors[2]     = "1.000000 1.000000 1.000000 1.000000";
colors[3]     = "1.000000 1.000000 1.000000 1.000000";
sizes[0]      = 0.799609;
sizes[1]      = 1.19636;
sizes[2]      = 1;
sizes[3]      = 1;
times[0]   = 0;
times[1]   = 1;
times[2]   = 2;
times[3]   = 2;

useInvAlpha = false;
};
datablock ParticleEmitterData(flamerExplosionEmitter)
{
   ejectionPeriodMS = 40;
   periodVarianceMS = 0;
   ejectionVelocity = 3.5;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 35;
   thetaMax         = 85;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   orientOnVelocity = true;
   particles = "flamerExplosionParticle";
};

datablock ExplosionData(flamerExplosion)
{
   lifeTimeMS = 128;

   particleEmitter = flamerExplosionEmitter;
   particleDensity = 10;
   particleRadius = 1;
   explosionScale = "1 1 1";
};


AddDamageType("flamerDirect",   '<bitmap:add-ons/ci/flamer> %1',    '%2 <bitmap:add-ons/ci/flamer> %1',1,1);
datablock ProjectileData(flamerProjectile)
{
   directDamage        = 12;
   directDamageType = $DamageType::flamerDirect;
   explosion           = flamerExplosion;

   muzzleVelocity      = 25;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 300;
   fadeDelay           = 0;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;
};

datablock ProjectileData(flamerAirProjectile)
{
   directDamage        = 0;
   directDamageType = $DamageType::flamerDirect;
   explosion           = flamerExplosion;
   particleEmitter     = flamerEmitter;
   

   muzzleVelocity      =50;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 500;
   fadeDelay           = 0;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;
};


//////////
// item //
//////////
datablock ItemData(flamerItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./flamer.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "flamer";
iconName = "./ItemIcons/flamer";
doColorShift = true;
colorShiftColor = "0.15 0.15 0.15 1.000";

// Dynamic properties defined by the scripts
image = FlamerImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(FlamerImage)
{
   // Basic Item properties
   shapeFile = "./Flamer.dts";
   emap = true;

   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0;
   rotation = "1 0 0 0";
   correctMuzzleVector = true;
   className = "WeaponImage";

   // Projectile && Ammo.
   item = flamerItem;
   ammo = " ";
   projectile = flamerProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;

   doRetraction = false;

   doColorShift = true;
   colorShiftColor = flamerItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTransitionOnTriggerDown[0]  = "Fire";
stateAllowImageChange[0]    = true;
stateSound[0]    = sprayActivateSound;
stateTransitionOnTimeout[0]    = "Ready";
stateTimeoutValue[0]    = 0.01;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateTimeoutValue[1]    = 0.04;
stateTransitionOnTimeout[1]    = "Ready";
stateWaitForTimeout[1]    = true;
stateAllowImageChange[1]    = true;
stateEmitter[1]    = flamerGasEmitter;
stateEmitterTime[1]    = 0.07;

stateName[2]                     = "Fire";
stateTransitionOnTriggerUp[2]    = "StopFire";
stateTransitionOnTimeout[2]    = "Fire";
stateTimeoutValue[2]    = 0.04;
stateWaitForTimeout[2]    = true;
stateFire[2]    = true;
stateAllowImageChange[2]    = true;
stateSound[2]    = sprayFireSound;
stateScript[2]    = "onFire";
stateEmitter[2]    = flamerEmitter;
stateEmitterTime[2]    = 0.07;
stateSequence[2]    = "fire";

stateName[3]    = "StopFire";
stateTransitionOnTimeout[3]    = "Ready";
stateWaitForTimeout[3]    = true;
stateAllowImageChange[3]    = true;
stateSequence[3]    = "stopfire";
};

package flameraltFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= FlamerImage.getID() && %slot $= 4)
      {
         if(%val)
         {
             
       %projectile = flamerAirProjectile;
     %vector = %obj.getMuzzleVector(%slot);
     %objectVelocity = %obj.getVelocity();
     %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
     %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
     %velocity = VectorAdd(%vector1,%vector2);
     %p = new Projectile()
     {
      dataBlock = %projectile;
      initialVelocity = %velocity;
      initialPosition = %obj.getMuzzlePoint(%slot);
      sourceObject = %obj;
      sourceSlot = %slot;
      client = %obj.client;
     };
     MissionCleanup.add(%p);
        return %p;
         }
      }
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(flameraltFire);

The Tank vehicle in your console log executes after your weapon, since the Portal Gun is enabled and that is required. A problem in the Tank's packaging causes it to block all triggers apart from Slot 0/Fire. (when you need Slot 4/Fire for jet trigger)

Try using this code from the Gravity Gun, as I used it to make the tank execute first to fix this problem: (I have been told that the problem will be fixed in v10, though)

Code: [Select]
%error = ForceRequiredAddOn("Vehicle_Tank");

if(%error == $Error::AddOn_Disabled)
{
 TankVehicle.uiName = "";
 tankShellProjectile.uiName = "";
}
else if(%error == $Error::AddOn_NotFound)
{
 error("Weapon_Flamer - required Add-On Vehicle_Tank not found");
 return;
}

(It originally said "Weapon_GravityGun - required Add-On...")

Place it at the top of server.cs, before executing the weapon code. This will make the Tank execute first, fixing the packages problem, and remove the Tank/Tank Shell from the Vehicle and Projectile menus if it is disabled.

ok i did that, but now whenever i press right click this comes up in the console:

Code: [Select]
Add-Ons/Weapon_TF2flamer/weapon_Flamer.cs (299): Unable to find object: '' attempting to call function 'getMuzzleVector'
Add-Ons/Weapon_TF2flamer/weapon_Flamer.cs (300): Unable to find object: '' attempting to call function 'getVelocity'
Add-Ons/Weapon_TF2flamer/weapon_Flamer.cs (312): Unable to find object: '' attempting to call function 'getMuzzlePoint'

The Tank vehicle in your console log executes after your weapon, since the Portal Gun is enabled and that is required. A problem in the Tank's packaging causes it to block all triggers apart from Slot 0/Fire. (when you need Slot 4/Fire for jet trigger)

Try using this code from the Gravity Gun, as I used it to make the tank execute first to fix this problem: (I have been told that the problem will be fixed in v10, though)

Code: [Select]
%error = ForceRequiredAddOn("Vehicle_Tank");

if(%error == $Error::AddOn_Disabled)
{
 TankVehicle.uiName = "";
 tankShellProjectile.uiName = "";
}
else if(%error == $Error::AddOn_NotFound)
{
 error("Weapon_Flamer - required Add-On Vehicle_Tank not found");
 return;
}

(It originally said "Weapon_GravityGun - required Add-On...")

Place it at the top of server.cs, before executing the weapon code. This will make the Tank execute first, fixing the packages problem, and remove the Tank/Tank Shell from the Vehicle and Projectile menus if it is disabled.

So that's why when I deactivated the tank, my guns with secondary fire functions work well.

ok i did that, but now whenever i press right click this comes up in the console:

Code: [Select]
Add-Ons/Weapon_TF2flamer/weapon_Flamer.cs (299): Unable to find object: '' attempting to call function 'getMuzzleVector'
Add-Ons/Weapon_TF2flamer/weapon_Flamer.cs (300): Unable to find object: '' attempting to call function 'getVelocity'
Add-Ons/Weapon_TF2flamer/weapon_Flamer.cs (312): Unable to find object: '' attempting to call function 'getMuzzlePoint'
If you look at the lines it says (299, 300, 312) you have "%obj.getMuzzleVector()", "%obj.getVelocity()", etc.

Change these to "%player.getMuzzleVector()", "%player.getVelocity()", etc.

ok, there is now no console errors, but it still does absolutly nothing when i right click, the full code looks like this:


Code: [Select]
datablock ParticleData(flamerParticle)
{
dragCoefficient      = 2.9;
gravityCoefficient   = 0.1;
inheritedVelFactor   = 1.0;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 75;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.000000 0.000000 1.000000 1.000000";
colors[1]     = "1.000000 0.496063 0.000000 0.000000";
    colors[2]     = "1.000000 1.000000 1.000000 1.000000";
    colors[3]     = "1.000000 1.000000 1.000000 1.000000";

sizes[0]      = 0.0946103;
sizes[1]      = 0.897272;
  sizes[2]      = 1;
  sizes[3]      = 1;

    times[0] = 0;
    times[1] = 1;
    times[2] = 2;
  times[3] = 2;

useInvAlpha = false;
};

datablock ParticleEmitterData(flamerEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 20;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   orientOnVelocity = true;
   particles = "flamerParticle";
};

datablock ParticleData(flamerGasParticle)
{
dragCoefficient      = 0.0;
gravityCoefficient   = -1;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 100;
lifetimeVarianceMS   = 75;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.000000 0.000000 1.000000 0.500000";
colors[1]     = "0.000000 0.496063 1.000000 0.000000";

sizes[0]      = 0.04;
sizes[1]      = 0.01;

    times[0] = 0;
    times[1] = 1;

useInvAlpha = false;
};

datablock ParticleEmitterData(flamerGasEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   orientOnVelocity = true;
   particles = "flamerGasParticle";
};


datablock ParticleData(flamerExplosionParticle)
{
dragCoefficient      = 2;
gravityCoefficient   = 0.0;
windCoefficient    = 1;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 600;
lifetimeVarianceMS   = 200;
textureName          = "base/data/particles/cloud";
spinSpeed = 100.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "1.000000 0.496063 0.000000 0.496063";
colors[1]     = "1.000000 0.496063 0.000000 0.000000";
colors[2]     = "1.000000 1.000000 1.000000 1.000000";
colors[3]     = "1.000000 1.000000 1.000000 1.000000";
sizes[0]      = 0.799609;
sizes[1]      = 1.19636;
sizes[2]      = 1;
sizes[3]      = 1;
times[0]   = 0;
times[1]   = 1;
times[2]   = 2;
times[3]   = 2;

useInvAlpha = false;
};
datablock ParticleEmitterData(flamerExplosionEmitter)
{
   ejectionPeriodMS = 40;
   periodVarianceMS = 0;
   ejectionVelocity = 3.5;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 35;
   thetaMax         = 85;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   orientOnVelocity = true;
   particles = "flamerExplosionParticle";
};

datablock ExplosionData(flamerExplosion)
{
   lifeTimeMS = 128;

   particleEmitter = flamerExplosionEmitter;
   particleDensity = 10;
   particleRadius = 1;
   explosionScale = "1 1 1";
};


AddDamageType("flamerDirect",   '<bitmap:add-ons/ci/flamer> %1',    '%2 <bitmap:add-ons/ci/flamer> %1',1,1);
datablock ProjectileData(flamerProjectile)
{
   directDamage        = 12;
   directDamageType = $DamageType::flamerDirect;
   explosion           = flamerExplosion;

   muzzleVelocity      = 25;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 300;
   fadeDelay           = 0;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;
};

datablock ProjectileData(flamerAirProjectile)
{
   directDamage        = 0;
   directDamageType = $DamageType::flamerDirect;
   explosion           = flamerExplosion;
   particleEmitter     = flamerEmitter;
   

   muzzleVelocity      =50;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 500;
   fadeDelay           = 0;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;
};


//////////
// item //
//////////
datablock ItemData(flamerItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./flamer.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "flamer";
iconName = "./ItemIcons/flamer";
doColorShift = true;
colorShiftColor = "0.15 0.15 0.15 1.000";

// Dynamic properties defined by the scripts
image = FlamerImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(FlamerImage)
{
   // Basic Item properties
   shapeFile = "./Flamer.dts";
   emap = true;

   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0;
   rotation = "1 0 0 0";
   correctMuzzleVector = true;
   className = "WeaponImage";

   // Projectile && Ammo.
   item = flamerItem;
   ammo = " ";
   projectile = flamerProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;

   doRetraction = false;

   doColorShift = true;
   colorShiftColor = flamerItem.colorShiftColor;//"0.400 0.196 0 1.000";

   //casing = " ";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTransitionOnTriggerDown[0]  = "Fire";
stateAllowImageChange[0]    = true;
stateSound[0]    = sprayActivateSound;
stateTransitionOnTimeout[0]    = "Ready";
stateTimeoutValue[0]    = 0.01;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateTimeoutValue[1]    = 0.04;
stateTransitionOnTimeout[1]    = "Ready";
stateWaitForTimeout[1]    = true;
stateAllowImageChange[1]    = true;
stateEmitter[1]    = flamerGasEmitter;
stateEmitterTime[1]    = 0.07;

stateName[2]                     = "Fire";
stateTransitionOnTriggerUp[2]    = "StopFire";
stateTransitionOnTimeout[2]    = "Fire";
stateTimeoutValue[2]    = 0.04;
stateWaitForTimeout[2]    = true;
stateFire[2]    = true;
stateAllowImageChange[2]    = true;
stateSound[2]    = sprayFireSound;
stateScript[2]    = "onFire";
stateEmitter[2]    = flamerEmitter;
stateEmitterTime[2]    = 0.07;
stateSequence[2]    = "fire";

stateName[3]    = "StopFire";
stateTransitionOnTimeout[3]    = "Ready";
stateWaitForTimeout[3]    = true;
stateAllowImageChange[3]    = true;
stateSequence[3]    = "stopfire";
};

package flameraltFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= FlamerImage.getID() && %slot $= 4)
      {
         if(%val)
         {
             
       %projectile = flamerProjectile;
     %vector = %player.getMuzzleVector(%slot);
     %objectVelocity = %player.getVelocity();
     %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
     %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
     %velocity = VectorAdd(%vector1,%vector2);
     %p = new Projectile()
     {
      dataBlock = %projectile;
      initialVelocity = %velocity;
      initialPosition = %player.getMuzzlePoint(%slot);
      sourceObject = %obj;
      sourceSlot = %slot;
      client = %obj.client;
     };
     MissionCleanup.add(%p);
        return %p;
         }
      }
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(flameraltFire);

Did you add the code I mentioned to server.cs?

ok, there is now no console errors, but it still does absolutly nothing when i right click, the full code looks like this:

Turn off Tank or any other vehicle that uses a turret.

If he's going to be releasing this, I suggest he adds the fix rather than forcing people to disable other Add-Ons they may want to use.

yes, i did add that code

Anyone know the answer? i really need this.

ok i know i have bumped a few times now but i need an answer, after a trace i found that it knows i am pressing right click, but still nothing comes out, Whats wrong?


Code: [Select]
datablock ParticleData(flamerParticle)
{
dragCoefficient      = 2.9;
gravityCoefficient   = 0.1;
inheritedVelFactor   = 1.0;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 75;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.000000 0.000000 1.000000 1.000000";
colors[1]     = "1.000000 0.496063 0.000000 0.000000";
    colors[2]     = "1.000000 1.000000 1.000000 1.000000";
    colors[3]     = "1.000000 1.000000 1.000000 1.000000";

sizes[0]      = 0.0946103;
sizes[1]      = 0.897272;
  sizes[2]      = 1;
  sizes[3]      = 1;

    times[0] = 0;
    times[1] = 1;
    times[2] = 2;
  times[3] = 2;

useInvAlpha = false;
};

datablock ParticleEmitterData(flamerEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 20;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   orientOnVelocity = true;
   particles = "flamerParticle";
};

datablock ParticleData(flamerairParticle)
{
dragCoefficient      = 2.9;
gravityCoefficient   = 0.1;
inheritedVelFactor   = 1.0;
constantAcceleration = 0.0;
lifetimeMS           = 700;
lifetimeVarianceMS   = 75;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "1 1 1 1.000000";
colors[1]     = "1 1 1 1.000000";


sizes[0]      = 0.0946103;
sizes[1]      = 0.897272;

    times[0] = 0;
    times[1] = 1;

useInvAlpha = false;
};

datablock ParticleEmitterData(flamerairEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 20;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   orientOnVelocity = true;
   particles = "flamerairParticle";
};

datablock ParticleData(flamerGasParticle)
{
dragCoefficient      = 0.0;
gravityCoefficient   = -1;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 100;
lifetimeVarianceMS   = 75;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0.000000 0.000000 1.000000 0.500000";
colors[1]     = "0.000000 0.496063 1.000000 0.000000";

sizes[0]      = 0.04;
sizes[1]      = 0.01;

    times[0] = 0;
    times[1] = 1;

useInvAlpha = false;
};

datablock ParticleEmitterData(flamerGasEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 5;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   orientOnVelocity = true;
   particles = "flamerGasParticle";
};


datablock ParticleData(flamerExplosionParticle)
{
dragCoefficient      = 2;
gravityCoefficient   = 0.0;
windCoefficient    = 1;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 600;
lifetimeVarianceMS   = 200;
textureName          = "base/data/particles/cloud";
spinSpeed = 100.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "1.000000 0.496063 0.000000 0.496063";
colors[1]     = "1.000000 0.496063 0.000000 0.000000";
colors[2]     = "1.000000 1.000000 1.000000 1.000000";
colors[3]     = "1.000000 1.000000 1.000000 1.000000";
sizes[0]      = 0.799609;
sizes[1]      = 1.19636;
sizes[2]      = 1;
sizes[3]      = 1;
times[0]   = 0;
times[1]   = 1;
times[2]   = 2;
times[3]   = 2;

useInvAlpha = false;
};
datablock ParticleEmitterData(flamerExplosionEmitter)
{
   ejectionPeriodMS = 40;
   periodVarianceMS = 0;
   ejectionVelocity = 3.5;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 35;
   thetaMax         = 85;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   orientOnVelocity = true;
   particles = "flamerExplosionParticle";
};

datablock ExplosionData(flamerExplosion)
{
   lifeTimeMS = 128;

   particleEmitter = flamerExplosionEmitter;
   particleDensity = 10;
   particleRadius = 1;
   explosionScale = "1 1 1";
};


AddDamageType("flamerDirect",   '<bitmap:./CI_flamerkill> %1',    '%2 <bitmap:./CI_flamerkill> %1',1,1);
datablock ProjectileData(flamerProjectile)
{
   directDamage        = 12;
   directDamageType = $DamageType::flamerDirect;
   explosion           = flamerExplosion;

   muzzleVelocity      = 25;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 300;
   fadeDelay           = 0;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;
};

datablock ProjectileData(flamerAirProjectile)
{
   projectileShapeName = "add-ons/weapon_gun/bullet.dts";
   directDamage        = 0;
   directDamageType = $DamageType::flamerDirect;
   explosion           = flamerExplosion;
   particleEmitter     = flamerairEmitter;
   

   muzzleVelocity      =100;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 2000;
   fadeDelay           = 2000;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;
};


//////////
// item //
//////////
datablock ItemData(flamerItem)
{
category = "Weapon";  // Mission editor category
className = "Weapon"; // For inventory system

// Basic Item Properties
shapeFile = "./flamer.dts";
rotate = false;
mass = 1;
density = 0.2;
elasticity = 0.2;
friction = 0.6;
emap = true;

//gui stuff
uiName = "TF2 Flamethrower";
iconName = "./icon_flamer";
doColorShift = true;
colorShiftColor = "1 1 1 1.000";

// Dynamic properties defined by the scripts
image = FlamerImage;
canDrop = true;
};

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(FlamerImage)
{
   // Basic Item properties
   shapeFile = "./Flamer.dts";
   emap = true;

   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0;
   rotation = "1 0 0 0";
   correctMuzzleVector = true;
   className = "WeaponImage";

   // Projectile && Ammo.
   item = flamerItem;
   ammo = " ";
   projectile = flamerProjectile;
   projectileType = Projectile;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;

   doRetraction = false;

   doColorShift = true;
   colorShiftColor = "0.15 0.15 0.15 1.000";

   //casing = " ";

   // Images have a state system which controls how the animations
   // are run, which sounds are played, script callbacks, etc. This
   // state system is downloaded to the client so that clients can
   // predict state changes and animate accordingly.  The following
   // system supports basic ready->fire->reload transitions as
   // well as a no-ammo->dryfire idle state.

   // Initial start up state
stateName[0]                     = "Activate";
stateTransitionOnTriggerDown[0]  = "Fire";
stateAllowImageChange[0]    = true;
stateSound[0]    = sprayActivateSound;
stateTransitionOnTimeout[0]    = "Ready";
stateTimeoutValue[0]    = 0.01;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "Fire";
stateTimeoutValue[1]    = 0.04;
stateTransitionOnTimeout[1]    = "Ready";
stateWaitForTimeout[1]    = true;
stateAllowImageChange[1]    = true;
stateEmitter[1]    = flamerGasEmitter;
stateEmitterTime[1]    = 0.07;

stateName[2]                     = "Fire";
stateTransitionOnTriggerUp[2]    = "StopFire";
stateTransitionOnTimeout[2]    = "Fire";
stateTimeoutValue[2]    = 0.04;
stateWaitForTimeout[2]    = true;
stateFire[2]    = true;
stateAllowImageChange[2]    = true;
stateSound[2]    = sprayFireSound;
stateScript[2]    = "onFire";
stateEmitter[2]    = flamerEmitter;
stateEmitterTime[2]    = 0.07;
stateSequence[2]    = "fire";

stateName[3]    = "StopFire";
stateTransitionOnTimeout[3]    = "Ready";
stateWaitForTimeout[3]    = true;
stateAllowImageChange[3]    = true;
stateSequence[3]    = "stopfire";
};


package flameraltFire
{
   function armor::onTrigger(%this, %player, %slot, %val)
   {
      if(%player.getMountedImage(0) $= FlamerImage.getID() && %slot $= 4)
         {
             
       %projectile = flamerAirProjectile;
     %vector = %player.getMuzzleVector(%slot);
     %objectVelocity = %player.getVelocity();
     %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
     %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
     %velocity = VectorAdd(%vector1,%vector2);
     %p = new Projectile()
     {
      dataBlock = %projectile;
      initialVelocity = %velocity;
      initialPosition = %player.getMuzzlePoint(%slot);
      sourceObject = %player;
      sourceSlot = %slot;
      client = %player.client;
     };
     MissionCleanup.add(%p);
        return %p;
         }
     
      parent::onTrigger(%this, %player, %slot, %val);
   }
};
activatePackage(flameraltFire);

The reason that it uses bullet is so I can see if it works

Change %player.getMuzzlePoint(%slot);
To %player.getMuzzlePoint(0);
And
sourceSlot = %slot;
to sourceSlot = 0;

ok that now fires, but there are 2 new problems: it fires 2, one when i press click down, and another when i take it off. The other problem is no matter where i face the bullets go north.Fixed that problem.
« Last Edit: October 07, 2008, 08:30:53 PM by Racer »