summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/decks.cc68
-rw-r--r--crawl-ref/source/mon-util.cc2
-rw-r--r--crawl-ref/source/monplace.cc17
-rw-r--r--crawl-ref/source/spells2.cc2
4 files changed, 61 insertions, 28 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index ad2b4dfba0..c5b56ffa0c 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2645,7 +2645,8 @@ static void _crusade_card(int power, deck_rarity_type rarity)
for (int i = 0; i < MAX_MONSTERS; ++i)
{
monsters* const monster = &menv[i];
- if (monster->type == -1 || !mons_near(monster)
+ if (!monster->alive()
+ || !mons_near(monster)
|| mons_friendly(monster)
|| mons_holiness(monster) != MH_NATURAL
|| mons_is_unique(monster->type)
@@ -2699,10 +2700,20 @@ static void _summon_demon_card(int power, deck_rarity_type rarity)
else
dct = DEMON_LESSER;
- create_monster(
- mgen_data(summon_any_demon(dct), BEH_FRIENDLY,
- std::min(power / 50, 6), 0,
- you.pos(), MHITYOU));
+ // FIXME: The manual testing for message printing is there because
+ // we can't rely on create_monster() to do it for us. This is
+ // because if you are completely surrounded by walls, create_monster()
+ // will never manage to give a position which isn't (-1,-1)
+ // and thus not print the message.
+ // This hack appears later in this file as well.
+ if (create_monster(
+ mgen_data(summon_any_demon(dct), BEH_FRIENDLY,
+ std::min(power / 50, 6), 0,
+ you.pos(), MHITYOU),
+ false) == -1)
+ {
+ mpr("You see a puff of smoke.");
+ }
}
static void _summon_any_monster(int power, deck_rarity_type rarity)
@@ -2751,12 +2762,13 @@ static void _summon_any_monster(int power, deck_rarity_type rarity)
const bool friendly = (power_level > 0 || !one_chance_in(4));
- create_monster(
- mgen_data(mon_chosen,
- friendly ? BEH_FRIENDLY : BEH_HOSTILE,
- 3, 0,
- chosen_spot,
- MHITYOU));
+ if (create_monster(mgen_data(mon_chosen,
+ friendly ? BEH_FRIENDLY : BEH_HOSTILE,
+ 3, 0, chosen_spot, MHITYOU),
+ false) == -1)
+ {
+ mpr("You see a puff of smoke.");
+ }
}
static void _summon_dancing_weapon(int power, deck_rarity_type rarity)
@@ -2768,7 +2780,8 @@ static void _summon_dancing_weapon(int power, deck_rarity_type rarity)
create_monster(
mgen_data(MONS_DANCING_WEAPON,
friendly ? BEH_FRIENDLY : BEH_HOSTILE,
- power_level + 3, 0, you.pos(), MHITYOU));
+ power_level + 3, 0, you.pos(), MHITYOU),
+ false);
// Given the abundance of Nemelex decks, not setting hard reset
// leaves a trail of weapons behind, most of which just get
@@ -2814,6 +2827,10 @@ static void _summon_dancing_weapon(int power, deck_rarity_type rarity)
}
menv[mon].flags |= MF_HARD_RESET;
}
+ else
+ {
+ mpr("You see a puff of smoke.");
+ }
}
static void _summon_flying(int power, deck_rarity_type rarity)
@@ -2852,12 +2869,14 @@ static void _summon_skeleton(int power, deck_rarity_type rarity)
MONS_SKELETON_LARGE, MONS_SKELETAL_WARRIOR, MONS_SKELETAL_DRAGON
};
- create_monster(
- mgen_data(
- skeltypes[power_level],
- friendly ? BEH_FRIENDLY : BEH_HOSTILE,
- std::min(power / 50, 6), 0,
- you.pos(), MHITYOU));
+ if (create_monster(mgen_data(skeltypes[power_level],
+ friendly ? BEH_FRIENDLY : BEH_HOSTILE,
+ std::min(power / 50, 6), 0,
+ you.pos(), MHITYOU),
+ false) == -1)
+ {
+ mpr("You see a puff of smoke.");
+ }
}
static void _summon_ugly(int power, deck_rarity_type rarity)
@@ -2872,11 +2891,14 @@ static void _summon_ugly(int power, deck_rarity_type rarity)
else
ugly = MONS_UGLY_THING;
- create_monster(
- mgen_data(ugly,
- friendly ? BEH_FRIENDLY : BEH_HOSTILE,
- std::min(power / 50, 6), 0,
- you.pos(), MHITYOU));
+ if (create_monster(mgen_data(ugly,
+ friendly ? BEH_FRIENDLY : BEH_HOSTILE,
+ std::min(power / 50, 6), 0,
+ you.pos(), MHITYOU),
+ false) == -1)
+ {
+ mpr("You see a puff of smoke.");
+ }
}
static int _card_power(deck_rarity_type rarity)
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index b53296fa7b..db4e34dd77 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -2000,7 +2000,7 @@ static std::string _str_monam(const monsters& mon, description_level_type desc,
use_inscrip = false;
}
- item_def item = mitm[mon.inv[MSLOT_WEAPON]];
+ const item_def& item = mitm[mon.inv[MSLOT_WEAPON]];
return item.name(desc, false, false, use_inscrip, false, ignore_flags);
}
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 42e0f9f9f2..c6866b3a7b 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -1115,12 +1115,23 @@ static int _place_monster_aux(const mgen_data &mg,
const bool summoned = mg.abjuration_duration >= 1
&& mg.abjuration_duration <= 6;
- if (mg.cls == MONS_DANCING_WEAPON && mg.number != 1) // ie not from spell
+ if (mg.cls == MONS_DANCING_WEAPON)
{
give_item(id, mg.power, summoned);
- if (menv[id].inv[MSLOT_WEAPON] != NON_ITEM)
- menv[id].colour = mitm[menv[id].inv[MSLOT_WEAPON]].colour;
+ // Dancing swords *always* have a weapon. Fail to
+ // create them otherwise.
+ const item_def* wpn = menv[id].weapon();
+ if (!wpn)
+ {
+ menv[id].destroy_inventory();
+ menv[id].reset();
+ return (-1);
+ }
+ else
+ {
+ menv[id].colour = wpn->colour;
+ }
}
else if (mons_class_itemuse(mg.cls) >= MONUSE_STARTING_EQUIPMENT)
{
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 93b42bae76..508a83cb94 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -1702,7 +1702,7 @@ bool cast_tukimas_dance(int pow, god_type god,
success = false;
else if (success)
// Copy item now so that mitm[i] is occupied and doesn't get picked
- // by get_item_slot() when giving the dancing weapon it's item
+ // by get_item_slot() when giving the dancing weapon its item
// during create_monster().
mitm[i] = you.inv[wpn];