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ZCBAVIB7NL3RRYPTACAY65SCUQKV6APFSAC BDFIS53HAIHOCXQ5BE7WCO2MEOFCUQPFY4JGUWVLWY6JO3IFMEKQC 3GLHLYH34NUBL2C5HSECKNVAO4ZFAAYXCW3Q5VZ2PXDDZ4SDD7LQC HSRRNAU5UAYC6B6IQWGJPFROMZBTJICPCH6DJVZDHDTAGOQ6IOYAC TM35IHKZZNBCMR3ERBS4EYHGUK5IVCPUT2JUITMT74AYAIUZSYFQC 4MPLCIJZL4YNUWK2RTKNE6N4UWNBMO5WDRKW737ENVE3RKV5LCRAC SEQIMAWXQYBD6UWTK5HYN4KGLLV53HFM3LLQRSG4N5ZVZTLPR22QC QFM6WJTFHB4KCQYVROAQD4KRAYV2FZKDL5PJZQN5MS7WDYSLJBIAC CWPA3Q5BG7KTTY6GX7CCS26PWC4UHJ47PUCMJX5BOJIP3FSTP2BQC IXW2IM5ITYDCXDB3ORDDVAR5XUSPVQ3BWLP3Q6TRXNTIKGMZTHXAC CYAVI4PYWMMKTPYT5N2B3MI4OSHZFLPKOZFSLFJUXRYAACYXWW3AC 7K5P2GRF6QUXTMERG2R3BB6DZFQYJQ6V2KNPMBPFDLOP36NQILPAC L254F6ZIU2HWGLFFGPIORTN4C3TDQ3E5JZ7Z7GQA5AEDIKL6PKDAC KQNIGKATHT4YSPJFPJGIGPD6VNR5B753SE2JN2LCXZZJNHCGY3DQC TRZAZJJA5VQBJ65SO5H5DNSILIZEJHIZCBYEBHEATCT6ZSMWIFKQC TP5EDQXPVPTKQYTAMN3VQYHM4WRT2RNIR4EDLWLDAV2OQGKSB6KAC LZB2MLE66DKPQPG3BE6IU77HLHYMBQFJTKFJSPKEKZSOSXPXESJQC mprf("%s %s covered in a thin film of poison.", old_desc,(you.inv[ammo].quantity == 1) ? "is" : "are");
preserve_quiver_slots q;const char *old_desc = you.inv[ammo].name(DESC_CAP_YOUR).c_str();if (set_item_ego_type( you.inv[ammo], OBJ_MISSILES, SPMSL_POISONED )){mprf("%s %s covered in a thin film of poison.", old_desc,(you.inv[ammo].quantity == 1) ? "is" : "are");
you.quiver_change = true;if (ammo == you.equip[EQ_WEAPON])you.wield_change = true;}else{canned_msg(MSG_NOTHING_HAPPENS);
if (ammo == you.equip[EQ_WEAPON])you.wield_change = true;}else{canned_msg(MSG_NOTHING_HAPPENS);}
// Quiver tracks items, which in most cases is the Right Thing. But// when a quivered item is identified, the quiver doesn't change to// match. We would like the quiver to store the identified item.//// This class saves off the quiver item slots, and restores them when// destroyed. The expected use is to create one of these around code// that identifies items in inv.class preserve_quiver_slots{public:preserve_quiver_slots();~preserve_quiver_slots();private:int m_last_used_of_type[NUM_AMMO];};
// Return item that we would like to fire by default, and its inv slot// (if there are any in inv). If the item is in inv, its count will// be correct.
// Return:// *slot_out filled in with the inv slot of the item we would like// to fire by default. If -1, the inv doesn't contain our desired// item.//// *item_out filled in with item we would like to fire by default.// This can be returned even if the item is not in inv (although if// it is in inv, a reference to the inv item, with accurate count,// is returned)//
static const short QUIVER_COOKIE = 0xb015;void player_quiver::save(writer& outf) const{marshallShort(outf, QUIVER_COOKIE);marshallItem(outf, m_last_weapon);marshallLong(outf, m_last_used_type);marshallLong(outf, ARRAYSIZE(m_last_used_of_type));for (int i=0; i<ARRAYSIZE(m_last_used_of_type); i++){marshallItem(outf, m_last_used_of_type[i]);}}void player_quiver::load(reader& inf){const short cooky = unmarshallShort(inf);ASSERT(cooky == QUIVER_COOKIE); (void)cooky;unmarshallItem(inf, m_last_weapon);m_last_used_type = (ammo_t)unmarshallLong(inf);ASSERT(m_last_used_type >= AMMO_INVALID && m_last_used_type < NUM_AMMO);const long count = unmarshallLong(inf);ASSERT(count <= ARRAYSIZE(m_last_used_of_type));for (int i=0; i<count; i++){unmarshallItem(inf, m_last_used_of_type[i]);}}// ----------------------------------------------------------------------// Identify helper// ----------------------------------------------------------------------preserve_quiver_slots::preserve_quiver_slots(){if (! you.m_quiver) return;COMPILE_CHECK(ARRAYSIZE(m_last_used_of_type) ==ARRAYSIZE(you.m_quiver->m_last_used_of_type), a);for (int i=0; i<ARRAYSIZE(m_last_used_of_type); i++){you.m_quiver->get_desired_item(NULL, &m_last_used_of_type[i]);}}preserve_quiver_slots::~preserve_quiver_slots(){if (! you.m_quiver) return;for (int i=0; i<ARRAYSIZE(m_last_used_of_type); i++){const int slot = m_last_used_of_type[i];if (slot != -1){you.m_quiver->m_last_used_of_type[i] = you.inv[slot];}}you.redraw_quiver = true;}// ----------------------------------------------------------------------