The Daily Click ::. Forums ::. Klik Coding Help ::. cloned enemies, different sound fx (tgf)
 

Post Reply  Post Oekaki 
 

Posted By Message

tetsuya_shino



Registered
  12/08/2004
Points
  491
6th August, 2010 at 11:21:37 -

Greetings. I have a quick question. I have a much of cloned enemies, but when the hero punchs one, I want each one to play a different sound fx. In other words, if there are 5 male soldiers, and I already have 5 different 'taking damage' wavs, how do I code it so each clone plays a set sound fx only? Thanks

 
n/a

nim



Registered
  17/05/2002
Points
  7229
6th August, 2010 at 11:51:37 -

I recommend using an alterable value, or if you have none of those left, try using an alterable string and using Val() to get TGF to treat it like a value. Specifically, I mean setting Alterable Value A to 3 for enemy type 3, and so on. Then you can use a condition like
Active("Enemy")'s Alterable Value A = 3 ... Play gethit3.wav

 
//

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
6th August, 2010 at 13:03:00 -

Would it not be better to just have a random .wav play whenever you hit an enemy? Or do you specifically want to apply each .wav to specific enemies?

If you want it to be random..

+ Player hits enemy
- Set a counter to Random(5)

+ If Counter is equal to 0
- Play 0.wav
- Set counter to -1

+ If Counter is equal to 1
- Play 1.wav
- Set counter to -1

... and then for every other .wav up to 4.wav. Even better would be to just play the .wav based on value("Counter") + ".wav" but I'm not sure MMF2 can do that (maybe some sound extension can).

If you want to assign each sound to a specific enemy..

+ Start of frame
- Spread value 0 in Alterable A of enemy

+ Player hits enemy
+ If Alterable A = 0
- Play sound 0.wav

+ Player hits enemy
+ If Alterable A = 1
- Play sound 1.wav

... and so on


Edited by Flava

 
This is a signature. Have this one on me.

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
6th August, 2010 at 13:13:53 -

In fact I think MMF2 can play a sound file based on it's file location, so to tidy the above up just do:

Random Sound

+ Player hits enemy
- Play "/sound/gethit" + Random(5) + ".wav"

Specific Sound

+ Player hits enemy
- Play "/sound/gethit" + Alterable Value A("Enemy") + ".wav"

You can do this using the "Play sample file on a specific channel" action and clicking the "Expression" button to provide a file location.

Example File: http://www.create-games.com/uploads/flava/SoundsExample.zip


Edited by Flava

 
This is a signature. Have this one on me.

Flava



Registered
  30/07/2002
Points
  684

Has Donated, Thank You!Code MonkeyVIP MemberThe Cake is a LieThe Spinster
6th August, 2010 at 13:58:12 -

Though I've only just now realised you're using TGF..

 
This is a signature. Have this one on me.

tetsuya_shino



Registered
  12/08/2004
Points
  491
6th August, 2010 at 14:04:07 -

Thank you both! I'll try that now.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click