diff options
-rw-r--r-- | crawl-ref/source/effects.cc | 29 | ||||
-rw-r--r-- | crawl-ref/source/makeitem.cc | 258 | ||||
-rw-r--r-- | crawl-ref/source/spells2.cc | 76 | ||||
-rw-r--r-- | crawl-ref/source/spells2.h | 12 | ||||
-rw-r--r-- | crawl-ref/source/spl-cast.cc | 2 | ||||
-rw-r--r-- | crawl-ref/source/stuff.cc | 30 | ||||
-rw-r--r-- | crawl-ref/source/view.cc | 26 |
7 files changed, 125 insertions, 308 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc index d1eaf0e1d7..f704f4243c 100644 --- a/crawl-ref/source/effects.cc +++ b/crawl-ref/source/effects.cc @@ -1158,35 +1158,6 @@ static int _acquirement_jewellery_subtype() return (result); } -static int _choose_first_unseen_book(int first, ...) -{ - va_list args; - va_start(args, first); - - if (first == NUM_BOOKS || !you.had_book[first]) - { - va_end(args); - return (first); - } - - int nargs = 100; - - while (nargs-- > 0) - { - const int another = va_arg(args, int); - if (another == NUM_BOOKS || !you.had_book[another]) - { - va_end(args); - return (another); - } - } - - ASSERT(nargs > 0); - - va_end(args); - return (NUM_BOOKS); -} - static int _acquirement_staff_subtype(const has_vector& already_has) { int result = random2(STAFF_FIRST_ROD); diff --git a/crawl-ref/source/makeitem.cc b/crawl-ref/source/makeitem.cc index 17f1e16a89..213a380388 100644 --- a/crawl-ref/source/makeitem.cc +++ b/crawl-ref/source/makeitem.cc @@ -2877,10 +2877,10 @@ int items( int allow_uniques, // not just true-false, } // Colour the item. - item_colour( item ); + item_colour(item); // Set brand appearance. - item_set_appearance( item ); + item_set_appearance(item); if (dont_place) { @@ -2889,23 +2889,21 @@ int items( int allow_uniques, // not just true-false, } else { - int x_pos, y_pos; - int tries = 500; - do + coord_def itempos; + bool found = false; + for (int i = 0; i < 500 && !found; ++i) { - if (tries-- <= 0) - { - destroy_item(p); - return (NON_ITEM); - } - - x_pos = random2(GXM); - y_pos = random2(GYM); + itempos = random_in_bounds(); + found = (grd(itempos) == DNGN_FLOOR + && unforbidden(itempos, mapmask)); } - while (grd[x_pos][y_pos] != DNGN_FLOOR - || !unforbidden(coord_def(x_pos, y_pos), mapmask)); - - move_item_to_grid( &p, coord_def(x_pos, y_pos) ); + if (!found) + { + // Couldn't find a single good spot! + destroy_item(p); + return (NON_ITEM); + } + move_item_to_grid(&p, itempos); } // Note that item might be invalidated now, since p could have changed. @@ -3047,39 +3045,37 @@ static void _give_scroll(monsters *mon, int level) static void _give_wand(monsters *mon, int level) { - //mv - give wand if (mons_is_unique(mon->type) && one_chance_in(5)) { - const int thing_created = - items(0, OBJ_WANDS, OBJ_RANDOM, true, level, 0); + const int idx = items(0, OBJ_WANDS, OBJ_RANDOM, true, level, 0); - if (thing_created == NON_ITEM) + if (idx == NON_ITEM) return; + item_def& wand = mitm[idx]; + // Don't give top-tier wands before 5 HD. if (mon->hit_dice < 5) { // Technically these wands will be undercharged, but it // doesn't really matter. - if (mitm[thing_created].sub_type == WAND_FIRE) - mitm[thing_created].sub_type = WAND_FLAME; - if (mitm[thing_created].sub_type == WAND_COLD) - mitm[thing_created].sub_type = WAND_FROST; - if (mitm[thing_created].sub_type == WAND_LIGHTNING) - { - mitm[thing_created].sub_type = (coinflip() ? WAND_FLAME - : WAND_FROST); - } + if (wand.sub_type == WAND_FIRE) + wand.sub_type = WAND_FLAME; + + if (wand.sub_type == WAND_COLD) + wand.sub_type = WAND_FROST; + + if (wand.sub_type == WAND_LIGHTNING) + wand.sub_type = (coinflip() ? WAND_FLAME : WAND_FROST); } - mitm[thing_created].flags = 0; - _give_monster_item(mon, thing_created); + wand.flags = 0; + _give_monster_item(mon, idx); } } static void _give_potion(monsters *mon, int level) { - //mv - give potion if (mons_species(mon->type) == MONS_VAMPIRE && one_chance_in(5)) { // This handles initialization of stack timer. @@ -3141,11 +3137,9 @@ static item_make_species_type _give_weapon(monsters *mon, int level, if (x_chance_in_y(3, 5)) // give hand weapon { item.base_type = OBJ_WEAPONS; - - const int temp_rand = random2(5); - item.sub_type = ((temp_rand > 2) ? WPN_DAGGER : // 40% - (temp_rand > 0) ? WPN_SHORT_SWORD // 40% - : WPN_CLUB); // 20% + item.sub_type = random_choose(WPN_DAGGER, WPN_DAGGER, + WPN_SHORT_SWORD, WPN_SHORT_SWORD, + WPN_CLUB, -1); } else return (item_race); @@ -3192,27 +3186,17 @@ static item_make_species_type _give_weapon(monsters *mon, int level, if (one_chance_in(6)) { - const int temp_rand = random2(4); - item.sub_type = ((temp_rand == 0) ? WPN_SPIKED_FLAIL : - (temp_rand == 1) ? WPN_GREAT_MACE : - (temp_rand == 2) ? WPN_WAR_AXE - : WPN_TRIDENT); + item.sub_type = random_choose(WPN_SPIKED_FLAIL, WPN_GREAT_MACE, + WPN_WAR_AXE, WPN_TRIDENT, -1); } else { - const int temp_rand = random2(12); - item.sub_type = ((temp_rand == 0) ? WPN_MACE : - (temp_rand == 1) ? WPN_FLAIL : - (temp_rand == 2) ? WPN_MORNINGSTAR : - (temp_rand == 3) ? WPN_DAGGER : - (temp_rand == 4) ? WPN_SHORT_SWORD : - (temp_rand == 5) ? WPN_LONG_SWORD : - (temp_rand == 6) ? WPN_SCIMITAR : - (temp_rand == 7) ? WPN_GREAT_SWORD : - (temp_rand == 8) ? WPN_HAND_AXE : - (temp_rand == 9) ? WPN_BATTLEAXE : - (temp_rand == 10) ? WPN_SPEAR - : WPN_HALBERD); + item.sub_type = random_choose( + WPN_MACE, WPN_FLAIL, WPN_MORNINGSTAR, + WPN_DAGGER, WPN_SHORT_SWORD, WPN_LONG_SWORD, + WPN_SCIMITAR, WPN_GREAT_SWORD, WPN_HAND_AXE, + WPN_BATTLEAXE, WPN_SPEAR, WPN_HALBERD, + -1); } if (coinflip()) @@ -3222,7 +3206,7 @@ static item_make_species_type _give_weapon(monsters *mon, int level, item.plus2 += 1 + random2(3); if (one_chance_in(5)) - set_item_ego_type( item, OBJ_WEAPONS, SPWPN_FREEZING ); + set_item_ego_type(item, OBJ_WEAPONS, SPWPN_FREEZING); } if (one_chance_in(3)) @@ -3239,12 +3223,8 @@ static item_make_species_type _give_weapon(monsters *mon, int level, if (!one_chance_in(5)) { item.base_type = OBJ_WEAPONS; - - const int temp_rand = random2(5); - item.sub_type = ((temp_rand > 2) ? WPN_SPEAR : // 40% - (temp_rand == 2) ? WPN_FLAIL : // 20% - (temp_rand == 1) ? WPN_HALBERD // 20% - : WPN_CLUB); // 20% + item.sub_type = random_choose(WPN_SPEAR, WPN_SPEAR, WPN_FLAIL, + WPN_HALBERD, WPN_CLUB, -1); } break; @@ -3259,22 +3239,15 @@ static item_make_species_type _give_weapon(monsters *mon, int level, if (!one_chance_in(5)) { item.base_type = OBJ_WEAPONS; - - const int temp_rand = random2(240); - item.sub_type = ((temp_rand > 209) ? WPN_DAGGER : //12.50% - (temp_rand > 179) ? WPN_CLUB : //12.50% - (temp_rand > 152) ? WPN_FLAIL : //11.25% - (temp_rand > 128) ? WPN_HAND_AXE : //10.00% - (temp_rand > 108) ? WPN_HAMMER : // 8.33% - (temp_rand > 88) ? WPN_HALBERD : // 8.33% - (temp_rand > 68) ? WPN_SHORT_SWORD : // 8.33% - (temp_rand > 48) ? WPN_MACE : // 8.33% - (temp_rand > 38) ? WPN_WHIP : // 4.17% - (temp_rand > 28) ? WPN_TRIDENT : // 4.17% - (temp_rand > 18) ? WPN_FALCHION : // 4.17% - (temp_rand > 8) ? WPN_MORNINGSTAR : // 4.17% - (temp_rand > 2) ? WPN_WAR_AXE // 2.50% - : WPN_SPIKED_FLAIL);// 1.25% + item.sub_type = random_choose_weighted( + 30, WPN_DAGGER, 30, WPN_CLUB, + 27, WPN_FLAIL, 24, WPN_HAND_AXE, + 20, WPN_HAMMER, 20, WPN_SHORT_SWORD, + 20, WPN_MACE, 10, WPN_WHIP, + 10, WPN_TRIDENT, 10, WPN_FALCHION, + 10, WPN_MORNINGSTAR, 6, WPN_WAR_AXE, + 3, WPN_SPIKED_FLAIL, + 0); } else return (item_race); @@ -3285,20 +3258,14 @@ static item_make_species_type _give_weapon(monsters *mon, int level, case MONS_DEEP_ELF_KNIGHT: case MONS_DEEP_ELF_PRIEST: case MONS_DEEP_ELF_SOLDIER: - { item_race = MAKE_ITEM_ELVEN; item.base_type = OBJ_WEAPONS; - - const int temp_rand = random2(100); - item.sub_type = ((temp_rand > 79) ? WPN_LONG_SWORD : // 20% - (temp_rand > 59) ? WPN_SHORT_SWORD : // 20% - (temp_rand > 45) ? WPN_SCIMITAR : // 14% - (temp_rand > 31) ? WPN_MACE : // 14% - (temp_rand > 18) ? WPN_BOW : // 13% - (temp_rand > 5) ? WPN_HAND_CROSSBOW // 13% - : WPN_LONGBOW); // 6% + item.sub_type = random_choose_weighted( + 20, WPN_LONG_SWORD, 20, WPN_SHORT_SWORD, 14, WPN_SCIMITAR, + 14, WPN_MACE, 13, WPN_BOW, 13, WPN_HAND_CROSSBOW, + 5, WPN_LONGBOW, + 0); break; - } case MONS_DEEP_ELF_BLADEMASTER: { @@ -3322,12 +3289,10 @@ static item_make_species_type _give_weapon(monsters *mon, int level, } case MONS_DEEP_ELF_MASTER_ARCHER: - { item_race = MAKE_ITEM_ELVEN; item.base_type = OBJ_WEAPONS; item.sub_type = WPN_LONGBOW; break; - } case MONS_DEEP_ELF_ANNIHILATOR: case MONS_DEEP_ELF_CONJURER: @@ -3343,17 +3308,13 @@ static item_make_species_type _give_weapon(monsters *mon, int level, case MONS_DRACONIAN_SCORCHER: case MONS_DRACONIAN_ANNIHILATOR: case MONS_DRACONIAN_CALLER: - { item.base_type = OBJ_WEAPONS; - - const int temp_rand = random2(6); - item.sub_type = ((temp_rand > 3) ? WPN_LONG_SWORD : // 2 in 6 - (temp_rand > 2) ? WPN_SHORT_SWORD :// 1 in 6 - (temp_rand > 1) ? WPN_SABRE : // 1 in 6 - (temp_rand > 0) ? WPN_DAGGER // 1 in 6 - : WPN_WHIP); // 1 in 6 + item.sub_type = random_choose(WPN_LONG_SWORD, WPN_LONG_SWORD, + WPN_SHORT_SWORD, WPN_SABRE, + WPN_DAGGER, WPN_WHIP, + -1); break; - } + case MONS_ORC_WARRIOR: case MONS_ORC_HIGH_PRIEST: case MONS_BLORK_THE_ORC: @@ -3381,28 +3342,21 @@ static item_make_species_type _give_weapon(monsters *mon, int level, case MONS_YELLOW_DRACONIAN: case MONS_PURPLE_DRACONIAN: case MONS_TIAMAT: - { if (mons_genus(mon->type) == MONS_NAGA) item_race = MAKE_ITEM_NO_RACE; item.base_type = OBJ_WEAPONS; - const int temp_rand = random2(120); - item.sub_type = ((temp_rand > 109) ? WPN_LONG_SWORD : // 8.33% - (temp_rand > 99) ? WPN_SHORT_SWORD : // 8.33% - (temp_rand > 89) ? WPN_SCIMITAR : // 8.33% - (temp_rand > 79) ? WPN_BATTLEAXE : // 8.33% - (temp_rand > 69) ? WPN_HAND_AXE : // 8.33% - (temp_rand > 59) ? WPN_HALBERD : // 8.33% - (temp_rand > 49) ? WPN_GLAIVE : // 8.33% - (temp_rand > 39) ? WPN_MORNINGSTAR : // 8.33% - (temp_rand > 29) ? WPN_GREAT_MACE : // 8.33% - (temp_rand > 19) ? WPN_TRIDENT : // 8.33% - (temp_rand > 10) ? WPN_WAR_AXE : // 7.50% - (temp_rand > 1) ? WPN_FLAIL : // 7.50% - (temp_rand > 0) ? WPN_BROAD_AXE // 0.83% - : WPN_SPIKED_FLAIL); // 0.83% + item.sub_type = random_choose_weighted( + 10, WPN_LONG_SWORD, 10, WPN_SHORT_SWORD, + 10, WPN_SCIMITAR, 10, WPN_BATTLEAXE, + 10, WPN_HAND_AXE, 10, WPN_HALBERD, + 10, WPN_GLAIVE, 10, WPN_MORNINGSTAR, + 10, WPN_GREAT_MACE, 10, WPN_TRIDENT, + 9, WPN_WAR_AXE, 9, WPN_FLAIL, + 1, WPN_BROAD_AXE, 1, WPN_SPIKED_FLAIL, + 0); break; - } + case MONS_ORC_WARLORD: case MONS_SAINT_ROKA: // being at the top has its privileges @@ -3433,17 +3387,13 @@ static item_make_species_type _give_weapon(monsters *mon, int level, { item.base_type = OBJ_WEAPONS; - const int temp_rand = random2(25); - item.sub_type = ((temp_rand > 20) ? WPN_GREAT_SWORD : // 16% - (temp_rand > 16) ? WPN_LONG_SWORD : // 16% - (temp_rand > 12) ? WPN_BATTLEAXE : // 16% - (temp_rand > 8) ? WPN_WAR_AXE : // 16% - (temp_rand > 5) ? WPN_GREAT_MACE : // 12% - (temp_rand > 3) ? WPN_DIRE_FLAIL : // 8% - (temp_rand > 2) ? WPN_BARDICHE : // 4% - (temp_rand > 1) ? WPN_GLAIVE : // 4% - (temp_rand > 0) ? WPN_BROAD_AXE // 4% - : WPN_HALBERD); // 4% + item.sub_type = random_choose_weighted( + 4, WPN_GREAT_SWORD, 4, WPN_LONG_SWORD, + 4, WPN_BATTLEAXE, 4, WPN_WAR_AXE, + 3, WPN_GREAT_MACE, 2, WPN_DIRE_FLAIL, + 1, WPN_BARDICHE, 1, WPN_GLAIVE, + 1, WPN_BROAD_AXE, 1, WPN_HALBERD, + 0); if (one_chance_in(4)) item.plus += 1 + random2(3); @@ -3603,7 +3553,6 @@ static item_make_species_type _give_weapon(monsters *mon, int level, case MONS_MAUD: case MONS_FREDERICK: case MONS_MARGERY: - { force_item = true; item.base_type = OBJ_WEAPONS; item.sub_type = (one_chance_in(3) ? WPN_LONG_SWORD : @@ -3633,13 +3582,10 @@ static item_make_species_type _give_weapon(monsters *mon, int level, set_item_ego_type( item, OBJ_WEAPONS, SPWPN_FLAMING ); else if (one_chance_in(3)) { - const int temp_rand = random2(5); - set_item_ego_type( item, OBJ_WEAPONS, - ((temp_rand == 0) ? SPWPN_DRAINING : - (temp_rand == 1) ? SPWPN_VORPAL : - (temp_rand == 2) ? SPWPN_PAIN : - (temp_rand == 3) ? SPWPN_DISTORTION - : SPWPN_SPEED) ); + set_item_ego_type(item, OBJ_WEAPONS, + random_choose(SPWPN_DRAINING, SPWPN_VORPAL, + SPWPN_PAIN, SPWPN_DISTORTION, + SPWPN_SPEED, -1)); } item.plus += random2(6); @@ -3652,7 +3598,7 @@ static item_make_species_type _give_weapon(monsters *mon, int level, if (one_chance_in(5)) item.colour = CYAN; break; - } + case MONS_FIRE_GIANT: force_item = true; item_race = MAKE_ITEM_NO_RACE; @@ -3717,22 +3663,16 @@ static item_make_species_type _give_weapon(monsters *mon, int level, item_race = MAKE_ITEM_NO_RACE; item.base_type = OBJ_WEAPONS; item.sub_type = coinflip() ? WPN_DAGGER : WPN_SHORT_SWORD; - { - const int temp_rand = random2(5); - set_item_ego_type( item, OBJ_WEAPONS, - ((temp_rand == 0) ? SPWPN_VENOM : - (temp_rand == 1) ? SPWPN_DRAINING : - (temp_rand == 2) ? SPWPN_VAMPIRICISM : - (temp_rand == 3) ? SPWPN_DISTORTION - : SPWPN_NORMAL) ); - } + set_item_ego_type(item, OBJ_WEAPONS, + random_choose(SPWPN_VENOM, SPWPN_DRAINING, + SPWPN_VAMPIRICISM, SPWPN_DISTORTION, + SPWPN_NORMAL, -1)); break; case MONS_EUSTACHIO: item_race = MAKE_ITEM_NO_RACE; item.base_type = OBJ_WEAPONS; - item.sub_type = (one_chance_in(3) ? WPN_FALCHION - : WPN_SABRE); + item.sub_type = (one_chance_in(3) ? WPN_FALCHION : WPN_SABRE); break; case MONS_CEREBOV: @@ -3760,29 +3700,21 @@ static item_make_species_type _give_weapon(monsters *mon, int level, case MONS_SALAMANDER: //mv: new 8 Aug 2001 //Yes, they've got really nice items, but //it's almost impossible to get them - { force_item = true; item_race = MAKE_ITEM_NO_RACE; item.base_type = OBJ_WEAPONS; - const int temp_rand = random2(6); - - item.sub_type = ((temp_rand == 5) ? WPN_GREAT_SWORD : - (temp_rand == 4) ? WPN_TRIDENT : - (temp_rand == 3) ? WPN_SPEAR : - (temp_rand == 2) ? WPN_GLAIVE : - (temp_rand == 1) ? WPN_BOW - : WPN_HALBERD); + item.sub_type = random_choose(WPN_GREAT_SWORD, WPN_TRIDENT, + WPN_SPEAR, WPN_GLAIVE, + WPN_BOW, WPN_HALBERD, + -1); - if (is_range_weapon(item)) - set_item_ego_type( item, OBJ_WEAPONS, SPWPN_FLAME ); - else - set_item_ego_type( item, OBJ_WEAPONS, SPWPN_FLAMING ); + set_item_ego_type(item, OBJ_WEAPONS, is_range_weapon(item) ? + SPWPN_FLAME : SPWPN_FLAMING); item.plus = random2(5); item.plus2 = random2(5); item.colour = RED; // forced by force_item above {dlb} break; - } default: break; diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index 7188bc8bf4..1f6e008d1b 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -820,21 +820,18 @@ bool vampiric_drain(int pow, const dist &vmove) return (success); } -bool burn_freeze(int pow, beam_type flavour, int targetmon) +bool burn_freeze(int pow, beam_type flavour, monsters *monster) { pow = std::min(25, pow); - if (targetmon == NON_MONSTER) + if (monster == NULL) { mpr("There isn't anything close enough!"); // If there's no monster there, you still pay the costs in - // order to prevent locating invisible monsters, unless - // you know that you see invisible. - return (!player_see_invis(false)); + // order to prevent locating invisible monsters. + return (true); } - monsters *monster = &menv[targetmon]; - god_conduct_trigger conducts[3]; disable_attack_conducts(conducts); @@ -1176,65 +1173,22 @@ bool cast_summon_swarm(int pow, god_type god, bool permanent) { bool success = false; - - monster_type mon = MONS_PROGRAM_BUG; - - const int dur = !permanent ? std::min(2 + (random2(pow) / 4), 6) : 0; - + const int dur = permanent ? 0 : std::min(2 + (random2(pow) / 4), 6); const int how_many = stepdown_value(2 + random2(pow)/10 + random2(pow)/25, 2, 2, 6, 8); for (int i = 0; i < how_many; ++i) { - switch (random2(14)) - { - case 0: - case 1: - case 2: // prototypical swarming creature {dlb} - mon = MONS_KILLER_BEE; - break; - - case 3: - mon = MONS_SCORPION; // think: "The Arrival" {dlb} - break; - - case 4: //jmf: technically not insects but still cool - mon = MONS_WORM; - break; // but worms kinda "swarm" so s'ok {dlb} - - case 5: - mon = MONS_GIANT_MOSQUITO; - break; // changed into giant mosquito 12jan2000 {dlb} - - case 6: - mon = MONS_GIANT_BEETLE; // think: scarabs in "The Mummy" {dlb} - break; - - case 7: //jmf: blowfly instead of queen bee - mon = MONS_GIANT_BLOWFLY; - break; - - // Queen bee added if more than x bees in swarm? {dlb} - // The above would require code rewrite - worth it? {dlb} - - case 8: - mon = MONS_WOLF_SPIDER; // think: "Kingdom of the Spiders" {dlb} - break; - - case 9: - mon = MONS_BUTTERFLY; // comic relief? {dlb} - break; - - case 10: // change into some kind of snake -- {dlb} - mon = MONS_YELLOW_WASP; // do wasps swarm? {dlb} - break; // think: "Indiana Jones" and snakepit? {dlb} - - default: // 3 in 14 chance, 12jan2000 {dlb} - mon = MONS_GIANT_ANT; - break; - } - - bool friendly = !force_hostile ? (random2(pow) > 7) : false; + const monster_type swarmers[] = { + MONS_KILLER_BEE, MONS_KILLER_BEE, MONS_KILLER_BEE, + MONS_SCORPION, MONS_WORM, MONS_GIANT_MOSQUITO, + MONS_GIANT_BEETLE, MONS_GIANT_BLOWFLY, MONS_WOLF_SPIDER, + MONS_BUTTERFLY, MONS_YELLOW_WASP, MONS_GIANT_ANT, + MONS_GIANT_ANT, MONS_GIANT_ANT + }; + + const monster_type mon = RANDOM_ELEMENT(swarmers); + const bool friendly = force_hostile ? false : (random2(pow) > 7); if (create_monster( mgen_data(mon, diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h index 1ef58c5818..c678e0b0d0 100644 --- a/crawl-ref/source/spells2.h +++ b/crawl-ref/source/spells2.h @@ -14,18 +14,8 @@ struct dist; -// last updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ bool brand_weapon(brand_type which_brand, int power); - - -// last updated 24may2000 {dlb} -/* *********************************************************************** - * called from: spell - * *********************************************************************** */ -bool burn_freeze(int pow, beam_type flavour, int targetmon); +bool burn_freeze(int pow, beam_type flavour, monsters *monster); void corpse_rot(); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index c89396b689..69e88ec5c0 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -1187,7 +1187,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail) case SPELL_CRUSH: case SPELL_ARC: if (!burn_freeze(powc, _spell_to_beam_type(spell), - mgrd(you.pos() + spd.delta))) + monster_at(you.pos() + spd.delta))) { return (SPRET_ABORT); } diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc index a89e46192d..97a910bed6 100644 --- a/crawl-ref/source/stuff.cc +++ b/crawl-ref/source/stuff.cc @@ -1297,36 +1297,6 @@ coord_def random_in_bounds() random_range(MAPGEN_BORDER, GYM - MAPGEN_BORDER - 1)); } -// Returns a random location in (x_pos, y_pos)... the grid will be -// DNGN_FLOOR if clear, and NON_MONSTER if empty. Exclusive tells -// if we're using in_bounds() or map_bounds() restriction. -void random_in_bounds(int &x_pos, int &y_pos, int terr, - bool empty, bool excl) -{ - bool done = false; - - do - { - x_pos = X_BOUND_1 + random2(X_WIDTH - 2 * excl) + 1 * excl; - y_pos = Y_BOUND_1 + random2(Y_WIDTH - 2 * excl) + 1 * excl; - - if (terr == DNGN_RANDOM) - done = true; - else if (terr == grd[x_pos][y_pos]) - done = true; - else if (terr == DNGN_DEEP_WATER - && grd[x_pos][y_pos] == DNGN_SHALLOW_WATER) - done = true; - else if (empty - && mgrd[x_pos][y_pos] != NON_MONSTER - && (coord_def(x_pos, y_pos) != you.pos())) - { - done = true; - } - } - while (!done); -} - unsigned char random_colour(void) { return (1 + random2(15)); diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index c16feff26c..b9d40322d1 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -735,12 +735,14 @@ screen_buffer_t colour_code_map( const coord_def& p, bool item_colour, { // If mesmerised, colour the few grids that can be reached anyway // lightgrey. - if (grd(p) >= DNGN_MINMOVE && mgrd(p) == NON_MONSTER) + const monsters *blocker = monster_at(p); + const bool seen_blocker = blocker && you.can_see(blocker); + if (grd(p) >= DNGN_MINMOVE && !seen_blocker) { bool blocked_movement = false; for (unsigned int i = 0; i < you.mesmerised_by.size(); i++) { - monsters& mon = menv[you.mesmerised_by[i]]; + const monsters& mon = menv[you.mesmerised_by[i]]; const int olddist = grid_distance(you.pos(), mon.pos()); const int newdist = grid_distance(p, mon.pos()); @@ -764,6 +766,8 @@ screen_buffer_t colour_code_map( const coord_def& p, bool item_colour, else if (Options.trap_item_brand && grid_is_trap(grid_value) && igrd(p) != NON_ITEM) { + // FIXME: this uses the real igrd, which the player shouldn't + // be aware of. tc |= COLFLAG_TRAP_ITEM; } @@ -898,10 +902,10 @@ static void _good_god_follower_attitude_change(monsters *monster) if (x_chance_in_y(you.piety, MAX_PIETY) && !you.penance[you.religion]) { - int wpn = you.equip[EQ_WEAPON]; - if (wpn != -1 - && you.inv[wpn].base_type == OBJ_WEAPONS - && is_evil_item(you.inv[wpn]) + const item_def* wpn = you.weapon(); + if (wpn + && wpn->base_type == OBJ_WEAPONS + && is_evil_item(*wpn) && coinflip()) // 50% chance of conversion failing { msg::stream << monster->name(DESC_CAP_THE) @@ -960,11 +964,8 @@ void beogh_follower_convert(monsters *monster, bool orc_hit) static void _handle_seen_interrupt(monsters* monster) { - if (mons_is_mimic(monster->type) - && !mons_is_known_mimic(monster)) - { + if (mons_is_mimic(monster->type) && !mons_is_known_mimic(monster)) return; - } activity_interrupt_data aid(monster); if (!monster->seen_context.empty()) @@ -1487,8 +1488,7 @@ inline static void _update_item_grid(const coord_def &gp, const coord_def &ep) void item_grid() { const coord_def c(crawl_view.glosc()); - for (radius_iterator ri(c, LOS_RADIUS, true, false); - ri; ++ri) + for (radius_iterator ri(c, LOS_RADIUS, true, false); ri; ++ri) { if (igrd(*ri) != NON_ITEM) { @@ -1650,7 +1650,7 @@ bool noisy(int loudness, const coord_def& where, const char *msg, bool mermaid) { monsters* monster = &menv[p]; - if (monster->type < 0) + if (!monster->alive()) continue; if (distance(monster->pos(), where) <= dist |