summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crawl-ref/source/item_use.cc3
-rw-r--r--crawl-ref/source/mon-util.cc22
-rw-r--r--crawl-ref/source/monstuff.cc4
-rw-r--r--crawl-ref/source/quiver.cc84
4 files changed, 77 insertions, 36 deletions
diff --git a/crawl-ref/source/item_use.cc b/crawl-ref/source/item_use.cc
index 0f9640d5fe..220aaefc69 100644
--- a/crawl-ref/source/item_use.cc
+++ b/crawl-ref/source/item_use.cc
@@ -1284,7 +1284,8 @@ int get_next_fire_item(int current, int direction)
{
if (fire_order[i] == current)
{
- unsigned next = (i + fire_order.size() + direction) % fire_order.size();
+ unsigned next =
+ (i + fire_order.size() + direction) % fire_order.size();
return fire_order[next];
}
}
diff --git a/crawl-ref/source/mon-util.cc b/crawl-ref/source/mon-util.cc
index 3c8140893a..91e073f839 100644
--- a/crawl-ref/source/mon-util.cc
+++ b/crawl-ref/source/mon-util.cc
@@ -1546,7 +1546,7 @@ void define_monster(monsters &mons)
case MONS_DEEP_ELF_KNIGHT:
case MONS_DEEP_ELF_SOLDIER:
case MONS_ORC_WIZARD:
- spells = static_cast<mon_spellbook_type>(MST_ORC_WIZARD_I+random2(3));
+ spells = static_cast<mon_spellbook_type>(MST_ORC_WIZARD_I + random2(3));
break;
case MONS_LICH:
@@ -2340,6 +2340,10 @@ bool ms_low_hitpoint_cast( const monsters *mon, spell_type monspell )
switch (monspell)
{
case SPELL_TELEPORT_SELF:
+ // Don't cast again if already about to teleport.
+ if (mon->has_ench(ENCH_TP))
+ return (false);
+ // intentional fall-through
case SPELL_TELEPORT_OTHER:
case SPELL_LESSER_HEALING:
case SPELL_GREATER_HEALING:
@@ -2371,11 +2375,15 @@ bool ms_quick_get_away( const monsters *mon /*unused*/, spell_type monspell )
{
switch (monspell)
{
- case SPELL_TELEPORT_SELF:
- case SPELL_BLINK:
- return true;
- default:
- return false;
+ case SPELL_TELEPORT_SELF:
+ // Don't cast again if already about to teleport.
+ if (mon->has_ench(ENCH_TP))
+ return (false);
+ // intentional fall-through
+ case SPELL_BLINK:
+ return (true);
+ default:
+ return (false);
}
}
@@ -2451,7 +2459,7 @@ bool ms_waste_of_time( const monsters *mon, spell_type monspell )
case SPELL_TELEPORT_SELF:
// Monsters aren't smart enough to know when to cancel teleport.
- if (mon->has_ench( ENCH_TP ))
+ if (mon->has_ench(ENCH_TP))
ret = true;
break;
diff --git a/crawl-ref/source/monstuff.cc b/crawl-ref/source/monstuff.cc
index 81c63c5c7b..55aea1c128 100644
--- a/crawl-ref/source/monstuff.cc
+++ b/crawl-ref/source/monstuff.cc
@@ -239,13 +239,13 @@ bool curse_an_item( bool decay_potions, bool quiet )
return (false);
// Curse item.
- if (decay_potions && !quiet) // just for mummies
+ if (decay_potions && !quiet) // Just for mummies.
mpr("You feel nervous for a moment...", MSGCH_MONSTER_SPELL);
if (you.inv[item].base_type == OBJ_POTIONS)
{
int amount;
- // decay at least two of the stack
+ // Decay at least two of the stack.
if (you.inv[item].quantity <= 2)
amount = you.inv[item].quantity;
else
diff --git a/crawl-ref/source/quiver.cc b/crawl-ref/source/quiver.cc
index 8f9bf95d1b..68f8b48e87 100644
--- a/crawl-ref/source/quiver.cc
+++ b/crawl-ref/source/quiver.cc
@@ -22,8 +22,10 @@
static int _get_pack_slot(const item_def&);
static ammo_t _get_weapon_ammo_type(const item_def*);
-static bool _item_matches(const item_def &item, fire_type types, const item_def* launcher);
+static bool _item_matches(const item_def &item, fire_type types,
+ const item_def* launcher);
static bool _items_similar(const item_def& a, const item_def& b);
+
// ----------------------------------------------------------------------
// player_quiver
// ----------------------------------------------------------------------
@@ -57,7 +59,7 @@ void player_quiver::get_desired_item(const item_def** item_out, int* slot_out) c
}
else
{
- // Return the item in inv, since it will have an accurate count
+ // Return the item in inv, since it will have an accurate count.
if (item_out)
*item_out = &you.inv[slot];
}
@@ -168,7 +170,7 @@ void player_quiver::on_weapon_changed()
}
else
{
- if (! _items_similar(*weapon, m_last_weapon))
+ if (!_items_similar(*weapon, m_last_weapon))
{
m_last_weapon = *weapon;
m_last_used_type = _get_weapon_ammo_type(weapon);
@@ -194,13 +196,11 @@ void player_quiver::on_inv_quantity_changed(int slot, int amt)
else
{
// Maybe matches current stack. Redraw if so.
- //
const item_def* desired;
- int qv_slot; get_desired_item(&desired, &qv_slot);
+ int qv_slot;
+ get_desired_item(&desired, &qv_slot);
if (qv_slot == slot)
- {
you.redraw_quiver = true;
- }
}
}
@@ -209,13 +209,39 @@ void player_quiver::_maybe_fill_empty_slot()
{
const item_def* weapon = you.weapon();
const ammo_t slot = _get_weapon_ammo_type(weapon);
- if (! is_valid_item(m_last_used_of_type[slot]))
+#ifdef DEBUG_QUIVER
+ mprf(MSGCH_DIAGNOSTICS, "last quiver item: %s; link %d, wpn: %d",
+ m_last_used_of_type[slot].name(DESC_PLAIN).c_str(),
+ m_last_used_of_type[slot].link, you.equip[EQ_WEAPON]);
+#endif
+ bool unquiver_weapon = false;
+
+ if (is_valid_item(m_last_used_of_type[slot]))
+ {
+ // If we're wielding an item previously quivered, the quiver may need
+ // to be cleared. Else, any already quivered item is valid and we
+ // don't need to do anything else.
+ if (m_last_used_of_type[slot].link == you.equip[EQ_WEAPON])
+ unquiver_weapon = true;
+ else
+ return;
+ }
+
+#ifdef DEBUG_QUIVER
+ mpr("recalculating fire order...", MSGCH_DIAGNOSTICS);
+#endif
+ // const launch_retval desired_ret =
+ // (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);
+ if (unquiver_weapon && order.empty())
+ {
+// m_last_used_of_type[slot] = you.inv[order[i]];
+ m_last_used_of_type[slot].quantity = 0;
+ }
+ else
{
- // const launch_retval desired_ret =
- // (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);
for (unsigned int i = 0; i < order.size(); i++)
{
if (is_launched(&you, weapon, you.inv[order[i]]) == desired_ret)
@@ -240,43 +266,49 @@ void player_quiver::get_fire_order(std::vector<int>& v) const
// fire order is empty.
//
// launcher determines what items match the 'launcher' fire_order type.
-void player_quiver::_get_fire_order(
- std::vector<int>& order,
- bool ignore_inscription_etc,
- const item_def* launcher) const
+void player_quiver::_get_fire_order( std::vector<int>& order,
+ bool ignore_inscription_etc,
+ const item_def* launcher) const
{
- const int inv_start = (ignore_inscription_etc ? 0 : Options.fire_items_start);
+ const int inv_start = (ignore_inscription_etc ? 0
+ : Options.fire_items_start);
// If in a net, cannot throw anything, and can only launch from blowgun.
if (you.attribute[ATTR_HELD])
{
if (launcher && launcher->sub_type == WPN_BLOWGUN)
- for (int i_inv=inv_start; i_inv<ENDOFPACK; i_inv++)
- if (is_valid_item(you.inv[i_inv]) && you.inv[i_inv].launched_by(*launcher))
+ {
+ for (int i_inv = inv_start; i_inv < ENDOFPACK; i_inv++)
+ if (is_valid_item(you.inv[i_inv])
+ && you.inv[i_inv].launched_by(*launcher))
+ {
order.push_back(i_inv);
+ }
+ }
return;
}
- for (int i_inv=inv_start; i_inv<ENDOFPACK; i_inv++)
+ for (int i_inv = inv_start; i_inv < ENDOFPACK; i_inv++)
{
const item_def& item = you.inv[i_inv];
if (!is_valid_item(item))
continue;
+
+ // Don't quiver wielded weapon.
if (you.equip[EQ_WEAPON] == i_inv)
continue;
// =f prevents item from being in fire order.
- if (!ignore_inscription_etc &&
- strstr(item.inscription.c_str(), "=f"))
+ if (!ignore_inscription_etc
+ && strstr(item.inscription.c_str(), "=f"))
{
continue;
}
- for (unsigned int i_flags = 0;
- i_flags < Options.fire_order.size();
+ for (unsigned int i_flags = 0; i_flags < Options.fire_order.size();
i_flags++)
{
- if (_item_matches(item, (fire_type)Options.fire_order[i_flags],
+ if (_item_matches(item, (fire_type) Options.fire_order[i_flags],
launcher))
{
order.push_back( (i_flags<<16) | (i_inv & 0xffff) );