/** * Equips a shield on a character. * @param charData the character data * @ if an error occurs */ private void EquipShield(IOCharacter charData) { // unequip old shield UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_SHIELD); // equip new shield charData.SetEquippedItem(EquipmentGlobals.EQUIP_SLOT_SHIELD, io.RefId); // TODO - attach new shield to mesh // EERIE_LINKEDOBJ_LinkObjectToObject(target->obj, // io->obj, "SHIELD_ATTACH", "SHIELD_ATTACH", io); int wpnID = charData.GetEquippedItem(EquipmentGlobals.EQUIP_SLOT_WEAPON); if (wpnID >= 0) { if (Interactive.Instance.HasIO(wpnID)) { BaseInteractiveObject wpn = Interactive.Instance.GetIO(wpnID); if (wpn.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_2H) || wpn.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_BOW)) { // unequip old weapon UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_WEAPON); } } } }
/// <summary> /// Gets the type of weapon the player is wielding. /// </summary> /// <returns>the player's weapon type</returns> public int GetPlayerWeaponType() { int type = EquipmentGlobals.WEAPON_BARE; int wpnId = GetEquippedItem(EquipmentGlobals.EQUIP_SLOT_WEAPON); if (wpnId >= 0 && Interactive.Instance.HasIO(wpnId)) { BaseInteractiveObject weapon = Interactive.Instance.GetIO(wpnId); if (weapon.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_DAGGER)) { type = EquipmentGlobals.WEAPON_DAGGER; } if (weapon.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_1H)) { type = EquipmentGlobals.WEAPON_1H; } if (weapon.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_2H)) { type = EquipmentGlobals.WEAPON_2H; } if (weapon.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_BOW)) { type = EquipmentGlobals.WEAPON_BOW; } weapon = null; } return(type); }
/// <summary> /// Equips the item on a target BaseInteractiveObject. /// </summary> /// <param name="target">the target <see cref="BaseInteractiveObject"/></param> public virtual void Equip(BaseInteractiveObject target) { if (Io == null) { throw new RPGException(ErrorMessage.INTERNAL_ERROR, "Cannot equip item with no BaseInteractiveObject data"); } if (target != null) { if (target.HasIOFlag(IoGlobals.IO_01_PC) || target.HasIOFlag(IoGlobals.IO_03_NPC)) { IOCharacter charData; if (target.HasIOFlag(IoGlobals.IO_01_PC)) { charData = target.PcData; } else { charData = target.NpcData; } int validid = -1; int i = Interactive.Instance.GetMaxIORefId(); for (; i >= 0; i--) { if (Interactive.Instance.HasIO(i) && Interactive.Instance.GetIO(i) != null && io.Equals(Interactive.Instance.GetIO(i))) { validid = i; break; } } if (validid >= 0) { Interactive.Instance.RemoveFromAllInventories(io); io.Show = IoGlobals.SHOW_FLAG_ON_PLAYER; // on player // handle drag // if (toequip == DRAGINTER) // Set_DragInter(NULL); if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_WEAPON)) { EquipWeapon(charData); } else if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_SHIELD)) { EquipShield(charData); } else if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_RING)) { EquipRing(charData); } else if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_ARMOR)) { // unequip old armor UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_TORSO); // equip new armor charData.SetEquippedItem(EquipmentGlobals.EQUIP_SLOT_TORSO, validid); } else if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_LEGGINGS)) { // unequip old leggings UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_LEGGINGS); // equip new leggings charData.SetEquippedItem(EquipmentGlobals.EQUIP_SLOT_LEGGINGS, validid); } else if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_HELMET)) { // unequip old helmet UnequipItemInSlot(charData, EquipmentGlobals.EQUIP_SLOT_HELMET); // equip new helmet charData.SetEquippedItem(EquipmentGlobals.EQUIP_SLOT_HELMET, validid); } if (io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_HELMET) || io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_ARMOR) || io.HasTypeFlag(EquipmentGlobals.OBJECT_TYPE_LEGGINGS)) { charData.RecreatePlayerMesh(); } charData.ComputeFullStats(); } } } }