ID:262857
 
Code:
mob/
Monsters
VVVV
icon = 'monsters.dmi'
icon_state = "VVVV"
name = "Monster VVVV"
HP = 100
Attack = 5
Charge = 1
New()
. = ..()
spawn()
move()
proc/move()
while(src)
var/player_found = 0
for(usr in oview(8,src))
step_towards(src,usr)
player_found = 1
break
if(player_found != 1)
step_rand(src)
sleep(10)
sleep(5)

Bump(mob/M)
if(istype(M,/mob/Player))
attack(M)
proc/attack(mob/M)
var/damage = rand(1,Attack)
M.HP -= damage
M <<"You are being attacked by [src]!"
src.icon_state = "VVVV"
if(src.HP <= 0)
src.icon_state = "VVVV"
src.exp += rand(5,10)
src.level_up()
M.deathcheck(src)


Problem description: Hi, I have made a death proc and when the monsters attack you(The usr), the usr get's negative HP (below 0) and the death proc is never called and they never die, Help! If you need me to post the death proc just say so..

Yes we need to see your deathcheck proc. Otherwise we can't tell you what the problem is.
In response to Pyro_dragons
mob
proc/deathcheck(mob/M as mob)//handles death
if(src.HP <= 0)
usr.icon_state = "Defeated"
world<<"<center>[usr] Defeated</center>"
usr << sound("Itsnothere.mid",1)
sleep(10)
switch(alert("Do you want to continue? If you choose No you log out.","continue?","Yes","No"))
if("Yes")
//equal to 0
usr.icon_state = "l"
sleep(6)
usr.icon_state = "blank"
usr.loc = locate(3,30,1) //sets the user to that location
usr.icon_state = "l"
sleep(6)
usr.icon_state = "blank"
usr << sound("Lalalala.mid",1)
usr.icon_state = "blank"
usr.HP = usr.MaxHP
if("No")
usr.icon_state = "l"
sleep(7)
usr.icon_state = "blank"
del(src)
else
// src <<"\yellow You have been killed by [M]!"
src.zenny += rand(5,10)
sleep(7)
del(src)


Here is the Death Proc I made.
In response to Kiyo Takamine
Massive usr abuse in that proc. I don't even know where to start.
mob
proc/deathcheck(mob/M as mob)//handles death
if(src.HP <= 0)
usr.icon_state = "Defeated"//usr
world<<"<center>[usr] Defeated</center>"//usr
usr << sound("Itsnothere.mid",1)//usr
sleep(10)
switch(alert("Do you want to continue? If you choose No you log out.","continue?","Yes","No"))//usr (alert() defaults to usr,\
so does input() )

if("Yes")
//equal to 0
usr.icon_state = "l"//usr
sleep(6)
usr.icon_state = "blank"//usr
usr.loc = locate(3,30,1) //sets the user to that location (USR!!)
usr.icon_state = "l"//usr
sleep(6)
usr.icon_state = "blank"//usr
usr << sound("Lalalala.mid",1)//usr
usr.icon_state = "blank"//usr
usr.HP = usr.MaxHP//usr
if("No")
usr.icon_state = "l"//usr
sleep(7)
usr.icon_state = "blank"//usr
del(src)
else
// src <<"\yellow You have been killed by [M]!"
src.zenny += rand(5,10)
sleep(7)
del(src)


I refuse to correct it all for you, but I'd say I pointed them out rather well. Don't use usr in a proc, use src. Some of the code has it right, but other parts are just all mucked up.
In response to Detnom
Wait, I don't get it.. So I just have to change all the usr in the death Proc to src? I just did that and It didn't work.. nothing changed The players HP still goes below 0 to negative, and the player doesn't die..

mob
proc/deathcheck(mob/M as mob)//handles death
if(src.HP <= 0)
src.icon_state = "Defeated"//usr
world<<"<center>[src] Defeated</center>"//usr
src << sound("Itsnothere.mid",1)//usr
sleep(10)
switch(alert("Do you want to continue? If you choose No you log out.","continue?","Yes","No"))//usr (alert() defaults to usr,\
so does input() )

if("Yes")
//equal to 0
src.icon_state = "l"//usr
sleep(6)
src.icon_state = "blank"//usr
src.loc = locate(3,30,1) //sets the user to that location (USR!!)
src.icon_state = "l"//usr
sleep(6)
src.icon_state = "blank"//usr
src << sound("Lalalala.mid",1)//usr
src.icon_state = "blank"//usr
src.HP = usr.MaxHP//usr
if("No")
src.icon_state = "l"//usr
sleep(7)
src.icon_state = "blank"//usr
del(src)
else
// src <<"\yellow You have been killed by [M]!"
src.zenny += rand(5,10)
sleep(7)
del(src)
</DM
In response to Kiyo Takamine
Since you defined M in deathcheck(mob/M), try changing them to M. I'm not sure if that will work because your deathcheck is more long and involved than any that I've seen. But try it. As I stated, I'm not sure it will work.
In response to Pyro_dragons
No, It's still no good... I wonder what the problem is..
In response to Kiyo Takamine
You still didn't fix the usr abuse in the switch(alert()).

This statement reads like this by default:
switch(alert(usr,"Do you want to continue? If you choose No you log out.","continue?","Yes","No"))


You want it to read like this:
switch(alert(src,"Do you want to continue? If you choose No you log out.","continue?","Yes","No"))


See the difference? Input does the same thing, defaults to usr.
In response to Kiyo Takamine
mob
Monsters
VVVV
icon = 'monsters.dmi'
icon_state = "VVVV"
name = "Monster VVVV"
HP = 100
Attack = 5
Charge = 1
New()
. = ..()
spawn()
move()
proc/move()
while(src)
var/player_found = 0
for(usr in oview(8,src))
step_towards(src,usr)
player_found = 1
break
if(player_found != 1)
step_rand(src)
sleep(10)
sleep(5)

Bump(mob/M)
if(istype(M,/mob/Player))
attack(M)
proc/attack(mob/M)
var/damage = rand(1,Attack)
M.HP -= damage
M <<"You are being attacked by [src]!"
src.icon_state = "VVVV"
if(src.HP <= 0) //This. It's a simple mistake, you're checking the wrong HP value! You have to check M.HP. Deathcheck is fine, just used the src'd version.
src.icon_state = "VVVV"
src.exp += rand(5,10)
src.level_up()
M.deathcheck(src)
In response to Tai-Chi Urameshi
Good catch, but his deathcheck was still tore up. XD
In response to Tai-Chi Urameshi
Ah! I missed that src. I was looking at another one in the deathcheck and thinking about chenaging it to M.HP but I missed that one. If I had seen it I would have said something. Yes, just change that to M.HP
In response to Detnom
Yeah, like I said, I've never seen such an unneccasarily(sp?) overly invovled Deathcheck.
In response to Pyro_dragons
I think I see the point of this strange deathcheck(). It's kind of like having unlimited continues in a fighting game. Now, not to say that I agree with this kind of implementation, but it certainly is unique. I haven't ever seen it before.
In response to Detnom
Thanks. Indeed, it was pretty messed up. Hopefully he learns from this experience, then it's definitely worth replying.

Topic Creator: If I can find the usr lecture I'll post it here.
In response to Tai-Chi Urameshi
Lol, just quote Lummox Jr

"Don't put usr in proc. Ungh." - Lummox Jr
In response to Tai-Chi Urameshi
Here we go, for everyones' benefit - Usr Lecture.
In response to Detnom
Thanks, now I don't have to go find it. =P