summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-20 17:09:17 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-20 17:09:17 +0000
commit71c0a31487f367fd8918fca553a0c65a92ec1171 (patch)
tree507d20843a6391e4a5664a2a6f771490bd67a73f /crawl-ref
parentea22861efb7bebe60b63c1755801fb835e514945 (diff)
downloadcrawl-ref-71c0a31487f367fd8918fca553a0c65a92ec1171.tar.gz
crawl-ref-71c0a31487f367fd8918fca553a0c65a92ec1171.zip
Add various attitude- and alignment-related fixes.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5156 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/beam.cc24
-rw-r--r--crawl-ref/source/enum.h4
-rw-r--r--crawl-ref/source/mon-util.cc21
-rw-r--r--crawl-ref/source/mon-util.h2
-rw-r--r--crawl-ref/source/output.cc4
5 files changed, 38 insertions, 17 deletions
diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc
index c82d72a934..362f161646 100644
--- a/crawl-ref/source/beam.cc
+++ b/crawl-ref/source/beam.cc
@@ -2314,8 +2314,11 @@ void fire_tracer(const monsters *monster, bolt &pbolt)
// foe ratio for summoning gtr. demons & undead -- they may be
// summoned, but they're hostile and would love nothing better
// than to nuke the player and his minions
- if (pbolt.attitude == ATT_FRIENDLY && monster->attitude != ATT_FRIENDLY)
+ if (mons_att_wont_attack(pbolt.attitude)
+ && !mons_att_wont_attack(monster->attitude))
+ {
pbolt.foe_ratio = 25;
+ }
// fire!
fire_beam(pbolt);
@@ -3096,7 +3099,7 @@ static int _affect_player( bolt &beam, item_def *item )
// check can see player
if (beam.can_see_invis || !you.invisible() || _fuzz_invis_tracer(beam))
{
- if (beam.attitude != ATT_HOSTILE)
+ if (mons_att_wont_attack(beam.attitude))
{
beam.fr_count += 1;
beam.fr_power += you.experience_level;
@@ -3326,8 +3329,11 @@ static int _affect_player( bolt &beam, item_def *item )
// An enemy helping you escape while in the Abyss, or an
// enemy stabilizing a teleport that was about to happen.
- if (beam.attitude == ATT_HOSTILE && you.level_type == LEVEL_ABYSS)
+ if (!mons_att_wont_attack(beam.attitude)
+ && you.level_type == LEVEL_ABYSS)
+ {
xom_is_stimulated(255);
+ }
beam.obvious_effect = true;
break;
@@ -3418,7 +3424,7 @@ static int _affect_player( bolt &beam, item_def *item )
if (nasty)
{
- if (beam.attitude != ATT_HOSTILE)
+ if (mons_att_wont_attack(beam.attitude))
{
beam.fr_hurt++;
if (beam.beam_source == NON_MONSTER)
@@ -3434,7 +3440,7 @@ static int _affect_player( bolt &beam, item_def *item )
if (nice)
{
- if (beam.attitude != ATT_HOSTILE)
+ if (mons_att_wont_attack(beam.attitude))
beam.fr_helped++;
else
{
@@ -3593,7 +3599,7 @@ static int _affect_player( bolt &beam, item_def *item )
if (hurted > 0 || old_hp < you.hp || was_affected)
{
- if (beam.attitude != ATT_HOSTILE)
+ if (mons_att_wont_attack(beam.attitude))
{
beam.fr_hurt++;
@@ -3644,7 +3650,7 @@ static int _name_to_skill_level(const std::string& name)
static void _update_hurt_or_helped(bolt &beam, monsters *mon)
{
- if (beam.attitude != mons_attitude(mon))
+ if (mons_atts_aligned(beam.attitude, mons_attitude(mon)))
{
if (nasty_beam(mon, beam))
beam.foe_hurt++;
@@ -3731,7 +3737,7 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item)
if (beam.is_tracer)
{
// enchant case -- enchantments always hit, so update target immed.
- if (beam.attitude != mons_attitude(mon))
+ if (mons_atts_aligned(beam.attitude, mons_attitude(mon)))
{
beam.foe_count += 1;
beam.foe_power += mons_power(mons_type);
@@ -3905,7 +3911,7 @@ static int _affect_monster(bolt &beam, monsters *mon, item_def *item)
// fireball at another fire giant, and it only took
// 1/3 damage, then power of 5 would be applied to
// foe_power or fr_power.
- if (beam.attitude != mons_attitude(mon))
+ if (mons_atts_aligned(beam.attitude, mons_attitude(mon)))
{
beam.foe_count += 1;
beam.foe_power += 2 * hurt_final * mons_power(mons_type) / hurt;
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index c77ab2098b..67d0957a2c 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1876,9 +1876,9 @@ enum beh_type
enum mon_attitude_type
{
ATT_HOSTILE, // 0, default in most cases
- ATT_FRIENDLY, // created friendly (or tamed?)
ATT_NEUTRAL, // neutral
- ATT_GOOD_NEUTRAL // neutral, but won't attack friendlies
+ ATT_GOOD_NEUTRAL, // neutral, but won't attack friendlies
+ ATT_FRIENDLY // created friendly (or tamed?)
};
enum mon_flight_type
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index dfa3108c93..1b8d97a49b 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1883,7 +1883,7 @@ int mons_power(int mc)
bool mons_aligned(int m1, int m2)
{
mon_attitude_type fr1, fr2;
- struct monsters *mon1, *mon2;
+ monsters *mon1, *mon2;
if (m1 == MHITNOT || m2 == MHITNOT)
return (true);
@@ -1904,6 +1904,11 @@ bool mons_aligned(int m1, int m2)
fr2 = mons_attitude(mon2);
}
+ return (mons_atts_aligned(fr1, fr2));
+}
+
+bool mons_atts_aligned(mon_attitude_type fr1, mon_attitude_type fr2)
+{
if (fr1 == ATT_GOOD_NEUTRAL)
fr1 = ATT_FRIENDLY;
@@ -1974,9 +1979,21 @@ bool mons_wont_attack(const monsters *m)
return (mons_friendly(m) || mons_good_neutral(m));
}
+bool mons_att_wont_attack(mon_attitude_type fr)
+{
+ return (fr == ATT_FRIENDLY || fr == ATT_GOOD_NEUTRAL);
+}
+
mon_attitude_type mons_attitude(const monsters *m)
{
- return (m->has_ench(ENCH_CHARM)? ATT_FRIENDLY : m->attitude);
+ if (mons_friendly(m))
+ return ATT_FRIENDLY;
+ else if (mons_good_neutral(m))
+ return ATT_GOOD_NEUTRAL;
+ else if (mons_neutral(m))
+ return ATT_NEUTRAL;
+ else
+ return ATT_HOSTILE;
}
bool mons_is_submerged(const monsters *mon)
diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h
index 2a75ff66c6..cedb1f7df6 100644
--- a/crawl-ref/source/mon-util.h
+++ b/crawl-ref/source/mon-util.h
@@ -618,6 +618,7 @@ const char *mons_pronoun(monster_type mon_type, pronoun_type variant);
* called from: monstuff
* *********************************************************************** */
bool mons_aligned(int m1, int m2);
+bool mons_atts_aligned(mon_attitude_type fr1, mon_attitude_type fr2);
// last updated 14mar2001 (gdl)
/* ***********************************************************************
@@ -627,6 +628,7 @@ bool mons_friendly(const monsters *m);
bool mons_neutral(const monsters *m);
bool mons_good_neutral(const monsters *m);
bool mons_wont_attack(const monsters *m);
+bool mons_att_wont_attack(mon_attitude_type fr);
mon_attitude_type mons_attitude(const monsters *m);
bool mons_behaviour_perceptible(const monsters *mon);
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 7b4d3b9082..3322539fd8 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -1025,10 +1025,6 @@ class monster_pane_info
monster_pane_info(const monsters* m)
: m_mon(m)
{
- // XXX: this doesn't take into account ENCH_NEUTRAL, but that's probably
- // a bug for mons_attitude, not this.
- // XXX: also, mons_attitude_type should be sorted hostile/neutral/friendly;
- // will break saves a little bit though.
m_attitude = mons_attitude(m);
// Currently, difficulty is defined as "average hp". Leaks too