diff options
-rw-r--r-- | crawl-ref/source/actor.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/attitude-change.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/beam.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/delay.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/fight.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/halo.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/mon-act.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/monplace.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/monster.cc | 41 | ||||
-rw-r--r-- | crawl-ref/source/monster.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/monstuff.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/player.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/player.h | 1 | ||||
-rw-r--r-- | crawl-ref/source/religion.cc | 6 | ||||
-rw-r--r-- | crawl-ref/source/spells1.cc | 10 | ||||
-rw-r--r-- | crawl-ref/source/spl-data.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/spl-util.h | 2 | ||||
-rw-r--r-- | crawl-ref/source/xom.cc | 2 |
20 files changed, 77 insertions, 42 deletions
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h index 6d98fb2245..009bfb237a 100644 --- a/crawl-ref/source/actor.h +++ b/crawl-ref/source/actor.h @@ -185,6 +185,7 @@ public: virtual int mons_species() const = 0; virtual mon_holy_type holiness() const = 0; + virtual bool is_holy() const = 0; virtual bool is_unholy() const = 0; virtual bool is_evil() const = 0; virtual bool is_chaotic() const = 0; diff --git a/crawl-ref/source/attitude-change.cc b/crawl-ref/source/attitude-change.cc index ffc3b6b612..1576c078eb 100644 --- a/crawl-ref/source/attitude-change.cc +++ b/crawl-ref/source/attitude-change.cc @@ -35,7 +35,7 @@ void good_god_follower_attitude_change(monsters *monster) // good neutral towards you. if (is_good_god(you.religion) && monster->foe == MHITYOU - && monster->holiness() == MH_HOLY + && monster->is_holy() && !testbits(monster->flags, MF_ATT_CHANGE_ATTEMPT) && !monster->wont_attack() && you.visible_to(monster) && !monster->asleep() @@ -148,7 +148,7 @@ static bool _holy_beings_on_level_attitude_change() { monsters *monster = &menv[i]; if (monster->alive() - && monster->holiness() == MH_HOLY) + && monster->is_holy()) { #ifdef DEBUG_DIAGNOSTICS mprf(MSGCH_DIAGNOSTICS, "Holy attitude changing: %s on level %d, branch %d", @@ -369,7 +369,7 @@ static bool _make_holy_god_gifts_on_level_good_neutral(bool seen = false) monsters *monster = &menv[i]; if (is_follower(monster) && !monster->has_ench(ENCH_CHARM) - && monster->holiness() == MH_HOLY + && monster->is_holy() && mons_is_god_gift(monster, god)) { // monster changes attitude @@ -785,7 +785,7 @@ static void _print_good_god_holy_being_speech(bool neutral, // the good gods, and be made worshippers of TSO if necessary. void good_god_holy_attitude_change(monsters *holy) { - ASSERT(holy->holiness() == MH_HOLY); + ASSERT(holy->is_holy()); if (you.can_see(holy)) // show reaction { @@ -813,7 +813,7 @@ void good_god_holy_attitude_change(monsters *holy) void good_god_holy_fail_attitude_change(monsters *holy) { - ASSERT(holy->holiness() == MH_HOLY); + ASSERT(holy->is_holy()); if (you.can_see(holy)) // show reaction { diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 1a6706447c..a27f985417 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -5856,7 +5856,7 @@ bool bolt::nasty_to(const monsters *mon) const // No charming holy beings! if (flavour == BEAM_CHARM) - return (mon->holiness() == MH_HOLY); + return (mon->is_holy()); // Friendly and good neutral monsters don't mind being teleported. if (flavour == BEAM_TELEPORT) diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index a891ea6f94..82776f0ac5 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -71,7 +71,7 @@ static bool _recite_mons_useless(const monsters *mon) const mon_holy_type holiness = mon->holiness(); return (mons_intel(mon) < I_NORMAL - || holiness != MH_HOLY + || !mon->is_holy() && holiness != MH_NATURAL && holiness != MH_UNDEAD && holiness != MH_DEMONIC @@ -103,7 +103,7 @@ static int _recite_to_monsters(coord_def where, int pow, int, actor *) int resist; const mon_holy_type holiness = mon->holiness(); - if (holiness == MH_HOLY) + if (mon->is_holy()) resist = std::max(0, 7 - random2(you.skills[SK_INVOCATIONS])); else { @@ -197,7 +197,7 @@ static int _recite_to_monsters(coord_def where, int pow, int, actor *) simple_monster_message(mon, " freezes in fright!"); break; default: - if (holiness == MH_HOLY) + if (mon->is_holy()) good_god_holy_attitude_change(mon); else { diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 5775f0ab6a..8b6dc76fd6 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2406,7 +2406,7 @@ void melee_attack::chaos_affects_defender() const bool immune = mon && mons_immune_magic(defender_as_monster()); const bool is_natural = mon && defender->holiness() == MH_NATURAL; const bool is_shifter = mon && defender_as_monster()->is_shapeshifter(); - const bool can_clone = mon && defender->holiness() == MH_HOLY + const bool can_clone = mon && defender->is_holy() && mons_clonable(defender_as_monster(), true); const bool can_poly = is_shifter || (defender->can_safely_mutate() && !immune); diff --git a/crawl-ref/source/halo.cc b/crawl-ref/source/halo.cc index f78b3e30bd..c177815552 100644 --- a/crawl-ref/source/halo.cc +++ b/crawl-ref/source/halo.cc @@ -32,7 +32,7 @@ int player::halo_radius() const int monsters::halo_radius() const { - if (holiness() == MH_HOLY) + if (is_holy()) return (2); else return (0); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 96081d555e..003be3ef61 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -3174,7 +3174,7 @@ bool stop_attack_prompt(const monsters *mon, bool beam_attack, const bool isFriendly = mon->friendly(); const bool isNeutral = mon->neutral(); const bool isUnchivalric = is_unchivalric_attack(&you, mon); - const bool isHoly = mon->holiness() == MH_HOLY + const bool isHoly = mon->is_holy() && (mon->attitude != ATT_HOSTILE || testbits(mon->flags, MF_CREATED_FRIENDLY) || testbits(mon->flags, MF_WAS_NEUTRAL)); diff --git a/crawl-ref/source/mon-act.cc b/crawl-ref/source/mon-act.cc index dd0036c2f4..d61a798eb8 100644 --- a/crawl-ref/source/mon-act.cc +++ b/crawl-ref/source/mon-act.cc @@ -290,7 +290,7 @@ static bool _mon_on_interesting_grid(monsters *mon) // else fall through case DNGN_ALTAR_ZIN: case DNGN_ALTAR_SHINING_ONE: - return (mon->holiness() == MH_HOLY); + return (mon->is_holy()); // Orcs will tend to patrol around altars to Beogh, and guard the // stairway from and to the Orcish Mines. diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 6c36113b11..f421cc6b7e 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -425,7 +425,7 @@ int mons_unusable_items(const monsters *mon) { int ret = 0; - if (mon->holiness() == MH_HOLY) + if (mon->is_holy()) ret += _scan_mon_inv_items(mon, is_evil_item) > 0; else if (mon->is_unholy()) { diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index f12e78df77..1bc990438a 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -2590,7 +2590,7 @@ bool player_will_anger_monster(monsters *mon, bool *holy, const bool isHoly = (is_good_god(you.religion) && mon->is_evil()); const bool isUnholy = - (is_evil_god(you.religion) && mon->holiness() == MH_HOLY); + (is_evil_god(you.religion) && mon->is_holy()); const bool isLawful = (you.religion == GOD_ZIN && mon->is_chaotic()); const bool isAntimagical = diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc index 6610a457a8..ae496d54b3 100644 --- a/crawl-ref/source/monster.cc +++ b/crawl-ref/source/monster.cc @@ -638,13 +638,12 @@ bool monsters::could_wield(const item_def &item, bool ignore_brand, // Holy monsters and monsters that are gifts of good gods won't // use evil weapons. - if ((holiness() == MH_HOLY || is_good_god(god)) && is_evil_item(item)) + if ((is_holy() || is_good_god(god)) && is_evil_item(item)) return (false); // Holy monsters that aren't gifts of chaotic gods and monsters // that are gifts of good gods won't use chaotic weapons. - if (((holiness() == MH_HOLY && !is_chaotic_god(god)) - || is_good_god(god)) + if (((is_holy() && !is_chaotic_god(god)) || is_good_god(god)) && is_chaotic_item(item)) { return (false); @@ -1691,7 +1690,7 @@ bool monsters::pickup_wand(item_def &item, int near) // Holy monsters and worshippers of good gods won't pick up evil // wands. - if ((holiness() == MH_HOLY || is_good_god(god)) && is_evil_item(item)) + if ((is_holy() || is_good_god(god)) && is_evil_item(item)) return (false); // If a monster already has a charged wand, don't bother. @@ -1719,7 +1718,7 @@ bool monsters::pickup_scroll(item_def &item, int near) // Holy monsters and worshippers of good gods won't pick up evil // scrolls. - if ((holiness() == MH_HOLY || is_good_god(god)) && is_evil_item(item)) + if ((is_holy() || is_good_god(god)) && is_evil_item(item)) return (false); return (pickup(item, MSLOT_SCROLL, near)); @@ -1731,7 +1730,7 @@ bool monsters::pickup_potion(item_def &item, int near) // them. const potion_type ptype = static_cast<potion_type>(item.sub_type); - if (!this->can_drink_potion(ptype)) + if (!can_drink_potion(ptype)) return (false); return (pickup(item, MSLOT_POTION, near)); @@ -1750,7 +1749,7 @@ bool monsters::pickup_misc(item_def &item, int near) // Holy monsters and worshippers of good gods won't pick up evil // miscellaneous items. - if ((holiness() == MH_HOLY || is_good_god(god)) && is_evil_item(item)) + if ((is_holy() || is_good_god(god)) && is_evil_item(item)) return (false); return (pickup(item, MSLOT_MISCELLANY, near)); @@ -2746,6 +2745,15 @@ bool monsters::has_spell(spell_type spell) const return (false); } +bool monsters::has_holy_spell() const +{ + for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) + if (is_holy_spell(spells[i])) + return (true); + + return (false); +} + bool monsters::has_evil_spell() const { for (int i = 0; i < NUM_MONSTER_SPELL_SLOTS; ++i) @@ -2944,6 +2952,21 @@ mon_holy_type monsters::holiness() const return (mons_class_holiness(type)); } +bool monsters::is_holy() const +{ + if (holiness() == MH_HOLY) + return (true); + + // Assume that all unknown gods (GOD_NAMELESS) are not holy. + if (is_priest() && is_good_god(god)) + return (true); + + if (has_holy_spell()) + return (true); + + return (false); +} + bool monsters::is_unholy() const { const mon_holy_type holi = holiness(); @@ -3219,8 +3242,8 @@ int monsters::res_holy_energy(const actor *attacker) const if (is_unholy()) return (-2); - if (is_good_god(god) - || holiness() == MH_HOLY + if (is_holy() + || is_good_god(god) || neutral() || is_unchivalric_attack(attacker, this) || is_good_god(you.religion) && is_follower(this)) diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h index a10c3ef2b2..8ff03b76dd 100644 --- a/crawl-ref/source/monster.h +++ b/crawl-ref/source/monster.h @@ -297,6 +297,7 @@ public: int mons_species() const; mon_holy_type holiness() const; + bool is_holy() const; bool is_unholy() const; bool is_evil() const; bool is_chaotic() const; @@ -347,6 +348,7 @@ public: bool has_spells() const; bool has_spell(spell_type spell) const; + bool has_holy_spell() const; bool has_evil_spell() const; bool has_chaotic_spell() const; diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index a36b349a03..5f82495a9d 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -652,8 +652,8 @@ static bool _ely_protect_ally(monsters *monster) if (you.religion != GOD_ELYVILON) return (false); - if (monster->holiness() != MH_NATURAL - && monster->holiness() != MH_HOLY + if (!monster->is_holy() + && monster->holiness() != MH_NATURAL || !monster->friendly() || !you.can_see(monster) // for simplicity || !one_chance_in(20)) @@ -1666,7 +1666,7 @@ int monster_die(monsters *monster, killer_type killer, } // Holy kills are always noticed. - if (targ_holy == MH_HOLY) + if (monster->is_holy()) { did_god_conduct(DID_KILL_HOLY, monster->hit_dice, true, monster); @@ -1873,7 +1873,7 @@ int monster_die(monsters *monster, killer_type killer, } // Holy kills are always noticed. - if (targ_holy == MH_HOLY) + if (monster->is_holy()) { if (killer_holy == MH_UNDEAD) { @@ -3942,7 +3942,7 @@ std::string summoned_poof_msg(const monsters* monster, bool plural) msg = "degenerate%s into a cloud of primal chaos"; } - if (monster->holiness() == MH_HOLY + if (monster->is_holy() && summon_type != SPELL_SHADOW_CREATURES && summon_type != MON_SUMM_CHAOS) { diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 4340a1c6ab..e48b4a5422 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -6364,6 +6364,14 @@ mon_holy_type player::holiness() const return (MH_NATURAL); } +bool player::is_holy() const +{ + if (is_good_god(religion)) + return (true); + + return (false); +} + bool player::is_unholy() const { const mon_holy_type holi = holiness(); @@ -6482,7 +6490,7 @@ int player::res_holy_energy(const actor *attacker) const if (is_unholy()) return (-2); - if (is_good_god(religion) || holiness() == MH_HOLY) + if (is_holy()) return (1); return (0); diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index f8d1e43f95..881e8f4f18 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -439,6 +439,7 @@ public: int mons_species() const; mon_holy_type holiness() const; + bool is_holy() const; bool is_unholy() const; bool is_evil() const; bool is_chaotic() const; diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 590a1ce345..605e13f8ec 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1666,7 +1666,7 @@ static int _tso_blessing_extend_stay(monsters* mon) // [ds] Disabling permanence for balance reasons, but extending // duration increase. These numbers are tenths of a player turn. // Holy monsters get a much bigger boost than random beasties. - const int base_increase = mon->holiness() == MH_HOLY ? 1100 : 500; + const int base_increase = mon->is_holy() ? 1100 : 500; const int increase = base_increase + random2(base_increase); return _increase_ench_duration(mon, abj, increase); } @@ -3545,7 +3545,7 @@ void set_attack_conducts(god_conduct_trigger conduct[3], const monsters *mon, _first_attack_was_unchivalric[midx] = true; } - if (mon->holiness() == MH_HOLY) + if (mon->is_holy()) conduct[2].set(DID_ATTACK_HOLY, mon->hit_dice, known, mon); _first_attack_conduct[midx] = false; @@ -5432,7 +5432,7 @@ bool tso_unchivalric_attack_safe_monster(const monsters *mon) const mon_holy_type holiness = mon->holiness(); return (mons_intel(mon) < I_NORMAL || mon->is_evil() - || holiness != MH_NATURAL && holiness != MH_HOLY); + || !mon->is_holy() && holiness != MH_NATURAL); } int get_tension(god_type god, bool count_travelling) diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index b3222f3817..2768394649 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -706,10 +706,10 @@ static bool _can_pacify_monster(const monsters *mon, const int healed) const mon_holy_type holiness = mon->holiness(); - if (holiness != MH_HOLY - && holiness != MH_NATURAL + if (!mon->is_holy() && holiness != MH_UNDEAD - && holiness != MH_DEMONIC) + && holiness != MH_DEMONIC + && holiness != MH_NATURAL) { return (false); } @@ -726,7 +726,7 @@ static bool _can_pacify_monster(const monsters *mon, const int healed) int divisor = 3; - if (holiness == MH_HOLY) + if (mon->is_holy()) divisor--; else if (holiness == MH_UNDEAD) divisor++; @@ -818,7 +818,7 @@ static int _healing_spell(int healed, bool divine_ability, { did_something = true; - const bool is_holy = monster->holiness() == MH_HOLY; + const bool is_holy = monster->is_holy(); const bool is_summoned = monster->is_summoned(); int pgain = 0; diff --git a/crawl-ref/source/spl-data.h b/crawl-ref/source/spl-data.h index 8a3dcb0623..444909f323 100644 --- a/crawl-ref/source/spl-data.h +++ b/crawl-ref/source/spl-data.h @@ -2005,7 +2005,7 @@ { SPELL_MINOR_HEALING, "Minor Healing", - SPTYP_HOLY, + SPTYP_ENCHANTMENT, // was SPTYP_HOLY SPFLAG_RECOVERY | SPFLAG_HELPFUL | SPFLAG_MONSTER, 2, 0, @@ -2018,7 +2018,7 @@ { SPELL_MAJOR_HEALING, "Major Healing", - SPTYP_HOLY, + SPTYP_ENCHANTMENT, // was SPTYP_HOLY SPFLAG_RECOVERY | SPFLAG_HELPFUL | SPFLAG_MONSTER, 6, 0, diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h index e3feea06ed..9715d52eee 100644 --- a/crawl-ref/source/spl-util.h +++ b/crawl-ref/source/spl-util.h @@ -25,7 +25,7 @@ enum spschool_flag_type SPTYP_POISON = 1<<9, SPTYP_EARTH = 1<<10, SPTYP_AIR = 1<<11, - SPTYP_HOLY = 1<<12, //jmf: moved to accomodate "random" miscast f/x + SPTYP_HOLY = 1<<12, //jmf: moved to accommodate "random" miscast f/x SPTYP_LAST_EXPONENT = 12, //jmf: ``NUM_SPELL_TYPES'' kinda useless NUM_SPELL_TYPES = 14, SPTYP_RANDOM = 1<<14 diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 5eb31d082b..b648367698 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -953,7 +953,7 @@ static bool _choose_chaos_upgrade(const monsters* mon) // Holy beings are presumably protected by another god, unless // they're gifts from a chaotic god. - if (mon->holiness() == MH_HOLY && !is_chaotic_god(mon->god)) + if (mon->is_holy() && !is_chaotic_god(mon->god)) return (false); // God gifts from good gods will be protected by their god from |