From bc30076f91a48a0e05a88317d2048f7bcafc06c7 Mon Sep 17 00:00:00 2001 From: haranp Date: Sun, 15 Feb 2009 09:00:16 +0000 Subject: Make paralysed creatures auto-stabbable and brand them appropriately. Petrified creatures are still only may-stabbable. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9085 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/fight.cc | 71 +++++++++++++++++--------------------------- crawl-ref/source/fight.h | 1 + crawl-ref/source/mon-util.cc | 22 +++++++------- 3 files changed, 39 insertions(+), 55 deletions(-) diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 317c7d2c72..417753447a 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -270,21 +270,22 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker, return (unchivalric); // Distracted (but not batty); this only applies to players. - if (attacker && attacker->atype() == ACT_PLAYER && def->foe != MHITYOU - && !mons_is_batty(def)) + if (attacker && attacker->atype() == ACT_PLAYER + && def && def->foe != MHITYOU && !mons_is_batty(def)) { unchivalric = UCAT_DISTRACTED; } // confused (but not perma-confused) - if (def->has_ench(ENCH_CONFUSION) + if (def + && def->has_ench(ENCH_CONFUSION) && !mons_class_flag(def->type, M_CONFUSED)) { unchivalric = UCAT_CONFUSED; } // fleeing - if (mons_is_fleeing(def)) + if (def && mons_is_fleeing(def)) unchivalric = UCAT_FLEEING; // invisible @@ -292,19 +293,23 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker, unchivalric = UCAT_INVISIBLE; // held in a net - if (mons_is_caught(def)) + if (def && mons_is_caught(def)) unchivalric = UCAT_HELD_IN_NET; // petrifying - if (mons_is_petrifying(def)) + if (def && mons_is_petrifying(def)) unchivalric = UCAT_PETRIFYING; + // petrified + if (def && mons_is_petrified(def)) + unchivalric = UCAT_PETRIFIED; + // paralysed - if (def->cannot_act()) + if (defender->paralysed()) unchivalric = UCAT_PARALYSED; // sleeping - if (mons_is_sleeping(def)) + if (defender->asleep()) unchivalric = UCAT_SLEEPING; return (unchivalric); @@ -3561,50 +3566,30 @@ int melee_attack::player_to_hit(bool random_factor) void melee_attack::player_stab_check() { - unchivalric_attack_type unchivalric = is_unchivalric_attack(&you, defender); + const unchivalric_attack_type uat = is_unchivalric_attack(&you, defender); + stab_attempt = (uat != UCAT_NO_ATTACK); + const bool roll_needed = (uat != UCAT_SLEEPING && uat != UCAT_PARALYSED); - bool roll_needed = true; int roll = 155; + if (uat == UCAT_INVISIBLE && !mons_sense_invis(defender_as_monster())) + roll -= 15; - // This ordering is important! - switch (unchivalric) + switch (uat) { - default: - case UCAT_NO_ATTACK: - stab_attempt = false; - stab_bonus = 0; - break; - - case UCAT_DISTRACTED: - stab_attempt = true; - stab_bonus = 3; - break; - - case UCAT_CONFUSED: - case UCAT_FLEEING: - stab_attempt = true; - stab_bonus = 2; - break; - - case UCAT_INVISIBLE: - stab_attempt = true; - stab_bonus = 2; - if (!mons_sense_invis(defender_as_monster())) - roll -= 15; - break; - + case UCAT_NO_ATTACK: stab_bonus = 0; break; case UCAT_HELD_IN_NET: case UCAT_PETRIFYING: + case UCAT_PETRIFIED: + case UCAT_SLEEPING: case UCAT_PARALYSED: - stab_attempt = true; - stab_bonus = 1; + stab_bonus = 1; break; - - case UCAT_SLEEPING: - stab_attempt = true; - roll_needed = false; - stab_bonus = 1; + case UCAT_INVISIBLE: + case UCAT_CONFUSED: + case UCAT_FLEEING: + stab_bonus = 2; break; + case UCAT_DISTRACTED: stab_bonus = 3; break; } // See if we need to roll against dexterity / stabbing. diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h index e4048e6f9f..0a1326b504 100644 --- a/crawl-ref/source/fight.h +++ b/crawl-ref/source/fight.h @@ -34,6 +34,7 @@ enum unchivalric_attack_type UCAT_INVISIBLE, UCAT_HELD_IN_NET, UCAT_PETRIFYING, + UCAT_PETRIFIED, UCAT_PARALYSED, UCAT_SLEEPING }; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 4f5ba1639f..ec1a0b88dd 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -2668,21 +2668,20 @@ bool mons_is_known_mimic(const monsters *m) bool mons_looks_stabbable(const monsters *m) { + const unchivalric_attack_type uat = is_unchivalric_attack(&you, m); return (mons_behaviour_perceptible(m) && !mons_friendly(m) - && mons_is_sleeping(m)); + && (uat == UCAT_PARALYSED || uat == UCAT_SLEEPING)); } bool mons_looks_distracted(const monsters *m) { + const unchivalric_attack_type uat = is_unchivalric_attack(&you, m); return (mons_behaviour_perceptible(m) && !mons_friendly(m) - && (m->foe != MHITYOU && !mons_is_batty(m) && !mons_neutral(m) - || mons_is_confused(m) - || mons_is_fleeing(m) - || mons_is_caught(m) - || mons_is_petrifying(m) - || mons_cannot_act(m))); + && uat != UCAT_NO_ATTACK + && uat != UCAT_PARALYSED + && uat != UCAT_SLEEPING); } void mons_pacify(monsters *mon) @@ -5845,11 +5844,10 @@ int monsters::res_holy_energy(const actor *attacker) const return (-2); if (is_good_god(god) - || mons_is_holy(this) - || mons_neutral(this) - || is_unchivalric_attack(attacker, this) - || is_good_god(you.religion) - && is_follower(this)) + || mons_is_holy(this) + || mons_neutral(this) + || is_unchivalric_attack(attacker, this) + || is_good_god(you.religion) && is_follower(this)) { return (1); } -- cgit v1.2.3-54-g00ecf