summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/effects.cc
diff options
context:
space:
mode:
authordshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-20 17:21:09 +0000
committerdshaligram <dshaligram@c06c8d41-db1a-0410-9941-cceddc491573>2008-07-20 17:21:09 +0000
commit3a4159644bb83b286ae10d5f37fcdbf81dced398 (patch)
treeedf72dff6f6250859ea6d051eba807049e6e661a /crawl-ref/source/effects.cc
parente57ab785ed42435069db2f2397fe939a70119c27 (diff)
downloadcrawl-ref-3a4159644bb83b286ae10d5f37fcdbf81dced398.tar.gz
crawl-ref-3a4159644bb83b286ae10d5f37fcdbf81dced398.zip
Pan overhaul:
Allow monsters (including player ghosts) to use fire storm and ice storm, give Lom Lobon ice storm and Cerebov fire storm. Lom Lobon also gets conjure ball lightning. Mnoleg gets Summon Horrible Things instead of polymorph/shadow creatures. Gloorx gets symbol of torment instead of summon demon. Hellion hellfire burst now behaves the same way for both hellion vs player and hellion vs monster. Merged monster vs player and m vs m handling for direct spell effects such as smiting. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6621 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/effects.cc')
-rw-r--r--crawl-ref/source/effects.cc134
1 files changed, 38 insertions, 96 deletions
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 05850e6ef0..86df6e4b0f 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -603,120 +603,62 @@ bool lose_stat(unsigned char which_stat, unsigned char stat_loss,
return lose_stat(which_stat, stat_loss, force, verb + " " + name, true);
}
-void direct_effect(struct bolt &pbolt)
+void direct_effect(monsters *source, spell_type spell,
+ bolt &pbolt, actor *defender)
{
- int damage_taken = 0;
-
- monsters* source = NULL;
-
- if (pbolt.beam_source != NON_MONSTER)
- source = &menv[pbolt.beam_source];
-
- switch (pbolt.type)
- {
- case DMNBM_HELLFIRE:
- pbolt.aux_source = "burst of hellfire";
- pbolt.name = "hellfire";
- pbolt.ex_size = 1;
- pbolt.flavour = BEAM_HELLFIRE;
- pbolt.is_explosion = true;
- pbolt.type = dchar_glyph(DCHAR_FIRED_ZAP);
- pbolt.colour = RED;
- pbolt.thrower = KILL_MON_MISSILE;
- pbolt.aux_source.clear();
- pbolt.is_beam = false;
- pbolt.is_tracer = false;
- pbolt.hit = 20;
- pbolt.damage = dice_def( 3, 20 );
- explosion( pbolt );
- break;
-
- case DMNBM_SMITING:
- mpr( "Something smites you!" );
- pbolt.name = "smiting";
- pbolt.aux_source = "by divine providence";
- damage_taken = 7 + random2avg(11, 2);
- break;
-
- case DMNBM_BRAIN_FEED:
- // lose_stat() must come last {dlb}
- if (one_chance_in(3)
- && lose_stat(STAT_INTELLIGENCE, 1, source))
- {
- mpr("Something feeds on your intellect!");
- xom_is_stimulated(50);
- }
- else
- mpr("Something tries to feed on your intellect!");
- break;
- }
+ const bool mons_defender = defender->atype() == ACT_MONSTER;
+ monsters *mdef = mons_defender? dynamic_cast<monsters*>(defender) : NULL;
- // apply damage and handle death, where appropriate {dlb}
- if (damage_taken > 0)
+ if (mdef)
{
- ouch(damage_taken, pbolt.beam_source, KILLED_BY_BEAM,
- pbolt.aux_source.c_str());
+ // annoy the target
+ behaviour_event(mdef, ME_ANNOY, monster_index(source));
}
- return;
-} // end direct_effect()
-// monster-to-monster
-void mons_direct_effect(struct bolt &pbolt, int i)
-{
- // note the translation here - important {dlb}
- int o = menv[i].foe;
- monsters *monster = &menv[o];
int damage_taken = 0;
-
- // annoy the target
- behaviour_event(monster, ME_ANNOY, i);
-
- switch (pbolt.type)
+ switch (spell)
{
- case DMNBM_HELLFIRE:
- simple_monster_message(monster, " is engulfed in hellfire.");
- pbolt.name = "hellfire";
- pbolt.flavour = BEAM_LAVA;
-
- damage_taken = 5 + random2(10) + random2(5);
- damage_taken = mons_adjust_flavoured(monster, pbolt, damage_taken);
- break;
-
- case DMNBM_SMITING:
- simple_monster_message(monster, " is smitten.");
- pbolt.name = "smiting";
- pbolt.flavour = BEAM_MISSILE;
-
- damage_taken += 7 + random2avg(11, 2);
- break;
-
- case DMNBM_BRAIN_FEED: // Not implemented here (nor, probably, can be).
+ case SPELL_SMITING:
+ if (mons_defender)
+ simple_monster_message(dynamic_cast<monsters*>(defender),
+ " is smitten.");
+ else
+ mpr( "Something smites you!" );
+ pbolt.name = "smiting";
+ pbolt.flavour = BEAM_MISSILE;
+ pbolt.aux_source = "by divine providence";
+ damage_taken = 7 + random2avg(11, 2);
break;
- case DMNBM_MUTATION:
- if (mons_holiness(monster) != MH_NATURAL
- || mons_immune_magic(monster))
+ case SPELL_BRAIN_FEED:
+ if (!mons_defender)
{
- simple_monster_message(monster, " is unaffected.");
+ // lose_stat() must come last {dlb}
+ if (one_chance_in(3)
+ && lose_stat(STAT_INTELLIGENCE, 1, source))
+ {
+ mpr("Something feeds on your intellect!");
+ xom_is_stimulated(50);
+ }
+ else
+ mpr("Something tries to feed on your intellect!");
}
- else if (check_mons_resist_magic( monster, pbolt.ench_power ))
- simple_monster_message(monster, " resists.");
- else
- monster_polymorph(monster, RANDOM_MONSTER);
break;
+
+ default:
+ ASSERT(false);
}
- // Apply damage and handle death, where appropriate {dlb}
+ // apply damage and handle death, where appropriate {dlb}
if (damage_taken > 0)
{
- hurt_monster(monster, damage_taken);
-
- if (monster->hit_points < 1)
- monster_die(monster, KILL_MON_MISSILE, i);
+ if (mdef)
+ mdef->hurt(source, damage_taken);
+ else
+ ouch(damage_taken, pbolt.beam_source, KILLED_BY_BEAM,
+ pbolt.aux_source.c_str());
}
-
- return;
}
void random_uselessness(int scroll_slot)