summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/effects.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-17 06:49:09 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-17 06:49:09 +0000
commit4f5084a7944889bd2095629ff0937b1ef39ccd2c (patch)
treeb46bbbb3184eb12fc15d9b201d28c136ff3b4330 /crawl-ref/source/effects.cc
parent24f899df4143cf27c98b218da786de393578e765 (diff)
downloadcrawl-ref-4f5084a7944889bd2095629ff0937b1ef39ccd2c.tar.gz
crawl-ref-4f5084a7944889bd2095629ff0937b1ef39ccd2c.zip
Simplify.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5915 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r--crawl-ref/source/effects.cc23
1 files changed, 5 insertions, 18 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 0deb563c7e..4cc4195aea 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -68,10 +68,7 @@ int holy_word_player(int pow, int caster)
if (!you.is_undead && you.species != SP_DEMONSPAWN)
return 0;
- int hploss = you.hp / 2 - 1;
-
- if (hploss < 0)
- hploss = 0;
+ int hploss = std::max(0, you.hp / 2 - 1);
if (!hploss)
return 0;
@@ -113,8 +110,7 @@ int holy_word_monsters(int x, int y, int pow, int caster)
int retval = 0;
// doubt this will ever happen, but it's here as a safety -- bwr
- if (pow > 300)
- pow = 300;
+ pow = std::min(300, pow);
// Is the player in this cell?
if (x == you.x_pos && y == you.y_pos)
@@ -135,10 +131,7 @@ int holy_word_monsters(int x, int y, int pow, int caster)
return retval;
}
- int hploss = roll_dice(2, 15) + (random2(pow) / 3);
-
- if (hploss < 0)
- hploss = 0;
+ int hploss = std::max(0, roll_dice(2, 15) + (random2(pow) / 3));
// Currently, holy word annoys the monsters it affects because it
// can kill them, and because hostile monsters don't use it.
@@ -189,10 +182,7 @@ int torment_player(int pow, int caster)
if (!player_res_torment())
{
// Negative energy resistance can alleviate torment.
- hploss = you.hp * (50 - player_prot_life() * 5) / 100 - 1;
-
- if (hploss < 0)
- hploss = 0;
+ hploss = std::max(0, you.hp * (50 - player_prot_life() * 5) / 100 - 1);
}
if (!hploss)
@@ -265,10 +255,7 @@ int torment_monsters(int x, int y, int pow, int caster)
if (invalid_monster(monster) || mons_res_negative_energy(monster) == 3)
return retval;
- int hploss = monster->hit_points / 2 - 1;
-
- if (hploss < 0)
- hploss = 0;
+ int hploss = std::max(0, monster->hit_points / 2 - 1);
// Currently, torment doesn't annoy the monsters it affects because
// it can't kill them, and because hostile monsters use it.