Skip to content

Commit

Permalink
Make infestation scarab-creation into a fineff (#10848)
Browse files Browse the repository at this point in the history
To fix newly-created scarabs being turned hostile when killing their host in
an explosion.
  • Loading branch information
Chris Campbell committed Dec 17, 2016
1 parent 575bbf7 commit ed96f7e
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 16 deletions.
19 changes: 19 additions & 0 deletions crawl-ref/source/fineff.cc
Expand Up @@ -529,6 +529,25 @@ void bennu_revive_fineff::fire()
newmons->props["bennu_revives"].get_byte() = revives + 1;
}

void infestation_death_fineff::fire()
{
if (monster *scarab = create_monster(mgen_data(MONS_DEATH_SCARAB,
BEH_FRIENDLY, posn,
MHITYOU, MG_AUTOFOE)
.set_summoned(&you, 0,
SPELL_INFESTATION),
false))
{
scarab->add_ench(mon_enchant(ENCH_FAKE_ABJURATION, 6));

if (you.see_cell(posn) || you.can_see(*scarab))
{
mprf("%s bursts from %s!", scarab->name(DESC_A, true).c_str(),
name.c_str());
}
}
}

// Effects that occur after all other effects, even if the monster is dead.
// For example, explosions that would hit other creatures, but we want
// to deal with only one creature at a time, so that's handled last.
Expand Down
18 changes: 18 additions & 0 deletions crawl-ref/source/fineff.h
Expand Up @@ -319,6 +319,24 @@ class bennu_revive_fineff : public final_effect
unsigned short foe;
};

class infestation_death_fineff : public final_effect
{
public:
bool mergeable(const final_effect &a) const override { return false; }
void fire() override;

static void schedule(coord_def pos, const string &name)
{
final_effect::schedule(new infestation_death_fineff(pos, name));
}
protected:
infestation_death_fineff(coord_def pos, const string &_name)
: final_effect(0, 0, pos), name(_name)
{
}
string name;
};

void fire_final_effects();

#endif
18 changes: 2 additions & 16 deletions crawl-ref/source/mon-death.cc
Expand Up @@ -1424,22 +1424,8 @@ static bool _explode_monster(monster* mons, killer_type killer,

static void _infestation_create_scarab(monster* mons)
{
if (monster *scarab = create_monster(mgen_data(MONS_DEATH_SCARAB,
BEH_FRIENDLY, mons->pos(),
MHITYOU, MG_AUTOFOE)
.set_summoned(&you, 0,
SPELL_INFESTATION),
false))
{
scarab->add_ench(mon_enchant(ENCH_FAKE_ABJURATION, 6));

if (you.see_cell(mons->pos()) || you.can_see(*scarab))
{
mprf("%s bursts from %s!", scarab->name(DESC_A, true).c_str(),
mons->name(DESC_THE).c_str());
}
mons->flags |= MF_EXPLODE_KILL;
}
mons->flags |= MF_EXPLODE_KILL;
infestation_death_fineff::schedule(mons->pos(), mons->name(DESC_THE));
}

static void _monster_die_cloud(const monster* mons, bool corpse, bool silent,
Expand Down

0 comments on commit ed96f7e

Please sign in to comment.