summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/transform.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-07-31 19:05:25 -0400
committerNeil Moore <neil@s-z.org>2014-07-31 19:22:10 -0400
commitaec5098ce35c6f07899d998b2f74934972640e4e (patch)
tree5a24513f46147aaa154bbb82a268b802902abb28 /crawl-ref/source/transform.cc
parentba7f0067d3dcc93715e1aba3e2e6f5af80ec1092 (diff)
downloadcrawl-ref-aec5098ce35c6f07899d998b2f74934972640e4e.tar.gz
crawl-ref-aec5098ce35c6f07899d998b2f74934972640e4e.zip
Don't remove extra horns when appendage ends (#8311)
This could happen if you got a mutation while transformed. It only occurred with horns, because appendage gives full levels of other slot mutations. Also, don't say your body part "disappears" if you still have mutation levels after the transformation ends, or if you lost the mutation before ending the transformation. Even before this commit, this could have happened if a demonspawn levelled up when in appendage form.
Diffstat (limited to 'crawl-ref/source/transform.cc')
-rw-r--r--crawl-ref/source/transform.cc33
1 files changed, 27 insertions, 6 deletions
diff --git a/crawl-ref/source/transform.cc b/crawl-ref/source/transform.cc
index 99110e9a49..989fd75c83 100644
--- a/crawl-ref/source/transform.cc
+++ b/crawl-ref/source/transform.cc
@@ -753,6 +753,15 @@ static int _transform_duration(transformation_type which_trans, int pow)
}
}
+static int _beastly_appendage_level(int appendage)
+{
+ switch (appendage)
+ {
+ case MUT_HORNS: return 2;
+ default: return 3;
+ }
+}
+
// Transforms you into the specified form. If involuntary, checks for
// inscription warnings are skipped, and the transformation fails silently
// (if it fails). If just_check is true the transformation doesn't actually
@@ -1156,7 +1165,7 @@ bool transform(int pow, transformation_type which_trans, bool involuntary,
int app = you.attribute[ATTR_APPENDAGE];
ASSERT(app != NUM_MUTATIONS);
ASSERT(beastly_slot(app) != EQ_NONE);
- you.mutation[app] = app == MUT_HORNS ? 2 : 3;
+ you.mutation[app] = _beastly_appendage_level(app);
}
break;
@@ -1353,12 +1362,24 @@ void untransform(bool skip_wielding, bool skip_move)
{
int app = you.attribute[ATTR_APPENDAGE];
ASSERT(beastly_slot(app) != EQ_NONE);
- // would be lots of work to do it via delete_mutation, the hacky
- // way is one line:
- you.mutation[app] = you.innate_mutation[app];
+ const int levels = you.mutation[app];
+ // Preserve extra mutation levels acquired after transforming.
+ const int beast_levels = _beastly_appendage_level(app);
+ const int extra = max(0, levels - you.innate_mutation[app]
+ - beast_levels);
+ you.mutation[app] = you.innate_mutation[app] + extra;
you.attribute[ATTR_APPENDAGE] = 0;
- mprf(MSGCH_DURATION, "Your %s disappear%s.", mutation_name((mutation_type) app),
- (app == MUT_TENTACLE_SPIKE) ? "s" : "");
+
+ // The mutation might have been removed already by a conflicting
+ // demonspawn innate mutation; no message then.
+ if (levels)
+ {
+ const char * const verb = you.mutation[app] ? "shrink"
+ : "disappear";
+ mprf(MSGCH_DURATION, "Your %s %s%s.",
+ mutation_name(static_cast<mutation_type>(app)), verb,
+ app == MUT_TENTACLE_SPIKE ? "s" : "");
+ }
}
break;