/// <summary> /// Generates loot for Items and GOs. /// </summary> /// <param name="lootable">The Object or Unit that is being looted</param> /// <returns>The object's loot or null if there is nothing to get or the given Character can't access the loot.</returns> public static ObjectLoot CreateAndSendObjectLoot(ILootable lootable, Character initialLooter, LootEntryType type, bool heroic) { var oldLoot = initialLooter.LooterEntry.Loot; if (oldLoot != null) { oldLoot.ForceDispose(); } var looters = FindLooters(lootable, initialLooter); var loot = CreateLoot <ObjectLoot>(lootable, initialLooter, type, heroic, 0); // TODO: pass mapid if (loot != null) { initialLooter.LooterEntry.Loot = loot; loot.Initialize(initialLooter, looters, 0); // TODO: pass mapid LootHandler.SendLootResponse(initialLooter, loot); } else { //lootable.OnFinishedLooting(); // empty Item -> Don't do anything } return(loot); }
/// <summary> /// Creates a new Loot object and returns it or null, if there is nothing to be looted. /// </summary> /// <typeparam name="T"><see cref="ObjectLoot"/> or <see cref="NPCLoot"/></typeparam> /// <param name="lootable"></param> /// <param name="initialLooter"></param> /// <param name="type"></param> /// <returns></returns> public static T CreateLoot <T>(ILootable lootable, Character initialLooter, LootEntryType type, bool heroic, MapId mapid) where T : Loot, new() { var looters = FindLooters(lootable, initialLooter); var items = CreateLootItems(lootable.GetLootId(type), type, heroic, looters); var money = lootable.LootMoney * DefaultMoneyDropFactor; if (items.Length == 0 && money == 0) { if (lootable is GameObject) { // TODO: Don't mark GO as lootable if it has nothing to loot money = 1; } } if (items.Length > 0 || money > 0) { var loot = new T { Lootable = lootable, Money = money, Items = items }; loot.Initialize(initialLooter, looters, mapid); return(loot); } else { //var loot = new T { Lootable = lootable, Money = 1, Items = LootItem.EmptyArray }; //loot.Initialize(initialLooter, looters); //return loot; return(null); } }
public static ResolvedLootItemList GetEntries(LootEntryType type, uint id) { var entries = LootEntries[(uint)type]; var list = entries.Get(id); return(list); }
public override uint GetLootId(LootEntryType type) { if (m_entry is IGOLootableEntry) { return(((IGOLootableEntry)m_entry).LootId); } return(0); }
/// <summary> /// Returns all Items that can be looted off the given lootable /// </summary> public static LootItem[] CreateLootItems(uint lootId, LootEntryType type, bool heroic, IList <LooterEntry> looters) { #if DEBUG if (!ItemMgr.Loaded) { return(LootItem.EmptyArray); } #endif var entries = GetEntries(type, lootId); if (entries == null) { return(LootItem.EmptyArray); } var items = new LootItem[Math.Min(MaxLootCount, entries.Count)]; //var i = max; var i = 0; foreach (var entry in entries) { var chance = entry.DropChance * LootItemDropFactor; if ((100 * Utility.RandomFloat()) >= chance) { continue; } var template = entry.ItemTemplate; if (template == null) { // weird continue; } if (!looters.Any(looter => template.CheckLootConstraints(looter.Owner))) { continue; } items[i] = new LootItem(template, Utility.Random(entry.MinAmount, entry.MaxAmount), (uint)i, template.RandomPropertiesId); i++; if (i == MaxLootCount) { break; } } if (i == 0) { return(LootItem.EmptyArray); } Array.Resize(ref items, i); return(items); }
/// <summary>Generates loot for Items and GOs.</summary> /// <param name="lootable">The Object or Unit that is being looted</param> /// <returns>The object's loot or null if there is nothing to get or the given Character can't access the loot.</returns> public static ObjectLoot CreateAndSendObjectLoot(ILootable lootable, Character initialLooter, LootEntryType type, bool heroic) { Asda2Loot loot = initialLooter.LooterEntry.Loot; if (loot != null) { loot.ForceDispose(); } LootMgr.FindLooters(lootable, initialLooter); return(LootMgr.CreateLoot <ObjectLoot>(lootable, initialLooter, type, heroic, MapId.Silaris)); }
protected static void AddItems <T>(LootEntryType t, List <T> all) where T : LootItemEntry { foreach (ResolvedLootItemList entry in LootMgr.GetEntries(t)) { if (entry != null) { foreach (LootEntity lootEntity in (List <LootEntity>)entry) { all.Add((T)lootEntity); } } } }
public override uint GetLootId(LootEntryType lootType) { switch (lootType) { case LootEntryType.NPCCorpse: return(m_entry.LootId); case LootEntryType.Skinning: return(m_entry.SkinLootId); case LootEntryType.PickPocketing: return(m_entry.PickPocketLootId); } return(0); }
protected static void AddItems <T>(LootEntryType t, List <T> all) where T : LootItemEntry { var entries = LootMgr.GetEntries(t); foreach (var list in entries) { if (list != null) { foreach (var entry in list) { all.Add((T)entry); } } } }
/// <summary> /// Returns all Items that can be looted off the given lootable /// </summary> public static LootItem[] CreateLootItems(uint lootId, LootEntryType type, bool heroic, IList <LooterEntry> looters) { ResolvedLootItemList entries = LootMgr.GetEntries(type, lootId); if (entries == null) { return(LootItem.EmptyArray); } LootItem[] array = new LootItem[Math.Min(15, entries.Count)]; int newSize = 0; foreach (LootEntity lootEntity in (List <LootEntity>)entries) { if (100.0 * (double)Utility.RandomFloat() < (double)lootEntity.DropChance) { ItemTemplate template = lootEntity.ItemTemplate; if (template != null && looters.Any <LooterEntry>((Func <LooterEntry, bool>)(looter => template.CheckLootConstraints(looter.Owner)))) { array[newSize] = new LootItem(template, Utility.Random(lootEntity.MinAmount, lootEntity.MaxAmount), (uint)newSize, template.RandomPropertiesId); ++newSize; if (newSize == 15) { break; } } } } if (newSize == 0) { return(LootItem.EmptyArray); } Array.Resize <LootItem>(ref array, newSize); return(array); }
public static ResolvedLootItemList[] GetEntries(LootEntryType type) { return(LootMgr.LootEntries[(uint)type]); }
/// <summary> /// Whether the given lootable contains quest items for the given Character when looting with the given type /// </summary> public static bool ContainsQuestItemsFor(this ILootable lootable, Character chr, LootEntryType type) { Asda2Loot loot = lootable.Loot; if (loot != null) { return(((IEnumerable <Asda2LootItem>)loot.Items).Any <Asda2LootItem>((Func <Asda2LootItem, bool>)(item => { if (item.Template.HasQuestRequirements) { return item.Template.CheckQuestConstraints(chr); } return false; }))); } ResolvedLootItemList entries = lootable.GetEntries(type); if (entries != null) { return(entries.Any <LootEntity>((Func <LootEntity, bool>)(entry => { if (entry.ItemTemplate.HasQuestRequirements) { return entry.ItemTemplate.CheckQuestConstraints(chr); } return false; }))); } return(false); }
public static ResolvedLootItemList GetEntries(this ILootable lootable, LootEntryType type) { return((ResolvedLootItemList)null); }
/// <summary> /// Generates normal loot (usually for dead mob-corpses). /// Returns null, if the loot is empty. /// </summary> /// <param name="lootable">The Object or Unit that is being looted</param> public static Loot GetOrCreateLoot(ILootable lootable, Character triggerChar, LootEntryType type, bool heroic) { var loot = lootable.Loot; if (loot != null) { // apparently mob got killed a 2nd time if (loot.IsMoneyLooted && loot.RemainingCount == 0) { // already looted empty return(null); } loot.Looters.Clear(); } else { lootable.Loot = loot = CreateLoot <NPCLoot>(lootable, triggerChar, type, heroic, 0); // TODO: pass mapid } return(loot); }
/// <summary> /// Generates normal loot (usually for dead mob-corpses). /// Returns null, if the loot is empty. /// </summary> /// <param name="lootable">The Object or Unit that is being looted</param> public static Loot GetOrCreateLoot(ILootable lootable, Character triggerChar, LootEntryType type, bool heroic) { return((Loot)null); }
/// <summary> /// Creates a new Loot object and returns it or null, if there is nothing to be looted. /// </summary> /// <typeparam name="T"><see cref="T:WCell.RealmServer.Looting.ObjectLoot" /> or <see cref="T:WCell.RealmServer.Looting.NPCLoot" /></typeparam> /// <param name="lootable"></param> /// <param name="initialLooter"></param> /// <param name="type"></param> /// <returns></returns> public static T CreateLoot <T>(ILootable lootable, Character initialLooter, LootEntryType type, bool heroic, MapId mapid) where T : Loot, new() { return(default(T)); }
public static ResolvedLootItemList GetEntries(this ILootable lootable, LootEntryType type) { return(GetEntries(type, lootable.GetLootId(type))); }
public override uint GetLootId(LootEntryType lootType) { switch (lootType) { case LootEntryType.NPCCorpse: return m_entry.LootId; case LootEntryType.Skinning: return m_entry.SkinLootId; case LootEntryType.PickPocketing: return m_entry.PickPocketLootId; } return 0; }
/// <summary> /// Whether the given lootable contains quest items for the given Character when looting with the given type /// </summary> public static bool ContainsQuestItemsFor(this ILootable lootable, Character chr, LootEntryType type) { var loot = lootable.Loot; if (loot != null) { // loot has already been created return(loot.Items.Any(item => item.Template.HasQuestRequirements && item.Template.CheckQuestConstraints(chr))); } // no loot yet -> check what happens if we create any var entries = lootable.GetEntries(type); if (entries != null) { return(entries.Any(entry => entry.ItemTemplate.HasQuestRequirements && entry.ItemTemplate.CheckQuestConstraints(chr))); } return(false); }
public override uint GetLootId(LootEntryType type) { return(m_template.Id); }
public override uint GetLootId(LootEntryType type) { if (m_entry is IGOLootableEntry) { return ((IGOLootableEntry)m_entry).LootId; } return 0; }
public static ResolvedLootItemList GetEntries(LootEntryType type, uint id) { return(LootMgr.LootEntries[(uint)type].Get <ResolvedLootItemList>(id)); }
public virtual uint GetLootId(LootEntryType type) { return 0; }
public virtual uint GetLootId(LootEntryType type) { return(0); }