From d03ad7b05a931a1bd0bc69eb809d30fca8177cb6 Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Fri, 27 Jun 2008 16:15:37 +0000 Subject: Add a new command for firing without quivering on 'F'. Use puff of fire/ice tiles for ammo of flame/ice being fired. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6169 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 6 +- crawl-ref/source/command.cc | 1 + crawl-ref/source/enum.h | 2 +- crawl-ref/source/item_use.cc | 133 ++++++++++++++++++++----------- crawl-ref/source/item_use.h | 5 +- crawl-ref/source/newgame.cc | 184 +++++++++++++++++++++++-------------------- crawl-ref/source/quiver.cc | 26 +++--- crawl-ref/source/tile1.cc | 32 +++++--- crawl-ref/source/tiles.h | 2 +- 9 files changed, 234 insertions(+), 157 deletions(-) (limited to 'crawl-ref/source') diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index 33903be17a..e90e785694 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -2086,6 +2086,10 @@ void process_command( command_type cmd ) choose_item_for_quiver(); break; + case CMD_THROW_ITEM_NO_QUIVER: + throw_item_no_quiver(); + break; + case CMD_WEAR_ARMOUR: wear_armour(); break; @@ -3460,7 +3464,7 @@ static command_type _keycode_to_command( keycode_type key ) case 'C': return CMD_CLOSE_DOOR; case 'D': return CMD_NO_CMD; case 'E': return CMD_EXPERIENCE_CHECK; - case 'F': return CMD_NO_CMD; + case 'F': return CMD_THROW_ITEM_NO_QUIVER; case 'G': return CMD_INTERLEVEL_TRAVEL; case 'I': return CMD_DISPLAY_SPELLS; case 'M': return CMD_MEMORISE_SPELL; diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc index 2e42c2b076..3b4d84c5c0 100644 --- a/crawl-ref/source/command.cc +++ b/crawl-ref/source/command.cc @@ -1828,6 +1828,7 @@ static void _add_formatted_keyhelp(column_composer &cols) "] : show inventory of equipped items\n" "{ : inscribe item\n" "f : Fire or throw an item\n" + "F : Fire or throw an item without quivering it\n" "( : cycle current ammunition\n" "e : Eat food (but tries floor first)\n" "q : Quaff a potion\n" diff --git a/crawl-ref/source/enum.h b/crawl-ref/source/enum.h index 9b1f3023b0..ba418d6027 100644 --- a/crawl-ref/source/enum.h +++ b/crawl-ref/source/enum.h @@ -447,9 +447,9 @@ enum command_type CMD_EVOKE, CMD_WIELD_WEAPON, CMD_WEAPON_SWAP, - CMD_THROW, // unused now CMD_FIRE, CMD_QUIVER_ITEM, + CMD_THROW_ITEM_NO_QUIVER, CMD_WEAR_ARMOUR, CMD_REMOVE_ARMOUR, CMD_WEAR_JEWELLERY, diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index 573a30ab62..08825a71fa 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -1472,21 +1472,7 @@ static bool _fire_choose_item_and_target(int& slot, dist& target, return (false); } - // Currently no difference between f() and fi. you.m_quiver->on_item_fired(you.inv[beh.m_slot], beh.chosen_ammo); -/* - // If ammo was chosen via 'fi', it's not supposed to get quivered. - // Otherwise, if the user chose different ammo, quiver it. - // Same for items selected in tile mode. - if (was_chosen || !beh.selected_from_inventory) - { - you.m_quiver->on_item_fired(you.inv[beh.m_slot], beh.chosen_ammo); - } - else - { - you.m_quiver->on_item_fired_fi(you.inv[beh.m_slot]); - } -*/ you.redraw_quiver = true; slot = beh.m_slot; @@ -1589,7 +1575,6 @@ int get_ammo_to_shoot(int item, dist &target, bool teleport) return (item); } - // If item == -1, prompt the user. // If item passed, it will be put into the quiver. void fire_thing(int item) @@ -1599,9 +1584,6 @@ void fire_thing(int item) if (item == -1) return; - if (Options.tutorial_left) - Options.tut_throw_counter++; - if (check_warning_inscriptions(you.inv[item], OPER_FIRE)) { bolt beam; @@ -1609,6 +1591,42 @@ void fire_thing(int item) } } +// Basically does what throwing used to do: throw an item without changing +// the quiver. +void throw_item_no_quiver() +{ + if (_fire_warn_if_impossible()) + { + flush_input_buffer( FLUSH_ON_FAILURE ); + return; + } + + if (inv_count() < 1) + { + canned_msg(MSG_NOTHING_CARRIED); + return; + } + + std::string warn; + int slot = _fire_prompt_for_item(warn); + + if (slot == -1) + { + canned_msg(MSG_OK); + return; + } + + if (!_fire_validate_item(slot, warn)) + { + mpr(warn.c_str()); + return; + } + + // Okay, item is valid. + bolt beam; + throw_it( beam, slot ); +} + // Returns delay multiplier numerator (denominator should be 100) for the // launcher with the currently equipped shield. int launcher_shield_slowdown(const item_def &launcher, const item_def *shield) @@ -2216,42 +2234,66 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, } // Note that bow_brand is known since the bow is equipped. - if ((bow_brand == SPWPN_FLAME || ammo_brand == SPMSL_FLAME) - && ammo_brand != SPMSL_ICE && bow_brand != SPWPN_FROST) + if (bow_brand == SPWPN_FLAME || ammo_brand == SPMSL_FLAME) { - // [dshaligram] Branded arrows are much stronger. - dice_mult = (dice_mult * 150) / 100; + if (ammo_brand != SPMSL_ICE && bow_brand != SPWPN_FROST) + { +#ifdef USE_TILE + // Mark brand for tile output. + if (ammo_brand != SPMSL_FLAME) + set_item_ego_type( item, OBJ_MISSILES, SPMSL_FLAME ); +#endif + + // [dshaligram] Branded arrows are much stronger. + dice_mult = (dice_mult * 150) / 100; - pbolt.flavour = BEAM_FIRE; - pbolt.name = "bolt of "; + pbolt.flavour = BEAM_FIRE; + pbolt.name = "bolt of "; - if (poisoned) - pbolt.name += "poison "; + if (poisoned) + pbolt.name += "poison "; - pbolt.name += "flame"; - pbolt.colour = RED; - pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); - pbolt.thrower = KILL_YOU_MISSILE; - pbolt.aux_source.clear(); + pbolt.name += "flame"; + pbolt.colour = RED; + pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); + pbolt.thrower = KILL_YOU_MISSILE; + pbolt.aux_source.clear(); + } +#ifdef USE_TILE + else + set_item_ego_type( item, OBJ_MISSILES, SPMSL_NORMAL ); +#endif } - if ((bow_brand == SPWPN_FROST || ammo_brand == SPMSL_ICE) - && ammo_brand != SPMSL_FLAME && bow_brand != SPWPN_FLAME) + if (bow_brand == SPWPN_FROST || ammo_brand == SPMSL_ICE) { - // [dshaligram] Branded arrows are much stronger. - dice_mult = (dice_mult * 150) / 100; + if (ammo_brand != SPMSL_FLAME && bow_brand != SPWPN_FLAME) + { +#ifdef USE_TILE + // Mark brand for tile output. + if (ammo_brand != SPMSL_ICE) + set_item_ego_type( item, OBJ_MISSILES, SPMSL_ICE ); +#endif - pbolt.flavour = BEAM_COLD; - pbolt.name = "bolt of "; + // [dshaligram] Branded arrows are much stronger. + dice_mult = (dice_mult * 150) / 100; - if (poisoned) - pbolt.name += "poison "; + pbolt.flavour = BEAM_COLD; + pbolt.name = "bolt of "; - pbolt.name += "frost"; - pbolt.colour = WHITE; - pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); - pbolt.thrower = KILL_YOU_MISSILE; - pbolt.aux_source.clear(); + if (poisoned) + pbolt.name += "poison "; + + pbolt.name += "frost"; + pbolt.colour = WHITE; + pbolt.type = dchar_glyph(DCHAR_FIRED_BOLT); + pbolt.thrower = KILL_YOU_MISSILE; + pbolt.aux_source.clear(); + } +#ifdef USE_TILE + else + set_item_ego_type( item, OBJ_MISSILES, SPMSL_NORMAL ); +#endif } // The chief advantage here is the extra damage this does @@ -2549,6 +2591,9 @@ bool throw_it(bolt &pbolt, int throw_2, bool teleport, int acc_bonus, } else { + if (Options.tutorial_left) + Options.tut_throw_counter++; + // Dropping item copy, since the launched item might be different. fire_beam(pbolt, &item, !did_return); diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h index ed6aece344..4477979152 100644 --- a/crawl-ref/source/item_use.h +++ b/crawl-ref/source/item_use.h @@ -107,6 +107,7 @@ bool remove_ring(int slot = -1, bool announce = false); int get_next_fire_item(int current, int offset); int get_ammo_to_shoot(int item, dist &target, bool teleport = false); void fire_thing(int item = -1); +void throw_item_no_quiver(void); // last updated 12may2000 {dlb} /* *********************************************************************** @@ -162,8 +163,8 @@ bool puton_item(int slot, bool prompt_finger = true); bool enchant_weapon( enchant_stat_type which_stat, bool quiet, item_def &wpn ); bool enchant_armour( int &ac_change, bool quiet, item_def &arm ); -bool throw_it(bolt &pbolt, int throw_2, bool teleport=false, int acc_bonus=0, - dist *target = NULL); +bool throw_it(bolt &pbolt, int throw_2, bool teleport = false, + int acc_bonus = 0, dist *target = NULL); bool thrown_object_destroyed( item_def *item, int x, int y, bool returning ); diff --git a/crawl-ref/source/newgame.cc b/crawl-ref/source/newgame.cc index e941a984c3..f5b6b9e661 100644 --- a/crawl-ref/source/newgame.cc +++ b/crawl-ref/source/newgame.cc @@ -1902,100 +1902,114 @@ static bool _is_good_combination( species_type spc, job_type cls, bool good) return (restrict != CC_BANNED); } -static bool _choose_book( item_def& book, int firstbook, int numbooks ) +// book 0 = fire (CONJ_I, MINOR_MAGIC_I), 1 = ice (CONJ_II, MINOR_MAGIC_II), +// 2 = summoning (MINOR_MAGIC_III) +static char_choice_restriction _book_restriction(int booktype, + bool summon_too = false) { - int keyin = 0; - clrscr(); - book.base_type = OBJ_BOOKS; - book.quantity = 1; - book.plus = 0; - book.special = 1; - - char_choice_restriction book_restrictions[3]; - - // Fire - switch (you.species) + switch (booktype) { - case SP_OGRE: - // Ogres are, of course, really bad at Fire and Ice, so it's usually - // restricted, but if the summoning book comes into play unrestrict - // those two because ogres are even *worse* at Summonings. - if (numbooks < 3) - book_restrictions[0] = CC_RESTRICTED; - // else fall-through - case SP_HUMAN: - case SP_HIGH_ELF: - case SP_GREY_ELF: - case SP_DEEP_ELF: - case SP_SLUDGE_ELF: - case SP_MOUNTAIN_DWARF: - case SP_HILL_ORC: - case SP_HALFLING: - case SP_GNOME: - case SP_KOBOLD: - case SP_NAGA: - case SP_OGRE_MAGE: - case SP_KENKU: - case SP_DEMONSPAWN: - book_restrictions[0] = CC_UNRESTRICTED; + case 0: // Fire + switch (you.species) + { + case SP_OGRE: + // Ogres are, of course, really bad at Fire and Ice, so it's usually + // restricted, but if the summoning book comes into play unrestrict + // those two because ogres are even *worse* at Summonings. + if (!summon_too) + return (CC_RESTRICTED); + // else fall-through + case SP_HUMAN: + case SP_HIGH_ELF: + case SP_GREY_ELF: + case SP_DEEP_ELF: + case SP_SLUDGE_ELF: + case SP_MOUNTAIN_DWARF: + case SP_HILL_ORC: + case SP_HALFLING: + case SP_GNOME: + case SP_KOBOLD: + case SP_NAGA: + case SP_OGRE_MAGE: + case SP_KENKU: + case SP_DEMONSPAWN: + return (CC_UNRESTRICTED); + + default: + return (CC_RESTRICTED); + } break; - default: - book_restrictions[0] = CC_RESTRICTED; - } + case 1: // Ice + switch (you.species) + { + case SP_OGRE_MAGE: + if (!summon_too) + return (CC_RESTRICTED); + // else fall-through + case SP_HUMAN: + case SP_HIGH_ELF: + case SP_GREY_ELF: + case SP_DEEP_ELF: + case SP_SLUDGE_ELF: + case SP_HILL_ORC: + case SP_MERFOLK: + case SP_HALFLING: + case SP_GNOME: + case SP_KOBOLD: + case SP_NAGA: + case SP_OGRE: + case SP_GHOUL: + case SP_VAMPIRE: + return (CC_UNRESTRICTED); - // Ice - switch (you.species) - { - case SP_OGRE_MAGE: - if (numbooks < 3) - book_restrictions[0] = CC_RESTRICTED; - // else fall-through - case SP_HUMAN: - case SP_HIGH_ELF: - case SP_GREY_ELF: - case SP_DEEP_ELF: - case SP_SLUDGE_ELF: - case SP_HILL_ORC: - case SP_MERFOLK: - case SP_HALFLING: - case SP_GNOME: - case SP_KOBOLD: - case SP_NAGA: - case SP_OGRE: - case SP_GHOUL: - case SP_VAMPIRE: - book_restrictions[1] = CC_UNRESTRICTED; + default: + return (CC_RESTRICTED); + } break; - default: - book_restrictions[1] = CC_RESTRICTED; + case 2: // Summoning + switch (you.species) + { + case SP_HUMAN: + case SP_GREY_ELF: + case SP_DEEP_ELF: + case SP_SLUDGE_ELF: + case SP_MERFOLK: + case SP_GNOME: + case SP_KOBOLD: + case SP_NAGA: + case SP_OGRE_MAGE: + case SP_KENKU: + case SP_DEMONSPAWN: + case SP_VAMPIRE: + return (CC_UNRESTRICTED); + break; + + default: + if (player_genus(GENPC_DRACONIAN)) + return (CC_UNRESTRICTED); + else + return (CC_RESTRICTED); + } } + return (CC_RESTRICTED); +} - // Summoning - switch (you.species) - { - case SP_HUMAN: - case SP_GREY_ELF: - case SP_DEEP_ELF: - case SP_SLUDGE_ELF: - case SP_MERFOLK: - case SP_GNOME: - case SP_KOBOLD: - case SP_NAGA: - case SP_OGRE_MAGE: - case SP_KENKU: - case SP_DEMONSPAWN: - case SP_VAMPIRE: - book_restrictions[2] = CC_UNRESTRICTED; - break; - default: - if (player_genus(GENPC_DRACONIAN)) - book_restrictions[2] = CC_UNRESTRICTED; - else - book_restrictions[2] = CC_RESTRICTED; - } +static bool _choose_book( item_def& book, int firstbook, int numbooks ) +{ + int keyin = 0; + clrscr(); + book.base_type = OBJ_BOOKS; + book.quantity = 1; + book.plus = 0; + book.special = 1; + + const bool summons_too = (numbooks == 3); + char_choice_restriction book_restrictions[3]; + for (int i = 0; i < numbooks; i++) + book_restrictions[i] = _book_restriction(i, summons_too); // Using the fact that CONJ_I and MINOR_MAGIC_I are both // fire books, CONJ_II and MINOR_MAGIC_II are both ice books. @@ -2083,7 +2097,7 @@ static bool _choose_book( item_def& book, int firstbook, int numbooks ) else ng_book = keyin - 'a' + 1; - if ( Options.random_pick || keyin == '*' ) + if (Options.random_pick || keyin == '*') keyin = random2(numbooks) + 'a'; book.sub_type = firstbook + keyin - 'a'; diff --git a/crawl-ref/source/quiver.cc b/crawl-ref/source/quiver.cc index 521923133e..5f764b5eb5 100644 --- a/crawl-ref/source/quiver.cc +++ b/crawl-ref/source/quiver.cc @@ -159,13 +159,13 @@ void choose_item_for_quiver() ammo_t t = _get_weapon_ammo_type(you.weapon()); you.m_quiver->empty_quiver(t); - mprf("Emptying quiver for %s.", + mprf("Reset %s quiver to default.", t == AMMO_THROW ? "throwing" : - t == AMMO_BLOWGUN ? "blowguns" : - t == AMMO_SLING ? "slings" : - t == AMMO_BOW ? "bows" : - t == AMMO_CROSSBOW ? "crossbows" - : "hand crossbows"); + t == AMMO_BLOWGUN ? "blowgun" : + t == AMMO_SLING ? "sling" : + t == AMMO_BOW ? "bow" : + t == AMMO_CROSSBOW ? "crossbow" + : "hand crossbow"); return; } else if (slot == you.equip[EQ_WEAPON]) @@ -194,13 +194,13 @@ void choose_item_for_quiver() t = _get_weapon_ammo_type(weapon); you.m_quiver->set_quiver(you.inv[slot], t); - mprf("Quivering %s %s.", you.inv[slot].name(DESC_INVENTORY).c_str(), - t == AMMO_THROW ? "as throwing weapon" : - t == AMMO_BLOWGUN ? "for blowguns" : - t == AMMO_SLING ? "for slings" : - t == AMMO_BOW ? "for bows" : - t == AMMO_CROSSBOW ? "for crossbows" - : "for hand crossbows"); + mprf("Quivering %s for %s.", you.inv[slot].name(DESC_INVENTORY).c_str(), + t == AMMO_THROW ? "throwing" : + t == AMMO_BLOWGUN ? "blowguns" : + t == AMMO_SLING ? "slings" : + t == AMMO_BOW ? "bows" : + t == AMMO_CROSSBOW ? "crossbows" + : "hand crossbows"); } // Notification that item was fired with 'f'. diff --git a/crawl-ref/source/tile1.cc b/crawl-ref/source/tile1.cc index ed2c3bf65a..d088b05d2e 100644 --- a/crawl-ref/source/tile1.cc +++ b/crawl-ref/source/tile1.cc @@ -1925,8 +1925,18 @@ int tileidx_item_throw(const item_def &item, int dx, int dy) int ch = -1; int dir = _tile_bolt_dir(dx, dy); + switch (get_ammo_brand(item)) + { + case SPMSL_FLAME: + return (tileidx_zap(RED)); + case SPMSL_ICE: + return (tileidx_zap(WHITE)); + default: + break; + } + // Thrown items with multiple directions - switch(item.sub_type) + switch (item.sub_type) { case MI_ARROW: ch = TILE_MI_ARROW0; @@ -1952,7 +1962,7 @@ int tileidx_item_throw(const item_def &item, int dx, int dy) return ch + dir; // Thrown items with a single direction - switch(item.sub_type) + switch (item.sub_type) { case MI_STONE: ch = TILE_MI_STONE0; @@ -2333,12 +2343,14 @@ int tileidx_bolt(const bolt &bolt) return tileidx_zap(col); } -int tileidx_zap(int color) +int tileidx_zap(int colour) { - int col = color; - if (col > 8) col -= 8; - if (col < 1) col = 7; - return TILE_SYM_BOLT_OFS -1 + col; + int col = colour; + if (col > 8) + col -= 8; + if (col < 1) + col = 7; + return (TILE_SYM_BOLT_OFS - 1 + col); } // Convert normal tile to 3D tile if it exists @@ -4472,9 +4484,9 @@ static void _finish_inven_data(int n, int *tiles, int *num, int *idx, if (q == 1) q = -1; - if ( type == OBJ_WANDS - && ((itm->flags & ISFLAG_KNOW_PLUSES ) - || itm->plus2 == ZAPCOUNT_EMPTY) ) + if (type == OBJ_WANDS + && ((itm->flags & ISFLAG_KNOW_PLUSES) + || itm->plus2 == ZAPCOUNT_EMPTY)) { q = itm->plus; } diff --git a/crawl-ref/source/tiles.h b/crawl-ref/source/tiles.h index 1ef45cff62..f563cec8d4 100644 --- a/crawl-ref/source/tiles.h +++ b/crawl-ref/source/tiles.h @@ -20,7 +20,7 @@ int tileidx_unseen(int ch, const coord_def& gc); int tileidx_item(const item_def &item); int tileidx_item_throw(const item_def &item, int dx, int dy); int tileidx_bolt(const bolt &bolt); -int tileidx_zap(int color); +int tileidx_zap(int colour); int tile_idx_unseen_terrain(int x, int y, int what); int tile_unseen_flag(const coord_def& gc); -- cgit v1.2.3-54-g00ecf