Author Topic: Weapon sound layers *need help*  (Read 7233 times)

It's not an issue of time, it's an issue of tediousness. It's hard to have patience with people when you're teaching them concepts that have been beaten into your brain repeatedly. If I was an elementary school teacher, I'd probably have to start taking Xanax daily to not get frustrated when kids can't add 10 and 2 after 2 weeks.

If you really want to learn, you should take the initiative to do so. There's a difference between having someone baby sit you and having someone you can go to when you get stumped and need some help.

There are coding help manuals posted on some stickied help topics.  Do a little research.  If you can't find anything there, use Google.

*bump, thanks swat, ill look for help
But in the mean time i have a problem coming up, im testing the sound layers on the Blockombat Service Pistol (CM1911). I put in the audio profiles
datablock AudioProfile(CM1911A1FireSound)
{
   filename    = "./CM1911A1Fire.wav";
   description = AudioClosest3d;
   preload = true;
};
datablock AudioProfile(LightClose)
{
   filename    = "./LightClose.wav";
   description = AudioClose3d;
   preload = true;
};
datablock AudioProfile(LightFar)
{
   filename    = "./LightFar.wav";
   description = AudioDefault3d;
   preload = true;
};

CM1911Fire being the base sound
LightClose being the pop at 5 meters
and LightFar being the pop at 10 meters ( just to test )
However ive found 2 or 3 "OnFire Functions, such as this one
function CM1911A1Image::onFire(%this,%obj,%slot)
{
   CM1911A1Fire(%this,%obj,%slot);
   %obj.toolAmmo[%obj.currTool]--;
   if($BKT::DH){commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:FF0000>.45 ACP Pistol  <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool]+0 @ " / " @ %obj.client.quantity["45caliber"]+0 @ "", 4, 2, 3, 4);}
   if($BKT::Recoil)
   {
      %projectile = "ATACRecoilProjectile";   
      %vector = %obj.getMuzzleVector(%slot);
      %objectVelocity = %obj.getVelocity();
      %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
      %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
      %velocity = VectorAdd(%vector1,%vector2);
      %p = new (%this.projectileType)()
      {
         dataBlock = %projectile;
         initialVelocity = %velocity;
         initialPosition = %obj.getMuzzlePoint(%slot);
         sourceObject = %obj;
         sourceSlot = %slot;
         client = %obj.client;
      };
   }
   MissionCleanup.add(%p);
   return %p;
}

and this one,
function CM1911A1ADSImage::onFire(%this,%obj,%slot)
{
   CM1911A1Fire(%this,%obj,%slot);
   %obj.toolAmmo[%obj.currTool]--;
   if($BKT::DH){commandToClient(%obj.client,'bottomPrint',"<just:right><font:impact:24><color:FF0000>.45 ACP Pistol  <font:impact:34>\c6" @ %obj.toolAmmo[%obj.currTool]+0 @ " / " @ %obj.client.quantity["45caliber"]+0 @ "", 4, 2, 3, 4);}
   if($BKT::Recoil)
   {
      %projectile = "ATACRecoilProjectile";   
      %vector = %obj.getMuzzleVector(%slot);
      %objectVelocity = %obj.getVelocity();
      %vector1 = VectorScale(%vector, %projectile.muzzleVelocity);
      %vector2 = VectorScale(%objectVelocity, %projectile.velInheritFactor);
      %velocity = VectorAdd(%vector1,%vector2);
      %p = new (%this.projectileType)()
      {
         dataBlock = %projectile;
         initialVelocity = %velocity;
         initialPosition = %obj.getMuzzlePoint(%slot);
         sourceObject = %obj;
         sourceSlot = %slot;
         client = %obj.client;
      };
   }
   MissionCleanup.add(%p);
   return %p;
}
the two strips of code are for "Non-ADS" and "ADS"
i put the following script in:

origin = origin-of-sound.getTransform();
for all clients
{
     transform = client.Transform()
     distance = vectorDist(origin, transform)

     if(dist < 5)
          play sound 1 - client.play3D(LightClose, origin)
     else if(dist < 10)
          play sound 2 - client.play3D(LightFar, origin)
}

I tried putting this in on both "OnFire" functions
but it just screws up the gun.

can one of you intellegent people, tell me where and how im loving up this bad?

