diff options
Diffstat (limited to 'crawl-ref')
-rw-r--r-- | crawl-ref/source/command.cc | 1 | ||||
-rw-r--r-- | crawl-ref/source/debug.cc | 79 | ||||
-rw-r--r-- | crawl-ref/source/debug.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/directn.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 1 |
5 files changed, 93 insertions, 0 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index db47d0442c..ca6f166666 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -660,6 +660,7 @@ static const char *targeting_help_1 = "<w>s</w>: force monster to shout or speak\n" "<w>F</w>: cycle monster friendly/good neutral/neutral/hostile\n" "<w>P</w>: apply divine blessing to monster\n" + "<w>m</w>: move monster or player\n" #endif ; diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index e2e369fd25..5d3a23f408 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -75,6 +75,7 @@ #include "monspeak.h" #include "monstuff.h" #include "mon-util.h" +#include "mstuff2.h" #include "mutation.h" #include "newgame.h" #include "ouch.h" @@ -3796,6 +3797,84 @@ void wizard_give_monster_item(monsters *mon) } #endif +#ifdef WIZARD + +static void _move_player(int x, int y) +{ + // no longer held in net + clear_trapping_net(); + + if (!you.can_pass_through_feat(grd[x][y])) + grd[x][y] = DNGN_FLOOR; + move_player_to_grid(x, y, false, true, true); +} + +static void _move_monster(int x, int y, int mid1) +{ + dist moves; + direction(moves, DIR_NONE, TARG_ANY, -1, true, false, + "Move monster to where?"); + + if (!moves.isValid || !in_bounds(moves.tx, moves.ty)) + return; + + struct monsters* mon1 = &menv[mid1]; + if (mons_is_caught(mon1)) + mons_clear_trapping_net(mon1); + + int mid2 = mgrd[moves.tx][moves.ty]; + struct monsters* mon2 = NULL; + + if (mid2 != NON_MONSTER) + { + mon2 = &menv[mid2]; + + if (mons_is_caught(mon2)) + mons_clear_trapping_net(mon2); + } + + mon1->x = moves.tx; + mon1->y = moves.ty; + mgrd[moves.tx][moves.ty] = mid1; + mon1->check_redraw(moves.target()); + + mgrd[x][y] = mid2; + + if (mon2 != NULL) + { + mon2->x = x; + mon2->y = y; + + mon1->check_redraw(coord_def(x, y)); + } +} + +void wizard_move_player_or_monster(int x, int y) +{ + crawl_state.cancel_cmd_again(); + crawl_state.cancel_cmd_repeat(); + + static bool already_moving = false; + + if (already_moving) + { + mpr("Already doing a move command."); + return; + } + + already_moving = true; + + int mid = mgrd[x][y]; + + if (mid == NON_MONSTER) + _move_player(x, y); + else + _move_monster(x, y, mid); + + already_moving = false; +} +#endif + #ifdef DEBUG_DIAGNOSTICS // Map statistics generation. diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h index 3a89575998..6b4039bd8b 100644 --- a/crawl-ref/source/debug.h +++ b/crawl-ref/source/debug.h @@ -164,6 +164,7 @@ class monsters; void debug_make_monster_shout(monsters* mon); void debug_apply_monster_blessing(monsters* mon); void wizard_give_monster_item(monsters* mon); +void wizard_move_player_or_monster(int x, int y); #ifdef DEBUG_DIAGNOSTICS void generate_map_stats(); diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 30cad152a3..1cb11e4303 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -900,6 +900,16 @@ void direction(dist& moves, targeting_type restricts, wizard_give_monster_item(&menv[mid]); break; + + case CMD_TARGET_WIZARD_MOVE: + if (!you.wizard || !in_bounds(moves.tx, moves.ty)) + break; + wizard_move_player_or_monster(moves.tx, moves.ty); + + loop_done = true; + skip_iter = true; + + break; #endif case CMD_TARGET_DESCRIBE: @@ -2464,6 +2474,7 @@ command_type targeting_behaviour::get_command(int key) case 'P': return CMD_TARGET_WIZARD_BLESS_MONSTER; case 's': return CMD_TARGET_WIZARD_MAKE_SHOUT; case 'g': return CMD_TARGET_WIZARD_GIVE_ITEM; + case 'm': return CMD_TARGET_WIZARD_MOVE; #endif case 'v': return CMD_TARGET_DESCRIBE; case '?': return CMD_TARGET_HELP; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 425e92b957..873fb760cf 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -599,6 +599,7 @@ enum command_type CMD_TARGET_WIZARD_BLESS_MONSTER, CMD_TARGET_WIZARD_MAKE_SHOUT, CMD_TARGET_WIZARD_GIVE_ITEM, + CMD_TARGET_WIZARD_MOVE, CMD_TARGET_HELP, #ifdef USE_TILE |