summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-02 04:25:42 +0000
committerzelgadis <zelgadis@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-02 04:25:42 +0000
commitc2934ef52cd1c8e65712f0800f19080981e0db81 (patch)
tree2f1880e114a13e3cd940f7bd057e5c5c0363d5d1 /crawl-ref
parent1eb7f2d5a83ed55299e3ed5c11aab34eb70732f4 (diff)
downloadcrawl-ref-c2934ef52cd1c8e65712f0800f19080981e0db81.tar.gz
crawl-ref-c2934ef52cd1c8e65712f0800f19080981e0db81.zip
The wizard "tweak item" command can now alter randart properties.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5429 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/debug.cc171
-rw-r--r--crawl-ref/source/randart.cc32
-rw-r--r--crawl-ref/source/randart.h8
3 files changed, 209 insertions, 2 deletions
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index abaefed3d0..48c3c0a3ce 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -1308,6 +1308,159 @@ void create_spec_object()
//
//---------------------------------------------------------------
#ifdef WIZARD
+
+const char* _prop_name[RAP_NUM_PROPERTIES] = {
+ "Brand",
+ "AC",
+ "EV",
+ "Str",
+ "Int",
+ "Dex",
+ "Fire",
+ "Cold",
+ "Elec",
+ "Pois",
+ "Neg",
+ "Mag",
+ "SInv",
+ "Inv",
+ "Lev",
+ "Blnk",
+ "Tele",
+ "Bers",
+ "Map",
+ "Nois",
+ "NoSpl",
+ "RndTl",
+ "NoTel",
+ "Anger",
+ "Metab",
+ "Mut",
+ "Acc",
+ "Dam",
+ "Curse",
+ "Stlth",
+ "MP"
+};
+
+#define RAP_VAL_BOOL 0
+#define RAP_VAL_POS 1
+#define RAP_VAL_ANY 2
+
+char _prop_type[RAP_NUM_PROPERTIES] = {
+ RAP_VAL_POS, //BRAND
+ RAP_VAL_ANY, //AC
+ RAP_VAL_ANY, //EVASION
+ RAP_VAL_ANY, //STRENGTH
+ RAP_VAL_ANY, //INTELLIGENCE
+ RAP_VAL_ANY, //DEXTERITY
+ RAP_VAL_ANY, //FIRE
+ RAP_VAL_ANY, //COLD
+ RAP_VAL_BOOL, //ELECTRICITY
+ RAP_VAL_BOOL, //POISON
+ RAP_VAL_BOOL, //NEGATIVE_ENERGY
+ RAP_VAL_POS, //MAGIC
+ RAP_VAL_BOOL, //EYESIGHT
+ RAP_VAL_BOOL, //INVISIBLE
+ RAP_VAL_BOOL, //LEVITATE
+ RAP_VAL_BOOL, //BLINK
+ RAP_VAL_BOOL, //CAN_TELEPORT
+ RAP_VAL_BOOL, //BERSERK
+ RAP_VAL_BOOL, //MAPPING
+ RAP_VAL_POS, //NOISES
+ RAP_VAL_BOOL, //PREVENT_SPELLCASTING
+ RAP_VAL_BOOL, //CAUSE_TELEPORTATION
+ RAP_VAL_BOOL, //PREVENT_TELEPORTATION
+ RAP_VAL_POS, //ANGRY
+ RAP_VAL_POS, //METABOLISM
+ RAP_VAL_POS, //MUTAGENIC
+ RAP_VAL_ANY, //ACCURACY
+ RAP_VAL_ANY, //DAMAGE
+ RAP_VAL_POS, //CURSED
+ RAP_VAL_ANY, //STEALTH
+ RAP_VAL_ANY //MAGICAL_POWER
+};
+
+static void _tweak_randart(item_def &item)
+{
+ if (item_is_equipped(item))
+ {
+ mpr("You can't tweak the randart properties of an equipped item.",
+ MSGCH_PROMPT);
+ return;
+ }
+
+ randart_properties_t props;
+ randart_wpn_properties(item, props);
+
+ std::string prompt = "";
+
+ for (int i = 0; i < RAP_NUM_PROPERTIES; i++)
+ {
+ if (i % 8 == 0 && i != 0)
+ prompt += "\n";
+
+ char choice;
+ char buf[80];
+
+ if (i < 26)
+ choice = 'A' + i;
+ else
+ choice = '1' + i - 26;
+
+ if (props[i])
+ sprintf(buf, "%c) <w>%-5s</w> ", choice, _prop_name[i]);
+ else
+ sprintf(buf, "%c) %-5s ", choice, _prop_name[i]);
+
+ prompt += buf;
+ }
+ formatted_message_history(prompt, MSGCH_PROMPT, 0, 80);
+
+ mpr( "Change which field? ", MSGCH_PROMPT );
+
+ char keyin = tolower( get_ch() );
+ int choice;
+
+ if (isalpha(keyin))
+ choice = keyin - 'a';
+ else if (isdigit(keyin) && keyin != '0')
+ choice = keyin - '1' + 26;
+ else
+ return;
+
+ int val;
+ switch(_prop_type[choice])
+ {
+ case RAP_VAL_BOOL:
+ mprf(MSGCH_PROMPT, "Toggling %s to %s.", _prop_name[choice],
+ props[choice] ? "off" : "on");
+ randart_set_property(item, static_cast<randart_prop_type>(choice),
+ !props[choice]);
+ break;
+
+ case RAP_VAL_POS:
+ mprf(MSGCH_PROMPT, "%s was %d.", _prop_name[choice], props[choice]);
+ val = _debug_prompt_for_int("New value? ", true);
+
+ if (val < 0)
+ {
+ mprf(MSGCH_PROMPT, "Value for %s must be non-negative",
+ _prop_name[choice]);
+ return;
+ }
+ randart_set_property(item, static_cast<randart_prop_type>(choice),
+ val);
+ break;
+ case RAP_VAL_ANY:
+ mprf(MSGCH_PROMPT, "%s was %d.", _prop_name[choice], props[choice]);
+ val = _debug_prompt_for_int("New value? ", false);
+ randart_set_property(item, static_cast<randart_prop_type>(choice),
+ val);
+ break;
+ }
+}
+
void tweak_object(void)
{
char specs[50];
@@ -1323,6 +1476,9 @@ void tweak_object(void)
if (item == you.equip[EQ_WEAPON])
you.wield_change = true;
+ const bool is_art = is_artefact(you.inv[item])
+ && !is_unrandom_artefact(you.inv[item]);
+
while (true)
{
void *field_ptr = NULL;
@@ -1331,8 +1487,13 @@ void tweak_object(void)
{
mpr( you.inv[item].name(DESC_INVENTORY_EQUIP).c_str() );
- mpr( "a - plus b - plus2 c - special d - quantity e - flags ESC - exit",
- MSGCH_PROMPT );
+ if (is_art)
+ mpr( "a - plus b - plus2 c - art props d - quantity "
+ "e - flags ESC - exit", MSGCH_PROMPT );
+ else
+ mpr( "a - plus b - plus2 c - special d - quantity "
+ "e - flags ESC - exit", MSGCH_PROMPT );
+
mpr( "Which field? ", MSGCH_PROMPT );
keyin = tolower( get_ch() );
@@ -1358,6 +1519,12 @@ void tweak_object(void)
break;
}
+ if (is_art && keyin == 'c')
+ {
+ _tweak_randart(you.inv[item]);
+ continue;
+ }
+
if (keyin != 'c' && keyin != 'e')
{
const short *const ptr = static_cast< short * >( field_ptr );
diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc
index 5239139a0a..951ab6427e 100644
--- a/crawl-ref/source/randart.cc
+++ b/crawl-ref/source/randart.cc
@@ -1929,3 +1929,35 @@ const char *unrandart_descrip( int which_descrip, const item_def &item )
(which_descrip == 2) ? unrand->spec_descrip3
: "Unknown.");
}
+
+void randart_set_properties( item_def &item,
+ randart_properties_t &proprt )
+{
+ ASSERT( is_random_artefact( item ) );
+ ASSERT( !is_unrandom_artefact ( item ) );
+ ASSERT( item.props.exists( RANDART_PROPS_KEY ) );
+
+ CrawlVector &rap_vec = item.props[RANDART_PROPS_KEY].get_vector();
+ ASSERT( rap_vec.get_type() == SV_SHORT );
+ ASSERT( rap_vec.size() == RA_PROPERTIES);
+ ASSERT( rap_vec.get_max_size() == RA_PROPERTIES);
+
+ for (vec_size i = 0; i < RA_PROPERTIES; i++)
+ rap_vec[i].get_short() = proprt[i];
+}
+
+void randart_set_property( item_def &item,
+ randart_prop_type prop,
+ int val )
+{
+ ASSERT( is_random_artefact( item ) );
+ ASSERT( !is_unrandom_artefact ( item ) );
+ ASSERT( item.props.exists( RANDART_PROPS_KEY ) );
+
+ CrawlVector &rap_vec = item.props[RANDART_PROPS_KEY].get_vector();
+ ASSERT( rap_vec.get_type() == SV_SHORT );
+ ASSERT( rap_vec.size() == RA_PROPERTIES);
+ ASSERT( rap_vec.get_max_size() == RA_PROPERTIES);
+
+ rap_vec[prop].get_short() = val;
+}
diff --git a/crawl-ref/source/randart.h b/crawl-ref/source/randart.h
index 81d640679c..c6ac468c99 100644
--- a/crawl-ref/source/randart.h
+++ b/crawl-ref/source/randart.h
@@ -113,4 +113,12 @@ void set_unrandart_exist(int whun, bool is_exist);
int find_unrandart_index(const item_def& artefact);
int find_unrandart_index(const item_def &item);
+/* ***********************************************************************
+ * called from: debug
+ * *********************************************************************** */
+void randart_set_properties( item_def &item,
+ randart_properties_t &proprt );
+void randart_set_property( item_def &item,
+ randart_prop_type prop,
+ int val );
#endif