summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-18 00:34:22 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-18 00:34:22 +0000
commit6817824379462ee5a1aab8267eb437d2b543504e (patch)
treede5fdb811964e1ae9baa86f8d78f19dc99f26a28
parentb5890e8e1fde868016e260b98170e00c67947601 (diff)
downloadcrawl-ref-6817824379462ee5a1aab8267eb437d2b543504e.tar.gz
crawl-ref-6817824379462ee5a1aab8267eb437d2b543504e.zip
Consolidate checks for the player's being undead or a demonspawn into
player_is_unholy(), a la mons_is_unholy(), and use it where possible. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8522 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/beam.cc6
-rw-r--r--crawl-ref/source/effects.cc2
-rw-r--r--crawl-ref/source/item_use.cc3
-rw-r--r--crawl-ref/source/itemprop.cc2
-rw-r--r--crawl-ref/source/newgame.cc2
-rw-r--r--crawl-ref/source/ouch.cc3
-rw-r--r--crawl-ref/source/player.cc12
-rw-r--r--crawl-ref/source/player.h1
-rw-r--r--crawl-ref/source/religion.cc3
-rw-r--r--crawl-ref/source/spl-book.cc3
-rw-r--r--crawl-ref/source/spl-cast.cc3
-rw-r--r--crawl-ref/source/view.cc2
12 files changed, 20 insertions, 22 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index c8f0bc0143..938ab464f3 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2270,7 +2270,6 @@ int mons_adjust_flavoured(monsters *monster, bolt &pbolt, int hurted,
hurted == 0 ? " appears unharmed."
: " writhes in agony!");
}
-
break;
case BEAM_ICE:
@@ -3254,7 +3253,6 @@ bool bolt::harmless_to_player() const
case BEAM_INVISIBILITY:
return (true);
- // Cleansing flame doesn't affect player's followers.
case BEAM_HOLY:
return (is_good_god(you.religion));
@@ -4361,7 +4359,7 @@ void bolt::affect_monster(monsters* mon)
// Visual - wake monsters.
if (flavour == BEAM_VISUAL)
{
- behaviour_event( mon, ME_DISTURB, beam_source, source );
+ behaviour_event(mon, ME_DISTURB, beam_source, source);
apply_hit_funcs(mon, 0);
return;
}
@@ -4386,7 +4384,7 @@ void bolt::affect_monster(monsters* mon)
// before we decide if it actually hits.
std::vector<std::string> messages;
int preac, postac, final;
- if ( !determine_damage(mon, preac, postac, final, messages) )
+ if (!determine_damage(mon, preac, postac, final, messages))
return;
#if DEBUG_DIAGNOSTICS
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 6ae8982826..f39252cfde 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -63,7 +63,7 @@ REVISION("$Rev$");
int holy_word_player(int pow, int caster)
{
- if (!you.is_undead && you.species != SP_DEMONSPAWN)
+ if (!player_is_unholy())
return 0;
int hploss = std::max(0, you.hp / 2 - 1);
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index fe1a1c8bdf..6881c556d0 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -144,8 +144,7 @@ bool can_wield(item_def *weapon, bool say_reason,
return (false);
}
- if ((you.is_undead || you.species == SP_DEMONSPAWN)
- && is_holy_item(*weapon))
+ if (player_is_unholy() && is_holy_item(*weapon))
{
if (say_reason)
{
diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc
index f441b8e089..25ac97b10e 100644
--- a/crawl-ref/source/itemprop.cc
+++ b/crawl-ref/source/itemprop.cc
@@ -2023,7 +2023,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)
- && (you.is_undead || you.species == SP_DEMONSPAWN))
+ && player_is_unholy())
{
if (!quiet)
mpr( "This weapon will not allow you to wield it." );
diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc
index 21be9c68e4..2848e0d981 100644
--- a/crawl-ref/source/newgame.cc
+++ b/crawl-ref/source/newgame.cc
@@ -4434,7 +4434,7 @@ bool _give_items_skills()
you.piety = 45;
// Set gods.
- if (you.species == SP_MUMMY || you.species == SP_DEMONSPAWN
+ if (you.species == SP_DEMONSPAWN || you.species == SP_MUMMY
|| you.species == SP_GHOUL || you.species == SP_VAMPIRE)
{
you.religion = GOD_YREDELEMNUL;
diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc
index 35892d7e22..d746ef8bf9 100644
--- a/crawl-ref/source/ouch.cc
+++ b/crawl-ref/source/ouch.cc
@@ -220,14 +220,13 @@ int check_your_resists(int hurted, beam_type flavour)
case BEAM_HOLY:
if (is_good_god(you.religion))
hurted = 0;
- else if (you.is_undead || you.species == SP_DEMONSPAWN)
+ else if (player_is_unholy())
hurted = (hurted * 3) / 2;
else if (!is_evil_god(you.religion))
hurted /= 2;
if (hurted == 0)
canned_msg(MSG_YOU_RESIST);
-
break;
default:
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 1c181b0223..e567735c3a 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -6342,11 +6342,8 @@ bool player::could_wield(const item_def &item, bool ignore_brand,
if (!ignore_brand)
{
- if (is_holy_item(item)
- && (you.is_undead || you.species == SP_DEMONSPAWN))
- {
+ if (player_is_unholy() && is_holy_item(item))
return (false);
- }
}
#if 0
@@ -6764,6 +6761,13 @@ mon_holy_type player::holiness() const
return (MH_NATURAL);
}
+bool player_is_unholy()
+{
+ const mon_holy_type holiness = you.holiness();
+
+ return (holiness == MH_UNDEAD || holiness == MH_DEMONIC);
+}
+
// Output active level of player mutation.
// Might be lower than real mutation for non-"Alive" Vampires.
int player_mutation_level(mutation_type mut)
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index f038c70459..44131ffb91 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -177,6 +177,7 @@ bool player_can_smell();
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 c26aad6157..4616c13fad 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -6426,8 +6426,7 @@ void god_pitch(god_type which_god)
// return, or not allow worshippers from other religions. -- bwr
// Gods can be racist...
- const bool you_evil = (you.is_undead || you.species == SP_DEMONSPAWN);
- if (you_evil && is_good_god(which_god)
+ if (player_is_unholy() && is_good_god(which_god)
|| which_god == GOD_BEOGH && you.species != SP_HILL_ORC)
{
you.turn_is_over = false;
diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc
index 93e291ba93..616a0a0c86 100644
--- a/crawl-ref/source/spl-book.cc
+++ b/crawl-ref/source/spl-book.cc
@@ -1391,8 +1391,7 @@ bool learn_spell(int book)
return (false);
}
- if ((you.is_undead || you.species == SP_DEMONSPAWN)
- && spell_typematch(specspell, SPTYP_HOLY))
+ if (player_is_unholy() && spell_typematch(specspell, SPTYP_HOLY))
{
mpr("You can't use this type of magic!");
return (false);
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 992ad4817a..13ceb292d1 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -864,8 +864,7 @@ static bool _vampire_cannot_cast(spell_type spell)
static bool _spell_is_uncastable(spell_type spell)
{
- if ((you.is_undead || you.species == SP_DEMONSPAWN)
- && spell_typematch(spell, SPTYP_HOLY))
+ if (player_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 f3bbd3986e..15d9f32552 100644
--- a/crawl-ref/source/view.cc
+++ b/crawl-ref/source/view.cc
@@ -882,7 +882,7 @@ static bool _mons_was_seen_this_turn(const monsters *mons)
static void _good_god_follower_attitude_change(monsters *monster)
{
- if (you.is_undead || you.species == SP_DEMONSPAWN)
+ if (player_is_unholy())
return;
// For followers of good gods, decide whether holy beings will be