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.
ID:148453
![]() Feb 11 2003, 5:14 pm
|
|
Never NEVER use "usr" in Enter() (and other procs of the type).
Enter(mob/M) |
Wanabe wrote:
Entered(mob/M) 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 |
Lummox JR wrote:
Wanabe wrote: :-P my bad, :| (haha first time i try help and i get it wrong) :P |
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.
|
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? |
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...
|
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... |
EnjoiStaticX wrote:
when i put it in like this: ... M << "Hot!" M.hp -= 1 M.deathcheck() Tab those three lines once each..that should fix it |
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
|
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 |
heh Nadrew your quicker then me i only just relized that. :p.. Try this:
proc/deathcheck() ...Well im off (going to play some games :-P) |
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. |
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...?