summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-27 22:57:53 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-27 22:57:53 +0000
commite1862125ea4fce442dd14faf3c1668a866876964 (patch)
tree00af2a10a40fb00cc932521dabc8692724ec1598 /crawl-ref/source
parent1e9759d7afc0d4b75b3d5a3c7af2adebf99c99ab (diff)
downloadcrawl-ref-e1862125ea4fce442dd14faf3c1668a866876964.tar.gz
crawl-ref-e1862125ea4fce442dd14faf3c1668a866876964.zip
Implement the first part of FR 2055862: Make the database search also
output AC/EV and damage/accuracy/speed for armour and weapons, respectively. Also, you can now wish for specific fixed and randarts in wizard mode via the 'o' command. (I was getting annoyed at always having to create all of them whenever I wanted to play around with the Singing Sword.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7048 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/command.cc23
-rw-r--r--crawl-ref/source/debug.cc437
-rw-r--r--crawl-ref/source/debug.h6
-rw-r--r--crawl-ref/source/describe.cc44
-rw-r--r--crawl-ref/source/describe.h6
5 files changed, 316 insertions, 200 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 49241aea20..94eafa6827 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -21,6 +21,7 @@
#include "chardump.h"
#include "cio.h"
#include "database.h"
+#include "debug.h"
#include "describe.h"
#include "files.h"
#include "initfile.h"
@@ -1191,6 +1192,28 @@ static bool _do_description(std::string key, std::string footer = "")
suffix += getLongDescription(symbol_suffix + "_lookup");
quote += getQuoteString(symbol_suffix);
}
+ else
+ {
+ int thing_created = get_item_slot();
+ if (thing_created != NON_ITEM)
+ {
+ char name[80];
+ snprintf(name, 80, key.c_str());
+ if (get_item_by_name(&mitm[thing_created], name, OBJ_WEAPONS))
+ {
+ append_weapon_stats(desc, mitm[thing_created]);
+ desc += "$";
+ }
+ else if (get_item_by_name(&mitm[thing_created], name, OBJ_ARMOUR))
+ {
+ append_armour_stats(desc, mitm[thing_created]);
+ desc += "$";
+ }
+
+ // Now we don't need the item anymore.
+ destroy_item(thing_created);
+ }
+ }
}
key = uppercase_first(key);
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index b709be9936..c3c28768b1 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -834,7 +834,6 @@ void debug_list_monsters()
#endif
#ifdef WIZARD
-
static void _rune_from_specs(const char* _specs, item_def &item)
{
char specs[80];
@@ -1097,39 +1096,11 @@ static bool _book_from_spell(const char* specs, item_def &item)
//---------------------------------------------------------------
void wizard_create_spec_object()
{
- static int max_subtype[] =
- {
- NUM_WEAPONS,
- NUM_MISSILES,
- NUM_ARMOURS,
- NUM_WANDS,
- NUM_FOODS,
- 0, // unknown I
- NUM_SCROLLS,
- NUM_JEWELLERY,
- NUM_POTIONS,
- 0, // unknown II
- NUM_BOOKS,
- NUM_STAVES,
- 0, // Orbs -- only one, handled specially
- NUM_MISCELLANY,
- 0, // corpses -- handled specially
- 0, // gold -- handled specially
- 0, // "gemstones" -- no items of type
- };
-
char specs[80];
- char obj_name[ ITEMNAME_SIZE ];
char keyin;
-
- char * ptr;
- int best_index;
int mon;
- int i;
object_class_type class_wanted = OBJ_UNASSIGNED;
- int type_wanted = -1;
- int special_wanted = 0;
int thing_created;
@@ -1246,209 +1217,313 @@ void wizard_create_spec_object()
return;
}
- // In order to get the sub-type, we'll fill out the base type...
- // then we're going to iterate over all possible subtype values
- // and see if we get a winner. -- bwr
- mitm[thing_created].base_type = class_wanted;
- mitm[thing_created].sub_type = 0;
- mitm[thing_created].plus = 0;
- mitm[thing_created].plus2 = 0;
- mitm[thing_created].special = 0;
- mitm[thing_created].flags = 0;
- mitm[thing_created].quantity = 1;
- set_ident_flags( mitm[thing_created], ISFLAG_IDENT_MASK );
+ if (!get_item_by_name(&mitm[thing_created], specs, class_wanted, true))
+ {
+ mpr( "No such item." );
+
+ // Clean up item
+ destroy_item(thing_created);
+ return;
+ }
+ }
+
+ // Deck colour (which control rarity) already set.
+ if (!is_deck(mitm[thing_created]))
+ item_colour( mitm[thing_created] );
+
+ move_item_to_grid( &thing_created, you.pos() );
+
+ if (thing_created != NON_ITEM)
+ {
+ // orig_monnum is used in corpses for things like the Animate
+ // Dead spell, so leave it alone.
+ if (class_wanted != OBJ_CORPSES)
+ origin_acquired( mitm[thing_created], AQ_WIZMODE );
+ canned_msg( MSG_SOMETHING_APPEARS );
+ }
+}
+#endif
+
+bool get_item_by_name(item_def *item, char* specs,
+ object_class_type class_wanted, bool create_for_real)
+{
+ static int max_subtype[] =
+ {
+ NUM_WEAPONS,
+ NUM_MISSILES,
+ NUM_ARMOURS,
+ NUM_WANDS,
+ NUM_FOODS,
+ 0, // unknown I
+ NUM_SCROLLS,
+ NUM_JEWELLERY,
+ NUM_POTIONS,
+ 0, // unknown II
+ NUM_BOOKS,
+ NUM_STAVES,
+ 0, // Orbs -- only one, handled specially
+ NUM_MISCELLANY,
+ 0, // corpses -- handled specially
+ 0, // gold -- handled specially
+ 0, // "gemstones" -- no items of type
+ };
+
+ char obj_name[ ITEMNAME_SIZE ];
+ char* ptr;
+ int i;
+ int best_index;
+ int type_wanted = -1;
+ int special_wanted = 0;
- if (class_wanted == OBJ_MISCELLANY)
+ // In order to get the sub-type, we'll fill out the base type...
+ // then we're going to iterate over all possible subtype values
+ // and see if we get a winner. -- bwr
+ item->base_type = class_wanted;
+ item->sub_type = 0;
+ item->plus = 0;
+ item->plus2 = 0;
+ item->special = 0;
+ item->flags = 0;
+ item->quantity = 1;
+ set_ident_flags( *item, ISFLAG_IDENT_MASK );
+
+ if (class_wanted == OBJ_MISCELLANY)
+ {
+ // Leaves object unmodified if it wasn't a rune or deck.
+ _rune_or_deck_from_specs(specs, *item);
+
+ if (item->base_type == OBJ_UNASSIGNED)
{
- // Leaves object unmodified if it wasn't a rune or deck.
- _rune_or_deck_from_specs(specs, mitm[thing_created]);
+ // Rune or deck creation canceled, clean up item->
+ return (false);
+ }
+ }
- if (mitm[thing_created].base_type == OBJ_UNASSIGNED)
+ if (!item->sub_type)
+ {
+ type_wanted = -1;
+ best_index = 10000;
+
+ for (i = 0; i < max_subtype[ item->base_type ]; i++)
+ {
+ item->sub_type = i;
+ strcpy(obj_name, item->name(DESC_PLAIN).c_str());
+
+ ptr = strstr( strlwr(obj_name), specs );
+ if (ptr != NULL)
{
- // Rune or deck creation canceled, clean up item.
- destroy_item(thing_created);
- return;
+ // Earliest match is the winner.
+ if (ptr - obj_name < best_index)
+ {
+ mpr( obj_name );
+ type_wanted = i;
+ best_index = ptr - obj_name;
+ }
}
}
- if (!mitm[thing_created].sub_type)
+ if (type_wanted != -1)
{
- type_wanted = -1;
- best_index = 10000;
-
- for (i = 0; i < max_subtype[ mitm[thing_created].base_type ]; i++)
+ item->sub_type = type_wanted;
+ if (!create_for_real)
+ return (true);
+ }
+ else
+ {
+ switch (class_wanted)
{
- mitm[thing_created].sub_type = i;
- strcpy(obj_name,mitm[thing_created].name(DESC_PLAIN).c_str());
+ case OBJ_BOOKS:
+ // Try if we get a match against a spell.
+ if (_book_from_spell(specs, *item))
+ type_wanted = item->sub_type;
+ break;
- ptr = strstr( strlwr(obj_name), specs );
- if (ptr != NULL)
+ case OBJ_WEAPONS:
+ {
+ // Try for fixed artefacts matching the name.
+ unique_item_status_type exists;
+ for (unsigned which = SPWPN_START_FIXEDARTS;
+ which <= SPWPN_END_FIXEDARTS; which++)
{
- // Earliest match is the winner.
- if (ptr - obj_name < best_index)
+ exists = get_unique_item_status(OBJ_WEAPONS, which);
+ make_item_fixed_artefact(*item, false, which);
+ strcpy(obj_name, item->name(DESC_PLAIN).c_str());
+
+ ptr = strstr( strlwr(obj_name), specs );
+ if (ptr != NULL)
{
- mpr( obj_name );
- type_wanted = i;
- best_index = ptr - obj_name;
+ if (create_for_real)
+ mpr( obj_name );
+ return(true);
+ }
+ else
+ {
+ set_unique_item_status(OBJ_WEAPONS, which, exists);
+ do_uncurse_item(*item);
+ item->props.clear();
}
}
}
-
- if (type_wanted == -1 && class_wanted == OBJ_BOOKS)
+ // intentional fall-through for the unrandarts
+ case OBJ_ARMOUR:
+ case OBJ_JEWELLERY:
{
- if (_book_from_spell(specs, mitm[thing_created]))
- type_wanted = mitm[thing_created].sub_type;
- }
-
- if (type_wanted == -1)
- {
- // ds -- If specs is a valid int, try using that.
- // Since zero is atoi's copout, the wizard
- // must enter (subtype + 1).
- if (!(type_wanted = atoi(specs)))
+ bool exists;
+ for (int unrand = 0; unrand < NO_UNRANDARTS; unrand++)
{
- mpr( "No such item." );
+ exists = does_unrandart_exist( unrand );
+ make_item_unrandart(*item, unrand);
+ strcpy(obj_name, item->name(DESC_PLAIN).c_str());
+
+ ptr = strstr( strlwr(obj_name), specs );
+ if (ptr != NULL && item->base_type == class_wanted)
+ {
+ if (create_for_real)
+ mpr( obj_name );
+ return(true);
+ }
- // Clean up item
- destroy_item(thing_created);
- return;
+ set_unrandart_exist(unrand, exists);
+ do_uncurse_item(*item);
+ item->props.clear();
}
- type_wanted--;
+
+ // Reset base type to class_wanted, if nothing found.
+ item->base_type = class_wanted;
+ item->sub_type = 0;
+ break;
}
- mitm[thing_created].sub_type = type_wanted;
+ default:
+ break;
+ }
}
- switch (mitm[thing_created].base_type)
+ if (type_wanted == -1)
{
- case OBJ_MISSILES:
- mitm[thing_created].quantity = 30;
- // intentional fall-through
- case OBJ_WEAPONS:
- case OBJ_ARMOUR:
- mpr( "What ego type? ", MSGCH_PROMPT );
- get_input_line( specs, sizeof( specs ) );
+ // ds -- If specs is a valid int, try using that.
+ // Since zero is atoi's copout, the wizard
+ // must enter (subtype + 1).
+ if (!(type_wanted = atoi(specs)))
+ return (false);
- if (specs[0] != '\0')
- {
- special_wanted = 0;
- best_index = 10000;
+ type_wanted--;
- for (i = 1; i < 25; i++)
- {
- mitm[thing_created].special = i;
- strcpy(obj_name,
- mitm[thing_created].name(DESC_PLAIN).c_str());
+ item->sub_type = type_wanted;
+ }
+ }
- ptr = strstr( strlwr(obj_name), strlwr(specs) );
- if (ptr != NULL)
- {
- // earliest match is the winner
- if (ptr - obj_name < best_index)
- {
- mpr( obj_name );
- special_wanted = i;
- best_index = ptr - obj_name;
- }
- }
- }
+ if (!create_for_real)
+ return (true);
- mitm[thing_created].special = special_wanted;
- }
- break;
+ switch (item->base_type)
+ {
+ case OBJ_MISSILES:
+ item->quantity = 30;
+ // intentional fall-through
+ case OBJ_WEAPONS:
+ case OBJ_ARMOUR:
+ mpr( "What ego type? ", MSGCH_PROMPT );
+ get_input_line( specs, sizeof( specs ) );
+
+ if (specs[0] != '\0')
+ {
+ special_wanted = 0;
+ best_index = 10000;
- case OBJ_BOOKS:
- if (mitm[thing_created].sub_type == BOOK_MANUAL)
+ for (i = 1; i < 25; i++)
{
- special_wanted =
- _debug_prompt_for_skill( "A manual for which skill? " );
+ item->special = i;
+ strcpy(obj_name, item->name(DESC_PLAIN).c_str());
- if (special_wanted != -1)
+ ptr = strstr( strlwr(obj_name), strlwr(specs) );
+ if (ptr != NULL)
{
- mitm[thing_created].plus = special_wanted;
- mitm[thing_created].plus2 = 3 + random2(15);
+ // earliest match is the winner
+ if (ptr - obj_name < best_index)
+ {
+ mpr( obj_name );
+ special_wanted = i;
+ best_index = ptr - obj_name;
+ }
}
- else
- mpr( "Sorry, no books on that skill today." );
}
- break;
- case OBJ_WANDS:
- mitm[thing_created].plus = 24;
- break;
+ item->special = special_wanted;
+ }
+ break;
+
+ case OBJ_BOOKS:
+ if (item->sub_type == BOOK_MANUAL)
+ {
+ special_wanted =
+ _debug_prompt_for_skill( "A manual for which skill? " );
- case OBJ_STAVES:
- if (item_is_rod( mitm[thing_created] ))
+ if (special_wanted != -1)
{
- mitm[thing_created].plus = MAX_ROD_CHARGE * ROD_CHARGE_MULT;
- mitm[thing_created].plus2 = MAX_ROD_CHARGE * ROD_CHARGE_MULT;
+ item->plus = special_wanted;
+ item->plus2 = 3 + random2(15);
}
- break;
+ else
+ mpr( "Sorry, no books on that skill today." );
+ }
+ break;
- case OBJ_MISCELLANY:
- if (!is_rune(mitm[thing_created]) && !is_deck(mitm[thing_created]))
- mitm[thing_created].plus = 50;
- break;
+ case OBJ_WANDS:
+ item->plus = 24;
+ break;
- case OBJ_POTIONS:
- mitm[thing_created].quantity = 12;
- if (is_blood_potion(mitm[thing_created]))
- init_stack_blood_potions(mitm[thing_created]);
- break;
+ case OBJ_STAVES:
+ if (item_is_rod(*item))
+ {
+ item->plus = MAX_ROD_CHARGE * ROD_CHARGE_MULT;
+ item->plus2 = MAX_ROD_CHARGE * ROD_CHARGE_MULT;
+ }
+ break;
- case OBJ_FOOD:
- case OBJ_SCROLLS:
- mitm[thing_created].quantity = 12;
- break;
+ case OBJ_MISCELLANY:
+ if (!is_rune(*item) && !is_deck(*item))
+ item->plus = 50;
+ break;
- case OBJ_JEWELLERY:
- if (jewellery_is_amulet(mitm[thing_created]))
- break;
+ case OBJ_POTIONS:
+ item->quantity = 12;
+ if (is_blood_potion(*item))
+ init_stack_blood_potions(*item);
+ break;
- switch(mitm[thing_created].sub_type)
- {
- case RING_SLAYING:
- mitm[thing_created].plus2 = 5;
- // intentional fall-through
- case RING_PROTECTION:
- case RING_EVASION:
- case RING_STRENGTH:
- case RING_DEXTERITY:
- case RING_INTELLIGENCE:
- mitm[thing_created].plus = 5;
- default:
- break;
- }
+ case OBJ_FOOD:
+ case OBJ_SCROLLS:
+ item->quantity = 12;
+ break;
+
+ case OBJ_JEWELLERY:
+ if (jewellery_is_amulet(*item))
+ break;
+
+ switch(item->sub_type)
+ {
+ case RING_SLAYING:
+ item->plus2 = 5;
+ // intentional fall-through
+ case RING_PROTECTION:
+ case RING_EVASION:
+ case RING_STRENGTH:
+ case RING_DEXTERITY:
+ case RING_INTELLIGENCE:
+ item->plus = 5;
default:
break;
}
- }
-
- // Deck colour (which control rarity) already set
- if (!is_deck(mitm[thing_created]))
- item_colour( mitm[thing_created] );
- move_item_to_grid( &thing_created, you.pos() );
-
- if (thing_created != NON_ITEM)
- {
- // orig_monnum is used in corpses for things like the Animate
- // Dead spell, so leave it alone.
- if (class_wanted != OBJ_CORPSES)
- origin_acquired( mitm[thing_created], AQ_WIZMODE );
- canned_msg( MSG_SOMETHING_APPEARS );
+ default:
+ break;
}
-}
-#endif
+ return (true);
+}
-//---------------------------------------------------------------
-//
-// create_spec_object
-//
-//---------------------------------------------------------------
#ifdef WIZARD
-
const char* _prop_name[RAP_NUM_PROPERTIES] = {
"Brand",
"AC",
diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h
index 85d2fc5d6e..4861382533 100644
--- a/crawl-ref/source/debug.h
+++ b/crawl-ref/source/debug.h
@@ -130,4 +130,10 @@ void mapgen_report_map_build_start();
void mapgen_report_map_veto();
#endif
+struct item_def;
+
+bool get_item_by_name(item_def *item, char* specs,
+ object_class_type class_wanted,
+ bool create_for_real = false);
+
#endif
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 1820667afc..034c12b027 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -782,6 +782,20 @@ static std::string _describe_demon(const monsters &mons)
return description.str();
}
+void append_weapon_stats(std::string &description, const item_def &item)
+{
+ description += "$Damage rating: ";
+ _append_value(description, property( item, PWPN_DAMAGE ), false);
+ description += " ";
+
+ description += "Accuracy rating: ";
+ _append_value(description, property( item, PWPN_HIT ), true);
+ description += " ";
+
+ description += "Base attack delay: ";
+ _append_value(description, property( item, PWPN_SPEED ) * 10, false);
+ description += "%";
+}
//---------------------------------------------------------------
//
@@ -883,19 +897,7 @@ static std::string _describe_weapon( const item_def &item, bool verbose)
}
if (verbose)
- {
- description += "$Damage rating: ";
- _append_value(description, property( item, PWPN_DAMAGE ), false);
- description += " ";
-
- description += "Accuracy rating: ";
- _append_value(description, property( item, PWPN_HIT ), true);
- description += " ";
-
- description += "Base attack delay: ";
- _append_value(description, property( item, PWPN_SPEED ) * 10, false);
- description += "%";
- }
+ append_weapon_stats(description, item);
if (!is_fixed_artefact( item ))
{
@@ -1216,6 +1218,15 @@ static std::string _describe_ammo( const item_def &item )
return (description);
}
+void append_armour_stats(std::string &description, const item_def &item)
+{
+ description += "$Armour rating: ";
+ _append_value(description, property( item, PARM_AC ), false);
+ description += " ";
+
+ description += "Evasion modifier: ";
+ _append_value(description, property( item, PARM_EVASION ), true);
+}
//---------------------------------------------------------------
//
@@ -1233,12 +1244,7 @@ static std::string _describe_armour( const item_def &item, bool verbose )
&& item.sub_type != ARM_BUCKLER
&& item.sub_type != ARM_LARGE_SHIELD)
{
- description += "$Armour rating: ";
- _append_value(description, property( item, PARM_AC ), false);
- description += " ";
-
- description += "Evasion modifier: ";
- _append_value(description, property( item, PARM_EVASION ), true);
+ append_armour_stats(description, item);
}
const int ego = get_armour_ego_type( item );
diff --git a/crawl-ref/source/describe.h b/crawl-ref/source/describe.h
index 1704945bda..eb1d517b5e 100644
--- a/crawl-ref/source/describe.h
+++ b/crawl-ref/source/describe.h
@@ -58,6 +58,12 @@ void describe_feature_wide(int x, int y);
void describe_item( item_def &item, bool allow_inscribe = false );
void inscribe_item( item_def &item, bool proper_prompt );
+/* ***********************************************************************
+ * called from: command
+ * *********************************************************************** */
+void append_weapon_stats(std::string &description, const item_def &item);
+void append_armour_stats(std::string &description, const item_def &item);
+
// last updated 12 Jun 2008 {jpeg}
/* ***********************************************************************
* called from: command - direct