From 5562dfc2a3dd500be1a98a02703eb37496b5fb8e Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Sun, 8 Nov 2009 05:13:41 -0800 Subject: Relax the one mutation per level rule for DS Breaks saves. --- crawl-ref/source/mutation.cc | 7 +++++-- crawl-ref/source/player.cc | 22 ++++++++++++++++++---- crawl-ref/source/player.h | 14 +++++++++++--- crawl-ref/source/tags.cc | 15 +++++++++++---- crawl-ref/source/wiz-you.cc | 6 +++--- 5 files changed, 48 insertions(+), 16 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc index c105cb585a..b6d1409ccc 100644 --- a/crawl-ref/source/mutation.cc +++ b/crawl-ref/source/mutation.cc @@ -2823,7 +2823,8 @@ try_again: } } - you.demon_trait.init(NUM_MUTATIONS); + you.demonic_traits.clear(); + player::demon_trait dt; // Now give mutations from the facets in some order, consistent // with the internal order of the facets. @@ -2871,7 +2872,9 @@ try_again: mprf(MSGCH_DIAGNOSTICS, "Demonspawn will gain %s at level %d", get_mutation_def(newmut).wizname, level); #endif - you.demon_trait[level - 2] = newmut; + dt.level_gained = level; + dt.mutation = newmut; + you.demonic_traits.push_back(dt); ++given[which_facet]; ++ngiven; diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 59a20295ac..07ba1e784a 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -3180,10 +3180,24 @@ void level_change(bool skip_attribute_increase) break; case SP_DEMONSPAWN: - if (you.demon_trait[you.experience_level - 2] != NUM_MUTATIONS) { - mpr("Your demonic ancestry asserts itself...", MSGCH_INTRINSIC_GAIN); - perma_mutate(you.demon_trait[you.experience_level - 2], 1); + bool gave_message = false; + + for (unsigned i = 0; i < you.demonic_traits.size(); ++i) + { + if (you.demonic_traits[i].level_gained + == you.experience_level) + { + if (!gave_message) + { + mpr("Your demonic ancestry asserts itself...", + MSGCH_INTRINSIC_GAIN); + + gave_message = true; + } + perma_mutate(you.demonic_traits[i].mutation, 1); + } + } } if (!(you.experience_level % 4)) @@ -5572,7 +5586,7 @@ void player::init() mutation.init(0); demon_pow.init(0); - demon_trait.init(NUM_MUTATIONS); + demonic_traits.clear(); had_book.init(false); diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index ff225c1105..e7cca6269b 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -12,6 +12,8 @@ #include "itemprop.h" #include "species.h" +#include + #ifdef USE_TILE // This used to be in tiles.h. (jpeg) #include "tiledef-main.h" @@ -221,9 +223,15 @@ public: FixedVector mutation; FixedVector demon_pow; - // demon_trait[i] is the mutation increased at the i'th - // levellup, or NUM_MUTATIONS - FixedVector demon_trait; + + struct demon_trait + { + int level_gained; + mutation_type mutation; + }; + + std::vector demonic_traits; + unsigned char magic_contamination; FixedVector had_book; diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 0d140664e5..7ba129ed01 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -949,10 +949,11 @@ static void tag_construct_you(writer &th) marshallByte(th, you.demon_pow[j]); } - marshallByte(th, 26); - for (j = 0; j < 26; j++) + marshallByte(th, you.demonic_traits.size()); + for (j = 0; j < int(you.demonic_traits.size()); ++j) { - marshallShort(th, you.demon_trait[j]); + marshallByte(th, you.demonic_traits[j].level_gained); + marshallShort(th, you.demonic_traits[j].mutation); } // how many penances? @@ -1403,8 +1404,14 @@ static void tag_read_you(reader &th, char minorVersion) if (minorVersion >= TAG_MINOR_DSTRAITS) { count_c = unmarshallByte(th); + you.demonic_traits.clear(); for (j = 0; j < count_c; ++j) - you.demon_trait[j] = static_cast(unmarshallShort(th)); + { + player::demon_trait dt; + dt.level_gained = unmarshallByte(th); + dt.mutation = static_cast(unmarshallShort(th)); + you.demonic_traits.push_back(dt); + } } // how many penances? diff --git a/crawl-ref/source/wiz-you.cc b/crawl-ref/source/wiz-you.cc index ad1fb6eb15..d81e08cc39 100644 --- a/crawl-ref/source/wiz-you.cc +++ b/crawl-ref/source/wiz-you.cc @@ -127,11 +127,11 @@ void wizard_change_species( void ) case SP_DEMONSPAWN: { roll_demonspawn_mutations(); - for (i = 2; i <= you.experience_level; ++i) + for (i = 0; i < int(you.demonic_traits.size()); ++i) { - mutation_type m = you.demon_trait[i-2]; + mutation_type m = you.demonic_traits[i].mutation; - if (m == NUM_MUTATIONS) + if (you.demonic_traits[i].level_gained > you.experience_level) continue; ++you.mutation[m]; -- cgit v1.2.3-54-g00ecf