All demonspawn mutations are now stored in the player data, and are determined at the same time. This makes a lot of things a lot simpler. On the other hand, it means that the influence of skills and gods on demonspawn mutations is now broken.
FI3VHM2VQ6464NMVYMZECJOR6QRAF34DFTY4QMZK6OKLULDPWDLQC
OMZYXQ7AISPGR5YAFE7KWIWJ7QRWWT7JW3IARYXTAD24MLESK3LQC
ASXBSZVXJCWVX5VQSRWXL5BWQ4NA7JLYXP6LWQTRGYW6DC2DZZPQC
ESDNBDSWZ7YAH2EEUW5ASOT4WEJTXRISLQYBOHR4UMLSM6R67NJAC
2J7K5MBUMH2E7SP6QAG3NCWLKOAVCCXGBTOWBS4TFR62EPR5LCTQC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
AM7QPHDAWNXHLUEVUHVRHG2RO2DOIEFFU4GV3DCIROW6O5HW7H4AC
3ZGWHU6PVOY4BN6RW6KDFDZMNRRVJUPPOKBJK6VGQWKCQO73RDLAC
SDLKLUNFGVKDS55DDJZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC
6LT6USGJOTDMRJGXLAN2NSZXK2GKWEXDKKUV6SVV7ZC6WI6EKMDQC
RPOZZWKG5GLPHVZZ7ZKMKS64ZMV2LDCQSARBJFJ6FZOTOKCQO7FAC
QCUMH3C7GXV7ZW444WT5SFAXQOJKJSE2YCQCEHMRYXCWF4QI7UMAC
JJULXW764V5C2HJKZNWQAEWB6QM5YZADD7ZCE35LYTBFEM6PMYCAC
PEUZZFISVFBBT4VAJXIMVHTWCILA6ZWQRRJQAU7GN53PB5UMSVDQC
ZASKZI4USJSPW7CSCJUCFMLLTNQT3IGF5XSSW2FU7ESY735AMSFAC
UQ7N7BERCVCYALWKITQMJIWNSHHSWUYOU65LXD6HQKLXG4NF5CTAC
XT54K5UXLTCR4WIB6OWYISDRXLC4WXFAK5MHKUBCDKDIKQSLS6GAC
4LFTDJY3DK6S7C7SQLLML6UIZ42GZOWK2EIMZZSNEKBWSA3YNUZAC
44HR7YI3CBRCEGEMIM6UOITU4W3RR5RBUGUV7ICXCN3ZIXLRJXYAC
VUQ5XAUEMDXEZG6OSF5KATPGSKWG7O2FETTNENYVKZ5CCTJVWICQC
CA6ZG6P2CE5EPAOQSB3P7NBDKTNFFHQP4CPOUFZL32ON6N32GSSQC
335BGGYD3NH4ACHUEZGDXKXXMVL6JMGQ7YPHLTU2256GT2VWV24AC
7QWZ7W65CQ6I4XXD4VKQC6AS2WJFQU6SFDBJB7HVIOW7CTOYRUFQC
CMNLYUECIMEZSOYG4KOSINOPER5OM7PPCGIHCM7LQVWEO77XFUYQC
TUK5T3O6YOMKR6SD37666MMV4OHXQ7D76JJ4DNVP5AXWZ2VQ2DXAC
TPQNZXHPSGTVA36N5YSQQVJJVVGWSRGNBNWQYMUXMFMINS4IZUCQC
PHEPIJAZS5AC3NBXJUINAIWXUCPEYILNNPTFRA7LGPFGGRC47CKAC
COLIFJSMENLCY37NBIBC4NLQ3FGRHWPJX4WIVLX64MK2K3YTRWBQC
CLIEHAE2PP7ZIGLLIMYCWM4FC54KBOAN5AILOLAZJ5S26GTJM4RQC
2U7VFZ3242P22EPRQKCIHFZRRWHHBZGOEEN2WJNMCXV5BEI67NNAC
S6ZETU2X3HBTKBDL2KTAMCNPMPGHEZO2JGMILIWETWC7XXRS5RYQC
BINKDWGFGUPTOA7IE5KK4ZIELGU5WC3X47MYXOWU4X43EGAC5DUAC
DWWOM6V2Z4RQVT6AKW6OYLSFOUE4W5PTP2SH4AAZE2E4EIH4RLUAC
// We want 17 (6*3 - 1) random attemps to raise or add a
// mutation in the 26 level ups. The following check is
// equivalent to taking a string of 17 1s and 9 0s and
// shuffling it.
if (x_chance_in_y(17 - you.attribute[ATTR_NUM_DEMONIC_POWERS],
28 - you.experience_level))
if (you.demon_trait[you.experience_level - 2] != NUM_MUTATIONS)
if (you.mutation[mut_to_increase] == mdef.levels)
{
// The player has our mutation as a temporary thing. Make
// it permanent. I want to put something like NetHack's "Your
// quickness feels more natural" here, but there doesn't seem
// to be a good way to do that.
mpr(mdef.gain[you.demon_pow[mut_to_increase]], MSGCH_MUTATION);
++you.demon_pow[mut_to_increase];
}
else
{
// None of the current demonspawn mutations is capable of
// failing. Be very careful if others are added; for instance,
// talons can fail to mutate if the player already has hooves.
// You'll need to add a case for clearing mutations in
// _handle_conflicting_mutations above.
ASSERT(perma_mutate(mut_to_increase, 1));
}
ASSERT(muts[mut_to_increase] < mdef.levels);
// Theoretically, you could use this with Trog (for rods and
// some misc. items), but in general it's going to be much more
// useful for someone capable of casting spells.
if (you.religion != GOD_TROG
&& you.religion != GOD_SIF_MUNA && one_chance_in(11))
if (one_chance_in(11))
// Yredelemnulites have the raise dead invocation
if (you.religion != GOD_YREDELEMNUL
&& you.skills[SK_SUMMONINGS] < 3
&& you.skills[SK_NECROMANCY] < 3 && one_chance_in(10))
if (one_chance_in(10))
// Drain Life only works if you're unarmed, so only
// give it if unarmed is your best attacking skill.
skill_type wpn_skill = best_skill(SK_SHORT_BLADES, SK_STAVES);
if ((you.skills[SK_UNARMED_COMBAT] > you.skills[wpn_skill])
&& one_chance_in(14))
{
whichm = MUT_DRAIN_LIFE;
}
whichm = MUT_DRAIN_LIFE;
if ((!you.mutation[MUT_THROW_FROST] // only one of these
&& !you.mutation[MUT_THROW_FLAMES]
&& !you.mutation[MUT_BREATHE_FLAMES])
&& (!you.skills[SK_CONJURATIONS] // conjurers seldomly
|| one_chance_in(5))
// Makhlebites seldom
&& (you.religion != GOD_MAKHLEB || one_chance_in(4))
&& (!you.skills[SK_ICE_MAGIC] // already ice & fire?
|| !you.skills[SK_FIRE_MAGIC]))
if (!muts[MUT_THROW_FROST] // only one of these
&& !muts[MUT_THROW_FLAMES]
&& !muts[MUT_BREATHE_FLAMES])
// try to give the flavour the character doesn't have
// neither
if (!you.skills[SK_FIRE_MAGIC] && !you.skills[SK_ICE_MAGIC])
whichm = (coinflip() ? MUT_THROW_FLAMES : MUT_THROW_FROST);
else if (!you.skills[SK_FIRE_MAGIC])
whichm = MUT_THROW_FLAMES;
else if (!you.skills[SK_ICE_MAGIC])
whichm = MUT_THROW_FROST;
// both
else
whichm = (coinflip() ? MUT_THROW_FLAMES : MUT_THROW_FROST);
whichm = (coinflip() ? MUT_THROW_FLAMES : MUT_THROW_FROST);
if (!you.mutation[MUT_THROW_FROST] // not with these
&& !you.mutation[MUT_THROW_FLAMES]
&& !you.mutation[MUT_BREATHE_FLAMES]
&& !you.skills[SK_FIRE_MAGIC] // or with fire already
if (!muts[MUT_THROW_FROST] // not with these
&& !muts[MUT_THROW_FLAMES]
&& !muts[MUT_BREATHE_FLAMES]
if (whichm == NUM_MUTATIONS || !perma_mutate( whichm, 1 ))
if (whichm == NUM_MUTATIONS)
{
return MUT_STRONG;
}
return whichm;
}
void roll_demonspawn_mutations()
{
FixedVector<int, NUM_MUTATIONS> muts;
int npowers = 0;
muts.init(0);
you.demon_trait.init(NUM_MUTATIONS);
for (int level = 2; level <= 27; ++level)
// Unlikely but remotely possible; I know this is a cop-out.
modify_stat(STAT_STRENGTH, 1, true, "demonspawn mutation");
modify_stat(STAT_INTELLIGENCE, 1, true, "demonspawn mutation");
modify_stat(STAT_DEXTERITY, 1, true, "demonspawn mutation");
mpr("You feel much better now.", MSGCH_INTRINSIC_GAIN);
// We want 17 (6*3 - 1) random attemps to raise or add a
// mutation in the 26 level ups. The following check is
// equivalent to taking a string of 17 1s and 9 0s and
// shuffling it.
if (x_chance_in_y(17 - npowers, 28 - level))
{
mutation_type newmut = _demonspawn(muts, npowers, level);
#ifdef DEBUG_DIAGNOSTICS
mprf(MSGCH_DIAGNOSTICS, "Demonspawn will gain %s at level %d",
get_mutation_def(newmut).wizname, level);
#endif
you.demon_trait[level-2] = newmut;
muts[newmut]++;
}
if (you.experience_level < 4)
powers = 0;
else if (you.experience_level < 9)
powers = 1;
else if (you.experience_level < 14)
powers = 2;
else if (you.experience_level < 19)
powers = 3;
else if (you.experience_level < 24)
powers = 4;
else if (you.experience_level == 27)
powers = 5;
int levels[] = {4, 9, 14, 19, 27};
int real_level = you.experience_level;
if (m == NUM_MUTATIONS)
continue;
for (i = 0; i < powers; ++i)
{
// The types of demonspawn mutations you get depends on your
// experience level at the time of gaining it.
you.experience_level = levels[i];
demonspawn();
++you.mutation[m];
++you.demon_pow[m];