ID:262925
 
Code:
mob/
A
Monsters
icon = 'monsters.dmi'
icon_state = "metty"
name = "MonV"
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(M.HP <=0)
..()
else
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 = "metty"
if(M.HP <= 0)
src.icon_state = "metty"
src.exp += rand(5,10)
src.level_up()
M.deathcheck(src)


Problem description: Hi, In my monster code I added this:
        if(M.HP <=0)
..()
else
in between Bump(mob/M) so the monster will stop attacking when you are dead. It works but I get a bug! when ever I log in I get Red Messages that I think are called Proc Crashes its a whole bunch too! It even gets surpressed after a while. can anyone fix this? Thanks.

Don't call the parent. Use
return
if you're trying to stop the proc. Also, they are called runtime errors, errors that occur when you run the game that don't show up in the coding error box because the proc itself makes sense, or the program thinks it does.
In response to Pyro_dragons
I changed "else" into "return" for my monsters but now I just get this Monsters.dm:30:error::invalid expression
In response to Kiyo Takamine
No he meant change the ..() into return. Calling ..() means to call the parent proc. If you want to stop something, use return.
In response to XxDohxX
Like this? I did it but I still got some errors so I don't think I did it correctly.
mob/
A
Monsters
icon = 'monsters.dmi'
icon_state = "metty"
name = "MonV"
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(M.HP <=0)
return
else
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 = "metty"
if(M.HP <= 0)
src.icon_state = "metty"
src.exp += rand(5,10)
src.level_up()
M.deathcheck(src)


Help!!
In response to Kiyo Takamine
Its been a day and well... I still can't figure it out. I added it to the code like in the previous post and I still get the runtime messages(red messages) is there something I'm doing wrong? or ...
In response to Kiyo Takamine
In the runtime error, it tell you which line and which file. Go to that file that is stated, and press ctrl+G and type in the line that is said. That will get you to where the error is.
In response to Pyro_dragons
No, it doesn't work... I have to enter an integer and I can't find any it scrolls to fast. also I know where the bug is because when I removed that part of the code I did not get any runtime errors. but I need that code for my game to work right.
In response to Kiyo Takamine
Its prolly the monster bumping into a dense object. Paste your runtime error.
In response to AnarkiOwns
[Deleted for reasons..]
In response to Kiyo Takamine
The problem is that you've assumed that whatever it's bumped into is a mob, and it won't always be that. It could be a turf, or and object, or even an area. You need to check if it's a mob first, using the ismob() proc.