only generates stats on items attained via acquirement.
Move the acquirement logic of turning non-wearable headgear to wearable headgear from acquirement() to find_acquirement_subtype() so that it will happen before acquirement()'s can_wear_armour() check. The old way of doing it meant that players who couldn't wear helmets/helms had the armour acquirement chance for headgear reduced from the noraml 10% to around 1%.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3022 c06c8d41-db1a-0410-9941-cceddc491573
KQNIGKATHT4YSPJFPJGIGPD6VNR5B753SE2JN2LCXZZJNHCGY3DQC
EKFYSZAARWAVH7VGCZBBHLLNEIMNMN5HCCMEW27QK57L7P7RHTWQC
BYJVNG64DJWUDZH55L5XKRZSRGDV54TJOIDUXWTG52KMUUOOG4QQC
2W34FMSGJ2BZY7QQM6X6RTVRXXI2H72Z2MH75SU3SDL4FN4G74KAC
VCG3BRIYRTNNWYC3LOXD6KFGXOX37HAFW2HNV7WXVG2V7EUHLDZQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
3D6NWJ44UYHLZMD3BOQIWXJUEGITAVCHK6Z2WWDQONVQC4HSBRXQC
5KJCHLIUFKRPMIVWUAYT6EOF7SW4PTQF6Y5OPEFWXGLE7DUGYLZAC
52XHD5LKS6UVLXBYUXMPTMVMTXQ6FBUFXJ2TAW6R7CSJY7OXWVJAC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
GQL5SIGBHLU3FMCE54XVGLRY5AZHRM6DUEB722REA2DPLGJSN6EQC
EFWEYIB2R3DPD3JWIPU6LS6SFLPMYN7J7X4GBZR7DJWKHJ3UELSAC
P722Q43MJLCJ5NHF6FA27YM7IYP2ZTP6WP373BAVZPODZW4JLJPQC
U3KGUJJQWQORJIIFH3ADVNIEEX5HOX6KEOXO7DJSL7L3Z6GG3PAQC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
DBGS3HXMW24VO5GBITT3UI2ZNIISUXUHAEAYUI52QPUT7IO46ITQC
5BJPWUPLJFS34FUTFJVKA4A52YMIGV6EWDXLNSDCWBJWBGVSQFGQC
L254F6ZIU2HWGLFFGPIORTN4C3TDQ3E5JZ7Z7GQA5AEDIKL6PKDAC
}
// 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;
}
}
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;
}
}
#endif
//---------------------------------------------------------------
//
// 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");