ID:148453
 
ok, in my game i'm trying to make it so that when the mob touches the fireplace, he loses 1 hp and dies if the hp reaches 0 or below. here's the coding for that so far:

mob
icon = 'characters.dmi'
var
hp = 10
maxhp = 10
fireplace
icon = 'land.dmi'
icon_state = "fireplace"
density = 1
Enter(mob/M)
usr << "Hot!"
usr.hp -= 1
deathcheck()
proc/deathcheck()
if(usr.hp <= 0)
usr<<"You have died!"
usr.loc = locate(8,1,1,)
usr.hp = "[usr.maxhp]"

now what happens is the first time i purposely try to kill myself, everything goes well and i'm sent to the new location with 10 hp. after i go back to the fireplace and try to kill myself again, i get runtime errors. they look like this:

runtime error: type mismatch
proc name: Enter (/turf/fireplace/Enter)
usr: EnjoiStaticX (/mob)
src: the fireplace (4,14,1) (/turf/fireplace)
call stack:
the fireplace (4,14,1) (/turf/fireplace): Enter(EnjoiStaticX (/mob))

my hp doesn't go down at all either. well, i hope someone can help me with this. thanks.
EnjoiStaticX wrote:
ok, in my game i'm trying to make it so that when the mob touches the fireplace, he loses 1 hp and dies if the hp reaches 0 or below. here's the coding for that so far:

mob
icon = 'characters.dmi'
var
hp = 10
maxhp = 10
fireplace
icon = 'land.dmi'
icon_state = "fireplace"
density = 1
Enter(mob/M)
usr<< "Hot!"
usr.hp -= 1
usr.deathcheck()
proc/deathcheck()
if(usr.hp <= 0)
usr<<"You have died!"
usr.loc = locate(8,1,1,)
usr.hp = "[usr.maxhp]"

now what happens is the first time i purposely try to kill myself, everything goes well and i'm sent to the new location with 10 hp. after i go back to the fireplace and try to kill myself again, i get runtime errors. they look like this:

runtime error: type mismatch
proc name: Enter (/turf/fireplace/Enter)
usr: EnjoiStaticX (/mob)
src: the fireplace (4,14,1) (/turf/fireplace)
call stack:
the fireplace (4,14,1) (/turf/fireplace): Enter(EnjoiStaticX (/mob))

my hp doesn't go down at all either. well, i hope someone can help me with this. thanks.
Dont use usr in enter it will muck up....and dont use usr in procs either!, either defign somthing or use src.

proc/deathcheck()
if(src.hp <= 0)
src<<"You have died!"
src.loc = locate(8,1,1,)
src.hp = [src.maxhp]

fireplace
icon = 'land.dmi'
icon_state = "fireplace"
density = 1
Enter(mob/M)
M<< "Hot!"
M.hp -= 1
M.deathcheck()

and if im wrong guru's please correct me :-)

Also, why Were you defigning (cant spell) M ?? and not using it...?
In response to Wanabe
I wonder if he has an attack proc.
Never NEVER use "usr" in Enter() (and other procs of the type).


Enter(mob/M)
if(ismob(M))
M << "Hot!"
//your stuff here
In response to Wanabe
Wanabe wrote:
Entered(mob/M)
src << "Hot!"
src.hp -= 1
deathcheck()

src would be the turf, so it isn't correct. M is the mob entering, and that's what you'd want to use. usr is of course totally wrong, which ESX should have known already.

Lummox JR
In response to Lummox JR
Lummox JR wrote:
Wanabe wrote:
Entered(mob/M)
src << "Hot!"
src.hp -= 1
deathcheck()

src would be the turf, so it isn't correct. M is the mob entering, and that's what you'd want to use. usr is of course totally wrong, which ESX should have known already.

Lummox JR

:-P my bad, :| (haha first time i try help and i get it wrong) :P
In response to Wanabe
dont feal bad, it happens to the best of us, last time i tryed to help, lummox wrote a 10 page paper on why i was wrong(not really, but he did make a HUGE deal out of it, but he had decent reason)
thanks for the help.....i know i should've known, but i didn't even realize it(stupid me lol). oh and no, i don't have an attack proc....yet.
In response to Scoobert
Scoobert wrote:
dont feal bad, it happens to the best of us, last time i tryed to help, lummox wrote a 10 page paper on why i was wrong(not really, but he did make a HUGE deal out of it, but he had decent reason)

...heh you spelt Feel wrong, and yeah its good that he does that any way, that way the newbies dont do somthing silly :-P...
here's the updated coding:

fireplace
icon = 'land.dmi'
icon_state = "fireplace"
density = 1
Enter(mob/M)
M << "Hot!"
M.hp -= 1
deathcheck()
proc/deathcheck()
if(src.hp <= 0)
src << "You have died!"
src.loc = locate(8,1,1,)
src.hp = "[usr.maxhp]"

ok, now i'm getting 3 errors when i compile. they say that the src.hp, src.loc, and src.hp from the proc are undefined variables. any suggestions?
In response to EnjoiStaticX
deathcheck() needs to be a mob proc, and within Enter() it needs to be called M.deathcheck().
In response to Nadrew
ok i did that, and now i'm not getting any compile errors....but instead i'm getting the same runtime error. this is really weird...
In response to EnjoiStaticX
Are you sure you kept the if(ismob(M)) part in the code? It's pretty important.
In response to Nadrew
when i put it in like this:

fireplace
icon = 'land.dmi'
icon_state = "fireplace"
density = 1
Enter(mob/M)
if(ismob(M))
M << "Hot!"
M.hp -= 1
M.deathcheck()

i get a warning error that says the if statement has no effect =/ sorry for putting you through all of this trouble...
In response to EnjoiStaticX
EnjoiStaticX wrote:
when i put it in like this:

fireplace
icon = 'land.dmi'
icon_state = "fireplace"
density = 1
Enter(mob/M)
if(ismob(M))
M << "Hot!"
M.hp -= 1
M.deathcheck()

i get a warning error that says the if statement has no effect =/ sorry for putting you through all of this trouble...

...

M << "Hot!"
M.hp -= 1
M.deathcheck()

Tab those three lines once each..that should fix it
In response to Wanabe
i tried that and it compiles fine....but after dying the first time i get the runtime errors and nothing happens again. wow....i can't believe how bad this is...lol
In response to EnjoiStaticX
1) You're using usr in your deathcheck proc, you should be using src.

2) You're trying to set your hp (number) to "[maxhp]" (text), try src.hp = src.maxhp
In response to Nadrew
heh Nadrew your quicker then me i only just relized that. :p.. Try this:

proc/deathcheck()
if(src.hp <= 0)
src<<"You have died!"
src.loc = locate(8,1,1,)
src.hp = src.maxhp


...Well im off (going to play some games :-P)
In response to Nadrew
still won't work....>_< here's the new code update:

fireplace
icon = 'land.dmi'
icon_state = "fireplace"
density = 1
Enter(mob/M)
if(ismob(M))
M << "Hot!"
M.hp -= 1
M.deathcheck()
mob
proc/deathcheck()
if(src.hp <= 0)
src << "You have died!"
src.loc = locate(8,1,1,)
src.hp = "[src.maxhp]"

now there's no usr being used anywhere, lol. ok, everything compiles fine now....but i'm still getting the runtime error. does anyone want to test my game and see the problem for themself? maybe that will help a little. btw, i really appreciate the help guys.
In response to EnjoiStaticX
EnjoiStaticX wrote:
src.hp = "[src.maxhp]"


Not paying attention, are we?
Page: 1 2