summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/fight.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-21 11:47:59 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-21 11:47:59 +0000
commit101ce9277219b6925dc9e7c70692984c6544c5cd (patch)
treef6995b47d38f62eaf261c332b812acd7e227dee2 /crawl-ref/source/fight.cc
parentd04f647d2a64423af89b497c4daab8b452e7bf1c (diff)
downloadcrawl-ref-101ce9277219b6925dc9e7c70692984c6544c5cd.tar.gz
crawl-ref-101ce9277219b6925dc9e7c70692984c6544c5cd.zip
Added wizmode command to simulate monster vs player combat (&^F).
Apply 4.1ish monster to-hit calculations. M_FIGHTER monsters get bonus to-hit. Split melee and beam to-hit calculations again. Melee to-hit is now largely 4.1ish, but uses randomised player evasion. Applied 4.1 unique rebalancing. Higher level uniques now hit harder and have more hp. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1074 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/fight.cc')
-rw-r--r--crawl-ref/source/fight.cc44
1 files changed, 42 insertions, 2 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index ac77cda8d7..14257e3861 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -99,6 +99,44 @@ static void mons_lose_attack_energy(monsters *attacker, int wpn_speed,
**************************************************
*/
+bool test_melee_hit(int to_hit, int ev)
+{
+ int roll = -1;
+ int margin = AUTOMATIC_HIT;
+
+ ev *= 2;
+
+ if (to_hit >= AUTOMATIC_HIT)
+ return (true);
+ else if (random2(1000) < 10 * MIN_HIT_MISS_PERCENTAGE)
+ margin = (coinflip() ? 1 : -1) * AUTOMATIC_HIT;
+ else
+ {
+ roll = random2( to_hit + 1 );
+ margin = (roll - random2avg(ev, 2));
+ }
+
+#if DEBUG_DIAGNOSTICS
+ float miss;
+
+ if (to_hit < ev)
+ miss = 100.0 - static_cast<float>( MIN_HIT_MISS_PERCENTAGE ) / 2.0;
+ else
+ {
+ miss = static_cast<float>( MIN_HIT_MISS_PERCENTAGE ) / 2.0
+ + static_cast<float>( (100 - MIN_HIT_MISS_PERCENTAGE) * ev )
+ / static_cast<float>( to_hit );
+ }
+
+ mprf( MSGCH_DIAGNOSTICS,
+ "to hit: %d; ev: %d; miss: %0.2f%%; roll: %d; result: %s%s (%d)",
+ to_hit, ev, miss, roll, (margin >= 0) ? "hit" : "miss",
+ (roll == -1) ? "!!!" : "", margin );
+#endif
+
+ return (margin >= 0);
+}
+
// This function returns the "extra" stats the player gets because of
// choice of weapon... it's used only for giving warnings when a player
// weilds a less than ideal weapon.
@@ -2875,7 +2913,8 @@ void melee_attack::mons_perform_attack_rounds()
if (!shield_blocked)
{
const int defender_evasion = defender->melee_evasion(attacker);
- if (attacker == defender || test_hit(to_hit, defender_evasion))
+ if (attacker == defender
+ || test_melee_hit(to_hit, defender_evasion))
{
this_round_hit = did_hit = true;
perceived_attack = true;
@@ -2974,7 +3013,8 @@ bool melee_attack::mons_attack_you()
int melee_attack::mons_to_hit()
{
- int mhit = 16 + atk->hit_dice;
+ const int hd_mult = mons_class_flag(atk->type, M_FIGHTER)? 25 : 15;
+ int mhit = 18 + atk->hit_dice * hd_mult / 10;
if (water_attack)
mhit += 5;