private static void GetPlacementLocation(WorldObject item, EquipMask wieldedLocation, out Placement placement, out ParentLocation parentLocation) { switch (wieldedLocation) { case EquipMask.MeleeWeapon: case EquipMask.Held: case EquipMask.TwoHanded: placement = ACE.Entity.Enum.Placement.RightHandCombat; parentLocation = ACE.Entity.Enum.ParentLocation.RightHand; break; case EquipMask.Shield: if (item.ItemType == ItemType.Armor) { placement = ACE.Entity.Enum.Placement.Shield; parentLocation = ACE.Entity.Enum.ParentLocation.Shield; } else { placement = ACE.Entity.Enum.Placement.RightHandNonCombat; parentLocation = ACE.Entity.Enum.ParentLocation.LeftWeapon; } break; case EquipMask.MissileWeapon: if (item.DefaultCombatStyle == CombatStyle.Bow || item.DefaultCombatStyle == CombatStyle.Crossbow) { placement = ACE.Entity.Enum.Placement.LeftHand; parentLocation = ACE.Entity.Enum.ParentLocation.LeftHand; } else { placement = ACE.Entity.Enum.Placement.RightHandCombat; parentLocation = ACE.Entity.Enum.ParentLocation.RightHand; } break; default: placement = ACE.Entity.Enum.Placement.Default; parentLocation = ACE.Entity.Enum.ParentLocation.None; break; } }
public void Push(LeanMyWorldObject item, EquipMask slot) { slotCache[nextOpenCacheIndex].Piece = item; slotCache[nextOpenCacheIndex].Slot = slot; //slotCache[nextOpenCacheIndex].SpellCount = item.SpellsToUseInSearch.Count; // Used for the old search compare method occupiedSlots |= slot; // Used for the old search compare method /*for (int i = 0; i < item.SpellsToUseInSearch.Count; i++) * { * spells[nextOpenSpellIndex] = item.SpellsToUseInSearch[i]; * nextOpenSpellIndex++; * }*/ if (nextOpenCacheIndex == 0) { spellBitmaps[nextOpenCacheIndex] = item.SpellBitmap; } else { spellBitmaps[nextOpenCacheIndex] = spellBitmaps[nextOpenCacheIndex - 1] | item.SpellBitmap; } nextOpenCacheIndex++; if (item.ItemSetId != -1) { armorSetCountById[item.ItemSetId]++; } if (item.CalcedStartingArmorLevel > 0) { TotalBaseArmorLevel += (item.CalcedStartingArmorLevel * slot.GetTotalBitsSet()); } if (slot.IsBodyArmor()) { TotalBodyArmorPieces++; } }
public void Pop() { occupiedSlots ^= slotCache[nextOpenCacheIndex - 1].Slot; //nextOpenSpellIndex -= slotCache[nextOpenCacheIndex - 1].SpellCount; // Used for the old search compare method armorSetCountById[slotCache[nextOpenCacheIndex - 1].Piece.ItemSetId]--; if (slotCache[nextOpenCacheIndex - 1].Piece.CalcedStartingArmorLevel > 0) { TotalBaseArmorLevel -= (slotCache[nextOpenCacheIndex - 1].Piece.CalcedStartingArmorLevel * slotCache[nextOpenCacheIndex - 1].Slot.GetTotalBitsSet()); } if (slotCache[nextOpenCacheIndex - 1].Slot.IsBodyArmor()) { TotalBodyArmorPieces--; } nextOpenCacheIndex--; }
/// <summary> /// This will set the CurrentWieldedLocation property to wieldedLocation and the Wielder property to this guid and will add it to the EquippedObjects dictionary.<para /> /// It will also increase the EncumbranceVal and Value. /// </summary> protected bool TryEquipObjectWithBroadcasting(WorldObject worldObject, EquipMask wieldedLocation) { if (!TryEquipObject(worldObject, wieldedLocation)) { return(false); } /*if (IsInChildLocation(worldObject)) // Is this equipped item visible to others? * EnqueueBroadcast(false, new GameMessageSound(Guid, Sound.WieldObject)); * * if (worldObject.ParentLocation != null) * EnqueueBroadcast(new GameMessageParentEvent(this, worldObject)); * * EnqueueBroadcast(new GameMessageObjDescEvent(this)); * * // Notify viewers in the area that we've equipped the item * EnqueueActionBroadcast(p => p.TrackEquippedObject(this, worldObject));*/ return(true); }
/// <summary> /// This will set the CurrentWieldedLocation property to wieldedLocation and the Wielder property to this guid and will add it to the EquippedObjects dictionary.<para /> /// It will also increase the EncumbranceVal and Value. /// </summary> public bool TryEquipObject(WorldObject worldObject, EquipMask wieldedLocation) { // todo: verify wielded location is valid location if (!WieldedLocationIsAvailable(worldObject, wieldedLocation)) { return(false); } worldObject.CurrentWieldedLocation = wieldedLocation; worldObject.WielderId = Biota.Id; EquippedObjects[worldObject.Guid] = worldObject; EncumbranceVal += (worldObject.EncumbranceVal ?? 0); Value += (worldObject.Value ?? 0); TrySetChild(worldObject); worldObject.EmoteManager.OnWield(this); return(true); }
/// <summary> /// Called by non-player creatures to unwield an item, /// removing any spells casted by the item /// </summary> public bool TryUnwieldObjectWithBroadcasting(ObjectGuid objectGuid, out WorldObject worldObject, out EquipMask wieldedLocation, bool droppingToLandscape = false) { if (!TryDequipObjectWithBroadcasting(objectGuid, out worldObject, out wieldedLocation, droppingToLandscape)) { return(false); } // remove item spells foreach (var spell in worldObject.Biota.GetKnownSpellsIds(BiotaDatabaseLock)) { RemoveItemSpell(worldObject, (uint)spell, true); } return(true); }
public static void HandleDebugEchoFlags(Session session, params string[] parameters) { try { if (parameters?.Length == 2) { var debugOutput = ""; switch (parameters[0].ToLower()) { case "descriptionflags": ObjectDescriptionFlag objectDescFlag = new ObjectDescriptionFlag(); objectDescFlag = (ObjectDescriptionFlag)Convert.ToUInt32(parameters[1]); debugOutput = $"{objectDescFlag.GetType().Name} = {objectDescFlag.ToString()}" + " (" + (uint)objectDescFlag + ")"; break; case "weenieflags": WeenieHeaderFlag weenieHdr = new WeenieHeaderFlag(); weenieHdr = (WeenieHeaderFlag)Convert.ToUInt32(parameters[1]); debugOutput = $"{weenieHdr.GetType().Name} = {weenieHdr.ToString()}" + " (" + (uint)weenieHdr + ")"; break; case "weenieflags2": WeenieHeaderFlag2 weenieHdr2 = new WeenieHeaderFlag2(); weenieHdr2 = (WeenieHeaderFlag2)Convert.ToUInt32(parameters[1]); debugOutput = $"{weenieHdr2.GetType().Name} = {weenieHdr2.ToString()}" + " (" + (uint)weenieHdr2 + ")"; break; case "positionflag": UpdatePositionFlag posFlag = new UpdatePositionFlag(); posFlag = (UpdatePositionFlag)Convert.ToUInt32(parameters[1]); debugOutput = $"{posFlag.GetType().Name} = {posFlag.ToString()}" + " (" + (uint)posFlag + ")"; break; case "type": ItemType objectType = new ItemType(); objectType = (ItemType)Convert.ToUInt32(parameters[1]); debugOutput = $"{objectType.GetType().Name} = {objectType.ToString()}" + " (" + (uint)objectType + ")"; break; case "containertype": ContainerType contType = new ContainerType(); contType = (ContainerType)Convert.ToUInt32(parameters[1]); debugOutput = $"{contType.GetType().Name} = {contType.ToString()}" + " (" + (uint)contType + ")"; break; case "usable": Usable usableType = new Usable(); usableType = (Usable)Convert.ToInt64(parameters[1]); debugOutput = $"{usableType.GetType().Name} = {usableType.ToString()}" + " (" + (Int64)usableType + ")"; break; case "radarbehavior": RadarBehavior radarBeh = new RadarBehavior(); radarBeh = (RadarBehavior)Convert.ToUInt32(parameters[1]); debugOutput = $"{radarBeh.GetType().Name} = {radarBeh.ToString()}" + " (" + (uint)radarBeh + ")"; break; case "physicsdescriptionflags": PhysicsDescriptionFlag physicsDescFlag = new PhysicsDescriptionFlag(); physicsDescFlag = (PhysicsDescriptionFlag)Convert.ToUInt32(parameters[1]); debugOutput = $"{physicsDescFlag.GetType().Name} = {physicsDescFlag.ToString()}" + " (" + (uint)physicsDescFlag + ")"; break; case "physicsstate": PhysicsState physState = new PhysicsState(); physState = (PhysicsState)Convert.ToUInt32(parameters[1]); debugOutput = $"{physState.GetType().Name} = {physState.ToString()}" + " (" + (uint)physState + ")"; break; case "validlocations": EquipMask locFlags = new EquipMask(); locFlags = (EquipMask)Convert.ToUInt32(parameters[1]); debugOutput = $"{locFlags.GetType().Name} = {locFlags.ToString()}" + " (" + (uint)locFlags + ")"; break; case "currentwieldedlocation": EquipMask locFlags2 = new EquipMask(); locFlags2 = (EquipMask)Convert.ToUInt32(parameters[1]); debugOutput = $"{locFlags2.GetType().Name} = {locFlags2.ToString()}" + " (" + (uint)locFlags2 + ")"; break; case "priority": CoverageMask covMask = new CoverageMask(); covMask = (CoverageMask)Convert.ToUInt32(parameters[1]); debugOutput = $"{covMask.GetType().Name} = {covMask.ToString()}" + " (" + (uint)covMask + ")"; break; case "radarcolor": RadarColor radarBlipColor = new RadarColor(); radarBlipColor = (RadarColor)Convert.ToUInt32(parameters[1]); debugOutput = $"{radarBlipColor.GetType().Name} = {radarBlipColor.ToString()}" + " (" + (uint)radarBlipColor + ")"; break; default: debugOutput = "No valid type to test"; break; } if (session == null) { Console.WriteLine(debugOutput.Replace(", ", " | ")); } else { session.Network.EnqueueSend(new GameMessageSystemChat(debugOutput, ChatMessageType.System)); } } } catch (Exception) { string debugOutput = "Exception Error, check input and try again"; if (session == null) { Console.WriteLine(debugOutput.Replace(", ", " | ")); } else { session.Network.EnqueueSend(new GameMessageSystemChat(debugOutput, ChatMessageType.System)); } } }
/// <summary> /// This will remove the Wielder and CurrentWieldedLocation properties on the item and will remove it from the EquippedObjects dictionary.<para /> /// It does not add it to inventory as you could be unwielding to the ground or a chest.<para /> /// It will also decrease the EncumbranceVal and Value. /// </summary> public bool TryDequipObject(ObjectGuid objectGuid, out WorldObject worldObject, out EquipMask wieldedLocation) { if (!EquippedObjects.Remove(objectGuid, out worldObject)) { wieldedLocation = 0; return(false); } RemoveItemFromEquippedItemsRatingCache(worldObject); wieldedLocation = worldObject.CurrentWieldedLocation ?? EquipMask.None; worldObject.RemoveProperty(PropertyInt.CurrentWieldedLocation); worldObject.RemoveProperty(PropertyInstanceId.Wielder); worldObject.Wielder = null; worldObject.IsAffecting = false; EncumbranceVal -= (worldObject.EncumbranceVal ?? 0); Value -= (worldObject.Value ?? 0); ClearChild(worldObject); var wo = worldObject; Children.Remove(Children.Find(s => s.Guid == wo.Guid.Full)); worldObject.OnUnWield(this); return(true); }
private void btnCalculatePossibilities_Click(object sender, System.EventArgs e) { if (filtersControl1.CantripsToLookFor.Count == 0) { if (MessageBox.Show("You have no spells selected. Your search results won't be very useful. Would you like to go ahead anyway?" + Environment.NewLine + Environment.NewLine + "To select spells, load defsults or click the spells you want on the bottom of the filters group on Tab labeled 'Step 1. Add Inventory'", "No Spells Selected", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.No) { return; } } btnCalculatePossibilities.Enabled = false; treeView1.Nodes.Clear(); PopulateFromEquipmentGroup(null); if (armorSearcher != null) { armorSearcher.SuitCreated -= new Action <CompletedSuit>(armorSearcher_SuitCreated); armorSearcher.SearchCompleted -= new Action(ThreadFinished); } accessorySearchers.Clear(); abortedSearch = false; SearcherConfiguration config = new SearcherConfiguration(); config.CantripsToLookFor = filtersControl1.CantripsToLookFor; config.PrimaryArmorSet = filtersControl1.PrimaryArmorSetId; config.SecondaryArmorSet = filtersControl1.SecondaryArmorSetId; // Build the list of items we're going to use in our search searchItems = new List <LeanMyWorldObject>(); // Only add items that meet our minimum requirements foreach (var piece in boundList) { if (piece.Locked || (!piece.Exclude && config.ItemPassesRules(piece))) { searchItems.Add(new LeanMyWorldObject(piece)); } } var possibleSpells = new List <Spell>(); // Go through our Equipment and remove/disable any extra spells that we're not looking for foreach (var piece in searchItems) { piece.SpellsToUseInSearch.Clear(); foreach (Spell spell in piece.ExtendedMyWorldObject.CachedSpells) { if (config.SpellPassesRules(spell) && !spell.IsOfSameFamilyAndGroup(SpellTools.GetSpell(4667))) // Epic Impenetrability { piece.SpellsToUseInSearch.Add(spell); if (!possibleSpells.Contains(spell)) { possibleSpells.Add(spell); } } } } // Go through our possible spells and make sure they are all unique. This will also keep the lowest level spell that passed our rules for (int i = possibleSpells.Count - 1; i >= 0; i--) { for (int j = 0; j < i; j++) { if (possibleSpells[j].IsOfSameFamilyAndGroup(possibleSpells[i])) { if (possibleSpells[j].Surpasses(possibleSpells[i])) { possibleSpells.RemoveAt(j); } else { possibleSpells.RemoveAt(j); } goto next; } } next :; } // Now, we create our bitmapped spell map if (possibleSpells.Count > 32) { MessageBox.Show("Too many spells."); btnCalculatePossibilities.Enabled = true; return; } Dictionary <Spell, int> spellMap = new Dictionary <Spell, int>(); for (int i = 0; i < possibleSpells.Count; i++) { spellMap.Add(possibleSpells[i], 1 << i); } // Now, we update each item with the new spell map foreach (var piece in searchItems) { piece.SpellBitmap = 0; foreach (var spell in piece.SpellsToUseInSearch) { foreach (var kvp in spellMap) { if (spell.IsOfSameFamilyAndGroup(kvp.Key)) { piece.SpellBitmap |= kvp.Value; } } } } // Build our base suit from locked in pieces CompletedSuit baseSuit = new CompletedSuit(); // Add locked pieces in order of slots covered, starting with the fewest for (int slotCount = 1; slotCount <= 5; slotCount++) { foreach (var item in searchItems) { // Don't add items that we don't care about if (item.EquippableSlots == EquipMask.None || item.EquippableSlots == EquipMask.MeleeWeapon || item.EquippableSlots == EquipMask.MissileWeapon || item.EquippableSlots == EquipMask.TwoHanded || item.EquippableSlots == EquipMask.Held || item.EquippableSlots == EquipMask.MissileAmmo) { continue; } if (item.EquippableSlots == EquipMask.Cloak || item.EquippableSlots == EquipMask.SigilOne || item.EquippableSlots == EquipMask.SigilTwo || item.EquippableSlots == EquipMask.SigilThree) { continue; } if (item.ExtendedMyWorldObject.Locked && item.EquippableSlots.GetTotalBitsSet() == slotCount) { try { if (item.EquippableSlots.GetTotalBitsSet() > 1 && item.EquippableSlots.IsBodyArmor() && MessageBox.Show(item.ExtendedMyWorldObject.Name + " covers multiple slots. Would you like to reduce it?", "Add Item", MessageBoxButtons.YesNo) == DialogResult.Yes) { var reductionOptions = item.Coverage.ReductionOptions(); EquipMask slotFlag = EquipMask.None; foreach (var option in reductionOptions) { if (option == CoverageMask.OuterwearChest && baseSuit[EquipMask.ChestArmor] == null) { slotFlag = EquipMask.ChestArmor; break; } if (option == CoverageMask.OuterwearUpperArms && baseSuit[EquipMask.UpperArmArmor] == null) { slotFlag = EquipMask.UpperArmArmor; break; } if (option == CoverageMask.OuterwearLowerArms && baseSuit[EquipMask.LowerArmArmor] == null) { slotFlag = EquipMask.LowerArmArmor; break; } if (option == CoverageMask.OuterwearAbdomen && baseSuit[EquipMask.AbdomenArmor] == null) { slotFlag = EquipMask.AbdomenArmor; break; } if (option == CoverageMask.OuterwearUpperLegs && baseSuit[EquipMask.UpperLegArmor] == null) { slotFlag = EquipMask.UpperLegArmor; break; } if (option == CoverageMask.OuterwearLowerLegs && baseSuit[EquipMask.LowerLegArmor] == null) { slotFlag = EquipMask.LowerLegArmor; break; } if (option == CoverageMask.Feet && baseSuit[EquipMask.FootWear] == null) { slotFlag = EquipMask.FootWear; break; } } if (slotFlag == EquipMask.None) { MessageBox.Show("Unable to reduce " + item + " into an open single slot." + Environment.NewLine + "Reduction coverage option not expected or not open."); } else { baseSuit.AddItem(slotFlag, item); } } else if (!baseSuit.AddItem(item)) { MessageBox.Show("Failed to add " + item.ExtendedMyWorldObject.Name + " to base suit of armor."); } } catch (ArgumentException) // Item failed to add { MessageBox.Show("Failed to add " + item.ExtendedMyWorldObject.Name + " to base suit of armor. It overlaps another piece"); } } } } if (baseSuit.Count > 0) { AddCompletedSuitToTreeView(baseSuit); } armorSearcher = new ArmorSearcher(config, searchItems, baseSuit); armorSearcherHighestItemCount = 0; armorSearcher.SuitCreated += new Action <CompletedSuit>(armorSearcher_SuitCreated); armorSearcher.SearchCompleted += new Action(ThreadFinished); startTime = DateTime.Now; armorThreadCounter = 1; accessoryThreadQueueCounter = 0; accessoryThreadRunningCounter = 0; timerCalculatorUpdator.Start(); new Thread(() => { // Do the actual search here armorSearcher.Start(); Interlocked.Decrement(ref armorThreadCounter); ThreadFinished(); }).Start(); btnStopCalculating.Enabled = true; progressBar1.Style = ProgressBarStyle.Marquee; }
public Bucket(EquipMask slot) { Slot = slot; }
public override void Unpack(BinaryReader reader) { base.Unpack(reader); ItemID = reader.ReadUInt32(); Slot = (EquipMask)reader.ReadUInt32(); }
public void AddEquipedItem(uint index, EquipMask equiperflag) { EquippedItem newitem = new EquippedItem(index, equiperflag); children.Add(newitem); }
public GameEventWieldItem(Session session, uint objectId, EquipMask newLocation) : base(GameEventType.WieldObject, GameMessageGroup.UIQueue, session) { Writer.Write(objectId); Writer.Write((int)newLocation); }
public static bool IsExtremityBodyArmor(this EquipMask value) { return((value & (EquipMask.FootWear | EquipMask.HandWear | EquipMask.HeadWear)) != 0); }
/// <summary> /// This will remove the Wielder and CurrentWieldedLocation properties on the item and will remove it from the EquippedObjects dictionary.<para /> /// It does not add it to inventory as you could be unwielding to the ground or a chest.<para /> /// It will also decrease the EncumbranceVal and Value. /// </summary> protected bool TryDequipObjectWithBroadcasting(ObjectGuid objectGuid, out WorldObject worldObject, out EquipMask wieldedLocation, bool droppingToLandscape = false) { if (!TryDequipObject(objectGuid, out worldObject, out wieldedLocation)) { return(false); } if ((wieldedLocation & EquipMask.Selectable) != 0) // Is this equipped item visible to others? { EnqueueBroadcast(false, new GameMessageSound(Guid, Sound.UnwieldObject)); } EnqueueBroadcast(new GameMessageObjDescEvent(this)); // If item has any spells, remove them from the registry on unequip if (worldObject.Biota.PropertiesSpellBook != null) { foreach (var spell in worldObject.Biota.PropertiesSpellBook) { if (worldObject.HasProcSpell((uint)spell.Key)) { continue; } RemoveItemSpell(worldObject, (uint)spell.Key, true); } } if (!droppingToLandscape) { // This should only be called if the object is going to the private storage, not when dropped on the landscape var wo = worldObject; EnqueueActionBroadcast(p => p.RemoveTrackedEquippedObject(this, wo)); } return(true); }
public static bool IsShirt(this EquipMask value) { return(((int)value & 0x0000001A) != 0); }
// Some feet armor have EquipMask.Feet | EquipMask.PantsLowerLegs public static bool IsBodyArmor(this EquipMask value) { return(((int)value & 0x00007F21) != 0); }
public bool SlotIsOpen(EquipMask slot) { return((occupiedSlots & slot) == 0); }
public static bool IsCoreBodyArmor(this EquipMask value) { return((value & (EquipMask.ChestArmor | EquipMask.UpperArmArmor | EquipMask.LowerArmArmor | EquipMask.AbdomenArmor | EquipMask.UpperLegArmor | EquipMask.LowerLegArmor)) != 0); }
public static List <EquipMask> GetFlags(EquipMask locations) { return(Enum.GetValues(typeof(EquipMask)).Cast <EquipMask>().Where(p => p != EquipMask.None && locations.HasFlag(p)).ToList()); }
public static bool PutItemInBuckets(this ICollection <Bucket> value, LeanMyWorldObject piece, EquipMask slot) { bool foundBucket = false; foreach (Bucket bucket in value) { if ((slot & bucket.Slot) == bucket.Slot) { foundBucket = true; bucket.Add(piece); } } return(foundBucket); }
public HeldItem(uint guid, uint locationId, EquipMask equipmask) { Guid = guid; EquipMask = equipmask; LocationId = locationId; }
public EquippedItem(uint guid, EquipMask equipmask) { Guid = guid; EquipMask = equipmask; }