Demonspawn gain all mutations at level 1, and the levels increase over time, such that at level 27 5 mutations are level 3 and the 6th is level 2.
At 17 (6 * 3 - 1) randomly chosen levellups, the PC gains one level in a current or new mutation; the chance of raising an existing mutation is (# of demon mutations) / 6, so the number of total mutations will reach 6 around level 15 and stay there, but the levels of the mutations will increase.
This is the first part of the DS rework; it is applicable as is, and has been tested (raising 8 demonspawn to level 27 in debug mode and sanity checking the results). However, it is not fully balanced as is for two reasons:
Not all demonspawn mutations have 3 levels yet, so you sometimes run out of available mutations before level 27. When this happens, this patch gives a bonus mutation.
Some demonspawn mutations are very broken at level 3, such as fire resistance and teleport at will (level 3 is instantaneous).
So demonspawn will get a lot stronger until the rest of the changes come in.
Signed-off-by: Stefan O'Rear <stefanor@cox.net> Signed-off-by: Robert Vollmert <rvollmert@gmx.net>
3ZGWHU6PVOY4BN6RW6KDFDZMNRRVJUPPOKBJK6VGQWKCQO73RDLAC
335BGGYD3NH4ACHUEZGDXKXXMVL6JMGQ7YPHLTU2256GT2VWV24AC
4LFTDJY3DK6S7C7SQLLML6UIZ42GZOWK2EIMZZSNEKBWSA3YNUZAC
K2CS6TCX2NDVL2ASEHGP4J4K4IJ6FP3ANNKTSIWVG43HPYSBX6ZQC
CMNLYUECIMEZSOYG4KOSINOPER5OM7PPCGIHCM7LQVWEO77XFUYQC
XT54K5UXLTCR4WIB6OWYISDRXLC4WXFAK5MHKUBCDKDIKQSLS6GAC
AE66GSBGYDYM74YB362N6RZW6RQQL4RCXWMDBGKKJXVAGCY25PFAC
63UCVTP63JTSBOG2SWB27RHOGKVSTRQL6XHF7D4GW2LNRDRZJ6FQC
if (you.attribute[ATTR_NUM_DEMONIC_POWERS] == 0
&& (you.experience_level == 4
|| (you.experience_level < 4 && one_chance_in(3))))
{
demonspawn();
}
if (you.attribute[ATTR_NUM_DEMONIC_POWERS] == 1
&& you.experience_level > 4
&& (you.experience_level == 9
|| (you.experience_level < 9 && one_chance_in(3))))
{
demonspawn();
}
if (you.attribute[ATTR_NUM_DEMONIC_POWERS] == 2
&& you.experience_level > 9
&& (you.experience_level == 14
|| (you.experience_level < 14 && one_chance_in(3))))
{
demonspawn();
}
if (you.attribute[ATTR_NUM_DEMONIC_POWERS] == 3
&& you.experience_level > 14
&& (you.experience_level == 19
|| (you.experience_level < 19 && one_chance_in(3))))
{
demonspawn();
}
// 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 (you.attribute[ATTR_NUM_DEMONIC_POWERS] == 4
&& you.experience_level > 19
&& (you.experience_level == 24
|| (you.experience_level < 24 && one_chance_in(3))))
if (x_chance_in_y(17 - you.attribute[ATTR_NUM_DEMONIC_POWERS],
28 - you.experience_level))
// A demonspawn logically has six mutation slots, like [cold res,
// negative res, teleport, black scales, mapping, repulsion field].
// They all start at 0 levels. For a smooth power-up, when this
// function is called we increase one mutation slot (which is not
// already at 3) by 1 level only.
// Look through the existing demon powers to find the slot. Note
// that this will not find powers at level 0; if a new power needs
// to be given, we will fall off the loop.
int increasable_muts_seen = 0;
int muts_seen = 0;
mutation_type mut_to_increase = NUM_MUTATIONS;
for (int i = 0; i < NUM_MUTATIONS; ++i)
{
whichm = static_cast<mutation_type>(i);
if (! you.demon_pow[whichm])
{
continue;
}
++muts_seen;
if (you.demon_pow[whichm] < mutation_defs[whichm].levels)
{
++increasable_muts_seen;
if (one_chance_in(increasable_muts_seen))
{
mut_to_increase = whichm;
}
}
}
// If you have less than 6 mutations, add chances to gain a new one
if (muts_seen < 6)
{
int chances_to_get_new = 6 - muts_seen;
increasable_muts_seen += chances_to_get_new;
if (x_chance_in_y(chances_to_get_new, increasable_muts_seen))
{
mut_to_increase = NUM_MUTATIONS;
}
}
// If you already have 6 demon powers, but there are no candidates
// for increasing, then this function has been called too many times.
// XXX right now, there are 1-level mutations on the demonspawn list,
// so this will be reached - give a bonus power.
if (increasable_muts_seen == 0)
{
mut_to_increase = NUM_MUTATIONS;
}
if (mut_to_increase != NUM_MUTATIONS)
{
const mutation_def& mdef = mutation_defs[mut_to_increase];
ASSERT(you.demon_pow[mut_to_increase] < mdef.levels);
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));
}
return;
}
// Otherwise we're adding a brand new mutation
switch (whichm)
{
case MUT_RED_SCALES:
case MUT_NACREOUS_SCALES:
case MUT_BLACK2_SCALES:
case MUT_WHITE_SCALES:
case MUT_BLUE_SCALES:
case MUT_SPECKLED_SCALES:
case MUT_ORANGE_SCALES:
case MUT_IRIDESCENT_SCALES:
case MUT_PATTERNED_SCALES:
levels = (coinflip() ? 2 : 3);
break;
default:
levels = (coinflip() ? 1 : 2);
break;
}