public Gear removeWeapon(Gear newlyEquippedWeapon, bool canDuelEquip = true, int removedWeaponIndex = -1) { Gear removed = null; if (removedWeaponIndex != -1) { removed = equippedWeapons[removedWeaponIndex]; if (removed != null && removed.ItemType == ITypes.Offhand) { Offhand spellbook = (Offhand)equippedWeapons[1]; foreach (ElementAttributes e in spellbook.Element) { Hero.Element.Remove(e); } } equippedWeapons[removedWeaponIndex] = null; } else if (Hero.heroRole == Classes.Sentinel || Hero.heroRole == Classes.Juggernaut) { if (newlyEquippedWeapon.ItemType == ITypes.Armor) { removed = equippedWeapons[1]; equippedWeapons[1] = null; } else { removed = equippedWeapons[0]; equippedWeapons[0] = null; } } else if (!canDuelEquip) { removed = equippedWeapons[0]; equippedWeapons[0] = null; } else { if (equippedWeapons[0] != null && equippedWeapons[0].EquipableIn.Contains(Slots.Hand_Both)) { removed = equippedWeapons[0]; equippedWeapons[0] = null; } else if (newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Primary) && newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Auxillary)) { removed = equippedWeapons[1]; equippedWeapons[1] = null; } else if (newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Primary)) { removed = equippedWeapons[0]; equippedWeapons[0] = null; } else if (newlyEquippedWeapon.EquipableIn.Contains(Slots.Hand_Auxillary)) { removed = equippedWeapons[1]; if (removed != null && removed.ItemType == ITypes.Offhand) { Offhand spellbook = (Offhand)equippedWeapons[1]; foreach (ElementAttributes e in spellbook.Element) { Hero.Element.Remove(e); } } equippedWeapons[1] = null; } } if (removed != null) { if (Hero.heroRole == Classes.Sentinel || Hero.heroRole == Classes.Juggernaut) { slotsOpen = 2; } else if (!canDuelEquip) { slotsOpen += 2; } else { slotsOpen += (removed.EquipableIn.Contains(Slots.Hand_Both)) ? 2 : 1; } } return removed; }
public void equipWeapon(Gear weapon, Hero hero, bool duelEquip) { int handsTaken = (weapon.EquipableIn.Contains(Enums.Slots.Hand_Both)) ? 2 : 1; bool equipped = false; if (!duelEquip && Hero.heroRole != Classes.Sentinel && Hero.heroRole != Classes.Juggernaut) { if (equippedWeapons[0] == null) { equippedWeapons[0] = weapon; equipped = true; } } else if (Hero.heroRole == Classes.Sentinel || Hero.heroRole == Classes.Juggernaut) { if (weapon.ItemType == ITypes.Armor && equippedWeapons[1] == null) { equippedWeapons[1] = weapon; equipped = true; } else { equippedWeapons[0] = weapon; equipped = true; } } else { for (int i = 0; i < weapon.EquipableIn.Count && !equipped; i++) { switch (weapon.EquipableIn[i]) { case Slots.Hand_Both: if (equippedWeapons[0] == null && equippedWeapons[1] == null && slotsOpen == 2) { equippedWeapons[0] = weapon; equipped = true; } break; case Slots.Hand_Primary: if (equippedWeapons[0] == null && slotsOpen >= 1) { equippedWeapons[0] = weapon; equipped = true; } break; case Slots.Hand_Auxillary: if (equippedWeapons[1] == null && slotsOpen >= 1) { equippedWeapons[1] = weapon; if (weapon.ItemType == ITypes.Offhand) { Offhand spellbook = (Offhand)weapon; foreach (ElementAttributes e in spellbook.Element) { if (Hero.Element != null && !Hero.Element.Contains(e)) { Hero.Element.Add(e); } else if (Hero.Element == null) { Hero.Element.Add(e); } } } equipped = true; } break; } } } if (equipped) { if (!duelEquip) { slotsOpen -= 2; } else { slotsOpen -= (equipped) ? handsTaken : 0; } } }
public bool isWeaponEquipable(Gear weapon, Classes heroRole, int level) { bool result = false; string logInfo = "You can't equip this weapon"; if (weapon != null) { logInfo = "Your class cannot equip this item."; if (weapon.ItemType == ITypes.Weapon || weapon.ItemType == ITypes.Offhand || (heroRole == Classes.Sentinel || heroRole == Classes.Juggernaut)) { bool equipable = false; for (int i = 0; i < weapon.UsedBy.Count && !equipable; i++) { equipable = (weapon.UsedBy[i] == heroRole); } result = (equipable && weapon.LevelReq <= level); if (!result) { logInfo = "You aren't a high enough level to equip this weapon."; } } } if (!result) { Engine.Engine.Log(logInfo); } return result; }