summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/decks.cc8
-rw-r--r--crawl-ref/source/enum.h3
-rw-r--r--crawl-ref/source/externs.h2
-rw-r--r--crawl-ref/source/mon-util.cc16
-rw-r--r--crawl-ref/source/monplace.cc6
-rw-r--r--crawl-ref/source/monstuff.cc52
-rw-r--r--crawl-ref/source/spl-cast.cc7
-rw-r--r--crawl-ref/source/stuff.cc2
8 files changed, 55 insertions, 41 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index d9704056d8..a37728d045 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2451,11 +2451,9 @@ static void summon_skeleton(int power, deck_rarity_type rarity)
MONS_SKELETON_LARGE, MONS_SKELETAL_WARRIOR, MONS_SKELETAL_DRAGON
};
- const int mon = create_monster(skeltypes[power_level], std::min(power/50,6),
- friendly ? BEH_FRIENDLY : BEH_HOSTILE,
- you.x_pos, you.y_pos, MHITYOU, 250 );
- if ( mon != -1 ) // don't want skeletal warriors dropping stuff
- menv[mon].flags |= MF_HARD_RESET;
+ create_monster(skeltypes[power_level], std::min(power/50,6),
+ friendly ? BEH_FRIENDLY : BEH_HOSTILE,
+ you.x_pos, you.y_pos, MHITYOU, 250 );
}
static int card_power(deck_rarity_type rarity)
diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h
index f3a19160eb..81671b0cce 100644
--- a/crawl-ref/source/enum.h
+++ b/crawl-ref/source/enum.h
@@ -1257,7 +1257,8 @@ enum item_status_flag_type // per item flags: ie. ident status, cursed status
ISFLAG_NOTED_ID = 0x08000000,
ISFLAG_NOTED_GET = 0x10000000,
- ISFLAG_BEEN_IN_INV = 0x20000000 // Item has been in inventory
+ ISFLAG_BEEN_IN_INV = 0x20000000, // Item has been in inventory
+ ISFLAG_SUMMONED = 0x40000000 // Item generated on a summon
};
enum job_type
diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h
index 0e664b8447..b787849353 100644
--- a/crawl-ref/source/externs.h
+++ b/crawl-ref/source/externs.h
@@ -1006,6 +1006,8 @@ public:
public:
void init_experience();
+
+ void mark_summoned(int longevity, bool mark_items_summoned );
bool has_action_energy() const;
void check_redraw(const coord_def &oldpos) const;
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index dc53042080..e7b6d93c4f 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -4186,7 +4186,7 @@ void monsters::remove_enchantment_effect(const mon_enchant &me, bool quiet)
add_ench( mon_enchant(ENCH_ABJ) );
// just for flavour
- if (this->flags & MF_GOD_GIFT && this->has_ench(ENCH_BERSERK))
+ if ((this->flags & MF_GOD_GIFT) && this->has_ench(ENCH_BERSERK))
simple_monster_message(this, " is no longer berserk.");
monster_die( this, quiet? KILL_DISMISSED : KILL_RESET, 0 );
@@ -4727,6 +4727,20 @@ void monsters::apply_enchantment(const mon_enchant &me)
}
}
+void monsters::mark_summoned(int longevity, bool mark_items)
+{
+ add_ench( mon_enchant(ENCH_ABJ, longevity) );
+ if (mark_items)
+ {
+ for (int i = 0; i < NUM_MONSTER_SLOTS; ++i)
+ {
+ const int item = inv[i];
+ if (item != NON_ITEM)
+ mitm[item].flags |= ISFLAG_SUMMONED;
+ }
+ }
+}
+
void monsters::apply_enchantments()
{
if (enchantments.empty())
diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc
index 1bacdf8b62..5a5f753a72 100644
--- a/crawl-ref/source/monplace.cc
+++ b/crawl-ref/source/monplace.cc
@@ -834,7 +834,7 @@ static int place_monster_aux( int mon_type, beh_type behaviour, int target,
// dur should always be 1-6 for monsters that can be abjured.
if (dur >= 1 && dur <= 6)
- menv[id].add_ench( mon_enchant(ENCH_ABJ, dur) );
+ menv[id].mark_summoned( dur, true );
menv[id].foe = target;
@@ -1645,11 +1645,11 @@ int create_monster( int cls, int dur, beh_type beha, int cr_x, int cr_y,
}
else
{
- struct monsters *const creation = &menv[summd];
+ monsters *const creation = &menv[summd];
// dur should always be ENCH_ABJ_xx
if (dur >= 1 && dur <= 6)
- creation->add_ench( mon_enchant(ENCH_ABJ, dur) );
+ creation->mark_summoned( dur, true );
// player summons do not give XP or other bonuses
// (you can still train skills on them though)
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 867253ed37..2ab5148d34 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -258,28 +258,26 @@ bool curse_an_item( bool decay_potions )
static void monster_drop_ething(monsters *monster,
bool mark_item_origins = false)
{
- /* drop weapons & missiles last (ie on top) so others pick up */
- int i; // loop variable {dlb}
- bool destroyed = false;
- bool hostile_grid = false;
-
- if ( grid_destroys_items(grd[monster->x][monster->y]) ) {
- hostile_grid = true;
- }
+ const bool hostile_grid = grid_destroys_items(grd(monster->pos()));
+ const int midx = (int) monster_index(monster);
- int midx = (int) monster_index(monster);
+ bool destroyed = false;
- for (i = MSLOT_GOLD; i >= MSLOT_WEAPON; i--)
+ /* drop weapons & missiles last (ie on top) so others pick up */
+ for (int i = NUM_MONSTER_SLOTS - 1; i >= 0; i--)
{
int item = monster->inv[i];
if (item != NON_ITEM)
{
- if (hostile_grid)
+ const bool summoned_item =
+ testbits(mitm[item].flags, ISFLAG_SUMMONED);
+ if (hostile_grid || summoned_item)
{
item_was_destroyed(mitm[item], midx);
- destroyed = true;
destroy_item( item );
+ if (!summoned_item)
+ destroyed = true;
}
else
{
@@ -294,11 +292,10 @@ static void monster_drop_ething(monsters *monster,
}
}
- if (destroyed) {
+ if (destroyed)
mprf(MSGCH_SOUND,
- grid_item_destruction_message(grd[monster->x][monster->y]));
- }
-} // end monster_drop_ething()
+ grid_item_destruction_message(grd(monster->pos())));
+}
static void place_monster_corpse(const monsters *monster)
{
@@ -494,7 +491,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
!silent && mons_near(monster) && player_monster_visible(monster);
bool in_transit = false;
const bool hard_reset = testbits(monster->flags, MF_HARD_RESET);
- bool drop_items = !monster->has_ench(ENCH_ABJ) && !hard_reset;
+ const bool drop_items = !hard_reset;
#ifdef DGL_MILESTONES
check_kill_milestone(monster, killer, i);
@@ -605,8 +602,6 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
place_cloud( random_smoke_type(),
monster->x, monster->y, 1 + random2(3),
monster->kill_alignment() );
- else
- drop_items = true;
}
else
{
@@ -823,16 +818,21 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent)
monster->x, monster->y, 1 + random2(3),
monster->kill_alignment() );
- if (monster->needs_transit())
- {
- monster->flags |= MF_BANISHED;
- monster->set_transit( level_id(LEVEL_ABYSS) );
- in_transit = true;
- }
+ // KILL_RESET monsters no longer lose their whole inventory, only
+ // items they were generated with.
+ if (!monster->needs_transit())
+ break;
- // fall-through
+ // Monster goes to the Abyss.
+ monster->flags |= MF_BANISHED;
+ monster->set_transit( level_id(LEVEL_ABYSS) );
+ in_transit = true;
+ monster->destroy_inventory();
+ break;
case KILL_DISMISSED:
+ break;
+
default:
monster->destroy_inventory();
break;
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 39b887ce6f..bf739e56f0 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -1698,11 +1698,8 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail )
case SPELL_SHADOW_CREATURES:
{
mpr( "Wisps of shadow whirl around you..." );
- const int which_mons =
- create_monster( RANDOM_MONSTER, 2, BEH_FRIENDLY,
- you.x_pos, you.y_pos, you.pet_target, 250 );
- if (which_mons != -1 && which_mons != NON_MONSTER)
- menv[which_mons].flags |= MF_HARD_RESET;
+ create_monster( RANDOM_MONSTER, 2, BEH_FRIENDLY,
+ you.x_pos, you.y_pos, you.pet_target, 250 );
break;
}
//jmf: new spells 19mar2000
diff --git a/crawl-ref/source/stuff.cc b/crawl-ref/source/stuff.cc
index 6c35f2a993..1a9043437a 100644
--- a/crawl-ref/source/stuff.cc
+++ b/crawl-ref/source/stuff.cc
@@ -1269,6 +1269,8 @@ void zap_los_monsters()
mprf(MSGCH_DIAGNOSTICS, "Dismissing %s",
mon->name(DESC_PLAIN, true).c_str() );
#endif
+ // Mark as summoned so its items will also be discarded.
+ mon->mark_summoned(1, true);
monster_die(mon, KILL_DISMISSED, 0);
}
}