do you even know the definition of pseudocode
plus that code isnt even in the onfire functionim dumb

no i dont know what pseudo code is, im new to scripting, just tell me what i need to do, and ill be on my way.

no i dont know what pseudo code is, im new to scripting, just tell me what i need to do, and ill be on my way.
Pseudo means close to, but different from. So "pseudocode" is close to real code, but not quite. It's fake code. It's meant to be interpreted, understood, and rewritten in whatever language you're using (in this case, Torque).

The code does not work, but it is instructions on how to do what you are trying to do.

Also use code tags around your codes to distinguish between that and explanations.

Otherwise, in the script you can put // before things so that line will not be executed.

Example:

Code: [Select]
This line will be executed.

//This line will not be executed and you can make it as long as you want.  Though for the courtesy of others reading your script, it is best to press enter/return so //that the line is immediately visible without side-scrolling.

@trinik, and where do i find these instructions?

let me rephrase, how do i rewrite this into torque, ive look all over the web and have found nothing on how to do this.

let me rephrase, how do i rewrite this into torque, ive look all over the web and have found nothing on how to do this.

Pseudocode is not metacode. Metacode is code that can be translated into many different languages by a computer program. Pseudocode has to be read by the programmer, then the programmer rewrites it in whatever language they're using because they understand how it works.

The part that is frustrating is that you have to know Torque to translate that metacode into Torque. There's no program that will do it, and nobody here wants to do it for you because we want you to learn. It wouldn't have helped you if teachers filled out your schoolwork and homework in school now, would it have?

Basically, i'll translate the pseudocode into simpler terms.
Code: [Select]
origin = origin-of-sound.getTransform();
for all clients
{
     transform = client.Transform()
     distance = vectorDist(origin, transform)

     if(dist < 50)
          play sound 1 - client.play3D(yourSound, origin)
     else if(dist < 100)
          play sound 2
     else
          play sound 3
}

Origin is the variable (Variables are things that can change) and we're calling it back (I'll explain what calling is later)

What we're doing is getting the sounds starting point (Correct me if i'm wrong) by using .getTransform();
We're doing the same with Transform = client.GetTransform(); we're making transform the variable to call back.

distance = (Yet again another variable to be called back) vectorDist(origin, transform) (We're getting the variable origin, and getting the variable transform, this is basically calling the variables.

if(distance < 50) (We're checking the distance and seeing if it is less than 50 torque units (These are the measurement for distance in torque, don't worry about them, they're relatively the same distance as blocks.) away, if it is go onto playsound1.

else if (If it's more than 50 go onto the next if statement which we call else if) else if( distance < 100) if distance less than 100 playsound 2.

else (If all else fails call this, so if it's not less than 50, if it's not less than 100, do this instead) playsound3




I'm tired, someone correct me if I am wrong, which I probably will be and make a fool of myself.
« Last Edit: June 01, 2014, 08:56:48 PM by Starzy »

Basically, i'll translate the pseudocode into simpler terms.
Code: [Select]
origin = origin-of-sound.getTransform();
for all clients
{
     transform = client.Transform()
     distance = vectorDist(origin, transform)

     if(dist < 50)
          play sound 1 - client.play3D(yourSound, origin)
     else if(dist < 100)
          play sound 2
     else
          play sound 3
}

Origin is the variable (Variables are things that can change) and we're calling it back (I'll explain what calling is later)

What we're doing is getting the sounds starting point (Correct me if i'm wrong) by using .getTransform();
We're doing the same with Transform = client.GetTransform(); we're making transform the variable to call back.

distance = (Yet again another variable to be called back) vectorDist(origin, transform) (We're getting the variable origin, and getting the variable transform, this is basically calling the variables.

if(distance < 50) (We're checking the distance and seeing if it is less than 50 blocks(?) away, if it is go onto playsound1.

else if (If it's more than 50 go onto the next if statement which we call else if) else if( distance < 100) if distance less than 100 playsound 2.

else (If all else fails call this, so if it's not less than 50, if it's not less than 100, do this instead) playsound3




I'm tired, someone correct me if I am wrong, which I probably will be and make a fool of myself.
vectorDist does not measure in brick units.

vectorDist does not measure in brick units.
Yeah it's torque units, they're relatively the same. Ill edit it once I'm on my pc.

@Starzy
 That helped alot, now i know what im doing :D