Skip to content

Commit

Permalink
Implement contamination resistance as a mutation, give it to some races.
Browse files Browse the repository at this point in the history
Mummies get it at level 3, halflings at level 1, and spriggans at level -3.
Loading a save from an older version won't give the right mutation levels, but
oh well.
  • Loading branch information
dtsund committed Sep 13, 2012
1 parent e23b7d7 commit ce920d7
Show file tree
Hide file tree
Showing 7 changed files with 85 additions and 61 deletions.
18 changes: 16 additions & 2 deletions crawl-ref/source/enum.h
Original file line number Diff line number Diff line change
Expand Up @@ -2524,7 +2524,9 @@ enum mutation_type
MUT_BLURRY_VISION,
MUT_BREATHE_FLAMES,
MUT_BREATHE_POISON,
#if TAG_MAJOR_VERSION == 32
MUT_CARNIVOROUS,
#endif
MUT_CLARITY,
MUT_CLEVER,
MUT_CLUMSY,
Expand All @@ -2536,12 +2538,20 @@ enum mutation_type
MUT_DETERIORATION,
MUT_DOPEY,
MUT_HEAT_RESISTANCE,
#if TAG_MAJOR_VERSION == 32
MUT_HERBIVOROUS,
#endif
MUT_HURL_HELLFIRE,
MUT_FAST,
MUT_FAST_METABOLISM,
#if TAG_MAJOR_VERSION == 32
MUT_GLOW_INTOLERANCE,
#endif
MUT_FLEXIBLE_WEAK,
MUT_FRAIL,
#if TAG_MAJOR_VERSION != 32
MUT_GLOW_TOLERANCE,
MUT_GLOW_INTOLERANCE,
#endif
MUT_GOURMAND,
MUT_HIGH_MAGIC,
MUT_ICEMAIL,
Expand All @@ -2559,12 +2569,16 @@ enum mutation_type
#endif
MUT_REGENERATION,
MUT_ROBUST,
#if TAG_MAJOR_VERSION == 32
MUT_SAPROVOROUS,
#endif
MUT_SCREAM,
MUT_SHAGGY_FUR,
MUT_SHOCK_RESISTANCE,
MUT_SLOW_HEALING,
MUT_SLOW_METABOLISM,
#if TAG_MAJOR_VERSION == 32
MUT_GLOW_TOLERANCE,
#endif
MUT_SPINY,
MUT_SPIT_POISON,
MUT_STOCHASTIC_TORMENT_RESISTANCE,
Expand Down
48 changes: 24 additions & 24 deletions crawl-ref/source/mutation-data.h
Original file line number Diff line number Diff line change
Expand Up @@ -206,40 +206,40 @@
"slow healing"
},

