summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2010-01-04 15:27:37 +0100
committerAdam Borowski <kilobyte@angband.pl>2010-01-04 15:42:43 +0100
commitad552ae6735e657e9e0a885d6d333d33f2b9d129 (patch)
tree726d9ec34bfb360608ebb6a106fc2579582d61e8
parentf1fdc16676179c58bff565682afa989ee93e79b7 (diff)
downloadcrawl-ref-ad552ae6735e657e9e0a885d6d333d33f2b9d129.tar.gz
crawl-ref-ad552ae6735e657e9e0a885d6d333d33f2b9d129.zip
Try to avoid repeats when acquiring already seen weapons/armour.
Weapons: both type and brand is handled, separately. This means, once you've seen any lajatang, there is no more any bonus to get them -- you'll get 5 times as many quarterstaves, brand repeat protection comes only within the type. Armour: currently only brand is handled, type will have to be merged with the old code which suffered from no information about stash.
-rw-r--r--crawl-ref/source/effects.cc15
-rw-r--r--crawl-ref/source/makeitem.cc21
-rw-r--r--crawl-ref/source/makeitem.h1
3 files changed, 37 insertions, 0 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 63730af531..f67d52ca47 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -1423,6 +1423,9 @@ static int _acquirement_weapon_subtype()
else
acqweight = acqweight * want_shield / dont_shield;
+ if (!you.seen_weapon[i])
+ acqweight *= 5; // strong emphasis on type variety, brands go only second
+
int wskill = range_skill(OBJ_WEAPONS, i);
if (wskill == SK_THROWING)
wskill = weapon_skill(OBJ_WEAPONS, i);
@@ -2023,6 +2026,18 @@ int acquirement_create_item(object_class_type class_wanted,
item_def &doodad(mitm[thing_created]);
+ // Try to not generate brands that were already seen, although unlike
+ // jewelry and books, this is not absolute.
+ while (!is_artefact(doodad)
+ && (doodad.base_type == OBJ_WEAPONS
+ && you.seen_weapon[doodad.sub_type] & (1<<get_weapon_brand(doodad))
+ || doodad.base_type == OBJ_ARMOUR
+ && you.seen_armour[doodad.sub_type] & (1<<get_weapon_brand(doodad)))
+ && !one_chance_in(5))
+ {
+ reroll_brand(doodad, MAKE_GOOD_ITEM);
+ }
+
// For plain armour, try to change the subtype to something
// matching a currently unfilled equipment slot.
if (doodad.base_type == OBJ_ARMOUR && !is_artefact(doodad))
diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc
index bfa26805b1..2312bc5712 100644
--- a/crawl-ref/source/makeitem.cc
+++ b/crawl-ref/source/makeitem.cc
@@ -3293,6 +3293,27 @@ int items(int allow_uniques, // not just true-false,
return (p);
}
+void reroll_brand(item_def &item, int item_level)
+{
+ ASSERT(!is_artefact(item));
+ switch(item.base_type)
+ {
+ case OBJ_WEAPONS:
+ item.special = _determine_weapon_brand(item, item_level);
+ break;
+ case OBJ_MISSILES:
+ item.special = _determine_missile_brand(item, item_level);
+ break;
+ case OBJ_ARMOUR:
+ // Robe of the Archmagi has an ugly hack of unknown purpose,
+ // as one of side effects it won't ever generate here.
+ item.special = _determine_armour_ego(item, OBJ_ARMOUR, item_level);
+ break;
+ default:
+ ASSERT(!"can't reroll brands of this type");
+ }
+}
+
static int _roll_rod_enchant(int item_level)
{
int value = 0;
diff --git a/crawl-ref/source/makeitem.h b/crawl-ref/source/makeitem.h
index 8e16989c15..7e2d0091ba 100644
--- a/crawl-ref/source/makeitem.h
+++ b/crawl-ref/source/makeitem.h
@@ -37,6 +37,7 @@ bool is_armour_brand_ok(int type, int brand);
bool is_missile_brand_ok(int type, int brand);
bool got_curare_roll(const int item_level);
+void reroll_brand(item_def &item, int item_level);
#if DEBUG_DIAGNOSTICS || DEBUG_TESTS
void makeitem_tests();