X-Git-Url: https://jxself.org/git/?p=open-adventure.git;a=blobdiff_plain;f=actions.c;h=abe9e5bb38ef2eac3a9b3e481bbbf1445c648874;hp=5689ad2c41d8862c8cf4525ae1b35d84304971e2;hb=19127d05df524822115e9b37fdfc9cd1b8aa4a1f;hpb=e46cbdf194bf086ea4d4b091746cb81dd469a443 diff --git a/actions.c b/actions.c index 5689ad2..abe9e5b 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); @@ -337,7 +338,7 @@ static int vcarry(token_t verb, token_t obj) rspeak(YOU_JOKING); return GO_CLEAROBJ; } - int spk; + if (obj == WATER || obj == OIL) { if (!HERE(BOTTLE) || @@ -355,39 +356,38 @@ static int vcarry(token_t verb, token_t obj) obj = BOTTLE; } - spk = CARRY_LIMIT; if (game.holdng >= INVLIMIT) { - rspeak(spk); + rspeak(CARRY_LIMIT); return GO_CLEAROBJ; - } else 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); return GO_CLEAROBJ; } - if (!TOTING(CAGE)) - spk = CANNOT_CARRY; - if (TOTING(ROD)) - spk = BIRD_EVADES; - if (spk == CANNOT_CARRY || - spk == BIRD_EVADES) { - rspeak(spk); + if (!TOTING(CAGE)) { + rspeak(CANNOT_CARRY); + return GO_CLEAROBJ; + } + if (TOTING(ROD)) { + rspeak(BIRD_EVADES); return GO_CLEAROBJ; } 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); @@ -446,12 +446,11 @@ static int discard(token_t verb, token_t obj, bool just_do_it) * bird (might attack snake or dragon) and cage (might contain bird) and vase. * Drop coins at vending machine for extra batteries. */ { - int spk = actions[verb].message; if (!just_do_it) { if (TOTING(ROD2) && obj == ROD && !TOTING(ROD)) obj = ROD2; if (!TOTING(obj)) { - rspeak(spk); + rspeak(actions[verb].message); return GO_CLEAROBJ; } if (obj == BIRD && HERE(SNAKE)) { @@ -464,11 +463,11 @@ 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))) { - spk = RUG_RISES; + int spk = RUG_RISES; if (TOTING(RUG)) spk = RUG_WIGGLES; if (obj == RUBY) @@ -514,7 +513,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) int k = LIQUID(); if (k == obj) obj = BOTTLE; - if (obj == BOTTLE && k != 0) + if (obj == BOTTLE && k != NO_OBJECT) game.place[k] = LOC_NOWHERE; if (obj == CAGE && game.prop[BIRD] == BIRD_CAGED) drop(BIRD, game.loc); @@ -663,7 +662,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 +691,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 +1110,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 +1136,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 +1221,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;