Add assistance to fire-command

Allows the fire-command to autowield a launcher; it will now
do either swapweapon or wield an appropriate launcher, if you
have ammo quivered.

This assistance can be turned off with the fireassist boolean option.

Adds a rudimentary command queue, which allows the code to add keys
or extended commands into the queue, and they're executed as if
the user did them.  Time passes normally when doing the queue,
and the queue will get cleared if hero is interrupted.
This commit is contained in:
Pasi Kallinen
2021-06-09 09:02:31 +03:00
parent f6e60c7516
commit 76f77ee0cc
15 changed files with 253 additions and 8 deletions

View File

@@ -644,6 +644,25 @@ struct _create_particular_data {
#define LUA_VER_BUFSIZ 20
#define LUA_COPYRIGHT_BUFSIZ 120
/*
* Rudimentary command queue.
* Allows the code to put keys and extended commands into the queue,
* and they're executed just as if the user did them. Time passes
* normally when doing queued actions. The queue will get cleared
* if hero is interrupted.
*/
enum cmdq_cmdtypes {
CMDQ_KEY = 0, /* a literal character, cmdq_add_key() */
CMDQ_EXTCMD, /* extended command, cmdq_add_ec() */
};
struct _cmd_queue {
int typ;
char key;
const struct ext_func_tab *ec_entry;
struct _cmd_queue *next;
};
/*
* 'g' -- instance_globals holds engine state that does not need to be
* persisted upon game exit. The initialization state is well defined
@@ -656,6 +675,8 @@ struct _create_particular_data {
*/
struct instance_globals {
struct _cmd_queue *command_queue;
/* apply.c */
int jumping_is_magic; /* current jump result of magic */
int polearm_range_min;

View File

@@ -199,12 +199,17 @@ extern char randomkey(void);
extern void random_response(char *, int);
extern int rnd_extcmd_idx(void);
extern int domonability(void);
extern const struct ext_func_tab *ext_func_tab_from_func(int(*)(void));
extern char cmd_from_func(int(*)(void));
extern const char *cmdname_from_func(int(*)(void), char *, boolean);
extern boolean redraw_cmd(char);
extern const char *levltyp_to_name(int);
extern void reset_occupations(void);
extern void set_occupation(int(*)(void), const char *, int);
extern void cmdq_add_ec(int(*)(void));
extern void cmdq_add_key(char);
extern struct _cmd_queue *cmdq_pop(void);
extern void cmdq_clear(void);
extern char pgetchar(void);
extern void pushch(char);
extern void savech(char);

View File

@@ -293,6 +293,7 @@ struct instance_flags {
#endif
boolean clicklook; /* allow right-clicking for look */
boolean cmdassist; /* provide detailed assistance for some comnds */
boolean fireassist; /* autowield launcher when using fire-command */
boolean time_botl; /* context.botl for 'time' (moves) only */
boolean wizweight; /* display weight of everything in wizard mode */
boolean wizmgender; /* test gender info from core in window port */

View File

@@ -170,6 +170,8 @@ opt_##a,
&iflags.extmenu)
NHOPTB(female, 0, opt_in, set_in_config, Off, Yes, No, No, "male",
&flags.female)
NHOPTB(fireassist, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
&iflags.fireassist)
NHOPTB(fixinv, 0, opt_out, set_in_game, On, Yes, No, No, NoAlias,
&flags.invlet_constant)
NHOPTC(font_map, 40, opt_in, set_gameview, Yes, Yes, Yes, No, NoAlias,