diff options
author | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-11 03:36:07 +0000 |
---|---|---|
committer | zelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573> | 2009-01-11 03:36:07 +0000 |
commit | 9d048940efbcf150729acca1e4962626a5db2299 (patch) | |
tree | 213cbe40ac33c9c8bda4ec20c409bbab727b8cff | |
parent | da22878d26b040a59f621a3a79730ee4dd7f9816 (diff) | |
download | crawl-ref-9d048940efbcf150729acca1e4962626a5db2299.tar.gz crawl-ref-9d048940efbcf150729acca1e4962626a5db2299.zip |
A limited set of commands are now available to use during arena mode:
look around ('x'), message history (Control-P) and suspend game (Control-Z).
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8408 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r-- | crawl-ref/docs/arena.txt | 16 | ||||
-rw-r--r-- | crawl-ref/source/acr.cc | 13 | ||||
-rw-r--r-- | crawl-ref/source/arena.cc | 56 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/state.cc | 14 | ||||
-rw-r--r-- | crawl-ref/source/state.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 14 |
8 files changed, 106 insertions, 21 deletions
diff --git a/crawl-ref/docs/arena.txt b/crawl-ref/docs/arena.txt index 901dd03638..72050361ec 100644 --- a/crawl-ref/docs/arena.txt +++ b/crawl-ref/docs/arena.txt @@ -63,6 +63,22 @@ and summon monsters with the Shadow Creatures spell: crawl -arena "test spawner v test spawner" + Commands +------------------------------------------------------------------------------ +There are a very limited number of command you can issue to the arena: + +* You can stop the arena simulation early by pressing Escape, 'q' or + Control-G. + +* You can look at the message history like in a normal game (Control-P). + +* You can look around the arena like in a normal game ('x'). + +* You can suspended the arena like in a normal game (Control-Z). + +If the arena has lots of monsters it might take a few second before it +responds. + Options and parameters ------------------------------------------------------------------------------ There are four arena parameters that you can set in your crawl options file: diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index a5425b651e..ca79d35a62 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1768,6 +1768,8 @@ static bool _marker_vetoes_stair() static void _go_downstairs(); static void _go_upstairs() { + ASSERT(!crawl_state.arena && !crawl_state.arena_suspended); + const dungeon_feature_type ygrd = grd(you.pos()); if (_stairs_check_mesmerised()) @@ -1812,6 +1814,8 @@ static void _go_upstairs() static void _go_downstairs() { + ASSERT(!crawl_state.arena && !crawl_state.arena_suspended); + bool shaft = (get_trap_type(you.pos()) == TRAP_SHAFT && grd(you.pos()) != DNGN_UNDISCOVERED_TRAP); @@ -2260,8 +2264,11 @@ void process_command( command_type cmd ) struct dist lmove; // Will be initialized by direction(). direction(lmove, DIR_TARGET, TARG_ANY, -1, true); - if (lmove.isValid && lmove.isTarget && !lmove.isCancel) + if (lmove.isValid && lmove.isTarget && !lmove.isCancel + && !crawl_state.arena_suspended) + { start_travel( lmove.target ); + } break; } @@ -3512,6 +3519,8 @@ static int _check_adjacent(dungeon_feature_type feat, coord_def& delta) // to be opened (eg if you type ctrl + dir). static void _open_door(coord_def move, bool check_confused) { + ASSERT(!crawl_state.arena && !crawl_state.arena_suspended); + if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) { mpr("You can't open doors in your present form."); @@ -4115,6 +4124,8 @@ static void _move_player(int move_x, int move_y) static void _move_player(coord_def move) { + ASSERT(!crawl_state.arena && !crawl_state.arena_suspended); + bool attacking = false; bool moving = true; // used to prevent eventual movement (swap) bool swap = false; diff --git a/crawl-ref/source/arena.cc b/crawl-ref/source/arena.cc index 2ac1f00434..f9b568184d 100644 --- a/crawl-ref/source/arena.cc +++ b/crawl-ref/source/arena.cc @@ -13,11 +13,13 @@ REVISION("$Rev$"); #include "arena.h" #include "chardump.h" #include "cio.h" +#include "command.h" #include "dungeon.h" #include "initfile.h" #include "items.h" #include "itemname.h" // for make_name() #include "libutil.h" +#include "macro.h" #include "maps.h" #include "message.h" #include "mon-pick.h" @@ -671,6 +673,44 @@ namespace arena } } + void handle_keypress(int ch) + { + if (ch == ESCAPE || tolower(ch) == 'q' || ch == CONTROL('G')) + { + contest_canceled = true; + mpr("Canceled contest at user request"); + return; + } + + const command_type cmd = key_to_command(ch, KC_DEFAULT); + + // We only allow a short list of commands to be used in the arena. + switch(cmd) + { + case CMD_LOOK_AROUND: + case CMD_SUSPEND_GAME: + case CMD_REPLAY_MESSAGES: + break; + + default: + return; + } + + if (file != NULL) + fflush(file); + + cursor_control coff(true); + + unwind_bool ar (crawl_state.arena, false); + unwind_bool ar_susp(crawl_state.arena_suspended, true); + + unwind_var<coord_def> pos(you.position); + coord_def yplace(dgn_find_feature_marker(DNGN_ESCAPE_HATCH_UP)); + you.moveto(yplace); + + process_command(cmd); + } + void do_fight() { mesclr(true); @@ -681,13 +721,10 @@ namespace arena if (kbhit()) { const int ch = getch(); - if (ch == ESCAPE || tolower(ch) == 'q' || - ch == CONTROL('G')) - { - contest_canceled = true; - mpr("Canceled contest at user request"); + handle_keypress(ch); + ASSERT(crawl_state.arena && !crawl_state.arena_suspended); + if (contest_canceled) return; - } } #ifdef DEBUG_DIAGNOSTICS @@ -1218,6 +1255,13 @@ int arena_cull_items() void run_arena() { + ASSERT(!crawl_state.arena_suspended); + +#ifdef WIZARD + // The playe has wizard powers for the duration of the arena. + unwind_bool wiz(you.wizard, true); +#endif + arena::global_setup(); arena::simulate(); arena::global_shutdown(); diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index 3a6a34c8f5..74e438a10b 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -4999,7 +4999,15 @@ void wizard_move_player_or_monster(const coord_def& where) int mid = mgrd(where); if (mid == NON_MONSTER) + { + if (crawl_state.arena_suspended) + { + mpr("You can't move yourself into the arena."); + more(); + return; + } _move_player(where); + } else _move_monster(where, mid); diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 52d1511380..36b276270b 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -1448,6 +1448,8 @@ void direction(dist& moves, targeting_type restricts, case CMD_TARGET_DESCRIBE: full_describe_square(moves.target); force_redraw = true; + if (crawl_state.arena_suspended) + need_beam_redraw = true; break; case CMD_TARGET_ALL_DESCRIBE: @@ -3069,7 +3071,7 @@ static void _describe_cell(const coord_def& where, bool in_range) bool cloud_described = false; bool item_described = false; - if (where == you.pos()) + if (where == you.pos() && !crawl_state.arena_suspended) mpr("You.", MSGCH_EXAMINE_FILTER); if (mgrd(where) != NON_MONSTER) diff --git a/crawl-ref/source/state.cc b/crawl-ref/source/state.cc index 001b6addb0..febc6e872d 100644 --- a/crawl-ref/source/state.cc +++ b/crawl-ref/source/state.cc @@ -27,13 +27,13 @@ game_state::game_state() : mouse_enabled(false), waiting_for_command(false), terminal_resized(false), io_inited(false), need_save(false), saving_game(false), updating_scores(false), seen_hups(0), - map_stat_gen(false), arena(false), unicode_ok(false), glyph2strfn(NULL), - multibyte_strlen(NULL), terminal_resize_handler(NULL), - terminal_resize_check(NULL), doing_prev_cmd_again(false), - prev_cmd(CMD_NO_CMD), repeat_cmd(CMD_NO_CMD), cmd_repeat_count(0), - cmd_repeat_goal(0), prev_repetition_turn(0), - cmd_repeat_started_unsafe(false), input_line_curr(0), - level_annotation_shown(false) + map_stat_gen(false), arena(false), arena_suspended(false), + unicode_ok(false), glyph2strfn(NULL), multibyte_strlen(NULL), + terminal_resize_handler(NULL), terminal_resize_check(NULL), + doing_prev_cmd_again(false), prev_cmd(CMD_NO_CMD), + repeat_cmd(CMD_NO_CMD), cmd_repeat_count(0), cmd_repeat_goal(0), + prev_repetition_turn(0), cmd_repeat_started_unsafe(false), + input_line_curr(0), level_annotation_shown(false) { reset_cmd_repeat(); reset_cmd_again(); diff --git a/crawl-ref/source/state.h b/crawl-ref/source/state.h index fe8ab01938..85abe5853b 100644 --- a/crawl-ref/source/state.h +++ b/crawl-ref/source/state.h @@ -43,6 +43,8 @@ struct game_state bool map_stat_gen; // Set if we're generating stats on maps. bool arena; // Set if we're in arena mode. + bool arena_suspended; // Set if the arena has been temporarily + // suspended. bool unicode_ok; // Is unicode support available? diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 143dffd0d1..f3bbd3986e 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -2823,7 +2823,7 @@ void losight(env_show_grid &sh, // clear out sh sh.init(0); - if (crawl_state.arena) + if (crawl_state.arena || crawl_state.arena_suspended) { for (int y = -ENV_SHOW_OFFSET; y <= ENV_SHOW_OFFSET; ++y) for (int x = -ENV_SHOW_OFFSET; x <= ENV_SHOW_OFFSET; ++x) @@ -3307,7 +3307,7 @@ static void _draw_level_map(int start_x, int start_y, bool travel_mode) buffer2[bufcount2 + 1] = colour; buffer2[bufcount2] = env.map(c).glyph(); - if (c == you.pos()) + if (c == you.pos() && !crawl_state.arena_suspended) { // [dshaligram] Draw the @ symbol on the level-map. It's no // longer saved into the env.map, so we need to draw it @@ -3933,7 +3933,7 @@ bool mons_near(const monsters *monster, unsigned short foe) if (foe == MHITYOU) { - if (crawl_state.arena) + if (crawl_state.arena || crawl_state.arena_suspended) return (true); if ( grid_distance(monster->pos(), you.pos()) <= LOS_RADIUS ) @@ -4001,7 +4001,8 @@ bool see_grid( const env_show_grid &show, // Answers the question: "Is a grid within character's line of sight?" bool see_grid( const coord_def &p ) { - return (crawl_state.arena && crawl_view.in_grid_los(p)) + return ((crawl_state.arena || crawl_state.arena_suspended) + && crawl_view.in_grid_los(p)) || see_grid(env.show, you.pos(), p); } @@ -5098,7 +5099,7 @@ void viewwindow(bool draw_it, bool do_updates) int count_x, count_y; - if (!crawl_state.arena) + if (!crawl_state.arena && !crawl_state.arena_suspended) { // Must be done first. losight(env.show, grd, you.pos()); @@ -5222,7 +5223,8 @@ void viewwindow(bool draw_it, bool do_updates) tileb[bufcount + 1] = bg | tile_unseen_flag(gc); #endif } - else if (gc == you.pos() && !crawl_state.arena) + else if (gc == you.pos() && !crawl_state.arena + && !crawl_state.arena_suspended) { int object = env.show(ep); unsigned short colour = env.show_col(ep); |