From 5deb29bf245d7ff57751f4ea2a2159439a516e42 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Mon, 18 May 2009 13:26:18 +0000 Subject: * Fix Bat Form restrictions not applying to choice by clicking (Tiles). * Allow as synonyms for left/right hand in swap_rings(). git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9791 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/abl-show.cc | 2 +- crawl-ref/source/acr.cc | 24 +++----------- crawl-ref/source/delay.cc | 3 +- crawl-ref/source/fight.cc | 19 ++++++----- crawl-ref/source/food.cc | 2 +- crawl-ref/source/it_use3.cc | 6 ++++ crawl-ref/source/item_use.cc | 77 ++++++++++++++++++++++++++++++++++---------- crawl-ref/source/player.cc | 16 +++++---- crawl-ref/source/player.h | 4 +-- crawl-ref/source/spl-book.cc | 6 ++++ crawl-ref/source/spl-cast.cc | 10 +++++- 11 files changed, 108 insertions(+), 61 deletions(-) (limited to 'crawl-ref') diff --git a/crawl-ref/source/abl-show.cc b/crawl-ref/source/abl-show.cc index b0a35bc933..908e609bd0 100644 --- a/crawl-ref/source/abl-show.cc +++ b/crawl-ref/source/abl-show.cc @@ -943,7 +943,7 @@ static bool _activate_talent(const talent& tal) } } else if (tal.which == ABIL_END_TRANSFORMATION - && you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT + && player_in_bat_form() && you.dex <= 5) { mpr("Turning back with such low dexterity would be fatal!", MSGCH_WARN); diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 497c462761..61683c32e8 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1563,7 +1563,7 @@ void process_command( command_type cmd ) case CMD_REMOVE_ARMOUR: { - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { mpr("You can't wear or remove anything in your present form."); break; @@ -1588,21 +1588,11 @@ void process_command( command_type cmd ) break; case CMD_MEMORISE_SPELL: - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) - { - canned_msg(MSG_PRESENT_FORM); - break; - } if (!learn_spell()) flush_input_buffer( FLUSH_ON_FAILURE ); break; case CMD_ZAP_WAND: - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) - { - canned_msg(MSG_PRESENT_FORM); - break; - } zap_wand(); break; @@ -1644,11 +1634,6 @@ void process_command( command_type cmd ) break; case CMD_READ: - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) - { - canned_msg(MSG_PRESENT_FORM); - break; - } read_scroll(); break; @@ -1669,7 +1654,7 @@ void process_command( command_type cmd ) case CMD_CAST_SPELL: case CMD_FORCE_CAST_SPELL: - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { canned_msg(MSG_PRESENT_FORM); break; @@ -2152,8 +2137,7 @@ static void _decrement_durations() } // Vampire bat transformations are permanent (until ended). - if (you.species != SP_VAMPIRE - || you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT + if (you.species != SP_VAMPIRE || !player_in_bat_form() || you.duration[DUR_TRANSFORMATION] <= 5) { if (_decrement_a_duration(DUR_TRANSFORMATION, NULL, random2(3), @@ -3113,7 +3097,7 @@ static void _open_door(coord_def move, bool check_confused) static void _close_door(coord_def move) { - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { mpr("You can't close doors in your present form."); return; diff --git a/crawl-ref/source/delay.cc b/crawl-ref/source/delay.cc index bd531617c4..13e06420ca 100644 --- a/crawl-ref/source/delay.cc +++ b/crawl-ref/source/delay.cc @@ -828,8 +828,7 @@ void handle_delay( void ) if (delay.type == DELAY_FEED_VAMPIRE) { if (you.hunger_state == HS_ENGORGED - || you.hunger_state > HS_SATIATED - && you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + || you.hunger_state > HS_SATIATED && player_in_bat_form()) { // Messages handled in _food_change() in food.cc. stop_delay(); diff --git a/crawl-ref/source/fight.cc b/crawl-ref/source/fight.cc index ed4f7c5ebc..2f1b22783f 100644 --- a/crawl-ref/source/fight.cc +++ b/crawl-ref/source/fight.cc @@ -789,7 +789,7 @@ static bool _player_vampire_draws_blood(const monsters* mon, const int damage, const int chunk_type = mons_corpse_effect(mon->type); // Now print message, need biting unless already done (never for bat form!) - if (needs_bite_msg && you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT) + if (needs_bite_msg && !player_in_bat_form()) { mprf( "You bite %s, and draw %s blood!", mon->name(DESC_NOCAP_THE, true).c_str(), @@ -809,7 +809,7 @@ static bool _player_vampire_draws_blood(const monsters* mon, const int damage, heal += 1 + random2(damage); // Decrease healing when done in bat form. - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) heal /= 2; if (heal > 0) @@ -829,7 +829,7 @@ static bool _player_vampire_draws_blood(const monsters* mon, const int damage, food_value = 15 + random2avg(29, 2); // Bats get a rather less nutrition out of it. - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) food_value /= 2; lessen_hunger(food_value, false); @@ -1691,8 +1691,8 @@ int melee_attack::player_weapon_type_modify(int damage) // All weak hits look the same, except for when the player // has a non-weapon in hand. -- bwr // Exception: vampire bats only _bite_ to allow for drawing blood - if (damage < HIT_WEAK && (you.species != SP_VAMPIRE - || you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT)) + if (damage < HIT_WEAK + && (you.species != SP_VAMPIRE || !player_in_bat_form())) { if (weap_type != WPN_UNKNOWN) attack_verb = "hit"; @@ -3145,7 +3145,7 @@ bool melee_attack::apply_damage_brand() { // Vampire bat form -- why the special handling? if (attacker->atype() == ACT_PLAYER && you.species == SP_VAMPIRE - && you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + && player_in_bat_form()) { _player_vampire_draws_blood(defender_as_monster(), damage_done); break; @@ -3892,10 +3892,9 @@ int melee_attack::player_unarmed_speed() if (you.burden_state == BS_UNENCUMBERED && one_chance_in(heavy_armour_penalty + 1)) { - const bool is_bat = (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT); unarmed_delay = - std::max(10 - you.skills[SK_UNARMED_COMBAT] / (is_bat ? 3 : 5), - min_delay); + std::max(10 - you.skills[SK_UNARMED_COMBAT] + / (player_in_bat_form() ? 3 : 5), min_delay); } return (unarmed_delay); @@ -3970,7 +3969,7 @@ int melee_attack::player_calc_base_unarmed_damage() damage += player_mutation_level(MUT_CLAWS) * 2; } - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { // Bats really don't do a lot of damage. damage += you.skills[SK_UNARMED_COMBAT]/5; diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 569208b831..f51fae45b2 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -968,7 +968,7 @@ bool food_change(bool suppress_message) you.duration[DUR_TRANSFORMATION] = 2; } } - else if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT + else if (player_in_bat_form() && you.duration[DUR_TRANSFORMATION] > 5) { print_stats(); diff --git a/crawl-ref/source/it_use3.cc b/crawl-ref/source/it_use3.cc index d68dee4a05..cde6d53c8f 100644 --- a/crawl-ref/source/it_use3.cc +++ b/crawl-ref/source/it_use3.cc @@ -480,6 +480,12 @@ bool evoke_item(int slot) return (false); } + if (player_in_bat_form()) + { + canned_msg(MSG_PRESENT_FORM); + return (false); + } + if (slot == -1) { slot = prompt_invent_item( "Evoke which item? (* to show all)", diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 70610c9e95..961dd0842b 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -843,7 +843,7 @@ static bool cloak_is_being_removed( void ) //--------------------------------------------------------------- void wear_armour(int slot) // slot is for tiles { - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { mpr("You can't wear anything in your present form."); return; @@ -3346,12 +3346,12 @@ void jewellery_wear_effects(item_def &item) mpr(item.name(DESC_INVENTORY_EQUIP).c_str()); } -static int prompt_ring_to_remove(int new_ring) +static int _prompt_ring_to_remove(int new_ring) { - const item_def &left = you.inv[you.equip[EQ_LEFT_RING]]; - const item_def &right = you.inv[you.equip[EQ_RIGHT_RING]]; + const item_def *left = you.slot_item(EQ_LEFT_RING); + const item_def *right = you.slot_item(EQ_RIGHT_RING); - if (item_cursed(left) && item_cursed(right)) + if (item_cursed(*left) && item_cursed(*right)) { mprf("You're already wearing two cursed rings!"); return (-1); @@ -3360,27 +3360,29 @@ static int prompt_ring_to_remove(int new_ring) mesclr(); mprf("Wearing %s.", you.inv[new_ring].name(DESC_NOCAP_A).c_str()); - char lslot = index_to_letter(left.link); - char rslot = index_to_letter(right.link); + const char lslot = index_to_letter(left->link); + const char rslot = index_to_letter(right->link); mprf(MSGCH_PROMPT, - "You're wearing two rings. Remove which one? (%c/%c/Esc)", + "You're wearing two rings. Remove which one? (%c/%c/</Esc)", lslot, rslot); - mprf(" %s", left.name(DESC_INVENTORY).c_str()); - mprf(" %s", right.name(DESC_INVENTORY).c_str()); + mprf(" < or %s", left->name(DESC_INVENTORY).c_str()); + mprf(" > or %s", right->name(DESC_INVENTORY).c_str()); int c; do c = getch(); - while (c != lslot && c != rslot && c != ESCAPE && c != ' '); + while (c != lslot && c != rslot && c != '<' && c != '>' + && c != ESCAPE && c != ' '); mesclr(); if (c == ESCAPE || c == ' ') return (-1); - const int eqslot = (c == lslot) ? EQ_LEFT_RING : EQ_RIGHT_RING; + const int eqslot = (c == lslot || c == '<') ? EQ_LEFT_RING + : EQ_RIGHT_RING; if (!check_warning_inscriptions(you.inv[you.equip[eqslot]], OPER_REMOVE)) return (-1); @@ -3471,8 +3473,32 @@ bool safe_to_remove_or_wear(const item_def &item, bool remove, // Does not do amulets. static bool _swap_rings(int ring_slot) { - // Ask the player which existing ring is persona non grata. - int unwanted = prompt_ring_to_remove(ring_slot); + const item_def* lring = you.slot_item(EQ_LEFT_RING); + const item_def* rring = you.slot_item(EQ_RIGHT_RING); + + if (item_cursed(*lring) && item_cursed(*rring)) + { + mprf("You're already wearing two cursed rings!"); + return (false); + } + + int unwanted; + + // Don't prompt if both rings are of the same type. + if (lring->sub_type == rring->sub_type + && !is_artefact(*lring) && !is_artefact(*rring)) + { + if (item_cursed(*lring)) + unwanted = you.equip[EQ_RIGHT_RING]; + else + unwanted = you.equip[EQ_LEFT_RING]; + } + else + { + // Ask the player which existing ring is persona non grata. + unwanted = _prompt_ring_to_remove(ring_slot); + } + if (unwanted == -1) { canned_msg(MSG_OK); @@ -3593,7 +3619,7 @@ bool puton_item(int item_slot) bool puton_ring(int slot) { - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { mpr("You can't put on anything in your present form."); return (false); @@ -3701,7 +3727,7 @@ void jewellery_remove_effects(item_def &item, bool mesg) bool remove_ring(int slot, bool announce) { - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { mpr("You can't wear or remove anything in your present form."); return (false); @@ -3844,6 +3870,12 @@ int _max_wand_range() void zap_wand(int slot) { + if (player_in_bat_form()) + { + canned_msg(MSG_PRESENT_FORM); + return; + } + bolt beam; dist zap_wand; int item_slot; @@ -4102,7 +4134,7 @@ void drink(int slot) return; } - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) { canned_msg(MSG_PRESENT_FORM); return; @@ -4785,6 +4817,12 @@ void read_scroll(int slot) return; } + if (player_in_bat_form()) + { + canned_msg(MSG_PRESENT_FORM); + return; + } + if (inv_count() < 1) { canned_msg(MSG_NOTHING_CARRIED); @@ -5464,6 +5502,11 @@ void tile_item_use(int idx) return; case OBJ_ARMOUR: + if (player_in_bat_form()) + { + mpr("You can't wear or remove anything in your present form."); + return; + } if (equipped && !equipped_weapon) { if (check_warning_inscriptions(item, OPER_TAKEOFF)) diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc index dbb5fc47e7..ef4c97f985 100644 --- a/crawl-ref/source/player.cc +++ b/crawl-ref/source/player.cc @@ -427,10 +427,15 @@ bool player_is_swimming() return (you.swimming()); } +bool player_in_bat_form() +{ + return (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT); +} + bool player_can_open_doors() { // Bats can't close/open doors. - return (you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT); + return !player_in_bat_form(); } bool player_under_penance(void) @@ -1096,7 +1101,7 @@ int player_hunger_rate(void) { int hunger = 3; - if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + if (player_in_bat_form()) return 1; if (you.species == SP_TROLL) @@ -1918,7 +1923,7 @@ int player_movement_speed(void) // transformations if (you.attribute[ATTR_TRANSFORMATION] == TRAN_SPIDER) mv = 8; - else if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT) + else if (player_in_bat_form()) mv = 5; // but allowed minimum is six // armour @@ -3600,7 +3605,7 @@ int check_stealth(void) // Thirsty/bat-form vampires are (much) more stealthy if (you.hunger_state == HS_STARVING) stealth += (you.skills[SK_STEALTH] * 21); - else if (you.attribute[ATTR_TRANSFORMATION] == TRAN_BAT + else if (player_in_bat_form() || you.hunger_state <= HS_NEAR_STARVING) { stealth += (you.skills[SK_STEALTH] * 20); @@ -3882,8 +3887,7 @@ void display_char_status() { std::string text; - if ((you.species != SP_VAMPIRE - || you.attribute[ATTR_TRANSFORMATION] != TRAN_BAT) + if ((you.species != SP_VAMPIRE || !player_in_bat_form()) && dur_expiring(DUR_TRANSFORMATION)) { text = "Expiring: "; diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h index ffb5542825..70a84a89e0 100644 --- a/crawl-ref/source/player.h +++ b/crawl-ref/source/player.h @@ -326,9 +326,7 @@ void modify_stat(stat_type which_stat, char amount, bool suppress_msg, void modify_stat(stat_type which_stat, char amount, bool suppress_msg, const item_def &cause, bool removed = false); -/* *********************************************************************** - * called from: acr - travel - * *********************************************************************** */ +bool player_in_bat_form(); bool player_can_open_doors(); // last updated 19may2000 {dlb} diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index 5d09f770e0..28f3b2c1c7 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -1332,6 +1332,12 @@ bool player_can_memorise(const item_def &book) bool learn_spell(int book) { + if (player_in_bat_form()) + { + canned_msg(MSG_PRESENT_FORM); + return (false); + } + int chance = 0; int levels_needed = 0; int index; diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index 36cc192fd3..2aeb7ab2c0 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -198,6 +198,7 @@ static bool _spell_no_hostile_in_range(spell_type spell, int minRange) if (minRange < 0) return (false); + bool bonus = 0; switch (spell) { case SPELL_APPORTATION: @@ -205,6 +206,13 @@ static bool _spell_no_hostile_in_range(spell_type spell, int minRange) case SPELL_CONJURE_FLAME: // These don't target monsters. return (false); + case SPELL_MEPHITIC_CLOUD: + case SPELL_FIREBALL: + case SPELL_FREEZING_CLOUD: + case SPELL_POISONOUS_CLOUD: + // Increase range by one due to cloud radius. + bonus = 1; + break; default: break; } @@ -217,7 +225,7 @@ static bool _spell_no_hostile_in_range(spell_type spell, int minRange) if (range < 0) return (false); - if (range < minRange) + if (range + bonus < minRange) return (true); return (false); -- cgit v1.2.3-54-g00ecf