Attached Files |
badattack_fixes_g997c442.patch [^] (3,438 bytes) 2014-02-18 04:57 [Show Content] [Hide Content]From 1b373ae48987fdaf834cd64b097b8d6b24320561 Mon Sep 17 00:00:00 2001
From: gammafunk <gammafunk@gmail.com>
Date: Mon, 17 Feb 2014 21:36:59 -0600
Subject: [PATCH] Fix to attack penance warnings.
Currently if you melee an "object" (according to mons_is_object()) such as a
conjured ball lightning, you get a penance warning if worshiping TSO. This is a
"bad attack" and should give a prompt, but will not cause penance. This commit
fixes this by making the necessary call to god_hates_attacking_friend() to
determine if penance would occur. This also fixes the case when you attack
allies/followers under beogh, which currently doesn't give a penance warning
(although it does give a bad attack warning).
This commit also cleans up is_unchivalric_attack() so that attacking an object
is not reported as unchivalric and attacking a friend that your god doesn't hate
for you attack isn't reported as UCAT_ALLY. These seem to both be
technicalities at this point, but they should avoid some confusion if conducts
change or new gods appear.
---
crawl-ref/source/fight.cc | 12 +++++++-----
crawl-ref/source/misc.cc | 13 ++++---------
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 4733243..4300208 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -417,10 +417,11 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
const monster* def = defender->as_monster();
unchivalric_attack_type unchivalric = UCAT_NO_ATTACK;
- // No unchivalric attacks on monsters that cannot fight (e.g.
- // plants) or monsters the attacker can't see (either due to
- // invisibility or being behind opaque clouds).
- if (defender->cannot_fight() || (attacker && !attacker->can_see(defender)))
+ // No unchivalric attacks on monsters that cannot fight (e.g. plants) or
+ // monsters that are objects or monsters the attacker can't see (either due
+ // to invisibility or being behind opaque clouds).
+ if (defender->cannot_fight() || mons_is_object(def->mons_species()) ||
+ (attacker && !attacker->can_see(defender)))
return unchivalric;
// Distracted (but not batty); this only applies to players.
@@ -435,7 +436,8 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
unchivalric = UCAT_CONFUSED;
// allies
- if (def && def->friendly())
+ if (def && def->friendly() && attacker->is_player()
+ && god_hates_attacking_friend(you.religion, defender))
unchivalric = UCAT_ALLY;
// fleeing
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index f3fa7c6..550cede 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2246,18 +2246,13 @@ bool bad_attack(const monster *mon, string& adj, string& suffix,
monster_info mi(mon, MILEV_NAME);
if (!mi.is(MB_NAME_UNQUALIFIED))
adj += "the ";
-
- would_cause_penance = true;
}
else
- {
adj = "your ";
- if (is_good_god(you.religion)
- || you_worship(GOD_FEDHAS) && fedhas_protects(mon))
- {
- would_cause_penance = true;
- }
- }
+
+ if (god_hates_attacking_friend(you.religion, mon))
+ would_cause_penance = true;
+
return true;
}
--
1.8.3.2
|