diff options
-rw-r--r-- | crawl-ref/source/acr.cc | 8 | ||||
-rw-r--r-- | crawl-ref/source/misc.cc | 18 | ||||
-rw-r--r-- | crawl-ref/source/misc.h | 4 | ||||
-rw-r--r-- | crawl-ref/source/mon-util.cc | 5 | ||||
-rw-r--r-- | crawl-ref/source/religion.cc | 57 | ||||
-rw-r--r-- | crawl-ref/source/spells3.cc | 64 | ||||
-rw-r--r-- | crawl-ref/source/spells3.h | 5 |
7 files changed, 129 insertions, 32 deletions
diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index d5b40a209c..11512ecb80 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2693,8 +2693,12 @@ static void decrement_durations() Options.tutorial_events[TUT_YOU_ENCHANTED] = tut_slow; } - if (you.duration[DUR_BACKLIGHT] > 0 && !--you.duration[DUR_BACKLIGHT] && !you.backlit()) + // players inside a halo don't lose backlight + if (you.duration[DUR_BACKLIGHT] > 0 && !halo_radius() + && !--you.duration[DUR_BACKLIGHT] && !you.backlit()) + { mpr("You are no longer glowing.", MSGCH_DURATION); + } // Leak piety from the piety pool into actual piety. // Note that changes of religious status without corresponding actions @@ -2884,6 +2888,8 @@ static void world_reacts() check_sanctuary(); + manage_halo(); + run_environment_effects(); if ( !you.cannot_act() && !you.mutation[MUT_BLURRY_VISION] && diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 80636c4bdb..856f91ded9 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -2108,3 +2108,21 @@ void reveal_secret_door(int x, int y) grd[x][y] = grid_is_opaque(door) ? DNGN_CLOSED_DOOR : DNGN_OPEN_DOOR; } + +// Is there a monster in a circle with the given radius, centered on the +// player's position? If so, return the distance to it. Otherwise, +// return -1. +int mons_inside_circle(int posx, int posy, int radius) +{ + if (!inside_level_bounds(posx, posy)) + return -1; + + int dist = distance(posx, posy, you.x_pos, you.y_pos); + if (dist > radius*radius) + return -1; + + if (mgrd[posx][posy] != NON_MONSTER) + return dist; + + return -1; +} diff --git a/crawl-ref/source/misc.h b/crawl-ref/source/misc.h index b967684ac4..aaf4b86f16 100644 --- a/crawl-ref/source/misc.h +++ b/crawl-ref/source/misc.h @@ -125,9 +125,11 @@ int speed_to_duration(int speed); bool scramble(void); -bool interrupt_cmd_repeat( activity_interrupt_type ai, +bool interrupt_cmd_repeat( activity_interrupt_type ai, const activity_interrupt_data &at ); void reveal_secret_door(int x, int y); +int mons_inside_circle(int posx, int posy, int radius); + #endif diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index ef3e325ce2..958f6bcd8d 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -49,6 +49,7 @@ #include "player.h" #include "randart.h" #include "religion.h" +#include "spells3.h" #include "spl-util.h" #include "stuff.h" #include "terrain.h" @@ -4093,6 +4094,10 @@ bool monsters::del_ench(enchant_type ench, bool quiet) if (i == enchantments.end()) return (false); + // monsters inside a halo don't lose backlight + if (ench == ENCH_BACKLIGHT && mons_inside_halo(x, y)) + return (false); + const mon_enchant me = i->second; const enchant_type et = i->first; enchantments.erase(et); diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 9ecb27ed13..e0ac11ea98 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -412,14 +412,21 @@ void dec_penance(god_type god, int val) take_note(Note(NOTE_MOLLIFY_GOD, god)); you.penance[god] = 0; - // When you've worked through all your penance, you get - // another chance to make hostile holy beings neutral. - if (is_good_god(you.religion)) - moral_beings_attitude_change(); + // the halo is once more available + if (god == GOD_SHINING_ONE && you.religion == GOD_SHINING_ONE + && you.piety >= piety_breakpoint(0)) + { + mpr("Your divine halo starts to return!"); + } // bonuses now once more effective if (god == GOD_BEOGH && you.religion == GOD_BEOGH) you.redraw_armour_class = true; + + // When you've worked through all your penance, you get + // another chance to make hostile holy beings neutral. + if (is_good_god(you.religion)) + moral_beings_attitude_change(); } else you.penance[god] -= val; @@ -455,10 +462,13 @@ void inc_penance(god_type god, int val) // orcish bonuses don't apply under penance if (god == GOD_BEOGH) you.redraw_armour_class = true; + // nor does TSO's halo or divine shield else if (god == GOD_SHINING_ONE) { + mpr("Your divine halo starts to fade."); + if (you.duration[DUR_DIVINE_SHIELD]) - { // nor does TSO's divine shield + { mpr("Your divine shield disappears!"); you.duration[DUR_DIVINE_SHIELD] = 0; you.attribute[ATTR_DIVINE_SHIELD] = 0; @@ -1824,6 +1834,12 @@ mprf(MSGCH_DIAGNOSTICS, "Piety increasing by %d (and %d taken from hysteresis)", learned_something_new(TUT_NEW_ABILITY); } + if (you.religion == GOD_SHINING_ONE) + { + if (i == 0) + mpr("A divine halo surrounds you!"); + } + // When you gain a piety level, you get another chance to // make hostile holy beings neutral. if (is_good_god(you.religion)) @@ -1839,16 +1855,16 @@ mprf(MSGCH_DIAGNOSTICS, "Piety increasing by %d (and %d taken from hysteresis)", if (you.piety > 160 && old_piety <= 160) { - // When you gain piety of more than 160, you get another chance - // to make hostile holy beings neutral. - if (is_good_god(you.religion)) - moral_beings_attitude_change(); - if ((you.religion == GOD_SHINING_ONE || you.religion == GOD_LUGONU) && you.num_gifts[you.religion] == 0) { simple_god_message( " will now bless your weapon at an altar...once."); } + + // When you gain piety of more than 160, you get another chance + // to make hostile holy beings neutral. + if (is_good_god(you.religion)) + moral_beings_attitude_change(); } do_god_gift(false); @@ -2139,21 +2155,26 @@ void lose_piety(int pgn) } } - if ( need_water_walking() && !beogh_water_walk() ) + if (you.religion == GOD_SHINING_ONE) { - fall_into_a_pool( you.x_pos, you.y_pos, true, - grd[you.x_pos][you.y_pos] ); + if (i == 0) + mpr("Your divine halo starts to fade."); } - if ( you.religion == GOD_BEOGH ) + if ( need_water_walking() && !beogh_water_walk() ) { - // every piety level change also affects AC from - // orcish gear - you.redraw_armour_class = true; + fall_into_a_pool( you.x_pos, you.y_pos, true, + grd[you.x_pos][you.y_pos] ); } } } } + + if ( you.religion == GOD_BEOGH ) + { + // every piety level change also affects AC from orcish gear + you.redraw_armour_class = true; + } } static bool tso_retribution() @@ -3456,6 +3477,8 @@ void excommunication(god_type new_god) break; case GOD_SHINING_ONE: + mpr("Your divine halo starts to fade."); + if (you.duration[DUR_DIVINE_SHIELD]) { mpr("Your divine shield disappears!"); diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 588795ee8d..670b435169 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -927,26 +927,20 @@ bool cast_sanctuary(const int power) const int pattern = random2(4); int count = 0; int monster = -1; - + for (int x=-radius; x<=radius; x++) for (int y=-radius; y<=radius; y++) { int posx = you.x_pos + x; int posy = you.y_pos + y; - - if (!inside_level_bounds(posx, posy)) - continue; - - int dist = distance(posx, posy, you.x_pos, you.y_pos); - if (dist > radius*radius) - continue; + int dist = mons_inside_circle(posx, posy, radius); // scare all hostile monsters inside sanctuary - if (mgrd[posx][posy] != NON_MONSTER) + if (dist != -1) { monster = mgrd[posx][posy]; monsters *mon = &menv[monster]; - + if (!mons_friendly(mon) && mon->add_ench(mon_enchant(ENCH_FEAR, 0, KC_YOU))) { @@ -954,7 +948,7 @@ bool cast_sanctuary(const int power) count++; } } - + // forming patterns if (pattern == 0 // outward rays && (x == 0 || y == 0 || x == y || x == -y) @@ -976,10 +970,56 @@ bool cast_sanctuary(const int power) simple_monster_message(&menv[monster], " turns to flee the light!"); else if (count > 0) mpr("The monsters scatter in all directions!"); - + return (true); } +int halo_radius() +{ + if (you.religion == GOD_SHINING_ONE && you.piety >= piety_breakpoint(0) + && !you.penance[GOD_SHINING_ONE]) + { + return you.piety / 20; + } + else + return 0; +} + +void manage_halo() +{ + int radius = halo_radius(); + + if (radius == 0) + return; + + int monster = -1; + + if (!you.duration[DUR_BACKLIGHT]) + you.duration[DUR_BACKLIGHT] = 1; + + for (int x=-radius; x<=radius; x++) + for (int y=-radius; y<=radius; y++) + { + int posx = you.x_pos + x; + int posy = you.y_pos + y; + + // affect all monsters inside the halo + if (mons_inside_halo(posx, posy)) + { + monster = mgrd[posx][posy]; + monsters *mon = &menv[monster]; + + if (!mon->has_ench(ENCH_BACKLIGHT)) + mon->add_ench(ENCH_BACKLIGHT); + } + } +} + +bool mons_inside_halo(int posx, int posy) +{ + return (mons_inside_circle(posx, posy, halo_radius()) != -1); +} + void cast_poison_ammo(void) { const int ammo = you.equip[EQ_WEAPON]; diff --git a/crawl-ref/source/spells3.h b/crawl-ref/source/spells3.h index 8972658739..508993da42 100644 --- a/crawl-ref/source/spells3.h +++ b/crawl-ref/source/spells3.h @@ -67,7 +67,10 @@ bool cast_selective_amnesia(bool force); int cast_smiting(int power, dist &); bool remove_sanctuary(bool did_attack = false); void decrease_sanctuary_radius(void); -bool cast_sanctuary(int power); +bool cast_sanctuary(const int power); +int halo_radius(void); +void manage_halo(void); +bool mons_inside_halo(int posx, int posy); // updated 24may2000 {dlb} /* *********************************************************************** |