From df39d45725b62feba8dbc81496902161ddb9f3ef Mon Sep 17 00:00:00 2001 From: haranp Date: Sat, 23 Jun 2007 14:21:09 +0000 Subject: Lots of things which used to be members (invis, conf, confusing_touch, etc.) are now durations. Removed some unnecessary limitations. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1626 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/abl-show.cc | 18 ++-- crawl-ref/source/acr.cc | 162 +++++++++++++++++------------------ crawl-ref/source/beam.cc | 16 ++-- crawl-ref/source/chardump.cc | 2 +- crawl-ref/source/cloud.cc | 2 +- crawl-ref/source/decks.cc | 7 +- crawl-ref/source/delay.cc | 4 +- crawl-ref/source/enum.h | 39 ++++++--- crawl-ref/source/externs.h | 33 ++------ crawl-ref/source/fight.cc | 24 +++--- crawl-ref/source/food.cc | 2 +- crawl-ref/source/it_use2.cc | 46 +++++----- crawl-ref/source/it_use3.cc | 12 +-- crawl-ref/source/item_use.cc | 38 ++++----- crawl-ref/source/items.cc | 21 ++--- crawl-ref/source/misc.cc | 18 ++-- crawl-ref/source/mon-util.cc | 2 +- crawl-ref/source/monstuff.cc | 18 ++-- crawl-ref/source/newgame.cc | 1 - crawl-ref/source/ouch.cc | 2 +- crawl-ref/source/output.cc | 56 ++++++------- crawl-ref/source/player.cc | 196 ++++++++++++++++++++----------------------- crawl-ref/source/religion.cc | 10 +-- crawl-ref/source/skills2.cc | 2 +- crawl-ref/source/spells1.cc | 93 ++++++++++---------- crawl-ref/source/spells2.cc | 2 +- crawl-ref/source/spells3.cc | 4 +- crawl-ref/source/spells4.cc | 8 +- crawl-ref/source/spl-book.cc | 4 +- crawl-ref/source/spl-cast.cc | 4 +- crawl-ref/source/tags.cc | 73 ++++------------ crawl-ref/source/transfor.cc | 2 +- crawl-ref/source/travel.cc | 4 +- crawl-ref/source/tutorial.cc | 6 +- crawl-ref/source/view.cc | 4 +- 35 files changed, 430 insertions(+), 505 deletions(-) diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index ab1fd61ab1..492d5cf247 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -427,7 +427,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.conf && !testbits(abil.flags, ABFLAG_CONF_OK)) + if (you.duration[DUR_CONF] && !testbits(abil.flags, ABFLAG_CONF_OK)) { result.which = ABIL_NON_ABILITY; return result; @@ -743,7 +743,7 @@ std::vector get_ability_names() bool activate_ability() { - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return (false); @@ -755,7 +755,7 @@ bool activate_ability() mpr("Sorry, you're not good enough to have a special ability."); return false; } - if ( you.conf ) + if ( you.duration[DUR_CONF] ) { talents = your_talents(true); if ( talents.empty() ) @@ -1076,13 +1076,13 @@ static bool do_ability(const ability_def& abil) if (you.experience_level > 14) { mpr("You feel very comfortable in the air."); - you.levitation = 100; + you.duration[DUR_LEVITATION] = 100; you.duration[DUR_CONTROLLED_FLIGHT] = 100; } break; case ABIL_FLY_II: // Fly (Draconians, or anything else with wings) - if (you.exhausted) + if (you.duration[DUR_EXHAUSTED]) { mpr("You're too exhausted to fly."); return (false); @@ -1188,7 +1188,7 @@ static bool do_ability(const ability_def& abil) case ABIL_EVOKE_TURN_VISIBLE: mpr("You feel less transparent."); - you.invis = 1; + you.duration[DUR_INVIS] = 1; break; case ABIL_EVOKE_LEVITATE: // ring, boots, randarts @@ -1198,7 +1198,7 @@ static bool do_ability(const ability_def& abil) case ABIL_EVOKE_STOP_LEVITATING: mpr("You feel heavy."); - you.levitation = 1; + you.duration[DUR_LEVITATION] = 1; break; case ABIL_END_TRANSFORMATION: @@ -1925,7 +1925,7 @@ std::vector your_talents( bool check_confused ) // Now you can only turn invisibility off if you have an // activatable item. Wands and potions allow will have // to time out. -- bwr - if (you.invis) + if (you.duration[DUR_INVIS]) add_talent(talents, ABIL_EVOKE_TURN_VISIBLE, check_confused ); else add_talent(talents, ABIL_EVOKE_TURN_INVISIBLE, check_confused ); @@ -1941,7 +1941,7 @@ std::vector your_talents( bool check_confused ) // activatable item. Potions and miscast effects will // have to time out (this makes the miscast effect actually // a bit annoying). -- bwr - if (you.levitation) + if (you.duration[DUR_LEVITATION]) add_talent(talents, ABIL_EVOKE_STOP_LEVITATING, check_confused ); else add_talent(talents, ABIL_EVOKE_LEVITATE, check_confused ); diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 7c8e4a1276..1a4ebbbf7f 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -540,7 +540,7 @@ static void handle_wizard_command( void ) case 'h': you.rotting = 0; - you.poisoning = 0; + you.duration[DUR_POISONING] = 0; you.disease = 0; set_hp( abs(you.hp_max), false ); set_hunger( 5000 + abs(you.hunger), true ); @@ -548,7 +548,7 @@ static void handle_wizard_command( void ) case 'H': you.rotting = 0; - you.poisoning = 0; + you.duration[DUR_POISONING] = 0; you.disease = 0; inc_hp( 10, true ); set_hp( you.hp_max, false ); @@ -886,7 +886,7 @@ static void input() } } - if ( you.paralysis ) + if ( you.duration[DUR_PARALYSIS] ) { world_reacts(); return; @@ -976,7 +976,7 @@ static void go_upstairs() if (ygrd == DNGN_ENTER_SHOP) { - if ( you.berserker ) + if ( you.duration[DUR_BERSERKER] ) canned_msg(MSG_TOO_BERSERK); else shop(); @@ -1960,21 +1960,21 @@ static void decrement_durations() you.duration[DUR_DEATH_CHANNEL] = 0; } - if (you.invis > 1) + if (you.duration[DUR_INVIS] > 1) { - you.invis--; + you.duration[DUR_INVIS]--; - if (you.invis == 6) + if (you.duration[DUR_INVIS] == 6) { mpr("You flicker for a moment.", MSGCH_DURATION); if (coinflip()) - you.invis--; + you.duration[DUR_INVIS]--; } } - else if (you.invis == 1) + else if (you.duration[DUR_INVIS] == 1) { mpr("You flicker back into view.", MSGCH_DURATION); - you.invis = 0; + you.duration[DUR_INVIS] = 0; } if ( you.duration[DUR_BARGAIN] > 1 ) @@ -1984,43 +1984,43 @@ static void decrement_durations() mpr("You feel less charismatic.", MSGCH_DURATION); } - if (you.conf > 0) + if (you.duration[DUR_CONF] > 0) reduce_confuse_player(1); - if (you.paralysis > 1) - you.paralysis--; - else if (you.paralysis == 1) + if (you.duration[DUR_PARALYSIS] > 1) + you.duration[DUR_PARALYSIS]--; + else if (you.duration[DUR_PARALYSIS] == 1) { mpr("You can move again.", MSGCH_DURATION); - you.paralysis = 0; + you.duration[DUR_PARALYSIS] = 0; } - if (you.exhausted > 1) - you.exhausted--; - else if (you.exhausted == 1) + if (you.duration[DUR_EXHAUSTED] > 1) + you.duration[DUR_EXHAUSTED]--; + else if (you.duration[DUR_EXHAUSTED] == 1) { mpr("You feel less fatigued.", MSGCH_DURATION); - you.exhausted = 0; + you.duration[DUR_EXHAUSTED] = 0; } dec_slow_player(); dec_haste_player(); - if (you.might > 1) - you.might--; - else if (you.might == 1) + if (you.duration[DUR_MIGHT] > 1) + you.duration[DUR_MIGHT]--; + else if (you.duration[DUR_MIGHT] == 1) { mpr("You feel a little less mighty now.", MSGCH_DURATION); - you.might = 0; + you.duration[DUR_MIGHT] = 0; modify_stat(STAT_STRENGTH, -5, true); } - if (you.berserker > 1) - you.berserker--; - else if (you.berserker == 1) + if (you.duration[DUR_BERSERKER] > 1) + you.duration[DUR_BERSERKER]--; + else if (you.duration[DUR_BERSERKER] == 1) { mpr( "You are no longer berserk.", MSGCH_DURATION ); - you.berserker = 0; + you.duration[DUR_BERSERKER] = 0; //jmf: guilty for berserking /after/ berserk did_god_conduct( DID_STIMULANTS, 6 + random2(6) ); @@ -2085,16 +2085,16 @@ static void decrement_durations() else { mpr("You pass out from exhaustion.", MSGCH_WARN); - you.paralysis += roll_dice( 1, 4 ); + you.duration[DUR_PARALYSIS] += roll_dice( 1, 4 ); } - if ( you.paralysis == 0 ) + if ( you.duration[DUR_PARALYSIS] == 0 ) mpr("You are exhausted.", MSGCH_WARN); // this resets from an actual penalty or from NO_BERSERK_PENALTY you.berserk_penalty = 0; int dur = 12 + roll_dice( 2, 12 ); - you.exhausted += dur; + you.duration[DUR_EXHAUSTED] += dur; // for tutorial unsigned tut_slow = Options.tutorial_events[TUT_YOU_ENCHANTED]; Options.tutorial_events[TUT_YOU_ENCHANTED] = 0; @@ -2111,47 +2111,47 @@ static void decrement_durations() Options.tutorial_events[TUT_YOU_ENCHANTED] = tut_slow; } - if (you.backlight > 0 && !--you.backlight && !you.backlit()) + if (you.duration[DUR_BACKLIGHT] > 0 && !--you.duration[DUR_BACKLIGHT] && !you.backlit()) mpr("You are no longer glowing.", MSGCH_DURATION); - if (you.confusing_touch > 1) - you.confusing_touch--; - else if (you.confusing_touch == 1) + if (you.duration[DUR_CONFUSING_TOUCH] > 1) + you.duration[DUR_CONFUSING_TOUCH]--; + else if (you.duration[DUR_CONFUSING_TOUCH] == 1) { msg::streams(MSGCH_DURATION) << "Your " << your_hand(true) << " stop glowing." << std::endl; - you.confusing_touch = 0; + you.duration[DUR_CONFUSING_TOUCH] = 0; } - if (you.sure_blade > 1) - you.sure_blade--; - else if (you.sure_blade == 1) + if (you.duration[DUR_SURE_BLADE] > 1) + you.duration[DUR_SURE_BLADE]--; + else if (you.duration[DUR_SURE_BLADE] == 1) { mpr("The bond with your blade fades away.", MSGCH_DURATION); - you.sure_blade = 0; + you.duration[DUR_SURE_BLADE] = 0; } - if (you.levitation > 1) + if (you.duration[DUR_LEVITATION] > 1) { if (you.species != SP_KENKU || you.experience_level < 15) - you.levitation--; + you.duration[DUR_LEVITATION]--; if (player_equip_ego_type( EQ_BOOTS, SPARM_LEVITATION )) - you.levitation = 2; + you.duration[DUR_LEVITATION] = 2; - if (you.levitation == 10) + if (you.duration[DUR_LEVITATION] == 10) { mpr("You are starting to lose your buoyancy!", MSGCH_DURATION); - you.levitation -= random2(6); + you.duration[DUR_LEVITATION] -= random2(6); if (you.duration[DUR_CONTROLLED_FLIGHT] > 0) - you.duration[DUR_CONTROLLED_FLIGHT] = you.levitation; + you.duration[DUR_CONTROLLED_FLIGHT] = you.duration[DUR_LEVITATION]; } } - else if (you.levitation == 1) + else if (you.duration[DUR_LEVITATION] == 1) { mpr("You float gracefully downwards.", MSGCH_DURATION); - you.levitation = 0; + you.duration[DUR_LEVITATION] = 0; burden_change(); you.duration[DUR_CONTROLLED_FLIGHT] = 0; @@ -2195,16 +2195,16 @@ static void decrement_durations() dec_disease_player(); - if (you.poisoning > 0) + if (you.duration[DUR_POISONING] > 0) { - if (random2(5) <= (you.poisoning - 1)) + if (random2(5) <= (you.duration[DUR_POISONING] - 1)) { - if (you.poisoning > 10 && random2(you.poisoning) >= 8) + if (you.duration[DUR_POISONING] > 10 && random2(you.duration[DUR_POISONING]) >= 8) { ouch(random2(10) + 5, 0, KILLED_BY_POISON); mpr("You feel extremely sick.", MSGCH_DANGER); } - else if (you.poisoning > 5 && coinflip()) + else if (you.duration[DUR_POISONING] > 5 && coinflip()) { ouch((coinflip()? 3 : 2), 0, KILLED_BY_POISON); mpr("You feel very sick.", MSGCH_WARN); @@ -2221,26 +2221,26 @@ static void decrement_durations() } } - if (you.deaths_door) + if (you.duration[DUR_DEATHS_DOOR]) { if (you.hp > allowed_deaths_door_hp()) { mpr("Your life is in your own hands once again.", MSGCH_DURATION); - you.paralysis += 5 + random2(5); + you.duration[DUR_PARALYSIS] += 5 + random2(5); confuse_player( 10 + random2(10) ); you.hp_max--; deflate_hp(you.hp_max, false); - you.deaths_door = 0; + you.duration[DUR_DEATHS_DOOR] = 0; } else - you.deaths_door--; + you.duration[DUR_DEATHS_DOOR]--; - if (you.deaths_door == 10) + if (you.duration[DUR_DEATHS_DOOR] == 10) { mpr("Your time is quickly running out!", MSGCH_DURATION); - you.deaths_door -= random2(6); + you.duration[DUR_DEATHS_DOOR] -= random2(6); } - if (you.deaths_door == 1) + if (you.duration[DUR_DEATHS_DOOR] == 1) { mpr("Your life is in your own hands again!", MSGCH_DURATION); more(); @@ -2289,7 +2289,7 @@ static void world_reacts() run_environment_effects(); - if ( !you.paralysis && !you.mutation[MUT_BLURRY_VISION] && + if ( !you.duration[DUR_PARALYSIS] && !you.mutation[MUT_BLURRY_VISION] && (you.mutation[MUT_ACUTE_VISION] >= 2 || random2(50) < you.skills[SK_TRAPS_DOORS]) ) search_around(false); // check nonadjacent squares too @@ -2327,7 +2327,7 @@ static void world_reacts() // is only an unsigned char and is thus likely to overflow. -- bwr int tmp = static_cast< int >( you.hit_points_regeneration ); - if (you.hp < you.hp_max && !you.disease && !you.deaths_door) + if (you.hp < you.hp_max && !you.disease && !you.duration[DUR_DEATHS_DOOR]) tmp += player_regen(); while (tmp >= 100) @@ -2385,19 +2385,19 @@ static void world_reacts() manage_clouds(); - if (you.fire_shield > 0) + if (you.duration[DUR_FIRE_SHIELD] > 0) manage_fire_shield(); // food death check: if (you.is_undead != US_UNDEAD && you.hunger <= 500) { - if (!you.paralysis && one_chance_in(40)) + if (!you.duration[DUR_PARALYSIS] && one_chance_in(40)) { mpr("You lose consciousness!", MSGCH_FOOD); - you.paralysis += 5 + random2(8); + you.duration[DUR_PARALYSIS] += 5 + random2(8); - if (you.paralysis > 13) - you.paralysis = 13; + if (you.duration[DUR_PARALYSIS] > 13) + you.duration[DUR_PARALYSIS] = 13; } if (you.hunger <= 100) @@ -2414,7 +2414,7 @@ static void world_reacts() { if (its_quiet) { - if (random2(30)) + if (!one_chance_in(30)) mpr("You are enveloped in profound silence.", MSGCH_WARN); else mpr("The dungeon seems quiet ... too quiet!", MSGCH_WARN); @@ -2429,7 +2429,7 @@ static void world_reacts() viewwindow(true, false); - if (you.paralysis > 0 && any_messages()) + if (you.duration[DUR_PARALYSIS] > 0 && any_messages()) more(); // place normal dungeon monsters, but not in player LOS @@ -2776,7 +2776,7 @@ static void open_door(int move_x, int move_y, bool check_confused) struct dist door_move; int dx, dy; // door x, door y - if (check_confused && you.conf && !one_chance_in(3)) + if (check_confused && you.duration[DUR_CONF] && !one_chance_in(3)) { move_x = random2(3) - 1; move_y = random2(3) - 1; @@ -3085,7 +3085,7 @@ static void do_berserk_no_combat_penalty(void) if (you.berserk_penalty == NO_BERSERK_PENALTY) return; - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { you.berserk_penalty++; @@ -3104,17 +3104,17 @@ static void do_berserk_no_combat_penalty(void) // I do these three separately, because the might and // haste counters can be different. - you.berserker -= you.berserk_penalty; - if (you.berserker < 1) - you.berserker = 1; + you.duration[DUR_BERSERKER] -= you.berserk_penalty; + if (you.duration[DUR_BERSERKER] < 1) + you.duration[DUR_BERSERKER] = 1; - you.might -= you.berserk_penalty; - if (you.might < 1) - you.might = 1; + you.duration[DUR_MIGHT] -= you.berserk_penalty; + if (you.duration[DUR_MIGHT] < 1) + you.duration[DUR_MIGHT] = 1; - you.haste -= you.berserk_penalty; - if (you.haste < 1) - you.haste = 1; + you.duration[DUR_HASTE] -= you.berserk_penalty; + if (you.duration[DUR_HASTE] < 1) + you.duration[DUR_HASTE] = 1; } return; } // end do_berserk_no_combat_penalty() @@ -3128,7 +3128,7 @@ static void move_player(int move_x, int move_y) bool moving = true; // used to prevent eventual movement (swap) bool swap = false; - if (you.conf) + if (you.duration[DUR_CONF]) { if (!one_chance_in(3)) { @@ -3146,7 +3146,7 @@ static void move_player(int move_x, int move_y) apply_berserk_penalty = true; return; } - } // end of if you.conf + } // end of if you.duration[DUR_CONF] if (you.running.check_stop_running()) { @@ -3168,7 +3168,7 @@ static void move_player(int move_x, int move_y) struct monsters *mon = &menv[targ_monst]; // you can swap places with a friendly monster if you're not confused - if (mons_friendly( mon ) && !you.conf) + if (mons_friendly( mon ) && !you.duration[DUR_CONF]) { if (swap_places( mon )) swap = true; diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index e4f962eaef..692bbd8143 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -2415,7 +2415,7 @@ static void beam_drop_object( bolt &beam, item_def *item, int x, int y ) static bool found_player(const bolt &beam, int x, int y) { const bool needs_fuzz = beam.is_tracer && !beam.can_see_invis - && you.invis; + && you.duration[DUR_INVIS]; const int dist = needs_fuzz? 2 : 0; return (grid_distance(x, y, you.x_pos, you.y_pos) <= dist); @@ -2989,7 +2989,7 @@ static int affect_player( bolt &beam ) if (beam.is_tracer) { // check can see player - if (beam.can_see_invis || !you.invis + if (beam.can_see_invis || !you.duration[DUR_INVIS] || fuzz_invis_tracer(beam)) { if (beam.is_friendly) @@ -3013,7 +3013,7 @@ static int affect_player( bolt &beam ) beamHit = beam.hit; // Monsters shooting at an invisible player are very inaccurate. - if (you.invis && !beam.can_see_invis) + if (you.duration[DUR_INVIS] && !beam.can_see_invis) beamHit /= 2; if (beam.name[0] != '0') @@ -3114,16 +3114,16 @@ static int affect_player( bolt &beam ) switch (beam.flavour) { case BEAM_BACKLIGHT: - if (!you.invis) + if (!you.duration[DUR_INVIS]) { - if (you.backlight) + if (you.duration[DUR_BACKLIGHT]) mpr("You glow brighter."); else mpr("You are outlined in light."); - you.backlight += random_range(15, 35); - if (you.backlight > 250) - you.backlight = 250; + you.duration[DUR_BACKLIGHT] += random_range(15, 35); + if (you.duration[DUR_BACKLIGHT] > 250) + you.duration[DUR_BACKLIGHT] = 250; beam.obvious_effect = true; } diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc index f7d655323a..73d1c2ff7d 100644 --- a/crawl-ref/source/chardump.cc +++ b/crawl-ref/source/chardump.cc @@ -446,7 +446,7 @@ static void dump_stats( std::string & text ) if (you.hp < 1) { text += " "; - text += ((!you.deaths_door) ? "(dead)" : "(almost dead)"); + text += ((!you.duration[DUR_DEATHS_DOOR]) ? "(dead)" : "(almost dead)"); } } diff --git a/crawl-ref/source/cloud.cc b/crawl-ref/source/cloud.cc index 1f542523fc..27329fe0c6 100644 --- a/crawl-ref/source/cloud.cc +++ b/crawl-ref/source/cloud.cc @@ -138,7 +138,7 @@ void manage_clouds(void) } // double the amount when slowed - must be applied last(!): - if (you.slow) + if (you.duration[DUR_SLOW]) dissipate *= 2; dissipate_cloud( cc, env.cloud[cc], dissipate ); diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc index 1c2a8c5205..814736c9a3 100644 --- a/crawl-ref/source/decks.cc +++ b/crawl-ref/source/decks.cc @@ -877,7 +877,7 @@ static void trowel_card(int power, deck_rarity_type rarity) static void genie_card(int power, deck_rarity_type rarity) { if ( coinflip() ) - acquirement( OBJ_RANDOM, AQ_CARD_ACQUISITION ); + acquirement( OBJ_RANDOM, AQ_CARD_GENIE ); else potion_effect( coinflip() ? POT_DEGENERATION : POT_DECAY, 40 ); } @@ -953,6 +953,11 @@ static int card_power(deck_rarity_type rarity) void card_effect(card_type which_card, deck_rarity_type rarity) { const int power = card_power(rarity); +#ifdef DEBUG_DIAGNOSTICS + msg::streams(MSGCH_DIAGNOSTICS) << "Card power: " << power + << ", rarity: " << static_cast(rarity) + << std::endl; +#endif msg::stream << "You have drawn " << card_name( which_card ) << '.' << std::endl; diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index f8f5806705..0e41f0967f 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -559,7 +559,7 @@ static void finish_delay(const delay_queue_item &delay) turn_corpse_into_chunks( mitm[ delay.parm1 ] ); - if (you.berserker && you.berserk_penalty != NO_BERSERK_PENALTY) + if (you.duration[DUR_BERSERKER] && you.berserk_penalty != NO_BERSERK_PENALTY) { mpr("You enjoyed that."); you.berserk_penalty = 0; @@ -709,7 +709,7 @@ static void armour_wear_effects(const int item_slot) break; case SPARM_DARKNESS: - if (!you.invis) + if (!you.duration[DUR_INVIS]) mpr("You become transparent for a moment."); break; diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 618fecb07b..4117c06801 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -184,10 +184,7 @@ enum acquirement_agent_type // Empty space for the gods - AQ_CARD_ACQUISITION = 100, - AQ_CARD_VIOLENCE, - AQ_CARD_PROTECTION, - AQ_CARD_KNOWLEDGE, + AQ_CARD_GENIE = 100, AQ_WIZMODE = 200 }; @@ -250,7 +247,7 @@ enum attribute_type ATTR_WAS_SILENCED, //jmf: added for silenced messages ATTR_GOD_GIFT_COUNT, //jmf: added to help manage god gift giving ATTR_DELAYED_FIREBALL, // bwr: reserve fireballs - NUM_ATTRIBUTES = 30 // must be at least 30 + NUM_ATTRIBUTES }; enum band_type @@ -1147,36 +1144,54 @@ enum dungeon_feature_type enum duration_type { - DUR_LIQUID_FLAMES, // 0 + DUR_INVIS, + DUR_CONF, + DUR_PARALYSIS, + DUR_SLOW, + DUR_HASTE, + DUR_MIGHT, + DUR_LEVITATION, + DUR_BERSERKER, + DUR_POISONING, + + DUR_CONFUSING_TOUCH, + DUR_SURE_BLADE, + DUR_BACKLIGHT, + DUR_DEATHS_DOOR, + DUR_FIRE_SHIELD, + + DUR_EXHAUSTED, // fatigue counter for berserk + + DUR_LIQUID_FLAMES, DUR_ICY_ARMOUR, DUR_REPEL_MISSILES, DUR_PRAYER, DUR_REGENERATION, - DUR_SWIFTNESS, // 5 + DUR_SWIFTNESS, DUR_STONEMAIL, DUR_CONTROLLED_FLIGHT, DUR_TELEPORT, DUR_CONTROL_TELEPORT, - DUR_BREATH_WEAPON, // 10 + DUR_BREATH_WEAPON, DUR_TRANSFORMATION, DUR_DEATH_CHANNEL, DUR_DEFLECT_MISSILES, DUR_FORESCRY, - DUR_SEE_INVISIBLE, // 15 + DUR_SEE_INVISIBLE, DUR_WEAPON_BRAND, // general "branding" spell counter DUR_SILENCE, DUR_GLAMOUR, DUR_CONDENSATION_SHIELD, - DUR_STONESKIN, // 20 + DUR_STONESKIN, DUR_REPEL_UNDEAD, DUR_GOURMAND, DUR_BARGAIN, DUR_INSULATION, - DUR_RESIST_POISON, // 25 + DUR_RESIST_POISON, DUR_RESIST_FIRE, DUR_RESIST_COLD, DUR_SLAYING, - NUM_DURATIONS = 30 // must be at least 30 + NUM_DURATIONS }; // various elemental colour schemes... used for abstracting random short lists diff --git a/crawl-ref/source/externs.h b/crawl-ref/source/externs.h index 25c0f33397..8b1568fcc5 100644 --- a/crawl-ref/source/externs.h +++ b/crawl-ref/source/externs.h @@ -618,8 +618,6 @@ public: runrest running; // Nonzero if running/traveling. char special_wield; - char deaths_door; - int fire_shield; double elapsed_time; // total amount of elapsed time in the game @@ -692,33 +690,20 @@ public: burden_state_type burden_state; FixedVector spells; char spell_no; - unsigned char char_direction; // + game_direction_type char_direction; // unsigned char pet_target; int your_level; // offset by one (-1 == 0, 0 == 1, etc.) for display - // durational things. Why didn't I do this for haste etc - // right from the start? Oh well. + // durational things FixedVector duration; - int invis; - int conf; - int paralysis; - int slow; - int haste; - int might; - int levitation; - - int poisoning; int rotting; - int berserker; - - int exhausted; // fatigue counter for berserk - int berserk_penalty; // pelnalty for moving while berserk + int berserk_penalty; // penalty for moving while berserk - FixedVector attribute; // see ATTRIBUTES in enum.h + FixedVector attribute; undead_state_type is_undead; @@ -752,15 +737,11 @@ public: FixedVector num_gifts; - FixedVector mutation; - FixedVector demon_pow; + FixedVector mutation; + FixedVector demon_pow; unsigned char magic_contamination; - short backlight; - - char confusing_touch; - char sure_blade; - FixedVector had_book; + FixedVector had_book; unsigned char normal_vision; // how far the species gets to see unsigned char current_vision; // current sight radius (cells) diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index 1d22ac2dac..33d81fbafb 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -81,8 +81,6 @@ static void stab_message(struct monsters *defender, int stab_bonus); -int weapon_str_weight( int wpn_class, int wpn_type ); - static inline int player_weapon_str_weight( void ); static inline int player_weapon_dex_weight( void ); @@ -969,7 +967,7 @@ int melee_attack::player_apply_fighting_skill(int damage, bool aux) int melee_attack::player_apply_misc_modifiers(int damage) { - if (you.might > 1) + if (you.duration[DUR_MIGHT] > 1) damage += 1 + random2(10); if (you.hunger_state == HS_STARVING) @@ -1730,10 +1728,10 @@ bool melee_attack::apply_damage_brand() mons_ench_f2( def, beam_temp ); - you.confusing_touch -= random2(20); + you.duration[DUR_CONFUSING_TOUCH] -= random2(20); - if (you.confusing_touch < 1) - you.confusing_touch = 1; + if (you.duration[DUR_CONFUSING_TOUCH] < 1) + you.duration[DUR_CONFUSING_TOUCH] = 1; break; } } @@ -2078,7 +2076,7 @@ int melee_attack::player_to_hit(bool random_factor) const bool see_invis = player_see_invis(); // if you can't see yourself, you're a little less acurate. - if (you.invis && !see_invis) + if (you.duration[DUR_INVIS] && !see_invis) your_to_hit -= 5; // fighting contribution @@ -2157,15 +2155,15 @@ int melee_attack::player_to_hit(bool random_factor) if (hand_half_bonus) your_to_hit += maybe_random2(3, random_factor); - if (weapon && wpn_skill == SK_SHORT_BLADES && you.sure_blade) + if (weapon && wpn_skill == SK_SHORT_BLADES && you.duration[DUR_SURE_BLADE]) your_to_hit += 5 + - (random_factor ? random2limit( you.sure_blade, 10 ) : - you.sure_blade / 2); + (random_factor ? random2limit( you.duration[DUR_SURE_BLADE], 10 ) : + you.duration[DUR_SURE_BLADE] / 2); // other stuff if (!weapon) { - if ( you.confusing_touch ) + if ( you.duration[DUR_CONFUSING_TOUCH] ) // just trying to touch is easier that trying to damage your_to_hit += maybe_random2(you.dex, random_factor); @@ -2264,7 +2262,7 @@ void melee_attack::player_stab_check() if (stab_attempt && roll_needed) stab_attempt = (random2(roll) <= you.skills[SK_STABBING] + you.dex); - if (stab_attempt && you.religion == GOD_SHINING_ONE && !you.berserker) + if (stab_attempt && you.religion == GOD_SHINING_ONE && !you.duration[DUR_BERSERKER]) { if (!yesno("Really attack this helpless creature?", false, 'n')) { @@ -2393,7 +2391,7 @@ int melee_attack::player_calc_base_unarmed_damage() { int damage = 3; - if (you.confusing_touch) + if (you.duration[DUR_CONFUSING_TOUCH]) { // no base hand damage while using this spell damage = 0; diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index ab3e0199f6..94fdc8b718 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -218,7 +218,7 @@ bool butchery(void) // It makes more sense that you first find out if there's anything // to butcher, *then* decide to actually butcher it. // The old code did it the other way. - if ( !can_butcher && you.berserker ) + if ( !can_butcher && you.duration[DUR_BERSERKER] ) { mpr ("You are too berserk to search for a butchering knife!"); return (false); diff --git a/crawl-ref/source/it_use2.cc b/crawl-ref/source/it_use2.cc index 01ccda0cd8..b247568409 100644 --- a/crawl-ref/source/it_use2.cc +++ b/crawl-ref/source/it_use2.cc @@ -64,10 +64,10 @@ bool potion_effect( potion_type pot_eff, int pow ) set_hp(you.hp_max, false); } - you.poisoning = 0; + you.duration[DUR_POISONING] = 0; you.rotting = 0; you.disease = 0; - you.conf = 0; + you.duration[DUR_CONF] = 0; break; case POT_HEAL_WOUNDS: @@ -88,7 +88,7 @@ bool potion_effect( potion_type pot_eff, int pow ) case POT_MIGHT: { - bool were_mighty = (you.might > 0); + bool were_mighty = (you.duration[DUR_MIGHT] > 0); if (!were_mighty) mpr( "You feel very mighty all of a sudden." ); @@ -99,14 +99,14 @@ bool potion_effect( potion_type pot_eff, int pow ) } // conceivable max gain of +184 {dlb} - you.might += 35 + random2(pow); + you.duration[DUR_MIGHT] += 35 + random2(pow); if (!were_mighty) modify_stat(STAT_STRENGTH, 5, true); // files.cc permits values up to 215, but ... {dlb} - if (you.might > 80) - you.might = 80; + if (you.duration[DUR_MIGHT] > 80) + you.duration[DUR_MIGHT] = 80; did_god_conduct( DID_STIMULANTS, 4 + random2(4) ); } @@ -131,10 +131,10 @@ bool potion_effect( potion_type pot_eff, int pow ) if (!player_is_levitating()) mpr("You gently float upwards from the floor."); - you.levitation += 25 + random2(pow); + you.duration[DUR_LEVITATION] += 25 + random2(pow); - if (you.levitation > 100) - you.levitation = 100; + if (you.duration[DUR_LEVITATION] > 100) + you.duration[DUR_LEVITATION] = 100; burden_change(); break; @@ -163,7 +163,7 @@ bool potion_effect( potion_type pot_eff, int pow ) break; case POT_PARALYSIS: - you.paralyse(2 + random2( 6 + you.paralysis )); + you.paralyse(2 + random2( 6 + you.duration[DUR_PARALYSIS] )); xom_is_stimulated(64); break; @@ -173,19 +173,19 @@ bool potion_effect( potion_type pot_eff, int pow ) break; case POT_INVISIBILITY: - mpr( (!you.invis) ? "You fade into invisibility!" - : "You fade further into invisibility." ); + mpr( (!you.duration[DUR_INVIS]) ? "You fade into invisibility!" + : "You fade further into invisibility." ); // now multiple invisiblity casts aren't as good -- bwr - if (!you.invis) - you.invis = 15 + random2(pow); + if (!you.duration[DUR_INVIS]) + you.duration[DUR_INVIS] = 15 + random2(pow); else - you.invis += random2(pow); + you.duration[DUR_INVIS] += random2(pow); - if (you.invis > 100) - you.invis = 100; + if (you.duration[DUR_INVIS] > 100) + you.duration[DUR_INVIS] = 100; - you.backlight = 0; + you.duration[DUR_BACKLIGHT] = 0; break; // carnivore check here? {dlb} @@ -452,8 +452,8 @@ void unwear_armour(char unw) break; case SPARM_DARKNESS: // I do not understand this {dlb} - if (you.invis) - you.invis = 1; + if (you.duration[DUR_INVIS]) + you.duration[DUR_INVIS] = 1; break; case SPARM_STRENGTH: @@ -474,9 +474,9 @@ void unwear_armour(char unw) break; case SPARM_LEVITATION: - //you.levitation++; - if (you.levitation) - you.levitation = 1; + //you.duration[DUR_LEVITATION]++; + if (you.duration[DUR_LEVITATION]) + you.duration[DUR_LEVITATION] = 1; break; case SPARM_MAGIC_RESISTANCE: diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index 456e05019f..664f448b06 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -310,7 +310,7 @@ bool evoke_wielded( void ) int wield = you.equip[EQ_WEAPON]; - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg( MSG_TOO_BERSERK ); return (false); @@ -342,7 +342,7 @@ bool evoke_wielded( void ) switch (wpn.special) { case SPWPN_STAFF_OF_DISPATER: - if (you.deaths_door || !enough_hp(11, true) + if (you.duration[DUR_DEATHS_DOOR] || !enough_hp(11, true) || !enough_mp(5, true)) { break; @@ -707,7 +707,7 @@ static bool ball_of_seeing(void) mpr("You gaze into the crystal ball."); - use = ((!you.conf) ? random2(you.skills[SK_EVOCATIONS] * 6) : random2(5)); + use = ((!you.duration[DUR_CONF]) ? random2(you.skills[SK_EVOCATIONS] * 6) : random2(5)); if (use < 2) { @@ -1002,7 +1002,7 @@ static bool ball_of_energy(void) mpr("You gaze into the crystal ball."); - use = ((!you.conf) ? random2(you.skills[SK_EVOCATIONS] * 6) : random2(6)); + use = ((!you.duration[DUR_CONF]) ? random2(you.skills[SK_EVOCATIONS] * 6) : random2(6)); if (use < 2 || you.max_magic_points == 0) { @@ -1046,8 +1046,8 @@ static bool ball_of_fixation(void) mpr("You gaze into the crystal ball."); mpr("You are mesmerised by a rainbow of scintillating colours!"); - you.paralysis = 100; - you.slow = 100; + you.duration[DUR_PARALYSIS] = 100; + you.duration[DUR_SLOW] = 100; return (true); } // end ball_of_fixation() diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 0db383d21e..1b88f4a50d 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -80,7 +80,7 @@ bool can_wield(const item_def *weapon, bool say_reason) { #define SAY(x) if (say_reason) { x; } else - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { SAY(canned_msg(MSG_TOO_BERSERK)); return false; @@ -184,10 +184,10 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages) if (!can_wield(NULL, true)) return (false); - if (you.sure_blade) + if (you.duration[DUR_SURE_BLADE]) { mpr("The bond with your blade fades away."); - you.sure_blade = 0; + you.duration[DUR_SURE_BLADE] = 0; } if (auto_wield) @@ -648,7 +648,7 @@ bool armour_prompt( const std::string & mesg, int *index, operation_types oper) if (inv_count() < 1) canned_msg(MSG_NOTHING_CARRIED); - else if (you.berserker) + else if (you.duration[DUR_BERSERKER]) canned_msg(MSG_TOO_BERSERK); else { @@ -1059,7 +1059,7 @@ void throw_anything(void) struct bolt beam; int throw_slot; - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return; @@ -1217,7 +1217,7 @@ void shoot_thing(void) { struct bolt beam; // passed in by reference, but never used here - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); flush_input_buffer( FLUSH_ON_FAILURE ); @@ -1403,7 +1403,7 @@ bool throw_it(struct bolt &pbolt, int throw_2, monsters *dummy_target) item.slot = index_to_letter(item.link); origin_set_unknown(item); - if (you.conf) + if (you.duration[DUR_CONF]) { thr.isTarget = true; thr.tx = you.x_pos + random2(13) - 6; @@ -2037,7 +2037,7 @@ void jewellery_wear_effects(item_def &item) break; case RING_INVISIBILITY: - if (!you.invis) + if (!you.duration[DUR_INVIS]) { mpr("You become transparent for a moment."); ident = ID_KNOWN_TYPE; @@ -2280,7 +2280,7 @@ bool puton_ring(int slot, bool prompt_finger) return (false); } - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return (false); @@ -2356,14 +2356,14 @@ void jewellery_remove_effects(item_def &item) case RING_INVISIBILITY: // removing this ring effectively cancels all invisibility {dlb} - if (you.invis) - you.invis = 1; + if (you.duration[DUR_INVIS]) + you.duration[DUR_INVIS] = 1; break; case RING_LEVITATION: // removing this ring effectively cancels all levitation {dlb} - if (you.levitation) - you.levitation = 1; + if (you.duration[DUR_LEVITATION]) + you.duration[DUR_LEVITATION] = 1; break; case RING_MAGICAL_POWER: @@ -2394,7 +2394,7 @@ bool remove_ring(int slot, bool announce) return (false); } - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return (false); @@ -2515,7 +2515,7 @@ void zap_wand(void) return; } - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return; @@ -2586,7 +2586,7 @@ void zap_wand(void) return; } - if (you.conf) + if (you.duration[DUR_CONF]) { zap_wand.tx = you.x_pos + random2(13) - 6; zap_wand.ty = you.y_pos + random2(13) - 6; @@ -2728,7 +2728,7 @@ void drink(void) return; } - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return; @@ -3221,7 +3221,7 @@ void read_scroll(void) // added: scroll effects are never tracers. beam.is_tracer = false; - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return; @@ -3291,7 +3291,7 @@ void read_scroll(void) // scrolls of paper are also exempted from this handling {dlb}: if (scroll_type != SCR_PAPER) { - if (you.conf) + if (you.duration[DUR_CONF]) { random_uselessness(random2(9), item_slot); dec_inv_item_quantity( item_slot, 1 ); diff --git a/crawl-ref/source/items.cc b/crawl-ref/source/items.cc index b493c5c367..6928a4ff58 100644 --- a/crawl-ref/source/items.cc +++ b/crawl-ref/source/items.cc @@ -915,17 +915,8 @@ std::string origin_desc(const item_def &item) case AQ_SCROLL: desc += "You acquired " + article_it(item) + " "; break; - case AQ_CARD_ACQUISITION: - desc += "You drew \"Acquisition\" "; - break; - case AQ_CARD_VIOLENCE: - desc += "You drew \"Violence\" "; - break; - case AQ_CARD_PROTECTION: - desc += "You drew \"Protection\" "; - break; - case AQ_CARD_KNOWLEDGE: - desc += "You drew \"Knowledge\" "; + case AQ_CARD_GENIE: + desc += "You drew the Genie "; break; case AQ_WIZMODE: desc += "Your wizardly powers created " @@ -2235,10 +2226,10 @@ void handle_time( long time_delta ) // about 1.5 points on average, so they can corrupt the player // quite quickly. Wielding one for a short battle is OK, which is // as things should be. -- GDL - if (you.invis && random2(10) < 6) + if (you.duration[DUR_INVIS] && random2(10) < 6) added_contamination++; - if (you.haste && !you.berserker && random2(10) < 6) + if (you.duration[DUR_HASTE] && !you.duration[DUR_BERSERKER] && random2(10) < 6) added_contamination++; // randarts are usually about 20x worse than running around invisible @@ -2246,7 +2237,7 @@ void handle_time( long time_delta ) added_contamination += random2(1 + scan_randarts(RAP_MUTAGENIC)); // we take off about .5 points per turn - if (!you.invis && !you.haste && coinflip()) + if (!you.duration[DUR_INVIS] && !you.duration[DUR_HASTE] && coinflip()) added_contamination -= 1; contaminate_player( added_contamination ); @@ -2507,7 +2498,7 @@ void handle_time( long time_delta ) } else // exercise stealth skill: { - if (you.burden_state != BS_UNENCUMBERED || you.berserker) + if (you.burden_state != BS_UNENCUMBERED || you.duration[DUR_BERSERKER]) return; if (you.special_wield == SPWLD_SHADOW) diff --git a/crawl-ref/source/misc.cc b/crawl-ref/source/misc.cc index 269fe2bcbb..b52c4ddd4d 100644 --- a/crawl-ref/source/misc.cc +++ b/crawl-ref/source/misc.cc @@ -331,7 +331,7 @@ void in_a_cloud() switch (env.cloud[cl].type) { case CLOUD_FIRE: - if (you.fire_shield) + if (you.duration[DUR_FIRE_SHIELD]) return; mpr("You are engulfed in roaring flames!"); @@ -548,7 +548,7 @@ void up_stairs(void) // the overloaded character makes an attempt... so we're doing this // check before that one. -- bwr if (!player_is_levitating() - && you.conf + && you.duration[DUR_CONF] && (stair_find >= DNGN_STONE_STAIRS_UP_I && stair_find <= DNGN_ROCK_STAIRS_UP) && random2(100) > you.dex) @@ -931,7 +931,7 @@ void down_stairs( int old_level, int force_stair ) } if (!player_is_levitating() - && you.conf + && you.duration[DUR_CONF] && (stair_find >= DNGN_STONE_STAIRS_DOWN_I && stair_find <= DNGN_ROCK_STAIRS_DOWN) && random2(100) > you.dex) @@ -1391,7 +1391,7 @@ void handle_traps(char trt, int i, bool trap_known) void disarm_trap( struct dist &disa ) { - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return; @@ -1565,7 +1565,7 @@ bool fall_into_a_pool( int entry_x, int entry_y, bool allow_shift, expose_player_to_element( BEAM_LAVA, 14 ); } - // a distinction between stepping and falling from you.levitation + // a distinction between stepping and falling from you.duration[DUR_LEVITATION] // prevents stepping into a thin stream of lava to get to the other side. if (scramble()) { @@ -1695,7 +1695,7 @@ bool go_berserk(bool intentional) mpr("You feel yourself moving faster!"); mpr("You feel mighty!"); - you.berserker += 20 + random2avg(19, 2); + you.duration[DUR_BERSERKER] += 20 + random2avg(19, 2); calc_hp(); you.hp *= 15; @@ -1703,11 +1703,11 @@ bool go_berserk(bool intentional) deflate_hp(you.hp_max, false); - if (!you.might) + if (!you.duration[DUR_MIGHT]) modify_stat( STAT_STRENGTH, 5, true ); - you.might += you.berserker; - haste_player( you.berserker ); + you.duration[DUR_MIGHT] += you.duration[DUR_BERSERKER]; + haste_player( you.duration[DUR_BERSERKER] ); if (you.berserk_penalty != NO_BERSERK_PENALTY) you.berserk_penalty = 0; diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc index 86e72d9d6c..1676fb498e 100644 --- a/crawl-ref/source/mon-util.cc +++ b/crawl-ref/source/mon-util.cc @@ -498,7 +498,7 @@ bool mons_monster_visible( struct monsters *mon, struct monsters *targ ) // with respect to mon's perception, but doesn't do walls or range. bool mons_player_visible( struct monsters *mon ) { - if (you.invis) + if (you.duration[DUR_INVIS]) { if (player_in_water()) return (true); diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc index cec3a9c299..dd00ba6fef 100644 --- a/crawl-ref/source/monstuff.cc +++ b/crawl-ref/source/monstuff.cc @@ -395,15 +395,15 @@ void monster_die(monsters *monster, char killer, int i, bool silent) // From time to time Trog gives you a little bonus - if (killer == KILL_YOU && you.berserker) + if (killer == KILL_YOU && you.duration[DUR_BERSERKER]) { if (you.religion == GOD_TROG && (!player_under_penance() && you.piety > random2(1000))) { int bonus = 3 + random2avg( 10, 2 ); - you.berserker += bonus; - you.might += bonus; + you.duration[DUR_BERSERKER] += bonus; + you.duration[DUR_MIGHT] += bonus; haste_player( bonus ); mpr( "You feel the power of Trog in you as your rage grows.", @@ -413,8 +413,8 @@ void monster_die(monsters *monster, char killer, int i, bool silent) { int bonus = 2 + random2(4); - you.berserker += bonus; - you.might += bonus; + you.duration[DUR_BERSERKER] += bonus; + you.duration[DUR_MIGHT] += bonus; haste_player( bonus ); mpr( "Your amulet glows a violent red." ); @@ -1536,7 +1536,7 @@ static void handle_behaviour(monsters *mon) // change proxPlayer depending on invisibility and standing // in shallow water - if (proxPlayer && you.invis) + if (proxPlayer && you.duration[DUR_INVIS]) { if (!mons_player_visible( mon )) proxPlayer = false; @@ -2016,8 +2016,8 @@ static void handle_nearby_ability(monsters *monster) { simple_monster_message(monster, " stares at you."); - if (you.paralysis < 10) - you.paralysis += 2 + random2(3); + if (you.duration[DUR_PARALYSIS] < 10) + you.duration[DUR_PARALYSIS] += 2 + random2(3); } break; @@ -3359,7 +3359,7 @@ static void monster_add_energy(monsters *monster) monster->speed_increment += energy_gained; - if (you.slow > 0) + if (you.duration[DUR_SLOW] > 0) monster->speed_increment += energy_gained; } diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index afc4a5811c..6e787655fd 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -693,7 +693,6 @@ bool new_game(void) //jmf: NEW ASSERTS: we ought to do a *lot* of these ASSERT(NUM_SPELLS < SPELL_NO_SPELL); ASSERT(NUM_JOBS < JOB_UNKNOWN); - ASSERT(NUM_ATTRIBUTES >= 30); init_player(); diff --git a/crawl-ref/source/ouch.cc b/crawl-ref/source/ouch.cc index 06c3b9fefb..5025e419a8 100644 --- a/crawl-ref/source/ouch.cc +++ b/crawl-ref/source/ouch.cc @@ -735,7 +735,7 @@ void ouch( int dam, int death_source, kill_method_type death_type, ait_hp_loss hpl(dam, death_type); interrupt_activity( AI_HP_LOSS, &hpl ); - if (you.deaths_door && death_type != KILLED_BY_LAVA + if (you.duration[DUR_DEATHS_DOOR] && death_type != KILLED_BY_LAVA && death_type != KILLED_BY_WATER) { return; diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc index 3400ddf5f0..a66b85619e 100644 --- a/crawl-ref/source/output.cc +++ b/crawl-ref/source/output.cc @@ -187,7 +187,7 @@ void print_stats(void) gotoxy(xcol + 5, 7); - if (you.might) + if (you.duration[DUR_MIGHT]) textcolor(LIGHTBLUE); // no end of effect warning else if (you.strength < you.max_strength) textcolor(YELLOW); @@ -499,19 +499,19 @@ void print_stats(void) if (wearing_amulet( AMU_CONTROLLED_FLIGHT )) { - dur_colour( MAGENTA, (you.levitation <= 10 && !perm) ); + dur_colour( MAGENTA, (you.duration[DUR_LEVITATION] <= 10 && !perm) ); cprintf( "Fly " ); } else { - dur_colour( BLUE, (you.levitation <= 10 && !perm) ); + dur_colour( BLUE, (you.duration[DUR_LEVITATION] <= 10 && !perm) ); cprintf( "Lev " ); } } - if (you.invis) + if (you.duration[DUR_INVIS]) { - dur_colour( BLUE, (you.invis <= 6) ); + dur_colour( BLUE, (you.duration[DUR_INVIS] <= 6) ); cprintf( "Invis " ); } @@ -557,7 +557,7 @@ void print_stats(void) // using the '@' command. Things like confusion and sticky flame // hide their amounts and are thus always the same colour (so // we're not really exposing any new information). --bwr - if (you.conf) + if (you.duration[DUR_CONF]) { textcolor( RED ); // no different levels cprintf( "Conf " ); @@ -569,12 +569,12 @@ void print_stats(void) cprintf( "Fire " ); } - if (you.poisoning) + if (you.duration[DUR_POISONING]) { // We skip marking "quite" poisoned and instead mark the // levels where the rules for dealing poison damage change // significantly. See acr.cc for that code. -- bwr - textcolor( bad_ench_colour( you.poisoning, 5, 10 ) ); + textcolor( bad_ench_colour( you.duration[DUR_POISONING], 5, 10 ) ); cprintf( "Pois " ); } @@ -605,14 +605,14 @@ void print_stats(void) cprintf( "Swift " ); } - if (you.slow && !you.haste) + if (you.duration[DUR_SLOW] && !you.duration[DUR_HASTE]) { textcolor( RED ); // no end of effect warning cprintf( "Slow" ); } - else if (you.haste && !you.slow) + else if (you.duration[DUR_HASTE] && !you.duration[DUR_SLOW]) { - dur_colour( BLUE, (you.haste <= 6) ); + dur_colour( BLUE, (you.duration[DUR_HASTE] <= 6) ); cprintf( "Fast" ); } @@ -1385,32 +1385,32 @@ std::string status_mut_abilities() // if (you.duration[DUR_SEE_INVISIBLE]) // text += "see invisible, "; - if (you.invis) + if (you.duration[DUR_INVIS]) text += "invisible, "; - if (you.conf) + if (you.duration[DUR_CONF]) text += "confused, "; - if (you.paralysis) + if (you.duration[DUR_PARALYSIS]) text += "paralysed, "; - if (you.exhausted) + if (you.duration[DUR_EXHAUSTED]) text += "exhausted, "; - if (you.might) + if (you.duration[DUR_MIGHT]) text += "mighty, "; - if (you.berserker) + if (you.duration[DUR_BERSERKER]) text += "berserking, "; if (player_is_levitating()) text += "levitating, "; - if (you.poisoning) + if (you.duration[DUR_POISONING]) { - text += (you.poisoning > 10) ? "extremely" : - (you.poisoning > 5) ? "very" : - (you.poisoning > 3) ? "quite" + text += (you.duration[DUR_POISONING] > 10) ? "extremely" : + (you.duration[DUR_POISONING] > 5) ? "very" : + (you.duration[DUR_POISONING] > 3) ? "quite" : "mildly"; text += " poisoned, "; } @@ -1426,14 +1426,14 @@ std::string status_mut_abilities() if (you.rotting || you.species == SP_GHOUL) text += "rotting, "; - if (you.confusing_touch) + if (you.duration[DUR_CONFUSING_TOUCH]) text += "confusing touch, "; - if (you.sure_blade) + if (you.duration[DUR_SURE_BLADE]) text += "bonded with blade, "; int move_cost = (player_speed() * player_movement_speed()) / 10; - if ( you.slow ) + if ( you.duration[DUR_SLOW] ) move_cost *= 2; text += (move_cost < 8) ? "very quick, " : @@ -1441,11 +1441,11 @@ std::string status_mut_abilities() (move_cost == 10) ? "" : (move_cost < 13) ? "slow, " : ""; - if (you.slow && !you.haste) + if (you.duration[DUR_SLOW] && !you.duration[DUR_HASTE]) text += "slowed, "; - else if (you.haste && !you.slow) + else if (you.duration[DUR_HASTE] && !you.duration[DUR_SLOW]) text += "hasted, "; - else if (!you.haste && you.duration[DUR_SWIFTNESS]) + else if (!you.duration[DUR_HASTE] && you.duration[DUR_SWIFTNESS]) text += "swift, "; const int mr = player_res_magic(); @@ -1519,7 +1519,7 @@ std::string status_mut_abilities() : "You feel confident with your ability to fight" ); text += info; - if (you.deaths_door) + if (you.duration[DUR_DEATHS_DOOR]) text += "\nYou are standing in death's doorway."; //---------------------------- diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index 940c0cc90b..979166c9be 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -208,7 +208,7 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift, int entry_x = (stepped) ? you.x_pos : x; int entry_y = (stepped) ? you.y_pos : y; - if (stepped && !force && !you.conf) + if (stepped && !force && !you.duration[DUR_CONF]) { bool okay = yesno( "Do you really want to step there?", false, 'n' ); @@ -262,7 +262,7 @@ bool move_player_to_grid( int x, int y, bool stepped, bool allow_shift, mpr("Moving in this stuff is going to be slow."); - if (you.invis) + if (you.duration[DUR_INVIS]) mpr( "... and don't expect to remain undetected." ); } } @@ -713,11 +713,11 @@ int player_hunger_rate(void) // moved here from acr.cc... maintaining the >= 40 behaviour if (you.hunger >= 40) { - if (you.invis > 0) + if (you.duration[DUR_INVIS] > 0) hunger += 5; // berserk has its own food penalty -- excluding berserk haste - if (you.haste > 0 && !you.berserker) + if (you.duration[DUR_HASTE] > 0 && !you.duration[DUR_BERSERKER]) hunger += 5; } @@ -894,7 +894,7 @@ int player_res_fire(bool calc_unid) // mutations: rf += you.mutation[MUT_HEAT_RESISTANCE]; - if (you.fire_shield) + if (you.duration[DUR_FIRE_SHIELD]) rf += 2; // transformations: @@ -955,7 +955,7 @@ int player_res_cold(bool calc_unid) // mutations: rc += you.mutation[MUT_COLD_RESISTANCE]; - if (you.fire_shield) + if (you.duration[DUR_FIRE_SHIELD]) rc -= 2; // transformations: @@ -1190,7 +1190,7 @@ int player_spec_fire() // rings of fire: sf += player_equip( EQ_RINGS, RING_FIRE ); - if (you.fire_shield) + if (you.duration[DUR_FIRE_SHIELD]) sf++; return sf; @@ -1446,7 +1446,7 @@ int player_speed(void) { int ps = 10; - if (you.haste) + if (you.duration[DUR_HASTE]) ps /= 2; switch (you.attribute[ATTR_TRANSFORMATION]) @@ -1913,7 +1913,7 @@ int old_player_evasion(void) // We return 2 here to give the player some chance of not being hit, // repulsion fields still work while paralysed - if (you.paralysis) + if (you.duration[DUR_PARALYSIS]) return (2 + you.mutation[MUT_REPULSION_FIELD] * 2); if (you.species == SP_CENTAUR) @@ -2027,7 +2027,7 @@ int player_shield_class(void) //jmf: changes for new spell if (shield == -1) { - if (!you.fire_shield && you.duration[DUR_CONDENSATION_SHIELD]) + if (!you.duration[DUR_FIRE_SHIELD] && you.duration[DUR_CONDENSATION_SHIELD]) base_shield = 2 + (you.skills[SK_ICE_MAGIC] / 6); // max 6 else return (0); @@ -2786,9 +2786,9 @@ void level_change(void) else if (you.experience_level == 15) { mpr("You can now fly continuously.", MSGCH_INTRINSIC_GAIN); - if (you.levitation) + if (you.duration[DUR_LEVITATION]) { - you.levitation = 100; + you.duration[DUR_LEVITATION] = 100; you.duration[DUR_CONTROLLED_FLIGHT] = 100; } } @@ -2843,7 +2843,7 @@ void level_change(void) // - 12mar2000 {dlb} int check_stealth(void) { - if (you.special_wield == SPWLD_SHADOW || you.berserker) + if (you.special_wield == SPWLD_SHADOW || you.duration[DUR_BERSERKER]) return (0); int stealth = you.dex * 3; @@ -2884,7 +2884,7 @@ int check_stealth(void) else if (you.burden_state == BS_OVERLOADED) stealth /= 5; - if (you.conf) + if (you.duration[DUR_CONF]) stealth /= 3; const int arm = you.equip[EQ_BODY_ARMOUR]; @@ -2974,7 +2974,7 @@ void display_char_status() { if (you.is_undead) mpr( "You are undead." ); - else if (you.deaths_door) + else if (you.duration[DUR_DEATHS_DOOR]) mpr( "You are standing in death's doorway." ); else mpr( "You are alive." ); @@ -3069,40 +3069,40 @@ void display_char_status() if (you.duration[DUR_SEE_INVISIBLE]) mpr( "You can see invisible." ); - if (you.invis) + if (you.duration[DUR_INVIS]) mpr( "You are invisible." ); - if (you.conf) + if (you.duration[DUR_CONF]) mpr( "You are confused." ); - if (you.paralysis) + if (you.duration[DUR_PARALYSIS]) mpr( "You are paralysed." ); - if (you.exhausted) + if (you.duration[DUR_EXHAUSTED]) mpr( "You are exhausted." ); - if (you.slow && you.haste) + if (you.duration[DUR_SLOW] && you.duration[DUR_HASTE]) mpr( "You are under both slowing and hasting effects." ); - else if (you.slow) + else if (you.duration[DUR_SLOW]) mpr( "Your actions are slowed." ); - else if (you.haste) + else if (you.duration[DUR_HASTE]) mpr( "Your actions are hasted." ); - if (you.might) + if (you.duration[DUR_MIGHT]) mpr( "You are mighty." ); - if (you.berserker) + if (you.duration[DUR_BERSERKER]) mpr( "You are possessed by a berserker rage." ); if (player_is_levitating()) mpr( "You are hovering above the floor." ); - if (you.poisoning) + if (you.duration[DUR_POISONING]) { mprf("You are %s poisoned.", - (you.poisoning > 10) ? "extremely" : - (you.poisoning > 5) ? "very" : - (you.poisoning > 3) ? "quite" + (you.duration[DUR_POISONING] > 10) ? "extremely" : + (you.duration[DUR_POISONING] > 5) ? "very" : + (you.duration[DUR_POISONING] > 3) ? "quite" : "mildly" ); } @@ -3129,24 +3129,24 @@ void display_char_status() // prints a contamination message contaminate_player( 0, true ); - if (you.confusing_touch) + if (you.duration[DUR_CONFUSING_TOUCH]) { mprf("Your hands are glowing %s red.", - (you.confusing_touch > 40) ? "an extremely bright" : - (you.confusing_touch > 20) ? "bright" + (you.duration[DUR_CONFUSING_TOUCH] > 40) ? "an extremely bright" : + (you.duration[DUR_CONFUSING_TOUCH] > 20) ? "bright" : "a soft" ); } - if (you.sure_blade) + if (you.duration[DUR_SURE_BLADE]) { mprf("You have a %sbond with your blade.", - (you.sure_blade > 15) ? "strong " : - (you.sure_blade > 5) ? "" + (you.duration[DUR_SURE_BLADE] > 15) ? "strong " : + (you.duration[DUR_SURE_BLADE] > 5) ? "" : "weak " ); } int move_cost = (player_speed() * player_movement_speed()) / 10; - if ( you.slow ) + if ( you.duration[DUR_SLOW] ) move_cost *= 2; const bool water = player_in_water(); @@ -4258,13 +4258,13 @@ bool poison_player( int amount, bool force ) if ((!force && player_res_poison()) || amount <= 0) return false; - const int old_value = you.poisoning; - you.poisoning += amount; + const int old_value = you.duration[DUR_POISONING]; + you.duration[DUR_POISONING] += amount; - if (you.poisoning > 40) - you.poisoning = 40; + if (you.duration[DUR_POISONING] > 40) + you.duration[DUR_POISONING] = 40; - if (you.poisoning > old_value) + if (you.duration[DUR_POISONING] > old_value) { // XXX: which message channel for this message? mprf("You are %spoisoned.", (old_value > 0) ? "more " : "" ); @@ -4275,14 +4275,14 @@ bool poison_player( int amount, bool force ) void reduce_poison_player( int amount ) { - if (you.poisoning == 0 || amount <= 0) + if (you.duration[DUR_POISONING] == 0 || amount <= 0) return; - you.poisoning -= amount; + you.duration[DUR_POISONING] -= amount; - if (you.poisoning <= 0) + if (you.duration[DUR_POISONING] <= 0) { - you.poisoning = 0; + you.duration[DUR_POISONING] = 0; mpr( "You feel better.", MSGCH_RECOVERY ); } else @@ -4302,32 +4302,32 @@ void confuse_player( int amount, bool resistable ) return; } - const int old_value = you.conf; - you.conf += amount; + const int old_value = you.duration[DUR_CONF]; + you.duration[DUR_CONF] += amount; - if (you.conf > 40) - you.conf = 40; + if (you.duration[DUR_CONF] > 40) + you.duration[DUR_CONF] = 40; - if (you.conf > old_value) + if (you.duration[DUR_CONF] > old_value) { // XXX: which message channel for this message? mprf("You are %sconfused.", (old_value > 0) ? "more " : "" ); learned_something_new(TUT_YOU_ENCHANTED); - xom_is_stimulated(you.conf - old_value); + xom_is_stimulated(you.duration[DUR_CONF] - old_value); } } void reduce_confuse_player( int amount ) { - if (you.conf == 0 || amount <= 0) + if (you.duration[DUR_CONF] == 0 || amount <= 0) return; - you.conf -= amount; + you.duration[DUR_CONF] -= amount; - if (you.conf <= 0) + if (you.duration[DUR_CONF] <= 0) { - you.conf = 0; + you.duration[DUR_CONF] = 0; mpr( "You feel less confused." ); } } @@ -4339,41 +4339,41 @@ void slow_player( int amount ) if (wearing_amulet( AMU_RESIST_SLOW )) mpr("You feel momentarily lethargic."); - else if (you.slow >= 100) + else if (you.duration[DUR_SLOW] >= 100) mpr( "You already are as slow as you could be." ); else { - if (you.slow == 0) + if (you.duration[DUR_SLOW] == 0) mpr( "You feel yourself slow down." ); else mpr( "You feel as though you will be slow longer." ); - you.slow += amount; + you.duration[DUR_SLOW] += amount; - if (you.slow > 100) - you.slow = 100; + if (you.duration[DUR_SLOW] > 100) + you.duration[DUR_SLOW] = 100; learned_something_new(TUT_YOU_ENCHANTED); } } void dec_slow_player( void ) { - if (you.slow > 1) + if (you.duration[DUR_SLOW] > 1) { // BCR - Amulet of resist slow affects slow counter if (wearing_amulet(AMU_RESIST_SLOW)) { - you.slow -= 5; - if (you.slow < 1) - you.slow = 1; + you.duration[DUR_SLOW] -= 5; + if (you.duration[DUR_SLOW] < 1) + you.duration[DUR_SLOW] = 1; } else - you.slow--; + you.duration[DUR_SLOW]--; } - else if (you.slow == 1) + else if (you.duration[DUR_SLOW] == 1) { mpr("You feel yourself speed up.", MSGCH_DURATION); - you.slow = 0; + you.duration[DUR_SLOW] = 0; } } @@ -4387,9 +4387,9 @@ void haste_player( int amount ) if (amu_eff) mpr( "Your amulet glows brightly." ); - if (you.haste == 0) + if (you.duration[DUR_HASTE] == 0) mpr( "You feel yourself speed up." ); - else if (you.haste > 80 + 20 * amu_eff) + else if (you.duration[DUR_HASTE] > 80 + 20 * amu_eff) mpr( "You already have as much speed as you can handle." ); else { @@ -4397,33 +4397,33 @@ void haste_player( int amount ) contaminate_player(1); } - you.haste += amount; + you.duration[DUR_HASTE] += amount; - if (you.haste > 80 + 20 * amu_eff) - you.haste = 80 + 20 * amu_eff; + if (you.duration[DUR_HASTE] > 80 + 20 * amu_eff) + you.duration[DUR_HASTE] = 80 + 20 * amu_eff; did_god_conduct( DID_STIMULANTS, 4 + random2(4) ); } void dec_haste_player( void ) { - if (you.haste > 1) + if (you.duration[DUR_HASTE] > 1) { // BCR - Amulet of resist slow affects haste counter if (!wearing_amulet(AMU_RESIST_SLOW) || coinflip()) - you.haste--; + you.duration[DUR_HASTE]--; - if (you.haste == 6) + if (you.duration[DUR_HASTE] == 6) { mpr( "Your extra speed is starting to run out.", MSGCH_DURATION ); if (coinflip()) - you.haste--; + you.duration[DUR_HASTE]--; } } - else if (you.haste == 1) + else if (you.duration[DUR_HASTE] == 1) { mpr( "You feel yourself slow down.", MSGCH_DURATION ); - you.haste = 0; + you.duration[DUR_HASTE] = 0; } } @@ -4502,28 +4502,13 @@ void player::init() just_autoprayed = false; berserk_penalty = 0; - berserker = 0; - conf = 0; - confusing_touch = 0; - deaths_door = 0; disease = 0; elapsed_time = 0; - exhausted = 0; - haste = 0; - invis = 0; - levitation = 0; - might = 0; - paralysis = 0; - poisoning = 0; rotting = 0; - fire_shield = 0; - slow = 0; special_wield = SPWLD_NONE; - sure_blade = 0; synch_time = 0; magic_contamination = 0; - backlight = 0; base_hp = 5000; base_hp2 = 5000; @@ -4664,7 +4649,8 @@ coord_def player::pos() const bool player::is_levitating() const { - return (attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON || levitation); + return (attribute[ATTR_TRANSFORMATION] == TRAN_DRAGON || + duration[DUR_LEVITATION]); } bool player::in_water() const @@ -4804,7 +4790,7 @@ int player::damage_brand(int) if ( !is_range_weapon(inv[wpn]) ) ret = get_weapon_brand( inv[wpn] ); } - else if (confusing_touch) + else if (duration[DUR_CONFUSING_TOUCH]) ret = SPWPN_CONFUSE; else if (mutation[MUT_DRAIN_LIFE]) ret = SPWPN_DRAINING; @@ -4936,7 +4922,7 @@ bool player::can_go_berserk() const bool player::can_go_berserk(bool verbose) const { - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { if (verbose) mpr("You're already berserk!"); @@ -4944,7 +4930,7 @@ bool player::can_go_berserk(bool verbose) const return (false); } - if (you.exhausted) + if (you.duration[DUR_EXHAUSTED]) { if (verbose) mpr("You're too exhausted to go berserk."); @@ -5005,12 +4991,12 @@ int player::warding() const bool player::paralysed() const { - return (paralysis); + return (duration[DUR_PARALYSIS]); } bool player::confused() const { - return (conf); + return (duration[DUR_CONF]); } int player::shield_block_penalty() const @@ -5198,13 +5184,13 @@ void player::confuse(int str) void player::paralyse(int str) { mprf( "You %s the ability to move!", - (paralysis) ? "still haven't" : "suddenly lose" ); + (duration[DUR_PARALYSIS]) ? "still haven't" : "suddenly lose" ); - if (str > paralysis) - paralysis = str; + if (str > duration[DUR_PARALYSIS]) + duration[DUR_PARALYSIS] = str; - if (paralysis > 13) - paralysis = 13; + if (duration[DUR_PARALYSIS] > 13) + duration[DUR_PARALYSIS] = 13; } void player::slow_down(int str) @@ -5252,12 +5238,12 @@ bool player::can_see_invisible() const bool player::invisible() const { - return (invis); + return (duration[DUR_INVIS]); } bool player::backlit() const { - return (magic_contamination >= 5 || backlight); + return (magic_contamination >= 5 || duration[DUR_BACKLIGHT]); } void player::mutate() diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc index 95eacfc701..47d95d5028 100644 --- a/crawl-ref/source/religion.cc +++ b/crawl-ref/source/religion.cc @@ -1849,21 +1849,21 @@ void divine_retribution( god_type god ) break; case 3: - if (!you.paralysis) + if (!you.duration[DUR_PARALYSIS]) { dec_penance(GOD_TROG, 3); mpr( "You suddenly pass out!", MSGCH_WARN ); - you.paralysis = 2 + random2(6); + you.duration[DUR_PARALYSIS] = 2 + random2(6); } break; case 4: case 5: - if (you.slow < 90) + if (you.duration[DUR_SLOW] < 90) { dec_penance( GOD_TROG, 1 ); mpr( "You suddenly feel exhausted!", MSGCH_WARN ); - you.exhausted = 100; + you.duration[DUR_EXHAUSTED] = 100; slow_player( 100 ); } break; @@ -2127,7 +2127,7 @@ void divine_retribution( god_type god ) } else { - if (you.slow < 90) + if (you.duration[DUR_SLOW] < 90) { mpr( "The divine experience leaves you feeling exhausted!", MSGCH_WARN ); diff --git a/crawl-ref/source/skills2.cc b/crawl-ref/source/skills2.cc index 2c29dcea27..40f74605b5 100644 --- a/crawl-ref/source/skills2.cc +++ b/crawl-ref/source/skills2.cc @@ -2200,7 +2200,7 @@ int calc_hp(void) hitp += (you.experience_level * you.skills[SK_FIGHTING]) / 5; // being berserk makes you resistant to damage. I don't know why. - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { hitp *= 15; hitp /= 10; diff --git a/crawl-ref/source/spells1.cc b/crawl-ref/source/spells1.cc index 62412a9ce7..973b82a2e7 100644 --- a/crawl-ref/source/spells1.cc +++ b/crawl-ref/source/spells1.cc @@ -55,7 +55,7 @@ int blink(void) mpr("You feel a weird sense of stasis."); else if (you.level_type == LEVEL_ABYSS && !one_chance_in(3)) mpr("The power of the Abyss keeps you in your place!"); - else if (you.conf) + else if (you.duration[DUR_CONF]) random_blink(false); else if (!allow_control_teleport(true)) { @@ -138,7 +138,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.conf + else if (player_control_teleport() && !you.duration[DUR_CONF] && allow_partial_control && allow_control_teleport()) { mpr("You may select the general direction of your translocation."); @@ -604,7 +604,7 @@ bool cast_revivification(int power) void cast_cure_poison(int mabil) { - if (!you.poisoning) + if (!you.duration[DUR_POISONING]) canned_msg(MSG_NOTHING_HAPPENS); else reduce_poison_player( 2 + random2(mabil) + random2(3) ); @@ -616,12 +616,12 @@ void purification(void) { mpr("You feel purified!"); - you.poisoning = 0; + you.duration[DUR_POISONING] = 0; you.rotting = 0; - you.conf = 0; - you.slow = 0; + you.duration[DUR_CONF] = 0; + you.duration[DUR_SLOW] = 0; you.disease = 0; - you.paralysis = 0; // can't currently happen -- bwr + you.duration[DUR_PARALYSIS] = 0; // can't currently happen -- bwr } // end purification() int allowed_deaths_door_hp(void) @@ -638,7 +638,7 @@ void cast_deaths_door(int pow) { if (you.is_undead) mpr("You're already dead!"); - else if (you.deaths_door) + else if (you.duration[DUR_DEATHS_DOOR]) mpr("Your appeal for an extension has been denied."); else { @@ -648,10 +648,10 @@ void cast_deaths_door(int pow) set_hp( allowed_deaths_door_hp(), false ); deflate_hp( you.hp_max, false ); - you.deaths_door = 10 + random2avg(13, 3) + (random2(pow) / 10); + you.duration[DUR_DEATHS_DOOR] = 10 + random2avg(13, 3) + (random2(pow) / 10); - if (you.deaths_door > 25) - you.deaths_door = 23 + random2(5); + if (you.duration[DUR_DEATHS_DOOR] > 25) + you.duration[DUR_DEATHS_DOOR] = 23 + random2(5); } return; @@ -690,12 +690,9 @@ void abjuration(int pow) // not as direct as falling into deep water) -- bwr void antimagic() { - int* direct_list[] = { - &you.haste, &you.slow, &you.paralysis, &you.conf, - &you.might, &you.invis, &you.fire_shield - }; - duration_type dur_list[] = { + DUR_HASTE, DUR_SLOW, DUR_PARALYSIS, DUR_CONF, + DUR_MIGHT, DUR_INVIS, DUR_FIRE_SHIELD, DUR_WEAPON_BRAND, DUR_ICY_ARMOUR, DUR_REPEL_MISSILES, DUR_REGENERATION, DUR_DEFLECT_MISSILES, DUR_SWIFTNESS, DUR_INSULATION, DUR_STONEMAIL, DUR_CONTROLLED_FLIGHT, DUR_CONTROL_TELEPORT, DUR_RESIST_POISON, @@ -703,12 +700,8 @@ void antimagic() DUR_FORESCRY, DUR_SEE_INVISIBLE, DUR_SILENCE, DUR_CONDENSATION_SHIELD }; - if (you.levitation > 2) - you.levitation = 2; - - for ( unsigned int i = 0; i < ARRAYSIZE(direct_list); ++i ) - if ( *(direct_list[i]) > 1 ) - *(direct_list[i]) = 1; + if (you.duration[DUR_LEVITATION] > 2) + you.duration[DUR_LEVITATION] = 2; for ( unsigned int i = 0; i < ARRAYSIZE(dur_list); ++i ) if ( you.duration[dur_list[i]] > 1 ) @@ -721,33 +714,33 @@ void extension(int pow) { int contamination = random2(2); - if (you.haste) + if (you.duration[DUR_HASTE]) { potion_effect(POT_SPEED, pow); contamination++; } - if (you.slow) + if (you.duration[DUR_SLOW]) potion_effect(POT_SLOWING, pow); #if 0 - if (you.paralysis) + if (you.duration[DUR_PARALYSIS]) potion_effect(POT_PARALYSIS, pow); // how did you cast extension? - if (you.conf) + if (you.duration[DUR_CONF]) potion_effect(POT_CONFUSION, pow); // how did you cast extension? #endif - if (you.might) + if (you.duration[DUR_MIGHT]) { potion_effect(POT_MIGHT, pow); contamination++; } - if (you.levitation) + if (you.duration[DUR_LEVITATION]) potion_effect(POT_LEVITATION, pow); - if (you.invis) + if (you.duration[DUR_INVIS]) { potion_effect(POT_INVISIBILITY, pow); contamination++; @@ -765,12 +758,12 @@ void extension(int pow) if (you.duration[DUR_DEFLECT_MISSILES]) deflection(pow); - if (you.fire_shield) + if (you.duration[DUR_FIRE_SHIELD]) { - you.fire_shield += random2(pow / 20); + you.duration[DUR_FIRE_SHIELD] += random2(pow / 20); - if (you.fire_shield > 50) - you.fire_shield = 50; + if (you.duration[DUR_FIRE_SHIELD] > 50) + you.duration[DUR_FIRE_SHIELD] = 50; mpr("Your ring of flames roars with new vigour!"); } @@ -971,10 +964,10 @@ void cast_fly(int power) else mpr("You feel more buoyant."); - if (you.levitation + dur_change > 100) - you.levitation = 100; + if (you.duration[DUR_LEVITATION] + dur_change > 100) + you.duration[DUR_LEVITATION] = 100; else - you.levitation += dur_change; + you.duration[DUR_LEVITATION] += dur_change; if (you.duration[DUR_CONTROLLED_FLIGHT] + dur_change > 100) you.duration[DUR_CONTROLLED_FLIGHT] = 100; @@ -1025,10 +1018,10 @@ void cast_teleport_control(int power) void cast_ring_of_flames(int power) { - you.fire_shield += 5 + (power / 10) + (random2(power) / 5); + you.duration[DUR_FIRE_SHIELD] += 5 + (power / 10) + (random2(power) / 5); - if (you.fire_shield > 50) - you.fire_shield = 50; + if (you.duration[DUR_FIRE_SHIELD] > 50) + you.duration[DUR_FIRE_SHIELD] = 50; mpr("The air around you leaps into flame!"); @@ -1038,12 +1031,12 @@ void cast_ring_of_flames(int power) void cast_confusing_touch(int power) { msg::stream << "Your " << your_hand(true) << " begin to glow " - << (you.confusing_touch ? "brighter" : "red") << std::endl; + << (you.duration[DUR_CONFUSING_TOUCH] ? "brighter" : "red") << std::endl; - you.confusing_touch += 5 + (random2(power) / 5); + you.duration[DUR_CONFUSING_TOUCH] += 5 + (random2(power) / 5); - if (you.confusing_touch > 50) - you.confusing_touch = 50; + if (you.duration[DUR_CONFUSING_TOUCH] > 50) + you.duration[DUR_CONFUSING_TOUCH] = 50; } // end cast_confusing_touch() @@ -1060,15 +1053,15 @@ bool cast_sure_blade(int power) } else { - if (!you.sure_blade) + if (!you.duration[DUR_SURE_BLADE]) mpr("You become one with your weapon."); - else if (you.sure_blade < 25) + else if (you.duration[DUR_SURE_BLADE] < 25) mpr("Your bond becomes stronger."); - you.sure_blade += 8 + (random2(power) / 10); + you.duration[DUR_SURE_BLADE] += 8 + (random2(power) / 10); - if (you.sure_blade > 25) - you.sure_blade = 25; + if (you.duration[DUR_SURE_BLADE] > 25) + you.duration[DUR_SURE_BLADE] = 25; success = true; } @@ -1078,9 +1071,9 @@ bool cast_sure_blade(int power) void manage_fire_shield(void) { - you.fire_shield--; + you.duration[DUR_FIRE_SHIELD]--; - if (!you.fire_shield) + if (!you.duration[DUR_FIRE_SHIELD]) return; char stx = 0, sty = 0; diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc index bb3427da8f..cfd9b8921a 100644 --- a/crawl-ref/source/spells2.cc +++ b/crawl-ref/source/spells2.cc @@ -805,7 +805,7 @@ void cast_toxic_radiance(void) mesclr(); // determine whether the player is hit by the radiance: {dlb} - if (you.invis) + if (you.duration[DUR_INVIS]) { mpr("The light passes straight through your body."); } diff --git a/crawl-ref/source/spells3.cc b/crawl-ref/source/spells3.cc index 503c967aa4..1dfec6784e 100644 --- a/crawl-ref/source/spells3.cc +++ b/crawl-ref/source/spells3.cc @@ -304,7 +304,7 @@ void sublimation(int power) || you.inv[you.equip[EQ_WEAPON]].base_type != OBJ_FOOD || you.inv[you.equip[EQ_WEAPON]].sub_type != FOOD_CHUNK) { - if (you.deaths_door) + if (you.duration[DUR_DEATHS_DOOR]) { mpr( "A conflicting enchantment prevents the spell from " "coming into effect." ); @@ -593,7 +593,7 @@ void you_teleport(void) static bool teleport_player( bool allow_control, bool new_abyss_area ) { - bool is_controlled = (allow_control && !you.conf + bool is_controlled = (allow_control && !you.duration[DUR_CONF] && player_control_teleport() && allow_control_teleport()); diff --git a/crawl-ref/source/spells4.cc b/crawl-ref/source/spells4.cc index 6a3fccf2f3..aef2799ce4 100644 --- a/crawl-ref/source/spells4.cc +++ b/crawl-ref/source/spells4.cc @@ -1169,7 +1169,7 @@ void cast_ignite_poison(int pow) } // player is poisoned - damage += roll_dice( you.poisoning, 6 ); + damage += roll_dice( you.duration[DUR_POISONING], 6 ); if (damage) { @@ -1192,10 +1192,10 @@ void cast_ignite_poison(int pow) ouch( damage, 0, KILLED_BY_TARGETTING ); - if (you.poisoning > 0) + if (you.duration[DUR_POISONING] > 0) { mpr( "You feel that the poison has left your system." ); - you.poisoning = 0; + you.duration[DUR_POISONING] = 0; } } @@ -2982,7 +2982,7 @@ void cast_sandblast(int pow, bolt &beam) void cast_condensation_shield(int pow) { - if (you.equip[EQ_SHIELD] != -1 || you.fire_shield) + if (you.equip[EQ_SHIELD] != -1 || you.duration[DUR_FIRE_SHIELD]) canned_msg(MSG_SPELL_FIZZLES); else { diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index bc3eee8912..23893fc384 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1138,13 +1138,13 @@ bool learn_spell(void) return (false); } - if (you.conf) + if (you.duration[DUR_CONF]) { mpr("You are too confused!"); return (false); } - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return (false); diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index e3d7357851..ec26318882 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -537,7 +537,7 @@ bool cast_a_spell() return (false); } - if (you.berserker) + if (you.duration[DUR_BERSERKER]) { canned_msg(MSG_TOO_BERSERK); return (false); @@ -616,7 +616,7 @@ bool cast_a_spell() return (false); } - if (you.conf) + if (you.duration[DUR_CONF]) random_uselessness( 2 + random2(7), 0 ); else { diff --git a/crawl-ref/source/tags.cc b/crawl-ref/source/tags.cc index 274fed6dbb..0049611f7d 100644 --- a/crawl-ref/source/tags.cc +++ b/crawl-ref/source/tags.cc @@ -657,14 +657,7 @@ static void tag_construct_you(struct tagHeader &th) marshallByte(th,you.religion); marshallByte(th,you.piety); - marshallByte(th,you.invis); - marshallByte(th,you.conf); - marshallByte(th,you.paralysis); - marshallByte(th,you.slow); - marshallByte(th,you.fire_shield); marshallByte(th,you.rotting); - marshallByte(th,you.exhausted); - marshallByte(th,you.deaths_door); marshallByte(th,you.symbol); marshallByte(th,you.colour); marshallByte(th,you.pet_target); @@ -675,7 +668,6 @@ static void tag_construct_you(struct tagHeader &th) marshallByte(th,you.your_level); marshallByte(th,you.is_undead); marshallByte(th,you.special_wield); - marshallByte(th,you.berserker); marshallByte(th,you.berserk_penalty); marshallByte(th,you.level_type); marshallByte(th,you.synch_time); @@ -684,26 +676,6 @@ static void tag_construct_you(struct tagHeader &th) marshallShort(th, you.hp); - if (you.haste > 215) - you.haste = 215; - - marshallByte(th,you.haste); - - if (you.might > 215) - you.might = 215; - - marshallByte(th,you.might); - - if (you.levitation > 215) - you.levitation = 215; - - marshallByte(th,you.levitation); - - if (you.poisoning > 215) - you.poisoning = 215; - - marshallByte(th,you.poisoning); - marshallShort(th, you.hunger); // how many you.equip? @@ -716,8 +688,6 @@ static void tag_construct_you(struct tagHeader &th) marshallByte(th,you.strength); marshallByte(th,you.intel); marshallByte(th,you.dex); - marshallByte(th,you.confusing_touch); - marshallByte(th,you.sure_blade); marshallByte(th,you.hit_points_regeneration); marshallByte(th,you.magic_points_regeneration); @@ -772,16 +742,16 @@ static void tag_construct_you(struct tagHeader &th) // how many durations? marshallByte(th, NUM_DURATIONS); for (j = 0; j < NUM_DURATIONS; ++j) - marshallByte(th,you.duration[j]); + marshallLong(th,you.duration[j]); // how many attributes? - marshallByte(th, 30); - for (j = 0; j < 30; ++j) + marshallByte(th, NUM_ATTRIBUTES); + for (j = 0; j < NUM_ATTRIBUTES; ++j) marshallByte(th,you.attribute[j]); // how many mutations/demon powers? - marshallShort(th, 100); - for (j = 0; j < 100; ++j) + marshallShort(th, NUM_MUTATIONS); + for (j = 0; j < NUM_MUTATIONS; ++j) { marshallByte(th,you.mutation[j]); marshallByte(th,you.demon_pow[j]); @@ -830,7 +800,6 @@ static void tag_construct_you(struct tagHeader &th) marshallLong( th, you.num_turns ); marshallShort(th, you.magic_contamination); - marshallShort(th, you.backlight); } static void tag_construct_you_items(struct tagHeader &th) @@ -879,10 +848,11 @@ static void tag_construct_you_items(struct tagHeader &th) // how many unique items? marshallByte(th, 50); for (j = 0; j < 50; ++j) - { - marshallByte(th,you.unique_items[j]); /* unique items */ + marshallByte(th,you.unique_items[j]); + + marshallByte(th, NUM_BOOKS); + for (j = 0; j < NUM_BOOKS; ++j) marshallByte(th,you.had_book[j]); - } // how many unrandarts? marshallShort(th, NO_UNRANDARTS); @@ -978,35 +948,23 @@ static void tag_read_you(struct tagHeader &th, char minorVersion) you.religion = static_cast(unmarshallByte(th)); you.piety = unmarshallByte(th); - you.invis = unmarshallByte(th); - you.conf = unmarshallByte(th); - you.paralysis = unmarshallByte(th); - you.slow = unmarshallByte(th); - you.fire_shield = unmarshallByte(th); you.rotting = unmarshallByte(th); - you.exhausted = unmarshallByte(th); - you.deaths_door = unmarshallByte(th); you.symbol = unmarshallByte(th); you.colour = unmarshallByte(th); you.pet_target = unmarshallByte(th); you.max_level = unmarshallByte(th); you.where_are_you = static_cast( unmarshallByte(th) ); - you.char_direction = unmarshallByte(th); + you.char_direction = static_cast(unmarshallByte(th)); you.your_level = unmarshallByte(th); you.is_undead = static_cast(unmarshallByte(th)); you.special_wield = unmarshallByte(th); - you.berserker = unmarshallByte(th); you.berserk_penalty = unmarshallByte(th); you.level_type = static_cast( unmarshallByte(th) ); you.synch_time = unmarshallByte(th); you.disease = unmarshallByte(th); you.species = static_cast(unmarshallByte(th)); you.hp = unmarshallShort(th); - you.haste = unmarshallByte(th); - you.might = unmarshallByte(th); - you.levitation = unmarshallByte(th); - you.poisoning = unmarshallByte(th); you.hunger = unmarshallShort(th); // how many you.equip? @@ -1019,8 +977,6 @@ static void tag_read_you(struct tagHeader &th, char minorVersion) you.strength = unmarshallByte(th); you.intel = unmarshallByte(th); you.dex = unmarshallByte(th); - you.confusing_touch = unmarshallByte(th); - you.sure_blade = unmarshallByte(th); you.hit_points_regeneration = unmarshallByte(th); you.magic_points_regeneration = unmarshallByte(th); @@ -1087,7 +1043,7 @@ static void tag_read_you(struct tagHeader &th, char minorVersion) // how many durations? count_c = unmarshallByte(th); for (j = 0; j < count_c; ++j) - you.duration[j] = (unsigned char) unmarshallByte(th); + you.duration[j] = unmarshallLong(th); // how many attributes? count_c = unmarshallByte(th); @@ -1133,7 +1089,6 @@ static void tag_read_you(struct tagHeader &th, char minorVersion) you.num_turns = unmarshallLong(th); you.magic_contamination = unmarshallShort(th); - you.backlight = unmarshallShort(th); } static void tag_read_you_items(struct tagHeader &th, char minorVersion) @@ -1215,10 +1170,12 @@ static void tag_read_you_items(struct tagHeader &th, char minorVersion) // how many unique items? count_c = unmarshallByte(th); for (j = 0; j < count_c; ++j) - { you.unique_items[j] = unmarshallByte(th); + + // how many books? + count_c = unmarshallByte(th); + for (j = 0; j < count_c; ++j) you.had_book[j] = unmarshallByte(th); - } // how many unrandarts? count_s = unmarshallShort(th); diff --git a/crawl-ref/source/transfor.cc b/crawl-ref/source/transfor.cc index 36f067063c..d90b73667b 100644 --- a/crawl-ref/source/transfor.cc +++ b/crawl-ref/source/transfor.cc @@ -286,7 +286,7 @@ bool transform(int pow, transformation_type which_trans) case TRAN_LICH: // also AC +3, cold +1, neg +3, pois +1, is_undead, res magic +50, // spec_death +1, and drain attack (if empty-handed) - if (you.deaths_door) + if (you.duration[DUR_DEATHS_DOOR]) { mpr( "The transformation conflicts with an enchantment " "already in effect." ); diff --git a/crawl-ref/source/travel.cc b/crawl-ref/source/travel.cc index 1db49cdff9..16632d34c0 100644 --- a/crawl-ref/source/travel.cc +++ b/crawl-ref/source/travel.cc @@ -449,7 +449,7 @@ static bool is_safe_move(int x, int y) static bool player_is_permalevitating() { - return you.levitation > 1 && + return you.duration[DUR_LEVITATION] > 1 && ((you.species == SP_KENKU && you.experience_level >= 15) || player_equip_ego_type( EQ_BOOTS, SPARM_LEVITATION )); } @@ -891,7 +891,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.conf) + if (kbhit() || you.duration[DUR_CONF]) { stop_running(); return CMD_NO_CMD; diff --git a/crawl-ref/source/tutorial.cc b/crawl-ref/source/tutorial.cc index 522511002a..f221e2eec8 100644 --- a/crawl-ref/source/tutorial.cc +++ b/crawl-ref/source/tutorial.cc @@ -719,7 +719,7 @@ void tutorial_prayer_reminder() // occasionally remind injured characters of resting void tutorial_healing_reminder() { - if (you.poisoning && 2*you.hp < you.hp_max) + if (you.duration[DUR_POISONING] && 2*you.hp < you.hp_max) { if (Options.tutorial_events[TUT_NEED_POISON_HEALING]) learned_something_new(TUT_NEED_POISON_HEALING); @@ -728,7 +728,7 @@ void tutorial_healing_reminder() { if (Options.tutorial_events[TUT_NEED_HEALING]) learned_something_new(TUT_NEED_HEALING); - else if (you.num_turns - Options.tut_last_healed >= 50 && !you.poisoning) + else if (you.num_turns - Options.tut_last_healed >= 50 && !you.duration[DUR_POISONING]) { if (Options.tut_just_triggered) return; @@ -1258,7 +1258,7 @@ void learned_something_new(tutorial_event_type seen_what, int x, int y) if (you.species == SP_CENTAUR) text << " As a four-legged centaur you are particularly quick - " "running is an option! "; - if (Options.tutorial_type == TUT_BERSERK_CHAR && !you.berserker + if (Options.tutorial_type == TUT_BERSERK_CHAR && !you.duration[DUR_BERSERKER] && !you.hunger) { text << "\nAlso, with " diff --git a/crawl-ref/source/view.cc b/crawl-ref/source/view.cc index 58b9420421..3aa253c3d4 100644 --- a/crawl-ref/source/view.cc +++ b/crawl-ref/source/view.cc @@ -860,7 +860,7 @@ bool check_awaken(int mons_aw) return (false); // berserkers aren't really concerned about stealth - if (you.berserker) + if (you.duration[DUR_BERSERKER]) return (true); // Repel undead is a holy aura, to which evil creatures are sensitive. @@ -3829,7 +3829,7 @@ static int viewmap_flash_colour() { if (you.special_wield == SPWLD_SHADOW) return (DARKGREY); - else if (you.berserker) + else if (you.duration[DUR_BERSERKER]) return (RED); return (BLACK); -- cgit v1.2.3-54-g00ecf