summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/actor.cc
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 /crawl-ref/source/actor.cc
parent329209bca2c5cf2b32fe7cffc12ced1151200043 (diff)
downloadcrawl-ref-8a71b54ce2a022bdd79680e19f88d9c600a0fc4e.tar.gz
crawl-ref-8a71b54ce2a022bdd79680e19f88d9c600a0fc4e.zip
Merge monsters,player::check_res_magic() (Zaba)
Diffstat (limited to 'crawl-ref/source/actor.cc')
-rw-r--r--crawl-ref/source/actor.cc36
1 files changed, 36 insertions, 0 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);
+}