From 52635e528e83419737ee28b01286ecd3df9be11a Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sat, 18 Apr 2009 18:46:56 +0000 Subject: * Fix Xom's piety wrapping around from 0 -> 255. * Fix Xom piety 100 (initial state) favouring bad effects. * Limit tension bonus for good effects to 199. * Add penalty for tension 0, so bad effects become more likely without tension. * Revert order of Xom's amusement to actually match the amusement gain. (Was getting "roars with laughter" for gain of 2, etc.) * Add damage shaving to Deep Dwarf ghosts. * Add 'o' to pickup list commands -> stop prompting, start autoexplore. * Default menu_colour_item_class to true in initfile.cc. * Allow autopickup of chunks in Lich form. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9634 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/docs/options_guide.txt | 2 +- crawl-ref/settings/init.txt | 2 +- crawl-ref/settings/menu_colours.txt | 7 +- crawl-ref/source/debug.cc | 6 +- crawl-ref/source/fight.cc | 1 - crawl-ref/source/initfile.cc | 2 +- crawl-ref/source/itemname.cc | 9 +- crawl-ref/source/itemprop.cc | 6 +- crawl-ref/source/items.cc | 9 +- crawl-ref/source/monplace.cc | 5 +- crawl-ref/source/monstuff.cc | 46 ++++++---- crawl-ref/source/notes.cc | 2 +- crawl-ref/source/ouch.cc | 1 - crawl-ref/source/player.cc | 5 +- crawl-ref/source/religion.cc | 16 ++-- crawl-ref/source/xom.cc | 165 +++++++++++++++++++++++++----------- 16 files changed, 185 insertions(+), 99 deletions(-) diff --git a/crawl-ref/docs/options_guide.txt b/crawl-ref/docs/options_guide.txt index 76c423eb6c..43aeb37c8d 100644 --- a/crawl-ref/docs/options_guide.txt +++ b/crawl-ref/docs/options_guide.txt @@ -1367,7 +1367,7 @@ menu_colour = :: white: menu_colour = notes:white:Reached XP level -menu_colour_prefix_class = false +menu_colour_prefix_class = true Setting this option to true will prefix the string against which menu_colour regexes are matched (not the string displayed) with the item's object type: armour, weapon, wand, etc. diff --git a/crawl-ref/settings/init.txt b/crawl-ref/settings/init.txt index 97030c6679..ddf4d4daf4 100644 --- a/crawl-ref/settings/init.txt +++ b/crawl-ref/settings/init.txt @@ -258,7 +258,7 @@ sort_menus = inv: true : equipped, freshness ##### Colours (messages and menus) ##### # -menu_colour_prefix_class = true +# menu_colour_prefix_class = false # menu_colour_shops = false # Food is colour coded in standard_colours.txt as follows: diff --git a/crawl-ref/settings/menu_colours.txt b/crawl-ref/settings/menu_colours.txt index d6257dc51a..31c44b83d7 100644 --- a/crawl-ref/settings/menu_colours.txt +++ b/crawl-ref/settings/menu_colours.txt @@ -24,7 +24,7 @@ menu = lightmagenta:.*orb.*Zot # Artefacts # -menu = inventory:white:.*artefact.* +menu = white:.*artefact.* #menu = white:.*identified.*artefact.* #menu = lightblue:.*unidentified.*artefact.* @@ -39,11 +39,6 @@ menu = lightblue:(^identified (weapon|armour) .* of ) # Possible egos menu = lightblue:^unidentified .*weapon.*(runed|glowing) menu = lightblue:^unidentified .*armour.*(runed|glowing|embroidered|shiny|dyed) - -: elseif options.menu_colour_prefix_class then -#Possible egos -menu = lightblue:.*weapon.*(runed|glowing) -menu = lightblue:.*armour.*(runed|glowing|embroidered|shiny|dyed) :end # Emergency items diff --git a/crawl-ref/source/debug.cc b/crawl-ref/source/debug.cc index f18f6bbd87..e6ad0aebf0 100644 --- a/crawl-ref/source/debug.cc +++ b/crawl-ref/source/debug.cc @@ -580,7 +580,7 @@ void wizard_create_spec_monster_name() } ghost.species = static_cast(sp_id); - mpr( "Make player ghost which class? ", MSGCH_PROMPT ); + mpr( "Make player ghost which job? ", MSGCH_PROMPT ); get_input_line( input_str, sizeof( input_str ) ); int class_id = get_class_by_abbrev(input_str); @@ -590,7 +590,7 @@ void wizard_create_spec_monster_name() if (class_id == -1) { - mpr("No such class, making it a Fighter."); + mpr("No such job, making it a Fighter."); class_id = JOB_FIGHTER; } ghost.job = static_cast(class_id); @@ -5071,6 +5071,8 @@ void wizard_dismiss_all_monsters(bool force_all) monster_die(monster, KILL_DISMISSED, NON_MONSTER, false, true); } } + // If it was turned off turn autopickup back on. + autotoggle_autopickup(false); return; } diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 0bbd1a3158..f298b1ad60 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -66,7 +66,6 @@ REVISION("$Rev$"); #define NOTE_DEBUG_CHAOS_EFFECTS #endif -#define NOTE_DEBUG_CHAOS_EFFECTS #ifdef NOTE_DEBUG_CHAOS_EFFECTS #include "notes.h" #endif diff --git a/crawl-ref/source/initfile.cc b/crawl-ref/source/initfile.cc index 05b02fca2f..592a237440 100644 --- a/crawl-ref/source/initfile.cc +++ b/crawl-ref/source/initfile.cc @@ -978,7 +978,7 @@ void game_options::reset_options() force_more_message.clear(); sound_mappings.clear(); menu_colour_mappings.clear(); - menu_colour_prefix_class = false; + menu_colour_prefix_class = true; menu_colour_shops = true; message_colour_mappings.clear(); drop_filter.clear(); diff --git a/crawl-ref/source/itemname.cc b/crawl-ref/source/itemname.cc index 2e4c449cd3..c54cbbc748 100644 --- a/crawl-ref/source/itemname.cc +++ b/crawl-ref/source/itemname.cc @@ -24,6 +24,7 @@ REVISION("$Rev$"); #include "externs.h" #include "decks.h" +#include "describe.h" #include "food.h" #include "initfile.h" #include "invent.h" @@ -43,11 +44,8 @@ REVISION("$Rev$"); #include "spl-book.h" #include "state.h" #include "stuff.h" +#include "transfor.h" #include "view.h" -#include "items.h" - - -#include "describe.h" id_arr type_ids; @@ -2613,7 +2611,8 @@ bool is_useless_item(const item_def &item, bool temp) if (item.sub_type == FOOD_CHUNK && (you.has_spell(SPELL_SUBLIMATION_OF_BLOOD) - || you.has_spell(SPELL_SIMULACRUM))) + || you.has_spell(SPELL_SIMULACRUM) + || !temp && you.attribute[ATTR_TRANSFORMATION] == TRAN_LICH)) { return (false); } diff --git a/crawl-ref/source/itemprop.cc b/crawl-ref/source/itemprop.cc index 21fd25c77c..faea323e9a 100644 --- a/crawl-ref/source/itemprop.cc +++ b/crawl-ref/source/itemprop.cc @@ -505,9 +505,11 @@ void do_curse_item( item_def &item, bool quiet ) { amusement *= 2; - // Cursed cloaks prevent you from removing body armour. + // Cursed cloaks prevent you from removing body armour, + // gloves from switching rings. if (item.base_type == OBJ_ARMOUR - && get_armour_slot(item) == EQ_CLOAK) + && (get_armour_slot(item) == EQ_CLOAK + || get_armour_slot(item) == EQ_GLOVES)) { amusement *= 2; } diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index d13e974967..fc6ba2facb 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -1237,7 +1237,7 @@ void pickup() int next; mpr("There are several objects here."); std::string pickup_warning; - while ( o != NON_ITEM ) + while (o != NON_ITEM) { // Must save this because pickup can destroy the item. next = mitm[o].link; @@ -1254,7 +1254,7 @@ void pickup() #ifdef USE_TILE "Left-click to enter menu, or press " #endif - "y/n/a/*?g,/q)"; + "y/n/a/*?g,/q/o)"; mprf(MSGCH_PROMPT, prompt.c_str(), get_menu_colour_prefix_tags(mitm[o], @@ -1271,7 +1271,7 @@ void pickup() break; } - if (keyin == 'q' || keyin == ESCAPE) + if (keyin == 'q' || keyin == ESCAPE || keyin == 'o') break; if (keyin == 'y' || keyin == 'a') @@ -1297,6 +1297,9 @@ void pickup() if (!pickup_warning.empty()) mpr(pickup_warning.c_str()); + + if (keyin == 'o') + start_explore(Options.explore_greedy); } } diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 47ba522857..e2b948b92d 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -1181,9 +1181,10 @@ static int _place_monster_aux(const mgen_data &mg, } if (summoned) + { menv[id].mark_summoned( mg.abjuration_duration, true, mg.summon_type ); - + } menv[id].foe = mg.foe; // Initialise pandemonium demons. @@ -2072,7 +2073,7 @@ void mark_interesting_monst(struct monsters* monster, beh_type behaviour) bool interesting = false; // Unique monsters are always intersting - if ( mons_is_unique(monster->type) ) + if (mons_is_unique(monster->type)) interesting = true; // If it's never going to attack us, then not interesting else if (behaviour == BEH_FRIENDLY) diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index fa827d503b..edee201177 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -1126,7 +1126,7 @@ int monster_die(monsters *monster, killer_type killer, { take_note(Note(NOTE_KILL_MONSTER, monster->type, mons_friendly(monster), - monster->name(DESC_NOCAP_A, true).c_str())); + monster->full_name(DESC_NOCAP_A).c_str())); } // From time to time Trog gives you a little bonus @@ -1979,17 +1979,17 @@ bool monster_polymorph(monsters *monster, monster_type targetc, bool can_see = you.can_see(monster); bool can_see_new = !mons_class_flag(targetc, M_INVIS) || player_see_invis(); + bool need_note = false; + std::string old_name = monster->full_name(DESC_CAP_A); // If old monster is visible to the player, and is interesting, // then note why the interesting monster went away. if (can_see && MONST_INTERESTING(monster)) - { - take_note(Note(NOTE_POLY_MONSTER, monster->type, 0, - monster->name(DESC_CAP_A, true).c_str())); - } + need_note = true; + std::string new_name = ""; if (monster->type == MONS_OGRE && targetc == MONS_TWO_HEADED_OGRE) - str_polymon = " grows a second head!"; + str_polymon = " grows a second head"; else { if (mons_is_shapeshifter(monster)) @@ -2000,17 +2000,20 @@ bool monster_polymorph(monsters *monster, monster_type targetc, str_polymon = " evaporates and reforms as "; if (!can_see_new) - str_polymon += "something you cannot see!"; + { + new_name = "something unseen"; + str_polymon += "something you cannot see"; + } else { str_polymon += mons_type_name(targetc, DESC_NOCAP_A); if (targetc == MONS_PULSATING_LUMP) str_polymon += " of flesh"; - - str_polymon += "!"; } } + str_polymon += "!"; + bool player_messaged = can_see && simple_monster_message(monster, str_polymon.c_str()); @@ -2116,13 +2119,25 @@ bool monster_polymorph(monsters *monster, monster_type targetc, // New monster type might be interesting. mark_interesting_monst(monster); + if (new_name.empty()) + new_name = monster->full_name(DESC_NOCAP_A); + + if (need_note + || can_see && you.can_see(monster) && MONST_INTERESTING(monster)) + { + take_note(Note(NOTE_POLY_MONSTER, 0, 0, old_name.c_str(), + new_name.c_str())); + + if (you.can_see(monster)) + monster->flags |= MF_SEEN; + } // If new monster is visible to player, then we've seen it. if (you.can_see(monster)) { seen_monster(monster); // If the player saw both the beginning and end results of a - // shifter changing, then he/she knows it must be a shifter. + // shifter changing, then s/he knows it must be a shifter. if (can_see && shifter.ench != ENCH_NONE) monster->flags |= MF_KNOWN_MIMIC; } @@ -2680,17 +2695,14 @@ void behaviour_event(monsters *mon, mon_event_type event, int src, break; case ME_SCARE: - // Stationary monsters can't flee. - if (mons_is_stationary(mon)) + // Stationary monsters can't flee, and berserking monsters + // are too enraged. + if (mons_is_stationary(mon) || mon->has_ench(ENCH_BERSERK)) { mon->del_ench(ENCH_FEAR, true, true); break; } - // Berserking monsters don't flee. - if (mon->has_ench(ENCH_BERSERK)) - break; - // Neither do plants or nonliving beings. if (mons_class_holiness(mon->type) == MH_PLANT || mons_class_holiness(mon->type) == MH_NONLIVING) @@ -8888,7 +8900,7 @@ void seen_monster(monsters *monster) { take_note( Note(NOTE_SEEN_MONSTER, monster->type, 0, - monster->name(DESC_NOCAP_A).c_str())); + monster->name(DESC_NOCAP_A, true).c_str())); } } diff --git a/crawl-ref/source/notes.cc b/crawl-ref/source/notes.cc index d1feb6bf07..b7e1cc3c38 100644 --- a/crawl-ref/source/notes.cc +++ b/crawl-ref/source/notes.cc @@ -344,7 +344,7 @@ std::string Note::describe( bool when, bool where, bool what ) const result << "Defeated " << name; break; case NOTE_POLY_MONSTER: - result << name << " changed form"; + result << name << " changed into " << desc; break; case NOTE_GOD_POWER: result << "Acquired " diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index d955dfdfdd..86dda18464 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -890,7 +890,6 @@ void ouch(int dam, int death_source, kill_method_type death_type, { lose_piety(21 + random2(20)); } - return; } } diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index d452d731e5..8663b0f499 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -4203,7 +4203,7 @@ int str_to_species(const std::string &species) } std::string species_name(species_type speci, int level, bool genus, bool adj) -// defaults: false false false +// defaults: false false { std::string res; @@ -5170,6 +5170,9 @@ void contaminate_player(int change, bool controlled, bool status_only) mprf((change > 0) ? MSGCH_WARN : MSGCH_RECOVERY, "You feel %s contaminated with magical energies.", (change > 0) ? "more" : "less" ); + + if (change > 0) + xom_is_stimulated(new_level * 32); } if (new_level >= 1) diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 39ff2b638e..b0bb0dce15 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -85,6 +85,7 @@ REVISION("$Rev$"); # define DEBUG_PIETY 1 #endif +#define DEBUG_PIETY 1 #define PIETY_HYSTERESIS_LIMIT 1 // Item offering messages for the gods: @@ -2670,7 +2671,9 @@ bool did_god_conduct(conduct_type thing_done, int level, bool known, // Holy gods are easier to please this way if (random2(level + 18 - (is_good_god(you.religion) ? 0 : you.experience_level / 2)) > 3) + { piety_change = 1; + } break; default: @@ -3248,7 +3251,7 @@ static void _dock_piety(int piety_loss, int penance) (piety_loss == 1) ? " a little " : (piety_loss < 5) ? " " : (piety_loss < 10) ? " very " - : " extremely " ); + : " extremely " ); } last_piety_lecture = you.num_turns; @@ -5393,8 +5396,7 @@ static bool _yred_slaves_abandon_you() int num_slaves = 0; if (you.religion != GOD_YREDELEMNUL) - reclaim = - apply_to_all_dungeons(_yred_slaves_on_level_abandon_you); + reclaim = apply_to_all_dungeons(_yred_slaves_on_level_abandon_you); else { for (radius_iterator ri(you.pos(), 9); ri; ++ri) @@ -5411,8 +5413,8 @@ static bool _yred_slaves_abandon_you() const int hd = monster->hit_dice; // During penance, followers get a saving throw. - if (random2((you.piety-you.penance[GOD_YREDELEMNUL])/18) + - random2(you.skills[SK_INVOCATIONS]-6) + if (random2((you.piety - you.penance[GOD_YREDELEMNUL])/18) + + random2(you.skills[SK_INVOCATIONS]-6) > random2(hd) + hd + random2(5)) { continue; @@ -5495,8 +5497,8 @@ static bool _beogh_followers_abandon_you() const int hd = monster->hit_dice; // During penance, followers get a saving throw. - if (random2((you.piety-you.penance[GOD_BEOGH])/18) + - random2(you.skills[SK_INVOCATIONS]-6) + if (random2((you.piety - you.penance[GOD_BEOGH])/18) + + random2(you.skills[SK_INVOCATIONS]-6) > random2(hd) + hd + random2(5)) { continue; diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc index 244dcd1eb2..5655e172b7 100644 --- a/crawl-ref/source/xom.cc +++ b/crawl-ref/source/xom.cc @@ -60,6 +60,8 @@ REVISION("$Rev$"); # define DEBUG_GIFTS 1 #endif +#define HALF_MAX_PIETY MAX_PIETY / 2 + // Which spells? First I copied all spells from your_spells(), and then // I filtered some out, especially conjurations. Then I sorted them in // roughly ascending order of power. @@ -70,8 +72,7 @@ static const spell_type _xom_nontension_spells[] = { SPELL_MAGIC_MAPPING, SPELL_DETECT_ITEMS, SPELL_SUMMON_BUTTERFLIES, SPELL_DETECT_CREATURES, SPELL_FLY, SPELL_SPIDER_FORM, - SPELL_OLGREBS_TOXIC_RADIANCE, SPELL_STATUE_FORM, SPELL_ICE_FORM, - SPELL_DRAGON_FORM, SPELL_NECROMUTATION + SPELL_STATUE_FORM, SPELL_ICE_FORM, SPELL_DRAGON_FORM, SPELL_NECROMUTATION }; // Spells to be cast at tension > 0, i.e. usually in battle situations. @@ -96,22 +97,22 @@ static const char *_xom_message_arrays[NUM_XOM_MESSAGE_TYPES][6] = { // XM_NORMAL { - "Xom roars with laughter!", - "Xom thinks this is hilarious!", - "Xom is highly amused!", - "Xom is amused.", + "Xom is interested.", "Xom is mildly amused.", - "Xom is interested." + "Xom is amused.", + "Xom is highly amused!", + "Xom thinks this is hilarious!", + "Xom roars with laughter!" }, // XM_INTRIGUED { - "Xom is fascinated!", - "Xom is very intrigued!", - "Xom is intrigued!", - "Xom is extremely interested.", + "Xom is interested.", "Xom is very interested.", - "Xom is interested." + "Xom is extremely interested.", + "Xom is intrigued!", + "Xom is very intrigued!", + "Xom is fascinated!" } }; @@ -175,11 +176,22 @@ bool xom_is_nice(int tension) if (you.gift_timeout == 0) return (false); - // At high tension Xom is more likely to be nice. - int tension_bonus = (tension <= 0 ? 0 : random2(tension)); + // At high tension Xom is more likely to be nice, + // at zero tension the opposite. + const int tension_bonus + = (tension == -1 ? 0 : + tension == 0 ? -std::min(abs(HALF_MAX_PIETY - you.piety)/2, + you.piety/10) + : std::min((MAX_PIETY - you.piety)/2, + random2(tension))); +#ifdef DEBUG_XOM + mprf(MSGCH_DIAGNOSTICS, + "Xom: tension: %d, piety: %d -> tension bonus = %d", + tension, you.piety, tension_bonus); +#endif // Whether Xom is nice depends largely on his mood (== piety). - return (x_chance_in_y(you.piety + tension_bonus, MAX_PIETY + 1)); + return (x_chance_in_y(you.piety + tension_bonus, MAX_PIETY)); } else // CARD_XOM return coinflip(); @@ -250,19 +262,38 @@ void xom_tick() { // Xom semi-randomly drifts your piety. const std::string old_xom_favour = describe_xom_favour(); - const bool good = you.piety > (MAX_PIETY / 2); - int size = abs(you.piety - 100); + const bool good = (you.piety == HALF_MAX_PIETY? coinflip() + : you.piety > HALF_MAX_PIETY); + int size = abs(you.piety - HALF_MAX_PIETY); + + // Piety slowly drifts towards the extremes. int delta = (x_chance_in_y(511, 1000) ? 1 : -1); size += delta; - you.piety = (MAX_PIETY / 2) + (good ? size : -size); + if (size > HALF_MAX_PIETY) + size = HALF_MAX_PIETY; + + you.piety = HALF_MAX_PIETY + (good ? size : -size); std::string new_xom_favour = describe_xom_favour(); if (old_xom_favour != new_xom_favour) { - // Dampen oscillation across announcement boundaries. + // If we entered another favour state, take a big step into + // the new territory to avoid oscillating favour announcements + // every few turns. size += delta * 8; - you.piety = (MAX_PIETY / 2) + (good ? size : -size); + if (size > HALF_MAX_PIETY) + size = HALF_MAX_PIETY; + + // If size was 0 to begin with it may become negative but that + // doesn't really matter. + you.piety = HALF_MAX_PIETY + (good ? size : -size); } +#ifdef DEBUG_XOM + snprintf(info, INFO_SIZE, "xom_tick(), delta: %d, piety: %d", + delta, you.piety); + take_note(Note(NOTE_MESSAGE, 0, 0, info), true); +#endif + // ...but he gets bored... if (you.gift_timeout > 0 && coinflip()) you.gift_timeout--; @@ -289,7 +320,7 @@ void xom_tick() // If Xom is bored the chances for Xom acting are reversed. if (you.gift_timeout == 0 && x_chance_in_y(5-chance,5)) { - xom_acts(abs(you.piety - MAX_PIETY/2), tension); + xom_acts(abs(you.piety - HALF_MAX_PIETY), tension); return; } else if (you.gift_timeout <= 1 && chance > 0 @@ -314,7 +345,7 @@ void xom_tick() } if (x_chance_in_y(chance, 5)) - xom_acts(abs(you.piety - MAX_PIETY/2), tension); + xom_acts(abs(you.piety - HALF_MAX_PIETY), tension); } } @@ -831,8 +862,11 @@ static bool _choose_chaos_upgrade(const monsters* mon) // Beogh presumably doesn't want Xom messing with his orcs, even if // it would give them a better weapon. - if (mons_species(mon->type) == MONS_ORC) + if (mons_species(mon->type) == MONS_ORC + && (mons_class_flag(mon->type, M_PRIEST) || coinflip())) + { return (false); + } mon_inv_type slots[] = {MSLOT_WEAPON, MSLOT_ALT_WEAPON, MSLOT_MISSILE}; @@ -1262,7 +1296,7 @@ static bool _xom_polymorph_nearby_monster(bool helpful) god_speaks(GOD_XOM, _get_xom_speech(lookup).c_str()); #ifdef NOTE_DEBUG_XOM - std::string old_name = mon->name(DESC_PLAIN); + std::string old_name = mon->full_name(DESC_PLAIN); #endif if (one_chance_in(8) && !mons_is_shapeshifter(mon)) { @@ -1277,7 +1311,7 @@ static bool _xom_polymorph_nearby_monster(bool helpful) #ifdef NOTE_DEBUG_XOM static char poly_buf[120]; snprintf(poly_buf, sizeof(poly_buf), "XOM: polymorph %s -> %s (%s)", - old_name.c_str(), mon->name(DESC_PLAIN, true).c_str(), + old_name.c_str(), mon->full_name(DESC_PLAIN).c_str(), powerup ? "upgrade" : "downgrade"); take_note(Note(NOTE_MESSAGE, 0, 0, poly_buf), true); #endif @@ -1374,8 +1408,8 @@ static bool _xom_rearrange_pieces(int sever) monsters *mon = mons[random2(num_mons)]; swap_with_monster(mon); - // Occasionally confuse said monster. - if (one_chance_in(5)) + // Sometimes confuse said monster. + if (coinflip()) _confuse_monster(*mon, sever); if (num_mons > 1 && x_chance_in_y(sever, 70)) @@ -1397,9 +1431,9 @@ static bool _xom_rearrange_pieces(int sever) mpr("Some monsters swap places."); did_message = true; } - if (one_chance_in(5)) + if (one_chance_in(3)) _confuse_monster(*mons[mon1], sever); - if (one_chance_in(5)) + if (one_chance_in(3)) _confuse_monster(*mons[mon2], sever); } } @@ -2237,6 +2271,14 @@ static bool _xom_player_confusion_effect(int sever) return (rc); } +static bool _valid_floor_grid(coord_def pos) +{ + if (!in_bounds(pos)) + return (false); + + return (grd(pos) == DNGN_FLOOR); +} + static bool _move_stair(coord_def stair_pos, bool away) { dungeon_feature_type feat = grd(stair_pos); @@ -2252,13 +2294,24 @@ static bool _move_stair(coord_def stair_pos, bool away) if (stair_pos == you.pos()) { coord_def new_pos(stair_pos); - int adj_count = 0; - for (adjacent_iterator ai(stair_pos); ai; ++ai) - if (grid_stair_direction(grd(*ai)) == CMD_NO_CMD - && one_chance_in(++adj_count)) - { - new_pos = *ai; - } + // Loop twice through all adjacent grids. In the first round, + // only consider grids whose next neighbour in the direction + // away from the player is also of type floor. If we didn't + // find any matching grid, try again without that restriction. + for (int tries = 0; tries < 2; ++tries) + { + int adj_count = 0; + for (adjacent_iterator ai(stair_pos); ai; ++ai) + if (grd(*ai) == DNGN_FLOOR + && (tries || _valid_floor_grid(*ai + *ai - stair_pos)) + && one_chance_in(++adj_count)) + { + new_pos = *ai; + } + + if (!tries && new_pos != stair_pos) + break; + } if (new_pos == stair_pos) return (false); @@ -2403,10 +2456,7 @@ static bool _repel_stairs() // Should only happen if there are stairs in view. if (stairs_avail.empty()) - { - mpr("No stairs found!"); return (false); - } god_speaks(GOD_XOM, _get_xom_speech("repel stairs").c_str()); @@ -2491,13 +2541,21 @@ static bool _xom_summon_hostiles(int sever) const std::string speech = _get_xom_speech("hostile monster"); // Nasty, but fun. - if (player_weapon_wielded() && one_chance_in(4)) +// if (player_weapon_wielded() && one_chance_in(4)) + if (player_weapon_wielded()) { + const item_def& weapon = *you.weapon(); + const std::string wep_name = weapon.name(DESC_PLAIN); rc = cast_tukimas_dance(100, GOD_XOM, true); #ifdef NOTE_DEBUG_XOM if (rc) - take_note(Note(NOTE_MESSAGE, 0, 0, "XOM: animates weapon"), true); + { + static char wpn_buf[80]; + snprintf(wpn_buf, sizeof(wpn_buf), + "XOM: animates weapon (%s)", wep_name.c_str()); + take_note(Note(NOTE_MESSAGE, 0, 0, wpn_buf), true); + } #endif } else @@ -2677,9 +2735,6 @@ static bool _xom_is_bad(int sever, int tension) mprf(MSGCH_DIAGNOSTICS, "badness: %d, new interest: %d", badness, you.gift_timeout); #endif - const std::string new_xom_favour = describe_xom_favour(); - const std::string msg = "You are now " + new_xom_favour; - god_speaks(you.religion, msg.c_str()); } return (done); } @@ -2886,7 +2941,8 @@ void xom_acts(bool niceness, int sever, int tension) take_note(Note(NOTE_MESSAGE, 0, 0, xom_buf), true); #endif - if (niceness && !one_chance_in(15)) + const bool was_bored = _xom_is_bored(); + if (niceness && !one_chance_in(20)) { // Good stuff. while (!_xom_is_good(sever, tension)) @@ -2895,7 +2951,7 @@ void xom_acts(bool niceness, int sever, int tension) else { #ifdef NOTE_DEBUG_XOM - if (_xom_is_bored()) + if (was_bored) take_note(Note(NOTE_MESSAGE, 0, 0, "XOM is BORED!"), true); #ifdef DEBUG_XOM else if (niceness) @@ -2924,16 +2980,29 @@ void xom_acts(bool niceness, int sever, int tension) } } - if (you.religion == GOD_XOM && one_chance_in(8)) + if (you.religion == GOD_XOM && one_chance_in(5)) { const std::string old_xom_favour = describe_xom_favour(); you.piety = random2(MAX_PIETY+1); const std::string new_xom_favour = describe_xom_favour(); - if (old_xom_favour != new_xom_favour) + if (was_bored || old_xom_favour != new_xom_favour) { const std::string msg = "You are now " + new_xom_favour; god_speaks(you.religion, msg.c_str()); } +#ifdef NOTE_DEBUG_XOM + snprintf(info, INFO_SIZE, "xom_acts(): reroll piety(1/5), piety: %d", + you.piety); + take_note(Note(NOTE_MESSAGE, 0, 0, info), true); +#endif + } + else if (was_bored) + { + // If we didn't reroll at least mention the new favour + // now it's not "BORING thing" anymore. + const std::string new_xom_favour = describe_xom_favour(); + const std::string msg = "You are now " + new_xom_favour; + god_speaks(you.religion, msg.c_str()); } } -- cgit v1.2.3-54-g00ecf