If you can meditate, don't prevent resting while caffienated.
Clarify args and description of gotosleep() vs. fallasleep()
This commit is contained in:
parent
43c20fbbaf
commit
d5254e25aa
11
ai.c
11
ai.c
|
@ -1560,13 +1560,7 @@ int ai_healing(lifeform_t *lf) {
|
||||||
if (ispeaceful(lf) && !isundead(lf)) {
|
if (ispeaceful(lf) && !isundead(lf)) {
|
||||||
int sleepval = 18;
|
int sleepval = 18;
|
||||||
if (modcounter(lf->flags, 1) >= sleepval) {
|
if (modcounter(lf->flags, 1) >= sleepval) {
|
||||||
// we say that this ISNT on purpose, because otherwise
|
if (!gotosleep(lf, B_NOWAKEWHENHEALED)) {
|
||||||
// we'll wake up as soon as we're healed. in this case
|
|
||||||
// we actually want to sleep forever (or until woken).
|
|
||||||
if (!gotosleep(lf, B_FALSE)) {
|
|
||||||
// force this since when not on purpose, gotosleep wont
|
|
||||||
// take time.
|
|
||||||
taketime(lf, getactspeed(lf));
|
|
||||||
return B_TRUE; // success
|
return B_TRUE; // success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1605,8 +1599,7 @@ int ai_healing(lifeform_t *lf) {
|
||||||
} else {
|
} else {
|
||||||
// if it's "night time" for us, sleep forever.
|
// if it's "night time" for us, sleep forever.
|
||||||
// otehrwise just sleep until we're healed
|
// otehrwise just sleep until we're healed
|
||||||
if (!gotosleep(lf, issleepingtimefor(lf) ? B_TRUE : B_FALSE)) {
|
if (!gotosleep(lf, issleepingtimefor(lf) ? B_WAKEWHENHEALED : B_NOWAKEWHENHEALED)) {
|
||||||
taketime(lf, getactspeed(lf)); // to make sure our turn ends
|
|
||||||
return B_TRUE; // success
|
return B_TRUE; // success
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
defs.h
3
defs.h
|
@ -114,6 +114,9 @@
|
||||||
#define B_RETAINATTR (-1)
|
#define B_RETAINATTR (-1)
|
||||||
#define B_MODATTR (0)
|
#define B_MODATTR (0)
|
||||||
|
|
||||||
|
#define B_WAKEWHENHEALED (-1)
|
||||||
|
#define B_NOWAKEWHENHEALED (0)
|
||||||
|
|
||||||
|
|
||||||
// askobject args
|
// askobject args
|
||||||
#define B_DONTINCLUDENOTHING (0)
|
#define B_DONTINCLUDENOTHING (0)
|
||||||
|
|
1
io.c
1
io.c
|
@ -8605,7 +8605,6 @@ void makespellchoicelist(prompt_t *pr, lifeform_t *lf, char *ques, char *ques2,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (includeit) {
|
if (includeit) {
|
||||||
int cost;
|
int cost;
|
||||||
int found = B_FALSE;
|
int found = B_FALSE;
|
||||||
|
|
77
lf.c
77
lf.c
|
@ -6469,7 +6469,8 @@ int fall(lifeform_t *lf, lifeform_t *fromlf, int announce) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// if you are going to sleep on purpose, use 'gotosleep'.
|
// if you are going to sleep on purpose, use 'gotosleep'.
|
||||||
// this function is for when it is forced upon you by a spell, etc.
|
//
|
||||||
|
// this function is for when sleep/unconsciousness is forced upon you by a spell, etc.
|
||||||
int fallasleep(lifeform_t *lf, enum SLEEPTYPE how, int howlong) {
|
int fallasleep(lifeform_t *lf, enum SLEEPTYPE how, int howlong) {
|
||||||
flag_t *f;
|
flag_t *f;
|
||||||
f = lfhasflag(lf, F_ASLEEP);
|
f = lfhasflag(lf, F_ASLEEP);
|
||||||
|
@ -6481,15 +6482,17 @@ int fallasleep(lifeform_t *lf, enum SLEEPTYPE how, int howlong) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((how == ST_ASLEEP) && lfhasflag(lf, F_CAFFEINATED)) {
|
if (how == ST_ASLEEP) {
|
||||||
if (isplayer(lf)) {
|
if (lfhasflag(lf, F_CAFFEINATED) || isundead(lf)) {
|
||||||
msg("You feel momentarily tired.");
|
if (isplayer(lf)) {
|
||||||
} else if (cansee(player, lf)) {
|
msg("You feel momentarily tired.");
|
||||||
char lfname[BUFLEN];
|
} else if (cansee(player, lf)) {
|
||||||
getlfname(lf, lfname);
|
char lfname[BUFLEN];
|
||||||
msg("%s looks momentarily tired.", lfname);
|
getlfname(lf, lfname);
|
||||||
|
msg("%s looks momentarily tired.", lfname);
|
||||||
|
}
|
||||||
|
return B_TRUE;
|
||||||
}
|
}
|
||||||
return B_TRUE;
|
|
||||||
}
|
}
|
||||||
loseconcentration(lf);
|
loseconcentration(lf);
|
||||||
interrupt(lf);
|
interrupt(lf);
|
||||||
|
@ -13514,37 +13517,47 @@ void givestartskills(lifeform_t *lf, flagpile_t *fp) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int gotosleep(lifeform_t *lf, int onpurpose) {
|
// go to sleep/rest/start meditating on purpose. If from a spell effect etc, use fallasleep().
|
||||||
|
int gotosleep(lifeform_t *lf, int wakewhenhealed) {
|
||||||
char lightid[BUFLEN];
|
char lightid[BUFLEN];
|
||||||
strcpy(lightid, "");
|
strcpy(lightid, "");
|
||||||
if (lfhasflag(lf, F_CAFFEINATED)) {
|
if (!lfhasflag(lf, F_MEDITATES)) {
|
||||||
if (isplayer(lf)) {
|
if (isundead(lf)) {
|
||||||
msg("Your caffeine high prevents you from sleeping.");
|
if (isplayer(lf)) {
|
||||||
|
msg("The undead do not require sleep!");
|
||||||
|
}
|
||||||
|
return B_TRUE;
|
||||||
|
}
|
||||||
|
if (lfhasflag(lf, F_CAFFEINATED)) {
|
||||||
|
if (isplayer(lf)) {
|
||||||
|
msg("Your caffeine high prevents you from sleeping.");
|
||||||
|
}
|
||||||
|
return B_TRUE;
|
||||||
}
|
}
|
||||||
return B_TRUE;
|
|
||||||
}
|
}
|
||||||
if (onpurpose) {
|
|
||||||
taketime(lf, getactspeed(lf));
|
taketime(lf, getactspeed(lf));
|
||||||
if (getattrbracket(getattr(lf, A_WIS), A_WIS, NULL) >= AT_GTAVERAGE) {
|
|
||||||
object_t *o;
|
if (getattrbracket(getattr(lf, A_WIS), A_WIS, NULL) >= AT_GTAVERAGE) {
|
||||||
// turn off light sources first
|
object_t *o;
|
||||||
for (o = lf->pack->first ; o ; o = o->next) {
|
// turn off light sources first
|
||||||
if (hasflag(o->flags, F_LIGHTSOURCE) && hasflag(o->flags, F_ACTIVATED)) {
|
for (o = lf->pack->first ; o ; o = o->next) {
|
||||||
if (!strlen(lightid)) {
|
if (hasflag(o->flags, F_LIGHTSOURCE) && hasflag(o->flags, F_ACTIVATED)) {
|
||||||
// first one.
|
if (!strlen(lightid)) {
|
||||||
if (isplayer(lf)) {
|
// first one.
|
||||||
char ch;
|
if (isplayer(lf)) {
|
||||||
ch = askchar("Turn off your light sources before resting?", "yn","y", B_TRUE, B_FALSE);
|
char ch;
|
||||||
if (ch != 'y') break;
|
ch = askchar("Turn off your light sources before resting?", "yn","y", B_TRUE, B_FALSE);
|
||||||
}
|
if (ch != 'y') break;
|
||||||
sprintf(lightid, "%ld", o->id);
|
|
||||||
}
|
}
|
||||||
turnoff(lf, o);
|
sprintf(lightid, "%ld", o->id);
|
||||||
}
|
}
|
||||||
|
turnoff(lf, o);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
addflag(lf->flags, F_ASLEEP, B_TRUE, lfhasflag(lf, F_MEDITATES) ? ST_MEDITATING : ST_ASLEEP, onpurpose ? B_TRUE : NA, lightid);
|
|
||||||
|
addflag(lf->flags, F_ASLEEP, B_TRUE, lfhasflag(lf, F_MEDITATES) ? ST_MEDITATING : ST_ASLEEP, wakewhenhealed ? B_TRUE : NA, lightid);
|
||||||
return B_FALSE;
|
return B_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20955,7 +20968,7 @@ int startresting(lifeform_t *lf, int willtrain) {
|
||||||
addflag(lf->flags, F_TRAINING, 0, traincounter, NA, NULL);
|
addflag(lf->flags, F_TRAINING, 0, traincounter, NA, NULL);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (gotosleep(lf, B_TRUE)) {
|
if (gotosleep(lf, B_WAKEWHENHEALED)) {
|
||||||
// failed
|
// failed
|
||||||
return B_TRUE;
|
return B_TRUE;
|
||||||
}
|
}
|
||||||
|
|
2
lf.h
2
lf.h
|
@ -331,7 +331,7 @@ flag_t *giveskilllev(lifeform_t *lf, enum SKILL id, enum SKILLLEVEL slev);
|
||||||
void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp);
|
void givestartobs(lifeform_t *lf, object_t *targob, flagpile_t *fp);
|
||||||
void givestartskills(lifeform_t *lf, flagpile_t *fp);
|
void givestartskills(lifeform_t *lf, flagpile_t *fp);
|
||||||
map_t *gotolev(lifeform_t *lf, int depth, object_t *fromstairs);
|
map_t *gotolev(lifeform_t *lf, int depth, object_t *fromstairs);
|
||||||
int gotosleep(lifeform_t *lf, int onpurpose);
|
int gotosleep(lifeform_t *lf, int wakewhenhealed);
|
||||||
void growhydrahead(lifeform_t *lf, int announce);
|
void growhydrahead(lifeform_t *lf, int announce);
|
||||||
void losehydrahead(lifeform_t *lf);
|
void losehydrahead(lifeform_t *lf);
|
||||||
flag_t *hasbleedinginjury(lifeform_t *lf, enum BODYPART bp);
|
flag_t *hasbleedinginjury(lifeform_t *lf, enum BODYPART bp);
|
||||||
|
|
Loading…
Reference in New Issue