X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=actions.c;h=5dfb987a74f8e92ce02edd9ca36bb3defd1591b0;hb=5613b0ce36636d421cfa3002d39aeb0e2f69e389;hp=9c54e17fb1d605dcc3c57bc0cec95960c85c948d;hpb=8fcbc8ecba9a3cf8970a6ab116d160edf7f26395;p=open-adventure.git diff --git a/actions.c b/actions.c index 9c54e17..5dfb987 100644 --- a/actions.c +++ b/actions.c @@ -20,9 +20,6 @@ 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 == NO_OBJECT || obj == INTRANSITIVE) { int changes = 0; @@ -521,23 +518,25 @@ static int eat(token_t verb, token_t obj) /* Eat. Intransitive: assume food if present, else ask what. Transitive: food * ok, some things lose appetite, rest are ridiculous. */ { - int spk = actions[verb].message; if (obj == INTRANSITIVE) { if (!HERE(FOOD)) return GO_UNKNOWN; DESTROY(FOOD); - spk = THANKS_DELICIOUS; - } else { - if (obj == FOOD) { - DESTROY(FOOD); - spk = THANKS_DELICIOUS; - } - if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj == - DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj == - OGRE) - spk = LOST_APPETITE; + rspeak(THANKS_DELICIOUS); + return GO_CLEAROBJ; } - rspeak(spk); + if (obj == FOOD) { + DESTROY(FOOD); + rspeak(THANKS_DELICIOUS); + return GO_CLEAROBJ; + } + if (obj == BIRD || obj == SNAKE || obj == CLAM || obj == OYSTER || obj == + DWARF || obj == DRAGON || obj == TROLL || obj == BEAR || obj == + OGRE) { + rspeak(LOST_APPETITE); + return GO_CLEAROBJ; + } + rspeak(actions[verb].message); return GO_CLEAROBJ; } @@ -1089,36 +1088,32 @@ static int wake(token_t verb, token_t obj) static int wave(token_t verb, token_t obj) /* Wave. No effect unless waving rod at fissure or at bird. */ { - int spk = actions[verb].message; - if ((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) - spk = ARENT_CARRYING; if (obj != ROD || !TOTING(obj) || (!HERE(BIRD) && (game.closng || !AT(FISSURE)))) { - rspeak(spk); + rspeak(((!TOTING(obj)) && (obj != ROD || !TOTING(ROD2))) ? ARENT_CARRYING : actions[verb].message); return GO_CLEAROBJ; } - /* FIXME: Arithemetic on property values */ - if (HERE(BIRD)) - spk = FREE_FLY + MOD(game.prop[BIRD], 2); - if (spk == FREE_FLY && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { + + if (game.prop[BIRD] == BIRD_UNCAGED && game.loc == game.place[STEPS] && game.prop[JADE] < 0) { drop(JADE, game.loc); game.prop[JADE] = 0; --game.tally; - spk = NECKLACE_FLY; - rspeak(spk); + rspeak(NECKLACE_FLY); return GO_CLEAROBJ; } else { if (game.closed) { - rspeak(spk); + rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY); return GO_DWARFWAKE; } if (game.closng || !AT(FISSURE)) { - rspeak(spk); + rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY); return GO_CLEAROBJ; } if (HERE(BIRD)) - rspeak(spk); + rspeak((game.prop[BIRD] == BIRD_CAGED) ? CAGE_FLY : FREE_FLY); + + /* FIXME: Arithemetic on property values */ game.prop[FISSURE] = 1 - game.prop[FISSURE]; pspeak(FISSURE, look, 2 - game.prop[FISSURE], true); return GO_CLEAROBJ; @@ -1130,8 +1125,6 @@ int action(struct command_t *command) * unless verb is "say", which snarfs arbitrary second word. */ { - token_t spk = actions[command->verb].message; - if (command->part == unknown) { /* Analyse an object word. See if the thing is here, whether * we've got a verb yet, and so on. Object must be here @@ -1160,8 +1153,7 @@ int action(struct command_t *command) /* FALL THROUGH */; } else if (command->obj == KNIFE && game.knfloc == game.loc) { game.knfloc = -1; - spk = KNIVES_VANISH; - rspeak(spk); + rspeak(KNIVES_VANISH); return GO_CLEAROBJ; } else if (command->obj == ROD && HERE(ROD2)) { command->obj = ROD2; @@ -1211,7 +1203,7 @@ int action(struct command_t *command) case TAME: return GO_UNKNOWN; case GO: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case ATTACK: @@ -1292,11 +1284,11 @@ int action(struct command_t *command) case WAVE: return wave(command->verb, command->obj); case TAME: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case GO: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case ATTACK: @@ -1312,7 +1304,7 @@ int action(struct command_t *command) case THROW: return throw (command); case QUIT: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case FIND: @@ -1327,15 +1319,15 @@ int action(struct command_t *command) blast(); return GO_CLEAROBJ; case SCORE: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case GIANTWORDS: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case BRIEF: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case READ: @@ -1345,17 +1337,17 @@ int action(struct command_t *command) case WAKE: return wake(command->verb, command->obj); case SAVE: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case RESUME: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case FLY: return fly(command->verb, command->obj); case LISTEN: { - rspeak(spk); + rspeak(actions[command->verb].message); return GO_CLEAROBJ; } case PART: