ID:142798
 
Code:
deathcheck()
if(src.monster >= 1)
if(src.health <= 0)
src.loc = null
spawn(600) loc = initial(loc)
src.health = src.max_health
usr.exp += src.level*10
usr << "You killed [src]"
if(src.blueslug >= 1)
var/droprate = rand(1,10)
if(droprate == 5)
var/obj/Equipment/Swords/Iron_Sword/O/ = new(loc)
O.rarity = rand(1,5)


Problem description:
What i want is if you kill a monster with a blueslug variable, you have a 1:10 chance of getting an iron sword with a random rarity, could anyone point out whats wrong? x.x;
You should not be using usr in procs. The proper way of writing a deathcheck is as so:

mob/proc/deathcheck(var/mob/killer)
if(HP <= 0) world << "[killer] killed [src]!"

mob/proc/attack(var/mob/target)
target.HP -= 1
target.deathcheck(src)


Also:

                        var/obj/Equipment/Swords/Iron_Sword/O/ = new(loc)


loc is null by this point.