summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/direct.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-21 21:23:21 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2007-03-21 21:23:21 +0000
commit109b00ddba65e56db1a90a374115df69070bca71 (patch)
tree0d22819524e8d7a5179e7ee280a4b16b16d6ded2 /crawl-ref/source/direct.cc
parent101ce9277219b6925dc9e7c70692984c6544c5cd (diff)
downloadcrawl-ref-109b00ddba65e56db1a90a374115df69070bca71.tar.gz
crawl-ref-109b00ddba65e56db1a90a374115df69070bca71.zip
Cleaned up monster enchantments. Instead of the old enum abuse (ENCH_ABJ_I, II,
etc.), enchantment is stored as a struct (ENCH_which, degree, whose_enchantment). This allows us to do such things as award experience for monsters poisoned by friends, or confused monsters bashing themselves or falling into lava (not implemented, but could be :-)). Doing monster_die() correctly is a little tricky for friendly-enchantment-deaths because the original monster may not be around to answer questions, so we fake the killer's stats for indirect friendly kills (which means that some gods may not award piety for minion-cast enchantments, f'r'instance). I think we can live with that for now. Breaks save file compatibility as usual. Clouds could also use similar treatment - poison clouds created by a friendly are not correctly tracked yet. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1075 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/direct.cc')
-rw-r--r--crawl-ref/source/direct.cc106
1 files changed, 51 insertions, 55 deletions
diff --git a/crawl-ref/source/direct.cc b/crawl-ref/source/direct.cc
index 299260289b..6cbc6a4120 100644
--- a/crawl-ref/source/direct.cc
+++ b/crawl-ref/source/direct.cc
@@ -1382,6 +1382,54 @@ std::string feature_description(int mx, int my)
return (desc);
}
+static void describe_mons_enchantment(const monsters &mons,
+ const mon_enchant &ench,
+ bool paralysed)
+{
+ // Suppress silly-looking combinations, even if they're
+ // internally valid.
+ if (paralysed && (ench.ench == ENCH_SLOW || ench.ench == ENCH_HASTE))
+ return;
+
+ strcpy(info, mons_pronoun(mons.type, PRONOUN_CAP));
+
+ switch (ench.ench)
+ {
+ case ENCH_POISON:
+ strcat(info, " is poisoned.");
+ break;
+ case ENCH_ROT:
+ strcat(info, " is rotting away."); //jmf: "covered in sores"?
+ break;
+ case ENCH_BACKLIGHT:
+ strcat(info, " is softly glowing.");
+ break;
+ case ENCH_SLOW:
+ strcat(info, " is moving slowly.");
+ break;
+ case ENCH_HASTE:
+ strcat(info, " is moving very quickly.");
+ break;
+ case ENCH_CONFUSION:
+ strcat(info, " appears to be bewildered and confused.");
+ break;
+ case ENCH_INVIS:
+ strcat(info, " is slightly transparent.");
+ break;
+ case ENCH_CHARM:
+ strcat(info, " is in your thrall.");
+ break;
+ case ENCH_STICKY_FLAME:
+ strcat(info, " is covered in liquid flames.");
+ break;
+ default:
+ info[0] = 0;
+ break;
+ } // end switch
+ if (info[0])
+ mpr(info);
+}
+
static void describe_cell(int mx, int my)
{
char str_pass[ ITEMNAME_SIZE ];
@@ -1484,62 +1532,10 @@ static void describe_cell(int mx, int my)
if (paralysed)
mprf("%s is paralysed.", mons_pronoun(menv[i].type, PRONOUN_CAP));
- for (int p = 0; p < NUM_MON_ENCHANTS; p++)
+ for (mon_enchant_list::const_iterator e = menv[i].enchantments.begin();
+ e != menv[i].enchantments.end(); ++e)
{
- const unsigned ench = menv[i].enchantment[p];
-
- // Suppress silly-looking combinations, even if they're
- // internally valid.
- if (paralysed && (ench == ENCH_SLOW || ench == ENCH_HASTE))
- continue;
-
- strcpy(info, mons_pronoun(menv[i].type, PRONOUN_CAP));
-
- switch (ench)
- {
- case ENCH_YOUR_ROT_I:
- case ENCH_YOUR_ROT_II:
- case ENCH_YOUR_ROT_III:
- case ENCH_YOUR_ROT_IV:
- strcat(info, " is rotting away."); //jmf: "covered in sores"?
- break;
- case ENCH_BACKLIGHT_I:
- case ENCH_BACKLIGHT_II:
- case ENCH_BACKLIGHT_III:
- case ENCH_BACKLIGHT_IV:
- strcat(info, " is softly glowing.");
- break;
- case ENCH_SLOW:
- strcat(info, " is moving slowly.");
- break;
- case ENCH_HASTE:
- strcat(info, " is moving very quickly.");
- break;
- case ENCH_CONFUSION:
- strcat(info, " appears to be bewildered and confused.");
- break;
- case ENCH_INVIS:
- strcat(info, " is slightly transparent.");
- break;
- case ENCH_CHARM:
- strcat(info, " is in your thrall.");
- break;
- case ENCH_YOUR_STICKY_FLAME_I:
- case ENCH_YOUR_STICKY_FLAME_II:
- case ENCH_YOUR_STICKY_FLAME_III:
- case ENCH_YOUR_STICKY_FLAME_IV:
- case ENCH_STICKY_FLAME_I:
- case ENCH_STICKY_FLAME_II:
- case ENCH_STICKY_FLAME_III:
- case ENCH_STICKY_FLAME_IV:
- strcat(info, " is covered in liquid flames.");
- break;
- default:
- info[0] = 0;
- break;
- } // end switch
- if (info[0])
- mpr(info);
+ describe_mons_enchantment(menv[i], *e, paralysed);
}
#if DEBUG_DIAGNOSTICS