Game Development Community

Flaming Sword

by Michael "Triskal" Collins · in General Discussion · 03/06/2004 (5:51 am) · 2 replies

Hi im trying to make a flaming sword for a little mod, and this is the code i have so far, but its not working, could someone tell me whats wrong?

function SwordImage::onMount(%pos,%obj,%slot) 
{ 
      %obj.setImageAmmo(%slot,true); 
       %p = new ParticleEmitterNode() { 
       position = %pos; 
       emitter = "SwordFlameEmitter"; 
       dataBlock        = ChimneySmokeEmitterNode; 
   }; 
   MissionCleanup.add(%p); 
     %obj.mountobject(%p,%slot); 
 
} 
 
function swordimage::onunmount(%obj,%slot)
{ 
     %obj.getobjectmount(%slot).delete(); 
} 

datablock ItemData(Sword)
{
   // Mission editor category
   category = "Weapon";

   // Hook into Item Weapon class hierarchy. The weapon namespace
   // provides common weapon handling functions in addition to hooks
   // into the inventory system.
   className = "Weapon";

   // Basic Item properties
   shapeFile = "~/data/shapes/sword/rune_blade01.dts";
   mass = 1;
   elasticity = 0.2;
   friction = 0.6;
   emap = true;

	// Dynamic properties defined by the scripts
	pickUpName = "a sword";
	image = SwordImage;
};


//--------------------------------------------------------------------------
// "Flame data"
 
datablock ParticleData(SwordFlameParticle) 
{ 
   dragCoefficient      = 1.0; 
   gravityCoefficient   = -2.0; 
   inheritedVelFactor   = 0; 
   constantAcceleration = 0.0; 
   lifetimeMS           = 300; 
   lifetimeVarianceMS   =  50; 
   textureName          = "~/data/shapes/particles/smoke"; 
   times[0]=0.0; 
   times[1]=1.0; 
 
   colors[0]     = "1.5 0.45 0.0 1.0"; 
   colors[1]     = "1.5 0.3 0.0 1.0"; 
   sizes[0]      = 0.1; 
   sizes[1]      = 0.1; 
}; 
 
datablock ParticleEmitterData(SwordFlameEmitter) 
{ 
   ejectionPeriodMS = 1; 
   periodVarianceMS = 0; 
   ejectionVelocity = 6.0; 
   velocityVariance = 2.0; 
   ejectionOffset   = 0.5; 
   thetaMin         = 0; 
   thetaMax         = 0; 
   phiReferenceVel  = 0; 
   phiVariance      = 0; 
   overrideAdvances = false; 
   particles = SwordFlameParticle; 
};

#1
03/06/2004 (6:12 am)
I take it your Sword has a node named "SwordFlameEmitter" built into it?
#2
10/08/2004 (10:32 am)
This doesn't seems to work... :(