diff options
-rw-r--r-- | crawl-ref/source/defines.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/describe.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/effects.cc | 11 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 21 | ||||
-rw-r--r-- | crawl-ref/source/item_use.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/itemname.cc | 17 | ||||
-rw-r--r-- | crawl-ref/source/itemprop.cc | 7 | ||||
-rw-r--r-- | crawl-ref/source/items.cc | 4 | ||||
-rw-r--r-- | crawl-ref/source/makeitem.cc | 26 | ||||
-rw-r--r-- | crawl-ref/source/spl-book.cc | 35 | ||||
-rw-r--r-- | crawl-ref/source/stuff.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/stuff.h | 3 |
12 files changed, 83 insertions, 74 deletions
diff --git a/crawl-ref/source/defines.h b/crawl-ref/source/defines.h index 03269ebd62..2ad611e620 100644 --- a/crawl-ref/source/defines.h +++ b/crawl-ref/source/defines.h @@ -205,8 +205,6 @@ #define MAX_ARM_ENCHANT 5 #define MAX_SEC_ENCHANT 2 -#define NUM_STAVE_ADJ 10 - // some shortcuts: #define menv env.mons #define mitm env.item diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc index b26bbc5040..392cab7941 100644 --- a/crawl-ref/source/describe.cc +++ b/crawl-ref/source/describe.cc @@ -2820,6 +2820,11 @@ static std::string describe_staff( const item_def &item ) "which drains four charges. "; break; + case STAFF_VENOM: + description += + "contains offensive and defensive spells of poison."; + break; + case STAFF_STRIKING: description += "allows its wielder to strike foes from afar " "with force bolts. "; diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index bae43a8677..b213683e5d 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1045,7 +1045,7 @@ static int find_acquirement_subtype(object_class_type class_wanted, case SK_EVOCATIONS: if (!one_chance_in(4)) - type_wanted = STAFF_SMITING + random2(10); + type_wanted = random_rod_subtype(); break; default: // invocations and leftover spell schools @@ -1073,16 +1073,15 @@ static int find_acquirement_subtype(object_class_type class_wanted, break; } - // Increased chance of getting spell staff for new or + // Increased chance of getting a rod for new or // non-spellcasters. -- bwr if (one_chance_in(20) || (spell_skills <= 1 // short on spells - && (type_wanted < STAFF_SMITING // already making one - || type_wanted >= STAFF_AIR) + && type_wanted < STAFF_SMITING && !one_chance_in(4))) { - type_wanted = (coinflip() ? STAFF_STRIKING - : STAFF_SMITING + random2(10)); + type_wanted = coinflip() ? STAFF_STRIKING : + random_rod_subtype(); } break; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 51fe08e20c..50e180a307 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -3635,29 +3635,32 @@ enum status_redraw_flag_type enum stave_type { - STAFF_WIZARDRY, // 0 + // staves + STAFF_WIZARDRY = 0, STAFF_POWER, STAFF_FIRE, STAFF_COLD, STAFF_POISON, - STAFF_ENERGY, // 5 + STAFF_ENERGY, STAFF_DEATH, STAFF_CONJURATION, STAFF_ENCHANTMENT, STAFF_SUMMONING, - STAFF_SMITING, // 10 + STAFF_AIR, + STAFF_EARTH, + STAFF_CHANNELING, + // rods + STAFF_SMITING, // must be first rod! STAFF_SPELL_SUMMONING, STAFF_DESTRUCTION_I, STAFF_DESTRUCTION_II, STAFF_DESTRUCTION_III, - STAFF_DESTRUCTION_IV, // 15 + STAFF_DESTRUCTION_IV, STAFF_WARDING, STAFF_DISCOVERY, - STAFF_DEMONOLOGY, // 18 - STAFF_STRIKING, // 19 - STAFF_AIR = 25, // 25 - STAFF_EARTH, - STAFF_CHANNELING, + STAFF_DEMONOLOGY, + STAFF_STRIKING, + STAFF_VENOM, NUM_STAVES // must remain last member {dlb} }; diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 1ce98686d1..b4b0dc5556 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -72,8 +72,8 @@ #include "tutorial.h" #include "view.h" -bool drink_fountain(void); -static bool enchant_armour( void ); +static bool drink_fountain(); +static bool enchant_armour(); // Rather messy - we've gathered all the can't-wield logic from wield_weapon() // here. @@ -3004,7 +3004,9 @@ bool drink_fountain() 4, 4, 4 }; ASSERT( ARRAYSIZE(weights) == ARRAYSIZE(effects) ); - fountain_effect = effects[weighted_random(weights,ARRAYSIZE(weights))]; + fountain_effect = + effects[choose_random_weighted(weights, + weights + ARRAYSIZE(weights))]; } if (fountain_effect != POT_WATER) diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 48ea28531f..a82f598bad 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -867,6 +867,7 @@ static const char* staff_type_name(int stafftype) { switch (static_cast<stave_type>(stafftype)) { + // staves case STAFF_WIZARDRY: return "wizardry"; case STAFF_POWER: return "power"; @@ -877,22 +878,26 @@ static const char* staff_type_name(int stafftype) case STAFF_DEATH: return "death"; case STAFF_CONJURATION: return "conjuration"; case STAFF_ENCHANTMENT: return "enchantment"; - case STAFF_SMITING: return "smiting"; - case STAFF_STRIKING: return "striking"; - case STAFF_WARDING: return "warding"; - case STAFF_DISCOVERY: return "discovery"; - case STAFF_DEMONOLOGY: return "demonology"; case STAFF_AIR: return "air"; case STAFF_EARTH: return "earth"; case STAFF_SUMMONING: return "summoning"; + // rods case STAFF_SPELL_SUMMONING: return "summoning"; + case STAFF_CHANNELING: return "channeling"; + case STAFF_WARDING: return "warding"; + case STAFF_DISCOVERY: return "discovery"; + case STAFF_SMITING: return "smiting"; + case STAFF_STRIKING: return "striking"; + case STAFF_DEMONOLOGY: return "demonology"; + case STAFF_VENOM: return "venom"; + case STAFF_DESTRUCTION_I: case STAFF_DESTRUCTION_II: case STAFF_DESTRUCTION_III: case STAFF_DESTRUCTION_IV: return "destruction"; - case STAFF_CHANNELING: return "channeling"; + default: return "bugginess"; } } diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 55af5c9b5a..65f87c3a50 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -1776,15 +1776,12 @@ bool is_throwable( const item_def &wpn, size_type bodysize ) // bool item_is_rod( const item_def &item ) { - return (item.base_type == OBJ_STAVES - && item.sub_type >= STAFF_SMITING && item.sub_type < STAFF_AIR); + return (item.base_type == OBJ_STAVES && item.sub_type >= STAFF_SMITING); } bool item_is_staff( const item_def &item ) { - // Isn't De Morgan's law wonderful. -- bwr - return (item.base_type == OBJ_STAVES - && (item.sub_type < STAFF_SMITING || item.sub_type >= STAFF_AIR)); + return (item.base_type == OBJ_STAVES && !item_is_rod(item)); } // diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index 73b85bb880..67cd67a401 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -2945,8 +2945,8 @@ bool item_def::has_spells() const int item_def::book_number() const { - return (base_type == OBJ_BOOKS? sub_type : - base_type == OBJ_STAVES? sub_type + 40 : + return (base_type == OBJ_BOOKS? sub_type : + base_type == OBJ_STAVES? sub_type + 50 - STAFF_SMITING : -1); } diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index b267bab7a3..380157719a 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -2738,21 +2738,20 @@ int items( int allow_uniques, // not just true-false, } break; - case OBJ_STAVES: // this can be parsed, too {dlb} + case OBJ_STAVES: if (force_type != OBJ_RANDOM) mitm[p].sub_type = force_type; else { - mitm[p].sub_type = random2(13); - - // top three non-spell staves are in separate block -- bwr - if (mitm[p].sub_type >= 10) - mitm[p].sub_type = STAFF_AIR + mitm[p].sub_type - 10; + // assumption: STAFF_SMITING is the first rod + mitm[p].sub_type = random2(STAFF_SMITING); - // spell staves + // rods are rare (10% of all staves) if (one_chance_in(10)) - mitm[p].sub_type = STAFF_SMITING + random2(10); + mitm[p].sub_type = random_rod_subtype(); + // staves of energy/channeling are less common, wizardry/power + // are more common if ((mitm[p].sub_type == STAFF_ENERGY || mitm[p].sub_type == STAFF_CHANNELING) && one_chance_in(4)) { @@ -2760,8 +2759,6 @@ int items( int allow_uniques, // not just true-false, } } - mitm[p].special = random2(NUM_STAVE_ADJ); - if (item_is_rod( mitm[p] )) init_rod_mp( mitm[p] ); @@ -2778,9 +2775,7 @@ int items( int allow_uniques, // not just true-false, set_unique_item_status( OBJ_ORBS, mitm[p].sub_type, UNIQ_EXISTS ); break; - // I think these must always be forced, too ... {dlb} - - case OBJ_MISCELLANY: //mv: rewrote with use of NUM_MISCELLANY (9 Aug 01) + case OBJ_MISCELLANY: if (force_type == OBJ_RANDOM) { do @@ -2819,7 +2814,7 @@ int items( int allow_uniques, // not just true-false, mitm[p].plus = item_race; quant = 1; - break; // mv: end of rewrote; + break; // that is, everything turns to gold if not enumerated above, so ... {dlb} default: @@ -2842,7 +2837,6 @@ int items( int allow_uniques, // not just true-false, mitm[p].quantity = quant; - // should really only be used for monster inventories. if (dont_place) { mitm[p].x = 0; @@ -2873,7 +2867,7 @@ int items( int allow_uniques, // not just true-false, // Okay, this check should be redundant since the purpose of // this function is to create valid items. Still, we're adding - // this safety for fear that a report of Trog giving a non-existant + // this safety for fear that a report of Trog giving a nonexistent // item might symbolize something more serious. -- bwr return (is_valid_item( mitm[p] ) ? p : NON_ITEM); } // end items() diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index d84bd02d21..0d4309d7cf 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -41,7 +41,7 @@ #include "stuff.h" #define SPELLBOOK_SIZE 8 -#define NUMBER_SPELLBOOKS 60 +#define NUMBER_SPELLBOOKS 61 static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = { @@ -574,7 +574,9 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, }, - // 50 - Staff of Smiting //jmf: totally obsolete --- no longer looks here. + // Rods - start at 50. + + // 50 - Rod of smiting {SPELL_SMITING, SPELL_NO_SPELL, SPELL_NO_SPELL, @@ -584,7 +586,8 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 51 - Staff of Summoning + + // 51 - Rod of summoning {SPELL_ABJURATION_I, SPELL_RECALL, SPELL_SUMMON_ELEMENTAL, @@ -594,7 +597,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 52 - Staff of Destruction + // 52 - Rod of destruction (fire) {SPELL_THROW_FLAME, SPELL_BOLT_OF_FIRE, SPELL_FIREBALL, @@ -604,7 +607,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 53 - Staff of Destruction + // 53 - Rod of destruction (ice) {SPELL_THROW_FROST, SPELL_ICE_BOLT, SPELL_FREEZING_CLOUD, @@ -614,7 +617,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 54 - Staff of Destruction + // 54 - Rod of destruction (iron, fireball, lightning) {SPELL_BOLT_OF_IRON, SPELL_FIREBALL, SPELL_LIGHTNING_BOLT, @@ -624,7 +627,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 55 - Staff of Destruction + // 55 - Rod of destruction (bolts) {SPELL_BOLT_OF_INACCURACY, SPELL_BOLT_OF_MAGMA, SPELL_BOLT_OF_COLD, @@ -634,7 +637,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 56 - Staff of Warding + // 56 - Rod of warding {SPELL_ABJURATION_I, SPELL_CONDENSATION_SHIELD, SPELL_CAUSE_FEAR, @@ -644,7 +647,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 57 - Staff of Exploration + // 57 - Rod of discovery {SPELL_DETECT_SECRET_DOORS, SPELL_DETECT_TRAPS, SPELL_DETECT_ITEMS, @@ -654,7 +657,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 58 - Staff of Demonology + // 58 - Rod of demonology {SPELL_ABJURATION_I, SPELL_RECALL, SPELL_CALL_IMP, @@ -664,7 +667,7 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, - // 59 - Staff of Striking -- unused like Smiting + // 59 - Rod of striking {SPELL_STRIKING, SPELL_NO_SPELL, SPELL_NO_SPELL, @@ -674,6 +677,16 @@ static spell_type spellbook_template_array[NUMBER_SPELLBOOKS][SPELLBOOK_SIZE] = SPELL_NO_SPELL, SPELL_NO_SPELL, }, + // 60 - Rod of venom + {SPELL_CURE_POISON_II, + SPELL_VENOM_BOLT, + SPELL_POISON_ARROW, + SPELL_POISONOUS_CLOUD, + SPELL_NO_SPELL, + SPELL_NO_SPELL, + SPELL_NO_SPELL, + SPELL_NO_SPELL + }, }; spell_type which_spell_in_book(int sbook_type, int spl) diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index 92063e93d3..ce8f822ef6 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -248,19 +248,6 @@ int random_choose_weighted(int weight, int first, ...) return (chosen); } -int weighted_random( const int weights[], unsigned int numweights ) -{ - int totalweight = 0; - unsigned int result = 0; - for ( unsigned int i = 0; i < numweights; ++i ) - { - totalweight += weights[i]; - if ( random2(totalweight) < weights[i] ) - result = i; - } - return result; -} - int random2( int max ) { if (max <= 1) @@ -1161,3 +1148,8 @@ int coord_def::distance_from(const coord_def &other) const { return (grid_distance(x, y, other.x, other.y)); } + +int random_rod_subtype() +{ + return STAFF_SMITING + random2(NUM_STAVES - STAFF_SMITING); +} diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h index 8e1532a21a..ee8534a24d 100644 --- a/crawl-ref/source/stuff.h +++ b/crawl-ref/source/stuff.h @@ -37,7 +37,6 @@ int random_range(int low, int high); int random_range(int low, int high, int nrolls); int random_choose(int first, ...); int random_choose_weighted(int weight, int first, ...); -int weighted_random(const int weights[], unsigned int numweights); unsigned long random_int(); int random2avg( int max, int rolls ); int bestroll(int max, int rolls); @@ -148,4 +147,6 @@ int choose_random_weighted(Iterator beg, const Iterator end) return result; } +int random_rod_subtype(); + #endif |