ID:261381
 
I copyed this code from the rpg tutorial made by Kunark, please help.

FIRST PROBLEM

mob
var
HP
Max_HP
strength
exp
exp_give
proc
DeathCheck(mob/M)
if(src.type == /mob/PC)
PCDeathCheck()
else
if(src.HP <= 0)
src.loc = locate(11,9,1)
src.HP = Max_HP


Lyodia.dm:64:error:PCDeathCheck:bad proc

SECOND PROBLEM

mob
NPC
Worm
icon = 'Worm.dmi'
name = "Worm"
HP = 10
Max_HP = 10
strength = 2
exp_give = 5
var/mob/PC/P
New()
.=..()
spawn(1)
Wander()
proc/Wander()
while(src)
if (P in oview(5))
step_towards(src,P)
else
step_rand(src)
for(P in view (src))
break
sleep(5)
spawn(40)
Wander()
Bump(mob/M)
if (istype(M,/mob/PC))
Attack(M)
proc/Attack(mob/M)
flick("Worm_Attack",src)
sleep(2)
var/damage = rand(1,strength)
M.HP -= damage
view(src) << "[src] attacks [M]!"
view(src) << "[damage] damage!"
M.PCDeathCheck()

Lyodia.dm:105:error:M.PCDeathCheck:bad proc
Little Sally wrote:
mob
var
HP
Max_HP
strength
exp
exp_give
proc
DeathCheck(mob/M)
if(src.type == /mob/PC)
PCDeathCheck()<font color=red>//Never defined this proc</font>
else
if(src.HP <= 0)
src.loc = locate(11,9,1)
src.HP = Max_HP


Lyodia.dm:64:error:PCDeathCheck:bad proc

SECOND PROBLEM

mob
NPC
Worm
icon = 'Worm.dmi'
name = "Worm"
HP = 10
Max_HP = 10
strength = 2
exp_give = 5
var/mob/PC/P
New()
.=..()
spawn(1)
Wander()
proc/Wander()
while(src)
if (P in oview(5))
step_towards(src,P)
else
step_rand(src)
for(P in view (src))
break
sleep(5)
spawn(40)
Wander()
Bump(mob/M)
if (istype(M,/mob/PC))
Attack(M)
proc/Attack(mob/M)
flick("Worm_Attack",src)
sleep(2)
var/damage = rand(1,strength)
M.HP -= damage
view(src) << "[src] attacks [M]!"
view(src) << "[damage] damage!"
M.PCDeathCheck()


Read the red text that's your problem with both errors.
In response to Nadrew
Thank you, I managed to solve one of the problems but im still stuck on this one(I can kill NPC but I cant be killed).

mob/PC
var
HP = 30
Max_HP = 30
strength = 3
exp = 0
exp_give = 0
gold = 50
verb
Attack(mob/M in oview(1))
var/damage = rand(1,strength)
usr << "You attack [M]!"
usr << "[damage] damage!"
M << "[usr] attacks you!"
M << "[damage] damage!"
M.HP -= damage
MDeathCheck()

Lyodia.dm:53:error:MDeathCheck:bad proc
(Not sure how to define the Mdeathcheck proc.)
In response to Little Sally
Have you tried M<big>.</big>DeathCheck()?
In response to Nadrew
Ok I tryed it and got some new errors...

mob/PC
var
HP = 30
Max_HP = 30
strength = 3
exp = 0
exp_give = 0
gold = 50

verb
Attack(mob/M in oview(1))
var/damage = rand(1,strength)
usr << "You attack [M]!"
usr << "[damage] damage!"
M << "[usr] attacks you!"
M << "[damage] damage!"
M.HP -= damage
M.DeathCheck()

mob
var
HP
Max_HP
strength
exp
exp_give
gold
proc
PCDeathCheck(mob/M)
if(src.type == /mob/PC)
PCDeathCheck()
else
if(src.HP <= 0)
src.loc = locate(3,2,1)
src.HP = Max_HP
M.DeathCheck(mob/M)
if(src.type == /mob/PC)
MDeathCheck()
else
if(src.HP <= 0)
src.loc = locate(3/2/1)
src.HP = Max_HP


