summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-02 23:35:45 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-05-02 23:35:45 +0000
commitbe475192b63984f46893bcf60b3f79f3b8820570 (patch)
tree42000f995d490da2255d2dcbca4ae2435ee3a0b6 /crawl-ref
parent69feb4ac309556a1464ec1ca7a1ab9cedc14176a (diff)
downloadcrawl-ref-be475192b63984f46893bcf60b3f79f3b8820570.tar.gz
crawl-ref-be475192b63984f46893bcf60b3f79f3b8820570.zip
Clean up and consolidate the holy word and torment effects.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4815 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/abl-show.cc3
-rw-r--r--crawl-ref/source/effects.cc125
-rw-r--r--crawl-ref/source/effects.h6
-rw-r--r--crawl-ref/source/item_use.cc40
-rw-r--r--crawl-ref/source/religion.cc2
-rw-r--r--crawl-ref/source/spells3.cc2
-rw-r--r--crawl-ref/source/spl-cast.cc2
7 files changed, 110 insertions, 70 deletions
diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc
index aafc185d92..0f97a557a9 100644
--- a/crawl-ref/source/abl-show.cc
+++ b/crawl-ref/source/abl-show.cc
@@ -1393,7 +1393,8 @@ static bool _do_ability(const ability_def& abil)
break;
case ABIL_ZIN_HOLY_WORD:
- holy_word( you.skills[SK_INVOCATIONS] * 8, HOLY_WORD_GENERIC );
+ holy_word(you.skills[SK_INVOCATIONS] * 8, HOLY_WORD_GENERIC, you.x_pos,
+ you.y_pos, true);
exercise(SK_INVOCATIONS, 3 + random2(5));
break;
diff --git a/crawl-ref/source/effects.cc b/crawl-ref/source/effects.cc
index 1554ed0064..cd3506bde2 100644
--- a/crawl-ref/source/effects.cc
+++ b/crawl-ref/source/effects.cc
@@ -71,8 +71,6 @@ bool holy_word_player(int pow, int caster)
int hploss = you.hp / 2 - 1;
- if (hploss >= you.hp)
- hploss = you.hp - 1;
if (hploss < 0)
hploss = 0;
@@ -103,52 +101,74 @@ bool holy_word_player(int pow, int caster)
return true;
}
-bool holy_word(int pow, int caster, bool silent)
+int holy_word_monsters(int x, int y, int pow, int caster)
{
- if (!silent)
- mpr("You speak a Word of immense power!");
+ int retval = 0;
// doubt this will ever happen, but it's here as a safety -- bwr
if (pow > 300)
pow = 300;
- bool holy_influenced = holy_word_player(pow, caster);
+ // Is the player in this cell?
+ if (x == you.x_pos && y == you.y_pos)
+ {
+ retval = (holy_word_player(pow, caster)) ? 1 : 0;
+ }
+
+ // Is a monster in this cell?
+ int mon = mgrd[x][y];
+
+ if (mon == NON_MONSTER)
+ return retval;
+
+ monsters *monster = &menv[mon];
- for (int tu = 0; tu < MAX_MONSTERS; tu++)
+ if (invalid_monster(monster) || !mons_near(monster)
+ || !mons_is_unholy(monster))
{
- monsters *monster = &menv[tu];
+ return retval;
+ }
- if (monster->type == -1 || !mons_near(monster))
- continue;
+ int hploss = roll_dice(2, 15) + (random2(pow) / 3);
- if (mons_is_unholy(monster))
- {
- holy_influenced = true;
+ if (hploss < 0)
+ hploss = 0;
+
+ behaviour_event(monster, ME_ANNOY, MHITYOU);
+ hurt_monster(monster, hploss);
+ if (hploss)
+ {
+ retval = 1;
+ if (monster->hit_points > 0)
simple_monster_message(monster, " convulses!");
+ else
+ monster_die(monster, KILL_YOU, 0);
+ }
- behaviour_event( monster, ME_ANNOY, MHITYOU );
- hurt_monster( monster, roll_dice( 2, 15 ) + (random2(pow) / 3) );
+ if (monster->speed_increment >= 25)
+ {
+ retval = 1;
+ monster->speed_increment -= 20;
+ }
- if (monster->hit_points < 1)
- {
- monster_die(monster, KILL_YOU, 0);
- continue;
- }
+ if (monster->add_ench(ENCH_FEAR))
+ retval = 1;
- if (monster->speed_increment >= 25)
- monster->speed_increment -= 20;
+ return retval;
+}
- monster->add_ench(ENCH_FEAR);
- } // end "if mons_holiness"
- } // end "for tu"
+int holy_word(int pow, int caster, int x, int y, bool silent)
+{
+ if (!silent)
+ mpr("You speak a Word of immense power!");
- return holy_influenced;
-} // end holy_word()
+ return apply_area_within_radius(holy_word_monsters, x, y, pow, 8, caster);
+}
bool torment_player(int pow, int caster)
{
- UNUSED( pow );
+ UNUSED(pow);
// [dshaligram] Switched to using ouch() instead of dec_hp() so that
// notes can also track torment and activities can be interrupted
@@ -159,8 +179,7 @@ bool torment_player(int pow, int caster)
{
// negative energy resistance can alleviate torment
hploss = you.hp * (50 - player_prot_life() * 5) / 100 - 1;
- if (hploss >= you.hp)
- hploss = you.hp - 1;
+
if (hploss < 0)
hploss = 0;
}
@@ -216,36 +235,52 @@ bool torment_player(int pow, int caster)
int torment_monsters(int x, int y, int pow, int caster)
{
- UNUSED( pow );
+ UNUSED(pow);
- // is player?
+ int retval = 0;
+
+ // Is the player in this cell?
if (x == you.x_pos && y == you.y_pos)
- torment_player(pow, caster);
+ retval = (torment_player(0, caster)) ? 1 : 0;
- // check for monster in cell
+ // Is a monster in this cell?
int mon = mgrd[x][y];
if (mon == NON_MONSTER)
- return 0;
+ return retval;
monsters *monster = &menv[mon];
- if (monster->type == -1)
- return 0;
+ if (invalid_monster(monster) || !mons_near(monster)
+ || mons_res_negative_energy(monster) == 3)
+ {
+ return retval;
+ }
+
+ int hploss = monster->hit_points / 2 - 1;
+
+ if (hploss < 0)
+ hploss = 0;
- if (mons_res_negative_energy( monster ) == 3)
- return 0;
+ behaviour_event(monster, ME_ANNOY, MHITYOU);
+ hurt_monster(monster, hploss);
- monster->hit_points = monster->hit_points / 2 + 1;
- simple_monster_message(monster, " convulses!");
+ if (hploss)
+ {
+ retval = 1;
+ if (monster->hit_points > 0)
+ simple_monster_message(monster, " convulses!");
+ else
+ monster_die(monster, KILL_YOU, 0);
+ }
- return 1;
+ return retval;
}
-void torment(int caster, int tx, int ty)
+int torment(int caster, int x, int y)
{
- apply_area_within_radius(torment_monsters, tx, ty, 0, 8, caster);
-} // end torment()
+ return apply_area_within_radius(torment_monsters, x, y, 0, 8, caster);
+}
static std::string who_banished(const std::string &who)
{
diff --git a/crawl-ref/source/effects.h b/crawl-ref/source/effects.h
index 627d7a5baa..aa6f4a2127 100644
--- a/crawl-ref/source/effects.h
+++ b/crawl-ref/source/effects.h
@@ -100,8 +100,10 @@ void yell(bool force = false);
/* ***********************************************************************
* called from: item_use - spell
* *********************************************************************** */
+int holy_word(int pow, int caster, int x, int y, bool silent);
+
bool holy_word_player(int pow, int caster);
-bool holy_word(int pow, int caster, bool silent = false);
+int holy_word_monsters(int x, int y, int pow, int caster);
// last updated 12may2000 {dlb}
@@ -109,7 +111,7 @@ bool holy_word(int pow, int caster, bool silent = false);
* called from: ability - decks - fight - it_use3 - item_use - mstuff2 -
* spell
* *********************************************************************** */
-void torment( int caster, int tx, int ty );
+int torment(int caster, int x, int y);
bool torment_player(int pow, int caster);
int torment_monsters(int x, int y, int pow, int caster);
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 82bf03b20a..ac369fc4c1 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -4402,30 +4402,32 @@ void read_scroll( int slot )
break;
case SCR_HOLY_WORD:
- {
- int pow = 100;
+ {
+ int pow = 100;
- if (is_good_god(you.religion))
- {
- pow += (you.religion == GOD_SHINING_ONE) ? you.piety :
- you.piety / 2;
- }
+ if (is_good_god(you.religion))
+ {
+ pow += (you.religion == GOD_SHINING_ONE) ? you.piety :
+ you.piety / 2;
+ }
- if (!holy_word(pow, HOLY_WORD_SCROLL, !item_type_known(scroll)))
- {
- canned_msg(MSG_NOTHING_HAPPENS);
- id_the_scroll = false;
- }
+ if (!holy_word(pow, HOLY_WORD_SCROLL, you.x_pos, you.y_pos,
+ !item_type_known(scroll)))
+ {
+ canned_msg(MSG_NOTHING_HAPPENS);
+ id_the_scroll = false;
+ }
- // good gods like this, regardless of whether it damages anything
- if (is_good_god(you.religion))
- {
- you.duration[DUR_PIETY_POOL] += 10;
- if (you.duration[DUR_PIETY_POOL] > 500)
- you.duration[DUR_PIETY_POOL] = 500;
- }
+ // Good gods like this, regardless of whether it damages anything.
+ if (is_good_god(you.religion))
+ {
+ you.duration[DUR_PIETY_POOL] += 10;
+ if (you.duration[DUR_PIETY_POOL] > 500)
+ you.duration[DUR_PIETY_POOL] = 500;
}
break;
+ }
+
default:
mpr("Read a buggy scroll, please report this.");
break;
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 9a83e04003..b80a849057 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -4340,7 +4340,7 @@ static bool _bless_weapon( god_type god, int brand, int colour )
if ( god == GOD_SHINING_ONE )
{
- holy_word( 100, HOLY_WORD_GENERIC, true );
+ holy_word(100, HOLY_WORD_GENERIC, you.x_pos, you.y_pos, true);
// Un-bloodify surrounding squares.
for (int i = -3; i <= 3; i++)
diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc
index 75cdb7f605..00be555070 100644
--- a/crawl-ref/source/spells3.cc
+++ b/crawl-ref/source/spells3.cc
@@ -984,7 +984,7 @@ bool cast_sanctuary(const int power)
you.flash_colour = WHITE;
viewwindow( true, false );
- holy_word( 100, HOLY_WORD_GENERIC, true );
+ holy_word(100, HOLY_WORD_GENERIC, you.x_pos, you.y_pos, true);
#ifndef USE_TILE
delay(1000);
#endif
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 1ef952a95e..bb430e6959 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -1312,7 +1312,7 @@ spret_type your_spells( spell_type spell, int powc, bool allow_fail )
break;
case SPELL_HOLY_WORD:
- holy_word(50, HOLY_WORD_SPELL);
+ holy_word(50, HOLY_WORD_SPELL, you.x_pos, you.y_pos, true);
break;
case SPELL_DETECT_CURSE: