Author Topic: Key editing  (Read 688 times)

I edited the key script, and I changed the model to the sword. However, the animation is still the same as the key - It turns. Is there someway to make it use the same animation as the sword?

The key uses:
Code: [Select]
function keyImage::onFire(%this,%obj,%slot)
{
%obj.playThread(2, rotCW);
Parent::onFire(%this,%obj,%slot);
}
While the sword should use:
Code: [Select]
function swordImage::onPreFire(%this, %obj, %slot)
{
%obj.playthread(2, armattack);
}

function swordImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
}


Im trying to make the key look like and animate like the sword, while still having the functions of the key
Im messing up somewhere ):
Code: [Select]
//key.cs
//a key

//audio
datablock AudioProfile(keyJingleSound)
{
   filename    = "./keysjingle.wav";
   description = AudioClose3d;
   preload = true;
};
datablock AudioProfile(keyHitSound)
{
   filename    = "./swordHit.wav";
   description = AudioClose3d;
   preload = true;
};

//explosion
datablock ParticleData(keyExplosionParticle)
{
   dragCoefficient      = 10;
   gravityCoefficient   = -0.15;
   inheritedVelFactor   = 0.2;
   constantAcceleration = 0.0;
   lifetimeMS           = 800;
   lifetimeVarianceMS   = 500;
   textureName          = "base/data/particles/star1";

spinSpeed = 200.0;
spinRandomMin = 0.0;
spinRandomMax = 20.0;

   colors[0]     = "1.0 1.0 0.0 0.65";
   colors[1]     = "0.0 0.0 0.0 0";
   sizes[0]      = 0.1;
   sizes[1]      = 0.0;

   useInvAlpha = true;
};

datablock ParticleEmitterData(keyExplosionEmitter)
{
lifeTimeMS = 20;

   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 4;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 95;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = keyExplosionParticle;
};

datablock ExplosionData(keyExplosion)
{
   //explosionShape = "";
   lifeTimeMS = 700;

   //emitter[0] = pushBroomExplosionEmitter;
   //emitter[0] = pushBroomSparkEmitter;
   particleEmitter = keyExplosionEmitter;
   particleDensity = 30;
   particleRadius = 1.0;
   
   faceViewer     = true;
   explosionScale = "1 1 1";

   soundProfile = keyHitSound;

   
   shakeCamera = true;
   camShakeFreq = "20.0 22.0 20.0";
   camShakeAmp = "1.0 1.0 1.0";
   camShakeDuration = 0.5;
   camShakeRadius = 10.0;

   // Dynamic light
   lightStartRadius = 3;
   lightEndRadius = 0;
   lightStartColor = "1.0 1.0 0.0";
   lightEndColor = "0 0 0";
};

//projectile
datablock ProjectileData(keyProjectile)
{
   //projectileShapeName = "~/data/shapes/sword.dts";
   directDamage        = 0;
   impactImpulse       = 0;
   verticalImpulse     = 0;
   explosion           = keyExplosion;
   //particleEmitter = keyTrailEmitter;

   muzzleVelocity      = 50;
   velInheritFactor    = 1;

   armingDelay         = 0;
   lifetime            = 100;
   fadeDelay           = 70;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   isBallistic         = false;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";

//Disabled due to a glitch where the event doesn't check for permissions upon it firing from a brick.
// uiName = "Key";
};

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

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

//gui properties
uiName = "Sword_RPG";
iconName = "./icon_sword";
doColorShift = true;
colorShiftColor = "0.471 0.471 0.471 1.000";


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

//function pushBroom::onUse(%this,%user)
//{
// //mount the image in the right hand slot
// %user.mountimage(%this.image, $RightHandSlot);
//}

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

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";

   // When firing from a point offset from the eye, muzzle correction
   // will adjust the muzzle vector to point to the eye LOS point.
   // Since this weapon doesn't actually fire from the muzzle point,
   // we need to turn this off. 
   correctMuzzleVector = false;

   //eyeOffset = "0.7 1.2 -0.25";

   // Add the WeaponImage namespace as a parent, WeaponImage namespace
   // provides some hooks into the inventory system.
   className = "WeaponImage";

   // Projectile && Ammo.
   item = keyItem;
   ammo = " ";
   projectile = keyProjectile;
   projectileType = Projectile;

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

   //casing = " ";
   doColorShift = true;
   colorShiftColor = "0.471 0.471 0.471 1.000";

   // 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";
stateTimeoutValue[0]             = 0.5;
stateTransitionOnTimeout[0]      = "Ready";
stateSound[0]                    = swordDrawSound;

stateName[1]                     = "Ready";
stateTransitionOnTriggerDown[1]  = "PreFire";
stateAllowImageChange[1]         = true;

stateName[2] = "PreFire";
stateScript[2]                  = "onPreFire";
stateAllowImageChange[2]        = false;
stateTimeoutValue[2]            = 0.1;
stateTransitionOnTimeout[2]     = "Fire";

stateName[3]                    = "Fire";
stateTransitionOnTimeout[3]     = "CheckFire";
stateTimeoutValue[3]            = 0.2;
stateFire[3]                    = true;
stateAllowImageChange[3]        = false;
stateSequence[3]                = "Fire";
stateScript[3]                  = "onFire";
stateWaitForTimeout[3] = true;

stateName[4] = "CheckFire";
stateTransitionOnTriggerUp[4] = "StopFire";
stateTransitionOnTriggerDown[4] = "Fire";


stateName[5]                    = "StopFire";
stateTransitionOnTimeout[5]     = "Ready";
stateTimeoutValue[5]            = 0.2;
stateAllowImageChange[5]        = false;
stateWaitForTimeout[5] = true;
stateSequence[5]                = "StopFire";
stateScript[5]                  = "onStopFire";
};

function swordImage::onPreFire(%this, %obj, %slot)
{
%obj.playthread(2, armattack);
}

function swordImage::onStopFire(%this, %obj, %slot)
{
%obj.playthread(2, root);
}
//This function removed for those minigames where you hand out keys to only certain people.
//function serverCmdKey(%client)
//{
// %player = %client.player;
// if(isObject(%player))
// {
// %player.updateArm(keyImage);
// %player.mountImage(keyImage, 0);
// }
// }


Quote
//key.cs
-snip-

function keyImage::onPreFire(%this, %obj, %slot)
{
   %obj.playthread(2, armattack);
}

function keyImage::onStopFire(%this, %obj, %slot)
{   
   %obj.playthread(2, root);
}
//This function removed for those minigames where you hand out keys to only certain people.
//function serverCmdKey(%client)
//{
//       %player = %client.player;
//       if(isObject(%player))
//       {
//          %player.updateArm(keyImage);
//          %player.mountImage(keyImage, 0);
//       }
//    }