X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=actions.c;h=0a5b8edb30ba09bcbb50c55ded35b0eec4a5a464;hb=35f4af108d332fc5682b264dd5ff1aeae7a892db;hp=f2ec65adac01a042d5b8b7283d4e89f9bee2ca4f;hpb=29672a64476e72db0e71931c1001fb345b5dae36;p=open-adventure.git diff --git a/actions.c b/actions.c index f2ec65a..0a5b8ed 100644 --- a/actions.c +++ b/actions.c @@ -8,7 +8,7 @@ static int fill(token_t, token_t); static void state_change(long obj, long state) { game.prop[obj] = state; - pspeak(obj, change, state); + pspeak(obj, change, state, true); } static int attack(struct command_t *command) @@ -19,40 +19,62 @@ static int attack(struct command_t *command) { vocab_t verb = command->verb; vocab_t obj = command->obj; + + if (obj == INTRANSITIVE) { + return GO_UNKNOWN; + } long spk = actions[verb].message; if (obj == 0 || obj == INTRANSITIVE) { - if (atdwrf(game.loc) > 0) + int changes = 0; + if (atdwrf(game.loc) > 0) { obj = DWARF; - if (HERE(SNAKE)) - obj = obj * NOBJECTS + SNAKE; - if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) - obj = obj * NOBJECTS + DRAGON; - if (AT(TROLL)) - obj = obj * NOBJECTS + TROLL; - if (AT(OGRE)) - obj = obj * NOBJECTS + OGRE; - if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) - obj = obj * NOBJECTS + BEAR; - if (obj > NOBJECTS) - return GO_UNKNOWN; + ++changes; + } + if (HERE(SNAKE)) { + obj = SNAKE; + ++changes; + } + if (AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) { + obj = DRAGON; + ++changes; + } + if (AT(TROLL)) { + obj = TROLL; + ++changes; + } + if (AT(OGRE)) { + obj = OGRE; + ++changes; + } + if (HERE(BEAR) && game.prop[BEAR] == UNTAMED_BEAR) { + obj = BEAR; + ++changes; + } + /* check for low-priority targets */ if (obj == 0) { /* Can't attack bird or machine by throwing axe. */ - if (HERE(BIRD) && verb != THROW) + if (HERE(BIRD) && verb != THROW) { obj = BIRD; - if (HERE(VEND) && verb != THROW) - obj = obj * NOBJECTS + VEND; + ++changes; + } + if (HERE(VEND) && verb != THROW) { + obj = VEND; + ++changes; + } /* Clam and oyster both treated as clam for intransitive case; * no harm done. */ - if (HERE(CLAM) || HERE(OYSTER)) - obj = NOBJECTS * obj + CLAM; - if (obj > NOBJECTS) - return GO_UNKNOWN; + if (HERE(CLAM) || HERE(OYSTER)) { + obj = CLAM; + ++changes; + } } + if (changes >= 2) + return GO_UNKNOWN; + } if (obj == BIRD) { - spk = UNHAPPY_BIRD; if (game.closed) { - rspeak(spk); + rspeak(UNHAPPY_BIRD); return GO_CLEAROBJ; } DESTROY(BIRD); @@ -178,7 +200,7 @@ static int bigwords(token_t foo) if (game.loc == objects[EGGS].plac) k = EGGS_HERE; move(EGGS, objects[EGGS].plac); - pspeak(EGGS, look, k); + pspeak(EGGS, look, k, true); return GO_CLEAROBJ; } } @@ -431,7 +453,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) } else if (obj == COINS && HERE(VEND)) { DESTROY(COINS); drop(BATTERY, game.loc); - pspeak(BATTERY, look, FRESH_BATTERIES); + pspeak(BATTERY, look, FRESH_BATTERIES, true); return GO_CLEAROBJ; } else if (obj == BIRD && AT(DRAGON) && game.prop[DRAGON] == DRAGON_BARS) { rspeak(BIRD_BURNT); @@ -451,7 +473,7 @@ static int discard(token_t verb, token_t obj, bool just_do_it) game.prop[VASE] = VASE_BROKEN; if (AT(PILLOW)) game.prop[VASE] = VASE_WHOLE; - pspeak(VASE, look, game.prop[VASE] + 1); + pspeak(VASE, look, game.prop[VASE] + 1, true); if (game.prop[VASE] != VASE_WHOLE) game.fixed[VASE] = -1; } @@ -529,8 +551,8 @@ static int extinguish(token_t verb, int obj) if (HERE(URN) && game.prop[URN] == URN_LIT) obj = URN; if (obj == INTRANSITIVE || - HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT && - HERE(URN) && game.prop[URN] == URN_LIT) + (HERE(LAMP) && game.prop[LAMP] == LAMP_BRIGHT && + HERE(URN) && game.prop[URN] == URN_LIT)) return GO_UNKNOWN; } @@ -538,7 +560,7 @@ static int extinguish(token_t verb, int obj) if (game.prop[URN] != URN_EMPTY) { state_change(URN, URN_DARK); } else { - pspeak(URN, change, URN_DARK); + pspeak(URN, change, URN_DARK, true); } } else if (obj == LAMP) { @@ -722,9 +744,7 @@ static int inven(void) continue; if (spk == NO_CARRY) rspeak(NOW_HOLDING); - game.blklin = false; - pspeak(i, touch, -1); - game.blklin = true; + pspeak(i, touch, -1, false); spk = NO_MESSAGE; } if (TOTING(BEAR)) @@ -742,8 +762,8 @@ static int light(token_t verb, token_t obj) if (HERE(URN) && game.prop[URN] == URN_DARK) obj = URN; if (obj == INTRANSITIVE || - HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 && - HERE(URN) && game.prop[URN] == URN_DARK) + (HERE(LAMP) && game.prop[LAMP] == LAMP_DARK && game.limit >= 0 && + HERE(URN) && game.prop[URN] == URN_DARK)) return GO_UNKNOWN; } @@ -787,7 +807,7 @@ static int listen(void) if (i == BIRD) mi += 3 * game.blooded; long packed_zzword = token_to_packed(game.zzword); - pspeak(i, hear, mi, packed_zzword); + pspeak(i, hear, mi, true, packed_zzword); spk = NO_MESSAGE; /* FIXME: Magic number, sensitive to bird state logic */ if (i == BIRD && game.prop[i] == 5) @@ -811,8 +831,6 @@ static int lock(token_t verb, token_t obj) obj = DOOR; if (AT(GRATE)) obj = GRATE; - if (obj != 0 && HERE(CHAIN)) - return GO_UNKNOWN; if (HERE(CHAIN)) obj = CHAIN; if (obj == 0 || obj == INTRANSITIVE) { @@ -827,7 +845,7 @@ static int lock(token_t verb, token_t obj) return bivalve(verb, obj); if (obj == DOOR) spk = RUSTY_DOOR; - if (obj == DOOR && game.prop[DOOR] == 1) + if (obj == DOOR && game.prop[DOOR] == DOOR_UNRUSTED) spk = OK_MAN; if (obj == CAGE) spk = NO_LOCK; @@ -871,7 +889,7 @@ static int pour(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - if (HERE(URN) && game.prop[URN] == 0) + if (HERE(URN) && game.prop[URN] == URN_EMPTY) return fill(verb, URN); game.prop[BOTTLE] = EMPTY_BOTTLE; game.place[obj] = LOC_NOWHERE; @@ -886,7 +904,7 @@ static int pour(token_t verb, token_t obj) rspeak(spk); return GO_CLEAROBJ; } - pspeak(PLANT, look, game.prop[PLANT] + 3); + pspeak(PLANT, look, game.prop[PLANT] + 3, true); game.prop[PLANT] = MOD(game.prop[PLANT] + 1, 3); game.prop[PLANT2] = game.prop[PLANT]; return GO_MOVE; @@ -924,7 +942,7 @@ static int read(struct command_t command) } else if (objects[command.obj].texts[0] == NULL || game.prop[command.obj] < 0) { rspeak(actions[command.verb].message); } else - pspeak(command.obj, study, game.prop[command.obj]); + pspeak(command.obj, study, game.prop[command.obj], true); return GO_CLEAROBJ; } @@ -935,7 +953,7 @@ static int reservoir(void) rspeak(NOTHING_HAPPENS); return GO_CLEAROBJ; } else { - pspeak(RESER, look, game.prop[RESER] + 1); + pspeak(RESER, look, game.prop[RESER] + 1, true); game.prop[RESER] = 1 - game.prop[RESER]; if (AT(RESER)) return GO_CLEAROBJ; @@ -954,7 +972,7 @@ static int rub(token_t verb, token_t obj) int spk = actions[verb].message; if (obj != LAMP) spk = PECULIAR_NOTHING; - if (obj == URN && game.prop[URN] == 2) { + if (obj == URN && game.prop[URN] == URN_LIT) { DESTROY(URN); drop(AMBER, game.loc); game.prop[AMBER] = 1; @@ -1107,7 +1125,7 @@ static int wave(token_t verb, token_t obj) if (HERE(BIRD)) rspeak(spk); game.prop[FISSURE] = 1 - game.prop[FISSURE]; - pspeak(FISSURE, look, 2 - game.prop[FISSURE]); + pspeak(FISSURE, look, 2 - game.prop[FISSURE], true); return GO_CLEAROBJ; } }