ID:359632
 
(See the best response by Popisfizzy.)
Code:
mob
var
bug_def=0
bugdead=FALSE
bhp=20000
mob
verb
Attack(mob/M as mob in oview(1))
flick("regA",usr)
var/damage = usr.str - bug_def
if(damage <=0)
usr << "[M] easily dodges your attack!"
M << "You easily dodge [usr]'s attack."
var/mob/BB
BB=new/mob/bug()
if(istype(BB) && damage>=1)
view() <<"[usr] attacks [M] for [damage] HP!"
bhp -= damage
deathcheck()

mob
proc
deathcheck()
if(usr.php <= 0)
dead=1
view() << "[usr] dies!"
sleep(2)
usr.icon_state="spr_dead"
sleep(10)
usr.loc=locate(1,1,1)
usr.php=usr.pmaxhp
usr.mp=usr.maxmp
usr.exp=0
usr.icon_state="normal"
sleep(1)
usr.php=usr.pmaxhp
else
var/mob/BB
BB=new/mob/bug()
if(istype(BB) && bhp<=0)
usr.exp+=50
usr.LevelCheck()
src.icon_state="dead"
src.density=0
bugdead=TRUE
del(src)


Problem description:

mm its deleting my screen and everything.

any help,advice or something?
Best response
That's what del src does when you delete the mob the client is attached to.
It would be helpful if the code in the example had the proper indentation so we'd be able to read it easier.

It looks like you're confusing src and usr. Look at it this way: In a proc, src is the SOURCE. The proc can't happen without its src(source). The src is the object that the proc is happening to, per se.

So in this:
proc/hurt()//when something is hurt
if(hp < 0)//check if its hp is less than zero
src.die()//if so, make src(the source, the one being hurt) die.
proc/die()//when something dies
src.icon_state = "dead"//make src appear as dead


src.die() is like saying "make src die" If you write usr.die(), you're telling the code to "make usr die". It's a lot to wrap your head around, but if you try reading the code in a more understandable way then it starts becoming clearer.

Now this is slightly off topic, but in your example, you're using variables that aren't needed. Think of this:

mob
var
hp = 30


Every single mob has the variable hp which by default has a value of 30.

Here, look at this example:
mob/verb/attack(mob/m as mob in oview(1))
m.hurt()
mob/proc/hurt()//when a mob(src) is hurt
src.hp -= 30//make src's hp go down 30
if(src.hp < 0)//if src has less than 0 hp
src.die()//make src die


I hope that's descriptive enough for you to understand this a little bit better.
Please put your code around the <*dm> (Without *> tags, making it more readable! Otherwise we won't be able to help you.
but what i dont understand is i have a variable for HP for my player, so when i use src.hp it just uses my player's hp so if my players hp is 10 i have to do 10 dmg to kill the monster