ID:166911
 

My code:
var/sound/crit = 'criticalhit.wav'
var/sound/att = 'attack.wav'
var/sound/hit = 'hit.wav'
var/sound/mhit = 'enemy-hit.wav'
var/sound/matt = 'enemy-attack.wav'
var/sound/dodge = 'dodge.wav'
var/sound/mdod = 'dodge2.wav'

mob
proc
attack(mob/M)
if(M)
src << "You attack [M]."
src << sound(att)
M << "[src] attacks you."
M << sound(matt)
sleep(5)
if(rand(1,4)==4)
src << "[M] dodges ."
src << sound(dodge)
M << "You dodge [src]'s attack."
M << sound(mdod)
sleep(5)
else
var/damage// = src.str - M.def
if(damage<=0)
damage = 1
src << sound(hit)
M << sound(mhit)
if(luckchance(src))
damage = damage*2
src << sound(crit)
M << sound(crit)
src << "Critical hit!"
M << "Critical hit!"
sleep(10)
src << "You hit [M] for [damage] hit points."
M << "[src] hits you for [damage] hit points."
M.hp -= damage
sleep(10)

var/sound/att = 'attack.wav'
var/sound/matt = 'enemy-attack.wav'

In battle I can hear the var "matt" but not "att" and I can't figure out why. Any help would be apprecited.
For future reference, you can put your code in <dm> tags to make it more readable.

Anyway, the reason you're only hearing the matt sound is because in this instance, you're M and the enemy is src. The reverse could sometimes be true.

Because each sound is only sent to one mob, only one sound is heard during the proc instead of both. In other words, you should've done this:
src << "You attack [M]."
src << sound(att)
oview(src) << sound(matt) // or you could send this to M, but I like this idea better
M << "[src] attacks you."
M << sound(matt)
oview(M) << sound(att) // or send just to src

Kudos in avoiding the usr trap that so many people fall into. I also have a few other suggestions that may help you out.

When calculating dodge chance, you used if(rand(1,4)==4), but an easier approach is if(prob(25)).

I also see that the damage formula was never calculated because it was commented out. Typically when using an attack-defense method, you'd use rand(0,attack)-rand(0,defense) and go from there. This is usually a pretty lousy formula, but it's a place to start.

Lummox JR