From 4f5084a7944889bd2095629ff0937b1ef39ccd2c Mon Sep 17 00:00:00 2001 From: dolorous Date: Tue, 17 Jun 2008 06:49:09 +0000 Subject: Simplify. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5915 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/effects.cc | 23 +++++------------------ 1 file 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. -- cgit v1.2.3-54-g00ecf