Trying to get a loop to work in Developer Help
|
|
Code:
proc/sdecline(obj/sickbed/B as obj in oview(0)) if(B.health==3) B.health=1 B.hurtpoints += B.declinerate usr << "The patients condition is steadily declining." if(B.critical <= B.hurtpoints) B.icon_state="2" B.sick = 0 usr << "<font size = 6></font><font color=red> <b>You've lost the patient...</b></font>" usr.exp -=B.exp usr << " You've lost [B.exp] experience." sleep(200) B.icon_state="1" B.sick=1 B.hurtpoints=B.startinghurtpoints B.health=0 else sleep(50) B.health=3 sdecline() else if(B.health==0) B.health=3 usr<< "B.health==3" sdecline() else if(B.health==1) usr << "B.health==1"
|
So just trying to get this loop to work basically you start working on a patient, I have most of the other mechanics working just trying to get a timed decline of the patients health to work which just won't do anything when it's called. Basically this proc is being called but doing nothing. The action that triggers it to begin can be called on more than once so I didn't want it to cumulatively add more instances of the loop, I'm kinda out of it today though so I may be missing some obvious errors, I threw in the messages at different steps to see what was going on but they aren't outputting at all.
Got it working referring to how my weather effects work but I'm sure my method is crap so go ahead and let me know why lol.
obj sickbed proc decline() if(declining==1 && sick==1) declining=2 hurtpoints += declinerate usr << "The patient is slipping away." if(critical <= hurtpoints) icon_state="2" sick = 0 usr << "<font size = 6></font><font color=red> <b>You've lost the patient...</b></font>" usr.exp -=exp usr << " You've lost [exp] experience." sleep(200) icon_state="1" sick=1 hurtpoints=startinghurtpoints declining=0 else sleep(50) declining=1 decline() else if(declining==0) declining=1 decline() else if(declining==2) usr << "" else usr << ""
obj sickbed layer = MOB_LAYER+1 noenterdirs = NORTH noexitdirs = SOUTH var/sick = 1 var/hurtpoints = 0 var/exp = 0 var/credits = 0 var/critical = 0 var/startinghurtpoints = 0 var/declining=0 var/declinerate=0
Pathogen_Transformer icon='artifact.dmi' carried2=1 proc Transform_Pathogen(obj/sickbed/B as obj in oview(0)) set category="Psionic" if(B.sick ==1) for(var/obj/sickbed/S in oview(0)) spawn() S.decline()
|
This works pretty well, if I die it continues to run until the patient dies but that's fine for me, I'm sure I could work out a way to stop it running in that case as well if I want to. The vars at the end are general, each bed is specific with differences in the critical, startinghurtpoints, declinerate, hurtpoints, exp, and credits.
mike
|