ID:170873
 
I was wondering if there was any way around the peice of code for sound to only play one like

usr << sound('sound.wav')

I want to do this because I have quite a few monsters in my game and I want to store the name of their attack wav in an interchangable sound proc. I want to be able to do

something like usr << sound('[M.attacksound]')

So does anyone know a way around this and not having to create a new proc to run if checks for every monster.
I think you can do something like the following, but I'm not sure.

mob
var/attacksound = 'swordhit.wav'

mob
Attack(mob/target)
target << sound(src.attacksound)
In response to Jon88
Just to make Jon's statement more clear, that IS indeed how you would do such a thing. It'd be best to hold the monster's sound in a defined variable, so you wouldn't have to do much work to change the sound... Embedding it in an attack variable would just be blasphemous.

mob
monster
var
sound = 'roar.wav'


Alternately, it would be cool to have multiple sounds per monster... Though, it'd be a shame to do this with a list. Here's a cool way to do this:

mob
monster
var
sound1 = 'roar.wav'
sound1_prob = 100
sound2 = 'meow.wav'
sound2_prob = 50
proc
play_sound(var/mob/hearer)
hearer << sound(pick(prob(sound1_prob);sound1,prob(sound2_prob);sound2)
In response to Ter13
yeah jons way was it. I just thought it had to be in ''s instead of just in the parenthesis. I didn't want to have to code 1000 if statements.
In response to InuTracy
I just tried it out and it didn't work. It doesn't pplay any sound at all. This is just a brief overview of the code. Is there another way?

mob
var
hitsound="_novice_attack.wav"

mob
verb
Attack()
view() << sound(usr.hitsound)
In response to InuTracy
Try this: '_novice_attack.wav'
In response to Ter13
Does anyone else have another suggestion? There has to be a way.
In response to InuTracy
InuTracy wrote:
I just tried it out and it didn't work. It doesn't pplay any sound at all. This is just a brief overview of the code. Is there another way?

mob
var
hitsound="_novice_attack.wav"

mob
verb
Attack()
view() << sound(usr.hitsound)

Lummox JR wrote:
No usr in procs. Ungh.
In response to Mega fart cannon
Are you blinde? That clearly says verb. Anyway I tried src but it still didn't work. Anyone?
[link]

Hope that solves your problem :)
In response to Wizkidd0123
Looks like Lummox was wrong. I tried both of his methods.
In response to InuTracy
InuTracy wrote:
Looks like Lummox was wrong. I tried both of his methods.

Are you using
src << sound(file("[M.FightSong]"))

?

I can only remember 2 occasions in which Lummox was wrong, and they both involved undocumented features of DM, such as \c. lol
In response to InuTracy
mob
verb
Attack()
view(src) << sound(src.hitsound)
src << "You sir, are winnar!"
src << sound(src.hitsound)
src << "If no sound, insert a coin and try again."
src << sound(file("[src.hitsound]"))
view(src) << sound(file("src.hitsound"))//If you hear this, delete the above one
src << "If heard, Wizzie is the obvious winnar"


I'm not sure. :(
[Edit]Added what Wizzy said
In response to Hell Ramen
Hell Ramen wrote:
mob
verb
Attack()
view(src) << sound(src.hitsound)
src << "You sir, are winnar!"
src << sound(src.hitsound)
src << "If no sound, insert a coin and try again."

I'm not sure. :(

FYI, that only works if hitsound includes single quotes:

mob/var/hitsound='MySong.wav'
In response to Wizkidd0123
Wiz:
usr << sound('sound.wav')
From that, I belive he is putting 's around his sound.
In response to Hell Ramen
Hell Ramen wrote:
Wiz:
usr << sound('sound.wav')
From that, I belive he is putting 's around his sound.

I know; just explaing that he needed to use single quotes for his var too :)
In response to Wizkidd0123
THANK YOU VERY MUCH! It's so obvious now! You have to define the variable as a file with single quotes.