Author Topic: Shot fired sound delay.  (Read 754 times)

I can get projectiles on a delay but I can't get the shotfire sound on a delay to match up with the projectile delay.  How would I set a shot fire sound delay?

I need at least a three second delay.

Code: [Select]
//audio
datablock AudioProfile(chordSound)
{
   filename    = "./Chords.wav";
   description = AudioClose3d;
   preload = true;
};

datablock ParticleData(V8GuitarTrailParticle)
{
dragCoefficient      = 3;
gravityCoefficient   = -0.0;
inheritedVelFactor   = 0.0;
constantAcceleration = 0.0;
lifetimeMS           = 2000;
lifetimeVarianceMS   = 0;
textureName          = "./Dot";
spinSpeed = 100.0;
spinRandomMin = 100.0;
spinRandomMax = 100.0;
colors[0]     = "0.9 0.9 0.9 0.8";
colors[1]     = "0.3 0.3 0.3 0.1";
   colors[2]     = "0.1 0.9 0.0 0.0";
   sizes[0]      = 0.7;
sizes[1]      = 1.0;
sizes[2]      = 3.0;

   useInvAlpha = false;
};
datablock ParticleEmitterData(V8GuitarTrailEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 0.0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "V8GuitarTrailParticle";

   uiName = "V8 Guitar";
};


datablock ExplosionData(V8GuitarExplosion)
{
   //explosionShape = "";
   lifeTimeMS = 500;

   emitter[0] = horseRayExplosionEmitter;

   //soundProfile = horseRayHitSound;

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

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

   // Dynamic light
   lightStartRadius = 3;
   lightEndRadius = 1;
   lightStartColor = "00.0 0.6 0.9";
   lightEndColor = "0 0 0";
};
AddDamageType("V8Guitar",  '<bitmap:add-ons/Weapon_V8Guitar/CI_V8Guitar %1',    '%2 <bitmap:add-ons/Weapon_V8Guitar/CI_V8Guitar> %1',1,1);

datablock ProjectileData(V8GuitarProjectile)
{
   projectileShapeName = "base/data/shapes/empty.dts";
   directDamage        = 40;
   directDamageType    = $DamageType::ERG;
   radiusDamageType    = $DamageType::ERG;

   brickExplosionRadius = 0;
   brickExplosionImpact = true;          //destroy a brick if we hit it directly?
   brickExplosionForce  = 10;
   brickExplosionMaxVolume = 1;          //max volume of bricks that we can destroy
   brickExplosionMaxVolumeFloating = 2;  //max volume of bricks that we can destroy if they aren't connected to the ground

   impactImpulse     = 000;
   verticalImpulse  = 100;
   explosion           = V8GuitarExplosion;
   //bloodExplosion        = horseRayExplosion;
   particleEmitter       = V8GuitarTrailEmitter;
   explodeOnPlayerImpact = true;
   explodeOnDeath        = true;

   muzzleVelocity      = 90;
   velInheritFactor    = 1;
  

   armingDelay         = 3000;
   lifetime            = 3000;
   fadeDelay           = 3500;
   bounceElasticity    = 0.99;
   bounceFriction      = 0.20;
   isBallistic         = true;
   gravityMod = 0.0;

   hasLight    = false;
   lightRadius = 3.0;
   lightColor  = "0 0 0.5";
  
   uiName = "V8 Guitar";
};

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

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

//gui stuff
uiName = "V8 Guitar";
iconName = "./Icon_V8Guitar";
doColorShift = false;
colorShiftColor = "0.0 0.7 0.0 1.000";

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

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

   // Specify mount point & offset for 3rd person, and eye offset
   // for first person rendering.
   mountPoint = 0;
   offset = "0 0 0";
   eyeOffset = 0; //"0.1 0.2 -0.55";
   rotation = eulerToMatrix( "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 = true;

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

   // Projectile && Ammo.
   item = BowItem;
   ammo = " ";
   projectile = V8GuitarProjectile;
   projectileType = Projectile;

//casing = horseRayShellDebris;
//shellExitDir        = "1.0 -1.3 1.0";
//shellExitOffset     = "0 0 0";
//shellExitVariance   = 15.0;
//shellVelocity       = 7.0;

   //melee particles shoot from eye node for consistancy
   melee = false;
   //raise your arm up or not
   armReady = true;
   minShotTime = 2000;   //minimum time allowed between shots (needed to prevent equip/dequip exploit)


   doColorShift = false;
   colorShiftColor = V8GuitarItem.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";
stateTimeoutValue[0]             = 0.15;
stateTransitionOnTimeout[0]       = "Ready";
stateSound[0] = weaponSwitchSound;

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

stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Smoke";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = horseRayFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateSound[2] = ChordSound;
stateEjectShell[2]       = true;

stateName[3] = "Smoke";
stateEmitter[3] = horseRaySmokeEmitter;
stateEmitterTime[3] = 0.4;
stateEmitterNode[3] = "muzzleNode";
stateTimeoutValue[3]            = 0.0;
stateTransitionOnTimeout[3]     = "Reload";

stateName[4] = "Reload";
stateSequence[4]                = "Reload";
stateTransitionOnTriggerUp[4]     = "Ready";
stateSequence[4] = "Ready";

};
« Last Edit: April 15, 2011, 04:16:47 PM by Lørd Tøny »


Here ye go.
Code: [Select]
stateName[2]                    = "Fire";
stateTransitionOnTimeout[2]     = "Delay";
stateTimeoutValue[2]            = 0.14;
stateFire[2]                    = true;
stateAllowImageChange[2]        = false;
stateSequence[2]                = "Fire";
stateScript[2]                  = "onFire";
stateWaitForTimeout[2] = true;
stateEmitter[2] = horseRayFlashEmitter;
stateEmitterTime[2] = 0.05;
stateEmitterNode[2] = "muzzleNode";
stateEjectShell[2]       = true;

stateName[5]                    = "Delay";
stateTransitionOnTimeout[5]     = "Smoke";
stateTimeoutValue[5]            = 3;
stateWaitForTimeout[5] = true;
stateSound[5] = ChordSound;

Why are you doing it like this?
Instead of hacking the states up to give the illusion of impact sound, overwrite the projectile ::onCollision code and add a sound effect there.

Why are you doing it like this?
Instead of hacking the states up to give the illusion of impact sound, overwrite the projectile ::onCollision code and add a sound effect there.

Because he wants the sound when it fires, not when it hits.