X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=actions.c;h=59ec428f506127b5b2612f282ca34e5da5b31c44;hb=3d5c7239f1c71b9531cb078520a5b619d4200891;hp=fdd1c9341e1fb911ac000fbe6241699638115dc5;hpb=92de4856a6b7f9889e72faa1fc30a78526a97758;p=open-adventure.git diff --git a/actions.c b/actions.c index fdd1c93..59ec428 100644 --- a/actions.c +++ b/actions.c @@ -7,6 +7,7 @@ static int fill(token_t, token_t); static void state_change(long obj, long state) +/* Object must have a change-message list for this to be useful; only some do */ { game.prop[obj] = state; pspeak(obj, change, state, true); @@ -361,7 +362,7 @@ static int vcarry(token_t verb, token_t obj) } - if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && -1 - game.prop[BIRD] != BIRD_CAGED) { + if (obj == BIRD && game.prop[BIRD] != BIRD_CAGED && STASHED(BIRD) != BIRD_CAGED) { if (game.prop[BIRD] == BIRD_FOREST_UNCAGED) { DESTROY(BIRD); rspeak(BIRD_CRAP); @@ -377,18 +378,16 @@ static int vcarry(token_t verb, token_t obj) } game.prop[BIRD] = BIRD_CAGED; } - /* FIXME: Arithmetic on state numbers */ if ((obj == BIRD || obj == CAGE) && - (game.prop[BIRD] == BIRD_CAGED || - -1 - game.prop[BIRD] == 1)) + (game.prop[BIRD] == BIRD_CAGED || STASHED(BIRD) == BIRD_CAGED)) + /* expression maps BIRD to CAGE and CAGE to BIRD */ carry(BIRD + CAGE - obj, game.loc); carry(obj, game.loc); if (obj == BOTTLE && LIQUID() != NO_OBJECT) game.place[LIQUID()] = CARRIED; - if (GSTONE(obj) && game.prop[obj] != 0) { - game.prop[obj] - = STATE_GROUND; + if (GSTONE(obj) && game.prop[obj] != STATE_FOUND) { + game.prop[obj] = STATE_FOUND; game.prop[CAVITY] = CAVITY_EMPTY; } rspeak(OK_MAN); @@ -451,7 +450,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) if (TOTING(ROD2) && obj == ROD && !TOTING(ROD)) obj = ROD2; if (!TOTING(obj)) { - rspeak(actions[verb].message;); + rspeak(actions[verb].message); return GO_CLEAROBJ; } if (obj == BIRD && HERE(SNAKE)) { @@ -464,7 +463,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) } else if ((GSTONE(obj) && AT(CAVITY) && game.prop[CAVITY] != CAVITY_FULL)) { rspeak(GEM_FITS); - game.prop[obj] = 1; + game.prop[obj] = STATE_IN_CAVITY; game.prop[CAVITY] = CAVITY_FULL; if (HERE(RUG) && ((obj == EMERALD && game.prop[RUG] != RUG_HOVER) || (obj == RUBY && game.prop[RUG] == RUG_HOVER))) { @@ -478,7 +477,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) /* FIXME: Arithmetic on state numbers */ int k = 2 - game.prop[RUG]; game.prop[RUG] = k; - if (k == 2) + if (k == RUG_HOVER) k = objects[SAPPH].plac; move(RUG + NOBJECTS, k); } @@ -503,10 +502,9 @@ static int discard(token_t verb, token_t obj, bool just_do_it) game.loc == objects[PILLOW].plac) { rspeak(OK_MAN); } else { - game.prop[VASE] = VASE_BROKEN; - if (AT(PILLOW)) - game.prop[VASE] = VASE_WHOLE; - pspeak(VASE, look, game.prop[VASE] + 1, true); + state_change(VASE, AT(PILLOW) + ? VASE_WHOLE + : VASE_DROPPED); if (game.prop[VASE] != VASE_WHOLE) game.fixed[VASE] = -1; } @@ -663,7 +661,7 @@ static int feed(token_t verb, token_t obj) DESTROY(FOOD); game.prop[BEAR] = SITTING_BEAR; game.fixed[AXE] = 0; - game.prop[AXE] = 0; + game.prop[AXE] = AXE_HERE; spk = BEAR_TAMED; } } else if (obj == OGRE) { @@ -692,7 +690,7 @@ int fill(token_t verb, token_t obj) rspeak(SHATTER_VASE); game.prop[VASE] = VASE_BROKEN; game.fixed[VASE] = -1; - return (discard(verb, obj, true)); + return (discard(verb, VASE, true)); } if (obj == URN) { @@ -1111,7 +1109,6 @@ static int say(struct command_t *command) char word1[TOKLEN + 1]; packed_to_token(command->wd1, word1); int wd = (int) get_vocab_id(word1); - /* FIXME: magic numbers */ if (wd == MOTION_WORD(XYZZY) || wd == MOTION_WORD(PLUGH) || wd == MOTION_WORD(PLOVER) || @@ -1138,8 +1135,6 @@ static int throw (struct command_t *command) * (Only way to do so!) Axe also special for dragon, bear, and * troll. Treasures special for troll. */ { - if (TOTING(ROD2) && command->obj == ROD && !TOTING(ROD)) - command->obj = ROD2; if (!TOTING(command->obj)) { rspeak(actions[command->verb].message); return GO_CLEAROBJ; @@ -1225,7 +1220,7 @@ static int wave(token_t verb, token_t obj) if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { drop(JADE, game.loc); - game.prop[JADE] = 0; + game.prop[JADE] = STATE_FOUND; --game.tally; rspeak(NECKLACE_FLY); return GO_CLEAROBJ;