ID:178098
 
mob
New()
..()
proc/Heal()
if(vitality<=0) healing()//call the hospital proc here
vitality=min(vitality+1,max_vitality)
spawn(healtime-recovery) Heal()



//These are the hospital turfs

turf/medic
icon = 'hospital.dmi'
var/healrate = 1
Free
Normal
healrate = 3
Advanced
healrate = 4
Minimal
healrate = 2


How can I make it so that if the person is healing in a hospital bed, they gain more "vitality" in the heal loop. Like if I am in a advanced bed, I get 4 more "vitality" per healing loop, but not have it go over the max_vitality var?
Sariat wrote:
How can I make it so that if the person is healing in a hospital bed, they gain more "vitality" in the heal loop. Like if I am in a advanced bed, I get 4 more "vitality" per healing loop, but not have it go over the max_vitality var?

Because you're already sensibly using min() to restrict vitality to max_vitality, just replace vitality+1 with vitalith+theturf.healrate. You've already ensured it won't go over the limit with the min() call.

Lummox JR
In response to Lummox JR
mob
proc/HealLoop()
var/turf/medic/theturf
if(vitality<=0) healing()
if(get_turf(theturf))
vitality=min(vitality+theturf.healrate,max_vitality)
if(!usr.inhospital)
vitality=min(vitality+1,max_vitality)
spawn(healtime-recovery) HealLoop()



proc/hospital(var/turf/T)//the hospital proc
world << "hospital proc running..."
for(T in world)
world << "checking"
if(locate(/mob) in T.contents)
continue
else
usr << "You have made it into a hospital bed!"
usr.loc = T
usr.inhospital = 1
break

mob/proc/healing()//selects which type of hospital plan they want to do
var/type = input("What type of healing do you want?") in list("Minimal","Normal","Advanced","Free")
switch(type)
if("Minimal")
hospital(/turf/medic/Minimal)
if("Normal")
hospital(/turf/medic/Normal)
if("Advanced")
hospital(/turf/medic/Advanced)
if("Free")
hospital(/turf/medic/Free)

<dm>

Thats all the hospital stuff, this is how I get the turf:

<dm>
//got this from Skysaw

proc
get_turf(atom/where) // very useful for other things as well
while(isloc(where))
if(isturf(where))
return where
where = where.loc
return null


Okay, the hospital proc is NOT taking me anywhere.... just to 1,1,1..... Help?
In response to Sariat
Sariat wrote:
mob
proc/hospital(var/turf/T)//the hospital proc
world << "hospital proc running..."
for(T in world)
world << "checking"
if(locate(/mob) in T.contents)
continue
else
usr << "You have made it into a hospital bed!"
usr.loc = T
usr.inhospital = 1
break

Okay, the hospital proc is NOT taking me anywhere.... just to 1,1,1..... Help?

Your problem is in the loop above.

First problem: You're not using the T var for the hospital() proc at all; you discard it as soon as you enter the loop.

Second problem: Because you're not looping through turf/hospital or some such, but just ordinary turfs, the loop will check every single turf in the world.

Third problem: You're using usr instead of src; usr is absolutely wrong here and will probably fail horrifically in multiplayer (if this is a response to a death in battle, anyway). Since src is the mob that's going to a hospital bed, you don't need to use usr at all.

What you're probably best off doing is putting all your bed turfs in a special area for the hospital, and then loop through every such area in the world and try to Move() into it--choosing an empty bed for you automatically.
mob
proc/hospital()
for(var/area/hospital/A in world)
if(Move(A))
src << "You have made it into a hospital bed!"
inhospital = 1
return

area/hospital
Enter(atom/movable/A)
// don't allow anyone to just walk onto a bed
if(A.loc && A.loc.loc && istype(A.loc.loc,/area/hospital_floor))
return 0
return ..()

area/hospital_floor // just outside a bed

Lummox JR
In response to Lummox JR
//this is a mob proc, called on mob/New()

proc/HealLoop()
if(vitality<=0) healing()
if(src.loc.loc == locate(var/area/medic/theturf))//TRYING to see if they are on a medical area
vitality=min(vitality+theturf.healrate,max_vitality)
if(!usr.inhospital)
vitality=min(vitality+1,max_vitality)
spawn(healtime-recovery) HealLoop()


What im trying to do there is making so that if you are on a medical area, you gain that area's healrate on your recovery.

So that if im on a super duper advanced bed with a healrate of 5, I gain 5 extra health during the time that I'm on that bed.

Thanks for the help,

ST