From e2cbc98a162d37386b3191ccf16c0d64ad7bb1b2 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sun, 18 May 2008 09:40:53 +0000 Subject: Pull code from mon->can_see(target) into a new function mon->see_grid() and use it in the checks for monster/monster visibility. I didn't have the time to test it but it should at least solve part of the problem of monsters firing through walls (if monster visibility is even checked there, which I don't know). Also (as usually), more code cleanup. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@5117 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 6 +- crawl-ref/source/beam.cc | 6 +- crawl-ref/source/decks.cc | 12 ++-- crawl-ref/source/directn.cc | 10 ++-- crawl-ref/source/externs.h | 3 +- crawl-ref/source/items.cc | 10 ++-- crawl-ref/source/mon-util.cc | 34 ++++++++---- crawl-ref/source/mon-util.h | 1 + crawl-ref/source/monplace.cc | 27 +++++---- crawl-ref/source/monstuff.cc | 127 ++++++++++++++++++++++--------------------- crawl-ref/source/mstuff2.cc | 3 - crawl-ref/source/player.cc | 20 ++++--- crawl-ref/source/spells4.cc | 122 ++++++++++++++++++++--------------------- crawl-ref/source/view.cc | 6 +- 14 files changed, 205 insertions(+), 182 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 32d118f992..3280acbe33 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -3727,7 +3727,7 @@ static void _open_door(int move_x, int move_y, bool check_confused) if (you.duration[DUR_BERSERKER]) { - // XXX: better flavor for larger doors? + // XXX: better flavour for larger doors? if (silenced(you.x_pos, you.y_pos)) { mprf("The %s%s flies open!", adj, noun); @@ -4238,8 +4238,8 @@ static void _move_player(int move_x, int move_y) you_attack( targ_monst, true ); you.turn_is_over = true; - // we don't want to create a penalty if there isn't - // supposed to be one + // We don't want to create a penalty if there isn't + // supposed to be one. if (you.berserk_penalty != NO_BERSERK_PENALTY) you.berserk_penalty = 0; diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index ffde1cb65f..9d04a2e73b 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -1304,7 +1304,7 @@ void fire_beam( bolt &pbolt, item_def *item, bool drop_item ) "ty=%d col=%d flav=%d hit=%d dam=%dd%d range=%d", (pbolt.is_beam) ? "beam" : "missile", (pbolt.is_explosion) ? "*" : - (pbolt.is_big_cloud) ? "+" : "", + (pbolt.is_big_cloud) ? "+" : "", (pbolt.is_tracer) ? " tracer" : "", pbolt.source_x, pbolt.source_y, pbolt.target_x, pbolt.target_y, @@ -1321,7 +1321,7 @@ void fire_beam( bolt &pbolt, item_def *item, bool drop_item ) ray_def ray; - if ( pbolt.chose_ray ) + if (pbolt.chose_ray) ray = pbolt.ray; else { @@ -1331,7 +1331,7 @@ void fire_beam( bolt &pbolt, item_def *item, bool drop_item ) 0, true ); } - if ( !pbolt.aimed_at_feet ) + if (!pbolt.aimed_at_feet) ray.advance_through(pbolt.target()); // give chance for beam to affect one cell even if aimed_at_feet. diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index aa83140bd4..2c59b1d8da 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -2308,7 +2308,7 @@ static bool _trowel_card(int power, deck_rarity_type rarity) }; if (create_monster( - mgen_data(RANDOM_ELEMENT(statues), + mgen_data(RANDOM_ELEMENT(statues), BEH_HOSTILE, 0, you.pos(), MHITYOU)) != -1) { mpr("A menacing statue appears!"); @@ -2542,7 +2542,7 @@ static void _summon_any_monster(int power, deck_rarity_type rarity) const bool friendly = (power_level > 0 || !one_chance_in(4)); create_monster( - mgen_data( mon_chosen, + mgen_data( mon_chosen, friendly ? BEH_FRIENDLY : BEH_HOSTILE, 3, coord_def(chosen_x, chosen_y), MHITYOU ) ); @@ -2587,9 +2587,11 @@ static void _summon_dancing_weapon(int power, deck_rarity_type rarity) wpn.plus = random2(4) - 1; wpn.plus2 = random2(4) - 1; wpn.sub_type = (coinflip() ? WPN_LONG_SWORD : WPN_HAND_AXE); - if ( coinflip() ) + if (coinflip()) + { set_item_ego_type(wpn, OBJ_WEAPONS, coinflip() ? SPWPN_FLAMING : SPWPN_FREEZING); + } } else if ( power_level == 2 ) { @@ -2645,7 +2647,7 @@ static void _summon_skeleton(int power, deck_rarity_type rarity) create_monster( mgen_data( - skeltypes[power_level], + skeltypes[power_level], friendly ? BEH_FRIENDLY : BEH_HOSTILE, std::min(power/50,6), you.pos(), @@ -2665,7 +2667,7 @@ static void _summon_ugly(int power, deck_rarity_type rarity) ugly = MONS_UGLY_THING; create_monster( - mgen_data( ugly, + mgen_data( ugly, friendly ? BEH_FRIENDLY : BEH_HOSTILE, std::min(power/50,6), you.pos(), diff --git a/crawl-ref/source/directn.cc b/crawl-ref/source/directn.cc index 1622723094..33d2bb0a2e 100644 --- a/crawl-ref/source/directn.cc +++ b/crawl-ref/source/directn.cc @@ -486,15 +486,15 @@ void direction(dist& moves, targeting_type restricts, bool target_unshifted = Options.target_unshifted_dirs; // Find a default target - if ( Options.default_target && mode == TARG_ENEMY ) + if (Options.default_target && mode == TARG_ENEMY) { skip_iter = true; // skip first iteration...XXX mega-hack - if ( you.prev_targ != MHITNOT && you.prev_targ != MHITYOU ) + if (you.prev_targ != MHITNOT && you.prev_targ != MHITYOU) { const monsters *montarget = &menv[you.prev_targ]; - if ( mons_near(montarget) && player_monster_visible(montarget) - && !mons_friendly(montarget) // not made friendly since then - && _is_target_in_range(montarget->x, montarget->y, range) ) + if (mons_near(montarget) && player_monster_visible(montarget) + && !mons_friendly(montarget) // not made friendly since then + && _is_target_in_range(montarget->x, montarget->y, range)) { found_autotarget = true; moves.tx = montarget->x; diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index ed3f164c87..432b4eee52 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -1208,7 +1208,8 @@ public: bool is_levitating() const; bool invisible() const; bool can_see_invisible() const; - bool visible_to(const actor *looker) const ; + bool visible_to(const actor *looker) const; + bool mon_see_grid(int tx, int ty) const; bool can_see(const actor *target) const; bool is_icy() const; bool paralysed() const; diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index fa1daf4aae..f9f75c581d 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -722,7 +722,7 @@ static int item_name_specialness(const item_def& item) return ( branded ? 1 : 0 ); } - if ( item.base_type == OBJ_MISSILES ) + if (item.base_type == OBJ_MISSILES) return 0; // missiles don't get name descriptors std::string itname = item.name(DESC_PLAIN, false, false, false); @@ -733,14 +733,14 @@ static int item_name_specialness(const item_def& item) const bool heav_runed = itname.find("heavily ") != std::string::npos; const bool item_glows = itname.find("glowing") != std::string::npos; - if ( item_glows || (item_runed && !heav_runed) || - get_equip_desc(item) == ISFLAG_EMBROIDERED_SHINY ) + if (item_glows || item_runed && !heav_runed + || get_equip_desc(item) == ISFLAG_EMBROIDERED_SHINY) { return 1; } - // You can tell artefacts, because they'll have a description which - // rules out anything else. + // You can tell something is an artefacts, because they'll have a + // description which rules out anything else. // XXX Fixedarts and unrandarts might upset the apple-cart, though. if ( is_artefact(item) ) return 2; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 7176e71d60..822f3f2416 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -613,12 +613,21 @@ bool mons_see_invis(const monsters *mon) return (false); } // end mons_see_invis() +bool mon_can_see_monster( const monsters *mon, const monsters *targ ) +{ + if (!mon->mon_see_grid(targ->x, targ->y)) + return false; + + return (mons_monster_visible(mon, targ)); +} + + // This does NOT do line of sight! It checks the targ's visibility // with respect to mon's perception, but doesn't do walls or range. bool mons_monster_visible( const monsters *mon, const monsters *targ ) { if (targ->has_ench(ENCH_SUBMERGED) - || (targ->invisible() && !mons_see_invis(mon))) + || targ->invisible() && !mons_see_invis(mon)) { return (false); } @@ -3564,7 +3573,7 @@ bool monsters::pickup_armour(item_def &item, int near, bool force) if (!mslot_item(mslot) && newAC > 0) return pickup(item, mslot, near); - // XXX: Very simplistic armour evaluation (AC comparison). + // Very simplistic armour evaluation (AC comparison). if (const item_def *existing_armour = slot_item(eq)) { if (!force) @@ -3576,8 +3585,8 @@ bool monsters::pickup_armour(item_def &item, int near, bool force) if (oldAC == newAC) { // Use shopping value as a crude estimate of resistances etc. - // XXX: This is not quite logical as many properties don't - // apply to monsters (e.g. levitation, blink, berserk). + // XXX: This is not really logical as many properties don't + // apply to monsters (e.g. levitation, blink, berserk). int oldval = item_value(*existing_armour); int newval = item_value(item); @@ -5605,6 +5614,15 @@ bool monsters::visible_to(const actor *looker) const } } +bool monsters::mon_see_grid(int tx, int ty) const +{ + if (distance(x, y, tx, ty) > LOS_RADIUS * LOS_RADIUS) + return false; + + // Ignoring clouds for now. + return (num_feats_between(x, y, tx, ty, DNGN_UNSEEN, DNGN_MAXOPAQUE) == 0); +} + bool monsters::can_see(const actor *target) const { if (this == target) @@ -5617,14 +5635,8 @@ bool monsters::can_see(const actor *target) const return mons_near(this); const monsters* mon = dynamic_cast(target); - int tx = mon->x; - int ty = mon->y; - if (distance(x, y, tx, ty) > LOS_RADIUS * LOS_RADIUS) - return false; - - // Ignoring clouds for now. - return (num_feats_between(x, y, tx, ty, DNGN_UNSEEN, DNGN_MAXOPAQUE) == 0); + return mon_see_grid(mon->x, mon->y); } bool monsters::can_mutate() const diff --git a/crawl-ref/source/mon-util.h b/crawl-ref/source/mon-util.h index ef33b70451..d2b50087a4 100644 --- a/crawl-ref/source/mon-util.h +++ b/crawl-ref/source/mon-util.h @@ -410,6 +410,7 @@ mon_itemuse_type mons_itemuse(int mc); * *********************************************************************** */ bool mons_see_invis(const monsters *mon); bool mons_sense_invis(const monsters *mon); +bool mon_can_see_monster( const monsters *mon, const monsters *targ ); bool mons_monster_visible( const monsters *mon, const monsters *targ ); bool mons_player_visible( const monsters *mon ); diff --git a/crawl-ref/source/monplace.cc b/crawl-ref/source/monplace.cc index 91630ca534..f772da69ab 100644 --- a/crawl-ref/source/monplace.cc +++ b/crawl-ref/source/monplace.cc @@ -63,9 +63,10 @@ bool grid_compatible(dungeon_feature_type grid_wanted, // XXX What in Xom's name is DNGN_WATER_STUCK? It looks like an artificial // device to slow down fiery monsters flying over water. if (grid_wanted == DNGN_FLOOR) - return actual_grid >= DNGN_FLOOR - || (!generation - && actual_grid == DNGN_SHALLOW_WATER); + { + return (actual_grid >= DNGN_FLOOR + || !generation && actual_grid == DNGN_SHALLOW_WATER); + } if (grid_wanted >= DNGN_ROCK_WALL && grid_wanted <= DNGN_CLEAR_PERMAROCK_WALL) @@ -1671,7 +1672,7 @@ void mark_interesting_monst(struct monsters* monster, beh_type behaviour) else if (behaviour == BEH_FRIENDLY || behaviour == BEH_GOD_GIFT) interesting = false; // Don't waste time on moname() if user isn't using this option - else if ( Options.note_monsters.size() > 0 ) + else if (Options.note_monsters.size() > 0) { const std::string iname = mons_type_name(monster->type, DESC_NOCAP_A); for (unsigned i = 0; i < Options.note_monsters.size(); ++i) @@ -1683,16 +1684,18 @@ void mark_interesting_monst(struct monsters* monster, beh_type behaviour) } } } - else if ( you.where_are_you == BRANCH_MAIN_DUNGEON && - you.level_type == LEVEL_DUNGEON && - mons_level(monster->type) >= you.your_level + ood_limit() && - mons_level(monster->type) < 99 && - !(monster->type >= MONS_EARTH_ELEMENTAL && - monster->type <= MONS_AIR_ELEMENTAL) - && !mons_class_flag( monster->type, M_NO_EXP_GAIN )) + else if (you.where_are_you == BRANCH_MAIN_DUNGEON + && you.level_type == LEVEL_DUNGEON + && mons_level(monster->type) >= you.your_level + ood_limit() + && mons_level(monster->type) < 99 + && !(monster->type >= MONS_EARTH_ELEMENTAL + && monster->type <= MONS_AIR_ELEMENTAL) + && !mons_class_flag( monster->type, M_NO_EXP_GAIN )) + { interesting = true; + } - if ( interesting ) + if (interesting) monster->flags |= MF_INTERESTING; } diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index 0676537633..d4129a45d0 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -760,10 +760,10 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) // Take note! if (killer != KILL_RESET && killer != KILL_DISMISSED) { - if ( MONST_INTERESTING(monster) - // XXX yucky hack - || monster->type == MONS_PLAYER_GHOST - || monster->type == MONS_PANDEMONIUM_DEMON ) + if (MONST_INTERESTING(monster) + // XXX yucky hack + || monster->type == MONS_PLAYER_GHOST + || monster->type == MONS_PANDEMONIUM_DEMON) { take_note(Note(NOTE_KILL_MONSTER, monster->type, mons_friendly(monster), @@ -775,7 +775,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) if (killer == KILL_YOU && you.duration[DUR_BERSERKER]) { if (you.religion == GOD_TROG - && (!player_under_penance() && you.piety > random2(1000))) + && !player_under_penance() && you.piety > random2(1000)) { int bonus = 3 + random2avg( 10, 2 ); @@ -869,8 +869,8 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) } } - bool death_message = - (!silent && mons_near(monster) && player_monster_visible(monster)); + bool death_message = (!silent && mons_near(monster) + && player_monster_visible(monster)); switch (killer) { @@ -1105,8 +1105,8 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) if (you.religion == GOD_VEHUMET && notice - && (!player_under_penance() - && random2(you.piety) >= piety_breakpoint(0))) + && !player_under_penance() + && random2(you.piety) >= piety_breakpoint(0)) { // Vehumet - only for non-undead servants (coding // convenience, no real reason except that Vehumet @@ -1119,7 +1119,7 @@ void monster_die(monsters *monster, killer_type killer, int i, bool silent) } if (you.religion == GOD_SHINING_ONE - && mons_is_evil_or_unholy(monster) + && mons_is_evil_or_unholy(monster) && !player_under_penance() && random2(you.piety) >= piety_breakpoint(0) && !invalid_monster_index(i)) @@ -1546,8 +1546,8 @@ bool monster_polymorph( monsters *monster, monster_type targetc, } // messaging: {dlb} - bool invis = (mons_class_flag( targetc, M_INVIS ) - || monster->invisible()) && !player_see_invis(); + bool invis = (!player_see_invis() && (mons_class_flag( targetc, M_INVIS ) + || monster->invisible())); if (monster->has_ench(ENCH_GLOWING_SHAPESHIFTER, ENCH_SHAPESHIFTER)) str_polymon = " changes into "; @@ -1648,9 +1648,7 @@ bool monster_polymorph( monsters *monster, monster_type targetc, monster->name(DESC_NOCAP_THE).c_str()); } else - { mpr("All of a sudden the net rips apart!"); - } } } else if (mons_is_insubstantial(monster->type) @@ -1690,7 +1688,9 @@ bool monster_blink(monsters *monster) if (!random_near_space(monster->x, monster->y, nx, ny, false, true)) + { return (false); + } } if (mons_is_caught(monster)) @@ -1731,9 +1731,11 @@ bool random_near_space(int ox, int oy, int &tx, int &ty, bool allow_adjacent, // Skip ray tracing if possible. if (trans_wall_block) + { min_walls_between = num_feats_between(ox, oy, you.x_pos, you.y_pos, DNGN_CLEAR_ROCK_WALL, DNGN_CLEAR_PERMAROCK_WALL); + } int tries = 0; while (tries++ < 150) { @@ -1753,12 +1755,14 @@ bool random_near_space(int ox, int oy, int &tx, int &ty, bool allow_adjacent, tried[dx][dy] = true; if (!in_bounds(tx, ty) - || (!see_grid(tx, ty) && restrict_LOS) + || restrict_LOS && !see_grid(tx, ty) || grd[tx][ty] < DNGN_SHALLOW_WATER || mgrd[tx][ty] != NON_MONSTER - || (tx == you.x_pos && ty == you.y_pos) - || (!allow_adjacent && distance(ox, oy, tx, ty) <= 2)) + || tx == you.x_pos && ty == you.y_pos + || !allow_adjacent && distance(ox, oy, tx, ty) <= 2) + { continue; + } if (!trans_wall_block && !origin_is_player) return (true); @@ -1773,7 +1777,7 @@ bool random_near_space(int ox, int oy, int &tx, int &ty, bool allow_adjacent, // away from the player, since in the absence of tranlucent // walls monsters can blink to places which are not in either // the monster's nor the player's LOS. - if (!see_grid(tx, ty) && !origin_is_player) + if (!origin_is_player && !see_grid(tx, ty)) return (true); // Player can't randomly pass through translucent walls. @@ -2088,7 +2092,7 @@ void behaviour_event( monsters *mon, int event, int src, mon->foe = src; mon->behaviour = BEH_FLEE; - // assume monsters know where to run from, even + // Assume monsters know where to run from, even // if player is invisible. setTarget = true; if (see_grid(mon->x, mon->y)) @@ -2176,8 +2180,8 @@ static void _handle_behaviour(monsters *mon) mon->foe = MHITNOT; } - // change proxPlayer depending on invisibility and standing - // in shallow water + // Change proxPlayer depending on invisibility and standing + // in shallow water. if (proxPlayer && you.invisible()) { if (!mons_player_visible( mon )) @@ -2219,8 +2223,8 @@ static void _handle_behaviour(monsters *mon) if (mon->has_ench(ENCH_BERSERK) && (mon->foe == MHITNOT || isFriendly && mon->foe == MHITYOU)) { - // intelligent monsters prefer to attack the player, - // even when berserking + // Intelligent monsters prefer to attack the player, + // even when berserking. if (!isFriendly && proxPlayer && mons_intel(mon->type) >= I_NORMAL) mon->foe = MHITYOU; else @@ -2234,15 +2238,15 @@ static void _handle_behaviour(monsters *mon) if (mon->foe == monster_index(mon)) mon->foe = MHITNOT; - // friendly and good neutral monsters do not attack other friendly - // and good neutral monsters + // Friendly and good neutral monsters do not attack other friendly + // and good neutral monsters. if (mon->foe != MHITNOT && mon->foe != MHITYOU && wontAttack && mons_wont_attack(&menv[mon->foe])) { mon->foe = MHITNOT; } - // neutral monsters prefer not to attack players, or other neutrals + // Neutral monsters prefer not to attack players, or other neutrals. if (isNeutral && mon->foe != MHITNOT && (mon->foe == MHITYOU || mons_neutral(&menv[mon->foe]))) { @@ -2286,11 +2290,7 @@ static void _handle_behaviour(monsters *mon) { proxFoe = mons_near(mon, mon->foe); - if (!mons_monster_visible( mon, &menv[mon->foe] )) - proxFoe = false; - - // XXX monsters will rely on player LOS -- GDL - if (!see_grid(menv[mon->foe].x, menv[mon->foe].y)) + if (!mon_can_see_monster(mon, &menv[mon->foe])) proxFoe = false; foe_x = menv[mon->foe].x; @@ -2455,7 +2455,7 @@ static void _handle_behaviour(monsters *mon) // direction to the left or right. We're changing this so // wandering monsters at least appear to have some sort of // attention span. -- bwr - if ((mon->x == mon->target_x && mon->y == mon->target_y) + if (mon->x == mon->target_x && mon->y == mon->target_y || one_chance_in(20) || testbits( mon->flags, MF_BATTY )) { @@ -2556,7 +2556,7 @@ static bool _mons_check_set_foe(monsters *mon, int x, int y, monsters *foe = &menv[mgrd[x][y]]; if (foe != mon - && mons_monster_visible(mon, foe) + && mon_can_see_monster(mon, foe) && (mons_friendly(foe) != friendly || (neutral && !mons_neutral(foe)))) { @@ -2651,6 +2651,11 @@ monsters *choose_random_monster_on_level(int weight, // monster (something like MF_DEITY_PREFERRED) and // use that instead of checking the name, given // that other monsters can also have names. + + // True, but it's currently only used for orcs, and + // Blork and Urug also being preferred to non-named orcs + // is fine, I think. Once more gods name followers (and + // prefer them) that should be changed, of course. (jpeg) if (prefer_named && mon->is_named()) { mons_count += 2; @@ -2840,19 +2845,19 @@ static void _handle_nearby_ability(monsters *monster) if (monster_can_submerge(monster, grd[monster->x][monster->y]) && !player_beheld_by(monster) // no submerging if player entranced && (one_chance_in(5) - || ((grid_distance( monster->x, monster->y, - you.x_pos, you.y_pos ) > 1 - // FIXME This is better expressed as a - // function such as - // monster_has_ranged_attack: - && monster->type != MONS_ELECTRICAL_EEL - && monster->type != MONS_LAVA_SNAKE - && (monster->type != MONS_MERMAID - || you.species == SP_MERFOLK) - // Don't submerge if we just unsubmerged for - // the sake of shouting. - && monster->seen_context != "bursts forth shouting" - && !one_chance_in(20)) ) + || grid_distance( monster->x, monster->y, + you.x_pos, you.y_pos ) > 1 + // FIXME This is better expressed as a + // function such as + // monster_has_ranged_attack: + && monster->type != MONS_ELECTRICAL_EEL + && monster->type != MONS_LAVA_SNAKE + && (monster->type != MONS_MERMAID + || you.species == SP_MERFOLK) + // Don't submerge if we just unsubmerged for + // the sake of shouting. + && monster->seen_context != "bursts forth shouting" + && !one_chance_in(20) || monster->hit_points <= monster->max_hit_points / 2 || env.cgrid[monster->x][monster->y] != EMPTY_CLOUD)) { @@ -3305,7 +3310,8 @@ static bool _handle_special_ability(monsters *monster, bolt & beem) // won't sing if either of you silenced, or it's friendly or confused if (monster->has_ench(ENCH_CONFUSION) || mons_friendly(monster) - || silenced(monster->x, monster->y) || silenced(you.x_pos, you.y_pos)) + || silenced(monster->x, monster->y) + || silenced(you.x_pos, you.y_pos)) { break; } @@ -3489,11 +3495,11 @@ static bool _handle_potion(monsters *monster, bolt & beem) beem.colour = MAGENTA; // Friendly monsters won't go invisible if the player // can't see invisible. We're being nice. - if ( mons_friendly(monster) && !player_see_invis(false) ) + if (mons_friendly(monster) && !player_see_invis(false)) break; } - // allow monsters to drink these when player in sight (jpeg) + // Allow monsters to drink these when player in sight. (jpeg) simple_monster_message(monster, " drinks a potion."); mons_ench_f2(monster, beem); imbibed = true; @@ -3533,7 +3539,7 @@ static bool _handle_reaching(monsters *monster) { if (monster->foe == MHITYOU) { - // this check isn't redundant -- player may be invisible. + // This check isn't redundant -- player may be invisible. if (monster->target_pos() == you.pos() && see_grid_no_trans(monster->pos())) { @@ -3564,7 +3570,7 @@ static bool _handle_reaching(monsters *monster) } } - // Player saw the item reach + // Player saw the item reach. if (ret && !is_artefact(mitm[wpn]) && mons_near(monster) && player_monster_visible(monster)) { @@ -4221,7 +4227,7 @@ static bool _handle_spell( monsters *monster, bolt & beem ) if (!finalAnswer) { - // if nothing found by now, safe friendlies will rarely cast + // If nothing found by now, safe friendlies will rarely cast. if (mons_friendly(monster) && !mon_enemies_around(monster) && !one_chance_in(8)) { @@ -4317,7 +4323,7 @@ static bool _handle_spell( monsters *monster, bolt & beem ) spellOK = false; } } - else if (!mons_monster_visible( monster, &menv[monster->foe] )) + else if (!mon_can_see_monster(monster, &menv[monster->foe])) { spellOK = false; } @@ -5822,11 +5828,8 @@ bool _mon_can_move_to_pos(const monsters *monster, const int count_x, return false; } - if (monster->type == MONS_WANDERING_MUSHROOM - && see_grid(targ_x, targ_y)) - { + if (monster->type == MONS_WANDERING_MUSHROOM && see_grid(targ_x, targ_y)) return false; - } // Water elementals avoid fire and heat if (monster->type == MONS_WATER_ELEMENTAL @@ -6739,16 +6742,16 @@ static spell_type _map_wand_to_mspell(int wand_type) void seen_monster(monsters *monster) { - if ( monster->flags & MF_SEEN ) + if (monster->flags & MF_SEEN) return; // First time we've seen this particular monster monster->flags |= MF_SEEN; - if ( !mons_is_mimic(monster->type) - && MONST_INTERESTING(monster) - && monster->type != MONS_PANDEMONIUM_DEMON - && monster->type != MONS_PLAYER_GHOST ) + if (!mons_is_mimic(monster->type) + && MONST_INTERESTING(monster) + && monster->type != MONS_PANDEMONIUM_DEMON + && monster->type != MONS_PLAYER_GHOST) { take_note( Note(NOTE_SEEN_MONSTER, monster->type, 0, diff --git a/crawl-ref/source/mstuff2.cc b/crawl-ref/source/mstuff2.cc index d728368c38..8370a35508 100644 --- a/crawl-ref/source/mstuff2.cc +++ b/crawl-ref/source/mstuff2.cc @@ -50,9 +50,6 @@ static int _monster_abjuration(const monsters *mons, bool test); -// XXX: must fix species abils to not use duration 15 -// -- ummm ... who wrote this? {dlb} - // NB: only works because grid location already verified // to be some sort of trap prior to function call: {dlb} void mons_trap(struct monsters *monster) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index b76c36349c..7fdcf0a035 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -4931,8 +4931,8 @@ bool poison_player( int amount, bool force ) if (you.duration[DUR_POISONING] > old_value) { - // XXX: which message channel for this message? - mprf("You are %spoisoned.", (old_value > 0) ? "more " : "" ); + mprf(MSGCH_WARN, "You are %spoisoned.", + (old_value > 0) ? "more " : "" ); learned_something_new(TUT_YOU_POISON); } return true; @@ -4975,9 +4975,9 @@ bool confuse_player( int amount, bool resistable ) if (you.duration[DUR_CONF] > old_value) { - // XXX: which message channel for this message? you.check_awaken(500); - mprf("You are %sconfused.", (old_value > 0) ? "more " : "" ); + mprf(MSGCH_WARN, "You are %sconfused.", + (old_value > 0) ? "more " : "" ); learned_something_new(TUT_YOU_ENCHANTED); xom_is_stimulated(you.duration[DUR_CONF] - old_value); @@ -5950,9 +5950,9 @@ void player::attacking(actor *other) pet_target = monster_index(mons); } - if (mutation[MUT_BERSERK] && - (random2(100) < (mutation[MUT_BERSERK] * 10) - 5) - || _equipment_make_berserk()) + if (mutation[MUT_BERSERK] + && (random2(100) < (mutation[MUT_BERSERK] * 10) - 5) + || _equipment_make_berserk()) { go_berserk(false); } @@ -5982,15 +5982,17 @@ bool player::can_go_berserk(bool verbose) const { if (verbose) mpr("You're too exhausted to go berserk."); + // or else they won't notice -- no message here return (false); } - if (you.is_undead && - (you.species != SP_VAMPIRE || you.hunger_state <= HS_SATIATED)) + if (you.is_undead + && (you.is_undead != US_SEMI_UNDEAD || you.hunger_state <= HS_SATIATED)) { if (verbose) mpr("You cannot raise a blood rage in your lifeless body."); + // or else you won't notice -- no message here return (false); } diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 8b914ad0fe..46b099e5cc 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -589,7 +589,7 @@ void cast_summon_dragon(int pow) const bool friendly = (random2(pow) > 5); if (create_monster( - mgen_data( MONS_DRAGON, + mgen_data( MONS_DRAGON, friendly ? BEH_FRIENDLY : BEH_HOSTILE, 3, you.pos(), friendly ? you.pet_target : MHITYOU )) != -1) @@ -1974,17 +1974,17 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike //FIXME: if (player typed '>' to attack floor) goto do_terrain; blast.beam_source = MHITYOU; - blast.thrower = KILL_YOU; + blast.thrower = KILL_YOU; blast.aux_source.clear(); - blast.ex_size = 1; // default - blast.type = '#'; - blast.colour = 0; + blast.ex_size = 1; // default + blast.type = '#'; + blast.colour = 0; blast.set_target(beam); - blast.source_x = you.x_pos; - blast.source_y = you.y_pos; - blast.is_tracer = false; - blast.flavour = BEAM_FRAG; - blast.hit = AUTOMATIC_HIT; + blast.source_x = you.x_pos; + blast.source_y = you.y_pos; + blast.is_tracer = false; + blast.flavour = BEAM_FRAG; + blast.hit = AUTOMATIC_HIT; // Number of dice vary... 3 is easy/common, but it can get as high as 6. blast.damage = dice_def( 0, 5 + pow / 10 ); @@ -2009,11 +2009,11 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike case MONS_ICE_BEAST: case MONS_SIMULACRUM_SMALL: case MONS_SIMULACRUM_LARGE: - explode = true; - blast.name = "icy blast"; - blast.colour = WHITE; + explode = true; + blast.name = "icy blast"; + blast.colour = WHITE; blast.damage.num = 2; - blast.flavour = BEAM_ICE; + blast.flavour = BEAM_ICE; if (player_hurt_monster(mon, roll_dice( blast.damage ))) blast.damage.num += 1; break; @@ -2058,9 +2058,9 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike case MONS_IRON_GOLEM: case MONS_METAL_GARGOYLE: - explode = true; - blast.name = "blast of metal fragments"; - blast.colour = CYAN; + explode = true; + blast.name = "blast of metal fragments"; + blast.colour = CYAN; blast.damage.num = 4; if (player_hurt_monster(mon, roll_dice( blast.damage ))) blast.damage.num += 2; @@ -2070,10 +2070,10 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike case MONS_STONE_GOLEM: case MONS_EARTH_ELEMENTAL: case MONS_GARGOYLE: - explode = true; - blast.ex_size = 2; - blast.name = "blast of rock fragments"; - blast.colour = BROWN; + explode = true; + blast.ex_size = 2; + blast.name = "blast of rock fragments"; + blast.colour = BROWN; blast.damage.num = 3; if (player_hurt_monster(mon, roll_dice( blast.damage ))) blast.damage.num += 1; @@ -2081,7 +2081,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike case MONS_SILVER_STATUE: case MONS_ORANGE_STATUE: - explode = true; + explode = true; blast.ex_size = 2; if (menv[mon].type == MONS_SILVER_STATUE) { @@ -2107,10 +2107,10 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike break; case MONS_CRYSTAL_GOLEM: - explode = true; - blast.ex_size = 2; - blast.name = "blast of crystal shards"; - blast.colour = WHITE; + explode = true; + blast.ex_size = 2; + blast.name = "blast of crystal shards"; + blast.colour = WHITE; blast.damage.num = 4; if (player_hurt_monster(mon, roll_dice( blast.damage ))) blast.damage.num += 2; @@ -2160,7 +2160,7 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike explode = true; - blast.name = "blast of rock fragments"; + blast.name = "blast of rock fragments"; blast.damage.num = 3; if (blast.colour == 0) blast.colour = LIGHTGREY; @@ -2168,17 +2168,17 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike if (okay_to_dest && (grid == DNGN_ORCISH_IDOL || grid == DNGN_GRANITE_STATUE - || (pow >= 40 && grid == DNGN_ROCK_WALL && one_chance_in(3)) - || (pow >= 40 && grid == DNGN_CLEAR_ROCK_WALL - && one_chance_in(3)) - || (pow >= 60 && grid == DNGN_STONE_WALL && one_chance_in(10)) - || (pow >= 60 && grid == DNGN_CLEAR_STONE_WALL && - one_chance_in(10)) )) + || pow >= 40 && grid == DNGN_ROCK_WALL && one_chance_in(3) + || pow >= 40 && grid == DNGN_CLEAR_ROCK_WALL + && one_chance_in(3) + || pow >= 60 && grid == DNGN_STONE_WALL && one_chance_in(10) + || pow >= 60 && grid == DNGN_CLEAR_STONE_WALL + && one_chance_in(10))) { // terrain blew up real good: - blast.ex_size = 2; + blast.ex_size = 2; grd[beam.tx][beam.ty] = DNGN_FLOOR; - debris = DEBRIS_ROCK; + debris = DEBRIS_ROCK; } break; @@ -2187,10 +2187,10 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike // case DNGN_METAL_WALL: - what = "metal wall"; - blast.colour = CYAN; - explode = true; - blast.name = "blast of metal fragments"; + what = "metal wall"; + blast.colour = CYAN; + explode = true; + blast.name = "blast of metal fragments"; blast.damage.num = 4; if (okay_to_dest && pow >= 80 && random2(500) < pow / 5) @@ -2206,15 +2206,14 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike // case DNGN_GREEN_CRYSTAL_WALL: // crystal -- large & nasty explosion - what = "crystal wall"; - blast.colour = GREEN; - explode = true; - blast.ex_size = 2; - blast.name = "blast of crystal shards"; + what = "crystal wall"; + blast.colour = GREEN; + explode = true; + blast.ex_size = 2; + blast.name = "blast of crystal shards"; blast.damage.num = 5; - if (okay_to_dest - && grid == DNGN_GREEN_CRYSTAL_WALL && coinflip()) + if (okay_to_dest && grid == DNGN_GREEN_CRYSTAL_WALL && coinflip()) { blast.ex_size = coinflip() ? 3 : 2; grd[beam.tx][beam.ty] = DNGN_FLOOR; @@ -2239,10 +2238,10 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike // undiscovered traps appear as exploding from the floor -- bwr what = ((grid == DNGN_UNDISCOVERED_TRAP) ? "floor" : "trap"); - explode = true; - hole = false; // to hit monsters standing on traps - blast.name = "blast of fragments"; - blast.colour = env.floor_colour; // in order to blend in + explode = true; + hole = false; // to hit monsters standing on traps + blast.name = "blast of fragments"; + blast.colour = env.floor_colour; // in order to blend in blast.damage.num = 2; // Exploded traps are nonfunctional, ammo is also ruined -- bwr @@ -2265,10 +2264,10 @@ void cast_fragmentation(int pow) // jmf: ripped idea from airstrike // fall-through case DNGN_STONE_ARCH: // floor -- small explosion - explode = true; - hole = false; // to hit monsters standing on doors - blast.name = "blast of rock fragments"; - blast.colour = LIGHTGREY; + explode = true; + hole = false; // to hit monsters standing on doors + blast.name = "blast of rock fragments"; + blast.colour = LIGHTGREY; blast.damage.num = 2; break; @@ -2317,7 +2316,7 @@ void cast_twist(int pow) // Get target, using DIR_TARGET for targetting only, // since we don't use fire_beam() for this spell. - if ( !spell_direction(targ, tmp, DIR_TARGET) ) + if (!spell_direction(targ, tmp, DIR_TARGET)) return; const int mons = mgrd[ targ.tx ][ targ.ty ]; @@ -2350,10 +2349,10 @@ void cast_twist(int pow) bool cast_portal_projectile(int pow, bolt& beam) { - if ( pow > 50 ) + if (pow > 50) pow = 50; - if ( grid_is_solid(beam.target_x, beam.target_y) ) + if (grid_is_solid(beam.target_x, beam.target_y)) { mpr("You can't shoot at gazebos."); return false; @@ -2368,18 +2367,19 @@ bool cast_portal_projectile(int pow, bolt& beam) int idx; const item_def* item; you.m_quiver->get_desired_item(&item, &idx); - if ( item == NULL ) + if (item == NULL) { mpr("No suitable missiles."); return false; } - else if ( idx == -1 ) + else if (idx == -1) { mpr("No missiles left."); return false; } - throw_it( beam, idx, true, random2(pow/4) ); + throw_it(beam, idx, true, random2(pow/4)); + return true; } @@ -2405,7 +2405,7 @@ void cast_far_strike(int pow) // Get target, using DIR_TARGET for targetting only, // since we don't use fire_beam() for this spell. - if ( !spell_direction(targ, tmp, DIR_TARGET) ) + if (!spell_direction(targ, tmp, DIR_TARGET)) return; // Get the target monster... diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index da1bbab112..2dfb5b73cb 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -2972,9 +2972,11 @@ static void _draw_level_map(int start_x, int start_y, bool travel_mode) // XXX: This is a horrible hack. screen_buffer_t &bc = buffer2[bufcount2]; unsigned char ch = is_waypoint(c.x, c.y); - if (ch && (bc == get_sightmap_char(DNGN_FLOOR) || - bc == get_magicmap_char(DNGN_FLOOR))) + if (ch && (bc == get_sightmap_char(DNGN_FLOOR) + || bc == get_magicmap_char(DNGN_FLOOR))) + { bc = ch; + } } } -- cgit v1.2.3-54-g00ecf