From d0f739d802e77186463731df1d6736db7daf983e Mon Sep 17 00:00:00 2001 From: j-p-e-g Date: Sat, 12 Jan 2008 21:10:29 +0000 Subject: Tile changes. *waves to Enne* Fix assertion error when unwielding items. FR 1838216: Make R-click on map *really* show grid information. FR 1838219: Add more diverse action verbs for items in inventory ("eat", "unwield" etc. rather than plain "use") and allow memorizing by L-clicking on books. Bug 1858432: Show 0 charge icon for empty but unID'd wands. Also: Don't regard enslavement on friendlies as attack attempt. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3264 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/acr.cc | 2 +- crawl-ref/source/beam.cc | 2 +- crawl-ref/source/item_use.cc | 58 +++++++++++++++++++++++--------------------- crawl-ref/source/item_use.h | 2 +- crawl-ref/source/libgui.cc | 47 ++++++++++++++++++++++------------- crawl-ref/source/spl-book.cc | 29 ++++++++++++---------- crawl-ref/source/spl-book.h | 2 +- crawl-ref/source/tile1.cc | 5 +++- 8 files changed, 84 insertions(+), 63 deletions(-) diff --git a/crawl-ref/source/acr.cc b/crawl-ref/source/acr.cc index d2c359dea4..35dbb3b133 100644 --- a/crawl-ref/source/acr.cc +++ b/crawl-ref/source/acr.cc @@ -1657,7 +1657,7 @@ void process_command( command_type cmd ) int idx; InvAction act; gui_get_mouse_inv(idx, act); - use_item(idx, act); + tile_use_item(idx, act); } break; diff --git a/crawl-ref/source/beam.cc b/crawl-ref/source/beam.cc index 2d171ab06b..f5a6d4971e 100644 --- a/crawl-ref/source/beam.cc +++ b/crawl-ref/source/beam.cc @@ -3755,7 +3755,7 @@ static int affect_monster(bolt &beam, monsters *mon) remove_sanctuary(true); } - if (mons_friendly( mon )) + if (mons_friendly( mon ) && beam.flavour != BEAM_CHARM) did_god_conduct( DID_ATTACK_FRIEND, 5, true, mon ); if (mons_holiness( mon ) == MH_HOLY) diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc index ff65a9e8ed..4e28412557 100644 --- a/crawl-ref/source/item_use.cc +++ b/crawl-ref/source/item_use.cc @@ -209,8 +209,8 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages) // If the swap slot has a bad (but valid) item in it, // the swap will be to bare hands. - const bool good_swap = - you.inv[item_slot].base_type == OBJ_WEAPONS + const bool good_swap = item_slot == PROMPT_GOT_SPECIAL + || you.inv[item_slot].base_type == OBJ_WEAPONS || you.inv[item_slot].base_type == OBJ_STAVES || (you.inv[item_slot].base_type == OBJ_MISCELLANY && you.inv[item_slot].sub_type != MISC_RUNE_OF_ZOT); @@ -230,31 +230,30 @@ bool wield_weapon(bool auto_wield, int slot, bool show_weff_messages) true, true, true, '-', NULL, OPER_WIELD); else item_slot = PROMPT_GOT_SPECIAL; + } - if (item_slot == PROMPT_ABORT) - { - canned_msg( MSG_OK ); - return (false); - } - else if (item_slot == PROMPT_GOT_SPECIAL) // '-' or bare hands + if (item_slot == PROMPT_ABORT) + { + canned_msg( MSG_OK ); + return (false); + } + else if (item_slot == PROMPT_GOT_SPECIAL) // '-' or bare hands + { + if (you.equip[EQ_WEAPON] != -1) { - if (you.equip[EQ_WEAPON] != -1) - { - if (!unwield_item(show_weff_messages)) - return (false); + if (!unwield_item(show_weff_messages)) + return (false); - canned_msg( MSG_EMPTY_HANDED ); + canned_msg( MSG_EMPTY_HANDED ); - you.turn_is_over = true; - you.time_taken *= 3; - you.time_taken /= 10; - } - else - { - mpr( "You are already empty-handed." ); - } - return (true); + you.turn_is_over = true; + you.time_taken *= 3; + you.time_taken /= 10; } + else + mpr( "You are already empty-handed." ); + + return (true); } if (item_slot == you.equip[EQ_WEAPON]) @@ -4396,7 +4395,7 @@ bool wearing_slot(int inv_slot) #ifdef USE_TILE // Interactive menu for item drop/use -void use_item(int idx, InvAction act) +void tile_use_item(int idx, InvAction act) { if (act == INV_PICKUP) { @@ -4405,9 +4404,7 @@ void use_item(int idx, InvAction act) } else if (act == INV_DROP) { -#ifdef USE_TILE TileMoveInvCursor(-1); -#endif drop_item(idx, you.inv[idx].quantity); return; } @@ -4427,9 +4424,7 @@ void use_item(int idx, InvAction act) } } -#ifdef USE_TILE TileMoveInvCursor(-1); -#endif // Special case for folks who are wielding something // that they shouldn't be wielding. @@ -4497,14 +4492,21 @@ void use_item(int idx, InvAction act) zap_wand(idx); return; + case OBJ_CORPSES: + if (you.species != SP_VAMPIRE) + break; + // intentional fall-through for Vampires case OBJ_FOOD: if (!check_warning_inscriptions(you.inv[idx], OPER_EAT)) return; eat_food(false, idx); return; - case OBJ_SCROLLS: case OBJ_BOOKS: + learn_spell(idx); + return; + + case OBJ_SCROLLS: if (!check_warning_inscriptions(you.inv[idx], OPER_READ)) return; read_scroll(idx); diff --git a/crawl-ref/source/item_use.h b/crawl-ref/source/item_use.h index e4d09c72a3..27c8e845e9 100644 --- a/crawl-ref/source/item_use.h +++ b/crawl-ref/source/item_use.h @@ -188,7 +188,7 @@ bool wearing_slot(int inv_slot); /* *********************************************************************** * * called from: acr * * *********************************************************************** */ -void use_item(int idx, InvAction act); +void tile_use_item(int idx, InvAction act); #endif #endif diff --git a/crawl-ref/source/libgui.cc b/crawl-ref/source/libgui.cc index c2af3ef8c3..3c98350c39 100644 --- a/crawl-ref/source/libgui.cc +++ b/crawl-ref/source/libgui.cc @@ -1226,21 +1226,23 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init) if (display_actions) { - desc += EOL "[L-Click] "; int type = you.inv[ix].base_type; + if (type != OBJ_CORPSES || you.species == SP_VAMPIRE) + desc += EOL "[L-Click] "; if (itemlist_iflag[cx] & TILEI_FLAG_EQUIP) type += 18; switch (type) { - case OBJ_JEWELLERY + 18: - desc += "*(R)emove"; - break; case OBJ_WEAPONS: case OBJ_STAVES: desc += "*(w)ield"; break; + case OBJ_WEAPONS + 18: + case OBJ_STAVES + 18: + desc += "unwield"; + break; case OBJ_MISSILES: desc += "*(t)hrow"; break; @@ -1248,15 +1250,35 @@ static int handle_mouse_motion(int mouse_x, int mouse_y, bool init) desc += "*(z)ap"; break; case OBJ_SCROLLS: - case OBJ_BOOKS: desc += "*(r)ead"; break; + case OBJ_BOOKS: + desc += "*(M)emorize"; + break; case OBJ_JEWELLERY: desc += "*(P)ut on"; break; + case OBJ_JEWELLERY + 18: + desc += "*(R)emove"; + break; case OBJ_POTIONS: desc += "*(q)uaff"; break; + case OBJ_ARMOUR: + desc += "*(W)ear"; + break; + case OBJ_ARMOUR + 18: + desc += "*(T)ake off"; + break; + case OBJ_FOOD: + desc += "*(e)at"; + break; + case OBJ_CORPSES: + if (you.species == SP_VAMPIRE) + desc += "drink blood"; + else // no action possible + desc += EOL; + break; default: desc += "*Use it"; } @@ -1473,19 +1495,10 @@ static int handle_mouse_button(int mx, int my, int button, // otherwise return trigger key if (!in_los_bounds(cx+1,cy+1)) return CK_MOUSE_B2; - const coord_def ep = view2show(coord_def(cx, cy)); - if (env.show(ep) == 0) - return trig; - - int mid = mgrd[cx][cy]; - if (mid == NON_MONSTER || !player_monster_visible( &menv[mid] )) - { - return trig; - } - describe_monsters( menv[ mid ] ); - redraw_screen(); - mesclr( true ); + const int gx = view2gridX(cx) + 1; + const int gy = view2gridY(cy) + 1; + full_describe_square(coord_def(gx,gy)); return CK_MOUSE_DONE; } diff --git a/crawl-ref/source/spl-book.cc b/crawl-ref/source/spl-book.cc index ecdf5945ea..f5953b0fd6 100644 --- a/crawl-ref/source/spl-book.cc +++ b/crawl-ref/source/spl-book.cc @@ -954,20 +954,21 @@ bool is_valid_spell_in_book( int splbook, int spell ) return which_spell_in_book(splbook, spell) != SPELL_NO_SPELL; } -static bool which_spellbook( int &book, int &spell ) +static int which_spellbook( void ) { + int book = -1; const int avail_levels = player_spell_levels(); // Knowing delayed fireball will allow Fireball to be learned for free -bwr if (avail_levels < 1 && !player_has_spell(SPELL_DELAYED_FIREBALL)) { mpr("You can't memorise any more spells yet."); - return (false); + return (-1); } else if (inv_count() < 1) { canned_msg(MSG_NOTHING_CARRIED); - return (false); + return (-1); } mprf("You can memorise %d more level%s of spells.", @@ -978,26 +979,23 @@ static bool which_spellbook( int &book, int &spell ) if (book == PROMPT_ABORT) { canned_msg( MSG_OK ); - return (false); + return (-1); } if (you.inv[book].base_type != OBJ_BOOKS || you.inv[book].sub_type == BOOK_MANUAL) { mpr("That isn't a spellbook!"); - return (false); + return (-1); } if (you.inv[book].sub_type == BOOK_DESTRUCTION) { tome_of_power( book ); - return (false); + return (-1); } - spell = read_book( you.inv[book], RBOOK_MEMORISE ); - clrscr(); - - return (true); + return (book); } // end which_spellbook() // Returns false if the player cannot read/memorize from the book, @@ -1178,11 +1176,10 @@ bool player_can_memorise(const item_def &book) return false; } -bool learn_spell(void) +bool learn_spell(int book) { int chance = 0; int levels_needed = 0; - int book, spell; int index; int i; @@ -1212,9 +1209,15 @@ bool learn_spell(void) return (false); } - if (!which_spellbook( book, spell )) + if (book < 0) + book = which_spellbook(); + + if (book < 0) // still -1? return (false); + int spell = read_book( you.inv[book], RBOOK_MEMORISE ); + clrscr(); + mesclr(true); redraw_screen(); diff --git a/crawl-ref/source/spl-book.h b/crawl-ref/source/spl-book.h index 7e6fe1cdf8..d67023eaeb 100644 --- a/crawl-ref/source/spl-book.h +++ b/crawl-ref/source/spl-book.h @@ -49,7 +49,7 @@ int read_book( item_def &item, read_book_action_type action ); * called from: acr * *********************************************************************** */ bool player_can_memorise(const item_def &book); -bool learn_spell(void); +bool learn_spell(int book = -1); spell_type which_spell_in_book(int sbook_type, int spl); diff --git a/crawl-ref/source/tile1.cc b/crawl-ref/source/tile1.cc index e6cbed30a2..4a9e999c12 100644 --- a/crawl-ref/source/tile1.cc +++ b/crawl-ref/source/tile1.cc @@ -3976,8 +3976,11 @@ void finish_inven_data(int n, int *tiles, int *num, int *idx, int *iflag) if (q==1) q = -1; if (type == OBJ_WANDS && - (itm->flags & ISFLAG_KNOW_PLUSES )!= 0) + ((itm->flags & ISFLAG_KNOW_PLUSES )!= 0 + || itm->plus2 == ZAPCOUNT_EMPTY)) + { q = itm->plus; + } tiles[i] = tileidx_item(*itm); num[i] = q; -- cgit v1.2.3-54-g00ecf