diff options
author | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-09 00:28:37 +0000 |
---|---|---|
committer | dolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-06-09 00:28:37 +0000 |
commit | d5950593f2e966032a81d4f150b24834c18a521b (patch) | |
tree | 8eb0aed3e97b4dd1b34a81487250c42cf96bb08b /crawl-ref/source/spells2.cc | |
parent | 297297da01e51a1ba70d3fde8c994ab9bb4f890c (diff) | |
download | crawl-ref-d5950593f2e966032a81d4f150b24834c18a521b.tar.gz crawl-ref-d5950593f2e966032a81d4f150b24834c18a521b.zip |
Clean up the routines to animate the dead.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5621 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells2.cc')
-rw-r--r-- | crawl-ref/source/spells2.cc | 345 |
1 files changed, 0 insertions, 345 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 6e991ea386..0c238f3a6a 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -58,15 +58,6 @@ #include "view.h" #include "xom.h" -static int raise_corpse( int corps, int corx, int cory, beh_type corps_beh, - int corps_hit, int actual ); - -static bool is_animatable_corpse(const item_def& item) -{ - return (item.base_type == OBJ_CORPSES && - mons_zombie_size(item.plus) != Z_NOZOMBIE); -} - unsigned char detect_traps( int pow ) { unsigned char traps_found = 0; @@ -317,342 +308,6 @@ int corpse_rot(int power) return 0; } // end corpse_rot() -int animate_dead( actor *caster, int power, beh_type corps_beh, - int corps_hit, int actual ) -{ - UNUSED( power ); - static env_show_grid losgrid; - - const coord_def c(caster->pos()); - int minx = c.x - 6; - int maxx = c.x + 7; - int miny = c.y - 6; - int maxy = c.y + 7; - int xinc = 1; - int yinc = 1; - - int number_raised = 0; - int number_seen = 0; - - if (coinflip()) - { - minx = c.x + 6; - maxx = c.x - 7; - xinc = -1; - } - - if (coinflip()) - { - miny = c.y + 6; - maxy = c.y - 7; - yinc = -1; - } - - if (caster != &you) - losight(losgrid, grd, c.x, c.y, true); - - env_show_grid &los(caster == &you? env.no_trans_show : losgrid); - - coord_def a; - bool was_butchered = false; - for (a.x = minx; a.x != maxx; a.x += xinc) - for (a.y = miny; a.y != maxy; a.y += yinc) - { - if (!in_bounds(a) || !see_grid(los, c, a)) - continue; - - if (igrd(a) != NON_ITEM) - { - int objl = igrd(a); - int hrg = 0; - - // This searches all the items on the ground for a corpse. - // Only one of a stack will be raised. - while (objl != NON_ITEM) - { - if (is_animatable_corpse(mitm[objl]) - && !is_being_butchered(mitm[objl])) - { - if (is_being_butchered(mitm[objl], false)) - was_butchered = true; - - int num = raise_corpse(objl, a.x, a.y, corps_beh, - corps_hit, actual); - - number_raised += num; - if (see_grid(env.show, you.pos(), a)) - number_seen += num; - break; - } - - hrg = mitm[objl].link; - objl = hrg; - } - - objl = 1; - } - } - - if (actual == 0) - return (number_raised); - - if (was_butchered) - mpr("The corpse you are butchering rises to attack!"); - - if (number_seen > 0) - mpr("The dead are walking!"); - - return (number_raised); -} - -int animate_a_corpse( int axps, int ayps, beh_type corps_beh, int corps_hit, - int class_allowed ) -{ - int rc = 0; - int objl = igrd[axps][ayps]; - // This searches all the items on the ground for a corpse - while (objl != NON_ITEM) - { - const item_def& item = mitm[objl]; - if (is_animatable_corpse(item) - && (class_allowed == CORPSE_BODY - || item.sub_type == CORPSE_SKELETON)) - { - bool was_butchering = is_being_butchered(item); - - rc = raise_corpse(objl, axps, ayps, corps_beh, corps_hit, 1); - if (rc) - { - if (was_butchering) - mpr("The corpse you are butchering rises to attack!"); - - if (is_terrain_seen(axps, ayps)) - mpr("The dead are walking!"); - - if (was_butchering) - xom_is_stimulated(255); - } - break; - } - objl = item.link; - } - - return rc; -} - -// Try to equip the zombie/skeleton with the objects it died with. -// This excludes items which were dropped by the player onto the corpse, -// and corpses which were picked up and moved by the player, so the player -// can't equip their undead slaves with items of their choice. -// -// The item selection logic has one problem: if a first monster without -// any items dies and leaves a corpse, and then a second monster with -// items dies on the same spot but doesn't leave a corpse, then the -// undead can be equipped with the second monster's items if the second -// monster is either of the same type as the first, or if the second -// monster wasn't killed by the player or a player's pet. -static void _equip_undead( int x, int y, int corps, int monster, int monnum) -{ -// Delay this until after 0.4 -#if 0 - monsters* mon = &menv[monster]; - - monster_type type = static_cast<monster_type>(monnum); - - if (mons_itemuse(monnum) < MONUSE_STARTING_EQUIPMENT) - return; - - // If the player picked up and dropped the corpse then all its - // original equipment fell off. - if (mitm[corps].flags & ISFLAG_DROPPED) - return; - - // A monster's corpse is last in the linked list after its items, - // so (for example) the first item after the second-to-last corpse - // is the first item belonging to the last corpse. - int objl = igrd[x][y]; - int first_obj = NON_ITEM; - - while (objl != NON_ITEM && objl != corps) - { - item_def item(mitm[objl]); - - if (item.base_type == OBJ_CORPSES) - { - first_obj = NON_ITEM; - continue; - } - - if (first_obj == NON_ITEM) - first_obj = objl; - - objl = item.link; - } - - ASSERT(objl == corps); - - if (first_obj == NON_ITEM) - return; - - // Iterate backwards over the list, since the items earlier in the - // linked list were dropped most recently and hence more likely to - // be items the monster didn't die with. - std::vector<int> item_list; - objl = first_obj; - while (objl != NON_ITEM && objl != corps) - { - item_list.push_back(objl); - objl = mitm[objl].link; - } - - for (int i = item_list.size() - 1; i >= 0; i--) - { - objl = item_list[i]; - item_def &item(mitm[objl]); - - // Stop equipping monster if the item probably didn't originally - // belong to the monster. - if ( (origin_known(item) && (item.orig_monnum - 1) != monnum) - || (item.flags & (ISFLAG_DROPPED | ISFLAG_THROWN)) - || item.base_type == OBJ_CORPSES) - { - return; - } - - mon_inv_type mslot; - - switch(item.base_type) - { - case OBJ_WEAPONS: - if (mon->inv[MSLOT_WEAPON] != NON_ITEM) - { - if (mons_wields_two_weapons(type)) - mslot = MSLOT_ALT_WEAPON; - else - { - if (is_range_weapon(mitm[mon->inv[MSLOT_WEAPON]]) - == is_range_weapon(item)) - { - // Two different items going into the same - // slot indicate that this and further items - // weren't equipment the monster died with. - return; - } - else - // The undead are too stupid to switch between weapons. - continue; - } - } - else - mslot = MSLOT_WEAPON; - break; - case OBJ_ARMOUR: - mslot = equip_slot_to_mslot(get_armour_slot(item)); - - // A piece of armour which can't be worn indicates that this - // and further items weren't the equipment the monster died - // with. - if (mslot == NUM_MONSTER_SLOTS) - return; - break; - - case OBJ_MISSILES: - mslot = MSLOT_MISSILE; - break; - - case OBJ_GOLD: - mslot = MSLOT_GOLD; - break; - - // The undead are too stupid to use these. - case OBJ_WANDS: - case OBJ_SCROLLS: - case OBJ_POTIONS: - case OBJ_MISCELLANY: - continue; - - default: - continue; - } // switch - - // Two different items going into the same slot indicate that - // this and further items weren't equipment the monster died - // with. - if (mon->inv[mslot] != NON_ITEM) - return; - - unlink_item(objl); - mon->inv[mslot] = objl; - - if (mslot != MSLOT_ALT_WEAPON || mons_wields_two_weapons(mon)) - mon->equip(item, mslot, 0); - } // while -#endif -} - -static int raise_corpse( int corps, int corx, int cory, - beh_type corps_beh, int corps_hit, int actual ) -{ - int returnVal = 1; - - if (!mons_zombie_size(mitm[corps].plus)) - returnVal = 0; - else if (actual != 0) - { - monster_type type = MONS_PROGRAM_BUG; - if (mitm[corps].sub_type == CORPSE_BODY) - { - if (mons_zombie_size(mitm[corps].plus) == Z_SMALL) - type = MONS_ZOMBIE_SMALL; - else - type = MONS_ZOMBIE_LARGE; - } - else - { - if (mons_zombie_size(mitm[corps].plus) == Z_SMALL) - type = MONS_SKELETON_SMALL; - else - type = MONS_SKELETON_LARGE; - } - - const int number = - mitm[corps].props.exists(MONSTER_NUMBER) - ? mitm[corps].props[MONSTER_NUMBER].get_short() - : 0; - - const monster_type zombie_type = - static_cast<monster_type>(mitm[corps].plus); - - // Headless hydras cannot be raised, sorry. - if (!number && zombie_type == MONS_HYDRA) - return (0); - - int monster = create_monster( - mgen_data( - type, corps_beh, 0, - coord_def(corx, cory), corps_hit, - 0, zombie_type, number)); - - if (monster != -1) - { - const int monnum = mitm[corps].orig_monnum - 1; - if (mons_is_unique(monnum)) - { - menv[monster].mname = origin_monster_name(mitm[corps]); - // Special case for Blork the orc: shorten his name to "Blork" - // to avoid mentions of "Blork the orc the orc skeleton". - if (monnum == MONS_BLORK_THE_ORC) - menv[monster].mname = "Blork"; - } - _equip_undead(corx, cory, corps, monster, monnum); - } - - destroy_item(corps); - } - - return returnVal; -} // end raise_corpse() - bool brand_weapon(brand_type which_brand, int power) { int temp_rand; // probability determination {dlb} |