diff options
author | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-10-31 15:08:00 -0500 |
---|---|---|
committer | David Lawrence Ramsey <dolorous@users.sourceforge.net> | 2009-10-31 15:09:10 -0500 |
commit | a418d15295dfc484bdeef463ef6678424981b224 (patch) | |
tree | 0e21c1fa45e4acf5a321582a10510b38d49ebc93 | |
parent | c96b1349887c237d78ab6f3cbaa3967c1fe31bbe (diff) | |
download | crawl-ref-a418d15295dfc484bdeef463ef6678424981b224.tar.gz crawl-ref-a418d15295dfc484bdeef463ef6678424981b224.zip |
Merge mons_holiness() into monster::holiness(), and add an is_unholy()
convenience function.
26 files changed, 168 insertions, 189 deletions
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index 00b61b039a..b0f8157eeb 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -167,6 +167,7 @@ public: virtual int mons_species() const = 0; virtual mon_holy_type holiness() const = 0; + virtual bool is_unholy() const = 0; virtual int res_fire() const = 0; virtual int res_steam() const = 0; virtual int res_cold() const = 0; diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 12510875e4..0c065e5fe9 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2479,7 +2479,7 @@ static bool _monster_resists_mass_enchantment(monsters *monster, if (mons_friendly(monster)) return (true); - if (mons_holiness(monster) != MH_UNDEAD) + if (monster->holiness() != MH_UNDEAD) return (true); if (check_mons_resist_magic(monster, pow)) @@ -2491,7 +2491,7 @@ static bool _monster_resists_mass_enchantment(monsters *monster, } } else if (wh_enchant == ENCH_CONFUSION - || mons_holiness(monster) == MH_NATURAL) + || monster->holiness() == MH_NATURAL) { if (wh_enchant == ENCH_CONFUSION && !mons_class_is_confusable(monster->type)) @@ -4836,25 +4836,24 @@ bool _ench_flavour_affects_monster(beam_type flavour, const monsters* mon) break; case BEAM_DEGENERATE: - rc = (mons_holiness(mon) == MH_NATURAL + rc = (mon->holiness() == MH_NATURAL && mon->type != MONS_PULSATING_LUMP); break; case BEAM_ENSLAVE_UNDEAD: - rc = (mons_holiness(mon) == MH_UNDEAD && mon->attitude != ATT_FRIENDLY); + rc = (mon->holiness() == MH_UNDEAD && mon->attitude != ATT_FRIENDLY); break; case BEAM_ENSLAVE_SOUL: - rc = (mons_holiness(mon) == MH_NATURAL - && mon->attitude != ATT_FRIENDLY); + rc = (mon->holiness() == MH_NATURAL && mon->attitude != ATT_FRIENDLY); break; case BEAM_DISPEL_UNDEAD: - rc = (mons_holiness(mon) == MH_UNDEAD); + rc = (mon->holiness() == MH_UNDEAD); break; case BEAM_ENSLAVE_DEMON: - rc = (mons_holiness(mon) == MH_DEMONIC && !mons_friendly(mon)); + rc = (mon->holiness() == MH_DEMONIC && !mons_friendly(mon)); break; case BEAM_PAIN: @@ -4862,14 +4861,14 @@ bool _ench_flavour_affects_monster(beam_type flavour, const monsters* mon) break; case BEAM_SLEEP: - rc = !mon->has_ench(ENCH_SLEEP_WARY) // slept recently - && mons_holiness(mon) == MH_NATURAL // no unnatural + rc = !mon->has_ench(ENCH_SLEEP_WARY) // slept recently + && mon->holiness() == MH_NATURAL // no unnatural && mon->res_cold() <= 0; // can't be hibernated break; case BEAM_PORKALATOR: - rc = (mons_holiness(mon) == MH_DEMONIC && mon->type != MONS_HELL_HOG) - || (mons_holiness(mon) == MH_NATURAL && mon->type != MONS_HOG); + rc = (mon->holiness() == MH_DEMONIC && mon->type != MONS_HELL_HOG) + || (mon->holiness() == MH_NATURAL && mon->type != MONS_HOG); break; default: @@ -5214,7 +5213,7 @@ mon_resist_type bolt::apply_enchantment_to_monster(monsters* mon) return (MON_AFFECTED); case BEAM_PORKALATOR: - if (monster_polymorph(mon, (mons_holiness(mon) == MH_DEMONIC ? + if (monster_polymorph(mon, (mon->holiness() == MH_DEMONIC ? MONS_HELL_HOG : MONS_HOG))) { obvious_effect = true; @@ -5714,12 +5713,12 @@ bool bolt::nasty_to(const monsters *mon) const || flavour == BEAM_SLEEP || flavour == BEAM_ENSLAVE_SOUL) { - return (mons_holiness(mon) == MH_NATURAL); + return (mon->holiness() == MH_NATURAL); } // dispel undead / control undead if (flavour == BEAM_DISPEL_UNDEAD || flavour == BEAM_ENSLAVE_UNDEAD) - return (mons_holiness(mon) == MH_UNDEAD); + return (mon->holiness() == MH_UNDEAD); // pain / agony if (flavour == BEAM_PAIN) @@ -5727,7 +5726,7 @@ bool bolt::nasty_to(const monsters *mon) const // control demon if (flavour == BEAM_ENSLAVE_DEMON) - return (mons_holiness(mon) == MH_DEMONIC); + return (mon->holiness() == MH_DEMONIC); // everything else is considered nasty by everyone return (true); diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index c5f9475ee7..93928809d6 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -2516,7 +2516,7 @@ static void _crusade_card(int power, deck_rarity_type rarity) if (!monster->alive() || !mons_near(monster) || mons_friendly(monster) - || mons_holiness(monster) != MH_NATURAL + || monster->holiness() != MH_NATURAL || mons_is_unique(monster->type) || mons_immune_magic(monster) || player_will_anger_monster(monster)) diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index 8cc8bce644..4de151f7a7 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -64,7 +64,7 @@ static void _finish_delay(const delay_queue_item &delay); // note that berserk monsters are also hasted.) static bool _recite_mons_useless(const monsters *mon) { - const mon_holy_type holiness = mons_holiness(mon); + const mon_holy_type holiness = mon->holiness(); return (mons_intel(mon) < I_NORMAL || holiness != MH_HOLY @@ -85,25 +85,25 @@ static bool _recite_mons_useless(const monsters *mon) // Power is maximum 50. static int _recite_to_monsters(coord_def where, int pow, int, actor *) { - monsters *mons = monster_at(where); + monsters *mon = monster_at(where); - if (mons == NULL) + if (mon == NULL) return (0); - if (_recite_mons_useless(mons)) + if (_recite_mons_useless(mon)) return (0); if (coinflip()) // nothing happens return (0); int resist; - const mon_holy_type holiness = mons_holiness(mons); + const mon_holy_type holiness = mon->holiness(); if (holiness == MH_HOLY) resist = std::max(0, 7 - random2(you.skills[SK_INVOCATIONS])); else { - resist = mons_resist_magic(mons); + resist = mons_resist_magic(mon); if (holiness == MH_UNDEAD) pow -= 2 + random2(3); @@ -122,16 +122,17 @@ static int _recite_to_monsters(coord_def where, int pow, int, actor *) return (0); // nothing happens, whew! if (!one_chance_in(4) && - mons->add_ench(mon_enchant(ENCH_HASTE, 0, KC_YOU, - (16 + random2avg(13, 2)) * 10))) + mon->add_ench(mon_enchant(ENCH_HASTE, 0, KC_YOU, + (16 + random2avg(13, 2)) * 10))) { - simple_monster_message(mons, " speeds up in annoyance!"); + + simple_monster_message(mon, " speeds up in annoyance!"); } else if (!one_chance_in(3) - && mons->add_ench(mon_enchant(ENCH_BATTLE_FRENZY, 1, KC_YOU, + && mon->add_ench(mon_enchant(ENCH_BATTLE_FRENZY, 1, KC_YOU, (16 + random2avg(13, 2)) * 10))) { - simple_monster_message(mons, " goes into a battle-frenzy!"); + simple_monster_message(mon, " goes into a battle-frenzy!"); } else return (0); // nothing happens @@ -149,66 +150,66 @@ static int _recite_to_monsters(coord_def where, int pow, int, actor *) case 2: case 3: case 4: - if (!mons_class_is_confusable(mons->type) - || !mons->add_ench(mon_enchant(ENCH_CONFUSION, 0, KC_YOU, - (16 + random2avg(13, 2)) * 10))) + if (!mons_class_is_confusable(mon->type) + || !mon->add_ench(mon_enchant(ENCH_CONFUSION, 0, KC_YOU, + (16 + random2avg(13, 2)) * 10))) { return (0); } - simple_monster_message(mons, " looks confused."); + simple_monster_message(mon, " looks confused."); break; case 5: case 6: case 7: case 8: - mons->put_to_sleep(); - simple_monster_message(mons, " falls asleep!"); + mon->put_to_sleep(); + simple_monster_message(mon, " falls asleep!"); break; case 9: case 10: case 11: case 12: - if (!mons->add_ench(mon_enchant(ENCH_NEUTRAL, 0, KC_YOU, - (16 + random2avg(13, 2)) * 10))) + if (!mon->add_ench(mon_enchant(ENCH_NEUTRAL, 0, KC_YOU, + (16 + random2avg(13, 2)) * 10))) { return (0); } - simple_monster_message(mons, " seems impressed!"); + simple_monster_message(mon, " seems impressed!"); break; case 13: case 14: case 15: - if (!mons->add_ench(ENCH_FEAR)) + if (!mon->add_ench(ENCH_FEAR)) return (0); - simple_monster_message(mons, " turns to flee."); + simple_monster_message(mon, " turns to flee."); break; case 16: case 17: - if (!mons->add_ench(mon_enchant(ENCH_PARALYSIS, 0, KC_YOU, - (16 + random2avg(13, 2)) * 10))) + if (!mon->add_ench(mon_enchant(ENCH_PARALYSIS, 0, KC_YOU, + (16 + random2avg(13, 2)) * 10))) { return (0); } - simple_monster_message(mons, " freezes in fright!"); + simple_monster_message(mon, " freezes in fright!"); break; default: if (holiness == MH_HOLY) - good_god_holy_attitude_change(mons); + good_god_holy_attitude_change(mon); else { if (holiness == MH_UNDEAD || holiness == MH_DEMONIC) { - if (!mons->add_ench(mon_enchant(ENCH_NEUTRAL, 0, KC_YOU, - (16 + random2avg(13, 2)) * 10))) + if (!mon->add_ench(mon_enchant(ENCH_NEUTRAL, 0, KC_YOU, + (16 + random2avg(13, 2)) * 10))) { return (0); } - simple_monster_message(mons, " seems impressed!"); + simple_monster_message(mon, " seems impressed!"); } else { - simple_monster_message(mons, " seems fully impressed!"); - mons_pacify(mons); + simple_monster_message(mon, " seems fully impressed!"); + mons_pacify(mon); } } break; diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index ffca8c92c9..82de3a69f9 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -64,7 +64,7 @@ int holy_word_player(int pow, int caster, actor *attacker) { - if (!player_is_unholy()) + if (!you.is_unholy()) return (0); int hploss; @@ -126,7 +126,7 @@ int holy_word_monsters(coord_def where, int pow, int caster, if (monster == NULL) return (retval); - if (!monster->alive() || !mons_is_unholy(monster)) + if (!monster->alive() || !monster->is_unholy()) return (retval); int hploss; @@ -296,7 +296,7 @@ int torment_monsters(coord_def where, int pow, int caster, actor *attacker) if (monster == NULL) return (retval); - if (!monster->alive() || monster->res_negative_energy() == 3) + if (!monster->alive() || monster->res_torment()) return (retval); int hploss = std::max(0, monster->hit_points / 2 - 1); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index ee0d6cb880..058faf0cd2 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2147,14 +2147,6 @@ int melee_attack::fire_res_apply_cerebov_downgrade(int res) return (res); } -bool melee_attack::defender_is_unholy() -{ - if (defender->atype() == ACT_PLAYER) - return (player_is_unholy()); - else - return (mons_is_unholy(defender_as_monster())); -} - void melee_attack::drain_defender() { if (defender->atype() == ACT_MONSTER && one_chance_in(3)) @@ -2319,8 +2311,7 @@ void melee_attack::chaos_affects_defender() { const bool mon = defender->atype() == ACT_MONSTER; const bool immune = mon && mons_immune_magic(defender_as_monster()); - const bool is_natural = mon && mons_holiness(defender_as_monster()) - == MH_NATURAL; + const bool is_natural = mon && defender->holiness() == MH_NATURAL; const bool is_shifter = mon && mons_is_shapeshifter(defender_as_monster()); const bool can_clone = mon && !mons_is_holy(defender_as_monster()) && mons_clonable(defender_as_monster(), true); @@ -3074,7 +3065,7 @@ bool melee_attack::apply_damage_brand() break; case SPWPN_HOLY_WRATH: - if (defender_is_unholy()) + if (defender->is_unholy()) special_damage = 1 + (random2(damage_done * 15) / 10); if (special_damage && defender_visible) diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h index 98bbe75346..ee5441122d 100644 --- a/crawl-ref/source/fight.h +++ b/crawl-ref/source/fight.h @@ -186,7 +186,6 @@ private: int res, const char *verb); int fire_res_apply_cerebov_downgrade(int res); - bool defender_is_unholy(); void drain_defender(); void rot_defender(int amount, int immediate = 0); void check_defender_train_armour(); diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 000be243f2..b5393c488d 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -144,7 +144,7 @@ bool can_wield(item_def *weapon, bool say_reason, return (false); } - if (player_is_unholy() && is_holy_item(*weapon)) + if (you.is_unholy() && is_holy_item(*weapon)) { if (say_reason) { @@ -1720,9 +1720,7 @@ static bool _silver_damages_victim(bolt &beam, actor* victim, int &dmg, else shifter = transform_changed_physiology(); - mon_holy_type holiness = victim->holiness(); - - if (shifter || holiness == MH_UNDEAD || holiness == MH_DEMONIC) + if (shifter || victim->is_unholy()) { dmg *= 2; diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index ffb665f089..23c2861b13 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -2084,7 +2084,7 @@ bool check_weapon_shape( const item_def &item, bool quiet, bool check_id ) && ((item.base_type == OBJ_WEAPONS && is_blessed_blade(item)) || brand == SPWPN_HOLY_WRATH) - && player_is_unholy()) + && you.is_unholy()) { if (!quiet) mpr("This weapon will not allow you to wield it."); diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index f35228ec9e..860c464539 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -3066,7 +3066,7 @@ static void _give_monster_item(monsters *mon, int thing, mthing.link = NON_ITEM; unset_ident_flags(mthing, ISFLAG_IDENT_MASK); - if (mons_is_unholy(mon) + if (mon->is_unholy() && (is_blessed_blade(mthing) || get_weapon_brand(mthing) == SPWPN_HOLY_WRATH)) { diff --git a/crawl-ref/source/mon-info.cc b/crawl-ref/source/mon-info.cc index 07a0619bf8..eda429d0f8 100644 --- a/crawl-ref/source/mon-info.cc +++ b/crawl-ref/source/mon-info.cc @@ -154,31 +154,31 @@ static std::string _verbose_info(const monsters* m) if (mons_behaviour_perceptible(m)) { if (mons_is_petrified(m)) - return(" (petrified)"); + return (" (petrified)"); if (mons_is_paralysed(m)) - return(" (paralysed)"); + return (" (paralysed)"); if (mons_is_petrifying(m)) - return(" (petrifying)"); + return (" (petrifying)"); if (mons_is_confused(m)) - return(" (confused)"); + return (" (confused)"); if (mons_is_fleeing(m)) - return(" (fleeing)"); + return (" (fleeing)"); if (m->asleep()) { - if (mons_holiness(m) == MH_UNDEAD - || mons_holiness(m) == MH_NONLIVING - || mons_holiness(m) == MH_PLANT) + if (m->holiness() == MH_UNDEAD + || m->holiness() == MH_NONLIVING + || m->holiness() == MH_PLANT) { - return(" (dormant)"); + return (" (dormant)"); } else - return(" (sleeping)"); + return (" (sleeping)"); } if (mons_is_wandering(m) && !mons_is_batty(m) && !(m->attitude == ATT_STRICT_NEUTRAL)) { // Labeling strictly neutral monsters as fellow slimes is more important. - return(" (wandering)"); + return (" (wandering)"); } if (m->foe == MHITNOT && !mons_is_batty(m) && !mons_neutral(m) && !mons_friendly(m)) diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 9b92846644..6fc2450884 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -464,15 +464,12 @@ int mons_unusable_items(const monsters *mon) if (mons_is_holy(mon)) ret += _scan_mon_inv_items(mon, is_evil_item) > 0; - else if (mons_is_unholy(mon)) + else if (mon->is_unholy()) { ret += _scan_mon_inv_items(mon, is_holy_item) > 0; - if (mons_holiness(mon) == MH_UNDEAD - && _mons_has_undrinkable_potion(mon)) - { + if (mon->holiness() == MH_UNDEAD && _mons_has_undrinkable_potion(mon)) ret++; - } } return (ret); @@ -484,14 +481,6 @@ mon_holy_type mons_class_holiness(int mc) return (smc->holiness); } -mon_holy_type mons_holiness(const monsters *mon) -{ - if (testbits(mon->flags, MF_HONORARY_UNDEAD)) - return (MH_UNDEAD); - - return (mons_class_holiness(mon->type)); -} - bool mons_class_is_confusable(int mc) { ASSERT(smc); @@ -579,7 +568,7 @@ bool mons_is_native_in_branch(const monsters *monster, || monster->type == MONS_DEATH_COB); case BRANCH_CRYPT: - return (mons_holiness(monster) == MH_UNDEAD); + return (monster->holiness() == MH_UNDEAD); case BRANCH_TOMB: return (mons_genus(monster->type) == MONS_MUMMY); @@ -1249,7 +1238,7 @@ bool check_mons_resist_magic( const monsters *monster, int pow ) bool mons_is_holy(const monsters *mon) { - return (mons_holiness(mon) == MH_HOLY); + return (mon->holiness() == MH_HOLY); } bool mons_is_evil(const monsters *mon) @@ -1257,21 +1246,14 @@ bool mons_is_evil(const monsters *mon) return (mons_class_flag(mon->type, M_EVIL)); } -bool mons_is_unholy(const monsters *mon) -{ - const mon_holy_type holiness = mons_holiness(mon); - - return (holiness == MH_UNDEAD || holiness == MH_DEMONIC); -} - bool mons_is_evil_or_unholy(const monsters *mon) { - return (mons_is_evil(mon) || mons_is_unholy(mon)); + return (mons_is_evil(mon) || mon->is_unholy()); } bool mons_has_lifeforce(const monsters *mon) { - const mon_holy_type holiness = mons_holiness(mon); + const mon_holy_type holiness = mon->holiness(); return (holiness == MH_NATURAL || holiness == MH_PLANT); } @@ -2547,7 +2529,7 @@ bool mons_is_lurking(const monsters *m) bool mons_is_influenced_by_sanctuary(const monsters *m) { return (!mons_wont_attack(m) - && (mons_holiness(m) != MH_PLANT || mons_is_stationary(m))); + && (m->holiness() != MH_PLANT || mons_is_stationary(m))); } bool mons_is_fleeing_sanctuary(const monsters *m) @@ -3579,7 +3561,7 @@ bool monsters::can_drown() const || mons_genus(type) == MONS_MUMMY || mons_genus(type) == MONS_GHOUL || mons_genus(type) == MONS_VAMPIRE - || mons_holiness(this) == MH_DEMONIC); + || holiness() == MH_DEMONIC); } size_type monsters::body_size(size_part_type /* psize */, bool /* base */) const @@ -3911,7 +3893,7 @@ bool monsters::could_wield(const item_def &item, bool ignore_brand, return (false); // Demonic/undead monsters won't use holy weapons. - if (mons_is_unholy(this) && is_holy_item(item)) + if (is_unholy() && is_holy_item(item)) return (false); // Holy monsters and monsters that are gifts of good gods won't @@ -5836,7 +5818,17 @@ void monsters::heal(int amount, bool max_too) mon_holy_type monsters::holiness() const { - return (mons_holiness(this)); + if (testbits(flags, MF_HONORARY_UNDEAD)) + return (MH_UNDEAD); + + return (mons_class_holiness(type)); +} + +bool monsters::is_unholy() const +{ + const mon_holy_type holi = holiness(); + + return (holi == MH_UNDEAD || holi == MH_DEMONIC); } int monsters::res_fire() const @@ -5968,8 +5960,8 @@ int monsters::res_elec() const int monsters::res_asphyx() const { int res = get_mons_resists(this).asphyx; - const mon_holy_type holi = mons_holiness(this); - if (mons_is_unholy(this) + const mon_holy_type holi = holiness(); + if (is_unholy() || holi == MH_NONLIVING || holi == MH_PLANT) { @@ -6028,7 +6020,7 @@ int monsters::res_sticky_flame() const int monsters::res_rotting() const { int res = get_mons_resists(this).rotting; - if (mons_holiness(this) != MH_NATURAL) + if (holiness() != MH_NATURAL) res += 1; return (res); } @@ -6038,7 +6030,7 @@ int monsters::res_holy_energy(const actor *attacker) const if (mons_is_evil(this)) return (-1); - if (mons_is_unholy(this)) + if (is_unholy()) return (-2); if (is_good_god(god) @@ -6055,7 +6047,7 @@ int monsters::res_holy_energy(const actor *attacker) const int monsters::res_negative_energy() const { - if (mons_holiness(this) != MH_NATURAL + if (holiness() != MH_NATURAL || type == MONS_SHADOW_DRAGON) { return (3); @@ -6093,7 +6085,7 @@ int monsters::res_negative_energy() const int monsters::res_torment() const { - const mon_holy_type holy = mons_holiness(this); + const mon_holy_type holy = holiness(); if (holy == MH_UNDEAD || holy == MH_DEMONIC || holy == MH_NONLIVING) @@ -7504,7 +7496,7 @@ void monsters::apply_enchantment(const mon_enchant &me) break; case ENCH_INVIS: - if (!mons_class_flag( type, M_INVIS )) + if (!mons_class_flag(type, M_INVIS)) decay_enchantment(me); break; @@ -7514,8 +7506,8 @@ void monsters::apply_enchantment(const mon_enchant &me) if (env.cgrid(pos()) != EMPTY_CLOUD) break; - // Air elementals are a special case, as their - // submerging in air isn't up to choice. -- bwr + // Air elementals are a special case, as their submerging in air + // isn't up to choice. - bwr if (type == MONS_AIR_ELEMENTAL) { heal_monster( this, 1, one_chance_in(5) ); diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index e5bfa0f84d..cf373ded5a 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -580,7 +580,6 @@ int mons_unusable_items(const monsters *mon); * spells3 - spells4 * *********************************************************************** */ mon_holy_type mons_class_holiness(int mc); -mon_holy_type mons_holiness(const monsters *mon); bool mons_is_mimic( int mc ); bool mons_is_statue( int mc, bool allow_disintegrate = false ); @@ -787,7 +786,6 @@ bool mons_is_known_mimic(const monsters *m); bool mons_is_unknown_mimic(const monsters *m); bool mons_is_holy(const monsters *mon); bool mons_is_evil(const monsters *mon); -bool mons_is_unholy(const monsters *mon); bool mons_is_evil_or_unholy(const monsters *mon); bool mons_is_icy(int mc); bool mons_is_skeletal(int mc); diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index 30fac86595..944a79a9a6 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -282,6 +282,7 @@ public: int mons_species() const; mon_holy_type holiness() const; + bool is_unholy() const; int res_fire() const; int res_steam() const; int res_cold() const; diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 176338c4ad..8a147e1c25 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -66,7 +66,7 @@ #include "stash.h" #include "xom.h" -static bool _wounded_damaged(int wound_class); +static bool _wounded_damaged(monster_type mon_type); static bool _handle_special_ability(monsters *monster, bolt & beem); static bool _handle_pickup(monsters *monster); static void _handle_behaviour(monsters *monster); @@ -606,8 +606,8 @@ static bool _ely_protect_ally(monsters *monster) if (you.religion != GOD_ELYVILON) return (false); - if (mons_holiness(monster) != MH_NATURAL - && mons_holiness(monster) != MH_HOLY + if (monster->holiness() != MH_NATURAL + && monster->holiness() != MH_HOLY || !mons_friendly(monster) || !you.can_see(monster) // for simplicity || !one_chance_in(20)) @@ -1446,7 +1446,7 @@ int monster_die(monsters *monster, killer_type killer, const bool created_friendly = testbits(monster->flags, MF_CREATED_FRIENDLY); bool anon = (killer_index == ANON_FRIENDLY_MONSTER); - const mon_holy_type targ_holy = mons_holiness(monster); + const mon_holy_type targ_holy = monster->holiness(); switch (killer) { @@ -1465,13 +1465,13 @@ int monster_die(monsters *monster, killer_type killer, mprf(MSGCH_MONSTER_DAMAGE, MDAM_DEAD, "%s is %s!", monster->name(DESC_CAP_THE).c_str(), _wounded_damaged(monster->type) ? - "destroyed" : "killed"); + "destroyed" : "killed"); } else { mprf(MSGCH_MONSTER_DAMAGE, MDAM_DEAD, "You %s %s!", _wounded_damaged(monster->type) ? "destroy" : "kill", - monster->name(DESC_NOCAP_THE).c_str()); + monster->name(DESC_NOCAP_THE).c_str()); } if ((created_friendly || was_neutral) && gives_xp) @@ -1600,7 +1600,7 @@ int monster_die(monsters *monster, killer_type killer, } if (you.duration[DUR_DEATH_CHANNEL] - && mons_holiness(monster) == MH_NATURAL + && monster->holiness() == MH_NATURAL && mons_can_be_zombified(monster) && gives_xp) { @@ -1634,7 +1634,7 @@ int monster_die(monsters *monster, killer_type killer, { simple_monster_message(monster, _wounded_damaged(monster->type) ? - " is destroyed!" : " dies!", + " is destroyed!" : " dies!", MSGCH_MONSTER_DAMAGE, MDAM_DEAD); } @@ -1677,7 +1677,7 @@ int monster_die(monsters *monster, killer_type killer, } const mon_holy_type killer_holy = - anon ? MH_NATURAL : mons_holiness(killer_mon); + anon ? MH_NATURAL : killer_mon->holiness(); if (you.religion == GOD_SHINING_ONE || you.religion == GOD_YREDELEMNUL @@ -1833,7 +1833,7 @@ int monster_die(monsters *monster, killer_type killer, { simple_monster_message(monster, _wounded_damaged(monster->type) ? - " is destroyed!" : " dies!", + " is destroyed!" : " dies!", MSGCH_MONSTER_DAMAGE, MDAM_DEAD); } @@ -2117,7 +2117,7 @@ static bool _valid_morph(monsters *monster, monster_type new_mclass) } // Various inappropriate polymorph targets. - if (mons_class_holiness(new_mclass) != mons_holiness(monster) + if (mons_class_holiness(new_mclass) != monster->holiness() || mons_class_flag(new_mclass, M_UNIQUE) // no uniques || mons_class_flag(new_mclass, M_NO_EXP_GAIN) // not helpless || new_mclass == mons_species(monster->type) // must be different @@ -2545,40 +2545,42 @@ bool monster_blink(monsters *monster, bool quiet) bool mon_can_be_slimified(monsters *monster) { - return (mons_holiness(monster) == MH_UNDEAD - || mons_holiness(monster) == MH_NATURAL + const mon_holy_type holi = monster->holiness(); + + return (holi == MH_UNDEAD + || holi == MH_NATURAL && !mons_is_slime(monster)); } void slimify_monster(monsters *mon, bool hostile) { - if (mons_holiness(mon) == MH_UNDEAD) - monster_polymorph(mon, MONS_DEATH_OOZE); + if (mon->holiness() == MH_UNDEAD) + monster_polymorph(mon, MONS_DEATH_OOZE); + else + { + const int x = mon->hit_dice + (coinflip() ? 1 : -1) * random2(5); + + if (x < 3) + monster_polymorph(mon, MONS_OOZE); + else if (x >= 3 && x < 5) + monster_polymorph(mon, MONS_JELLY); + else if (x >= 5 && x < 7) + monster_polymorph(mon, MONS_BROWN_OOZE); + else if (x >= 7 && x <= 11) + { + if (coinflip()) + monster_polymorph(mon, MONS_SLIME_CREATURE); + else + monster_polymorph(mon, MONS_GIANT_AMOEBA); + } else { - const int x = mon->hit_dice + (coinflip() ? 1 : -1) * random2(5); - - if (x < 3) - monster_polymorph(mon, MONS_OOZE); - else if (x >= 3 && x < 5) - monster_polymorph(mon, MONS_JELLY); - else if (x >= 5 && x < 7) - monster_polymorph(mon, MONS_BROWN_OOZE); - else if (x >= 7 && x <= 11) - { - if (coinflip()) - monster_polymorph(mon, MONS_SLIME_CREATURE); - else - monster_polymorph(mon, MONS_GIANT_AMOEBA); - } + if (coinflip()) + monster_polymorph(mon, MONS_ACID_BLOB); else - { - if (coinflip()) - monster_polymorph(mon, MONS_ACID_BLOB); - else - monster_polymorph(mon, MONS_AZURE_JELLY); - } + monster_polymorph(mon, MONS_AZURE_JELLY); } + } if (!mons_eats_items(mon)) mon->add_ench(ENCH_EAT_ITEMS); @@ -2593,10 +2595,10 @@ void slimify_monster(monsters *mon, bool hostile) static void _set_random_target(monsters* mon) { - mon->target = random_in_bounds(); // If we don't find anything better + mon->target = random_in_bounds(); // If we don't find anything better. for (int tries = 0; tries < 150; ++tries) { - coord_def delta = coord_def(random2(13), random2(13)) - coord_def(6,6); + coord_def delta = coord_def(random2(13), random2(13)) - coord_def(6, 6); if (delta.origin()) continue; @@ -2948,10 +2950,10 @@ void print_wounds(const monsters *monster) // (true == 'damaged') [constructs, undead, etc.] // and (false == 'wounded') [living creatures, etc.] {dlb} -static bool _wounded_damaged(int monster_type) +static bool _wounded_damaged(monster_type mon_type) { // this schema needs to be abstracted into real categories {dlb}: - const mon_holy_type holy = mons_class_holiness(monster_type); + const mon_holy_type holy = mons_class_holiness(mon_type); if (holy == MH_UNDEAD || holy == MH_NONLIVING || holy == MH_PLANT) return (true); @@ -3125,8 +3127,8 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, } // Neither do plants or nonliving beings. - if (mons_class_holiness(mon->type) == MH_PLANT - || mons_class_holiness(mon->type) == MH_NONLIVING) + if (mon->holiness() == MH_PLANT + || mon->holiness() == MH_NONLIVING) { mon->del_ench(ENCH_FEAR, true, true); break; @@ -4656,8 +4658,8 @@ static void _handle_behaviour(monsters *mon) // things, plants, and nonliving monsters cannot flee. if (isHurt && !isSmart && isMobile && (!mons_is_zombified(mon) || mon->type == MONS_SPECTRAL_THING) - && mons_class_holiness(mon->type) != MH_PLANT - && mons_class_holiness(mon->type) != MH_NONLIVING) + && mon->holiness() != MH_PLANT + && mon->holiness() != MH_NONLIVING) { new_beh = BEH_FLEE; } @@ -4771,8 +4773,8 @@ static void _handle_behaviour(monsters *mon) case BEH_CORNERED: // Plants and nonliving monsters cannot fight back. - if (mons_class_holiness(mon->type) == MH_PLANT - || mons_class_holiness(mon->type) == MH_NONLIVING) + if (mon->holiness() == MH_PLANT + || mon->holiness() == MH_NONLIVING) { break; } diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index 1f47dc9cd2..a86faa226f 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -1222,9 +1222,9 @@ void setup_mons_cast(monsters *monster, bolt &pbolt, continue; hog_type = MONS_HOG; - if (mons_holiness(targ) == MH_DEMONIC) + if (targ->holiness() == MH_DEMONIC) hog_type = MONS_HELL_HOG; - else if (mons_holiness(targ) != MH_NATURAL) + else if (targ->holiness() != MH_NATURAL) continue; if (targ->type != hog_type diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index d5c6ccf3c6..299ae43219 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6323,7 +6323,7 @@ bool player::could_wield(const item_def &item, bool ignore_brand, if (!ignore_brand) { - if (player_is_unholy() && is_holy_item(item)) + if (is_unholy() && is_holy_item(item)) return (false); } @@ -6732,11 +6732,11 @@ mon_holy_type player::holiness() const return (MH_NATURAL); } -bool player_is_unholy() +bool player::is_unholy() const { - const mon_holy_type holiness = you.holiness(); + const mon_holy_type holi = holiness(); - return (holiness == MH_UNDEAD || holiness == MH_DEMONIC); + return (holi == MH_UNDEAD || holi == MH_DEMONIC); } // Output active level of player mutation. @@ -6810,7 +6810,7 @@ int player::res_holy_energy(const actor *attacker) const if (is_evil_god(you.religion)) return (-1); - if (player_is_unholy()) + if (is_unholy()) return (-2); if (is_good_god(you.religion)) diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index f9054e4ee8..873b5cd275 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -408,6 +408,7 @@ public: int mons_species() const; mon_holy_type holiness() const; + bool is_unholy() const; int res_fire() const; int res_steam() const; int res_cold() const; @@ -657,7 +658,6 @@ bool player_likes_chunks(bool permanently = false); bool player_can_swim(); bool player_likes_water(bool permanently = false); -bool player_is_unholy(); int player_mutation_level(mutation_type mut); /* *********************************************************************** diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 6b9d506afa..f19fe4203b 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1431,7 +1431,7 @@ static bool _is_yred_enslaved_body_and_soul(const monsters* mon) bool is_undead_slave(const monsters* mon) { - return (mon->alive() && mons_holiness(mon) == MH_UNDEAD + return (mon->alive() && mon->holiness() == MH_UNDEAD && mon->attitude == ATT_FRIENDLY); } @@ -6811,7 +6811,7 @@ bool player_can_join_god(god_type which_god) if (you.species == SP_DEMIGOD) return (false); - if (player_is_unholy() && is_good_god(which_god)) + if (you.is_unholy() && is_good_god(which_god)) return (false); // Feawn hates undead, but will accept demonspawn. diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 40fdc8bcf5..06225193b4 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -671,7 +671,7 @@ static bool _can_pacify_monster(const monsters *mon, const int healed) if (mons_intel(mon) <= I_PLANT) // no self-awareness return (false); - const mon_holy_type holiness = mons_holiness(mon); + const mon_holy_type holiness = mon->holiness(); if (holiness != MH_HOLY && holiness != MH_NATURAL diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index a1ea78180f..bc5ce39e56 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -680,7 +680,7 @@ void drain_life(int pow) monsters* monster = &menv[i]; if (!monster->alive() - || mons_holiness(monster) != MH_NATURAL + || monster->holiness() != MH_NATURAL || monster->res_negative_energy()) { continue; @@ -746,14 +746,14 @@ bool vampiric_drain(int pow, const dist &vmove) return (false); } - if (mons_is_unholy(monster)) + if (monster->is_unholy()) { mpr("Aaaarggghhhhh!"); dec_hp(random2avg(39, 2) + 10, false, "vampiric drain backlash"); return (false); } - if (mons_holiness(monster) != MH_NATURAL + if (monster->holiness() != MH_NATURAL || monster->res_negative_energy()) { canned_msg(MSG_NOTHING_HAPPENS); diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 094595ca72..15397a1f77 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -2131,11 +2131,8 @@ bool recall(char type_recalled) if (type_recalled == 1) // undead { - if (monster->type != MONS_REAPER - && mons_holiness(monster) != MH_UNDEAD) - { + if (monster->holiness() != MH_UNDEAD) continue; - } } else if (type_recalled == 2) // Beogh { diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 3d281652b2..160fee75b1 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -393,7 +393,7 @@ static int _sleep_monsters(coord_def where, int pow, int, actor *) if (monster == NULL) return (0); - if (mons_holiness(monster) != MH_NATURAL) + if (monster->holiness() != MH_NATURAL) return (0); if (check_mons_resist_magic(monster, pow)) return (0); @@ -1002,7 +1002,7 @@ static int _intoxicate_monsters(coord_def where, int pow, int, actor *) monsters *monster = monster_at(where); if (monster == NULL || mons_intel(monster) < I_NORMAL - || mons_holiness(monster) != MH_NATURAL + || monster->holiness() != MH_NATURAL || monster->res_poison() > 0) { return 0; diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index d1a75373fb..fd6b110c00 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1001,7 +1001,7 @@ static bool _vampire_cannot_cast(spell_type spell) static bool _spell_is_uncastable(spell_type spell) { - if (player_is_unholy() && spell_typematch(spell, SPTYP_HOLY)) + if (you.is_unholy() && spell_typematch(spell, SPTYP_HOLY)) { mpr("You can't use this type of magic!"); return (true); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 204803c98c..42b6254e90 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -932,7 +932,7 @@ int get_mons_colour(const monsters *mons) static void _good_god_follower_attitude_change(monsters *monster) { - if (player_is_unholy() || crawl_state.arena) + if (you.is_unholy() || crawl_state.arena) return; // For followers of good gods, decide whether holy beings will be @@ -1517,7 +1517,7 @@ bool check_awaken(monsters* monster) if (monster->asleep()) { - if (mons_holiness(monster) == MH_NATURAL) + if (monster->holiness() == MH_NATURAL) { // Monster is "hibernating"... reduce chance of waking. if (monster->has_ench(ENCH_SLEEP_WARY)) diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 7c77d0d76d..c73d266c37 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -1412,7 +1412,7 @@ static int _xom_polymorph_nearby_monster(bool helpful, bool debug = false) if (one_chance_in(8) && !mons_is_ghost_demon(mon->type) && !mons_is_shapeshifter(mon) - && mons_holiness(mon) == MH_NATURAL) + && mon->holiness() == MH_NATURAL) { mon->add_ench(one_chance_in(3) ? ENCH_GLOWING_SHAPESHIFTER : ENCH_SHAPESHIFTER); |