diff options
Diffstat (limited to 'crawl-ref/source')
-rw-r--r-- | crawl-ref/source/acr.cc | 3 | ||||
-rw-r--r-- | crawl-ref/source/dat/crypt.des | 7 | ||||
-rw-r--r-- | crawl-ref/source/enum.h | 3 | ||||
-rw-r--r-- | crawl-ref/source/mutation.cc | 284 | ||||
-rw-r--r-- | crawl-ref/source/mutation.h | 6 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 5 |
6 files changed, 182 insertions, 126 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index aee9c4f90b..b868e61bee 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3482,6 +3482,9 @@ static bool initialise(void) const bool newc = new_game(); if (!newc) restore_game(); + + // Fix the mutation definitions for the species we're playing. + fixup_mutations(); // Load macros macro_init(); diff --git a/crawl-ref/source/dat/crypt.des b/crawl-ref/source/dat/crypt.des index e56cb741fb..4f2acba0d8 100644 --- a/crawl-ref/source/dat/crypt.des +++ b/crawl-ref/source/dat/crypt.des @@ -455,7 +455,8 @@ PLACE: Tomb:2 # Can be rotated! ORIENT: encompass # -SHUFFLE: ABCD[, Ww/Yy/Zz, Uu/Vv, Qq/Rr/Ss +NSUBST: A = [ / ' +SHUFFLE: Ww/Yy/Zz, Uu/Vv, Qq/Rr/Ss SUBST: W=', w=c, Y=T, y=+, Z=T, z=+ SUBST: U=', u=c, V=T, v=+ SUBST: Q=', q=c, R=T, r=+, S=T, s=+ @@ -521,14 +522,14 @@ xxxxxxxxxxxxxxcccczcc..ccc.........1.........ccc..c''''ccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc'ZZZc..ccc...................ccc..c''''ccxxxxxxxxxxxxx xxxxxxxxxxxxxxccA'''c..ccc4.................4ccc..c''''ccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc'YYYc.............................c''''ccxxxxxxxxxxxxx -xxxxxxxxxxxxxxccccycc.............................cRRR[ccxxxxxxxxxxxxx +xxxxxxxxxxxxxxccccycc.............................cRRRAccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc'YYYc.............................ccrccccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc''''ccccc+ccccccccccccccc+cccccccccRRR'ccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc''''''c'TTTc''''''''''''cTT''''''c'''''ccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc'''''WcW''UcU''''''''''VcV''''''ScS''''ccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc'''''WwW''UuU''''''''''VvV''''''SsS''''ccxxxxxxxxxxxxx xxxxxxxxxxxxxxcc'''''WcW''UcU''''''''''VcV''''''ScS''''ccxxxxxxxxxxxxx -xxxxxxxxxxxxxxccB'''''c''''cC'''''''''''c''''''''c''''Dccxxxxxxxxxxxxx +xxxxxxxxxxxxxxccA'''''c''''cA'''''''''''c''''''''c''''Accxxxxxxxxxxxxx xxxxxxxxxxxxxxcccccccccccccccccccccccccccccccccccccccccccxxxxxxxxxxxxx xxxxxxxxxxxxxxcccccccccccccccccccccccccccccccccccccccccccxxxxxxxxxxxxx xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 2595d53732..269a706212 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -2041,7 +2041,8 @@ enum mutation_type NUM_MUTATIONS, RANDOM_MUTATION = 100, - RANDOM_XOM_MUTATION = 101 + RANDOM_XOM_MUTATION = 101, + RANDOM_GOOD_MUTATION = 102 }; enum object_class_type // (unsigned char) mitm[].base_type diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index f794bdd5cf..7c2d5d4acc 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -884,120 +884,119 @@ const char *lose_mutation[][3] = { /* mutation definitions: first number = probability (0 means it doesn't appear naturally?) second number = maximum levels */ -static const mutation_def mutation_defs[] = { - { MUT_TOUGH_SKIN, 10, 3 }, - { MUT_STRONG, 8, 14 }, - { MUT_CLEVER, 8, 14 }, - { MUT_AGILE, 8, 14 }, - { MUT_GREEN_SCALES, 2, 3 }, - { MUT_BLACK_SCALES, 1, 3 }, - { MUT_GREY_SCALES, 2, 3 }, - { MUT_BONEY_PLATES, 1, 3 }, - { MUT_REPULSION_FIELD, 1, 3 }, - { MUT_POISON_RESISTANCE, 4, 1 }, +static mutation_def mutation_defs[] = { + { MUT_TOUGH_SKIN, 10, 3, false }, + { MUT_STRONG, 8, 14, false }, + { MUT_CLEVER, 8, 14, false }, + { MUT_AGILE, 8, 14, false }, + { MUT_GREEN_SCALES, 2, 3, false }, + { MUT_BLACK_SCALES, 1, 3, false }, + { MUT_GREY_SCALES, 2, 3, false }, + { MUT_BONEY_PLATES, 1, 3, false }, + { MUT_REPULSION_FIELD, 1, 3, false }, + { MUT_POISON_RESISTANCE, 4, 1, false }, // 10 - { MUT_CARNIVOROUS, 5, 3 }, - { MUT_HERBIVOROUS, 5, 3 }, - { MUT_HEAT_RESISTANCE, 4, 3 }, - { MUT_COLD_RESISTANCE, 4, 3 }, - { MUT_SHOCK_RESISTANCE, 2, 1 }, - { MUT_REGENERATION, 3, 3 }, - { MUT_FAST_METABOLISM, 10, 3 }, - { MUT_SLOW_METABOLISM, 7, 3 }, - { MUT_WEAK, 10, 14 }, - { MUT_DOPEY, 10, 14 }, + { MUT_CARNIVOROUS, 5, 3, false }, + { MUT_HERBIVOROUS, 5, 3, true }, + { MUT_HEAT_RESISTANCE, 4, 3, false }, + { MUT_COLD_RESISTANCE, 4, 3, false }, + { MUT_SHOCK_RESISTANCE, 2, 1, false }, + { MUT_REGENERATION, 3, 3, false }, + { MUT_FAST_METABOLISM, 10, 3, true }, + { MUT_SLOW_METABOLISM, 7, 3, false }, + { MUT_WEAK, 10, 14, true }, + { MUT_DOPEY, 10, 14, true }, // 20 - { MUT_CLUMSY, 10, 14 }, - { MUT_TELEPORT_CONTROL, 2, 1 }, - { MUT_TELEPORT, 3, 3 }, - { MUT_MAGIC_RESISTANCE, 5, 3 }, - { MUT_FAST, 1, 3 }, - { MUT_ACUTE_VISION, 2, 1 }, - { MUT_DEFORMED, 8, 3 }, - { MUT_TELEPORT_AT_WILL, 2, 3 }, - { MUT_SPIT_POISON, 8, 3 }, - { MUT_MAPPING, 3, 3 }, + { MUT_CLUMSY, 10, 14, true }, + { MUT_TELEPORT_CONTROL, 2, 1, false }, + { MUT_TELEPORT, 3, 3, true }, + { MUT_MAGIC_RESISTANCE, 5, 3, false }, + { MUT_FAST, 1, 3, false }, + { MUT_ACUTE_VISION, 2, 1, false }, + { MUT_DEFORMED, 8, 3, true }, + { MUT_TELEPORT_AT_WILL, 2, 3, false }, + { MUT_SPIT_POISON, 8, 3, false }, + { MUT_MAPPING, 3, 3, false }, // 30 - { MUT_BREATHE_FLAMES, 4, 3 }, - { MUT_BLINK, 3, 3 }, - { MUT_HORNS, 7, 3 }, - { MUT_STRONG_STIFF, 10, 3 }, - { MUT_FLEXIBLE_WEAK, 10, 3 }, - { MUT_SCREAM, 6, 3 }, - { MUT_CLARITY, 6, 1 }, - { MUT_BERSERK, 7, 3 }, - { MUT_DETERIORATION, 10, 3 }, - { MUT_BLURRY_VISION, 10, 3 }, + { MUT_BREATHE_FLAMES, 4, 3, false }, + { MUT_BLINK, 3, 3, false }, + { MUT_HORNS, 7, 3, false }, + { MUT_STRONG_STIFF, 10, 3, false }, + { MUT_FLEXIBLE_WEAK, 10, 3, false }, + { MUT_SCREAM, 6, 3, true }, + { MUT_CLARITY, 6, 1, false }, + { MUT_BERSERK, 7, 3, true }, + { MUT_DETERIORATION, 10, 3, true }, + { MUT_BLURRY_VISION, 10, 3, true }, // 40 - { MUT_MUTATION_RESISTANCE, 4, 3 }, - { MUT_FRAIL, 10, 3 }, - { MUT_ROBUST, 5, 3 }, + { MUT_MUTATION_RESISTANCE, 4, 3, false }, + { MUT_FRAIL, 10, 3, true }, + { MUT_ROBUST, 5, 3, false }, /* Some demonic powers start here: */ - { MUT_TORMENT_RESISTANCE, 0, 1 }, - { MUT_NEGATIVE_ENERGY_RESISTANCE, 0, 3 }, - { MUT_SUMMON_MINOR_DEMONS, 0, 1 }, - { MUT_SUMMON_DEMONS, 0, 1 }, - { MUT_HURL_HELLFIRE, 0, 1 }, - { MUT_CALL_TORMENT, 0, 1 }, - { MUT_RAISE_DEAD, 0, 1 }, + { MUT_TORMENT_RESISTANCE, 0, 1, false }, + { MUT_NEGATIVE_ENERGY_RESISTANCE, 0, 3, false }, + { MUT_SUMMON_MINOR_DEMONS, 0, 1, false }, + { MUT_SUMMON_DEMONS, 0, 1, false }, + { MUT_HURL_HELLFIRE, 0, 1, false }, + { MUT_CALL_TORMENT, 0, 1, false }, + { MUT_RAISE_DEAD, 0, 1, false }, // 50 - { MUT_CONTROL_DEMONS, 0, 1 }, - { MUT_PANDEMONIUM, 0, 1 }, - { MUT_DEATH_STRENGTH, 0, 1 }, - { MUT_CHANNEL_HELL, 0, 1 }, - { MUT_DRAIN_LIFE, 0, 1 }, - { MUT_THROW_FLAMES, 0, 1 }, - { MUT_THROW_FROST, 0, 1 }, - { MUT_SMITE, 0, 1 }, + { MUT_CONTROL_DEMONS, 0, 1, false }, + { MUT_PANDEMONIUM, 0, 1, false }, + { MUT_DEATH_STRENGTH, 0, 1, false }, + { MUT_CHANNEL_HELL, 0, 1, false }, + { MUT_DRAIN_LIFE, 0, 1, false }, + { MUT_THROW_FLAMES, 0, 1, false }, + { MUT_THROW_FROST, 0, 1, false }, + { MUT_SMITE, 0, 1, false }, /* end of demonic powers */ - { MUT_CLAWS, 2, 3 }, - { MUT_FANGS, 1, 3 }, + { MUT_CLAWS, 2, 3, false }, + { MUT_FANGS, 1, 3, false }, // 60 - { MUT_HOOVES, 1, 1 }, - { MUT_TALONS, 1, 1 }, - { MUT_PAWS, 1, 1 }, + { MUT_HOOVES, 1, 1, false }, + { MUT_TALONS, 1, 1, false }, + { MUT_PAWS, 1, 1, false }, - { MUT_BREATHE_POISON, 0, 1 }, // Naga only - { MUT_STINGER, 0, 3 }, // Naga and Draconian only + { MUT_BREATHE_POISON, 0, 1, false }, // Naga only + { MUT_STINGER, 0, 3, false }, // Naga and Draconian only // 65 - { MUT_BIG_WINGS, 0, 3 }, // Draconian only - { MUT_BLUE_MARKS, 0, 3 }, // used by evil gods to mark followers - { MUT_GREEN_MARKS, 0, 3 }, + { MUT_BIG_WINGS, 0, 3, false }, // Draconian only + { MUT_BLUE_MARKS, 0, 3, false }, // used by evil gods to mark followers + { MUT_GREEN_MARKS, 0, 3, false }, - { MUT_DRIFTING, 2, 3 }, - { MUT_SAPROVOROUS, 0, 3 }, // species-dependent innate mutation + { MUT_DRIFTING, 2, 3, true }, + { MUT_SAPROVOROUS, 0, 3, false }, // species-dependent innate mutation // 70 - { MUT_SHAGGY_FUR, 2, 3 }, - { MUT_HIGH_MAGIC, 1, 3 }, - { MUT_LOW_MAGIC, 9, 3 }, - { MUT_SLEEPINESS, 3, 3 }, - { RANDOM_MUTATION, 0, 3 }, + { MUT_SHAGGY_FUR, 2, 3, false }, + { MUT_HIGH_MAGIC, 1, 3, false }, + { MUT_LOW_MAGIC, 9, 3, true }, + { MUT_SLEEPINESS, 3, 3, true }, + { RANDOM_MUTATION, 0, 3, false }, // 75 -- scales of various colours and effects - { MUT_RED_SCALES, 2, 3 }, - { MUT_NACREOUS_SCALES, 1, 3 }, - { MUT_GREY2_SCALES, 2, 3 }, - { MUT_METALLIC_SCALES, 1, 3 }, - { MUT_BLACK2_SCALES, 2, 3 }, - { MUT_WHITE_SCALES, 2, 3 }, - { MUT_YELLOW_SCALES, 2, 3 }, - { MUT_BROWN_SCALES, 2, 3 }, - { MUT_BLUE_SCALES, 2, 3 }, - { MUT_PURPLE_SCALES, 2, 3 }, + { MUT_RED_SCALES, 2, 3, false }, + { MUT_NACREOUS_SCALES, 1, 3, false }, + { MUT_GREY2_SCALES, 2, 3, false }, + { MUT_METALLIC_SCALES, 1, 3, false }, + { MUT_BLACK2_SCALES, 2, 3, false }, + { MUT_WHITE_SCALES, 2, 3, false }, + { MUT_YELLOW_SCALES, 2, 3, false }, + { MUT_BROWN_SCALES, 2, 3, false }, + { MUT_BLUE_SCALES, 2, 3, false }, + { MUT_PURPLE_SCALES, 2, 3, false }, // 85 - { MUT_SPECKLED_SCALES, 2, 3 }, - { MUT_ORANGE_SCALES, 2, 3 }, - { MUT_INDIGO_SCALES, 2, 3 }, - { MUT_RED2_SCALES, 1, 3 }, - { MUT_IRIDESCENT_SCALES, 1, 3 }, - { MUT_PATTERNED_SCALES, 1, 3 } + { MUT_SPECKLED_SCALES, 2, 3, false }, + { MUT_ORANGE_SCALES, 2, 3, false }, + { MUT_INDIGO_SCALES, 2, 3, false }, + { MUT_RED2_SCALES, 1, 3, false }, + { MUT_IRIDESCENT_SCALES, 1, 3, false }, + { MUT_PATTERNED_SCALES, 1, 3, false } }; #ifdef DEBUG_DIAGNOSTICS - void sanity_check_mutation_defs() { ASSERT(ARRAYSIZE(mutation_defs) == NUM_MUTATIONS); @@ -1009,9 +1008,14 @@ void sanity_check_mutation_defs() || mdef.mutation == RANDOM_MUTATION); } } - #endif +void fixup_mutations() +{ + if (player_genus(GENPC_DRACONIAN)) + mutation_defs[MUT_BIG_WINGS].rarity = 1; +} + formatted_string describe_mutations() { std::string result; @@ -1397,16 +1401,75 @@ static int calc_mutation_amusement_value(mutation_type which_mutation) return (amusement); } -static bool accept_mutation( mutation_type mutat ) +static bool accept_mutation( mutation_type mutat, bool ignore_rarity = false ) { if ( you.mutation[mutat] >= mutation_defs[mutat].levels ) - return false; + return (false); + + if ( ignore_rarity ) + return (true); const int rarity = mutation_defs[mutat].rarity + you.demon_pow[mutat]; // low rarity means unlikely to choose it return (rarity > random2(10)); } +static mutation_type get_random_xom_mutation() +{ + mutation_type mutat = NUM_MUTATIONS; + do + { + mutat = static_cast<mutation_type>(random2(NUM_MUTATIONS)); + + if (one_chance_in(1000)) + return (NUM_MUTATIONS); + if (one_chance_in(5)) + { + switch (random2(8)) + { + case 0: mutat = MUT_WEAK; break; + case 1: mutat = MUT_DOPEY; break; + case 2: mutat = MUT_CLUMSY; break; + case 3: mutat = MUT_DEFORMED; break; + case 4: mutat = MUT_SCREAM; break; + case 5: mutat = MUT_DETERIORATION; break; + case 6: mutat = MUT_BLURRY_VISION; break; + case 7: mutat = MUT_FRAIL; break; + } + } + } + while ( !accept_mutation(mutat) ); + + return (mutat); +} + +static mutation_type get_random_mutation(bool prefer_good, + int preferred_multiplier) +{ + int cweight = 0; + mutation_type chosen = NUM_MUTATIONS; + for (int i = 0; i < NUM_MUTATIONS; ++i) + { + if (!mutation_defs[i].rarity) + continue; + + const mutation_type curr = static_cast<mutation_type>(i); + if (!accept_mutation(curr, true)) + continue; + + const bool weighted = mutation_defs[i].bad != prefer_good; + int weight = mutation_defs[i].rarity; + if (weighted) + weight = weight * preferred_multiplier / 100; + + cweight += weight; + + if (random2(cweight) < weight) + chosen = curr; + } + return (chosen); +} + bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation, bool demonspawn) { @@ -1482,28 +1545,13 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation, } else if (which_mutation == RANDOM_XOM_MUTATION) { - do - { - mutat = static_cast<mutation_type>(random2(NUM_MUTATIONS)); - - if (one_chance_in(1000)) - return false; - if (one_chance_in(5)) - { - switch (random2(8)) - { - case 0: mutat = MUT_WEAK; break; - case 1: mutat = MUT_DOPEY; break; - case 2: mutat = MUT_CLUMSY; break; - case 3: mutat = MUT_DEFORMED; break; - case 4: mutat = MUT_SCREAM; break; - case 5: mutat = MUT_DETERIORATION; break; - case 6: mutat = MUT_BLURRY_VISION; break; - case 7: mutat = MUT_FRAIL; break; - } - } - } - while ( !accept_mutation(mutat) ); + if ((mutat = get_random_xom_mutation()) == NUM_MUTATIONS) + return (false); + } + else if (which_mutation == RANDOM_GOOD_MUTATION) + { + if ((mutat = get_random_mutation(true, 500)) == NUM_MUTATIONS) + return (false); } else if (you.mutation[mutat] >= 3 && mutat != MUT_STRONG && mutat != MUT_CLEVER && diff --git a/crawl-ref/source/mutation.h b/crawl-ref/source/mutation.h index 35419cf737..6f653e3c30 100644 --- a/crawl-ref/source/mutation.h +++ b/crawl-ref/source/mutation.h @@ -22,8 +22,13 @@ struct mutation_def mutation_type mutation; short rarity; // Rarity of the mutation. short levels; // The number of levels of the mutation. + bool bad; // A mutation that's more bad than good. Xom uses + // this to decide which mutations to hand out as + // rewards. }; +void fixup_mutations(); + // last updated 12may2000 {dlb} /* *********************************************************************** * called from: acr - decks - effects - fight - food - it_use2 - items - @@ -32,7 +37,6 @@ struct mutation_def bool mutate(mutation_type which_mutation, bool failMsg = true, bool force_mutation = false, bool demonspawn = false); - // last updated 12may2000 {dlb} /* *********************************************************************** * called from: acr diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 93c0fa630c..d08588ced8 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -626,7 +626,7 @@ static bool xom_is_good(int sever) int j = random2(4); while (i < j) { - if (mutate(RANDOM_MUTATION, failMsg, true)) + if (mutate(RANDOM_GOOD_MUTATION, failMsg, true)) done = true; else failMsg = false; @@ -704,8 +704,7 @@ static bool xom_is_bad(int sever) (temp_rand == 2) ? "Xom's power almost touches on you for a moment." : "You almost hear Xom's maniacal laughter."); - miscast_effect( SPTYP_RANDOM, 0, 0, 0, - "the mischievity of Xom" ); + miscast_effect( SPTYP_RANDOM, 0, 0, 0, "the mischief of Xom" ); done = true; } |