summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-26 10:08:26 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-01-26 10:08:26 +0000
commitfb7a3b56c6dde207c2fa6233d0738af8b20fac6d (patch)
tree211ded0a34bc6949cad45bf6cb2cd73b3daccc7b /crawl-ref
parent95b4d220b5abfe9a835832a8ebcda1a12951cb28 (diff)
downloadcrawl-ref-fb7a3b56c6dde207c2fa6233d0738af8b20fac6d.tar.gz
crawl-ref-fb7a3b56c6dde207c2fa6233d0738af8b20fac6d.zip
[1829946] Fixed broken beam tracers.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3341 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/mon-data.h3
-rw-r--r--crawl-ref/source/mon-util.cc15
-rw-r--r--crawl-ref/source/stuff.cc5
-rw-r--r--crawl-ref/source/stuff.h1
4 files changed, 17 insertions, 7 deletions
diff --git a/crawl-ref/source/mon-data.h b/crawl-ref/source/mon-data.h
index 4a44c871e8..5b1d63de84 100644
--- a/crawl-ref/source/mon-data.h
+++ b/crawl-ref/source/mon-data.h
@@ -1216,7 +1216,8 @@
{
MONS_ORC_SORCERER, 'o', DARKGREY, "orc sorcerer",
- M_SPELLCASTER | M_SEE_INVIS | M_SPEAKS | M_ACTUAL_SPELLS | M_WARM_BLOOD | M_EVIL,
+ M_SPELLCASTER | M_SEE_INVIS | M_SPEAKS | M_ACTUAL_SPELLS
+ | M_WARM_BLOOD | M_EVIL,
MR_RES_FIRE,
600, 12, MONS_ORC, MONS_ORC, MH_NATURAL, -3,
{ {AT_HIT, AF_PLAIN, 7}, AT_NO_ATK, AT_NO_ATK, AT_NO_ATK },
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index c34626ca91..40eb712310 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1863,6 +1863,12 @@ bool mons_looks_distracted(const monsters *m)
bool mons_should_fire(struct bolt &beam)
{
+#ifdef DEBUG_DIAGNOSTICS
+ mprf(MSGCH_DIAGNOSTICS,
+ "tracer: foes %d, friends %d, foe_ratio: %d, smart: %s",
+ beam.foe_count, beam.fr_count, beam.foe_ratio,
+ beam.smart_monster? "yes" : "no");
+#endif
// use of foeRatio:
// the higher this number, the more monsters
// will _avoid_ collateral damage to their friends.
@@ -1879,12 +1885,9 @@ bool mons_should_fire(struct bolt &beam)
return (true);
// only fire if they do acceptably low collateral damage
- // the default for this is 50%; in other words, don't
- // hit a foe unless you hit 2 or fewer friends.
- if (beam.foe_power >= (beam.foe_ratio * beam.fr_power) / 100)
- return (true);
-
- return (false);
+ return (beam.foe_power >=
+ div_round_up(beam.foe_ratio * (beam.foe_power + beam.fr_power),
+ 100));
}
// used to determine whether or not a monster should always
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 4e20392423..b1d8952fa9 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -643,6 +643,11 @@ int div_rand_round( int num, int den )
return (num / den + (random2(den) < num % den));
}
+int div_round_up( int num, int den )
+{
+ return (num / den + (num % den != 0));
+}
+
bool one_chance_in(int a_million)
{
return (random2(a_million) == 0);
diff --git a/crawl-ref/source/stuff.h b/crawl-ref/source/stuff.h
index de773bcd54..0ff8ba7d91 100644
--- a/crawl-ref/source/stuff.h
+++ b/crawl-ref/source/stuff.h
@@ -32,6 +32,7 @@ void pop_rng_state();
void cf_setseed();
bool coinflip();
int div_rand_round( int num, int den );
+int div_round_up( int num, int den );
bool one_chance_in(int a_million);
int random2(int randmax);
int random_range(int low, int high);