mob/verb/Rest()
var/image/Rest = new('Resting Overlay.dmi')
Rest.appearance_flags = RESET_COLOR
if(src.resting)
src.overlays -= Rest
src.busy = 0
src.resting = 0
src << ">> You stop resting."
return
if(src.busy)
return
src.overlays += Rest
src.busy = 1
src << ">> You begin to rest."
src.resting = 1
while(src.resting)
sleep(20)
if(src.resting)
src.stamina += 2
if(src.stamina >= 100)
src.stamina = 100
for(var/turf/Tiles/T027 in oview(0,src))
src.hp_min += 2
if(src.hp_min >= src.hp_max)
src.hp_min = src.hp_max
src.mp_min += 2
if(src.mp_min >= src.mp_max)
src.mp_min = src.mp_max
Problem description:
Intent: When a player rests anywhere besides on turf T027 (bed), all they recover is stamina. While on T027, they also recover hp and mp. The current above example acts as if you are always on T027, regardless of where you are.
I also tried if(src in /turf/Tiles/T027) instead of for(var/turf/Tiles/T027 in oview(0,src)), which compiles fine but does not recover hp or mp.
I am wondering if perhaps I should be using a defined area instead on the map, but thought if I can just check for the specific turf, what's the point of making a special area?
if(istype(src.loc,/turf/Tiles/T027))
Is probably the easiest way to do it (loc is the turf you're standing on if you're on a turf).
HOWEVER, having something like a bed be a turf and not an obj is probably a bad design choice that's gonna bite you in the butt down the road.