ID:1712335
 
Code:
mob
proc
DeathCheck(mob/client/M)
M.loc=locate(7,18,1)
M.overlays = null
M.Health = 100
M.Days_Survived = 0
M.Hunger = 100
M.Thirst = 100
M.Poisoned= 0
M.Head = 0
M.Body = 0
M.Running = 0
M.Stamina = 50
M.Antidote = 0
world<<"<font color=red><b><big>[M] was killed by a [src]!"
DinoDeath(M)










mob
proc
DinoDeath(mob/client/M)
var/mob/dinosaur/TRex/rex
if(istype(rex))
world<<sound('Rex Roar.ogg')


Problem description: Feels pretty simple to do, but I can't figure it out. Basically, I want a dinosaur roar to coincide with the players death when its broadcast to the world.

Of course, each dinosaur has a different sound it would make across the world when it claims a victim.

I'm not getting any errors, I just can't figure it out.

First off, you should probably rename DinoDeath to onDeath() (or something similar) since then you can use that anytime you want.

This way you can define onDeath() whatever you want it will be specific to that type and its children:
Dino
var/sound/deathcry = 'default_dino_cry.ogg'
onDeath(mob/Killer) // Any /Dino that dies will have this done by default upon death.
viewers(src) << sound(deathcry)

Trex
deathcry = 'RexCry.ogg'

OnDeath(mob/K)
if(prob(10)) // 10% chance
new/Item/Rare/DinoDNA(src.loc)
else if(prob(50)) // 45% chance == (100-10%) * 50% = 90%/2 = 45%
new/Food/DinoMeat(src.loc)

if(prob(75)) // 75% chance
new/item/DinoBonez(src.loc)
.=..() // Calls the parent procedure - which is Dino/onDeath() which will do the death cry.



The reason why it didn't work is because you never defined who the variable rex was set to. Also, look up istype(), it would have functioned if you did if(istype(src, /.../TRex))

But you could easily make it fit any mob to do anything upon death as with the example I have shown
In response to GhostAnime
I should of been more specific. It's for when a player gets killed by a certain type of dinosaur.

Dinosaurs aren't killable.

EDIT: Got it sorted. Woop woop.
Ah, I see. In that case, in case for those wondering how to do this in the future, you should make a onKill() version
mob/Death_Check(mob/Killer)
if(src.HP > 0) return 0 // Safety check. Don't do anything if the person is still alive
src.onDeath(Killer)
viewers(src) << "[src.name] dies"

if(ismob(Killer))
viewers(src) << "\... by [Killer.name]" // \... surpresses the new line, making the message look like it's one line
Killer.onKill(src)

viewers(src) << "\.... " + pick(\
"What a bloody mess.", // will appear if pick()d
prob(3) // 3% chance
"Cleanup in Aisle 3!",
prob(75) // 75% chance
"... About time \he[src] died."


mob/proc
OnDeath(mob/Killer) // src = killed
onKill(mob/Victim) // src = killer

Dino/onKill(mob/V)
viewers(src) << sound(victory_roar)