public void UnEquip(EquipSlots slots) { for (int i = _items.Count - 1; i >= 0; i--) { Equippable item = _items[i]; if((item.slots & slots) != EquipSlots.None) UnEquip(item); } }
public void Equip(Equippable item, EquipSlots slots) { UnEquip(slots); _items.Add(item); item.transform.SetParent(transform); item.slots = slots; item.OnEquip(); this.PostNotification(EquippedNotification, item); }
public Equippable GetItem(EquipSlots slots) { for (int i = 0; i < _items.Count; i++) { Equippable item = _items [i]; if ((item.slots & slots) != EquipSlots.None) { return item; } } return null; }
public Equippable GetItem(EquipSlots slots) { for (int i = _items.Count - 1; i >= 0; i--) { Equippable item = _items [i]; if ((item.slots & slots) != EquipSlots.None) return item; } return null; }
/// <summary> /// Attempt to unequip item from slot. /// </summary> /// <param name="slot">Slot to unequip.</param> /// <returns>The item unequipped, otherwise null.</returns> public DaggerfallUnityItem UnequipItem(EquipSlots slot) { if (!IsSlotOpen(slot)) { DaggerfallUnityItem item = equipTable[(int)slot]; equipTable[(int)slot].EquipSlot = EquipSlots.None; equipTable[(int)slot] = null; // Allow entity effect manager to stop any enchantments on this item StopEquippedItem(item); return(item); } return(null); }
/// <summary> /// Checks if a slot is open. /// </summary> public bool IsSlotOpen(EquipSlots slot) { if (slot == EquipSlots.None) { return(false); } if (equipTable[(int)slot] == null) { return(true); } else { return(false); } }
static int GetRoleplayRealismItemsWeaponBalanceAdjustedSpeed(int baseSpeed, PlayerEntity player, WeaponTypes weaponType) { EquipSlots weaponSlot = GameManager.Instance.WeaponManager.UsingRightHand ? EquipSlots.RightHand : EquipSlots.LeftHand; DaggerfallUnityItem weapon = player.ItemEquipTable.GetItem(weaponSlot); // Hand-to-hand keeps its whole speed if (weaponType == WeaponTypes.Melee || weapon == null) { return(baseSpeed); } float weaponWeight = weapon.ItemTemplate.baseWeight; // Seems like the Feather Weight weapon enchant won't affect this formula int strWeightPerc = 150 - player.Stats.LiveStrength; float adjustedWeight = strWeightPerc * weaponWeight / 100f; float speedReductionPerc = adjustedWeight * 3.4f / 90f; // Magic numbers taken from R&R:I return((int)(baseSpeed * (1 - speedReductionPerc))); }
// NOTE: Working through action processes here. Will clean up soon. private void AccessoryItemsButton_OnMouseClick(BaseScreenComponent sender, Vector2 position) { // Get item EquipSlots slot = (EquipSlots)sender.Tag; DaggerfallUnityItem item = playerEntity.ItemEquipTable.GetItem(slot); if (item == null) { return; } // Handle click based on action if (selectedActionMode == ActionModes.Equip) { UnequipItem(item, false); } else if (selectedActionMode == ActionModes.Info) { ShowInfoPopup(item); } }
/// <summary> /// Get the equipment slot this items belongs in. /// Not currently 100% known how Daggerfall defines equipment slots. /// This method uses the best available knowledge at time of writing. /// When item supports multiple slots: /// - If a slot is open, returns first free slot. /// - If both slots populated, returns first slot by order. /// </summary> /// <param name="item">Item to find equipment slot.</param> /// <returns>EquipSlot.</returns> public EquipSlots GetEquipSlot(DaggerfallUnityItem item) { // Check for a custom item defining an equip slot, and return if so, else if None then continue EquipSlots result = item.GetEquipSlot(); if (result != EquipSlots.None) { return(result); } // Resolve based on equipment category switch (item.ItemGroup) { case ItemGroups.Gems: result = GetGemSlot(); break; case ItemGroups.Jewellery: result = GetJewellerySlot(item); break; case ItemGroups.Armor: result = GetArmorSlot(item); break; case ItemGroups.Weapons: result = GetWeaponSlot(item); break; case ItemGroups.MensClothing: result = GetMensClothingSlot(item); break; case ItemGroups.WomensClothing: result = GetWomensClothingSlot(item); break; } return(result); }
public void ItemBreaks(DaggerfallEntity owner) { // Classic does not have the plural version of this string, and uses the short name rather than the long one. // Also the classic string says "is" instead of "has" string itemBroke = ""; if (TemplateIndex == (int)Armor.Boots || TemplateIndex == (int)Armor.Gauntlets || TemplateIndex == (int)Armor.Greaves) { itemBroke = UserInterfaceWindows.HardStrings.itemHasBrokenPlural; } else { itemBroke = UserInterfaceWindows.HardStrings.itemHasBroken; } itemBroke = itemBroke.Replace("%s", LongName); DaggerfallUI.Instance.PopupMessage(itemBroke); EquipSlots slot = owner.ItemEquipTable.GetEquipSlot(this); if (owner.ItemEquipTable.GetItem(slot) == this) { owner.ItemEquipTable.UnequipItem(slot); } }
/// <summary> /// Returns the magnitude of the stat reduction if this item is to be equipped. /// Based on the EquipSlot of the new item, the old item is checked. /// </summary> public ItemBase GetEquipSlot(EquipSlots slot) { switch (slot) { case EquipSlots.Head: return(Head); case EquipSlots.Hand: return(Hand); case EquipSlots.Torso: return(Torso); case EquipSlots.Legs: return(Legs); case EquipSlots.Extra: return(Extra); default: return(null); } }
/// <summary> /// Attempt to unequip item from slot. /// </summary> /// <param name="slot">Slot to unequip.</param> /// <returns>The item unequipped, otherwise null.</returns> public DaggerfallUnityItem UnequipItem(EquipSlots slot) { if (!IsSlotOpen(slot)) { DaggerfallUnityItem item = equipTable[(int)slot]; equipTable[(int)slot].EquipSlot = EquipSlots.None; equipTable[(int)slot] = null; // Allow entity effect manager to stop any enchantments on this item StopEquippedItem(item); PlayerEntity player = GameManager.Instance.PlayerEntity; if (parentEntity == player) { GameManager.Instance.PlayerEntity.EquipmentEncumbranceSpeedMod = GameManager.Instance.PlayerEntity.UpdateEquipmentEncumbranceState(); } return(item); } return(null); }
private static EquipmentItem getEquipItem(PlayerInfo info, int slotNum) { if (System.Enum.GetValues(typeof(EquipSlots)).Length <= slotNum || slotNum < 0) { return(null); } EquipSlots slot = (EquipSlots)slotNum; switch (slot) { case EquipSlots.Helmet: return(info.helmet); case EquipSlots.UpperBody: return(info.upperBody); case EquipSlots.LowerBody: return(info.lowerBody); case EquipSlots.Boots: return(info.boots); case EquipSlots.LeftClaw: return(info.leftClaw); case EquipSlots.RightClaw: return(info.rightClaw); case EquipSlots.Backpack: return(info.backpack); default: Debug.Log("unsupported inventory detected"); return(null); } }
// After HeroStatsMenu instantiates the EquipMenu, it passes relevant values for set up public void SetHero(int index, EquipSlots slot, GameObject parentGameObject) { // Sets HeroStatsMenuMonitor's gameObject as a parent, and displays it so the new menu displays this.parentGameObject = parentGameObject; parentGameObject.SetActive(false); // Index of current hero heroIndex = index; hero = BattleLoader.Party.Hero[heroIndex]; // Type of weapon or armor being selected this.slot = slot; heroStash = BattleLoader.Party.Hero[heroIndex].Equipment; // Make sure equip button is inactive at start equipButton.GetComponent <Button>().interactable = false; messageText.text = ""; partyStash = BattleLoader.Party.Inventory; // Fill the grid PopulateGrid(); }
public override void Update() { // Update HUD visibility popupText.Enabled = ShowPopupText; midScreenTextLabel.Enabled = ShowMidScreenText; crosshair.Enabled = ShowCrosshair; vitals.Enabled = ShowVitals; compass.Enabled = ShowCompass; interactionModeIcon.Enabled = ShowInteractionModeIcon; placeMarker.Enabled = ShowLocalQuestPlaces; escortingFaces.EnableBorder = ShowEscortingFaces; questDebugger.Enabled = !(questDebugger.State == HUDQuestDebugger.DisplayState.Nothing); activeSpells.Enabled = ShowActiveSpells; // Large HUD will force certain other HUD elements off as they conflict in space or utility bool largeHUDEnabled = false;//DaggerfallUnity.Settings.LargeHUD; if (largeHUDEnabled) { largeHUD.Enabled = true; vitals.Enabled = false; compass.Enabled = false; interactionModeIcon.Enabled = false; } else { largeHUD.Enabled = false; } // Scale HUD elements largeHUD.Scale = NativePanel.LocalScale * DaggerfallUnity.Settings.LargeHUDScale; compass.Scale = NativePanel.LocalScale; vitals.Scale = NativePanel.LocalScale; crosshair.CrosshairScale = CrosshairScale; interactionModeIcon.Scale = NativePanel.LocalScale; // Align compass to screen panel Rect screenRect = ParentPanel.Rectangle; float compassX = screenRect.width - (compass.Size.x); float compassY = screenRect.height - (compass.Size.y); compass.Position = new Vector2(compassX, compassY); // Update midscreen text timer and remove once complete if (midScreenTextTimer != -1) { midScreenTextTimer += Time.deltaTime; if (midScreenTextTimer > midScreenTextDelay) { midScreenTextTimer = -1; midScreenTextLabel.Text = string.Empty; } } // Update arrow count if player holding an unsheathed bow // TODO: Find a spot for arrow counter when large HUD enabled (remembering player could be in 320x200 retro mode) arrowCountTextLabel.Enabled = false; if (!largeHUDEnabled && ShowArrowCount && !GameManager.Instance.WeaponManager.Sheathed) { EquipSlots slot = DaggerfallUnity.Settings.BowLeftHandWithSwitching ? EquipSlots.LeftHand : EquipSlots.RightHand; DaggerfallUnityItem held = GameManager.Instance.PlayerEntity.ItemEquipTable.GetItem(slot); if (held != null && held.ItemGroup == ItemGroups.Weapons && (held.TemplateIndex == (int)Weapons.Long_Bow || held.TemplateIndex == (int)Weapons.Short_Bow)) { // Arrow count label position is offset to left of compass and centred relative to compass height // This is done every frame to handle adaptive resolutions Vector2 arrowLabelPos = compass.Position; arrowLabelPos.x -= arrowCountTextLabel.TextWidth; arrowLabelPos.y += compass.Size.y / 2 - arrowCountTextLabel.TextHeight / 2; DaggerfallUnityItem arrows = GameManager.Instance.PlayerEntity.Items.GetItem(ItemGroups.Weapons, (int)Weapons.Arrow); arrowCountTextLabel.Text = (arrows != null) ? arrows.stackCount.ToString() : "0"; arrowCountTextLabel.TextScale = NativePanel.LocalScale.x; arrowCountTextLabel.Position = arrowLabelPos; arrowCountTextLabel.Enabled = true; } } HotkeySequence.KeyModifiers keyModifiers = HotkeySequence.GetKeyboardKeyModifiers(); // Cycle quest debugger state if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.DebuggerToggle).IsDownWith(keyModifiers)) { questDebugger.NextState(); } if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.Pause).IsUpWith(keyModifiers)) { DaggerfallUI.PostMessage(DaggerfallUIMessages.dfuiOpenPauseOptionsDialog); } // Toggle HUD rendering if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.HUDToggle).IsDownWith(keyModifiers)) { renderHUD = !renderHUD; } // Toggle Retro Renderer Postprocessing if (DaggerfallShortcut.GetBinding(DaggerfallShortcut.Buttons.ToggleRetroPP).IsDownWith(keyModifiers)) { RetroRenderer.enablePostprocessing = !RetroRenderer.enablePostprocessing; } flickerController.NextCycle(); // Don't display persistent HUD elements during initial startup // Prevents HUD elements being shown briefly at wrong size/scale at game start if (!startupComplete && !GameManager.Instance.IsPlayingGame()) { largeHUD.Enabled = false; vitals.Enabled = false; crosshair.Enabled = false; compass.Enabled = false; } else { startupComplete = true; } base.Update(); }
public int this[EquipSlots slot] { set { _equipmentSlots[(int)slot] = value; } get { return(_equipmentSlots[(int)slot]); } }
public void SetSlotEquipment(EquipSlots slot, int gumpID) { _equipmentSlots[(int)slot] = gumpID; }
/// <summary> /// Attempt to unequip item from slot. /// </summary> /// <param name="slot">Slot to unequip.</param> /// <returns>True if item unequipped, otherwise false.</returns> public bool UnequipItem(EquipSlots slot) { if (!IsSlotOpen(slot)) { equipTable[(int)slot].EquipSlot = EquipSlots.None; equipTable[(int)slot] = null; return true; } return false; }
/// <summary> /// Attempt to equip item. /// </summary> /// <param name="item">Item to equip.</param> /// <param name="alwaysEquip">Always equip item, replacing another in the same slot if needed.</param> /// <returns>True when item equipped, otherwise false.</returns> public bool EquipItem(DaggerfallUnityItem item, bool alwaysEquip = true) { if (item == null) { return(false); } // Special weapon handling if (item.ItemGroup == ItemGroups.Weapons) { // Cannot equip arrows if (item.TemplateIndex == (int)Weapons.Arrow) { return(false); } // Equipping a 2H weapons will always unequip both hands if (GetItemHands(item) == ItemHands.Both) { UnequipItem(EquipSlots.LeftHand); UnequipItem(EquipSlots.RightHand); } } // Equipping a shield will always unequip 2H weapon if (item.ItemGroup == ItemGroups.Armor && (item.TemplateIndex == (int)Armor.Kite_Shield || item.TemplateIndex == (int)Armor.Round_Shield || item.TemplateIndex == (int)Armor.Tower_Shield)) { // If holding a 2H weapon then unequip DaggerfallUnityItem rightHandItem = equipTable[(int)EquipSlots.RightHand]; if (rightHandItem != null) { if (GetItemHands(rightHandItem) == ItemHands.Both) { UnequipItem(EquipSlots.RightHand); } } } // Get slot for this item EquipSlots slot = GetEquipSlot(item); if (slot == EquipSlots.None) { return(false); } // Unequip any previous item if (!IsSlotOpen(slot) && !alwaysEquip) { return(false); } else { UnequipItem(slot); } // Equip item to slot item.EquipSlot = slot; equipTable[(int)slot] = item; //Debug.Log(string.Format("Equipped {0} to {1}", item.LongName, slot.ToString())); return(true); }
int equipmentSlot(EquipSlots slotID) { return m_equipmentSlots[(int)slotID]; }
/* Equips the item passed to the EquipSlot passed. If the equipment cannot be equipped * to the equip slot then the original item passed is returned. */ public Gear Equip(Gear equip, EquipSlots slot) { Gear equipped = equip; // will be 0 if the equipment cannot go in that slot if ((equip.EquipSlot & slot) != 0) { // will be false if there is nothing equipped to that slot if (IsEquipped(slot)) { // is the item to equip two handed if ((equip.EquipSlot & EquipSlots.TWO_HANDED) != 0) { // will be false if a two handed weapon is not equipped if (!IsEquipped(EquipSlots.TWO_HANDED)) { // Here we need to know if both hands are equipped or only one // returns true is both hands equipped with item if (IsEquipped(EquipSlots.BOTH_HANDS)) { // evaluates to true if the inventory has enough space to return the item if (!playerInventory.IsFull()) { // both hands have to have something in them and cannot be a 2H item by here // so we add offhand to the inventory and place main hand on the cursor by returning it playerInventory.AddItemToLocation(playerInventory.GetFirstEmptyIndex(), (Item)equipment[EquipSlots.OFF_HAND]); equipped = Unequip(EquipSlots.MAIN_HAND); equipGear(equip, slot); } } else { // by this point we can assume that the item being // equipped is a 2H weapon and only one hand is used if (IsEquipped(EquipSlots.MAIN_HAND)) { equipped = Unequip(EquipSlots.MAIN_HAND); equipGear(equip, slot); } else { equipped = Unequip(EquipSlots.OFF_HAND); equipGear(equip, slot); } } } else { equipped = Unequip(slot); equipGear(equip, slot); } } else { equipped = Unequip(slot); equipGear(equip, slot); } } else { equipGear(equip, slot); } } return(equipped); }
/* returns true if the spot being equipped to has equipment in it */ public bool IsEquipped(EquipSlots slot) { return(equipState.HasFlag(slot)); }
/* returns the gear in the specified equip slot */ public Gear GetGearBySlot(EquipSlots slot) { return((Gear)equipment[slot]); }
/* equips gear and updates the equipState at the same time to * keep these two items in sync */ private void equipGear(Gear equip, EquipSlots slot) { equipment.Add(slot, equip); equipState = equipState | equip.EquipSlot; }
void drawLargePaperdoll_Noninteractable(SpriteBatchUI spriteBatch) { EquipSlots[] slotsToDraw = new EquipSlots[6] { EquipSlots.Body, EquipSlots.Footwear, EquipSlots.Legging, EquipSlots.Shirt, EquipSlots.Hair, EquipSlots.FacialHair }; for (int i = 0; i < slotsToDraw.Length; i++) { int bodyID = 0, hue = hueSlot(slotsToDraw[i]); bool hueGreyPixelsOnly = true; switch (slotsToDraw[i]) { case EquipSlots.Body: if (_isElf) bodyID = (_isFemale ? 1893 : 1894); else bodyID = (_isFemale ? 1888 : 1889); break; case EquipSlots.Footwear: bodyID = (_isFemale ? 1891 : 1890); hue = 900; break; case EquipSlots.Legging: bodyID = (_isFemale ? 1892 : 1848); hue = 348; break; case EquipSlots.Shirt: bodyID = (_isFemale ? 1812 : 1849); hue = 792; break; case EquipSlots.Hair: if (equipmentSlot(EquipSlots.Hair) != 0) { bodyID = _isFemale ? Data.HairStyles.FemaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)) : Data.HairStyles.MaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)); hueGreyPixelsOnly = false; } break; case EquipSlots.FacialHair: if (equipmentSlot(EquipSlots.FacialHair) != 0) { bodyID = _isFemale ? 0 : Data.HairStyles.FacialHairGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.FacialHair)); hueGreyPixelsOnly = false; } break; } if (bodyID != 0) spriteBatch.Draw2D(Data.Gumps.GetGumpXNA(bodyID), Position, hue, hueGreyPixelsOnly, false); } }
public WeaponItem(EquipSlots slot, int maxDurability, int minDamage, int maxDamage, bool isRanged = false, Dictionary <StatTypes, int>?requirements = null) : base(slot, maxDurability, requirements) { AffectedStats.Add(StatTypes.MINDMG, minDamage); AffectedStats.Add(StatTypes.MAXDMG, maxDamage); IsRanged = isRanged; }
public override void Draw(SpriteBatchUI spriteBatch, Point position) { EquipSlots[] slotsToDraw = new EquipSlots[6] { EquipSlots.Body, EquipSlots.Footwear, EquipSlots.Legging, EquipSlots.Shirt, EquipSlots.Hair, EquipSlots.FacialHair }; for (int i = 0; i < slotsToDraw.Length; i++) { int bodyID = 0; int hue = hueSlot(slotsToDraw[i]); bool hueGreyPixelsOnly = true; switch (slotsToDraw[i]) { case EquipSlots.Body: if (m_isElf) bodyID = (m_isFemale ? 1893 : 1894); else bodyID = (m_isFemale ? 1888 : 1889); break; case EquipSlots.Footwear: bodyID = (m_isFemale ? 1891 : 1890); hue = 900; break; case EquipSlots.Legging: bodyID = (m_isFemale ? 1892 : 1848); hue = 348; break; case EquipSlots.Shirt: bodyID = (m_isFemale ? 1812 : 1849); hue = 792; break; case EquipSlots.Hair: if (equipmentSlot(EquipSlots.Hair) != 0) { bodyID = m_isFemale ? IO.HairStyles.FemaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)) : IO.HairStyles.MaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)); hueGreyPixelsOnly = false; } break; case EquipSlots.FacialHair: if (equipmentSlot(EquipSlots.FacialHair) != 0) { bodyID = m_isFemale ? 0 : IO.HairStyles.FacialHairGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.FacialHair)); hueGreyPixelsOnly = false; } break; } if (bodyID != 0) spriteBatch.Draw2D(IO.GumpData.GetGumpXNA(bodyID), new Vector3(position.X, position.Y, 0), Utility.GetHueVector(hue, hueGreyPixelsOnly, false)); } }
/// <summary> /// Gets item equipped to slot. /// </summary> /// <param name="slot">Slot to check.</param> /// <returns>Item present in slot, otherwise null.</returns> public DaggerfallUnityItem GetItem(EquipSlots slot) { if (slot == EquipSlots.None) return null; return equipTable[(int)slot]; }
public void SetSlotHue(EquipSlots slot, int gumpID) { m_hueSlots[(int)slot] = gumpID; }
/// <summary> /// Update armor values after equipping or unequipping a piece of armor. /// </summary> public void UpdateEquippedArmorValues(DaggerfallUnityItem armor, bool equipping) { if (!armor.IsShield) { // Get slot used by this armor EquipSlots slot = ItemEquipTable.GetEquipSlot(armor); // This array maps equip slots to the order of the 7 armor values EquipSlots[] equipSlots = { EquipSlots.Head, EquipSlots.RightArm, EquipSlots.LeftArm, EquipSlots.ChestArmor, EquipSlots.Gloves, EquipSlots.LegsArmor, EquipSlots.Feet }; // Get the index for the correct armor value and update the armor value. // Armor value is 100 when no armor is equipped. For every point of armor as shown on the inventory screen, 5 is subtracted. int index = System.Array.IndexOf(equipSlots, slot); if (equipping) { armorValues[index] -= (sbyte)(armor.GetMaterialArmorValue() * 5); } else { armorValues[index] += (sbyte)(armor.GetMaterialArmorValue() * 5); } } else { // Shields armor values in classic are unaffected by their material type. int[] values = { 0, 0, 0, 0, 0, 0, 0 }; // shield's effect on the 7 armor values if (armor.TemplateIndex == (int)Armor.Buckler) { values[2] = 1; // left arm values[4] = 1; // gloves } else if (armor.TemplateIndex == (int)Armor.Round_Shield) { values[2] = 2; // left arm values[4] = 2; // gloves values[5] = 2; // legs armor } else if (armor.TemplateIndex == (int)Armor.Kite_Shield) { values[2] = 3; // left arm values[4] = 3; // gloves values[5] = 3; // legs armor } else if (armor.TemplateIndex == (int)Armor.Tower_Shield) { values[0] = 4; // head values[2] = 4; // left arm values[4] = 4; // gloves values[5] = 4; // legs armor } for (int i = 0; i < armorValues.Length; i++) { if (equipping) { armorValues[i] -= (sbyte)(values[i] * 5); } else { armorValues[i] += (sbyte)(values[i] * 5); } } } }
int hueSlot(EquipSlots slotID) { return m_hueSlots[(int)slotID]; }
private static bool validateFromCursorOperation(ItemInventorySlot swapSlot, EquipmentItem swapEquipItem, int slotNum, bool drop, int quantity, PlayerInfo info) { //cursor must have something in it for a valid transfer if (info.cursorSlot == null || info.cursorSlot.isEmpty()) { Debug.Log("InventoryOperation validation error: cursor is null or has no contents to transfer"); return(false); } Item transferItem = info.cursorSlot.getItem(); int cursorQuantity = info.cursorSlot.getQuantity(); //quantity tranferred cannot be greater than that in cursor if (quantity > cursorQuantity) { Debug.Log("InventoryOperation validation error: cannot transfer more items than cursor has"); return(false); } bool handleEquipment = true; //if there is an equipment slot or if dropping, not performing an equipment change if (swapSlot != null || drop == true) { handleEquipment = false; } if (handleEquipment) { //equippables dont stack if (cursorQuantity > 1) { Debug.Log("InventoryOperation validation error: cursor cannot carry more than one equipment item"); return(false); } EquipSlots eSlot = (EquipSlots)slotNum; switch (eSlot) { case EquipSlots.Helmet: //check for inconsistency. if (info.helmet != null && swapEquipItem == null) { Debug.Log("InventoryOperation validation error: trying to equip incorrect equipment to helmet slot or slot is occupied"); return(false); } return(transferItem is HelmetItem); case EquipSlots.UpperBody: if (info.upperBody != null && swapEquipItem == null) { Debug.Log("InventoryOperation validation error: trying to equip incorrect equipment to upper body slot or slot is occupied"); return(false); } return(transferItem is UpperBodyItem); case EquipSlots.LowerBody: if (info.lowerBody != null && swapEquipItem == null) { Debug.Log("InventoryOperation validation error: trying to equip incorrect equipment to lower body slot or slot is occupied"); return(false); } return(transferItem is LowerBodyItem); case EquipSlots.Boots: if (info.boots != null && swapEquipItem == null) { Debug.Log("InventoryOperation validation error: trying to equip incorrect equipment to boots slot or slot is occupied"); return(false); } return(transferItem is BootsItem); case EquipSlots.LeftClaw: if (info.leftClaw != null && swapEquipItem == null) { Debug.Log("InventoryOperation validation error: trying to equip incorrect equipment to left claw slot or slot is occupied"); return(false); } return(transferItem is ClawItem); case EquipSlots.RightClaw: if (info.rightClaw != null && swapEquipItem == null) { Debug.Log("InventoryOperation validation error: trying to equip incorrect equipment to right claw slot or slot is occupied"); return(false); } return(transferItem is ClawItem); case EquipSlots.Backpack: if (info.backpack != null && swapEquipItem == null) { Debug.Log("InventoryOperation validation error: trying to equip incorrect equipment to backpack slot or slot is occupied"); return(false); } return(transferItem is BackpackItem); default: Debug.Log("InventoryOperation validation error: unrecognized equipment type"); return(false); } } else { if (swapSlot != null) { //if enough space and item is same as destination, success. if (swapSlot.isAddableItems(transferItem, quantity)) { return(true); } else { Debug.Log("InventoryOperation validation error: trying to unequip non-existing helmet"); return(false); } } else { //if not a swap slot, must be drop. Return drop success. return(drop); } } }
void drawLargePaperdoll_Noninteractable(SpriteBatchUI spriteBatch) { EquipSlots[] slotsToDraw = new EquipSlots[6] { EquipSlots.Body, EquipSlots.Footwear, EquipSlots.Legging, EquipSlots.Shirt, EquipSlots.Hair, EquipSlots.FacialHair }; for (int i = 0; i < slotsToDraw.Length; i++) { int bodyID = 0; int hue = hueSlot(slotsToDraw[i]); bool hueGreyPixelsOnly = true; switch (slotsToDraw[i]) { case EquipSlots.Body: if (m_isElf) { bodyID = (m_isFemale ? 1893 : 1894); } else { bodyID = (m_isFemale ? 1888 : 1889); } break; case EquipSlots.Footwear: bodyID = (m_isFemale ? 1891 : 1890); hue = 900; break; case EquipSlots.Legging: bodyID = (m_isFemale ? 1892 : 1848); hue = 348; break; case EquipSlots.Shirt: bodyID = (m_isFemale ? 1812 : 1849); hue = 792; break; case EquipSlots.Hair: if (equipmentSlot(EquipSlots.Hair) != 0) { bodyID = m_isFemale ? UltimaData.HairStyles.FemaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)) : UltimaData.HairStyles.MaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)); hueGreyPixelsOnly = false; } break; case EquipSlots.FacialHair: if (equipmentSlot(EquipSlots.FacialHair) != 0) { bodyID = m_isFemale ? 0 : UltimaData.HairStyles.FacialHairGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.FacialHair)); hueGreyPixelsOnly = false; } break; } if (bodyID != 0) { spriteBatch.Draw2D(UltimaData.GumpData.GetGumpXNA(bodyID), Position, hue, hueGreyPixelsOnly, false); } } }
/// <summary> /// Get the equipment slot this items belongs in. /// Not currently 100% known how Daggerfall defines equipment slots. /// This method uses the best available knowledge at time of writing. /// When item supports multiple slots: /// - If a slot is open, returns first free slot. /// - If both slots populated, returns first slot by order. /// </summary> /// <param name="item">Item to find equipment slot.</param> /// <returns>EquipSlot.</returns> public EquipSlots GetEquipSlot(DaggerfallUnityItem item) { // Check for a custom item defining an equip slot, and return if so, else if None then continue EquipSlots result = item.GetEquipSlot(); if (result != EquipSlots.None) { return(result); } // Resolve based on equipment category switch (item.ItemGroup) { case ItemGroups.Gems: result = GetGemSlot(); break; case ItemGroups.Jewellery: result = GetJewellerySlot(item); break; case ItemGroups.Tiara_Jewelry: case ItemGroups.Crown_Jewelry: result = EquipSlots.Head; break; case ItemGroups.Ring_Jewelry: result = GetFirstSlot(EquipSlots.Ring0, EquipSlots.Ring1); break; case ItemGroups.Earing_Jewelry: result = GetFirstSlot(EquipSlots.Mark0, EquipSlots.Mark1); break; case ItemGroups.Neck_Jewelry: result = GetFirstSlot(EquipSlots.Amulet0, EquipSlots.Amulet1); break; case ItemGroups.Bracelet_Jewelry: result = GetFirstSlot(EquipSlots.Bracelet0, EquipSlots.Bracelet1); break; case ItemGroups.Magic_Amplifiers: result = GetFirstSlot(EquipSlots.Mark0, EquipSlots.Mark1); // Will likely change later when I make scepters and wands possibly equip onto left-hand instead of an accessory slot, for not this is just for the mark item. break; case ItemGroups.Armor: result = GetArmorSlot(item); break; case ItemGroups.Weapons: result = GetWeaponSlot(item); break; case ItemGroups.MensClothing: result = GetMensClothingSlot(item); break; case ItemGroups.WomensClothing: result = GetWomensClothingSlot(item); break; } return(result); }
int equipmentSlot(EquipSlots slotID) { return(_equipmentSlots[(int)slotID]); }
/// <summary> /// Checks if a slot is open. /// </summary> public bool IsSlotOpen(EquipSlots slot) { if (slot == EquipSlots.None) return false; if (equipTable[(int)slot] == null) return true; else return false; }
/// <summary> /// Attempt to equip item. /// </summary> /// <param name="item">Item to equip.</param> /// <param name="alwaysEquip">Always equip item, replacing another in the same slot if needed.</param> /// <returns>True when item equipped, otherwise false.</returns> public List <DaggerfallUnityItem> EquipItem(DaggerfallUnityItem item, bool alwaysEquip = true, bool playEquipSounds = true) { if (item == null) { return(null); } // Get slot for this item EquipSlots slot = GetEquipSlot(item); if (slot == EquipSlots.None) { return(null); } // If more than one item selected, equip only one if (item.IsAStack()) { item = GameManager.Instance.PlayerEntity.Items.SplitStack(item, 1); } List <DaggerfallUnityItem> unequippedList = new List <DaggerfallUnityItem>(); // Special weapon handling if (item.ItemGroup == ItemGroups.Weapons) { // Cannot equip arrows if (item.TemplateIndex == (int)Weapons.Arrow) { return(null); } // Equipping a 2H weapons will always unequip both hands if (GetItemHands(item) == ItemHands.Both) { UnequipItem(EquipSlots.LeftHand, unequippedList); UnequipItem(EquipSlots.RightHand, unequippedList); } } // Equipping a shield will always unequip 2H weapon if (GetItemHands(item) == ItemHands.LeftOnly) { // If holding a 2H weapon then unequip DaggerfallUnityItem rightHandItem = equipTable[(int)EquipSlots.RightHand]; if (rightHandItem != null && GetItemHands(rightHandItem) == ItemHands.Both) { UnequipItem(EquipSlots.RightHand, unequippedList); } } // Unequip any previous item if (!IsSlotOpen(slot) && !alwaysEquip) { return(null); } else { UnequipItem(slot, unequippedList); } PlayerEntity player = GameManager.Instance.PlayerEntity; // Equip item to slot item.EquipSlot = slot; equipTable[(int)slot] = item; // Play equip sound if (playEquipSounds) { DaggerfallUI.Instance.PlayOneShot(item.GetEquipSound()); } // Allow entity effect manager to start any enchantments on this item StartEquippedItem(item); //Debug.Log(string.Format("Equipped {0} to {1}", item.LongName, slot.ToString())); if (parentEntity == player) { GameManager.Instance.PlayerEntity.EquipmentEncumbranceSpeedMod = GameManager.Instance.PlayerEntity.UpdateEquipmentEncumbranceState(); } return(unequippedList); }
/// <summary> /// Attempt to equip item. /// </summary> /// <param name="item">Item to equip.</param> /// <param name="alwaysEquip">Always equip item, replacing another in the same slot if needed.</param> /// <returns>True when item equipped, otherwise false.</returns> public List <DaggerfallUnityItem> EquipItem(DaggerfallUnityItem item, bool alwaysEquip = true, bool playEquipSounds = true) { if (item == null) { return(null); } // Get slot for this item EquipSlots slot = GetEquipSlot(item); if (slot == EquipSlots.None) { return(null); } List <DaggerfallUnityItem> unequippedList = new List <DaggerfallUnityItem>(); // Special weapon handling if (item.ItemGroup == ItemGroups.Weapons) { // Cannot equip arrows if (item.TemplateIndex == (int)Weapons.Arrow) { return(null); } // Equipping a 2H weapons will always unequip both hands if (GetItemHands(item) == ItemHands.Both) { UnequipItem(EquipSlots.LeftHand, unequippedList); UnequipItem(EquipSlots.RightHand, unequippedList); } } // Equipping a shield will always unequip 2H weapon if (item.ItemGroup == ItemGroups.Armor && (item.TemplateIndex == (int)Armor.Kite_Shield || item.TemplateIndex == (int)Armor.Round_Shield || item.TemplateIndex == (int)Armor.Tower_Shield || item.TemplateIndex == (int)Armor.Buckler)) { // If holding a 2H weapon then unequip DaggerfallUnityItem rightHandItem = equipTable[(int)EquipSlots.RightHand]; if (rightHandItem != null && GetItemHands(rightHandItem) == ItemHands.Both) { UnequipItem(EquipSlots.RightHand, unequippedList); } } // Unequip any previous item if (!IsSlotOpen(slot) && !alwaysEquip) { return(null); } else { UnequipItem(slot, unequippedList); } // Equip item to slot item.EquipSlot = slot; equipTable[(int)slot] = item; // Play equip sound if (playEquipSounds) { DaggerfallUI.Instance.PlayOneShot(item.GetEquipSound()); } // Allow entity effect manager to start any enchantments on this item StartEquippedItem(item); //Debug.Log(string.Format("Equipped {0} to {1}", item.LongName, slot.ToString())); return(unequippedList); }
int hueSlot(EquipSlots slotID) { return(_hueSlots[(int)slotID]); }
public Gear(String name, EquipSlots equipSlot, int id) : base(name, 1, id) { this.equipSlot = equipSlot; }
public void SetSlotHue(EquipSlots slot, int gumpID) { _hueSlots[(int)slot] = gumpID; }
public int this[EquipSlots slot] { set { m_equipmentSlots[(int)slot] = value; } get { return m_equipmentSlots[(int)slot]; } }
/// Allocate any equipment damage from a strike, and reduce item condition. private static bool DamageEquipment(DaggerfallEntity attacker, DaggerfallEntity target, int damage, DaggerfallUnityItem weapon, int struckBodyPart) { int atkStrength = attacker.Stats.LiveStrength; int tarMatMod = 0; int matDifference = 0; bool bluntWep = false; bool shtbladeWep = false; bool missileWep = false; int wepEqualize = 1; int wepWeight = 1; float wepDamResist = 1f; float armorDamResist = 1f; // If damage was done by a weapon, damage the weapon and armor of the hit body part. if (weapon != null && damage > 0) { int atkMatMod = weapon.GetWeaponMaterialModifier() + 2; int wepDam = damage; wepEqualize = EqualizeMaterialConditions(weapon); wepDam *= wepEqualize; if (weapon.GetWeaponSkillIDAsShort() == 32) // Checks if the weapon being used is in the Blunt Weapon category, then sets a bool value to true. { wepDam += (atkStrength / 10); wepDamResist = (wepEqualize * .20f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); bluntWep = true; wepWeight = (int)Mathf.Ceil(weapon.EffectiveUnitWeightInKg()); ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } else if (weapon.GetWeaponSkillIDAsShort() == 28) // Checks if the weapon being used is in the Short Blade category, then sets a bool value to true. { if (weapon.TemplateIndex == (int)Weapons.Dagger || weapon.TemplateIndex == (int)Weapons.Tanto) { wepDam += (atkStrength / 30); wepDamResist = (wepEqualize * .90f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); shtbladeWep = true; } else { wepDam += (atkStrength / 30); wepDamResist = (wepEqualize * .30f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); shtbladeWep = true; } ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } else if (weapon.GetWeaponSkillIDAsShort() == 33) // Checks if the weapon being used is in the Missile Weapon category, then sets a bool value to true. { missileWep = true; ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } else // If all other weapons categories have not been found, it defaults to this, which currently includes long blades and axes. { wepDam += (atkStrength / 10); wepDamResist = (wepEqualize * .20f) + 1; wepDam = (int)Mathf.Ceil(wepDam / wepDamResist); ApplyConditionDamageThroughWeaponDamage(weapon, attacker, wepDam, bluntWep, shtbladeWep, missileWep, wepEqualize); // Does condition damage to the attackers weapon. } if (attacker == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(weapon); } DaggerfallUnityItem shield = target.ItemEquipTable.GetItem(EquipSlots.LeftHand); // Checks if character is using a shield or not. bool shieldTakesDamage = false; if (shield != null) { BodyParts[] protectedBodyParts = shield.GetShieldProtectedBodyParts(); for (int i = 0; (i < protectedBodyParts.Length) && !shieldTakesDamage; i++) { if (protectedBodyParts[i] == (BodyParts)struckBodyPart) { shieldTakesDamage = true; } } } if (shieldTakesDamage) { int shieldEqualize = EqualizeMaterialConditions(shield); damage *= shieldEqualize; tarMatMod = ArmorMaterialModifierFinder(shield); matDifference = tarMatMod - atkMatMod; damage = MaterialDifferenceDamageCalculation(shield, matDifference, atkStrength, damage, bluntWep, wepWeight, shieldTakesDamage); ApplyConditionDamageThroughWeaponDamage(shield, target, damage, bluntWep, shtbladeWep, missileWep, wepEqualize); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(shield); } } else { EquipSlots hitSlot = DaggerfallUnityItem.GetEquipSlotForBodyPart((BodyParts)struckBodyPart); DaggerfallUnityItem armor = target.ItemEquipTable.GetItem(hitSlot); if (armor != null) { int armorEqualize = EqualizeMaterialConditions(armor); damage *= armorEqualize; tarMatMod = ArmorMaterialModifierFinder(armor); matDifference = tarMatMod - atkMatMod; damage = MaterialDifferenceDamageCalculation(armor, matDifference, atkStrength, damage, bluntWep, wepWeight, shieldTakesDamage); ApplyConditionDamageThroughWeaponDamage(armor, target, damage, bluntWep, shtbladeWep, missileWep, wepEqualize); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(armor); } } } return(false); } else if (weapon == null && damage > 0) // Handles Unarmed attacks. { DaggerfallUnityItem shield = target.ItemEquipTable.GetItem(EquipSlots.LeftHand); bool shieldTakesDamage = false; if (shield != null) { BodyParts[] protectedBodyParts = shield.GetShieldProtectedBodyParts(); for (int i = 0; (i < protectedBodyParts.Length) && !shieldTakesDamage; i++) { if (protectedBodyParts[i] == (BodyParts)struckBodyPart) { shieldTakesDamage = true; } } } if (shieldTakesDamage) { int shieldEqualize = EqualizeMaterialConditions(shield); damage *= shieldEqualize; tarMatMod = ArmorMaterialModifierFinder(shield); atkStrength /= 5; armorDamResist = (tarMatMod * .35f) + 1; damage = (int)Mathf.Ceil((damage + atkStrength) / armorDamResist); ApplyConditionDamageThroughUnarmedDamage(shield, target, damage); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(shield); } } else { EquipSlots hitSlot = DaggerfallUnityItem.GetEquipSlotForBodyPart((BodyParts)struckBodyPart); DaggerfallUnityItem armor = target.ItemEquipTable.GetItem(hitSlot); if (armor != null) { int armorEqualize = EqualizeMaterialConditions(armor); damage *= armorEqualize; tarMatMod = ArmorMaterialModifierFinder(armor); atkStrength /= 5; armorDamResist = (tarMatMod * .20f) + 1; damage = (int)Mathf.Ceil((damage + atkStrength) / armorDamResist); ApplyConditionDamageThroughUnarmedDamage(armor, target, damage); if (target == GameManager.Instance.PlayerEntity) { WarningMessagePlayerEquipmentCondition(armor); } } } return(false); } return(false); }
public override void Draw(SpriteBatchUI spriteBatch, Point position) { EquipSlots[] slotsToDraw = new EquipSlots[6] { EquipSlots.Body, EquipSlots.Footwear, EquipSlots.Legging, EquipSlots.Shirt, EquipSlots.Hair, EquipSlots.FacialHair }; for (int i = 0; i < slotsToDraw.Length; i++) { int bodyID = 0; int hue = hueSlot(slotsToDraw[i]); bool hueGreyPixelsOnly = true; switch (slotsToDraw[i]) { case EquipSlots.Body: if (m_isElf) bodyID = (m_isFemale ? 1893 : 1894); else bodyID = (m_isFemale ? 1888 : 1889); break; case EquipSlots.Footwear: bodyID = (m_isFemale ? 1891 : 1890); hue = 900; break; case EquipSlots.Legging: bodyID = (m_isFemale ? 1892 : 1848); hue = 348; break; case EquipSlots.Shirt: bodyID = (m_isFemale ? 1812 : 1849); hue = 792; break; case EquipSlots.Hair: if (equipmentSlot(EquipSlots.Hair) != 0) { bodyID = m_isFemale ? HairStyles.FemaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)) : HairStyles.MaleGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.Hair)); hueGreyPixelsOnly = false; } break; case EquipSlots.FacialHair: if (equipmentSlot(EquipSlots.FacialHair) != 0) { bodyID = m_isFemale ? 0 : HairStyles.FacialHairGumpIDForCharacterCreationFromItemID(equipmentSlot(EquipSlots.FacialHair)); hueGreyPixelsOnly = false; } break; } if (bodyID != 0) { // this is silly, we should be keeping a local copy of the body texture. IResourceProvider provider = ServiceRegistry.GetService<IResourceProvider>(); spriteBatch.Draw2D(provider.GetUITexture(bodyID), new Vector3(position.X, position.Y, 0), Utility.GetHueVector(hue, hueGreyPixelsOnly, false)); } } }
public void SetSlotEquipment(EquipSlots slot, int gumpID) { m_equipmentSlots[(int)slot] = gumpID; }
/// <summary> /// Returns first open slot or just first slot if both populated. /// This follows Daggerfall's behaviour for multi-slot items. /// </summary> public EquipSlots GetFirstSlot(EquipSlots slot1, EquipSlots slot2) { if (IsSlotOpen(slot1)) return slot1; else if (IsSlotOpen(slot2)) return slot2; else return slot1; }