{ MUT_FAST_METABOLISM, 10, 3, true, false,
"fast metabolism",
{ MUT_GLOW_INTOLERANCE, 10, 3, true, false,
"contamination intolerance",

{"You have a fast metabolism.",
"You have a very fast metabolism.",
"Your metabolism is lightning-fast."},
{"You tolerate magical contamination poorly.",
"You tolerate magical contamination very poorly.",
"You tolerate magical contamination extremely poorly."},

{"You feel a little hungry.",
"You feel a little hungry.",
"You feel a little hungry."},
{"You feel averse to contamination.",
"You feel averse to contamination.",
"You feel averse to contamination."},

{"Your metabolism slows.",
"Your metabolism slows.",
"Your metabolism slows."},
{"You feel more resistant to magical contamination.",
"You feel more resistant to magical contamination.",
"You feel more resistant to magical contamination."},

"fast metabolism"
"contamination intolerance"
},

{ MUT_SLOW_METABOLISM, 7, 3, false, false,
"slow metabolism",
{ MUT_GLOW_TOLERANCE, 7, 3, false, false,
"contamination tolerance",

{"You have a slow metabolism.",
"You have a slow metabolism.",
"You need consume almost no food."},
{"You tolerate magical contamination well.",
"You tolerate magical contamination very well.",
"You tolerate magical contamination extremely well."},

{"Your metabolism slows.",
"Your metabolism slows.",
"Your metabolism slows."},
{"You feel more resistant to magical contamination.",
"You feel more resistant to magical contamination.",
"You feel more resistant to magical contamination."},

{"You feel a little hungry.",
"You feel a little hungry.",
"You feel a little hungry."},
{"You feel averse to contamination.",
"You feel averse to contamination.",
"You feel averse to contamination."},

"slow metabolism"
"contamination tolerance"
},

{ MUT_WEAK, 10, 14, true, true,
Expand Down
27 changes: 14 additions & 13 deletions crawl-ref/source/mutation.cc
Original file line number Diff line number Diff line change
Expand Up @@ -571,7 +571,7 @@ static int _calc_mutation_amusement_value(mutation_type which_mutation)
case MUT_POISON_RESISTANCE:
case MUT_SHOCK_RESISTANCE:
case MUT_REGENERATION:
case MUT_SLOW_METABOLISM:
case MUT_GLOW_TOLERANCE:
case MUT_TELEPORT_CONTROL:
case MUT_MAGIC_RESISTANCE:
case MUT_TELEPORT_AT_WILL:
Expand All @@ -585,7 +585,7 @@ static int _calc_mutation_amusement_value(mutation_type which_mutation)
case MUT_CARNIVOROUS:
case MUT_HERBIVOROUS:
case MUT_SLOW_HEALING:
case MUT_FAST_METABOLISM:
case MUT_GLOW_INTOLERANCE:
case MUT_WEAK:
case MUT_DOPEY:
case MUT_CLUMSY:
Expand Down Expand Up @@ -757,7 +757,6 @@ static int _handle_conflicting_mutations(mutation_type mutation,
bool override)
{
const int conflict[][3] = {
{ MUT_REGENERATION, MUT_SLOW_METABOLISM, 0},
{ MUT_REGENERATION, MUT_SLOW_HEALING, 0},
{ MUT_ACUTE_VISION, MUT_BLURRY_VISION, 0},
{ MUT_FAST, MUT_SLOW, 0},
Expand All @@ -771,7 +770,7 @@ static int _handle_conflicting_mutations(mutation_type mutation,
{ MUT_ROBUST, MUT_FRAIL, 1},
{ MUT_HIGH_MAGIC, MUT_LOW_MAGIC, 1},
{ MUT_CARNIVOROUS, MUT_HERBIVOROUS, 1},
{ MUT_SLOW_METABOLISM, MUT_FAST_METABOLISM, 1},
{ MUT_GLOW_TOLERANCE, MUT_GLOW_INTOLERANCE, 1},
{ MUT_REGENERATION, MUT_SLOW_HEALING, 1},
{ MUT_ACUTE_VISION, MUT_BLURRY_VISION, 1},
{ MUT_FAST, MUT_SLOW, 1},
Expand Down Expand Up @@ -905,15 +904,6 @@ static bool _physiology_mutation_conflict(mutation_type mutat)
if (mutat == MUT_BIG_WINGS && !player_genus(GENPC_DRACONIAN))
return (true);

// Vampires' healing and thirst rates depend on their blood level.
if (you.species == SP_VAMPIRE
&& (mutat == MUT_CARNIVOROUS || mutat == MUT_HERBIVOROUS
|| mutat == MUT_REGENERATION || mutat == MUT_SLOW_HEALING
|| mutat == MUT_FAST_METABOLISM || mutat == MUT_SLOW_METABOLISM))
{
return (true);
}

// Already innate, and unlike trolls/ghouls, no increases for you!
if (mutat == MUT_CLAWS && you.species == SP_CAT)
return (true);
Expand Down Expand Up @@ -1203,6 +1193,12 @@ bool mutate(mutation_type which_mutation, bool failMsg,
case MUT_RUGGED_BROWN_SCALES:
calc_hp();
break;

case MUT_GLOW_TOLERANCE:
case MUT_GLOW_INTOLERANCE:
you.max_magic_contamination = get_max_magic_contamination();
you.redraw_glow = true;
break;

case MUT_LOW_MAGIC:
case MUT_HIGH_MAGIC:
Expand Down Expand Up @@ -1330,6 +1326,11 @@ static bool _delete_single_mutation_level(mutation_type mutat)
}
if (mutat == MUT_LOW_MAGIC || mutat == MUT_HIGH_MAGIC)
calc_mp();
if (mutat == MUT_GLOW_TOLERANCE || mutat == MUT_GLOW_INTOLERANCE)
{
you.max_magic_contamination = get_max_magic_contamination();
you.redraw_glow = true;
}

// Did we gain a slot?
slots = player_armour_slots() - slots;
Expand Down
30 changes: 13 additions & 17 deletions crawl-ref/source/ng-setup.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,36 +229,32 @@ void unfocus_stats()

void give_basic_mutations(species_type speci)
{
// We should switch over to a size-based system
// for the fast/slow metabolism when we get around to it.
switch (speci)
{
case SP_HILL_ORC:
you.mutation[MUT_SAPROVOROUS] = 1;
break;
case SP_OGRE:
you.mutation[MUT_TOUGH_SKIN] = 1;
you.mutation[MUT_FAST_METABOLISM] = 1;
you.mutation[MUT_SAPROVOROUS] = 1;
break;
case SP_HALFLING:
you.mutation[MUT_SLOW_METABOLISM] = 1;
you.mutation[MUT_MUTATION_RESISTANCE] = 1;
you.mutation[MUT_GLOW_TOLERANCE] = 1;
break;
case SP_MINOTAUR:
you.mutation[MUT_HORNS] = 2;
break;
case SP_SPRIGGAN:
you.mutation[MUT_ACUTE_VISION] = 1;
you.mutation[MUT_FAST] = 3;
you.mutation[MUT_HERBIVOROUS] = 3;
you.mutation[MUT_SLOW_METABOLISM] = 3;
you.mutation[MUT_ACUTE_VISION] = 1;
you.mutation[MUT_FAST] = 3;
you.mutation[MUT_HERBIVOROUS] = 3;
you.mutation[MUT_GLOW_INTOLERANCE] = 3;
break;
case SP_CENTAUR:
you.mutation[MUT_TOUGH_SKIN] = 3;
you.mutation[MUT_FAST] = 2;
you.mutation[MUT_DEFORMED] = 1;
you.mutation[MUT_FAST_METABOLISM] = 2;
you.mutation[MUT_HOOVES] = 3;
break;
case SP_NAGA:
Expand All @@ -273,6 +269,7 @@ void give_basic_mutations(species_type speci)
you.mutation[MUT_COLD_RESISTANCE] = 1;
you.mutation[MUT_NEGATIVE_ENERGY_RESISTANCE] = 3;
you.mutation[MUT_UNBREATHING] = 1;
you.mutation[MUT_GLOW_TOLERANCE] = 3;
break;
case SP_DEEP_DWARF:
you.mutation[MUT_SLOW_HEALING] = 3;
Expand All @@ -293,12 +290,12 @@ void give_basic_mutations(species_type speci)
you.mutation[MUT_TALONS] = 3;
break;
case SP_TROLL:
you.mutation[MUT_TOUGH_SKIN] = 2;
you.mutation[MUT_REGENERATION] = 2;
you.mutation[MUT_FAST_METABOLISM] = 3;
you.mutation[MUT_SAPROVOROUS] = 2;
you.mutation[MUT_GOURMAND] = 1;
you.mutation[MUT_SHAGGY_FUR] = 1;
you.mutation[MUT_TOUGH_SKIN] = 2;
you.mutation[MUT_REGENERATION] = 2;
you.mutation[MUT_GLOW_INTOLERANCE] = 3;
you.mutation[MUT_SAPROVOROUS] = 2;
you.mutation[MUT_GOURMAND] = 1;
you.mutation[MUT_SHAGGY_FUR] = 1;
break;
case SP_KOBOLD:
you.mutation[MUT_SAPROVOROUS] = 2;
Expand All @@ -315,7 +312,6 @@ void give_basic_mutations(species_type speci)
you.mutation[MUT_ACUTE_VISION] = 1;
you.mutation[MUT_FAST] = 1;
you.mutation[MUT_CARNIVOROUS] = 3;
you.mutation[MUT_SLOW_METABOLISM] = 2;
break;
default:
break;
Expand Down Expand Up @@ -1628,7 +1624,7 @@ static void _setup_generic(const newgame_def& ng)
you.difficulty_level = 0;

// Set max glow according to race.
you.max_magic_contamination = get_max_magic_contamination(you.species);
you.max_magic_contamination = get_max_magic_contamination();

// tmpfile purging removed in favour of marking
Generated_Levels.clear();
Expand Down
19 changes: 16 additions & 3 deletions crawl-ref/source/player.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7003,10 +7003,23 @@ bool need_expiration_warning(coord_def p)
|| need_expiration_warning(DUR_TRANSFORMATION, p);
}

int get_max_magic_contamination(species_type species)
int get_max_magic_contamination()
{
if(species == SP_SPRIGGAN)
return 7;
//Levels 1, 2, and 3 of contamination intolerance mean
//max contamination of 9, 8, and 7 respectively.
if(you.mutation[MUT_GLOW_INTOLERANCE] > 0)
return 10 - you.mutation[MUT_GLOW_INTOLERANCE];

//Levels 1, 2, and 3 of contamination tolerance mean
//max contamination of 11, 13, and 15 respectively.
if(you.mutation[MUT_GLOW_TOLERANCE] == 1)
return 11;
if(you.mutation[MUT_GLOW_TOLERANCE] == 2)
return 13;
if(you.mutation[MUT_GLOW_TOLERANCE] == 3)
return 15;

//For everyone else, max contamination is 10.
return 10;
}

Expand Down
2 changes: 1 addition & 1 deletion crawl-ref/source/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ int count_worn_ego(int which_ego);
bool need_expiration_warning(duration_type dur, coord_def p = you.pos());
bool need_expiration_warning(coord_def p = you.pos());

int get_max_magic_contamination(species_type species);
int get_max_magic_contamination();
bool contamination_warning_prompt(int cost);

void check_relatively_safe(bool maybe_print_message);
Expand Down
2 changes: 1 addition & 1 deletion crawl-ref/source/tags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1914,7 +1914,7 @@ static void tag_read_you(reader &th)

you.magic_contamination = unmarshallShort(th);

you.max_magic_contamination = get_max_magic_contamination(you.species);
you.max_magic_contamination = get_max_magic_contamination();

you.transit_stair = static_cast<dungeon_feature_type>(unmarshallShort(th));
you.entering_level = unmarshallByte(th);
Expand Down

0 comments on commit ce920d7

Please sign in to comment.