X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=actions.c;h=05c59d5def25b248365282abbf6dfcf184c02489;hb=2dd1ccc53580a93a144b163006f32fe374921447;hp=9917199bc5bcef7bed8a7ca38ba1174ba1e63df4;hpb=747c42029df74710034eff07316e91cf8c6e1444;p=open-adventure.git diff --git a/actions.c b/actions.c index 9917199..05c59d5 100644 --- a/actions.c +++ b/actions.c @@ -1,5 +1,5 @@ /* - * Actions for the duneon-running code. + * Actions for the dungeon-running code. * * Copyright (c) 1977, 2005 by Will Crowther and Don Woods * Copyright (c) 2017 by Eric S. Raymond @@ -111,7 +111,7 @@ static phase_codes_t attack(command_t command) * fixed), move rug there (not fixed), and move him there, * too. Then do a null motion to get new description. */ rspeak(BARE_HANDS_QUERY); - if (!silent_yes()) { + if (!silent_yes_or_no()) { speak(arbitrary_messages[NASTY_DRAGON]); return GO_MOVE; } @@ -187,17 +187,24 @@ static phase_codes_t attack(command_t command) } static phase_codes_t bigwords(vocab_t 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). */ +/* Only called on 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). */ { - if ((game.foobar == WORD_EMPTY && id == FEE) || - (game.foobar == FEE && id == FIE) || - (game.foobar == FIE && id == FOE) || - (game.foobar == FOE && id == FOO) || - (game.foobar == FOE && id == FUM)) { + int foobar = abs(game.foobar); + + if ((foobar == WORD_EMPTY) && (id == FIE || id == FOE || id == FOO || id == FUM)) { + rspeak(NOTHING_HAPPENS); + return GO_CLEAROBJ; + } + + if ((foobar == WORD_EMPTY && id == FEE) || + (foobar == FEE && id == FIE) || + (foobar == FIE && id == FOE) || + (foobar == FOE && id == FOO)) { game.foobar = id; - if ((id != FOO) && (id != FUM)) { + if (id != FOO) { rspeak(OK_MAN); return GO_CLEAROBJ; } @@ -222,13 +229,7 @@ static phase_codes_t bigwords(vocab_t id) 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); - } + rspeak(START_OVER); game.foobar = WORD_EMPTY; return GO_CLEAROBJ; } @@ -845,15 +846,22 @@ static phase_codes_t fly(verb_t verb, obj_t obj) rspeak(RUG_NOTHING1); return GO_CLEAROBJ; } - game.oldlc2 = game.oldloc; - game.oldloc = game.loc; - if (game.prop[SAPPH] == STATE_NOTFOUND) { - game.newloc = game.place[SAPPH]; + if (game.loc == LOC_CLIFF) { + game.oldlc2 = game.oldloc; + game.oldloc = game.loc; + game.newloc = LOC_LEDGE; rspeak(RUG_GOES); - } else { + } else if (game.loc == LOC_LEDGE) { + game.oldlc2 = game.oldloc; + game.oldloc = game.loc; game.newloc = LOC_CLIFF; rspeak(RUG_RETURNS); + } else { +// LCOV_EXCL_START + /* should never happen */ + rspeak(NOTHING_HAPPENS); +// LCOV_EXCL_STOP } return GO_TERMINATE; } @@ -918,14 +926,15 @@ static phase_codes_t light(verb_t verb, obj_t obj) } static phase_codes_t listen(void) -/* Listen. Intransitive only. Print stuff based on object sound proprties. */ +/* Listen. Intransitive only. Print stuff based on object sound properties. */ { + bool soundlatch = false; vocab_t sound = locations[game.loc].sound; if (sound != SILENT) { rspeak(sound); if (!locations[game.loc].loud) rspeak(NO_MESSAGE); - return GO_CLEAROBJ; + soundlatch = true; } for (obj_t i = 1; i <= NOBJECTS; i++) { if (!HERE(i) || @@ -944,9 +953,10 @@ static phase_codes_t listen(void) rspeak(NO_MESSAGE); if (i == BIRD && mi == BIRD_ENDSTATE) DESTROY(BIRD); - return GO_CLEAROBJ; + soundlatch = true; } - rspeak(ALL_SILENT); + if (!soundlatch) + rspeak(ALL_SILENT); return GO_CLEAROBJ; } @@ -999,7 +1009,7 @@ static phase_codes_t lock(verb_t verb, obj_t obj) if (verb == LOCK) rspeak(HUH_MAN); else if (TOTING(CLAM)) - rspeak(DROP_CLAM); + rspeak(DROP_CLAM); else if (!TOTING(TRIDENT)) rspeak(CLAM_OPENER); else { @@ -1083,7 +1093,7 @@ static phase_codes_t pour(verb_t verb, obj_t obj) static phase_codes_t quit(void) /* Quit. Intransitive only. Verify intent and exit if that's what he wants. */ { - if (yes(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) + if (yes_or_no(arbitrary_messages[REALLY_QUIT], arbitrary_messages[OK_MAN], arbitrary_messages[OK_MAN])) terminate(quitgame); return GO_CLEAROBJ; } @@ -1106,13 +1116,13 @@ static phase_codes_t read(command_t command) if (DARK(game.loc)) { sspeak(NO_SEE, command.word[0].raw); } else if (command.obj == OYSTER) { - if (!TOTING(OYSTER) || !game.closed) { - rspeak(DONT_UNDERSTAND); - } else if (!game.clshnt) { - game.clshnt = yes(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); - } else if (game.clshnt) { - pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well. - } + if (!TOTING(OYSTER) || !game.closed) { + rspeak(DONT_UNDERSTAND); + } else if (!game.clshnt) { + game.clshnt = yes_or_no(arbitrary_messages[CLUE_QUERY], arbitrary_messages[WAYOUT_CLUE], arbitrary_messages[OK_MAN]); + } else { + pspeak(OYSTER, hear, true, 1); // Not really a sound, but oh well. + } } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] == STATE_NOTFOUND) { speak(actions[command.verb].message); @@ -1191,7 +1201,7 @@ static phase_codes_t throw_support(vocab_t spk) return GO_MOVE; } -static phase_codes_t throw (command_t command) +static phase_codes_t throwit(command_t command) /* Throw. Same as discard unless axe. Then same as attack except * ignore bird, and if dwarf is present then one might be killed. * (Only way to do so!) Axe also special for dragon, bear, and @@ -1354,8 +1364,8 @@ phase_codes_t action(command_t command) /* FALL THROUGH */; else if (command.obj == DWARF && atdwrf(game.loc) > 0) /* FALL THROUGH */; - else if ((LIQUID() == command.obj && HERE(BOTTLE)) || - command.obj == LIQLOC(game.loc)) + else if (!game.closed && ((LIQUID() == command.obj && HERE(BOTTLE)) || + command.obj == LIQLOC(game.loc))) /* FALL THROUGH */; else if (command.obj == OIL && HERE(URN) && game.prop[URN] != URN_EMPTY) { command.obj = URN; @@ -1526,7 +1536,7 @@ phase_codes_t action(command_t command) case RUB: return rub(command.verb, command.obj); case THROW: - return throw (command); + return throwit(command); case QUIT: { speak(actions[command.verb].message); return GO_CLEAROBJ;