summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAdam Borowski <kilobyte@angband.pl>2009-11-05 15:24:46 +0100
committerAdam Borowski <kilobyte@angband.pl>2009-11-05 15:24:46 +0100
commit8a71b54ce2a022bdd79680e19f88d9c600a0fc4e (patch)
tree659e82ce2a598331ffc14fb7e07a054dae11ce04
parent329209bca2c5cf2b32fe7cffc12ced1151200043 (diff)
downloadcrawl-ref-8a71b54ce2a022bdd79680e19f88d9c600a0fc4e.tar.gz
crawl-ref-8a71b54ce2a022bdd79680e19f88d9c600a0fc4e.zip
Merge monsters,player::check_res_magic() (Zaba)
-rw-r--r--crawl-ref/source/actor.cc36
-rw-r--r--crawl-ref/source/actor.h2
-rw-r--r--crawl-ref/source/monster.cc35
-rw-r--r--crawl-ref/source/monster.h1
-rw-r--r--crawl-ref/source/player.cc22
-rw-r--r--crawl-ref/source/player.h1
6 files changed, 37 insertions, 60 deletions
diff --git a/crawl-ref/source/actor.cc b/crawl-ref/source/actor.cc
index 657542d0f5..97aa4f928d 100644
--- a/crawl-ref/source/actor.cc
+++ b/crawl-ref/source/actor.cc
@@ -3,7 +3,9 @@
#include "actor.h"
#include "env.h"
#include "player.h"
+#include "random.h"
#include "state.h"
+#include "stuff.h"
#include "traps.h"
actor::~actor()
@@ -73,3 +75,37 @@ bool actor::handle_trap()
trap->trigger(*this);
return (trap != NULL);
}
+
+bool actor::check_res_magic(int power)
+{
+ int mrs = this->res_magic();
+
+ if (mrs == MAG_IMMUNE)
+ return (true);
+
+ // Evil, evil hack to make weak one hd monsters easier for first level
+ // characters who have resistable 1st level spells. Six is a very special
+ // value because mrs = hd * 2 * 3 for most monsters, and the weak, low
+ // level monsters have been adjusted so that the "3" is typically a 1.
+ // There are some notable one hd monsters that shouldn't fall under this,
+ // so we do < 6, instead of <= 6... or checking monster->hit_dice. The
+ // goal here is to make the first level easier for these classes and give
+ // them a better shot at getting to level two or three and spells that can
+ // help them out (or building a level or two of their base skill so they
+ // aren't resisted as often). -- bwr
+ if (this->atype() == ACT_MONSTER && mrs < 6 && coinflip())
+ return (false);
+
+ power = stepdown_value(power, 30, 40, 100, 120);
+
+ const int mrchance = (100 + mrs) - power;
+ const int mrch2 = random2(100) + random2(101);
+
+#if DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS,
+ "Power: %d, MR: %d, target: %d, roll: %d",
+ power, mrs, mrchance, mrch2);
+#endif
+
+ return (mrch2 < mrchance);
+}
diff --git a/crawl-ref/source/actor.h b/crawl-ref/source/actor.h
index 2f46aff6aa..50750abee6 100644
--- a/crawl-ref/source/actor.h
+++ b/crawl-ref/source/actor.h
@@ -181,7 +181,7 @@ public:
virtual int res_negative_energy() const = 0;
virtual int res_torment() const = 0;
virtual int res_magic() const = 0;
- virtual bool check_res_magic(int power) = 0;
+ virtual bool check_res_magic(int power);
virtual flight_type flight_mode() const = 0;
virtual bool is_levitating() const = 0;
diff --git a/crawl-ref/source/monster.cc b/crawl-ref/source/monster.cc
index 705e689ce8..300c44a4ae 100644
--- a/crawl-ref/source/monster.cc
+++ b/crawl-ref/source/monster.cc
@@ -3191,41 +3191,6 @@ int monsters::res_magic() const
return (u);
}
-bool monsters::check_res_magic(int pow)
-{
- int mrs = this->res_magic();
-
- if (mrs == MAG_IMMUNE)
- return (true);
-
- // Evil, evil hack to make weak one hd monsters easier for first
- // level characters who have resistable 1st level spells. Six is
- // a very special value because mrs = hd * 2 * 3 for most monsters,
- // and the weak, low level monsters have been adjusted so that the
- // "3" is typically a 1. There are some notable one hd monsters
- // that shouldn't fall under this, so we do < 6, instead of <= 6...
- // or checking monster->hit_dice. The goal here is to make the
- // first level easier for these classes and give them a better
- // shot at getting to level two or three and spells that can help
- // them out (or building a level or two of their base skill so they
- // aren't resisted as often). -- bwr
- if (mrs < 6 && coinflip())
- return (false);
-
- pow = stepdown_value( pow, 30, 40, 100, 120 );
-
- const int mrchance = (100 + mrs) - pow;
- const int mrch2 = random2(100) + random2(101);
-
-#if DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS,
- "Power: %d, monster's MR: %d, target: %d, roll: %d",
- pow, mrs, mrchance, mrch2 );
-#endif
-
- return (mrch2 < mrchance);
-}
-
flight_type monsters::flight_mode() const
{
return (mons_flies(this));
diff --git a/crawl-ref/source/monster.h b/crawl-ref/source/monster.h
index 0528163fe4..cba8bce535 100644
--- a/crawl-ref/source/monster.h
+++ b/crawl-ref/source/monster.h
@@ -308,7 +308,6 @@ public:
int res_torment() const;
int res_acid() const;
int res_magic() const;
- bool check_res_magic(int power);
flight_type flight_mode() const;
bool is_levitating() const;
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 1d84ae7496..e1bcf50a2d 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -6725,28 +6725,6 @@ int player::res_magic() const
return (rm);
}
-bool player::check_res_magic(int power)
-{
- int ench_power = stepdown_value( power, 30, 40, 100, 120 );
-
- int mrchance = 100 + this->res_magic();
-
- mrchance -= ench_power;
-
- int mrch2 = random2(100) + random2(101);
-
-#if DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS,
- "Power: %d, player's MR: %d, target: %d, roll: %d",
- ench_power, this->res_magic(), mrchance, mrch2);
-#endif
-
- if (mrch2 < mrchance)
- return (true); // ie saved successfully
-
- return (false);
-}
-
bool player::confusable() const
{
return (player_mental_clarity() == 0);
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index c8a095d727..ed6f44d491 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -425,7 +425,6 @@ public:
int res_negative_energy() const;
int res_torment() const;
int res_magic() const;
- bool check_res_magic(int power);
bool confusable() const;
bool slowable() const;