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 +++++++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 43 deletions(-) (limited to 'crawl-ref/source/fight.cc') 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. -- cgit v1.2.3-54-g00ecf