summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/acr.cc4
-rw-r--r--crawl-ref/source/command.cc5
-rw-r--r--crawl-ref/source/debug.cc156
-rw-r--r--crawl-ref/source/debug.h1
-rw-r--r--crawl-ref/source/effects.cc64
-rw-r--r--crawl-ref/source/effects.h3
-rw-r--r--crawl-ref/source/itemname.cc6
7 files changed, 198 insertions, 41 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc
index e8f99fe547..fa1ccfa013 100644
--- a/crawl-ref/source/acr.cc
+++ b/crawl-ref/source/acr.cc
@@ -859,6 +859,10 @@ static void handle_wizard_command( void )
}
break;
+ case CONTROL('I'):
+ debug_item_statistics();
+ break;
+
case 'X':
xom_acts(abs(you.piety - 100));
break;
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index b656405356..55c16e5c78 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -1785,6 +1785,7 @@ static void list_wizard_commands()
"Ctrl-F : combat stats (monster vs PC)\n"
"h/H : heal yourself (super-Heal)\n"
"i/I : identify/unidentify inventory\n"
+ "Ctrl-I : item generation stats\n"
"l : make entrance to labyrinth\n"
"L : place a vault by name\n"
"m/M : create monster by number/name\n"
@@ -1793,11 +1794,11 @@ static void list_wizard_commands()
"P : make a portal (i.e., bazaars)\n"
"r : change character's species\n"
"s : gain 20000 skill points\n"
- "S : set skill to level\n"
- "t : tweak object properties\n",
+ "S : set skill to level\n",
true, true);
cols.add_formatted(1,
+ "t : tweak object properties\n"
"T : make a trap\n"
"v : show gold value of an item\n"
"x : gain an experience level\n"
diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc
index 27f5c1c514..baa38dde2d 100644
--- a/crawl-ref/source/debug.cc
+++ b/crawl-ref/source/debug.cc
@@ -44,6 +44,7 @@
#include "describe.h"
#include "direct.h"
#include "dungeon.h"
+#include "effects.h"
#include "fight.h"
#include "files.h"
#include "food.h"
@@ -1650,6 +1651,161 @@ void debug_item_scan( void )
//---------------------------------------------------------------
//
+// debug_item_statistics
+//
+//---------------------------------------------------------------
+#ifdef WIZARD
+void debug_acquirement_stats(FILE *ostat)
+{
+ if (grid_destroys_items(grd[you.x_pos][you.y_pos]))
+ {
+ mpr("You must stand on a square which doesn't destroy items "
+ "in order to do this.");
+ return;
+ }
+
+ int p = get_item_slot(11);
+ if (p == NON_ITEM)
+ {
+ mpr("Too many items on level.");
+ return;
+ }
+ mitm[p].base_type = OBJ_UNASSIGNED;
+
+ mpr( "[a] Weapons [b] Armours [c] Jewellery [d] Books" );
+ mpr( "[e] Staves [f] Food [g] Miscellaneous" );
+ mpr("What kind of item would you like to get stats on? ", MSGCH_PROMPT);
+
+ object_class_type type;
+ const int keyin = tolower( get_ch() );
+ switch ( keyin )
+ {
+ case 'a': type = OBJ_WEAPONS; break;
+ case 'b': type = OBJ_ARMOUR; break;
+ case 'c': type = OBJ_JEWELLERY; break;
+ case 'd': type = OBJ_BOOKS; break;
+ case 'e': type = OBJ_STAVES; break;
+ case 'f': type = OBJ_FOOD; break;
+ case 'g': type = OBJ_MISCELLANY; break;
+ default:
+ canned_msg( MSG_OK );
+ return;
+ }
+
+ const int num_itrs = debug_prompt_for_int("How many iterations? ", true);
+
+ if (num_itrs == 0)
+ {
+ canned_msg( MSG_OK );
+ return;
+ }
+
+ int last_percent = 0;
+ int acq_calls = 0;
+ int total_quant = 0;
+
+ int subtype_quants[256];
+ memset(subtype_quants, 0, sizeof(subtype_quants));
+
+ for (int i = 0; i < num_itrs; i++)
+ {
+ if (kbhit())
+ {
+ mpr("Stopping early due to keyboard input.");
+ break;
+ }
+
+ int item_index = NON_ITEM;
+
+ if (!acquirement(type, AQ_WIZMODE, true, &item_index)
+ || item_index == NON_ITEM
+ || !is_valid_item(mitm[item_index]))
+ {
+ mpr("Acquirement failed, stopping early.");
+ break;
+ }
+
+ item_def &item(mitm[item_index]);
+
+ acq_calls++;
+ total_quant += item.quantity;
+ subtype_quants[item.sub_type] += item.quantity;
+
+ destroy_item(item_index, true);
+
+ int curr_percent = acq_calls * 100 / num_itrs;
+ if (curr_percent > last_percent)
+ {
+ mesclr();
+ mprf("%2d%% done.", curr_percent);
+ last_percent = curr_percent;
+ }
+ }
+
+ if (total_quant == 0 || acq_calls == 0)
+ {
+ mpr("No items generated.");
+ return;
+ }
+
+ fprintf(ostat, "acquirement called %d times, total quantity = %d\n\n",
+ acq_calls, total_quant);
+
+ item_def item;
+ item.quantity = 1;
+ item.base_type = type;
+
+ int max_width = 0;
+ for (int i = 0; i < 256; i++)
+ {
+ if (subtype_quants[i] == 0)
+ continue;
+
+ item.sub_type = i;
+
+ std::string name = item.name(DESC_DBNAME, true, true);
+
+ max_width = std::max(max_width, (int) name.length());
+ }
+
+ char format_str[80];
+ sprintf(format_str, "%%%ds: %%6.2f\n", max_width);
+
+ for (int i = 0; i < 256; i++)
+ {
+ if (subtype_quants[i] == 0)
+ continue;
+
+ item.sub_type = i;
+
+ std::string name = item.name(DESC_DBNAME, true, true);
+
+ fprintf(ostat, format_str, name.c_str(),
+ (float) subtype_quants[i] * 100.0 / (float) total_quant);
+ }
+ fprintf(ostat, "----------------------\n");
+}
+
+void debug_item_statistics( void )
+{
+ FILE *ostat = fopen("items.stat", "a");
+
+ if (!ostat)
+ {
+#ifndef DOS
+ mprf("Can't write items.stat: %s", strerror(errno));
+#endif
+ return;
+ }
+
+ debug_acquirement_stats(ostat);
+
+ fclose(ostat);
+}
+#endif
+
+//---------------------------------------------------------------
+//
// debug_add_skills
//
//---------------------------------------------------------------
diff --git a/crawl-ref/source/debug.h b/crawl-ref/source/debug.h
index 03e9c0353e..a051922bb7 100644
--- a/crawl-ref/source/debug.h
+++ b/crawl-ref/source/debug.h
@@ -144,6 +144,7 @@ void wizard_interlevel_travel();
void stethoscope(int mwh);
void debug_item_scan( void );
+void debug_item_statistics( void );
void debug_get_religion( void );
void debug_change_species( void );
void debug_fight_statistics( bool use_init_defaults, bool defence = false );
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 3934512d58..b858cb61aa 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -923,6 +923,19 @@ static int find_acquirement_subtype(object_class_type class_wanted,
type_wanted = OBJ_RANDOM;
}
+ // Do this here, before acquirement()'s call to can_wear_armour(),
+ // so that caps will be just as common as helmets for those
+ // that can't wear helmets.
+ if (type_wanted == ARM_HELMET
+ && ((you.species >= SP_OGRE && you.species <= SP_OGRE_MAGE)
+ || player_genus(GENPC_DRACONIAN)
+ || you.species == SP_KENKU
+ || you.species == SP_SPRIGGAN
+ || you.mutation[MUT_HORNS]))
+ {
+ type_wanted = ARM_CAP;
+ }
+
// Now we'll randomly pick a body armour (light only in the
// case of ARM_ROBE). Unlike before, now we're only giving
// out the finished products here, never the hides. -- bwr
@@ -1312,12 +1325,19 @@ static int find_acquirement_subtype(object_class_type class_wanted,
return (type_wanted);
}
-bool acquirement(object_class_type class_wanted, int agent)
+bool acquirement(object_class_type class_wanted, int agent,
+ bool quiet, int* item_index)
{
- int thing_created = 0;
+ int thing_created = NON_ITEM;
+
+ if (item_index == NULL)
+ item_index = &thing_created;
+
+ *item_index = NON_ITEM;
while (class_wanted == OBJ_RANDOM)
{
+ ASSERT(!quiet);
mesclr();
mpr( "[a] Weapon [b] Armour [c] Jewellery [d] Book" );
mpr( "[e] Staff [f] Food [g] Miscellaneous [h] Gold" );
@@ -1341,11 +1361,12 @@ bool acquirement(object_class_type class_wanted, int agent)
if (grid_destroys_items(grd[you.x_pos][you.y_pos]))
{
// how sad (and stupid)
- if (!silenced(you.pos()))
+ if (!silenced(you.pos()) && !quiet)
mprf(MSGCH_SOUND,
grid_item_destruction_message(grd[you.x_pos][you.y_pos]));
item_was_destroyed(mitm[igrd[you.x_pos][you.y_pos]], NON_MONSTER);
+ *item_index = NON_ITEM;
}
else
{
@@ -1404,7 +1425,9 @@ bool acquirement(object_class_type class_wanted, int agent)
if (thing_created == NON_ITEM)
{
- mpr("The demon of the infinite void smiles upon you.");
+ if (!quiet)
+ mpr("The demon of the infinite void smiles upon you.");
+ *item_index = NON_ITEM;
return (false);
}
@@ -1553,35 +1576,6 @@ bool acquirement(object_class_type class_wanted, int agent)
thing.plus2 = std::max(static_cast<int>(thing.plus2), 0);
}
}
- else if (thing.base_type == OBJ_ARMOUR
- && !is_fixed_artefact( thing )
- && !is_unrandom_artefact( thing ))
- {
- // HACK: make unwearable hats and boots wearable
- // Note: messing with fixed artefacts is probably very bad.
- switch (thing.sub_type)
- {
- case ARM_HELMET:
- if ((get_helmet_type(thing) == THELM_HELM
- || get_helmet_type(thing) == THELM_HELMET)
- && ((you.species >= SP_OGRE && you.species <= SP_OGRE_MAGE)
- || player_genus(GENPC_DRACONIAN)
- || you.species == SP_KENKU
- || you.species == SP_SPRIGGAN
- || you.mutation[MUT_HORNS]))
- {
- // turn it into a cap or wizard hat
- set_helmet_type(thing,
- coinflip() ? THELM_CAP : THELM_WIZARD_HAT);
-
- thing.colour = random_colour();
- }
- break;
-
- default:
- break;
- }
- }
move_item_to_grid( &thing_created, you.x_pos, you.y_pos );
@@ -1590,9 +1584,11 @@ bool acquirement(object_class_type class_wanted, int agent)
// but we're checking it anyways. -- bwr
if (thing_created != NON_ITEM)
{
- canned_msg(MSG_SOMETHING_APPEARS);
+ if (!quiet)
+ canned_msg(MSG_SOMETHING_APPEARS);
origin_acquired(mitm[thing_created], agent);
}
+ *item_index = thing_created;
}
// Well, the item may have fallen in the drink, but the intent is
diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h
index 1472fb4b56..0cdf176ad1 100644
--- a/crawl-ref/source/effects.h
+++ b/crawl-ref/source/effects.h
@@ -64,7 +64,8 @@ void random_uselessness(unsigned char ru, unsigned char sc_read_2);
/* ***********************************************************************
* called from: acr - decks - item_use - religion
* *********************************************************************** */
-bool acquirement(object_class_type force_class, int agent);
+bool acquirement(object_class_type force_class, int agent,
+ bool quiet = false, int *item_index = NULL);
// last updated 12may2000 {dlb}
diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc
index 2ec5246031..cbcee48703 100644
--- a/crawl-ref/source/itemname.cc
+++ b/crawl-ref/source/itemname.cc
@@ -2198,13 +2198,11 @@ void init_item_name_cache()
unsigned glyph;
unsigned short colour;
get_item_glyph(&item, &glyph, &colour);
- destroy_item(o);
+ destroy_item(o, true);
lowercase(name);
if (base_type == OBJ_JEWELLERY && name == "buggy jewellery")
continue;
-// else if (base_type == OBJ_MISSILES && name == "eggplant")
-// continue;
else if (item.base_type == OBJ_ARMOUR
&& get_armour_slot( item ) == EQ_HELMET)
{
@@ -2262,7 +2260,7 @@ void init_item_name_cache()
item_names_by_glyph_cache[glyph].push_back(name);
}
}
- destroy_item(o);
+ destroy_item(o, true);
}
item_types_pair item_types_by_name(std::string name)