summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-17 18:27:26 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-17 18:27:26 +0000
commit51a3d79045ff49839e884b92c78e9a0cc01ed33f (patch)
treeaf8d3307b82ed70baf3d19b609f6c186254161ee /crawl-ref/source
parent18a94062a4fdde6994e4c4ad1598e38d79c24ee4 (diff)
downloadcrawl-ref-51a3d79045ff49839e884b92c78e9a0cc01ed33f.tar.gz
crawl-ref-51a3d79045ff49839e884b92c78e9a0cc01ed33f.zip
Clean up the unchivalric attack routine a bit.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5101 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source')
-rw-r--r--crawl-ref/source/fight.cc63
-rw-r--r--crawl-ref/source/fight.h2
2 files changed, 31 insertions, 34 deletions
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 01e01795e8..3e4350ee6e 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -289,45 +289,42 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
{
unchivalric_attack_type unchivalric = UCAT_NO_ATTACK;
- // distracted (but not batty)
- if (def->foe != MHITYOU && !testbits(def->flags, MF_BATTY))
- unchivalric = UCAT_DISTRACTED;
-
- // confused (but not perma-confused)
- if (def->has_ench(ENCH_CONFUSION)
- && !mons_class_flag(def->type, M_CONFUSED))
+ // no unchivalric attacks on dead or abjured monsters, monsters that
+ // cannot fight (e.g. plants), or invisible monsters
+ if (defender->alive() && !defender->cannot_fight()
+ && player_monster_visible(def))
{
- unchivalric = UCAT_CONFUSED;
- }
+ // distracted (but not batty)
+ if (def->foe != MHITYOU && !testbits(def->flags, MF_BATTY))
+ unchivalric = UCAT_DISTRACTED;
- // fleeing
- if (def->behaviour == BEH_FLEE)
- unchivalric = UCAT_FLEEING;
-
- // invisible
- if (attacker->invisible() && !defender->can_see_invisible())
- unchivalric = UCAT_INVISIBLE;
+ // confused (but not perma-confused)
+ if (def->has_ench(ENCH_CONFUSION)
+ && !mons_class_flag(def->type, M_CONFUSED))
+ {
+ unchivalric = UCAT_CONFUSED;
+ }
- // held in a net
- if (def->has_ench(ENCH_HELD))
- unchivalric = UCAT_NET_HELD;
+ // fleeing
+ if (def->behaviour == BEH_FLEE)
+ unchivalric = UCAT_FLEEING;
- // paralysed
- if (def->has_ench(ENCH_PARALYSIS))
- unchivalric = UCAT_PARALYSED;
+ // invisible
+ if (attacker->invisible() && !defender->can_see_invisible())
+ unchivalric = UCAT_INVISIBLE;
- // sleeping
- if (def->behaviour == BEH_SLEEP)
- unchivalric = UCAT_SLEEPING;
+ // held in a net
+ if (def->has_ench(ENCH_HELD))
+ unchivalric = UCAT_HELD_IN_NET;
- // no unchivalric attacks on monsters that cannot fight
- // (plants, etc.)
- if (defender->cannot_fight())
- unchivalric = UCAT_NO_ATTACK;
+ // paralysed
+ if (def->has_ench(ENCH_PARALYSIS))
+ unchivalric = UCAT_PARALYSED;
- // no unchivalric attacks on invisible monsters
- if (!player_monster_visible(def))
- unchivalric = UCAT_NO_ATTACK;
+ // sleeping
+ if (def->behaviour == BEH_SLEEP)
+ unchivalric = UCAT_SLEEPING;
+ }
return unchivalric;
}
@@ -2856,7 +2853,7 @@ void melee_attack::player_stab_check()
stab_bonus = 2;
break;
- case UCAT_NET_HELD:
+ case UCAT_HELD_IN_NET:
case UCAT_PARALYSED:
stab_attempt = true;
stab_bonus = 1;
diff --git a/crawl-ref/source/fight.h b/crawl-ref/source/fight.h
index 83d79d2efd..02d01c618c 100644
--- a/crawl-ref/source/fight.h
+++ b/crawl-ref/source/fight.h
@@ -35,7 +35,7 @@ enum unchivalric_attack_type
UCAT_CONFUSED,
UCAT_FLEEING,
UCAT_INVISIBLE,
- UCAT_NET_HELD,
+ UCAT_HELD_IN_NET,
UCAT_PARALYSED,
UCAT_SLEEPING
};