Author Topic: Spawn projectile wont work and explosion wont spawn?  (Read 765 times)

This is what it is supposed to do:
On impact, SmashProjectile spawns.
But the projectile wont spawn...
The Code:
Code: [Select]
package what
{
        function Armor::onImpact(%this,%obj,%col,%pos,%speed)
        {
                new Projectile()
                {
                        dataBlock = smashprojectile;
                        initialPosition = %pos;
                        initialVelocity = "0 0 1";
                        sourceObject = "";
                        client = "";
                        sourceSlot = 0;
                        originPoint = %pos;
                };
                Parent::onImpact(%this,%obj,%col,%pos,%speed);
        }
};
activatePackage(what);


Explosion wont spawn?
Upon smashprojectile exploding, a puff of dust is supposed to form, but it dosent.
The Code:

Code: [Select]
datablock ParticleData(SmashExplosionParticle)
{
   dragCoefficient      = 8;
   gravityCoefficient   = -5;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 700;
   lifetimeVarianceMS   = 300;
   textureName          = "base/data/particles/cloud";
   spinSpeed = 10.0;
   spinRandomMin = -50.0;
   spinRandomMax = 50.0;
   colors[0]     = "1.0 1.0 1.0 1.0";
   colors[1]     = "1.0 1.0 1.0 1.0";
   colors[2]     = "1.0 1.0 1.0 1.0";

   sizes[0]      = 8.0;
   sizes[1]      = 15.0;
   sizes[2]      = 12.0;

   times[0] = 0.0;
   times[1] = 0.4;
   times[2] = 1.0;

   useInvAlpha = true;
};
datablock ParticleEmitterData(SmashExplosionEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 15;
   velocityVariance = 1.0;
   ejectionOffset   = 3.0;
   thetaMin         = 89;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "SmashExplosionParticle";
};

datablock ParticleData(SmashExplosionRingParticle)
{
   dragCoefficient      = 8;
   gravityCoefficient   = -0.5;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 40;
   lifetimeVarianceMS   = 10;
   textureName          = "base/data/particles/star1";
   spinSpeed = 10.0;
   spinRandomMin = -500.0;
   spinRandomMax = 500.0;
   colors[0]     = "1 0.5 0.0 0.5";
   colors[1]     = "0.9 0.0 0.0 0.0";
   sizes[0]      = 8;
   sizes[1]      = 13;

   useInvAlpha = false;
};


datablock ExplosionData(SmashExplosion)
{
   //explosionShape = "";
   explosionShape = "";
soundProfile = smashExplodeSound;

   lifeTimeMS = 150;

   particleEmitter = SmashExplosionEmitter;
   particleDensity = 10;
   particleRadius = 0.2;

   emitter[0] = SmashExplosionRingEmitter;

   faceViewer     = true;
   explosionScale = "1 1 1";

   shakeCamera = false;
   camShakeFreq = "10.0 11.0 10.0";
   camShakeAmp = "3.0 10.0 3.0";
   camShakeDuration = 0.5;
   camShakeRadius = 20.0;

   // Dynamic light
   //lightStartRadius = 5;
   //lightEndRadius = 20;
   //lightStartColor = "1 1 1 1";
   //lightEndColor = "0 0 0 0";

   damageRadius = 30;
   radiusDamage = 500;

   impulseRadius = 40;
   impulseForce = 16000;
};

/////////////////
//  Projectile //
/////////////////
if(!$DamageType::RocketDirect)
   AddDamageType("RocketDirect",   '<bitmap:add-ons/Projectile_Smash/rocket> %1',    '%2 <bitmap:add-ons/Projectile_Smash/rocket> %1',1,1);
if(!$DamageType::RocketRadius)
   AddDamageType("RocketRadius",   '<bitmap:add-ons/Projectile_Smash/rocketRadius> %1',    '%2 <bitmap:add-ons/Projectile_Smash/rocketRadius> %1',1,0);
datablock ProjectileData(SmashProjectile)
{
   projectileShapeName = "./RocketGravityProjectile.dts";
   directDamage        = 1000;
   directDamageType = $DamageType::RocketDirect;
   radiusDamageType = $DamageType::RocketRadius;
   impactImpulse    = 1000;
   verticalImpulse    = 1000;
   explosion           = SmashExplosion;
   particleEmitter     = rocketTrailEmitter;
   explodeOnDeath = 1;

   brickExplosionRadius = 3;
   brickExplosionImpact = false;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 30;             
   brickExplosionMaxVolume = 30;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloating = 60;  //max volume of bricks that we can destroy if they aren't connected to the ground (should always be >= brickExplosionMaxVolume)

   sound = rocketLoopSound;

   muzzleVelocity      = 65;
   velInheritFactor    = 1.0;

   armingDelay         = 00;
   lifetime            = 0;
   fadeDelay           = 11500;
   bounceElasticity    = 0.5;
   bounceFriction      = 0.20;
   isBallistic         = true;
   gravityMod = 0.0;

   uiName = "Smash"; //naming it this way so it's next to the rocket in the alphabetized list
};




Don't bumb every hour, and on the new Projectile() don't you need to add the Projectile Name?
new Projectile(Name) or $Name = new Projectile() i believe;
And isn't it ProjectileData?

on the new Projectile() don't you need to add the Projectile Name?
No, you don't. You just won't have a handle for it in order to do stuff to it later (if you choose to).
It is not a bad idea however to add projectiles to the missionCleanup group, however since this projectile has a lifetime of 0, I don't see why it would be necessary.

And isn't it ProjectileData?
projectileData for projectile datablocks
projectile for projectiles
yogurt has it right.