ID:262953
 
Code:
    proc/deathcheck()
if(src.health <= 0)
if(src.client)
src <<"[src] killed you!"
src.loc = locate(172,421,1)
src.health = src.maxhealth
if(src.monstername == "Infil Sniper")
var/Rand = rand(1,5)

if(Rand==5)
new/obj/Items/Health_Pack(src.loc)
del(src)

if(Rand==3)
new/obj/Items/Small_Health_Pack(src.loc)
del(src)

if(Rand==1)
new/obj/Items/Small_Health_Pack(src.loc)
del(src)
else
del(src)


Problem description:
They dont die, no warnings or anything.. no errors.... But they somtimes die (but only when they drop an item) such as a health pack.. I did try making a rand 2,4,5 for dropping and item and just del(src) and it still wont work.. any suggestions?

Fix'd.
    proc/deathcheck()
if(src.health <= 0)
if(src.client)
src <<"[src] killed you!"
src.loc = locate(172,421,1)
src.health = src.maxhealth
if(src.monstername == "Infil Sniper")
var/Rand = rand(1,5)
if(Rand==5) new/obj/Items/Health_Pack(src.loc)
if(Rand==3) new/obj/Items/Small_Health_Pack(src.loc)
if(Rand==1) new/obj/Items/Small_Health_Pack(src.loc)
del(src)
In response to Sniper Joe
Yeah thanks, one thing though... wouldnt it be...

if(Rand==5) new/obj/Items/Health_Pack(src.loc)
del(src)
if(Rand==3) new/obj/Items/Small_Health_Pack(src.loc)
del(src)
if(Rand==1) new/obj/Items/Small_Health_Pack(src.loc)
del(src)


or...


if(Rand==5) new/obj/Items/Health_Pack(src.loc)
if(Rand==3) new/obj/Items/Small_Health_Pack(src.loc)
if(Rand==1) new/obj/Items/Small_Health_Pack(src.loc)
del(src)
In response to Flame Guardian
Wait, it works now but it takes them like 10 seconds or somthing to relize that they are dead, lol
In response to Flame Guardian
Figured out the problem, the enemy has to shoot u after it got less than 0 health.... I need to find a way to fix that now...
Any ideas? (because I dont know how the shot will always hit you)
In response to Flame Guardian
Make no sleep in the shot, make the enemy maybe do a couple shots of the no sleep shot and make sure it takes no dmg... show me your shooting code and I could show what i mean ;D
Flame Guardian wrote:
Code:
proc/deathcheck()
if(src.health <= 0)
if(src.client)
src <<"[src] killed you!"


Unless all deaths are suicides, you'd best change that.

Remember, in a deathcheck() proc if you need to know the killer, you have to pass it as an argument to the proc.

Lummox JR
mob
proc/deathcheck(mob/killer)
if(!(health<=0)||!ismob(killer)||!killer) return
src<<"[killer] killed you!"
loc=locate(172,421,1)
health=maxhealth
if(istype(killer,/mob/enemies))
if(prob(60))
var/mob/enemies/enemy=killer
var/item=pick(enemy.item_drops)
new item(loc)

Might be a better way to do it. item_drops is of course optional, but if I were you I'd set a list variable for /mob/enemies and set the items the enemies can drop under their subtypes of /mob/enemies.