Name the lamp, grate, and bird states.

This commit is contained in:
Eric S. Raymond 2017-06-23 14:21:25 -04:00
parent 2848494a01
commit ecff53d3a8
4 changed files with 33 additions and 30 deletions

View file

@ -42,7 +42,6 @@ static int attack(FILE *input, struct command_t *command)
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
DESTROY(BIRD); DESTROY(BIRD);
game.prop[BIRD] = 0;
spk = BIRD_DEAD; spk = BIRD_DEAD;
} else if (obj == VEND) { } else if (obj == VEND) {
pspeak(VEND, game.prop[VEND] + 2); pspeak(VEND, game.prop[VEND] + 2);
@ -259,8 +258,8 @@ static int carry(token_t verb, token_t obj)
if (game.holdng >= INVLIMIT) { if (game.holdng >= INVLIMIT) {
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} else if (obj == BIRD && game.prop[BIRD] != 1 && -1 - game.prop[BIRD] != 1) { } else if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) {
if (game.prop[BIRD] == 2) { if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) {
DESTROY(BIRD); DESTROY(BIRD);
rspeak(BIRD_CRAP); rspeak(BIRD_CRAP);
return GO_CLEAROBJ; return GO_CLEAROBJ;
@ -271,9 +270,9 @@ static int carry(token_t verb, token_t obj)
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.prop[BIRD] = 1; game.prop[BIRD] = BIRD_CAGED;
} }
if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == 1 || -1 - game.prop[BIRD] == 1)) if ((obj == BIRD || obj == CAGE) && (game.prop[BIRD] == BIRD_CAGED || -1 - game.prop[BIRD] == 1))
CARRY(BIRD + CAGE - obj, game.loc); CARRY(BIRD + CAGE - obj, game.loc);
CARRY(obj, game.loc); CARRY(obj, game.loc);
if (obj == BOTTLE && LIQUID() != 0) if (obj == BOTTLE && LIQUID() != 0)
@ -362,7 +361,6 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
} else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) { } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == 0) {
rspeak(BIRD_BURNT); rspeak(BIRD_BURNT);
DESTROY(BIRD); DESTROY(BIRD);
game.prop[BIRD] = 0;
return GO_CLEAROBJ; return GO_CLEAROBJ;
} else if (obj == BEAR && AT(TROLL)) { } else if (obj == BEAR && AT(TROLL)) {
rspeak(TROLL_SCAMPERS); rspeak(TROLL_SCAMPERS);
@ -385,11 +383,13 @@ static int discard(token_t verb, token_t obj, bool just_do_it)
if (k == obj)obj = BOTTLE; if (k == obj)obj = BOTTLE;
if (obj == BOTTLE && k != 0) if (obj == BOTTLE && k != 0)
game.place[k] = LOC_NOWHERE; game.place[k] = LOC_NOWHERE;
if (obj == CAGE && game.prop[BIRD] == 1)DROP(BIRD, game.loc); if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED)
DROP(BIRD, game.loc);
DROP(obj, game.loc); DROP(obj, game.loc);
if (obj != BIRD) return GO_CLEAROBJ; if (obj != BIRD) return GO_CLEAROBJ;
game.prop[BIRD] = 0; game.prop[BIRD] = BIRD_UNCAGED;
if (FOREST(game.loc))game.prop[BIRD] = 2; if (FOREST(game.loc))
game.prop[BIRD] = BIRD_FOREST_UNCAGED;
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
@ -445,7 +445,8 @@ static int extinguish(token_t verb, int obj)
{ {
int spk = ACTSPK[verb]; int spk = ACTSPK[verb];
if (obj == INTRANSITIVE) { if (obj == INTRANSITIVE) {
if (HERE(LAMP) && game.prop[LAMP] == 1)obj = LAMP; if (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT)
obj = LAMP;
if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN; if (HERE(URN) && game.prop[URN] == 2)obj = obj * NOBJECTS + URN;
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN; if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
} }
@ -454,7 +455,7 @@ static int extinguish(token_t verb, int obj)
game.prop[URN] = game.prop[URN] / 2; game.prop[URN] = game.prop[URN] / 2;
spk = URN_DARK; spk = URN_DARK;
} else if (obj == LAMP) { } else if (obj == LAMP) {
game.prop[LAMP] = 0; game.prop[LAMP] = LAMP_DARK;
rspeak(LAMP_OFF); rspeak(LAMP_OFF);
spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE; spk = DARK(game.loc) ? PITCH_DARK : NO_MESSAGE;
} else if (obj == DRAGON || obj == VOLCANO) } else if (obj == DRAGON || obj == VOLCANO)
@ -477,7 +478,6 @@ static int feed(token_t verb, token_t obj)
if (obj == TROLL)spk = TROLL_VICES; if (obj == TROLL)spk = TROLL_VICES;
if (obj == SNAKE && !game.closed && HERE(BIRD)) { if (obj == SNAKE && !game.closed && HERE(BIRD)) {
DESTROY(BIRD); DESTROY(BIRD);
game.prop[BIRD] = 0;
spk = BIRD_DEVOURED; spk = BIRD_DEVOURED;
} }
} else if (obj == DWARF) { } else if (obj == DWARF) {
@ -638,7 +638,8 @@ static int light(token_t verb, token_t obj)
{ {
int spk = ACTSPK[verb]; int spk = ACTSPK[verb];
if (obj == INTRANSITIVE) { if (obj == INTRANSITIVE) {
if (HERE(LAMP) && game.prop[LAMP] == 0 && game.limit >= 0)obj = LAMP; if (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0)
obj = LAMP;
if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN; if (HERE(URN) && game.prop[URN] == 1)obj = obj * NOBJECTS + URN;
if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN; if (obj == INTRANSITIVE || obj == 0 || obj > NOBJECTS) return GO_UNKNOWN;
} }
@ -661,7 +662,7 @@ static int light(token_t verb, token_t obj)
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
game.prop[LAMP] = 1; game.prop[LAMP] = LAMP_BRIGHT;
rspeak(LAMP_ON); rspeak(LAMP_ON);
if (game.wzdark) if (game.wzdark)
return GO_TOP; return GO_TOP;
@ -731,7 +732,7 @@ static int lock(token_t verb, token_t obj)
if (!game.panic)game.clock2 = PANICTIME; if (!game.panic)game.clock2 = PANICTIME;
game.panic = true; game.panic = true;
} else { } else {
game.prop[GRATE] = (verb == LOCK) ? 0 : 1; game.prop[GRATE] = (verb == LOCK) ? GRATE_CLOSED : GRATE_OPEN;
spk = game.prop[GRATE] ? GRATE_UNLOCKED : GRATE_LOCKED; spk = game.prop[GRATE] ? GRATE_UNLOCKED : GRATE_LOCKED;
} }
} }
@ -968,7 +969,9 @@ static int wave(token_t verb, token_t obj)
rspeak(spk); rspeak(spk);
return GO_CLEAROBJ; return GO_CLEAROBJ;
} }
if (HERE(BIRD))spk = FREE_FLY + MOD(game.prop[BIRD], 2); /* FIXME: Arithemetic on proprty values */
if (HERE(BIRD))
spk = FREE_FLY + MOD(game.prop[BIRD], 2);
if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) {
DROP(JADE, game.loc); DROP(JADE, game.loc);
game.prop[JADE] = 0; game.prop[JADE] = 0;

View file

@ -152,7 +152,7 @@ extern int restore(FILE *);
#define LIQLOC(LOC) (LIQ2((MOD(conditions[LOC]/2*2,8)-5)*MOD(conditions[LOC]/4,2)+1)) #define LIQLOC(LOC) (LIQ2((MOD(conditions[LOC]/2*2,8)-5)*MOD(conditions[LOC]/4,2)+1))
#define CNDBIT(L,N) (TSTBIT(conditions[L],N)) #define CNDBIT(L,N) (TSTBIT(conditions[L],N))
#define FORCED(LOC) CNDBIT(LOC, COND_FORCED) #define FORCED(LOC) CNDBIT(LOC, COND_FORCED)
#define DARK(DUMMY) ((!TSTBIT(conditions[game.loc],COND_LIT)) && (game.prop[LAMP] == 0 || !HERE(LAMP))) #define DARK(DUMMY) ((!TSTBIT(conditions[game.loc],COND_LIT)) && (game.prop[LAMP] == LAMP_DARK || !HERE(LAMP)))
#define PCT(N) (randrange(100) < (N)) #define PCT(N) (randrange(100) < (N))
#define GSTONE(OBJ) ((OBJ) == EMERALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH) #define GSTONE(OBJ) ((OBJ) == EMERALD || (OBJ) == RUBY || (OBJ) == AMBER || (OBJ) == SAPPH)
#define FOREST(LOC) CNDBIT(LOC, COND_FOREST) #define FOREST(LOC) CNDBIT(LOC, COND_FOREST)

View file

@ -1484,13 +1484,13 @@ object_descriptions: !!omap
- OBJ_2: - OBJ_2:
inventory: 'Brass lantern' inventory: 'Brass lantern'
longs: longs:
- 'There is a shiny brass lamp nearby.' - [LAMP_DARK, 'There is a shiny brass lamp nearby.']
- 'There is a lamp shining nearby.' - [LAMP_BRIGHT, 'There is a lamp shining nearby.']
- OBJ_3: - OBJ_3:
inventory: '*grate' inventory: '*grate'
longs: longs:
- 'The grate is locked.' - [GRATE_CLOSED, 'The grate is locked.']
- 'The grate is open.' - [GRATE_OPEN, 'The grate is open.']
- OBJ_4: - OBJ_4:
inventory: 'Wicker cage' inventory: 'Wicker cage'
longs: longs:
@ -1511,9 +1511,9 @@ object_descriptions: !!omap
- OBJ_8: - OBJ_8:
inventory: 'Little bird in cage' inventory: 'Little bird in cage'
longs: longs:
- 'A cheerful little bird is sitting here singing.' - [BIRD_UNCAGED, 'A cheerful little bird is sitting here singing.']
- 'There is a little bird in the cage.' - [BIRD_CAGED, 'There is a little bird in the cage.']
- 'A cheerful little bird is sitting here singing.' - [BIRD_FOREST_UNCAGED, 'A cheerful little bird is sitting here singing.']
- 'The bird''s singing is quite melodious.' - 'The bird''s singing is quite melodious.'
- 'The bird does not seem inclined to sing while in the cage.' - 'The bird does not seem inclined to sing while in the cage.'
- 'It almost seems as though the bird is trying to tell you something.' - 'It almost seems as though the bird is trying to tell you something.'

12
main.c
View file

@ -203,7 +203,7 @@ static void checkhints(void)
switch (hint) { switch (hint) {
case 0: case 0:
/* cave */ /* cave */
if (game.prop[GRATE] == 0 && !HERE(KEYS)) if (game.prop[GRATE] == GRATE_CLOSED && !HERE(KEYS))
break; break;
game.hintlc[hint] = 0; game.hintlc[hint] = 0;
return; return;
@ -303,7 +303,7 @@ static bool spotted_by_pirate(int i)
} }
} }
/* Force chest placement before player finds last treasure */ /* Force chest placement before player finds last treasure */
if (game.tally == 1 && snarfed == 0 && game.place[CHEST] == LOC_NOWHERE && HERE(LAMP) && game.prop[LAMP] == 1) { if (game.tally == 1 && snarfed == 0 && game.place[CHEST] == LOC_NOWHERE && HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT) {
rspeak(PIRATE_SPOTTED); rspeak(PIRATE_SPOTTED);
movechest = true; movechest = true;
} }
@ -501,7 +501,7 @@ static void croak(void)
else { else {
game.place[WATER] = game.place[OIL] = LOC_NOWHERE; game.place[WATER] = game.place[OIL] = LOC_NOWHERE;
if (TOTING(LAMP)) if (TOTING(LAMP))
game.prop[LAMP] = 0; game.prop[LAMP] = LAMP_DARK;
for (int j = 1; j <= NOBJECTS; j++) { for (int j = 1; j <= NOBJECTS; j++) {
int i = NOBJECTS + 1 - j; int i = NOBJECTS + 1 - j;
if (TOTING(i)) { if (TOTING(i)) {
@ -761,7 +761,7 @@ static bool closecheck(void)
* know the bivalve is an oyster. *And*, the dwarves must * know the bivalve is an oyster. *And*, the dwarves must
* have been activated, since we've found chest. */ * have been activated, since we've found chest. */
if (game.clock1 == 0) { if (game.clock1 == 0) {
game.prop[GRATE] = 0; game.prop[GRATE] = GRATE_CLOSED;
game.prop[FISSURE] = 0; game.prop[FISSURE] = 0;
for (int i = 1; i <= NDWARVES; i++) { for (int i = 1; i <= NDWARVES; i++) {
game.dseen[i] = false; game.dseen[i] = false;
@ -839,7 +839,7 @@ static bool closecheck(void)
static void lampcheck(void) static void lampcheck(void)
/* Check game limit and lamp timers */ /* Check game limit and lamp timers */
{ {
if (game.prop[LAMP] == 1) if (game.prop[LAMP] == LAMP_BRIGHT)
--game.limit; --game.limit;
/* Another way we can force an end to things is by having the /* Another way we can force an end to things is by having the
@ -857,7 +857,7 @@ static void lampcheck(void)
game.lmwarn = false; game.lmwarn = false;
} else if (game.limit == 0) { } else if (game.limit == 0) {
game.limit = -1; game.limit = -1;
game.prop[LAMP] = 0; game.prop[LAMP] = LAMP_DARK;
if (HERE(LAMP)) if (HERE(LAMP))
rspeak(LAMP_OUT); rspeak(LAMP_OUT);
} else if (game.limit <= WARNTIME) { } else if (game.limit <= WARNTIME) {