X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=actions.c;h=e7574be4f2ce3c0e32af03376c98a04306cc25af;hb=b2a686b07def29a898fee83ab1e3a4a4f2ebd3eb;hp=06da68805481e1526c7a24687b09c9224188b6b1;hpb=7be7ac9406512644886fbf4a99d16e1b4f7cefc3;p=open-adventure.git diff --git a/actions.c b/actions.c index 06da688..e7574be 100644 --- a/actions.c +++ b/actions.c @@ -6,13 +6,6 @@ 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); -} - static int attack(struct command_t *command) /* Attack. Assume target if unambiguous. "Throw" also links here. * Attackable objects fall into two categories: enemies (snake, @@ -180,51 +173,58 @@ static int attack(struct command_t *command) rspeak(ROCKY_TROLL); break; default: - rspeak(actions[verb].message); + speak(actions[verb].message); } return GO_CLEAROBJ; } -static int bigwords(token_t foo) +static int bigwords(long id) /* FEE FIE FOE FOO (AND FUM). Advance to next state if given in proper order. * Look up foo in special section of vocab to determine which word we've got. * Last word zips the eggs back to the giant room (unless already there). */ { - char word[TOKLEN + 1]; - packed_to_token(foo, word); - int k = (int) get_special_vocab_id(word); - if (game.foobar != 1 - k) { - if (game.foobar != 0 && game.loc == LOC_GIANTROOM) { - rspeak( START_OVER); - } else { - rspeak(NOTHING_HAPPENS); - } - return GO_CLEAROBJ; - } else { - game.foobar = k; - if (k != 4) { - rspeak(OK_MAN); - return GO_CLEAROBJ; - } - game.foobar = 0; - if (game.place[EGGS] == objects[EGGS].plac || - (TOTING(EGGS) && game.loc == objects[EGGS].plac)) { - rspeak(NOTHING_HAPPENS); - return GO_CLEAROBJ; - } else { - /* Bring back troll if we steal the eggs back from him before - * crossing. */ - if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID) - game.prop[TROLL] = TROLL_PAIDONCE; - k = EGGS_DONE; - if (HERE(EGGS)) - k = EGGS_VANISHED; - if (game.loc == objects[EGGS].plac) - k = EGGS_HERE; - move(EGGS, objects[EGGS].plac); - pspeak(EGGS, look, k, true); - return GO_CLEAROBJ; - } + if ((game.foobar == WORD_EMPTY && id == ACTION_WORD(FEE)) || + (game.foobar == ACTION_WORD(FEE) && id == ACTION_WORD(FIE)) || + (game.foobar == ACTION_WORD(FIE) && id == ACTION_WORD(FOE)) || + (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FOO)) || + (game.foobar == ACTION_WORD(FOE) && id == ACTION_WORD(FUM))) + { + game.foobar = id; + if ((id != ACTION_WORD(FOO)) && (id != ACTION_WORD(FUM))) { + rspeak(OK_MAN); + return GO_CLEAROBJ; + } + game.foobar = WORD_EMPTY; + if (game.place[EGGS] == objects[EGGS].plac || + (TOTING(EGGS) && game.loc == objects[EGGS].plac)) { + rspeak(NOTHING_HAPPENS); + return GO_CLEAROBJ; + } else { + /* Bring back troll if we steal the eggs back from him before + * crossing. */ + if (game.place[EGGS] == LOC_NOWHERE && game.place[TROLL] == LOC_NOWHERE && game.prop[TROLL] == TROLL_UNPAID) + game.prop[TROLL] = TROLL_PAIDONCE; + int k = EGGS_DONE; + if (HERE(EGGS)) + k = EGGS_VANISHED; + if (game.loc == objects[EGGS].plac) + k = EGGS_HERE; + move(EGGS, objects[EGGS].plac); + pspeak(EGGS, look, k, true); + return GO_CLEAROBJ; + } + } + else + { + if (game.loc == LOC_GIANTROOM) { + rspeak(START_OVER); + } else { + /* This is new begavior in Open Adventure - sounds better when + * player isn't in the Giant Room. */ + rspeak(WELL_POINTLESS); + } + game.foobar = WORD_EMPTY; + return GO_CLEAROBJ; } } @@ -264,7 +264,7 @@ static int vbreak(token_t verb, token_t obj) game.fixed[VASE] = IS_FIXED; return GO_CLEAROBJ; } - rspeak(actions[verb].message); + speak(actions[verb].message); return (GO_CLEAROBJ); } @@ -303,7 +303,7 @@ static int vcarry(token_t verb, token_t obj) } if (game.fixed[obj] != IS_FREE) { - /* Next guard tests whether plant is tiny or stashed */ + /* Next guard tests whether plant is tiny or stashed */ if (obj == PLANT && game.prop[PLANT] <= PLANT_THIRSTY) { rspeak(DEEP_ROOTS); return GO_CLEAROBJ; @@ -451,7 +451,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); + speak(actions[verb].message); return GO_CLEAROBJ; } if (obj == BIRD && HERE(SNAKE)) { @@ -476,7 +476,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) rspeak(spk); if (spk != RUG_WIGGLES) { /* FIXME: Arithmetic on state numbers */ - int k = 2 - game.prop[RUG]; + int k = (game.prop[RUG] == RUG_HOVER) ? RUG_FLOOR : RUG_HOVER; game.prop[RUG] = k; if (k == RUG_HOVER) k = objects[SAPPH].plac; @@ -503,9 +503,9 @@ static int discard(token_t verb, token_t obj, bool just_do_it) game.loc == objects[PILLOW].plac) { rspeak(OK_MAN); } else { - state_change(VASE, AT(PILLOW) - ? VASE_WHOLE - : VASE_DROPPED); + state_change(VASE, AT(PILLOW) + ? VASE_WHOLE + : VASE_DROPPED); if (game.prop[VASE] != VASE_WHOLE) game.fixed[VASE] = IS_FIXED; } @@ -552,7 +552,7 @@ static int drink(token_t verb, token_t obj) return GO_CLEAROBJ; } - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } @@ -584,7 +584,7 @@ static int eat(token_t verb, token_t obj) rspeak(LOST_APPETITE); return GO_CLEAROBJ; } - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } @@ -623,7 +623,7 @@ static int extinguish(token_t verb, int obj) return GO_CLEAROBJ; } - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } @@ -631,46 +631,59 @@ static int feed(token_t verb, token_t obj) /* Feed. If bird, no seed. Snake, dragon, troll: quip. If dwarf, make him * mad. Bear, special. */ { - int spk = actions[verb].message; - if (obj == BIRD) { + switch (obj) { + case BIRD: rspeak(BIRD_PINING); - return GO_CLEAROBJ; - } else if (obj == SNAKE || - obj == DRAGON || - obj == TROLL) { - spk = NOTHING_EDIBLE; - if (obj == DRAGON && game.prop[DRAGON] != DRAGON_BARS) - spk = RIDICULOUS_ATTEMPT; - if (obj == TROLL) - spk = TROLL_VICES; - if (obj == SNAKE && !game.closed && HERE(BIRD)) { + break; + case DRAGON: + if (game.prop[DRAGON] != DRAGON_BARS) + rspeak(RIDICULOUS_ATTEMPT); + else + rspeak(NOTHING_EDIBLE); + break; + case SNAKE: + if (!game.closed && HERE(BIRD)) { DESTROY(BIRD); - spk = BIRD_DEVOURED; - } - } else if (obj == DWARF) { + rspeak(BIRD_DEVOURED); + } else + rspeak(NOTHING_EDIBLE); + break; + case TROLL: + rspeak(TROLL_VICES); + break; + case DWARF: if (HERE(FOOD)) { game.dflag += 2; - spk = REALLY_MAD; + rspeak(REALLY_MAD); + } else + speak(actions[verb].message); + break; + case BEAR: + if (game.prop[BEAR] == BEAR_DEAD) { + rspeak(RIDICULOUS_ATTEMPT); + break; } - } else if (obj == BEAR) { - if (game.prop[BEAR] == UNTAMED_BEAR) - spk = NOTHING_EDIBLE; - if (game.prop[BEAR] == BEAR_DEAD) - spk = RIDICULOUS_ATTEMPT; - if (HERE(FOOD)) { - DESTROY(FOOD); - game.prop[BEAR] = SITTING_BEAR; - game.fixed[AXE] = IS_FREE; - game.prop[AXE] = AXE_HERE; - spk = BEAR_TAMED; + if (game.prop[BEAR] == UNTAMED_BEAR) { + if (HERE(FOOD)) { + DESTROY(FOOD); + game.fixed[AXE] = IS_FREE; + game.prop[AXE] = AXE_HERE; + state_change(BEAR, SITTING_BEAR); + } else + rspeak(NOTHING_EDIBLE); + break; } - } else if (obj == OGRE) { + speak(actions[verb].message); + break; + case OGRE: if (HERE(FOOD)) - spk = OGRE_FULL; - } else { - spk = AM_GAME; + rspeak(OGRE_FULL); + else + speak(actions[verb].message); + break; + default: + rspeak(AM_GAME); } - rspeak(spk); return GO_CLEAROBJ; } @@ -722,7 +735,7 @@ int fill(token_t verb, token_t obj) return GO_CLEAROBJ; } if (obj != NO_OBJECT && obj != BOTTLE) { - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } if (obj == NO_OBJECT && !HERE(BOTTLE)) @@ -742,8 +755,8 @@ int fill(token_t verb, token_t obj) } state_change(BOTTLE, (LIQLOC(game.loc) == OIL) - ? OIL_BOTTLE - : WATER_BOTTLE); + ? OIL_BOTTLE + : WATER_BOTTLE); if (TOTING(BOTTLE)) game.place[LIQUID()] = CARRIED; return GO_CLEAROBJ; @@ -771,7 +784,7 @@ static int find(token_t verb, token_t obj) } - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } @@ -791,7 +804,7 @@ static int fly(token_t verb, token_t obj) } if (obj != RUG) { - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } if (game.prop[RUG] != RUG_HOVER) { @@ -800,12 +813,12 @@ static int fly(token_t verb, token_t obj) } game.oldlc2 = game.oldloc; game.oldloc = game.loc; - /* FIXME: Arithmetic on location values */ - game.newloc = game.place[RUG] + game.fixed[RUG] - game.loc; if (game.prop[SAPPH] == STATE_NOTFOUND) { + game.newloc = game.place[SAPPH]; rspeak(RUG_GOES); } else { + game.newloc = LOC_CLIFF; rspeak(RUG_RETURNS); } return GO_TERMINATE; @@ -853,7 +866,7 @@ static int light(token_t verb, token_t obj) return GO_CLEAROBJ; } else { if (obj != LAMP) { - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } if (game.limit < 0) { @@ -971,7 +984,7 @@ static int lock(token_t verb, token_t obj) rspeak(CANNOT_UNLOCK); break; default: - rspeak(actions[verb].message); + speak(actions[verb].message); } return GO_CLEAROBJ; @@ -987,7 +1000,7 @@ static int pour(token_t verb, token_t obj) if (obj == NO_OBJECT) return GO_UNKNOWN; if (!TOTING(obj)) { - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } @@ -1051,7 +1064,7 @@ static int read(struct command_t command) game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) { - rspeak(actions[command.verb].message); + speak(actions[command.verb].message); } else pspeak(command.obj, study, game.prop[command.obj], true); return GO_CLEAROBJ; @@ -1091,7 +1104,7 @@ static int rub(token_t verb, token_t obj) } else if (obj != LAMP) { rspeak(PECULIAR_NOTHING); } else { - rspeak(actions[verb].message); + speak(actions[verb].message); } return GO_CLEAROBJ; } @@ -1109,7 +1122,11 @@ static int say(struct command_t *command) if (wd == MOTION_WORD(XYZZY) || wd == MOTION_WORD(PLUGH) || wd == MOTION_WORD(PLOVER) || - wd == ACTION_WORD(GIANTWORDS) || + wd == ACTION_WORD(FEE) || + wd == ACTION_WORD(FIE) || + wd == ACTION_WORD(FOE) || + wd == ACTION_WORD(FOO) || + wd == ACTION_WORD(FUM) || wd == ACTION_WORD(PART)) { /* FIXME: scribbles on the interpreter's command block */ wordclear(&command->wd2); @@ -1133,7 +1150,7 @@ static int throw (struct command_t *command) * troll. Treasures special for troll. */ { if (!TOTING(command->obj)) { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } if (objects[command->obj].is_treasure && AT(TROLL)) { @@ -1192,7 +1209,7 @@ static int wake(token_t verb, token_t obj) { if (obj != DWARF || !game.closed) { - rspeak(actions[verb].message); + speak(actions[verb].message); return GO_CLEAROBJ; } else { rspeak(PROD_DWARF); @@ -1208,9 +1225,9 @@ static int wave(token_t verb, token_t obj) (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) { - rspeak(((!TOTING(obj)) && (obj != ROD || + speak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? - ARENT_CARRYING : + arbitrary_messages[ARENT_CARRYING] : actions[verb].message); return GO_CLEAROBJ; } @@ -1339,7 +1356,7 @@ int action(struct command_t *command) case TAME: return GO_UNKNOWN; case GO: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case ATTACK: @@ -1370,8 +1387,12 @@ int action(struct command_t *command) case SCORE: score(scoregame); return GO_CLEAROBJ; - case GIANTWORDS: - return bigwords(command->wd1); + case FEE: + case FIE: + case FOE: + case FOO: + case FUM: + return bigwords(command->id1); case BRIEF: return brief(); case READ: @@ -1420,11 +1441,11 @@ int action(struct command_t *command) case WAVE: return wave(command->verb, command->obj); case TAME: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case GO: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case ATTACK: @@ -1440,7 +1461,7 @@ int action(struct command_t *command) case THROW: return throw (command); case QUIT: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case FIND: @@ -1455,15 +1476,19 @@ int action(struct command_t *command) blast(); return GO_CLEAROBJ; case SCORE: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } - case GIANTWORDS: { - rspeak(actions[command->verb].message); + case FEE: + case FIE: + case FOE: + case FOO: + case FUM: { + speak(actions[command->verb].message); return GO_CLEAROBJ; } case BRIEF: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case READ: @@ -1473,17 +1498,17 @@ int action(struct command_t *command) case WAKE: return wake(command->verb, command->obj); case SAVE: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case RESUME: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case FLY: return fly(command->verb, command->obj); case LISTEN: { - rspeak(actions[command->verb].message); + speak(actions[command->verb].message); return GO_CLEAROBJ; } case PART: