Also, because mundane items are so terribly rare in acquirement use another check to occasionally produce mundane items filling empty equipment slots: If the rolled item is an ego item and you're already wearing an item in the same slot that has the same ego and better or equal enchantment, try for a mundane item filling an empty slot instead.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@10500 c06c8d41-db1a-0410-9941-cceddc491573
4ZLLCF3RTKOEZ6CRNLREKZXZKQTNGQPOZXLA5KRFKEGYWWU72XRAC _try_give_mundane_armour(doodad);if (agent == GOD_OKAWARU && doodad.plus < 0)doodad.plus = 0;
const equipment_type eq = get_armour_slot(doodad);// Don't try to replace an item if it would already fill a// currently unfilled secondary armour slot.if (eq == EQ_BODY_ARMOUR || you.equip[eq] != -1){const special_armour_type sparm = get_armour_ego_type(doodad);bool mundane_check = (sparm == SPARM_NORMAL);// If the created item is an ego item, check whether we're// already wearing an item with this ego in the same slot, and// whether the enchantment is worse than that of the current// item. (For armour, only consider items of the same subtype.)// If so, try filling an unfilled equipment slot after all.if (!mundane_check){if (you.equip[eq] != -1&& (eq != EQ_BODY_ARMOUR|| doodad.sub_type == you.inv[you.equip[eq]].sub_type)&& sparm == get_armour_ego_type(you.inv[you.equip[eq]])&& doodad.plus <= you.inv[you.equip[eq]].plus){// Ego type is cleared later.mundane_check = true;}}if (mundane_check){if (_try_give_mundane_armour(doodad)){// Make sure the item is mundane.doodad.special = SPARM_NORMAL;// Okawaru shouldn't hand out negatively enchanted// mundane items.if (agent == GOD_OKAWARU && doodad.plus < 0)doodad.plus = 0;}else if (eq != EQ_BODY_ARMOUR && one_chance_in(5)){// If there weren't any unfilled slots, there's a 20%// chance for non-body armour to roll again.destroy_item(thing_created, true);thing_created = NON_ITEM;continue;}}}