All specials are now actions. Builds correct outputs, more needs deleting.

This commit is contained in:
Aaron Traas 2017-07-21 16:56:43 -04:00
parent 80b2b9b356
commit 5f28f95244
3 changed files with 55 additions and 48 deletions

View file

@ -1313,6 +1313,14 @@ int action(struct command_t *command)
* unless verb is "say", which snarfs arbitrary second word. * unless verb is "say", which snarfs arbitrary second word.
*/ */
{ {
/* Previously, actions that result in a message, but don't do anything
* further were called "specials". Now they're handled here as normal
* actions. If noaction is true, then we spit out the message and return */
if (actions[command->verb].noaction) {
speak(actions[command->verb].message);
return GO_CLEAROBJ;
}
if (command->part == unknown) { if (command->part == unknown) {
/* Analyse an object word. See if the thing is here, whether /* Analyse an object word. See if the thing is here, whether
* we've got a verb yet, and so on. Object must be here * we've got a verb yet, and so on. Object must be here

View file

@ -3889,15 +3889,15 @@ actions: !!omap
- ACT_UNKNOWN: - ACT_UNKNOWN:
message: *huh_man message: *huh_man
words: !!null words: !!null
- THANKYOU:
specials: !!omap
- SPC_THANKYOU:
message: 'You''re quite welcome.' message: 'You''re quite welcome.'
words: ['thank'] words: ['thank']
- SPC_INVALIDMAGIC: noaction: true
- INVALIDMAGIC:
message: 'Good try, but that is an old worn-out magic word.' message: 'Good try, but that is an old worn-out magic word.'
words: ['sesam', 'opens', 'abra', 'abrac', 'shaza', 'hocus', 'pocus'] words: ['sesam', 'opens', 'abra', 'abrac', 'shaza', 'hocus', 'pocus']
- SPC_HELP: noaction: true
- HELP:
message: |- message: |-
I know of places, actions, and things. Most of my vocabulary I know of places, actions, and things. Most of my vocabulary
describes places and is used to move you there. To move, try words describes places and is used to move you there. To move, try words
@ -3929,10 +3929,12 @@ specials: !!omap
though the direction that takes you back might not be the reverse of though the direction that takes you back might not be the reverse of
what got you here. Good luck, and have fun! what got you here. Good luck, and have fun!
words: ['help', '?'] words: ['help', '?']
- SPC_NO: noaction: true
- NO:
message: *ok_man message: *ok_man
words: ['no'] words: ['no']
- SPC_TREE: noaction: true
- TREE:
message: |- message: |-
The trees of the forest are large hardwood oak and maple, with an The trees of the forest are large hardwood oak and maple, with an
occasional grove of pine or spruce. There is quite a bit of under- occasional grove of pine or spruce. There is quite a bit of under-
@ -3941,27 +3943,33 @@ specials: !!omap
all the leaves, but travel is quite easy if you detour around the all the leaves, but travel is quite easy if you detour around the
spruce and berry bushes. spruce and berry bushes.
words: ['tree', 'trees'] words: ['tree', 'trees']
- SPC_DIG: noaction: true
- DIG:
message: |- message: |-
Digging without a shovel is quite impractical. Even with a shovel Digging without a shovel is quite impractical. Even with a shovel
progress is unlikely. progress is unlikely.
words: ['dig', 'excav'] words: ['dig', 'excav']
- SPC_LOST: noaction: true
- LOST:
message: 'I''m as confused as you are.' message: 'I''m as confused as you are.'
words: ['lost'] words: ['lost']
- SPC_MIST: noaction: true
- MIST:
message: |- message: |-
Mist is a white vapor, usually water, seen from time to time in Mist is a white vapor, usually water, seen from time to time in
caverns. It can be found anywhere but is frequently a sign of a deep caverns. It can be found anywhere but is frequently a sign of a deep
pit leading down to water.' pit leading down to water.'
words: ['mist'] words: ['mist']
- SPC_FBOMB: noaction: true
- FBOMB:
message: 'Watch it!' message: 'Watch it!'
words: ['fuck'] words: ['fuck']
- SPC_STOP: noaction: true
- STOP:
message: 'I don''t know the word "stop". Use "quit" if you want to give up.' message: 'I don''t know the word "stop". Use "quit" if you want to give up.'
words: ['stop'] words: ['stop']
- SPC_INFO: noaction: true
- INFO:
message: |- message: |-
For a summary of the most recent changes to the game, say "news". For a summary of the most recent changes to the game, say "news".
If you want to end your adventure early, say "quit". To suspend your If you want to end your adventure early, say "quit". To suspend your
@ -3985,16 +3993,20 @@ specials: !!omap
save time, you may specify "brief", which tells me never to repeat the save time, you may specify "brief", which tells me never to repeat the
full description of a place unless you explicitly ask me to. full description of a place unless you explicitly ask me to.
words: ['info', 'infor'] words: ['info', 'infor']
- SPC_SWIM: noaction: true
- SWIM:
message: *not_knowhow message: *not_knowhow
words: ['swim'] words: ['swim']
- SPC_WIZARD: noaction: true
- WIZARD:
message: 'Wizards are not to be disturbed by such as you.' message: 'Wizards are not to be disturbed by such as you.'
words: ['wizar'] words: ['wizar']
- SPC_YES: noaction: true
- YES:
message: 'Guess again.' message: 'Guess again.'
words: ['yes'] words: ['yes']
- SPC_NEWS: noaction: true
- NEWS:
message: |- message: |-
Open Adventure is an author-approved open-source release of Open Adventure is an author-approved open-source release of
Version 2.5 with, as yet, no gameplay changes. Version 2.5 with, as yet, no gameplay changes.
@ -4006,11 +4018,19 @@ specials: !!omap
while first), but it now costs you a few points each time you save the while first), but it now costs you a few points each time you save the
game. Saved games are now stored in much smaller files than before. game. Saved games are now stored in much smaller files than before.
words: ['news'] words: ['news']
- SPC_VERSION: noaction: true
- ACT_VERSION:
message: |- message: |-
There is a puff of orange smoke; within it, fiery runes spell out: There is a puff of orange smoke; within it, fiery runes spell out:
\tOpen Adventure %V - http://www.catb.org/esr/open-adventure/ \tOpen Adventure %V - http://www.catb.org/esr/open-adventure/
words: ['versi'] words: ['versi']
noaction: true
# Specials no longer used, but this is still needed for now
specials: !!omap
- SPC_DELETEME:
message: 'Please delete this item'
words: ['null']
# end # end

View file

@ -105,11 +105,13 @@ typedef struct {{
typedef struct {{ typedef struct {{
const string_group_t words; const string_group_t words;
const char* message; const char* message;
const bool noaction;
}} action_t; }} action_t;
typedef struct {{ typedef struct {{
const string_group_t words; const string_group_t words;
const char* message; const char* message;
const bool noaction;
}} special_t; }} special_t;
enum condtype_t {{cond_goto, cond_pct, cond_carry, cond_with, cond_not}}; enum condtype_t {{cond_goto, cond_pct, cond_carry, cond_with, cond_not}};
@ -497,39 +499,11 @@ def get_motions(motions):
ignore += word.upper() ignore += word.upper()
return mot_str return mot_str
def get_actions(actions):
template = """ {{
.words = {},
.message = {},
}},
"""
act_str = ""
for action in actions:
contents = action[1]
if contents["words"] == None:
words_str = get_string_group([])
else:
words_str = get_string_group(contents["words"])
if contents["message"] == None:
message = "NO_MESSAGE"
else:
message = contents["message"]
act_str += template.format(words_str, message)
global ignore
if contents.get("oldstyle", True) == False:
for word in contents["words"]:
if len(word) == 1:
ignore += word.upper()
act_str = act_str[:-1] # trim trailing newline
return act_str
def get_specials(specials): def get_specials(specials):
template = """ {{ template = """ {{
.words = {}, .words = {},
.message = {}, .message = {},
.noaction = {},
}}, }},
""" """
spc_str = "" spc_str = ""
@ -546,7 +520,12 @@ def get_specials(specials):
else: else:
message = make_c_string(contents["message"]) message = make_c_string(contents["message"])
spc_str += template.format(words_str, message) if contents.get("noaction") == None:
noaction = "false"
else:
noaction = "true"
spc_str += template.format(words_str, message, noaction)
global ignore global ignore
if contents.get("oldstyle", True) == False: if contents.get("oldstyle", True) == False:
for word in contents["words"]: for word in contents["words"]: