From ec8f97b4eb0d8f26161440c69eeaebacf861b3b3 Mon Sep 17 00:00:00 2001 From: ennewalker Date: Thu, 8 Nov 2007 04:21:29 +0000 Subject: Merged 2802. Randarts with no mods get one of (ac, ev, str, int, dex.) [1826417] git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2803 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/randart.cc | 83 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 83 insertions(+) diff --git a/crawl-ref/source/randart.cc b/crawl-ref/source/randart.cc index 14c468f6e6..8e9308fa6d 100644 --- a/crawl-ref/source/randart.cc +++ b/crawl-ref/source/randart.cc @@ -878,6 +878,86 @@ static long calc_seed( const item_def &item ) return (item.special & RANDART_SEED_MASK); } +static int randart_add_one_property( const item_def &item, + randart_properties_t &proprt ) +{ + // This function assumes that no properties have been added to this + // randart yet. + + const object_class_type cl = item.base_type; + const int ty = item.sub_type; + + // 0 - ac, 1 - ev, 2 - str, 3 - int, 4 - dex + int prop; + int skip = -1; + + // Determine if we need to skip any of the above. + if (cl == OBJ_ARMOUR || cl == OBJ_JEWELLERY && ty == RING_PROTECTION) + skip = 0; + else if (cl == OBJ_JEWELLERY && ty == RING_EVASION) + skip = 1; + else if (cl == OBJ_JEWELLERY && ty == RING_STRENGTH) + skip = 2; + else if (cl == OBJ_JEWELLERY && ty == RING_INTELLIGENCE) + skip = 3; + else if (cl == OBJ_JEWELLERY && ty == RING_DEXTERITY) + skip = 4; + + // Pick a random enchantment, taking into account the skipped index. + if (skip >= 0) + { + prop = random2(4); + if (prop >= skip) + prop++; + } + else + { + prop = random2(5); + } + + bool negench = one_chance_in(4); + + switch(prop) + { + default: + case 0: + if (negench) + proprt[RAP_AC] -= 1 + random2(3) + random2(3) + random2(3); + else + proprt[RAP_AC] = 1 + random2(3) + random2(3) + random2(3); + break; + case 1: + if (negench) + proprt[RAP_EVASION] -= 1 + random2(3) + random2(3) + random2(3); + else + proprt[RAP_EVASION] = 1 + random2(3) + random2(3) + random2(3); + break; + case 2: + if (negench) + proprt[RAP_STRENGTH] -= 1 + random2(3) + random2(3) + + random2(3); + else + proprt[RAP_STRENGTH] = 1 + random2(3) + random2(2); + break; + case 3: + if (negench) + proprt[RAP_INTELLIGENCE] -= 1 + random2(3) + random2(3) + + random2(3); + else + proprt[RAP_INTELLIGENCE] = 1 + random2(3) + random2(2); + break; + case 4: + if (negench) + proprt[RAP_DEXTERITY] -= 1 + random2(3) + random2(3) + + random2(3); + else + proprt[RAP_DEXTERITY] = 1 + random2(3) + random2(2); + break; + } + + return negench ? 0 : 1; +} + void randart_wpn_properties( const item_def &item, randart_properties_t &proprt ) { @@ -1343,6 +1423,9 @@ void randart_wpn_properties( const item_def &item, } } + if (randart_wpn_num_props(proprt) == 0) + power_level += randart_add_one_property(item, proprt); + if ((power_level < 2 && one_chance_in(5)) || one_chance_in(30)) proprt[RAP_CURSED] = 1; } -- cgit v1.2.3-54-g00ecf