From 8e74fc3cd96c84d0945e00e64889677ebdf347ee Mon Sep 17 00:00:00 2001 From: Jared Tinney (Twinge) Date: Thu, 25 Feb 2010 19:39:00 -0800 Subject: [PATCH] Animate Dead message tweak (nubinia) "The dead are walking, swimming and flying!" --- crawl-ref/source/abl-show.cc | 6 ++- crawl-ref/source/contrib/sdl-image | 2 +- crawl-ref/source/contrib/sqlite | 2 +- crawl-ref/source/fight.cc | 3 +- crawl-ref/source/mon-stuff.cc | 3 +- crawl-ref/source/spells3.cc | 74 ++++++++++++++++++++++++++++++++---- crawl-ref/source/spells3.h | 10 ++++- crawl-ref/source/spl-cast.cc | 5 +- 8 files changed, 88 insertions(+), 17 deletions(-) diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index 767f634..360c2b6 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -1268,6 +1268,7 @@ static bool _do_ability(const ability_def& abil) dist abild; bolt beam; dist spd; + int motions = 0; // For Animate Skeleton message // Note: the costs will not be applied until after this switch // statement... it's assumed that only failures have returned! - bwr @@ -1628,7 +1629,8 @@ static bool _do_ability(const ability_def& abil) mpr("You attempt to give life to the dead..."); if (animate_remains(you.pos(), CORPSE_BODY, BEH_FRIENDLY, - MHITYOU, &you, "", GOD_YREDELEMNUL) < 0) + MHITYOU, &you, "", GOD_YREDELEMNUL, + 1, 0, 0, 0, &motions) < 0) { mpr("There are no remains here to animate!"); } @@ -1641,7 +1643,7 @@ static bool _do_ability(const ability_def& abil) break; case ABIL_YRED_ANIMATE_DEAD: - mpr("You call on the dead to walk for you..."); + mpr("You call on the dead to rise..."); animate_dead(&you, 1 + you.skills[SK_INVOCATIONS], BEH_FRIENDLY, MHITYOU, &you, "", GOD_YREDELEMNUL); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 0b85c8c..e6d9bf9 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -2834,9 +2834,10 @@ static bool _make_zombie(monsters* mon, int corpse_class, int corpse_index, mitm[idx].link = mitm[last_item].link; mitm[last_item].link = idx; + int motions = 0; // For Animate Skeleton message animate_remains(mon->pos(), CORPSE_BODY, mon->behaviour, mon->foe, 0, "a chaos effect", mon->god, - true, true, true, &zombie_index); + true, true, true, &zombie_index, &motions); } // No equipment to get, or couldn't get it for some reason. diff --git a/crawl-ref/source/mon-stuff.cc b/crawl-ref/source/mon-stuff.cc index 56f0e26..5084ea1 100644 --- a/crawl-ref/source/mon-stuff.cc +++ b/crawl-ref/source/mon-stuff.cc @@ -3709,8 +3709,9 @@ bool mons_reaped(actor *killer, monsters *victim) } int midx = NON_MONSTER; + int motions = 0; // For Animate Skeleton message if (animate_remains(victim->pos(), CORPSE_BODY, beh, hitting, killer, "", - GOD_NO_GOD, true, true, true, &midx) <= 0) + GOD_NO_GOD, true, true, true, &midx, &motions) <= 0) { return (false); } diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 718b310..a34a937 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -35,6 +35,7 @@ #include "itemprop.h" #include "items.h" #include "item_use.h" +#include "libutil.h" #include "message.h" #include "misc.h" #include "mon-behv.h" @@ -935,10 +936,40 @@ void equip_undead(const coord_def &a, int corps, int monster, int monnum) } } +//Displays message when raising dead with Animate Skeleton or Animate Dead +void _display_undead_motions(int* motions) +{ + std::vector motions_list; + + //Check bitfield from _raise_remains for types of corpse(s) being animated + if (motions) + { + if (*motions & DEAD_ARE_WALKING) + motions_list.push_back("walking"); + if (*motions & DEAD_ARE_HOPPING) + motions_list.push_back("hopping"); + if (*motions & DEAD_ARE_FLOATING) + motions_list.push_back("floating"); + if (*motions & DEAD_ARE_SWIMMING) + motions_list.push_back("swimming"); + if (*motions & DEAD_ARE_FLYING) + motions_list.push_back("flying"); + if (*motions & DEAD_ARE_SLITHERING) + motions_list.push_back("slithering"); + + //Prevents the message from getting too long and spammy + if (motions_list.size() > 3) + mpr("The dead have arisen!"); + else + mpr("The dead are " + comma_separated_line(motions_list.begin(), + motions_list.end()) + "!"); + } +} + static bool _raise_remains(const coord_def &pos, int corps, beh_type beha, unsigned short hitting, actor *as, std::string nas, god_type god, bool actual, bool force_beh, - int* mon_index) + int* mon_index, int* motions) { if (mon_index != NULL) *mon_index = -1; @@ -1012,17 +1043,41 @@ static bool _raise_remains(const coord_def &pos, int corps, beh_type beha, if (!force_beh) player_angers_monster(&menv[monster]); + //Bitfield for motions - determines text displayed when animating dead + if (motions) + { + if (mons_class_primary_habitat(zombie_type) == HT_WATER + || mons_class_primary_habitat(zombie_type) == HT_LAVA) + *motions |= DEAD_ARE_SWIMMING; + else if (mons_class_flies(zombie_type) == FL_FLY) + *motions |= DEAD_ARE_FLYING; + else if (mons_class_flies(zombie_type) == FL_LEVITATE) + *motions |= DEAD_ARE_FLOATING; + else if (mons_genus(zombie_type) == MONS_SNAKE + || mons_genus(zombie_type) == MONS_NAGA + || mons_genus(zombie_type) == MONS_GUARDIAN_SERPENT + || mons_genus(zombie_type) == MONS_GIANT_SLUG + || mons_genus(zombie_type) == MONS_WORM) + *motions |= DEAD_ARE_SLITHERING; + else if (mons_genus(zombie_type) == MONS_GIANT_FROG + || mons_genus(zombie_type) == MONS_BLINK_FROG) + *motions |= DEAD_ARE_HOPPING; + else + *motions |= DEAD_ARE_WALKING; + } + return (true); } // Note that quiet will *not* suppress the message about a corpse // you are butchering being animated. +// This is called for Animate Skeleton and from animate_dead. int animate_remains(const coord_def &a, corpse_type class_allowed, beh_type beha, unsigned short hitting, actor *as, std::string nas, god_type god, bool actual, bool quiet, bool force_beh, - int* mon_index) + int* mon_index, int* motions) { if (is_sanctuary(a)) return (0); @@ -1045,7 +1100,10 @@ int animate_remains(const coord_def &a, corpse_type class_allowed, const bool was_butchering = is_being_butchered(*si); success = _raise_remains(a, si.link(), beha, hitting, as, nas, - god, actual, force_beh, mon_index); + god, actual, force_beh, mon_index, + motions); + + if (actual && success) { @@ -1058,7 +1116,7 @@ int animate_remains(const coord_def &a, corpse_type class_allowed, } if (!quiet && you.see_cell(a)) - mpr("The dead are walking!"); + _display_undead_motions(motions); if (was_butchering) xom_is_stimulated(255); @@ -1084,16 +1142,16 @@ int animate_dead(actor *caster, int pow, beh_type beha, unsigned short hitting, int number_raised = 0; int number_seen = 0; + int motions = 0; radius_iterator ri(caster->pos(), 6, C_SQUARE, &caster->get_los_no_trans()); for (; ri; ++ri) { - // This will produce a message if the corpse you are butchering - // is raised. + // Produces a message if the corpse you are butchering is raised. if (animate_remains(*ri, CORPSE_BODY, beha, hitting, as, nas, god, - actual, true) > 0) + actual, true, 0, 0, &motions) > 0) { number_raised++; if (you.see_cell(*ri)) @@ -1102,7 +1160,7 @@ int animate_dead(actor *caster, int pow, beh_type beha, unsigned short hitting, } if (actual && number_seen > 0) - mpr("The dead are walking!"); + _display_undead_motions(&motions); return (number_raised); } diff --git a/crawl-ref/source/spells3.h b/crawl-ref/source/spells3.h index 3025296..d95d65a 100644 --- a/crawl-ref/source/spells3.h +++ b/crawl-ref/source/spells3.h @@ -8,6 +8,14 @@ #ifndef SPELLS3_H #define SPELLS3_H +//Bitfield for animate dead messages +#define DEAD_ARE_WALKING 1 +#define DEAD_ARE_SWIMMING 2 +#define DEAD_ARE_FLYING 4 +#define DEAD_ARE_SLITHERING 8 +#define DEAD_ARE_HOPPING 16 +#define DEAD_ARE_FLOATING 32 + #include "itemprop-enum.h" class dist; @@ -51,7 +59,7 @@ int animate_remains(const coord_def &a, corpse_type class_allowed, actor *as = NULL, std::string nas = "", god_type god = GOD_NO_GOD, bool actual = true, bool quiet = false, bool force_beh = false, - int* mon_index = NULL); + int* mon_index = NULL, int* motions = NULL); int animate_dead(actor *caster, int pow, beh_type beha, unsigned short hitting, actor *as = NULL, std::string nas = "", diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index c3762f7..b72a56e 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1005,6 +1005,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) ASSERT(!crawl_state.arena); const bool wiz_cast = (crawl_state.prev_cmd == CMD_WIZARD && !allow_fail); + int motions = 0; // For Animate Skeleton message dist spd; bolt beam; @@ -1610,14 +1611,14 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) mpr("You attempt to give life to the dead..."); if (animate_remains(you.pos(), CORPSE_SKELETON, BEH_FRIENDLY, - MHITYOU, &you, "", god) < 0) + MHITYOU, &you, "", god, 1, 0, 0, 0, &motions) < 0) { mpr("There is no skeleton here to animate!"); } break; case SPELL_ANIMATE_DEAD: - mpr("You call on the dead to walk for you..."); + mpr("You call on the dead to rise..."); animate_dead(&you, powc + 1, BEH_FRIENDLY, MHITYOU, &you, "", god); break; -- 1.6.5.1