summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-20 10:56:39 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-09-20 10:56:39 +0000
commitd31d7584ae39422c3ba70297d6abd1da69d2e714 (patch)
tree021abc01ae108f766018be4835deedc80dc1efdc
parenta324c4ba0fbb3c8b96c549301237db8b6efdea1c (diff)
downloadcrawl-ref-d31d7584ae39422c3ba70297d6abd1da69d2e714.tar.gz
crawl-ref-d31d7584ae39422c3ba70297d6abd1da69d2e714.zip
2058436: better interface for the range-1 attack spells.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6955 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/misc.cc2
-rw-r--r--crawl-ref/source/spells2.cc54
-rw-r--r--crawl-ref/source/spells2.h2
-rw-r--r--crawl-ref/source/spl-cast.cc42
4 files changed, 37 insertions, 63 deletions
diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc
index 4b5a6234d6..6f3fb1b150 100644
--- a/crawl-ref/source/misc.cc
+++ b/crawl-ref/source/misc.cc
@@ -2674,7 +2674,7 @@ std::string your_hand(bool plural)
bool stop_attack_prompt(const monsters *mon, bool beam_attack,
bool beam_target)
{
- if (you.confused())
+ if (you.confused() || !you.can_see(mon))
return (false);
bool retval = false;
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index d987299724..495f92fe42 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -819,44 +819,25 @@ bool vampiric_drain(int pow, const dist &vmove)
return (true);
}
-char burn_freeze(int pow, beam_type flavour)
+bool burn_freeze(int pow, beam_type flavour, int targetmon )
{
- dist spd;
-
pow = std::min(25, pow);
- mpr("Which direction?", MSGCH_PROMPT);
- direction(spd, DIR_DIR, TARG_ENEMY);
-
- if (!spd.isValid)
- {
- canned_msg(MSG_OK);
- return (-1);
- }
-
- if (spd.isMe)
- {
- canned_msg(MSG_UNTHINKING_ACT);
- return (-1);
- }
-
- const int mgr = mgrd(you.pos() + spd.delta);
-
- // Yes, this is strange, but it does maintain the original
- // behaviour. Possibly to avoid giving information about invisible
- // monsters?
- if (mgr == NON_MONSTER)
+ if (targetmon == NON_MONSTER)
{
mpr("There isn't anything close enough!");
- return (0);
+ // 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));
}
- monsters *monster = &menv[mgr];
+ monsters *monster = &menv[targetmon];
god_conduct_trigger conducts[3];
disable_attack_conducts(conducts);
- bool success = !stop_attack_prompt(monster, false, false);
+ const bool success = !stop_attack_prompt(monster, false, false);
if (success)
{
@@ -879,27 +860,20 @@ char burn_freeze(int pow, beam_type flavour)
{
bolt beam;
beam.flavour = flavour;
+ beam.thrower = KILL_YOU;
int hurted = roll_dice(1, 3 + pow / 3);
+ hurted = mons_adjust_flavoured(monster, beam, hurted);
+ monster->hurt(&you, hurted);
- if (flavour != BEAM_MISSILE)
- hurted = mons_adjust_flavoured(monster, beam, hurted);
-
- hurt_monster(monster, hurted);
-
- if (monster->hit_points < 1)
- monster_die(monster, KILL_YOU, 0);
- else
+ if (monster->alive())
{
print_wounds(monster);
if (flavour == BEAM_COLD)
{
- if (mons_class_flag(monster->type, M_COLD_BLOOD)
- && coinflip())
- {
+ if (mons_class_flag(monster->type, M_COLD_BLOOD) && coinflip())
monster->add_ench(ENCH_SLOW);
- }
const int cold_res = mons_res_cold( monster );
if (cold_res <= 0)
@@ -911,7 +885,7 @@ char burn_freeze(int pow, beam_type flavour)
}
}
- return (1);
+ return (success);
}
bool summon_animals(int pow)
diff --git a/crawl-ref/source/spells2.h b/crawl-ref/source/spells2.h
index 7612fd91b2..2469e5e0ef 100644
--- a/crawl-ref/source/spells2.h
+++ b/crawl-ref/source/spells2.h
@@ -25,7 +25,7 @@ bool brand_weapon(brand_type which_brand, int power);
/* ***********************************************************************
* called from: spell
* *********************************************************************** */
-char burn_freeze(int pow, beam_type b_f);
+bool burn_freeze(int pow, beam_type flavour, int targetmon);
// last updated 24may2000 {dlb}
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 7661821878..86320e69e3 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -931,6 +931,19 @@ static void _try_monster_cast(spell_type spell, int powc,
}
#endif // WIZARD
+beam_type _spell_to_beam_type(spell_type spell)
+{
+ switch (spell)
+ {
+ case SPELL_BURN: return BEAM_FIRE;
+ case SPELL_FREEZE: return BEAM_COLD;
+ case SPELL_CRUSH: return BEAM_MISSILE;
+ case SPELL_ARC: return BEAM_ELECTRICITY;
+ default: break;
+ }
+ return BEAM_NONE;
+}
+
// Returns SPRET_SUCCESS if spell is successfully cast for purposes of
// exercising, SPRET_FAIL otherwise, or SPRET_ABORT if the player canceled
// the casting.
@@ -948,7 +961,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
if (_spell_is_uncastable(spell))
return (SPRET_ABORT);
- const int flags = get_spell_flags(spell);
+ const unsigned int flags = get_spell_flags(spell);
int potion = -1;
@@ -956,10 +969,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
// there are others that do their own that will be missed by this
// (and thus will not properly ESC without cost because of it).
// Hopefully, those will eventually be fixed. -- bwr
- if ((flags & SPFLAG_TARGETING_MASK)
- && spell != SPELL_BURN && spell != SPELL_FREEZE
- && spell != SPELL_CRUSH && spell != SPELL_ARC
- && spell != SPELL_PORTAL_PROJECTILE)
+ if ((flags & SPFLAG_TARGETING_MASK) && spell != SPELL_PORTAL_PROJECTILE)
{
targ_mode_type targ =
(testbits(flags, SPFLAG_HELPFUL) ? TARG_FRIEND : TARG_ENEMY);
@@ -1104,28 +1114,18 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
switch (spell)
{
- // Attack spells.
- // using burn_freeze()
+ // spells using burn_freeze()
case SPELL_BURN:
- if (burn_freeze(powc, BEAM_FIRE) == -1)
- return (SPRET_ABORT);
- break;
-
case SPELL_FREEZE:
- if (burn_freeze(powc, BEAM_COLD) == -1)
- return (SPRET_ABORT);
- break;
-
case SPELL_CRUSH:
- if (burn_freeze(powc, BEAM_MISSILE) == -1)
- return (SPRET_ABORT);
- break;
-
case SPELL_ARC:
- if (burn_freeze(powc, BEAM_ELECTRICITY) == -1)
+ if (!burn_freeze(powc, _spell_to_beam_type(spell),
+ mgrd(you.pos() + spd.delta)))
+ {
return (SPRET_ABORT);
+ }
break;
-
+
// direct beams/bolts
case SPELL_MAGIC_DART:
if (!zapping(ZAP_MAGIC_DARTS, powc, beam, true))