summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-24 08:24:46 +0000
committerj-p-e-g <j-p-e-g@c06c8d41-db1a-0410-9941-cceddc491573>2008-06-24 08:24:46 +0000
commit83040a103063abbfa9e92105c47bda428ba8e742 (patch)
treed0e10c36a84b12ea50418a559ea64392653b32b1
parentce05e64645f5e9ba07c5b8b72d0da8d5f8cecb28 (diff)
downloadcrawl-ref-83040a103063abbfa9e92105c47bda428ba8e742.tar.gz
crawl-ref-83040a103063abbfa9e92105c47bda428ba8e742.zip
Force update of the quiver by picking up throwable items. This might
hamper performance and is still not optimal: Wielding a sling, running out of stones, firing darts instead and then picking up some new stones won't make the quiver switch away from the darts because you "explicitly" fired them. Also, can someone please tell me whether "(" or ")" are supposed to loop to the correct next item? I haven't been able to work that out from the quiver behaviour alone - it's not all that consistent, unfortunately. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@6108 c06c8d41-db1a-0410-9941-cceddc491573
-rw-r--r--crawl-ref/source/command.cc26
-rw-r--r--crawl-ref/source/quiver.cc29
2 files changed, 33 insertions, 22 deletions
diff --git a/crawl-ref/source/command.cc b/crawl-ref/source/command.cc
index 98847ab7ea..6afe25ab5d 100644
--- a/crawl-ref/source/command.cc
+++ b/crawl-ref/source/command.cc
@@ -672,20 +672,24 @@ void list_weapons(void)
// Now we print out the current default fire weapon.
wstring = "Firing : ";
- const item_def* item;
- int slot;
- you.m_quiver->get_desired_item(&item, &slot);
+ std::string error_reason;
+ int slot = you.m_quiver->get_fire_item(&error_reason);
colour = MSGCOL_BLACK;
- if (slot == -1 && !is_valid_item(*item))
+ if (slot == -1)
{
- wstring += " nothing";
- }
- else if (slot == -1)
- {
- wstring += " - ";
- wstring += item->name(DESC_NOCAP_A);
- wstring += " (empty)";
+ const item_def* item;
+ you.m_quiver->get_desired_item(&item, &slot);
+ if (!is_valid_item(*item))
+ {
+ wstring += " nothing";
+ }
+ else
+ {
+ wstring += " - ";
+ wstring += item->name(DESC_NOCAP_A);
+ wstring += " (empty)";
+ }
}
else
{
diff --git a/crawl-ref/source/quiver.cc b/crawl-ref/source/quiver.cc
index 680fa465e2..6ecf4c8661 100644
--- a/crawl-ref/source/quiver.cc
+++ b/crawl-ref/source/quiver.cc
@@ -139,6 +139,13 @@ void player_quiver::on_item_fired(const item_def& item)
}
else
{
+ const launch_retval projected = is_launched(&you, you.weapon(),
+ item);
+
+ // Don't do anything if this item is not really fit for throwing.
+ if (projected == LRET_FUMBLED)
+ return;
+
m_last_used_of_type[AMMO_THROW] = item;
m_last_used_of_type[AMMO_THROW].quantity = 1;
m_last_used_type = AMMO_THROW;
@@ -182,24 +189,22 @@ void player_quiver::on_weapon_changed()
void player_quiver::on_inv_quantity_changed(int slot, int amt)
{
+ const launch_retval projected = is_launched(&you, you.weapon(),
+ you.inv[slot]);
+
+ // Don't do anything if this item is not throwable.
+ if (projected == LRET_FUMBLED)
+ return;
+
if (m_last_used_of_type[m_last_used_type].base_type == OBJ_UNASSIGNED)
{
// Empty quiver. Maybe we can fill it now?
_maybe_fill_empty_slot();
you.redraw_quiver = true;
}
- else if (m_last_used_of_type[m_last_used_type].base_type
- != you.inv[slot].base_type)
- {
- // Not our current stack; don't bother
- }
else
{
- // Maybe matches current stack. Redraw if so.
-// const item_def* desired;
-// int qv_slot;
-// get_desired_item(&desired, &qv_slot);
-
+ // We might need to update the quiver...
std::string error_reason;
int qv_slot = get_fire_item(&error_reason);
if (qv_slot == slot)
@@ -236,7 +241,9 @@ void player_quiver::_maybe_fill_empty_slot()
#endif
const launch_retval desired_ret =
- (slot == AMMO_THROW ? LRET_THROWN : LRET_LAUNCHED);
+ (weapon && is_range_weapon(*weapon)) ? LRET_LAUNCHED : LRET_THROWN;
+// const launch_retval desired_ret =
+// (slot == AMMO_THROW ? LRET_THROWN : LRET_LAUNCHED);
std::vector<int> order;
_get_fire_order(order, false, weapon);