summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-19 21:02:48 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-01-19 21:02:48 +0000
commit96edac1d649d50f9cfacf317c88007783657c55f (patch)
treef6df66bbb1e96cf067eb1c4dd3bf506cb167c056 /crawl-ref
parente40eb81627b79763549583a56ebd2cd1f91d337c (diff)
downloadcrawl-ref-96edac1d649d50f9cfacf317c88007783657c55f.tar.gz
crawl-ref-96edac1d649d50f9cfacf317c88007783657c55f.zip
Expand effect applicator functions to take an actor parameter, and use
it for holy word in order to generalize it. This way, monsters as well as players may be able to use it in the future. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@8598 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/abl-show.cc2
-rw-r--r--crawl-ref/source/decks.cc3
-rw-r--r--crawl-ref/source/delay.cc4
-rw-r--r--crawl-ref/source/effects.cc81
-rw-r--r--crawl-ref/source/effects.h11
-rw-r--r--crawl-ref/source/fight.cc66
-rw-r--r--crawl-ref/source/item_use.cc2
-rw-r--r--crawl-ref/source/religion.cc7
-rw-r--r--crawl-ref/source/spells3.cc3
-rw-r--r--crawl-ref/source/spells4.cc89
-rw-r--r--crawl-ref/source/spells4.h2
-rw-r--r--crawl-ref/source/spl-cast.cc2
-rw-r--r--crawl-ref/source/spl-util.cc53
-rw-r--r--crawl-ref/source/spl-util.h30
14 files changed, 179 insertions, 176 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index 5e52268867..39e1874f49 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -2408,7 +2408,7 @@ static int _find_ability_slot( ability_type which_ability )
////////////////////////////////////////////////////////////////////////////
-static int _lugonu_warp_monster(coord_def where, int pow, int)
+static int _lugonu_warp_monster(coord_def where, int pow, int, actor *)
{
if (!in_bounds(where) || mgrd(where) == NON_MONSTER)
return (0);
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 0b0fe786f7..cfa3527d62 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -1716,9 +1716,8 @@ static void _stairs_card(int power, deck_rarity_type rarity)
stair_draw_count++;
}
-static int _drain_monsters(coord_def where, int pow, int garbage)
+static int _drain_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
if (where == you.pos())
drain_exp();
else
diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc
index fb1eabd818..bbd0ba1f2f 100644
--- a/crawl-ref/source/delay.cc
+++ b/crawl-ref/source/delay.cc
@@ -81,10 +81,8 @@ static bool _recite_mons_useless(const monsters *mon)
}
// Power is maximum 50.
-static int _recite_to_monsters(coord_def where, int pow, int unused)
+static int _recite_to_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED(unused);
-
const int mon = mgrd(where);
if (mon == NON_MONSTER)
return (0);
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 5a5f6db7c5..5ffd192a96 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -61,12 +61,18 @@ REVISION("$Rev$");
#include "view.h"
#include "xom.h"
-int holy_word_player(int pow, int caster)
+int holy_word_player(int pow, int caster, actor *attacker)
{
if (!player_is_unholy())
return 0;
- int hploss = std::max(0, you.hp / 2 - 1);
+ int hploss;
+
+ // Holy word won't kill its user.
+ if (attacker != &you)
+ hploss = roll_dice(2, 15) + (random2(pow) / 3);
+ else
+ hploss = std::max(0, you.hp / 2 - 1);
if (!hploss)
return 0;
@@ -103,7 +109,8 @@ int holy_word_player(int pow, int caster)
return 1;
}
-int holy_word_monsters(coord_def where, int pow, int caster)
+int holy_word_monsters(coord_def where, int pow, int caster,
+ actor *attacker)
{
int retval = 0;
@@ -112,7 +119,7 @@ int holy_word_monsters(coord_def where, int pow, int caster)
// Is the player in this cell?
if (where == you.pos())
- retval = holy_word_player(pow, caster);
+ retval = holy_word_player(pow, caster, attacker);
// Is a monster in this cell?
const int mon = mgrd(where);
@@ -122,35 +129,56 @@ int holy_word_monsters(coord_def where, int pow, int caster)
monsters *monster = &menv[mon];
- if (!monster->alive() || monster->res_holy_energy(&you) > 0)
+ if (!monster->alive() || !mons_is_unholy(monster))
return retval;
- const int hploss = roll_dice(2, 15) + (random2(pow) / 3);
- retval = 1;
+ int hploss;
+
+ // Holy word won't kill its user.
+ if (attacker != monster)
+ hploss = roll_dice(2, 15) + (random2(pow) / 3);
+ else
+ hploss = std::max(0, monster->hit_points / 2 - 1);
+
+ if (hploss)
+ simple_monster_message(monster, " convulses!");
- // Currently, holy word annoys the monsters it affects because it
- // can kill them, and because hostile monsters don't use it.
- behaviour_event(monster, ME_ANNOY, MHITYOU);
- simple_monster_message(monster, " convulses!");
- monster->hurt(&you, hploss);
+ monster->hurt(attacker, hploss);
- if (monster->alive())
+ if (hploss)
{
- if (monster->speed_increment >= 25)
- monster->speed_increment -= 20;
+ retval = 1;
+
+ // Holy word won't annoy, slow, or frighten its user.
+ if (monster->alive() && attacker != monster)
+ {
+ // Currently, holy word annoys the monsters it affects
+ // because it can kill them, and because hostile monsters
+ // don't use it.
+ behaviour_event(monster, ME_ANNOY, MHITYOU);
- monster->add_ench(ENCH_FEAR);
+ if (monster->speed_increment >= 25)
+ monster->speed_increment -= 20;
+
+ monster->add_ench(ENCH_FEAR);
+ }
}
return retval;
}
-int holy_word(int pow, int caster, const coord_def& where, bool silent)
+int holy_word(int pow, int caster, const coord_def& where, bool silent,
+ actor *attacker)
{
- if (!silent)
- mpr("You speak a Word of immense power!");
+ if (!silent && attacker)
+ {
+ mprf("%s %s a Word of immense power!",
+ attacker->name(DESC_CAP_THE).c_str(),
+ attacker->conj_verb("speak").c_str());
+ }
- return apply_area_within_radius(holy_word_monsters, where, pow, 8, caster);
+ return apply_area_within_radius(holy_word_monsters, where, pow, 8, caster,
+ attacker);
}
int torment_player(int pow, int caster)
@@ -221,7 +249,7 @@ int torment_player(int pow, int caster)
// maximum power of 1000, high level monsters and characters would save
// too often. (GDL)
-int torment_monsters(coord_def where, int pow, int caster)
+int torment_monsters(coord_def where, int pow, int caster, actor *attacker)
{
UNUSED(pow);
@@ -232,7 +260,7 @@ int torment_monsters(coord_def where, int pow, int caster)
retval = torment_player(0, caster);
// Is a monster in this cell?
- int mon = mgrd(where);
+ const int mon = mgrd(where);
if (mon == NON_MONSTER)
return retval;
@@ -244,18 +272,15 @@ int torment_monsters(coord_def where, int pow, int caster)
int hploss = std::max(0, monster->hit_points / 2 - 1);
+ if (hploss)
+ simple_monster_message(monster, " convulses!");
+
// Currently, torment doesn't annoy the monsters it affects because
// it can't kill them, and because hostile monsters use it.
monster->hurt(NULL, hploss, BEAM_TORMENT_DAMAGE);
if (hploss)
- {
retval = 1;
- if (!monster->alive())
- return retval;
- }
-
- simple_monster_message(monster, " convulses!");
return retval;
}
diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h
index e2c05fac02..5b17185d33 100644
--- a/crawl-ref/source/effects.h
+++ b/crawl-ref/source/effects.h
@@ -96,10 +96,12 @@ void yell(bool force = false);
/* ***********************************************************************
* called from: item_use - spell
* *********************************************************************** */
-int holy_word(int pow, int caster, const coord_def& where, bool silent);
+int holy_word(int pow, int caster, const coord_def& where, bool silent = false,
+ actor *attacker = NULL);
-int holy_word_player(int pow, int caster);
-int holy_word_monsters(coord_def where, int pow, int caster);
+int holy_word_player(int pow, int caster, actor *attacker = NULL);
+int holy_word_monsters(coord_def where, int pow, int caster,
+ actor *attacker = NULL);
// last updated 12may2000 {dlb}
@@ -110,7 +112,8 @@ int holy_word_monsters(coord_def where, int pow, int caster);
int torment(int caster, const coord_def& where);
int torment_player(int pow, int caster);
-int torment_monsters(coord_def where, int pow, int caster);
+int torment_monsters(coord_def where, int pow, int caster,
+ actor *attacker = NULL);
void immolation(int caster, bool known = false);
diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc
index 16a72a5847..fdddab382c 100644
--- a/crawl-ref/source/fight.cc
+++ b/crawl-ref/source/fight.cc
@@ -266,48 +266,48 @@ unchivalric_attack_type is_unchivalric_attack(const actor *attacker,
// No unchivalric attacks on monsters that cannot fight (e.g.
// plants) or monsters the attacker can't see (either due to
// invisibility or being behind opaque clouds).
- if (!defender->cannot_fight() && attacker->can_see(defender))
+ if (defender->cannot_fight() || (attacker && !attacker->can_see(defender)))
+ return (unchivalric);
+
+ // Distracted (but not batty); this only applies to players.
+ if (attacker && attacker->atype() == ACT_PLAYER && def->foe != MHITYOU
+ && !mons_is_batty(def))
{
- // Distracted (but not batty); this only applies to players.
- if (attacker->atype() == ACT_PLAYER && def->foe != MHITYOU
- && !mons_is_batty(def))
- {
- unchivalric = UCAT_DISTRACTED;
- }
+ unchivalric = UCAT_DISTRACTED;
+ }
- // confused (but not perma-confused)
- if (def->has_ench(ENCH_CONFUSION)
- && !mons_class_flag(def->type, M_CONFUSED))
- {
- unchivalric = UCAT_CONFUSED;
- }
+ // confused (but not perma-confused)
+ if (def->has_ench(ENCH_CONFUSION)
+ && !mons_class_flag(def->type, M_CONFUSED))
+ {
+ unchivalric = UCAT_CONFUSED;
+ }
- // fleeing
- if (mons_is_fleeing(def))
- unchivalric = UCAT_FLEEING;
+ // fleeing
+ if (mons_is_fleeing(def))
+ unchivalric = UCAT_FLEEING;
- // invisible
- if (!attacker->visible_to(defender))
- unchivalric = UCAT_INVISIBLE;
+ // invisible
+ if (attacker && !attacker->visible_to(defender))
+ unchivalric = UCAT_INVISIBLE;
- // held in a net
- if (mons_is_caught(def))
- unchivalric = UCAT_HELD_IN_NET;
+ // held in a net
+ if (mons_is_caught(def))
+ unchivalric = UCAT_HELD_IN_NET;
- // petrifying
- if (mons_is_petrifying(def))
- unchivalric = UCAT_PETRIFYING;
+ // petrifying
+ if (mons_is_petrifying(def))
+ unchivalric = UCAT_PETRIFYING;
- // paralysed
- if (def->cannot_act())
- unchivalric = UCAT_PARALYSED;
+ // paralysed
+ if (def->cannot_act())
+ unchivalric = UCAT_PARALYSED;
- // sleeping
- if (mons_is_sleeping(def))
- unchivalric = UCAT_SLEEPING;
- }
+ // sleeping
+ if (mons_is_sleeping(def))
+ unchivalric = UCAT_SLEEPING;
- return unchivalric;
+ return (unchivalric);
}
//////////////////////////////////////////////////////////////////////////
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 15415b9467..882845c031 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -5040,7 +5040,7 @@ void read_scroll(int slot)
}
const bool success = holy_word(pow, HOLY_WORD_SCROLL, you.pos(),
- !item_type_known(scroll));
+ !item_type_known(scroll), &you);
if (!success)
{
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 4616c13fad..5ffde17d8f 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -5972,7 +5972,7 @@ static bool _bless_weapon( god_type god, brand_type brand, int colour )
take_note(Note(NOTE_GOD_GIFT, you.religion));
you.flash_colour = colour;
- viewwindow( true, false );
+ viewwindow(true, false);
mprf( MSGCH_GOD, "Your weapon shines brightly!" );
simple_god_message( " booms: Use this gift wisely!" );
@@ -5980,6 +5980,9 @@ static bool _bless_weapon( god_type god, brand_type brand, int colour )
if ( god == GOD_SHINING_ONE )
{
holy_word(100, HOLY_WORD_TSO, you.pos(), true);
+#ifndef USE_TILE
+ delay(1000);
+#endif
// Un-bloodify surrounding squares.
for (radius_iterator ri(you.pos(), 3, true, true); ri; ++ri)
@@ -5987,8 +5990,6 @@ static bool _bless_weapon( god_type god, brand_type brand, int colour )
env.map(*ri).property &= ~(FPROP_BLOODY);
}
- delay(1000);
-
return (true);
}
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 9d07e15a2c..665951f70a 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -1691,7 +1691,8 @@ bool cast_sanctuary(const int power)
mpr("You are suddenly bathed in radiance!");
you.flash_colour = WHITE;
- viewwindow( true, false );
+ viewwindow(true, false);
+
holy_word(100, HOLY_WORD_ZIN, you.pos(), true);
#ifndef USE_TILE
delay(1000);
diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc
index adea2e1abf..049b901be9 100644
--- a/crawl-ref/source/spells4.cc
+++ b/crawl-ref/source/spells4.cc
@@ -66,7 +66,6 @@ enum DEBRIS // jmf: add for shatter, dig, and Giants to throw
}; // jmf: ...and I'll actually implement the items Real Soon Now...
static int _make_a_rot_cloud(const coord_def& where, int pow, cloud_type ctype);
-static int _quadrant_blink(coord_def where, int pow, int garbage);
void do_monster_rot(int mon);
@@ -91,10 +90,8 @@ static bool _player_hurt_monster(int monster, int damage)
}
// Here begin the actual spells:
-static int _shatter_monsters(coord_def where, int pow, int garbage)
+static int _shatter_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
-
dice_def dam_dice( 0, 5 + pow / 3 ); // number of dice set below
const int monster = mgrd(where);
@@ -186,10 +183,9 @@ static int _shatter_monsters(coord_def where, int pow, int garbage)
return (damage);
}
-static int _shatter_items(coord_def where, int pow, int garbage)
+static int _shatter_items(coord_def where, int pow, int, actor *)
{
UNUSED( pow );
- UNUSED( garbage );
int broke_stuff = 0;
@@ -213,10 +209,8 @@ static int _shatter_items(coord_def where, int pow, int garbage)
return 0;
}
-static int _shatter_walls(coord_def where, int pow, int garbage)
+static int _shatter_walls(coord_def where, int pow, int, actor *)
{
- UNUSED(garbage);
-
int chance = 0;
// if not in-bounds then we can't really shatter it -- bwr
@@ -388,9 +382,8 @@ void cast_detect_secret_doors(int pow)
mprf("You detect %s", (found > 0) ? "secret doors!" : "nothing.");
}
-static int _sleep_monsters(coord_def where, int pow, int garbage)
+static int _sleep_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
const int mnstr = mgrd(where);
if (mnstr == NON_MONSTER)
@@ -447,9 +440,8 @@ static bool _is_domesticated_animal(int type)
return (false);
}
-static int _tame_beast_monsters(coord_def where, int pow, int garbage)
+static int _tame_beast_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
const int which_mons = mgrd(where);
if (which_mons == NON_MONSTER)
@@ -488,10 +480,9 @@ void cast_tame_beasts(int pow)
apply_area_visible(_tame_beast_monsters, pow);
}
-static int _ignite_poison_objects(coord_def where, int pow, int garbage)
+static int _ignite_poison_objects(coord_def where, int pow, int, actor *)
{
UNUSED( pow );
- UNUSED( garbage );
int strength = 0;
@@ -526,10 +517,9 @@ static int _ignite_poison_objects(coord_def where, int pow, int garbage)
return (strength);
}
-static int _ignite_poison_clouds( coord_def where, int pow, int garbage )
+static int _ignite_poison_clouds( coord_def where, int pow, int, actor *)
{
UNUSED( pow );
- UNUSED( garbage );
bool did_anything = false;
@@ -557,10 +547,8 @@ static int _ignite_poison_clouds( coord_def where, int pow, int garbage )
return did_anything;
}
-static int _ignite_poison_monsters(coord_def where, int pow, int garbage)
+static int _ignite_poison_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
-
bolt beam;
beam.flavour = BEAM_FIRE; // This is dumb, only used for adjust!
@@ -777,10 +765,8 @@ void cast_silence(int pow)
}
}
-static int _discharge_monsters( coord_def where, int pow, int garbage )
+static int _discharge_monsters( coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
-
const int mon = mgrd(where);
int damage = 0;
@@ -864,7 +850,7 @@ void cast_discharge( int pow )
// NB: this must be checked against the same effects
// in fight.cc for all forms of attack !!! {dlb}
// This function should be currently unused (the effect is too powerful).
-static int _distortion_monsters(coord_def where, int pow, int message)
+static int _distortion_monsters(coord_def where, int pow, int, actor *)
{
if (pow > 100)
pow = 100;
@@ -937,9 +923,9 @@ static int _distortion_monsters(coord_def where, int pow, int message)
defender->banish();
return 1;
}
- else if (message)
+ else
{
- mpr("Nothing seems to happen.");
+ canned_msg(MSG_NOTHING_HAPPENS);
return 1;
}
@@ -956,10 +942,8 @@ void cast_bend(int pow)
// Really this is just applying the best of Band/Warp weapon/Warp field
// into a spell that gives the "make monsters go away" benefit without
// the insane damage potential. -- bwr
-int disperse_monsters(coord_def where, int pow, int message)
+int disperse_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED( message );
-
const int monster_attacked = mgrd(where);
if (monster_attacked == NON_MONSTER)
@@ -997,16 +981,12 @@ int disperse_monsters(coord_def where, int pow, int message)
void cast_dispersal(int pow)
{
- if (apply_area_around_square( disperse_monsters, you.pos(), pow ) == 0)
- {
- mpr( "The air shimmers briefly around you." );
- }
+ if (apply_area_around_square(disperse_monsters, you.pos(), pow) == 0)
+ mpr("The air shimmers briefly around you.");
}
-static int _spell_swap_func(coord_def where, int pow, int message)
+static int _spell_swap_func(coord_def where, int pow, int, actor *)
{
- UNUSED( message );
-
int monster_attacked = mgrd(where);
if (monster_attacked == NON_MONSTER)
@@ -1041,7 +1021,7 @@ static int _spell_swap_func(coord_def where, int pow, int message)
void cast_swap(int pow)
{
- apply_one_neighbouring_square( _spell_swap_func, pow );
+ apply_one_neighbouring_square(_spell_swap_func, pow);
}
static int _make_a_rot_cloud(const coord_def& where, int pow, cloud_type ctype)
@@ -1081,10 +1061,8 @@ int make_a_normal_cloud(coord_def where, int pow, int spread_rate,
return 1;
}
-static int _passwall(coord_def where, int pow, int garbage)
+static int _passwall(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
-
int howdeep = 0;
bool done = false;
int shallow = 1 + (you.skills[SK_EARTH_MAGIC] / 8);
@@ -1160,17 +1138,16 @@ static int _passwall(coord_def where, int pow, int garbage)
start_delay( DELAY_PASSWALL, 1 + howdeep, n.x, n.y );
return 1;
-} // end passwall()
+}
void cast_passwall(int pow)
{
apply_one_neighbouring_square(_passwall, pow);
}
-static int _intoxicate_monsters(coord_def where, int pow, int garbage)
+static int _intoxicate_monsters(coord_def where, int pow, int, actor *)
{
UNUSED( pow );
- UNUSED( garbage );
int mon = mgrd(where);
@@ -1536,11 +1513,9 @@ void cast_fulsome_distillation( int powc )
mpr( "Unfortunately, you can't carry it right now!" );
}
-static int _rot_living(coord_def where, int pow, int message)
+static int _rot_living(coord_def where, int pow, int, actor *)
{
- UNUSED( message );
-
- int mon = mgrd(where);
+ const int mon = mgrd(where);
int ench;
if (mon == NON_MONSTER)
@@ -1560,11 +1535,9 @@ static int _rot_living(coord_def where, int pow, int message)
return 1;
}
-static int _rot_undead(coord_def where, int pow, int garbage)
+static int _rot_undead(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
-
- int mon = mgrd(where);
+ const int mon = mgrd(where);
int ench;
if (mon == NON_MONSTER)
@@ -1618,10 +1591,8 @@ static int _rot_undead(coord_def where, int pow, int garbage)
return 1;
}
-static int _rot_corpses(coord_def where, int pow, int garbage)
+static int _rot_corpses(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
-
return _make_a_rot_cloud(where, pow, CLOUD_MIASMA);
}
@@ -1647,11 +1618,9 @@ void do_monster_rot(int mon)
return;
}
-static int _snake_charm_monsters(coord_def where, int pow, int message)
+static int _snake_charm_monsters(coord_def where, int pow, int, actor *)
{
- UNUSED( message );
-
- int mon = mgrd(where);
+ const int mon = mgrd(where);
if (mon == NON_MONSTER
|| one_chance_in(4)
@@ -2394,10 +2363,8 @@ void cast_divine_shield()
you.redraw_armour_class = true;
}
-static int _quadrant_blink(coord_def where, int pow, int garbage)
+static int _quadrant_blink(coord_def where, int pow, int, actor *)
{
- UNUSED( garbage );
-
if (where == you.pos())
return (0);
diff --git a/crawl-ref/source/spells4.h b/crawl-ref/source/spells4.h
index 7996dffac9..c508003df2 100644
--- a/crawl-ref/source/spells4.h
+++ b/crawl-ref/source/spells4.h
@@ -19,7 +19,7 @@ bool backlight_monsters(coord_def where, int pow, int garbage);
int make_a_normal_cloud(coord_def where, int pow, int spread_rate,
cloud_type ctype, kill_category,
killer_type killer = KILL_NONE);
-int disperse_monsters(coord_def where, int pow, int message);
+int disperse_monsters(coord_def where, int pow);
void cast_bend(int pow);
void remove_condensation_shield();
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 8cef3bf1b1..6874c78590 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -1358,7 +1358,7 @@ spret_type your_spells(spell_type spell, int powc, bool allow_fail)
break;
case SPELL_HOLY_WORD:
- holy_word(100, HOLY_WORD_SPELL, you.pos(), true);
+ holy_word(100, HOLY_WORD_SPELL, you.pos(), true, &you);
break;
case SPELL_REPEL_UNDEAD:
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index be1be5ae5b..b030fe8fca 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -467,25 +467,27 @@ const char *spell_title(spell_type spell)
// Apply a function-pointer to all visible squares
// Returns summation of return values from passed in function.
-int apply_area_visible( cell_func cf, int power, bool pass_through_trans)
+int apply_area_visible(cell_func cf, int power,
+ bool pass_through_trans, actor *agent)
{
int rv = 0;
for (radius_iterator ri(you.pos(), LOS_RADIUS); ri; ++ri)
- if ( pass_through_trans || see_grid_no_trans(*ri) )
- rv += cf(*ri, power, 0);
+ if (pass_through_trans || see_grid_no_trans(*ri))
+ rv += cf(*ri, power, 0, agent);
return (rv);
}
// Applies the effect to all nine squares around/including the target.
// Returns summation of return values from passed in function.
-int apply_area_square( cell_func cf, const coord_def& where, int power )
+int apply_area_square(cell_func cf, const coord_def& where, int power,
+ actor *agent)
{
int rv = 0;
for (adjacent_iterator ai(where, false); ai; ++ai)
- rv += cf(*ai, power, 0);
+ rv += cf(*ai, power, 0, agent);
return (rv);
}
@@ -493,20 +495,22 @@ int apply_area_square( cell_func cf, const coord_def& where, int power )
// Applies the effect to the eight squares beside the target.
// Returns summation of return values from passed in function.
-int apply_area_around_square( cell_func cf, const coord_def& where, int power)
+int apply_area_around_square(cell_func cf, const coord_def& where, int power,
+ actor *agent)
{
int rv = 0;
for (adjacent_iterator ai(where, true); ai; ++ai)
- rv += cf(*ai, power, 0);
+ rv += cf(*ai, power, 0, agent);
return (rv);
}
-// Effect up to max_targs monsters around a point, chosen randomly
-// Return varies with the function called; return values will be added up.
-int apply_random_around_square( cell_func cf, const coord_def& where,
- bool exclude_center, int power, int max_targs )
+// Affect up to max_targs monsters around a point, chosen randomly.
+// Return varies with the function called; return values will be added up.
+int apply_random_around_square(cell_func cf, const coord_def& where,
+ bool exclude_center, int power, int max_targs,
+ actor *agent)
{
int rv = 0;
@@ -514,10 +518,10 @@ int apply_random_around_square( cell_func cf, const coord_def& where,
return 0;
if (max_targs >= 9 && !exclude_center)
- return (apply_area_square( cf, where, power ));
+ return (apply_area_square(cf, where, power, agent));
if (max_targs >= 8 && exclude_center)
- return (apply_area_around_square( cf, where, power ));
+ return (apply_area_around_square(cf, where, power, agent));
coord_def targs[8];
@@ -600,11 +604,11 @@ int apply_random_around_square( cell_func cf, const coord_def& where,
// slot -- but we don't care about them).
if (count <= max_targs)
{
- targs[ count - 1 ] = *ai;
+ targs[count - 1] = *ai;
}
else if (x_chance_in_y(max_targs, count))
{
- const int pick = random2( max_targs );
+ const int pick = random2(max_targs);
targs[ pick ] = *ai;
}
}
@@ -618,8 +622,8 @@ int apply_random_around_square( cell_func cf, const coord_def& where,
// balance the called function. -- bwr
for (int i = 0; i < targs_found; i++)
{
- ASSERT( !targs[i].origin() );
- rv += cf( targs[i], power, 0 );
+ ASSERT(!targs[i].origin());
+ rv += cf(targs[i], power, 0, agent);
}
}
@@ -627,12 +631,12 @@ int apply_random_around_square( cell_func cf, const coord_def& where,
}
// Apply func to one square of player's choice beside the player.
-int apply_one_neighbouring_square(cell_func cf, int power)
+int apply_one_neighbouring_square(cell_func cf, int power, actor *agent)
{
dist bmove;
mpr("Which direction? [ESC to cancel]", MSGCH_PROMPT);
- direction( bmove, DIR_DIR, TARG_ENEMY );
+ direction(bmove, DIR_DIR, TARG_ENEMY);
if (!bmove.isValid)
{
@@ -640,7 +644,7 @@ int apply_one_neighbouring_square(cell_func cf, int power)
return (-1);
}
- int rv = cf(you.pos() + bmove.delta, power, 1);
+ int rv = cf(you.pos() + bmove.delta, power, 1, agent);
if (rv == 0)
canned_msg(MSG_NOTHING_HAPPENS);
@@ -648,14 +652,15 @@ int apply_one_neighbouring_square(cell_func cf, int power)
return (rv);
}
-int apply_area_within_radius( cell_func cf, const coord_def& where,
- int pow, int radius, int ctype )
+int apply_area_within_radius(cell_func cf, const coord_def& where,
+ int pow, int radius, int ctype,
+ actor *agent)
{
int rv = 0;
- for ( radius_iterator ri(where, radius, false, false); ri; ++ri )
- rv += cf(*ri, pow, ctype);
+ for (radius_iterator ri(where, radius, false, false); ri; ++ri)
+ rv += cf(*ri, pow, ctype, agent);
return (rv);
}
diff --git a/crawl-ref/source/spl-util.h b/crawl-ref/source/spl-util.h
index 2a916a4b32..0342fcc076 100644
--- a/crawl-ref/source/spl-util.h
+++ b/crawl-ref/source/spl-util.h
@@ -79,25 +79,34 @@ const char *spell_title(spell_type which_spell);
const char* spelltype_short_name( int which_spelltype );
const char* spelltype_long_name( int which_spelltype );
-typedef int cell_func(coord_def where, int pow, int aux);
+typedef int cell_func(coord_def where, int pow, int aux, actor *agent);
typedef int cloud_func(coord_def where, int pow, int spreadrate,
cloud_type type, kill_category whose,
killer_type killer);
int apply_area_visible(cell_func cf, int power,
- bool pass_through_trans = false);
+ bool pass_through_trans = false, actor *agent = NULL);
-int apply_area_square(cell_func cf, const coord_def& where, int power);
+int apply_area_square(cell_func cf, const coord_def& where, int power,
+ actor *agent = NULL);
-int apply_area_around_square(cell_func cf, const coord_def& where, int power );
+int apply_area_around_square(cell_func cf, const coord_def& where, int power,
+ actor *agent = NULL);
-int apply_random_around_square( cell_func cf, const coord_def& where,
- bool hole_in_middle, int power, int max_targs );
+int apply_random_around_square(cell_func cf, const coord_def& where,
+ bool hole_in_middle, int power, int max_targs,
+ actor *agent = NULL);
-int apply_one_neighbouring_square(cell_func cf, int power);
+int apply_one_neighbouring_square(cell_func cf, int power, actor *agent = NULL);
int apply_area_within_radius(cell_func cf, const coord_def& where,
- int pow, int radius, int ctype);
+ int pow, int radius, int ctype,
+ actor *agent = NULL);
+
+void apply_area_cloud(cloud_func func, const coord_def& where,
+ int pow, int number, cloud_type ctype,
+ kill_category kc, killer_type killer,
+ int spread_rate = -1);
bool spell_direction( dist &spelld, bolt &pbolt,
targeting_type restrict = DIR_NONE,
@@ -107,11 +116,6 @@ bool spell_direction( dist &spelld, bolt &pbolt,
bool may_target_self = false, const char *prompt = NULL,
bool cancel_at_self = false );
-void apply_area_cloud(cloud_func func, const coord_def& where,
- int pow, int number, cloud_type ctype,
- kill_category kc, killer_type killer,
- int spread_rate = -1);
-
const char *spelltype_name(unsigned int which_spelltype);
int spell_type2skill (unsigned int which_spelltype);