Action RPG Framework

by Forum_account
Action RPG Framework
A framework for developing action RPGs.
ID:789903
 
turf

land1
icon = 'icons/land1.dmi'
lava
icon_state = "L1_Lava"
Entered(atom/a)
..(a)
if(ismob(a))
var/mob/m = a
var/lost = 5
m.health -= lost
m << "You fell in lava; you lost [lost] hit points."


this code works great in my learning project, but does not work in the demo game. could this be a focus issue again. if so, could you lead me in the right direction. perhaps a small tutor would be great.
Does that code not work at all? This might be a problem with how the Entered proc is handled by the Pixel Movement library. You cam try changing Entered to stepped_on - that's a proc that's defined by the Pixel Movement library that is similar to Entered.

Also, when you change a mob's health you need to use the set_health() proc. That's the proc that causes the health meter to update and checks if the mob died. The line of code should be: m.set_health(m.health - lost)
yes, that code does not work at all. the Pixel Movement library was unchecked when tested. then it was checked with no different result. the stepped_on proc works fine.

please verify

Edit: also, it seems that the "Enter" proc is broken

also, with this line of code you gave me, when i added it to the stepped_on proc and ran the code, i am getting an error when the hit points is below 0.

m.set_health(m.health - lost)


to fix the error, i think the code should be...

m.set_health(m.health - lost,m)
In response to Kalster
What you could also do is use the mob's lose_health(lost, attacker) proc. It's the same thing, but it's a bit more clear.

I see the problem in die(), where it calls attacker.killed(src). It isn't expecting a null attacker, since the lava damage is an environmental thing rather than an actual attack.
yes. i seemed to fix the error with...
m.lose_health(lost,m)

where m is the attacker. the problem with that is i get a message "You gain 0 XP and $0." just before the die proc is ran. i need to run the code as follows but that would give the error but stop the message "You gain 0 XP and $0." from displaying

m.lose_health(lost)


there is also an issue that the respawn proc does not stop the movement of the mob for those two seconds of wait, the mob can still walk on the lava and get more messages about lava hit point lose.
Ok, I'll make some changes to the library to make it handle this better. I'll make the lose_health proc return the amount of health lost so you can say if(m.lose_health(lost)) so you'll know when the player actually takes damage. You could also check if(!m.dead) before inflicting damage. I'll also make sure all of the procs handle a null attacker.

I won't be able to make these changes for a few days yet. I'll try to remember to post here to let you know its been updated.
that would be great. also, please make a reminder to see what is happening to the enter and entered proc. cheers!
I have some changes to how the entered proc will work when you're using the Pixel Movement library, I just haven't posted them yet.
hi Forum_account. at this topic we were talking about the entered proc not working in pixel movement library. it seems you fixed it since then but the enter proc is still not working please verify. just thought i would post it here instead of the pixel movement forum since we were talking about those issues here
With the Pixel Movement library you use the mob's can_bump proc to determine what objects they can bump into and which ones they can pass through.
turf
land1
lava
can_bump(atom/a)
if(a:can_walk)
world << "walking"
return 0
else
return ..()


error: can_bump: undefined proc.
i don't know why i am getting this error for the can_bump proc. the library is enabled
The can_bump proc belongs to mobs, so you'd do it like this:

mob
can_bump(turf/land1/lava/t)
if(istype(t))
if(can_walk)
return 0
return ..()
the lava turf has a stepped_on proc that should not be executed when a condition is met. with your code, a usr can still walk on the lava because the code is outside of the lava turf.

what i really need is the enter proc to be fixed or an alternative proc that can stop the executing of the stepped_on proc inside of the lava turf

here is the full code
turf
land1
lava
can_bump(atom/a)
if(O:can_walk)
world << "walking"
return 0
else
return ..()
icon = 'lava.dmi'
stepped_on(atom/a)
..(a)
if(ismob(a))
var/mob/m = a
var/lost = 5
if(!m.dead)
m << "You fell in lava; you lost [lost] hit points."
m.lose_health(lost,m)
You're still putting the can_bump() proc underneath the turf. It needs to be under the mob instead:

mob
can_bump(turf/land1/lava/l)
if(istype(l))
if(can_walk)
return 0
return ..()

turf
land1
lava
icon = 'lava.dmi'

stepped_on(mob/m)
var/lost = 5
if(!m.dead)
m << "You fell in lava; you lost [lost] hit points."
m.lose_health(lost, m)
yes that is what i did. the code i gave was only to show what i am trying to do. with the code you just gave me, it does not work. the stepped_on proc is still executed
can_bump is conceptually the opposite of Enter. Enter() returns 1 if you're allowed to step on it, can_bump() returns 1 if you should bump into the turf instead of walking on it. Make sure those return values are correct.
it works. thank you