From 8a71b54ce2a022bdd79680e19f88d9c600a0fc4e Mon Sep 17 00:00:00 2001 From: Adam Borowski Date: Thu, 5 Nov 2009 15:24:46 +0100 Subject: Merge monsters,player::check_res_magic() (Zaba) --- crawl-ref/source/actor.cc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'crawl-ref/source/actor.cc') 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); +} -- cgit v1.2.3-54-g00ecf