From c07f2c46323c57f9d5699293e3e4458d5bbacde5 Mon Sep 17 00:00:00 2001 From: haranp Date: Fri, 3 Oct 2008 20:00:42 +0000 Subject: Some cleanup (replacing you.duration[DUR_CONF] with you.confused()) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7108 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/abl-show.cc | 4 ++-- crawl-ref/source/acr.cc | 17 +++++++++-------- crawl-ref/source/beam.cc | 2 +- crawl-ref/source/fight.cc | 2 +- crawl-ref/source/it_use3.cc | 14 +++++--------- crawl-ref/source/item_use.cc | 10 +++++----- crawl-ref/source/misc.cc | 4 ++-- crawl-ref/source/output.cc | 6 +++--- crawl-ref/source/player.cc | 8 ++++---- crawl-ref/source/spells1.cc | 6 +++--- crawl-ref/source/spells3.cc | 2 +- crawl-ref/source/spl-book.cc | 2 +- crawl-ref/source/spl-cast.cc | 2 +- crawl-ref/source/traps.cc | 2 +- crawl-ref/source/travel.cc | 2 +- 15 files changed, 40 insertions(+), 43 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index a7b28f2bfe..446709cbfe 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -442,7 +442,7 @@ static talent _get_talent(ability_type ability, bool check_confused) if (check_confused) { const ability_def &abil = get_ability_def(result.which); - if (you.duration[DUR_CONF] && !testbits(abil.flags, ABFLAG_CONF_OK)) + if (you.confused() && !testbits(abil.flags, ABFLAG_CONF_OK)) { result.which = ABIL_NON_ABILITY; return result; @@ -856,7 +856,7 @@ bool activate_ability() return (false); } - if (you.duration[DUR_CONF]) + if (you.confused()) { talents = your_talents(true); if (talents.empty()) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 0ebc0bec8e..0fdc0f8a0c 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -674,6 +674,7 @@ static void _do_wizard_command(int wiz_command, bool silent_fail) you.duration[DUR_CONF] = 0; you.duration[DUR_POISONING] = 0; set_hp( abs(you.hp_max), false ); + set_mp( you.max_magic_points, false); set_hunger( 10999, true ); you.redraw_hit_points = true; break; @@ -1645,7 +1646,7 @@ static bool _toggle_flag( bool* flag, const char* flagname ) static bool _stairs_check_beheld() { - if (you.duration[DUR_BEHELD] && !you.duration[DUR_CONF]) + if (you.duration[DUR_BEHELD] && !you.confused()) { mprf("You cannot move away from %s!", menv[you.beheld_by[0]].name(DESC_NOCAP_THE, true).c_str()); @@ -3460,7 +3461,7 @@ static void _open_door(coord_def move, bool check_confused) } // If there's only one door to open, don't ask. - if ((!check_confused || !you.duration[DUR_CONF]) && move.origin()) + if ((!check_confused || !you.confused()) && move.origin()) { if (_check_adjacent(DNGN_CLOSED_DOOR, move) == 0) { @@ -3469,7 +3470,7 @@ static void _open_door(coord_def move, bool check_confused) } } - if (check_confused && you.duration[DUR_CONF] && !one_chance_in(3)) + if (check_confused && you.confused() && !one_chance_in(3)) { move.x = random2(3) - 1; move.y = random2(3) - 1; @@ -3642,7 +3643,7 @@ static void _close_door(coord_def move) coord_def doorpos; // If there's only one door to close, don't ask. - if (!you.duration[DUR_CONF] && move.origin()) + if (!you.confused() && move.origin()) { int num = _check_adjacent(DNGN_OPEN_DOOR, move); if (num == 0) @@ -3657,7 +3658,7 @@ static void _close_door(coord_def move) } } - if (you.duration[DUR_CONF] && !one_chance_in(3)) + if (you.confused() && !one_chance_in(3)) { move.x = random2(3) - 1; move.y = random2(3) - 1; @@ -4045,7 +4046,7 @@ static void _move_player(coord_def move) } // When confused, sometimes make a random move - if (you.duration[DUR_CONF]) + if (you.confused()) { if (!one_chance_in(3)) { @@ -4076,14 +4077,14 @@ static void _move_player(coord_def move) const bool can_swap_places = targ_monst != NON_MONSTER && !mons_is_stationary(&menv[targ_monst]) && (mons_wont_attack(&menv[targ_monst]) - && !you.duration[DUR_CONF] + && !you.confused() || is_sanctuary(you.pos()) && is_sanctuary(targ)); // You cannot move away from a mermaid but you CAN fight monsters on // neighbouring squares. monsters *beholder = NULL; - if (you.duration[DUR_BEHELD] && !you.duration[DUR_CONF]) + if (you.duration[DUR_BEHELD] && !you.confused()) { for (unsigned int i = 0; i < you.beheld_by.size(); i++) { diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index cafdde92a4..caf4bcd426 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -577,7 +577,7 @@ bool player_tracer( zap_type ztype, int power, bolt &pbolt, int range) { // Non-controlleable during confusion. // (We'll shoot in a different direction anyway.) - if (you.duration[DUR_CONF]) + if (you.confused()) return (true); _beam_set_default_values(pbolt, power); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 47ce1aac54..8e1d8623bc 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -4089,7 +4089,7 @@ int melee_attack::mons_to_hit() static bool wielded_weapon_check(const item_def *weapon) { bool result = true; - if (!you.received_weapon_warning && !you.duration[DUR_CONF] + if (!you.received_weapon_warning && !you.confused() && (weapon && weapon->base_type != OBJ_STAVES && (weapon->base_type != OBJ_WEAPONS || is_range_weapon(*weapon)) || you.attribute[ATTR_WEAPON_SWAP_INTERRUPTED])) diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index e3ffee2d08..c38df3aa6f 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -729,13 +729,12 @@ static bool efreet_flask(void) static bool ball_of_seeing(void) { - int use = 0; bool ret = false; mpr("You gaze into the crystal ball."); - use = (!you.duration[DUR_CONF] ? random2(you.skills[SK_EVOCATIONS] * 6) - : random2(5)); + int use = (!you.confused() ? random2(you.skills[SK_EVOCATIONS] * 6) + : random2(5)); if (use < 2) { @@ -1016,14 +1015,12 @@ static bool box_of_beasts() static bool ball_of_energy(void) { - int use = 0; - int proportional = 0; - bool ret = false; mpr("You gaze into the crystal ball."); - use = ((!you.duration[DUR_CONF]) ? random2(you.skills[SK_EVOCATIONS] * 6) : random2(6)); + int use = ((!you.confused()) ? random2(you.skills[SK_EVOCATIONS] * 6) + : random2(6)); if (use < 2 || you.max_magic_points == 0) { @@ -1041,8 +1038,7 @@ static bool ball_of_energy(void) } else { - proportional = you.magic_points * 100; - proportional /= you.max_magic_points; + int proportional = (you.magic_points * 100) / you.max_magic_points; if (random2avg(77 - you.skills[SK_EVOCATIONS] * 2, 4) > proportional || one_chance_in(25)) diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 66eec08c36..dedab92eac 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1915,7 +1915,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, pbolt.range = max_range; // Don't do the tracing when using Portaled Projectile, or when confused. - if (!teleport && !you.duration[DUR_CONF]) + if (!teleport && !you.confused()) { // Init tracer variables. pbolt.foe_count = pbolt.fr_count = 0; @@ -1964,7 +1964,7 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, init_stack_blood_potions(item, val); } - if (you.duration[DUR_CONF]) + if (you.confused()) { thr.isTarget = true; thr.target = you.pos() + coord_def(random2(13)-6, random2(13)-6); @@ -3517,7 +3517,7 @@ void zap_wand( int slot ) } - if (you.duration[DUR_CONF]) + if (you.confused()) { zap_wand.target = you.pos() + coord_def(random2(13)-6, random2(13)-6); } @@ -4346,7 +4346,7 @@ void read_scroll( int slot ) // Decrement and handle inventory if any scroll other than paper {dlb}: const scroll_type which_scroll = static_cast(scroll.sub_type); if (which_scroll != SCR_PAPER - && (which_scroll != SCR_IMMOLATION || you.duration[DUR_CONF])) + && (which_scroll != SCR_IMMOLATION || you.confused())) { mpr("As you read the scroll, it crumbles to dust."); // Actual removal of scroll done afterwards. -- bwr @@ -4358,7 +4358,7 @@ void read_scroll( int slot ) // Scrolls of paper are also exempted from this handling {dlb}: if (which_scroll != SCR_PAPER) { - if (you.duration[DUR_CONF]) + if (you.confused()) { random_uselessness(item_slot); dec_inv_item_quantity( item_slot, 1 ); diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 1e85627792..212636c8ca 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -1487,7 +1487,7 @@ void up_stairs(dungeon_feature_type force_stair, // the overloaded character makes an attempt... so we're doing this // check before that one. -- bwr if (!player_is_airborne() - && you.duration[DUR_CONF] + && you.confused() && old_level_type == LEVEL_DUNGEON && stair_find >= DNGN_STONE_STAIRS_UP_I && stair_find <= DNGN_STONE_STAIRS_UP_III @@ -1923,7 +1923,7 @@ void down_stairs( int old_level, dungeon_feature_type force_stair, mprf("Welcome back to %s!", branches[you.where_are_you].longname); if (!player_is_airborne() - && you.duration[DUR_CONF] + && you.confused() && !grid_is_escape_hatch(stair_find) && force_stair != DNGN_ENTER_ABYSS && random2(100) > you.dex) diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 72a227b1a6..242f64f329 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -681,7 +681,7 @@ static void _get_status_lights(std::vector& out) out.push_back(status_light(BLUE, "Blade")); } - if (you.duration[DUR_CONF]) + if (you.confused()) { out.push_back(status_light(RED, "Conf")); } @@ -2132,13 +2132,13 @@ std::string _status_mut_abilities() if (you.duration[DUR_INVIS]) text += "invisible, "; - if (you.duration[DUR_CONF]) + if (you.confused()) text += "confused, "; // How exactly did you get to show the status? // It's not so unreasonable anymore now that the new overview screen is // dumped. When the player dies while paralysed it's important information. - if (you.duration[DUR_PARALYSIS]) + if (you.paralysed()) text += "paralysed, "; if (you.duration[DUR_PETRIFIED]) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index fe6dadca51..ebd6b2d28b 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -116,7 +116,7 @@ bool move_player_to_grid( const coord_def& p, bool stepped, bool allow_shift, || mons_is_submerged( &menv[ mgrd(p) ]))); const int cloud = env.cgrid(p); - if (cloud != EMPTY_CLOUD && !you.duration[DUR_CONF]) + if (cloud != EMPTY_CLOUD && !you.confused()) { const cloud_type ctype = env.cloud[ cloud ].type; // Don't prompt if already in a cloud of the same type. @@ -225,7 +225,7 @@ bool move_player_to_grid( const coord_def& p, bool stepped, bool allow_shift, // lava and dangerous deep water (ie not merfolk) const coord_def entry = (stepped) ? you.pos() : p; - if (stepped && !force && !you.duration[DUR_CONF]) + if (stepped && !force && !you.confused()) { canned_msg(MSG_UNTHINKING_ACT); return (false); @@ -3544,7 +3544,7 @@ int check_stealth(void) if (you.burden_state > BS_UNENCUMBERED) stealth /= you.burden_state; - if (you.duration[DUR_CONF]) + if (you.confused()) stealth /= 3; const int arm = you.equip[EQ_BODY_ARMOUR]; @@ -3854,7 +3854,7 @@ void display_char_status() if (you.duration[DUR_INVIS]) mpr("You are invisible."); - if (you.duration[DUR_CONF]) + if (you.confused()) mpr("You are confused."); if (you.duration[DUR_BEHELD]) diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 65a83236b9..4666e8f176 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -81,7 +81,7 @@ int blink(int pow, bool high_level_controlled_blink, bool wizard_blink) { mpr("The power of the Abyss keeps you in your place!"); } - else if (you.duration[DUR_CONF] && !wizard_blink) + else if (you.confused() && !wizard_blink) random_blink(false); else if (!allow_control_teleport(true) && !wizard_blink) { @@ -217,7 +217,7 @@ void random_blink(bool allow_partial_control, bool override_abyss) #ifdef USE_SEMI_CONTROLLED_BLINK //jmf: Add back control, but effect is cast_semi_controlled_blink(pow). - else if (player_control_teleport() && !you.duration[DUR_CONF] + else if (player_control_teleport() && !you.confused() && allow_partial_control && allow_control_teleport()) { mpr("You may select the general direction of your translocation."); @@ -871,7 +871,7 @@ bool cast_vitalisation() int type = 0; // Remove negative afflictions. - if (you.disease || you.rotting || you.duration[DUR_CONF] + if (you.disease || you.rotting || you.confused() || you.duration[DUR_PARALYSIS] || you.duration[DUR_POISONING] || you.duration[DUR_PETRIFIED]) { diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 3a00fd310d..9cb7ac7434 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -1238,7 +1238,7 @@ void you_teleport(void) static bool _teleport_player( bool allow_control, bool new_abyss_area ) { - bool is_controlled = (allow_control && !you.duration[DUR_CONF] + bool is_controlled = (allow_control && !you.confused() && player_control_teleport() && allow_control_teleport()); diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 4efa85e260..36153059bc 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1189,7 +1189,7 @@ bool learn_spell(int book) return (false); } - if (you.duration[DUR_CONF]) + if (you.confused()) { mpr("You are too confused!"); return (false); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 5fd43d0bec..a0274b61d5 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -631,7 +631,7 @@ bool cast_a_spell() } const bool staff_energy = player_energy(); - if (you.duration[DUR_CONF]) + if (you.confused()) random_uselessness(); else { diff --git a/crawl-ref/source/traps.cc b/crawl-ref/source/traps.cc index 7d3c1430d7..b69a514fd4 100644 --- a/crawl-ref/source/traps.cc +++ b/crawl-ref/source/traps.cc @@ -898,7 +898,7 @@ static int damage_or_escape_net(int hold) // Confusion makes the whole thing somewhat harder // (less so for trying to escape). - if (you.duration[DUR_CONF]) + if (you.confused()) { if (escape > 1) escape--; diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 3fb1d82e58..f562bcadfe 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -1061,7 +1061,7 @@ command_type travel() command_type result = CMD_NO_CMD; // Abort travel/explore if you're confused or a key was pressed. - if (kbhit() || you.duration[DUR_CONF]) + if (kbhit() || you.confused()) { stop_running(); return CMD_NO_CMD; -- cgit v1.2.3-54-g00ecf