ID:261405
 
Can someone please explain to me how you would set it so that if a mob kills another it gains all the gold that it held? Thank you
Assuming gold is an object...

mob/verb/Attack(mob/M)
//do attack stuff
M.DeathCheck(src)

mob/proc/DeathCheck(killer)
for(var/obj/gold/O in src)
O.Move(killer)

or if it's a var...

mob/proc/DeathCheck(killer)
killer.gold += src.gold
src.gold = 0
This is one way:

mob/proc/deathcheck(mob/M)
if(M.health<=0)
if(M.client)//is a player
src.gold+=M.gold
M.gold = 0
//rest of death here
else
del(M)
else
return..()

//And call this proc:
attacker.deathcheck(victum)
In response to Nadrew
Just a friendly suggestion, I would recommend dividing up the amount of gold taken from PCs. I had that in my game too and when someone lost all their gold it can really make the game unenjoyable trying to get it all back. If you want a system to divide the money up and make it a whole number use the code below.

LJR


takegold = M:gold/3; goldtaken = round(takegold)