Lyodia.dm:72:error:M :invalid proc definition
Lyodia.dm:54:error:M.DeathCheck:undefined type: M.DeathCheck
In response to Little Sally
It wouldn't hurt if you tried it for all of them, either. You still have MDeathCheck in there.
In response to Foomer
Tryed it. No luck. :(
In response to Little Sally
Another problem, you only need to call M. when you're calling the proc for something, not when you're defining it.

you defined a variable, mob/M. That means your proc is working with M. So, when you call M.DeathCheck(), you're calling that proc with M as the target. But, when you define a proc, you don't need a target, so there's no reason to have the M.
In response to Foomer
I think we are getting there, the PC still wont die but now when you play the game and attack a monster it says.
------------------------------------------------------------
runtime error: Maximum recursion level reached (perhaps there is an infinite loop)
To avoid this safety check, set world.loop_checks=0.
proc name: PCDeathCheck (/mob/proc/PCDeathCheck)
usr: Kento (/mob/PC)
src: Kento (/mob/PC)
call stack:
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
...
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): PCDeathCheck(null)
Kento (/mob/PC): Attack(Worm (/mob/NPC/Worm))
Shutting down after encountering too many critical errors.

I think I have killed my code for good :(
In response to Little Sally
That means that somewhere in your code there's a proc that's repeating over and over, and since your computer can't do an infinite number of things at once, it's closing it down. Post the code again and let me see what's wrong.
In response to Foomer
Sorry about the delay in response I had to get to bed. Heres the code.


turf
grass
icon = 'Grass.dmi'
name = "grass"
wall
icon = 'Wall.dmi'
name = "stone wall"
density = 1
opacity = 1
path
icon = 'Path.dmi'
name = "road"
path1
icon = 'Path1.dmi'
name = "road"
floor
icon = 'FloorH.dmi'
name = "floor"

world
turf = /turf/grass

world
mob = /mob/PC

mob
PC
icon = 'PC.dmi'
verb
say(msg as text)
view(src) << "[usr] says: [msg]"
Login()
icon_state = gender
usr.loc = locate(3,2,1)


mob/PC
var
HP = 30
Max_HP = 30
strength = 3
exp = 0
exp_give = 0
gold = 50

verb
Attack(mob/M in oview(1))
var/damage = rand(1,strength)
usr << "You attack [M]!"
usr << "[damage] damage!"
M << "[usr] attacks you!"
M << "[damage] damage!"
M.HP -= damage
PCDeathCheck()

mob
var
HP
Max_HP
strength
exp
exp_give
gold
proc
PCDeathCheck(mob/M)
if(src.type == /mob/PC)
PCDeathCheck()
else
if(src.HP <= 0)
src.loc = locate(3,2,1)
src.HP = Max_HP








mob
NPC
Worm
icon = 'Worm.dmi'
name = "Worm"
HP = 10
Max_HP = 10
strength = 2
exp_give = 5
gold = 1
var/mob/PC/P
New()
.=..()
spawn(1)
Wander()
proc/Wander()
while(src)
if (P in oview(5))
step_towards(src,P)
else
step_rand(src)
for(P in view(src))
break
sleep(5)
spawn(40)
Wander()
Bump(mob/M)
if (istype(M,/mob/PC))
Attack(M)
proc/Attack(mob/M)
flick("Worm_Attack",src)
sleep(2)
var/damage = rand(1,strength)
M.HP -= damage
view(src) << "[src] attacks [M]!"
view(src) << "[damage] damage!"

PCDeathCheck()

mob/Stat()
stat("Stats:",src.desc)
if(src == usr) statpanel("Inventory",src.contents)
stat("HP: ",HP)
stat("Strength: ",strength)
stat("Experience: ",exp)
stat("Gold: ",gold)