summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-22 10:45:59 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2006-09-22 10:45:59 +0000
commita7ed5868fa0c7ebf712b518bfb2d75c3d9887128 (patch)
tree2cef4b8987152cf13878f5f042bf3425169f70c4 /crawl-ref
parent9291d6fd9854cc88b30bf6739da38b3cface7052 (diff)
downloadcrawl-ref-a7ed5868fa0c7ebf712b518bfb2d75c3d9887128.tar.gz
crawl-ref-a7ed5868fa0c7ebf712b518bfb2d75c3d9887128.zip
Added a debug command to create a trap of any kind for easier trap-testing
porpoises. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup@64 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/acr.cc4
-rw-r--r--crawl-ref/source/debug.cc65
-rw-r--r--crawl-ref/source/debug.h1
-rw-r--r--crawl-ref/source/describe.cc13
-rw-r--r--crawl-ref/source/describe.h3
-rw-r--r--crawl-ref/source/travel.cc10
6 files changed, 88 insertions, 8 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index 8e192a5c1f..ffe72abf05 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -577,6 +577,10 @@ static void handle_wizard_command( void )
tweak_object();
break;
+ case 'T':
+ debug_make_trap();
+ break;
+
case 'f':
debug_fight_statistics(false);
break;
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 08822e84a3..bd1bb85f67 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -29,6 +29,7 @@
#include "externs.h"
#include "direct.h"
+#include "describe.h"
#include "dungeon.h"
#include "fight.h"
#include "invent.h"
@@ -49,6 +50,7 @@
#include "spl-cast.h"
#include "spl-util.h"
#include "stuff.h"
+#include "travel.h"
#include "version.h"
#ifndef WIZARD
@@ -2117,4 +2119,67 @@ void debug_fight_statistics(bool use_defaults)
fsim_mcleanup:
monster_die(&menv[mindex], KILL_DISMISSED, 0);
}
+
+static int find_trap_slot()
+{
+ for (int i = 0; i < MAX_TRAPS; ++i)
+ {
+ if (env.trap[i].type == TRAP_UNASSIGNED)
+ return (i);
+ }
+ return (-1);
+}
+
+void debug_make_trap()
+{
+ char requested_trap[80];
+ int trap_slot = find_trap_slot();
+ trap_type trap = TRAP_UNASSIGNED;
+ int gridch = grd[you.x_pos][you.y_pos];
+
+ if (trap_slot == -1)
+ {
+ mpr("Sorry, this level can't take any more traps.");
+ return;
+ }
+
+ if (gridch != DNGN_FLOOR)
+ {
+ mpr("You need to be on a floor square to make a trap.");
+ return;
+ }
+
+ mprf(MSGCH_PROMPT, "What kind of trap? ");
+ get_input_line( requested_trap, sizeof( requested_trap ) );
+ if (!*requested_trap)
+ return;
+
+ strlwr(requested_trap);
+ for (int t = TRAP_DART; t < NUM_TRAPS; ++t)
+ {
+ if (strstr(requested_trap,
+ trap_name(trap_type(t))))
+ {
+ trap = trap_type(t);
+ break;
+ }
+ }
+
+ if (trap == TRAP_UNASSIGNED)
+ {
+ mprf("I know no traps named \"%s\"", requested_trap);
+ return;
+ }
+
+ env.trap[trap_slot].type = trap;
+ env.trap[trap_slot].x = you.x_pos;
+ env.trap[trap_slot].y = you.y_pos;
+ grd[you.x_pos][you.y_pos] = DNGN_UNDISCOVERED_TRAP;
+
+ mprf("Created a %s trap, marked it undiscovered",
+ trap_name(trap));
+
+ // Also tell travel that its world-view must change.
+ travel_init_new_level();
+}
#endif
diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h
index 3df332441d..1a8a743916 100644
--- a/crawl-ref/source/debug.h
+++ b/crawl-ref/source/debug.h
@@ -144,5 +144,6 @@ void debug_item_scan( void );
void debug_get_religion( void );
void debug_change_species( void );
void debug_fight_statistics( bool use_init_defaults );
+void debug_make_trap( void );
#endif
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index bca3575d66..65deaa249f 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -332,6 +332,19 @@ static void randart_descpr( std::string &description, const item_def &item )
}
}
+static const char *trap_names[] =
+{
+ "dart", "arrow", "spear", "axe",
+ "teleport", "amnesia", "blade",
+ "bolt", "zot", "needle",
+};
+
+const char *trap_name(trap_type trap)
+{
+ if (trap >= TRAP_DART && trap < NUM_TRAPS)
+ return trap_names[ static_cast<int>( trap ) ];
+ return (NULL);
+}
//---------------------------------------------------------------
//
diff --git a/crawl-ref/source/describe.h b/crawl-ref/source/describe.h
index 981f90ce01..01a9657618 100644
--- a/crawl-ref/source/describe.h
+++ b/crawl-ref/source/describe.h
@@ -15,6 +15,7 @@
#include <string>
#include "externs.h"
+#include "enum.h"
// last updated 12may2000 {dlb}
/* ***********************************************************************
@@ -61,4 +62,6 @@ void describe_spell(int spelled);
* *********************************************************************** */
std::string ghost_description(bool concise = false);
+const char *trap_name(trap_type trap);
+
#endif
diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc
index a5381df8c6..b6f7f22ec5 100644
--- a/crawl-ref/source/travel.cc
+++ b/crawl-ref/source/travel.cc
@@ -11,6 +11,7 @@
#include "files.h"
#include "FixAry.h"
#include "clua.h"
+#include "describe.h"
#include "mon-util.h"
#include "player.h"
#include "stash.h"
@@ -194,13 +195,6 @@ static void init_traps()
traps_inited = true;
}
-static const char *trap_names[] =
-{
- "dart", "arrow", "spear", "axe",
- "teleport", "amnesia", "blade",
- "bolt", "zot", "needle",
-};
-
static const char *trap_name(int x, int y)
{
if (!traps_inited)
@@ -211,7 +205,7 @@ static const char *trap_name(int x, int y)
{
int type = env.trap[ti].type;
if (type >= 0 && type < NUM_TRAPS)
- return (trap_names[type]);
+ return (trap_name(trap_type(type)));
}
return ("");
}