projects
/
open-adventure.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Unspk'd inventory lookup
[open-adventure.git]
/
actions.c
diff --git
a/actions.c
b/actions.c
index b079bd352f863da9e3dab42a30da543b34efa5a9..f4633f58d617b9ab0fb4a3358a3daab618419005 100644
(file)
--- a/
actions.c
+++ b/
actions.c
@@
-172,14
+172,15
@@
static int bigwords(token_t foo)
* 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). */
{
* 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];
+ char word[TOKLEN
+
1];
packed_to_token(foo, word);
int k = (int) get_special_vocab_id(word);
packed_to_token(foo, word);
int k = (int) get_special_vocab_id(word);
- int spk = NOTHING_HAPPENS;
if (game.foobar != 1 - k) {
if (game.foobar != 1 - k) {
- if (game.foobar != 0 && game.loc == LOC_GIANTROOM)
- spk = START_OVER;
- rspeak(spk);
+ if (game.foobar != 0 && game.loc == LOC_GIANTROOM) {
+ rspeak( START_OVER);
+ } else {
+ rspeak(NOTHING_HAPPENS);
+ }
return GO_CLEAROBJ;
} else {
game.foobar = k;
return GO_CLEAROBJ;
} else {
game.foobar = k;
@@
-190,7
+191,7
@@
static int bigwords(token_t foo)
game.foobar = 0;
if (game.place[EGGS] == objects[EGGS].plac ||
(TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
game.foobar = 0;
if (game.place[EGGS] == objects[EGGS].plac ||
(TOTING(EGGS) && game.loc == objects[EGGS].plac)) {
- rspeak(
spk
);
+ rspeak(
NOTHING_HAPPENS
);
return GO_CLEAROBJ;
} else {
/* Bring back troll if we steal the eggs back from him before
return GO_CLEAROBJ;
} else {
/* Bring back troll if we steal the eggs back from him before
@@
-482,13
+483,12
@@
static int discard(token_t verb, token_t obj, bool just_do_it)
DESTROY(BIRD);
return GO_CLEAROBJ;
} else if (obj == BEAR && AT(TROLL)) {
DESTROY(BIRD);
return GO_CLEAROBJ;
} else if (obj == BEAR && AT(TROLL)) {
-
rspeak(TROLL_SCAMPERS
);
+
state_change(TROLL, TROLL_GONE
);
move(TROLL, LOC_NOWHERE);
move(TROLL + NOBJECTS, LOC_NOWHERE);
move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
move(TROLL, LOC_NOWHERE);
move(TROLL + NOBJECTS, LOC_NOWHERE);
move(TROLL2, objects[TROLL].plac);
move(TROLL2 + NOBJECTS, objects[TROLL].fixd);
juggle(CHASM);
- game.prop[TROLL] = TROLL_GONE;
} else if (obj != VASE ||
game.loc == objects[PILLOW].plac) {
rspeak(OK_MAN);
} else if (obj != VASE ||
game.loc == objects[PILLOW].plac) {
rspeak(OK_MAN);
@@
-778,19
+778,21
@@
static int fly(token_t verb, token_t obj)
static int inven(void)
/* Inventory. If object, treat same as find. Else report on current burden. */
{
static int inven(void)
/* Inventory. If object, treat same as find. Else report on current burden. */
{
-
int spk = NO_CARRY
;
+
bool empty = true
;
for (int i = 1; i <= NOBJECTS; i++) {
if (i == BEAR ||
!TOTING(i))
continue;
for (int i = 1; i <= NOBJECTS; i++) {
if (i == BEAR ||
!TOTING(i))
continue;
- if (
spk == NO_CARRY)
+ if (
empty) {
rspeak(NOW_HOLDING);
rspeak(NOW_HOLDING);
+ empty = false;
+ }
pspeak(i, touch, -1, false);
pspeak(i, touch, -1, false);
- spk = NO_MESSAGE;
}
if (TOTING(BEAR))
}
if (TOTING(BEAR))
- spk = TAME_BEAR;
- rspeak(spk);
+ rspeak(TAME_BEAR);
+ if (empty)
+ rspeak(NO_CARRY);
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
}
@@
-874,8
+876,7
@@
static int lock(token_t verb, token_t obj)
obj = GRATE;
if (HERE(CHAIN))
obj = CHAIN;
obj = GRATE;
if (HERE(CHAIN))
obj = CHAIN;
- if (obj == NO_OBJECT ||
- obj == INTRANSITIVE) {
+ if (obj == INTRANSITIVE) {
rspeak(NOTHING_LOCKED);
return GO_CLEAROBJ;
}
rspeak(NOTHING_LOCKED);
return GO_CLEAROBJ;
}
@@
-883,26
+884,17
@@
static int lock(token_t verb, token_t obj)
/* Lock, unlock object. Special stuff for opening clam/oyster
* and for chain. */
/* Lock, unlock object. Special stuff for opening clam/oyster
* and for chain. */
- int spk = actions[verb].message;
- if (obj == CLAM || obj == OYSTER)
- return bivalve(verb, obj);
- if (obj == DOOR)
- spk = (game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR;
- if (obj == CAGE)
- spk = NO_LOCK;
- if (obj == KEYS)
- spk = CANNOT_UNLOCK;
if (obj == GRATE ||
obj == CHAIN) {
if (obj == GRATE ||
obj == CHAIN) {
- spk = NO_KEYS;
if (HERE(KEYS)) {
if (obj == CHAIN)
return chain(verb);
if (game.closng) {
if (HERE(KEYS)) {
if (obj == CHAIN)
return chain(verb);
if (game.closng) {
-
spk = EXIT_CLOSED
;
+
rspeak(EXIT_CLOSED)
;
if (!game.panic)
game.clock2 = PANICTIME;
game.panic = true;
if (!game.panic)
game.clock2 = PANICTIME;
game.panic = true;
+ return GO_CLEAROBJ ;
} else {
state_change(GRATE, (verb == LOCK) ?
GRATE_CLOSED :
} else {
state_change(GRATE, (verb == LOCK) ?
GRATE_CLOSED :
@@
-910,8
+902,27
@@
static int lock(token_t verb, token_t obj)
return GO_CLEAROBJ;
}
}
return GO_CLEAROBJ;
}
}
+ rspeak(NO_KEYS);
+ return GO_CLEAROBJ;
}
}
- rspeak(spk);
+
+ switch (obj) {
+ case CLAM:
+ case OYSTER:
+ return bivalve(verb, obj);
+ case DOOR:
+ rspeak((game.prop[DOOR] == DOOR_UNRUSTED) ? OK_MAN : RUSTY_DOOR);
+ break;
+ case CAGE:
+ rspeak( NO_LOCK);
+ break;
+ case KEYS:
+ rspeak(CANNOT_UNLOCK);
+ break;
+ default:
+ rspeak(actions[verb].message);
+ }
+
return GO_CLEAROBJ;
}
return GO_CLEAROBJ;
}
@@
-943,15
+954,15
@@
static int pour(token_t verb, token_t obj)
return GO_CLEAROBJ;
}
if (!AT(DOOR)) {
return GO_CLEAROBJ;
}
if (!AT(DOOR)) {
- if (obj != WATER) {
+ if (obj == WATER) {
+ /* cycle through the three plant states */
+ state_change(PLANT, MOD(game.prop[PLANT] + 1, 3));
+ game.prop[PLANT2] = game.prop[PLANT];
+ return GO_MOVE;
+ } else {
rspeak(SHAKING_LEAVES);
return GO_CLEAROBJ;
rspeak(SHAKING_LEAVES);
return GO_CLEAROBJ;
- }
- /* FIXME: Arithmetic on state numbers */
- 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;
+ }
} else {
state_change(DOOR, (obj == OIL) ?
DOOR_UNRUSTED :
} else {
state_change(DOOR, (obj == OIL) ?
DOOR_UNRUSTED :
@@
-1038,13
+1049,11
@@
static int rub(token_t verb, token_t obj)
static int say(struct command_t *command)
/* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
{
static int say(struct command_t *command)
/* Say. Echo WD2 (or WD1 if no WD2 (SAY WHAT?, etc.).) Magic words override. */
{
- long a = command->wd1;
if (command->wd2 > 0) {
if (command->wd2 > 0) {
- a = command->wd2;
command->wd1 = command->wd2;
command->wd1 = command->wd2;
- strcpy(command->raw1, command->raw2);
+
strcpy(command->raw1, command->raw2);
}
}
- char word1[TOKLEN
+
1];
+ char word1[TOKLEN
+
1];
packed_to_token(command->wd1, word1);
int wd = (int) get_vocab_id(word1);
/* FIXME: magic numbers */
packed_to_token(command->wd1, word1);
int wd = (int) get_vocab_id(word1);
/* FIXME: magic numbers */