Author Topic: 3D sound isn't working  (Read 679 times)

Code: [Select]
datablock AudioProfile(DubstepRifleShot1Sound)
{
   filename    = "./Shoot.wav";
   description = AudioCloseLooping3D;
   preload = true;
};

datablock AudioProfile(DubstepRifleCharge)
{
   filename    = "./Charge.wav";
   description = AudioCloseLooping3D;
   preload = true;
};

//muzzle flash effects
datablock ParticleData(DubstepRifleFlashParticle)
{
dragCoefficient      = 2;
gravityCoefficient   = 1;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 15;
textureName          = "base/data/particles/thinring";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0]     = "0 0.96 0.11 0.9";
colors[1]     = "0 0.96 0.11 0.9";
sizes[0]      = 1;
sizes[1]      = 2;

useInvAlpha = true;
};
datablock ParticleEmitterData(DubstepRifleFlashEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 1.0;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "DubstepRifleFlashParticle";

   uiName = "DubstepRifle Flash";
};

datablock ParticleData(DubstepRifleSmallFlashParticle)
{
dragCoefficient      = 2;
gravityCoefficient   = 1;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 500;
lifetimeVarianceMS   = 25;
textureName          = "base/data/particles/thinring";
spinSpeed = 10.0;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0]     = "0 0.96 0.11 0.9";
colors[1]     = "0 0.96 0.11 0.9";
sizes[0]      = 0.5;
sizes[1]      = 1;

useInvAlpha = true;
};
datablock ParticleEmitterData(DubstepRifleSmallFlashEmitter)
{
   ejectionPeriodMS = 3;
   periodVarianceMS = 0;
   ejectionVelocity = 1.0;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 0;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "DubstepRifleSmallFlashParticle";

   uiName = "DubstepRifle Small Flash";
};

datablock ParticleData(DubstepRifleExplosionParticle)
{
dragCoefficient      = 8;
gravityCoefficient   = 1;
inheritedVelFactor   = 0.2;
constantAcceleration = 0.0;
lifetimeMS           = 700;
lifetimeVarianceMS   = 400;
textureName          = "base/data/particles/cloud";
spinSpeed = 10.0;
spinRandomMin = -50.0;
spinRandomMax = 50.0;
colors[0]     = "0 0.96 0.11 0.9";
colors[1]     = "0 0.96 0.11 0.9";
sizes[0]      = 0.5;
sizes[1]      = 0.75;

useInvAlpha = true;
};
datablock ParticleEmitterData(DubstepRifleExplosionEmitter)
{
   ejectionPeriodMS = 1;
   periodVarianceMS = 0;
   ejectionVelocity = 2;
   velocityVariance = 1.0;
   ejectionOffset   = 0.0;
   thetaMin         = 89;
   thetaMax         = 90;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "DubstepRifleExplosionParticle";

   useEmitterColors = true;
   uiName = "DubstepRifle Hit Dust";
};


datablock ParticleData(DubstepRifleExplosionRingParticle)
{
dragCoefficient      = 1;
gravityCoefficient   = 0;
inheritedVelFactor   = 0;
constantAcceleration = 1;
lifetimeMS           = 750;
lifetimeVarianceMS   = 50;
textureName          = "base/data/particles/thinring";
spinSpeed = 100;
spinRandomMin = -500.0;
spinRandomMax = 500.0;
colors[0]     = "0 0.96 0.11 0.9";
colors[1]     = "0 0.96 0.11 0.9";
sizes[0]      = 0.2;
sizes[1]      = 0.4;

useInvAlpha = true;
};
datablock ParticleEmitterData(DubstepRifleExplosionRingEmitter)
{
lifeTimeMS = 50;

   ejectionPeriodMS = 0;
   periodVarianceMS = 0;
   ejectionVelocity = 0;
   velocityVariance = 0.0;
   ejectionOffset   = 0.0;
   thetaMin         = 5;
   thetaMax         = 10;
   phiReferenceVel  = 0;
   phiVariance      = 360;
   overrideAdvance = false;
   particles = "DubstepRifleExplosionRingParticle";

   useEmitterColors = true;
   uiName = "DubstepRifle Hit Flash";
};

datablock ExplosionData(DubstepRifleExplosion)
{
   //explosionShape = "";

   lifeTimeMS = 150;

   particleEmitter = DubstepRifleExplosionEmitter;
   particleDensity = 5;
   particleRadius = 0.2;

   emitter[0] = DubstepRifleExplosionEmitter;

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

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

   // Dynamic light
   lightStartRadius = 0;
   lightEndRadius = 2;
   lightStartColor = "0.3 0.6 0.7";
   lightEndColor = "0 0 0";
};


AddDamageType("DubstepRifle",   '<bitmap:add-ons/Weapon_DubstepRifle/CI_gun> %1',    '%2 <bitmap:add-ons/Weapon_DubstepRifle/CI_gun> %1',0.2,1);
datablock ProjectileData(DubstepRifleProjectile)
{
   projectileShapeName = "./bullet.dts";
   directDamage        = 15;
   directDamageType    = $DamageType::DubstepRifle;
   radiusDamageType    = $DamageType::DubstepRifle;

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

   impactImpulse      = 750;
   verticalImpulse   = 750;
   explosion           = DubstepRifleExplosion;
   particleEmitter     = DubstepRifleExplosionRingEmitter;

   muzzleVelocity      = 100;
   velInheritFactor    = 1;

   armingDelay         = 00;
   lifetime            = 4000;
   fadeDelay           = 3500;
   bounceElasticity    = 0.5;
   bounceFriction      = 0.20;
   isBallistic         = false;
   gravityMod = 0.0;

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

   uiName = "";
};

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

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

//gui stuff
uiName = "Dubstep Rifle MK-1";
iconName = "./Icon";
doColorShift = true;
colorShiftColor = "0.25 0.25 0.25 1.000";

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

////////////////
//weapon image//
////////////////
datablock ShapeBaseImageData(DubstepRifleImage)
{
   // Basic Item properties
   shapeFile = "./DubstepRifle.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.7 1.2 -0.5";
   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 = DubstepRifleProjectile;
   projectileType = Projectile;

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

   doColorShift = true;
   colorShiftColor = DubstepRifleItem.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]  = "Charge";
stateAllowImageChange[1]         = true;
stateSequence[1] = "Ready";

stateName[2] ="Charge";
stateTransitionOnTimeout[2]     = "Fire";
stateTimeoutValue[2]            = 1.86;
stateWaitForTimeout[2] = true;
stateSound[2] = DubstepRifleCharge;
stateEmitter[2] = DubstepRifleSmallFlashEmitter;
stateEmitterTime[2] = 1.5;
stateTransitionOnTriggerUp[2]   = "Ready";

stateName[3]                    = "Fire";
stateTransitionOnTimeout[3]     = "Fire";
stateTransitionOnTriggerUp[3]   = "Ready";
stateTimeoutValue[3]            = 0.07;
stateFire[3]                    = true;
stateAllowImageChange[3]        = false;
stateSequence[3]                = "Fire";
stateScript[3]                  = "onFire";
stateWaitForTimeout[3] = true;
stateEmitter[3] = DubstepRifleFlashEmitter;
stateEmitterTime[3] = 0.1;
stateEmitterNode[3] = "muzzleNode";
stateSound[3] = DubstepRifleShot1Sound;

stateName[4] = "Reload";
stateTransitionOnTriggerDown[4]  = "Fire";
stateTransitionOnTriggerUp[4]     = "Ready";
stateSequence[4] = "Ready";
};

The weapon works fine and all, but the sound isn't 3d. It plays at the same volume even if are far away from the weapon, then simply cuts off at a certain distance. I really need it to be 3d.

Try changing the description field on the audio datablocks to AudioClosest3d

Try changing the description field on the audio datablocks to AudioClosest3d
I did AudioClose, AudioClosest, AudioDefault, pretty much all of them

Your best bet is to create your own profile that falls off.

Your best bet is to create your own profile that falls off.
just did that, didn't work