public override void Update() { Ped player = Game.Player.Character; NearestPed = World.GetNearbyPeds(player, 3).FirstOrDefault(); NearbyLoot = PlayerMethods.GetNearbyLoot(2.5f).FirstOrDefault(); IsWideScreen = Function.Call<bool>(Hash.GET_IS_WIDESCREEN); Wait(400); }
public static void SendStartRoll(Loot loot, LootItem item, IEnumerable <LooterEntry> looters, MapId mapid) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_START_ROLL)) { packet.Write(loot.Lootable.EntityId); packet.WriteUInt((uint)mapid); // TODO: actually use this packet.Write(item.Index); packet.Write(item.Template.Id); packet.Write(item.Template.RandomSuffixFactor); packet.Write((int)(item.Template.RandomSuffixFactor > 0 ? -item.Template.RandomSuffixId : item.Template.RandomPropertiesId)); //packet.Write(LootMgr.DefaultLootRollTimeout); packet.Write((byte)0x0F); // since 3.3: loot roll mask foreach (var looter in looters) { if (looter.Owner != null) { looter.Owner.Client.Send(packet, addEnd: false); } } } }
public static void SendRoll(Character looter, Loot loot, LootItem item, int rollNumber, LootRollType rollType) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_ROLL)) { packet.Write(loot.Lootable.EntityId); packet.Write(item.Index); packet.Write(looter.EntityId); packet.Write(item.Template.Id); packet.Write(item.Template.RandomSuffixFactor); packet.Write(item.Template.RandomSuffixFactor > 0U ? (int)-item.Template.RandomSuffixId : (int)item.Template.RandomPropertiesId); packet.Write(rollNumber); packet.Write((byte)rollType); foreach (LooterEntry looter1 in loot.Looters) { if (looter1.Owner != null) { looter1.Owner.Client.Send(packet, false); } } } }
public static void ItemsList() { try { Cons.Main.tItems = new List <LootItem>(); List <LootItem> .Enumerator temporalItemsEnum = Cons.Main._GameWorld.LootItems.GetValuesEnumerator().GetEnumerator(); while (temporalItemsEnum.MoveNext()) { LootItem temp = temporalItemsEnum.Current; if (temp.GetType() == Types.LootItem || temp.GetType() == Types.ObservedLootItem) { if (Cons.LootSearcher == "") { Cons.Main.tItems.Add(temp); } try { if (temp.Item.ShortName.Localized().ToLower().IndexOf(Cons.LootSearcher) >= 0) { Cons.Main.tItems.Add(temp); } } catch (Exception e) { ErrorHandler.Catch("LootItem_Translate_SearcherIndexOf", e); } } } Cons.Main._lootItems = Cons.Main.tItems; temporalItemsEnum.Dispose(); } catch (Exception e) { ErrorHandler.Catch("Get_LootItems", e); } }
public static void Loot(LootItem loot) { if (loot != null) { if (loot.Item.Type == ItemType.Money) { var notification = Notification.Loot("Looted GTA$" + loot.Item.MoneyValue.ToString("N0")); notification.Tracking = loot.Item.MoneyValue; RPG.Notify(notification); PlayerData.AddMoney(loot.Item.MoneyValue); loot.Destroy(); Game.PlaySound("FocusOut", "HintCamSounds"); } else { RPG.Notify(Notification.Loot("Looted: " + loot.Name + " x" + loot.Item.Quantity)); PlayerData.AddItem(loot.Item); loot.Destroy(); Game.PlaySound("FocusOut", "HintCamSounds"); } } RPGInfo.NearbyLoot = null; }
public static Color GetItemColor(LootItem itm) { if (!Settings.CItem.DisplayLootSrare && !Settings.CItem.DisplayLootCustom1 && !Settings.CItem.DisplayLootCustom2 && !Settings.CItem.DisplayLootCustom3) { // nothing is enabled to color staff so return basic color return(Settings.CItem.DrawBaseColor); } if (Settings.CItem.DisplayLootSrare && itm.Item.Template.Rarity == JsonType.ELootRarity.Superrare) { // enabled super rare and item is super rare return(Settings.CItem.DrawSRare); } if (Settings.CItem.DisplayLootCustom1 && (Array.IndexOf(IDTable1, itm.Item.TemplateId) != -1 || Array.IndexOf(IDTable1, itm.Item.Template._parent) != -1)) { // enabled rare and item is rare return(Settings.CItem.DrawCustom1); } if (Settings.CItem.DisplayLootCustom2 && (Array.IndexOf(IDTable2, itm.Item.TemplateId) != -1 || Array.IndexOf(IDTable2, itm.Item.Template._parent) != -1)) { // enabled common and item is common return(Settings.CItem.DrawCustom2); } if (Settings.CItem.DisplayLootCustom3 && (Array.IndexOf(IDTable3, itm.Item.TemplateId) != -1 || Array.IndexOf(IDTable3, itm.Item.Template._parent) != -1)) { // enabled custom search and item is on list (as parent or template id) return(Settings.CItem.DrawCustom3); } return(Settings.CItem.DrawBaseColor); }
public void AddItem(LootItem newItem, int amount) { //if(equippedItemSlot != null){ // equippedItemSlot.AddItem(newItem, amount); //} item = newItem; icon.sprite = item.icon; icon.enabled = true; if (amount == 1) { amountText.text = null; } else { amountText.text = amount.ToString(); } isEmpty = (amount <= 0); if (image != null) { image.color = (amount <= 0) ? disabledColor : stdColor; } }
public static void SendRollWon(Character looter, Loot loot, LootItem item, LootRollEntry entry) { using (var packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_ROLL_WON)) { packet.Write(loot.Lootable.EntityId); packet.Write(item.Index); packet.Write(looter.EntityId); packet.Write(item.Template.Id); packet.Write(item.Template.RandomSuffixFactor); packet.Write((int)(item.Template.RandomSuffixFactor > 0 ? -item.Template.RandomSuffixId : item.Template.RandomPropertiesId)); packet.Write(looter.EntityId); packet.Write(entry.Number); packet.Write((int)entry.Type); foreach (var looterEntry in loot.Looters) { if (looterEntry.Owner != null) { looterEntry.Owner.Client.Send(packet); } } } }
/// <summary> /// Assign data from item to button /// </summary> /// <param name="item"></param> public void Initialize(LootItem item, ItemList list, Animator animator, Transform parentUI) { if (ItemName == null || ItemCost == null) { return; } m_List = list; m_Item = item; ItemName.text = item.itemName; ItemCost.text = item.itemCost.ToString(); ItemImage.sprite = item.itemShopPoster != null ? item.itemShopPoster : item.itemSprite; CurrencyImage.sprite = item.currencySprite; byte r = (byte)Random.Range(0, 255); byte g = (byte)Random.Range(0, 255); byte b = (byte)Random.Range(0, 255); BackgroundImage.color = new Color32(r, g, b, 150); m_CamAnim = animator; m_ParentUI = parentUI; }
public static void SendRollWon(Character looter, Loot loot, LootItem item, LootRollEntry entry) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_ROLL_WON)) { packet.Write((ulong)loot.Lootable.EntityId); packet.Write(item.Index); packet.Write((ulong)looter.EntityId); packet.Write(item.Template.Id); packet.Write(item.Template.RandomSuffixFactor); packet.Write(item.Template.RandomSuffixFactor > 0U ? (int)-item.Template.RandomSuffixId : (int)item.Template.RandomPropertiesId); packet.Write((ulong)looter.EntityId); packet.Write(entry.Number); packet.Write((int)entry.Type); foreach (LooterEntry looter1 in (IEnumerable <LooterEntry>)loot.Looters) { if (looter1.Owner != null) { looter1.Owner.Client.Send(packet, false); } } } }
private static List <Enemy> PopulateEnemies() { context.Enemies.Include(enemy => enemy.LootTable); // !!! var smallDagger = new LootItem(ItemByID(ITEM_ID_SMALL_DAGGER), 100, false, ITEM_ID_SMALL_DAGGER); context.LootItems.Add(smallDagger); context.SaveChanges(); Enemy dummy = new Enemy(ENEMY_ID_DUMMY, "Dummy", 1, 4, 0, 45, 45); context.Enemies.Add(dummy); // how to add the dagger to the dbset's instances' loottable collections, if the dbset's instances don't have access to the loottable collections in the Enemy ??? //context.Enemies.Include(enemy => enemy.LootTable); // ^ the answer context.Enemies.FirstOrDefault(e => e.ID == smallDagger.EnemyID).LootTable.Add(smallDagger); return(new List <Enemy>() { dummy }); }
void PrepareItems(Player receiver, SQLTransaction trans) { if (m_mailTemplateId == 0 || !m_mailTemplateItemsNeed) { return; } m_mailTemplateItemsNeed = false; // The mail sent after turning in the quest The Good News and The Bad News contains 100g if (m_mailTemplateId == 123) { m_money = 1000000; } Loot mailLoot = new(); // can be empty mailLoot.FillLoot(m_mailTemplateId, LootStorage.Mail, receiver, true, true, LootModes.Default, ItemContext.None); uint max_slot = mailLoot.GetMaxSlotInLootFor(receiver); for (uint i = 0; m_items.Count < SharedConst.MaxMailItems && i < max_slot; ++i) { LootItem lootitem = mailLoot.LootItemInSlot(i, receiver); if (lootitem != null) { Item item = Item.CreateItem(lootitem.itemid, lootitem.count, lootitem.context, receiver); if (item != null) { item.SaveToDB(trans); // save for prevent lost at next mail load, if send fail then item will deleted AddItem(item); } } } }
static void Postfix() { BlockLootVessel.lootLists["seed"] = LootList.Create(2, LootItem.Item(1f, 5, 7, "seeds-carrot", "seeds-onion", "seeds-spelt", "seeds-turnip", "seeds-rice", "seeds-rye", "seeds-soybean", "seeds-pumpkin", "seeds-cabbage"), LootItem.Item(1f, 5, 7, "wildfarming:wildseeds-herb-basil", "wildfarming:wildseeds-herb-thyme", "wildfarming:wildseeds-herb-sage", "wildfarming:wildseeds-herb-chamomile", "wildfarming:wildseeds-herb-mint", "wildfarming:wildseeds-herb-saffron", "wildfarming:wildseeds-herb-marjoram", "wildfarming:wildseeds-herb-cilantro", "wildfarming:wildseeds-herb-lavender") ); BlockLootVessel.lootLists["food"] = LootList.Create(1, LootItem.Item(1.5f, 8, 15, "grain-spelt", "grain-rice", "grain-flax", "grain-rye"), LootItem.Item(1, 8, 15, "redmeat-cured", "bushmeat-cured", "poultry-cured", "pickledlegume-soybean"), LootItem.Item(1, 8, 15, "pickledvegetable-carrot", "pickledvegetable-parsnip", "pickledvegetable-turnip", "pickledvegetable-pumpkin", "pickledvegetable-onion", "pickledvegetable-cabbage"), LootItem.Item(0.1f, 1, 1, "resonancearchive-1", "resonancearchive-2", "resonancearchive-3", "resonancearchive-4", "resonancearchive-5", "resonancearchive-6", "resonancearchive-7", "resonancearchive-8", "resonancearchive-9") ); BlockLootVessel.lootLists["forage"] = LootList.Create(2.5f, LootItem.Item(1, 2, 6, "flint"), LootItem.Item(1, 3, 9, "stick"), LootItem.Item(1, 3, 16, "drygrass"), LootItem.Item(1, 3, 24, "stone-chalk"), LootItem.Item(1, 3, 24, "clay-blue", "clay-fire"), LootItem.Item(1, 3, 24, "cattailtops"), LootItem.Item(1, 1, 4, "poultice-linen-horsetail"), LootItem.Item(0.5f, 1, 12, "flaxfibers"), LootItem.Item(0.3f, 1, 3, "honeycomb"), LootItem.Item(1f, 2, 6, "herbbundle-basil", "herbbundle-thyme", "herbbundle-sage", "herbbundle-saffron", "herbbundle-marjoram", "herbbundle-lavender", "herbbundle-chamomile", "herbbundle-cilantro", "herbbundle-mint"), LootItem.Item(0.3f, 2, 6, "beenade-closed") ); BlockLootVessel.lootLists["farming"] = LootList.Create(2.5f, LootItem.Item(0.5f, 5, 7, "seeds-carrot", "seeds-onion", "seeds-spelt", "seeds-turnip", "seeds-rice", "seeds-rye", "seeds-soybean", "seeds-pumpkin", "seeds-cabbage"), LootItem.Item(0.5f, 5, 7, "wildfarming:wildseeds-herb-basil", "wildfarming:wildseeds-herb-thyme", "wildfarming:wildseeds-herb-sage", "wildfarming:wildseeds-herb-chamomile", "wildfarming:wildseeds-herb-mint", "wildfarming:wildseeds-herb-saffron", "wildfarming:wildseeds-herb-marjoram", "wildfarming:wildseeds-herb-cilantro", "wildfarming:wildseeds-herb-lavender"), LootItem.Item(0.75f, 3, 10, "feather"), LootItem.Item(0.75f, 2, 10, "flaxfibers"), LootItem.Item(0.35f, 2, 10, "flaxtwine"), LootItem.Item(0.5f, 2, 6, "herbbundle-basil", "herbbundle-thyme", "herbbundle-sage", "herbbundle-saffron", "herbbundle-marjoram", "herbbundle-lavender", "herbbundle-chamomile", "herbbundle-cilantro", "herbbundle-mint"), LootItem.Item(0.75f, 5, 10, "cattailtops"), LootItem.Item(0.1f, 1, 1, "scythe-copper", "scythe-tinbronze") ); }
// Token: 0x060000F5 RID: 245 RVA: 0x0000DCEC File Offset: 0x0000BEEC private void Update() { try { bool corpse = Config.ESP.Corpse; if (corpse) { bool flag = Time.time >= this._nextLootItemCacheTime && Misc.GameWorld != null && Misc.GameWorld.LootItems != null && Misc.LocalPlayer != null && !MonoBehaviourSingleton <PreloaderUI> .Instance.IsBackgroundBlackActive && Misc.MainCamera != null; if (flag) { this._gameLootItems.Clear(); for (int i = 0; i < Misc.GameWorld.LootItems.Count; i++) { LootItem byIndex = Misc.GameWorld.LootItems.GetByIndex(i); bool flag2 = \uE4E3.Localized(byIndex.Item.ShortName) == "Default Inventory"; if (flag2) { bool flag3 = GameUtils.IsLootItemValid(byIndex) && Vector3.Distance(Misc.MainCamera.transform.position, byIndex.transform.position) <= 500f; if (flag3) { this._gameLootItems.Add(new GameLootItem(byIndex)); } } } this._nextLootItemCacheTime = Time.time + CorpseEsp.CacheLootItemsInterval1; } foreach (GameLootItem gameLootItem in this._gameLootItems) { gameLootItem.RecalculateDynamics(); } } } catch { } }
public void Update() { if (!Settings.DrawLootItems) { return; } if (Time.time >= _nextLootItemCacheTime) { GameWorld gameWorld = Singleton <GameWorld> .Instance; if ((gameWorld != null) && (gameWorld.LootItems != null)) { _gameLootItems.Clear(); for (int i = 0; i < gameWorld.LootItems.Count; i++) { LootItem lootItem = gameWorld.LootItems.GetByIndex(i); if (!GameUtils.IsLootItemValid(lootItem) || (Vector3.Distance(Camera.main.transform.position, lootItem.transform.position) > MaximumLootItemDistance)) { continue; } _gameLootItems.Add(new GameLootItem(lootItem)); } _nextLootItemCacheTime = (Time.time + CacheLootItemsInterval); } } foreach (GameLootItem gameLootItem in _gameLootItems) { gameLootItem.RecalculateDynamics(); } }
public void DisplayLootItem(LootItem item) { EditorGUILayout.Separator(); EditorGUILayout.BeginHorizontal(); item.itemType = (ItemType)EditorGUILayout.EnumPopup(item.itemType , GUILayout.Width(200)); EditorGUILayout.PrefixLabel(" ID: "); for (int i = 0; i < item.itemID.Count; i++) { item.itemID[i] = EditorGUILayout.IntField(item.itemID[i], GUILayout.Width(90)); } if (GUILayout.Button("Add new item index", GUILayout.Width(200))) { item.itemID.Add(1); } EditorGUILayout.PrefixLabel(" itemlevel: "); item.itemLevel = EditorGUILayout.IntField(item.itemLevel, GUILayout.Width(90)); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.PrefixLabel(" min amount: "); item.minQuantity = EditorGUILayout.IntField(item.minQuantity, GUILayout.Width(90)); EditorGUILayout.PrefixLabel(" max amount: "); item.maxQuantity = EditorGUILayout.IntField(item.maxQuantity, GUILayout.Width(90)); EditorGUILayout.PrefixLabel(" droprate: "); item.dropRate = EditorGUILayout.FloatField(item.dropRate, GUILayout.Width(90)); EditorGUILayout.EndHorizontal(); ConditionsUtils.Conditions(item.Conditions, Data); }
public void AddNewLoot(LootItem loot) { lootItems.Add(loot); }
public void AddLootByRatio(double ratio, byte container) { foreach (var i in ItemDataLists.AllItems) { if (i.Value.ValueRatio >= ratio) { LootItem lootItem = new LootItem((ushort)i.Value.Id, container, i.Value.Name); LootItems.Add(lootItem); } } }
/// <summary> /// Adds a weapon to the list of weapons purchased/owned by the player /// </summary> /// <param name="id">Id of the weapon to purchase</param> public void PurchaseWeapon(string id, LootItem weapon) { purchasedWeapons.Add(new WeaponShopSaveData(id, weapon)); }
public void AttachItem(LootItem lootItem) { image.sprite = lootItem.Icon; }
public static void SendAllPassed(Character looter, Loot loot, LootItem item) { using (RealmPacketOut packet = new RealmPacketOut(RealmServerOpCode.SMSG_LOOT_ALL_PASSED)) looter.Client.Send(packet, false); }
void HandleLootMasterGive(MasterLootItem masterLootItem) { AELootResult aeResult = new(); if (GetPlayer().GetGroup() == null || GetPlayer().GetGroup().GetLooterGuid() != GetPlayer().GetGUID() || GetPlayer().GetGroup().GetLootMethod() != LootMethod.MasterLoot) { GetPlayer().SendLootError(ObjectGuid.Empty, ObjectGuid.Empty, LootError.DidntKill); return; } // player on other map Player target = Global.ObjAccessor.GetPlayer(_player, masterLootItem.Target); if (!target) { GetPlayer().SendLootError(ObjectGuid.Empty, ObjectGuid.Empty, LootError.PlayerNotFound); return; } foreach (LootRequest req in masterLootItem.Loot) { Loot loot = null; ObjectGuid lootguid = _player.GetLootWorldObjectGUID(req.Object); if (!_player.IsInRaidWith(target) || !_player.IsInMap(target)) { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterOther); Log.outInfo(LogFilter.Cheat, $"MasterLootItem: Player {GetPlayer().GetName()} tried to give an item to ineligible player {target.GetName()} !"); return; } if (GetPlayer().GetLootGUID().IsCreatureOrVehicle()) { Creature creature = GetPlayer().GetMap().GetCreature(lootguid); if (!creature) { return; } loot = creature.loot; } else if (GetPlayer().GetLootGUID().IsGameObject()) { GameObject pGO = GetPlayer().GetMap().GetGameObject(lootguid); if (!pGO) { return; } loot = pGO.loot; } if (loot == null) { return; } byte slotid = (byte)(req.LootListID - 1); if (slotid >= loot.items.Count + loot.quest_items.Count) { Log.outDebug(LogFilter.Loot, $"MasterLootItem: Player {GetPlayer().GetName()} might be using a hack! (slot {slotid}, size {loot.items.Count})"); return; } LootItem item = slotid >= loot.items.Count ? loot.quest_items[slotid - loot.items.Count] : loot.items[slotid]; List <ItemPosCount> dest = new(); InventoryResult msg = target.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count); if (!item.AllowedForPlayer(target, true)) { msg = InventoryResult.CantEquipEver; } if (msg != InventoryResult.Ok) { if (msg == InventoryResult.ItemMaxCount) { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterUniqueItem); } else if (msg == InventoryResult.InvFull) { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterInvFull); } else { _player.SendLootError(req.Object, ObjectGuid.Empty, LootError.MasterOther); } return; } // now move item from loot to target inventory Item newitem = target.StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs); aeResult.Add(newitem, item.count, loot.loot_type); // mark as looted item.count = 0; item.is_looted = true; loot.NotifyItemRemoved(slotid); --loot.unlootedCount; } foreach (var resultValue in aeResult.GetByOrder()) { target.SendNewItem(resultValue.item, resultValue.count, false, false, true); target.UpdateCriteria(CriteriaType.LootItem, resultValue.item.GetEntry(), resultValue.count); target.UpdateCriteria(CriteriaType.GetLootByType, resultValue.item.GetEntry(), resultValue.count, (ulong)resultValue.lootType); target.UpdateCriteria(CriteriaType.LootAnyItem, resultValue.item.GetEntry(), resultValue.count); } }
/// <summary> /// Add an item to the inventory. /// Check if the item already exists in the inventory /// If the item exists and is not stackable use the item /// immediately, if the item is a weapon fill up the clip /// else increment the count in the slot (= 1 if item was not in the inventory) /// </summary> /// <param name="item"></param> public void AddItem(LootItem item) { // Maximum amount of items that can be carried has been reached // We cannot add this item if (FreeSpace <= 0 && item.itemType != ItemType.Weapon) { Debug.Log("The maximum number of items you can carry has been reached"); return; } bool found = false; int firstEmpty = -1; for (int i = 0; i < 16; i++) { if (Entries[i] == null) { if (firstEmpty == -1) { firstEmpty = i; } } else if (Entries[i].Item == item) { if (Entries[i].Item.stackable) { Entries[i].Count += 1; } else { if (!item.UsedBy(m_Player)) { // This is ammo, increase the count Debug.Log("[Inventory] This item is not stackable but could not be used, stacking the item anyway"); Entries[i].Count += 1; FreeSpace -= 1; } } m_Player.Experience.AddExperience(item.pickUpPoints); found = true; } } // A new item entry is done here because no such item has been found in the inventory if (!found && firstEmpty != -1) { if (!item.stackable) { if (item.itemType != ItemType.Weapon) { // If this is not a weapon, try to use it before storing it if (!item.UsedBy(m_Player)) { InventoryEntry newEntry = new InventoryEntry(); newEntry.Item = item; newEntry.Count = 1; Entries[firstEmpty] = newEntry; newEntry.Slot = firstEmpty; FreeSpace -= 1; m_Player.Experience.AddExperience(item.pickUpPoints); m_Player.UpdateEncumbranceUI(); } } else { // This is a weapon, just store it InventoryEntry newEntry = new InventoryEntry(); newEntry.Item = item; newEntry.Count = 1; Entries[firstEmpty] = newEntry; newEntry.Slot = firstEmpty; WeaponSpace -= 1; m_Player.UpdateEncumbranceUI(); } } else { InventoryEntry entry = new InventoryEntry(); entry.Item = item; entry.Count = 1; Entries[firstEmpty] = entry; entry.Slot = firstEmpty; FreeSpace -= 1; m_Player.Experience.AddExperience(item.pickUpPoints); m_Player.UpdateEncumbranceUI(); } Debug.Log("[Inventory] Done Adding"); } }
public void AddLootById(uint id, byte container) { if (ItemLists.AllItems.ContainsKey(id)) { LootItem lootItem = new LootItem((ushort)ItemLists.AllItems[id].Id, container, ItemLists.AllItems[id].Name); LootItems.Add(lootItem); } }
public static void HandleLootResponse(Packet packet) { var loot = new Loot(); var guid = packet.ReadGuid("GUID"); var lootType = packet.ReadEnum <LootType>("Loot Type", TypeCode.Byte); if (lootType == LootType.Unk0) { packet.ReadByte("Slot"); return; } loot.Gold = packet.ReadUInt32("Gold"); var count = packet.ReadByte("Drop Count"); byte currencyCount = 0; if (ClientVersion.AddedInVersion(ClientVersionBuild.V4_0_6a_13623)) { currencyCount = packet.ReadByte("Currency Count"); } loot.LootItems = new List <LootItem>(count); for (var i = 0; i < count; ++i) { var lootItem = new LootItem(); packet.ReadByte("Slot", i); lootItem.ItemId = (uint)packet.ReadEntryWithName <UInt32>(StoreNameType.Item, "Entry", i); lootItem.Count = packet.ReadUInt32("Count", i); packet.ReadUInt32("Display ID", i); packet.ReadInt32("Random Suffix", i); packet.ReadInt32("Random Property Id", i); packet.ReadEnum <LootSlotType>("Slot Type", TypeCode.Byte, i); loot.LootItems.Add(lootItem); } for (int i = 0; i < currencyCount; ++i) { packet.ReadByte("Slot", i); packet.ReadInt32("Currency Id", i); packet.ReadInt32("Count", i); // unconfirmed } // Items do not have item id in its guid, we need to query the wowobject store go if (guid.GetObjectType() == ObjectType.Item) { WoWObject item; UpdateField itemEntry; if (Storage.Objects.TryGetValue(guid, out item)) { if (item.UpdateFields.TryGetValue(UpdateFields.GetUpdateField(ObjectField.OBJECT_FIELD_ENTRY), out itemEntry)) { Storage.Loots.Add(new Tuple <uint, ObjectType>(itemEntry.UInt32Value, guid.GetObjectType()), loot, packet.TimeSpan); return; } } } Storage.Loots.Add(new Tuple <uint, ObjectType>(guid.GetEntry(), guid.GetObjectType()), loot, packet.TimeSpan); }
// Token: 0x0600B89F RID: 47263 RVA: 0x0011514F File Offset: 0x0011334F public static bool IsLootItemValid(LootItem lootItem) { return(lootItem != null && lootItem.Item != null && lootItem.Item.Template != null); }
/// <summary> /// returns all possible ways to make an item from current inventory /// </summary> /// <returns> /// A list (paths to make the item) of lists (ingredients in the path) of LootItemQty<item required, number required> /// </returns> public List <List <LootItemQty> > findCreationPaths(LootItem result) { List <LootItemQty> lootUsed = new List <LootItemQty>(); return(findCreationPaths(result, lootUsed)); }
private void Loot(byte number) { Container container = Core.Client.Inventory.GetContainer(number); if (container == null || !IsLootContainer(number)) { return; } IEnumerable <Item> containterEnumerable = container.GetItems(); List <Item> containerItems = containterEnumerable.ToList(); while (containerItems.Count > 0) { Item item = containerItems.Last(); LootItem lootItem = LootItems.Find(delegate(LootItem loot) { return(loot.Id == item.Id); }); if (lootItem != null) { if (lootItem.Container == (byte)LootContainer.Ground) { int startAmmount = container.Amount; for (int i = 0; i < maxTries && container.Amount == startAmmount; i++) { item.Move(ItemLocation.FromLocation(Core.Player.Location)); Thread.Sleep(100); } } else { Container lootContainer = null; #region Select container if (lootItem.Container == (byte)LootContainer.Any) { lootContainer = GetLootContainer(item); } else { lootContainer = Core.Client.Inventory.GetContainer(lootItem.Container); } #endregion if (lootContainer == null) { continue; } int startAmmount = container.Amount; for (int i = 0; i < maxTries && container.Amount == startAmmount; i++) { GetItem(item, lootContainer); Thread.Sleep(100); } } } containerItems.Remove(item); } #region Eat Foot if (EatFromMonsters) { Item food = containterEnumerable.FirstOrDefault(i => ItemLists.Foods.ContainsKey(i.Id)); if (food != null) { for (int i = 0; i < food.Count; i++) { food.Use(); Thread.Sleep(300); } } } #endregion #region Open bag / close container Item bag = containterEnumerable.LastOrDefault(i => i.GetFlag(Tibia.Addresses.DatItem.Flag.IsContainer)); if (bag != null) { OpenNewContainer(bag, container.Number); } else { container.Close(); } Thread.Sleep(100); #endregion }
/// <summary> /// returns all possible ways to make an item /// </summary> /// <param name="lootUsed">The list of items already used by this recipie line</param> /// <returns> /// A list (paths to make the item) /// of KeyValuePair<lists (ingredients in the path) /// of LootItemQty<item required, number required> /// , quantity this path can make> /// </returns> public List <KeyValuePair <List <LootItemQty>, int> > findCreationPaths(LootItem result, List <LootItemQty> lootUsed) { //create list of paths tomake the item List <KeyValuePair <List <LootItemQty>, int> > returnValue = new List <KeyValuePair <List <LootItemQty>, int> >(); //loop over each basic path in the recipie list List <Recipie> recipiePaths = recipies.where (x => x.result == result); foreach (Recipie r in recipiePaths) { //default to infinite possible items to be made, then reduce based on current stock; int numPossible = int.MaxValue; foreach (LootItemQty currentIngredient in r.ingredients) { //find current stock LootItemQty itemInInventory = findLootInInventory(currentIngredient.item.id); int numInInventory = itemInInventory.qty; //take into account used up stockfrom other ingredient creation LootItemQty usedLoot = lootUsed.find(currentIngredient); if (usedLoot != null) { numInInventory -= usedLoot.qty; } //reduce total number to be made to match inventory int currNumPosible = numInInventory / currIngredient.qty; if (currNumPossible < numPossible) { numPossible = currNumPossible; } } //add basic recipie path to result set KeyValuePair <List <LootItemQty>, int> path = new KeyValuePair <List <LootItemQty>, int>(); path.Key = r.ingredients; path.Value = numPossible; returnValue.add(path); //note used items for sub-queries foreach (LootItemQty currentIngredient in r.ingredients) { LootItemQty usedLoot = lootUsed.find(currentIngredient); if (usedLoot != null) { usedLoot.qty += numPossible * currentIngredient.qty; } else { LootItemQty liq = new LootItemQty(); liq.item = currentIngredient.item; liq.qty = numPossible * currentIngredient.qty; lootUsed.Add(liq); } //check to see if this item can be made List <KeyValuePair <List <LootItemQty>, int> > innerCreation = findCreationPaths(currentIngredient.Key); if (innerCreation.Count != 0) { foreach (KeyValuePair <List <LootItemQty>, int> innerPath in innerCreation) { List <LootItemQty> newIngredients = new List <LootItemQty>(); foreach (LootItemQty ingredientToAdd in r.ingredients) { if (ingredientToAdd.Item != currentIngredient.Item) { newIngredients.add(ingredientToAdd); } } foreach (List <LootItemQty> innerRecipie in innerPath.Key) { foreach (LootItemQty ingredientToAdd in innerRecipie) { newIngredients.add(ingredientToAdd); } } KeyValuePair <List <LootItemQty>, int> newPath = new KeyValuePair <List <LootItemQty>, int>(); newPath.Key = newIngredients; newPath.Value = innerPath.Value; returnValue.add(newIngredients); } } } } }
public void PurchaseItem(string id, LootItem item) { purchasedItems.Add(new ShopSaveData(id, item)); }
public MainWindow() { using (SqlConnection dataConnection = new SqlConnection(ConfigurationManager.AppSettings["SQL_URI"])) { dataConnection.Open(); //load loot string selectLoot = @"SELECT * FROM loot ORDER BY id" ; using (SqlCommand comm = new SqlCommand(selectLoot, dataConnection)) { using (SqlDataReader reader = comm.DataReader()) { while (reader.Read()) { LootItem li = new LootItem(); li.id = (int)reader["id"]; li.name = (string)reader["name"]; li.description = (string)reader["description"]; LootItemQty liq = new LootItemQty(); liq.item = li; liq.qty = (int)reader["qty"]; loot.Add(liq); } } } //load recipies string selectRecipies = @"SELECT * FROM recipies ORDER BY id" ; using (SqlCommand comm = new SqlCommand(selectRecipies, dataConnection)) { using (SqlDataReader reader = comm.DataReader()) { while (reader.Read()) { Recipie r = new Recipie(); r.id = (int)reader["id"]; string selectIngredients = @"SELECT * FROM recipieIngredients WHERE recipieID = '" + r.id + "'"; using (SqlCommand commIngredients = new SqlCommand(selectIngredients, dataConnection)) { using (SqlDataReader readerIngredients = commIngredients.DataReader()) { while (readerIngredients.Read()) { LootItemQty liq = new LootItemQty(); liq.item = findLootInInventory((int)reader["ingredient"]).item; liq.qty = (int)reader["qty"]; r.ingredients.add(liq); } } } LootItem result = findLootInInventory((int)reader["result"]).item; r.resultQty = (int)reader["resultQty"]; r.profession = (string)reader["profession"]; r.crafterLevel = (string)reader["crafterLevel"]; recipies.Add(r); } } } } }
public void Update() { if (Time.time >= this.nextPlayerCacheTime) { GameWorld gameWorld = Singleton <GameWorld> .Instance; if ((gameWorld != null) && (gameWorld.RegisteredPlayers != null)) { this.gamePlayers.Clear(); foreach (Player player in gameWorld.RegisteredPlayers) { if (!GameUtil.IsPlayerAlive(player) || player.IsYourPlayer() || (Vector3.Distance(Camera.main.transform.position, player.Transform.position) > _maximumPlayerDistance)) { continue; } this.gamePlayers.Add(new GamePlayer(player)); } this.nextPlayerCacheTime = (Time.time + _cachePlayersInterval); } } if (Time.time >= this.nextLootItemCacheTime) { GameWorld gameWorld = Singleton <GameWorld> .Instance; if ((gameWorld != null) && (gameWorld.LootItems != null)) { this.gameLootItems.Clear(); for (int i = 0; i < gameWorld.LootItems.Count; i++) { LootItem lootItem = gameWorld.LootItems.GetByIndex(i); if (!GameUtil.IsLootItemValid(lootItem) || (Vector3.Distance(Camera.main.transform.position, lootItem.transform.position) > _maximumLootItemDistance)) { continue; } this.gameLootItems.Add(new GameLootItem(lootItem)); } this.nextLootItemCacheTime = (Time.time + _cacheLootItemsInterval); } } foreach (GamePlayer gamePlayer in this.gamePlayers) { gamePlayer.RecalculateDynamics(); } foreach (GameLootItem gameLootItem in this.gameLootItems) { gameLootItem.RecalculateDynamics(); } ModuleManager.Update(); if (Time.time >= this.nextShaderUpdateTime) { if (this.gamePlayers.Count > 0) { foreach (GamePlayer gamePlayer in this.gamePlayers) { if (!GameUtil.IsPlayerAlive(gamePlayer.Player) || gamePlayer.Player.IsYourPlayer()) { continue; } Color shaderColor = ((gamePlayer.IsAI) ? _botColor : _playerColor); foreach (EBodyModelPart bodyModelPart in Enum.GetValues(typeof(EBodyModelPart))) { foreach (Renderer renderer in gamePlayer.Player.PlayerBody.BodySkins[bodyModelPart].GetRenderers()) { Material material = renderer.material; Shader shader = material.shader; if ((shader.name == this.shader.name)) { continue; } material.shader = this.shader; material.SetColor("_FirstOutlineColor", Color.red); material.SetFloat("_FirstOutlineWidth", 0.02f); material.SetColor("_SecondOutlineColor", shaderColor); material.SetFloat("_SecondOutlineWidth", 0.0025f); } } } this.nextShaderUpdateTime = (Time.time + _shaderUpdateInterval); } } }
private void EventPlayer(LootItem item) { EventPlayer(); }
//[WorldPacketHandler(ClientOpcodes.MasterLootItem)] void HandleLootMasterGive(WorldPacket packet) { ObjectGuid lootguid = packet.ReadPackedGuid(); byte slotid = packet.ReadUInt8(); ObjectGuid target_playerguid = packet.ReadPackedGuid(); if (GetPlayer().GetGroup() == null || GetPlayer().GetGroup().GetLooterGuid() != GetPlayer().GetGUID() || GetPlayer().GetGroup().GetLootMethod() != LootMethod.MasterLoot) { GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.DidntKill); return; } // player on other map Player target = Global.ObjAccessor.GetPlayer(_player, target_playerguid); if (!target) { GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.PlayerNotFound); return; } Log.outDebug(LogFilter.Network, "HandleLootMasterGive (CMSG_LOOT_MASTER_GIVE, 0x02A3) Target = [{0}].", target.GetName()); if (GetPlayer().GetLootGUID() != lootguid) { GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.DidntKill); return; } if (!GetPlayer().IsInRaidWith(target) || !GetPlayer().IsInMap(target)) { GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterOther); Log.outInfo(LogFilter.Loot, "MasterLootItem: Player {0} tried to give an item to ineligible player {1}!", GetPlayer().GetName(), target.GetName()); return; } Loot loot = null; if (GetPlayer().GetLootGUID().IsCreatureOrVehicle()) { Creature creature = GetPlayer().GetMap().GetCreature(lootguid); if (creature == null) { return; } loot = creature.loot; } else if (GetPlayer().GetLootGUID().IsGameObject()) { GameObject pGO = GetPlayer().GetMap().GetGameObject(lootguid); if (pGO == null) { return; } loot = pGO.loot; } if (loot == null) { return; } if (slotid >= loot.items.Count + loot.quest_items.Count) { Log.outDebug(LogFilter.Loot, "MasterLootItem: Player {0} might be using a hack! (slot {1}, size {2})", GetPlayer().GetName(), slotid, loot.items.Count); return; } LootItem item = slotid >= loot.items.Count ? loot.quest_items[slotid - loot.items.Count] : loot.items[slotid]; List <ItemPosCount> dest = new List <ItemPosCount>(); InventoryResult msg = target.CanStoreNewItem(ItemConst.NullBag, ItemConst.NullSlot, dest, item.itemid, item.count); if (item.follow_loot_rules && !item.AllowedForPlayer(target)) { msg = InventoryResult.CantEquipEver; } if (msg != InventoryResult.Ok) { if (msg == InventoryResult.ItemMaxCount) { GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterUniqueItem); } else if (msg == InventoryResult.InvFull) { GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterInvFull); } else { GetPlayer().SendLootError(lootguid, ObjectGuid.Empty, LootError.MasterOther); } target.SendEquipError(msg, null, null, item.itemid); return; } // not move item from loot to target inventory Item newitem = target.StoreNewItem(dest, item.itemid, true, item.randomBonusListId, item.GetAllowedLooters(), item.context, item.BonusListIDs); target.SendNewItem(newitem, item.count, false, false, true); target.UpdateCriteria(CriteriaTypes.LootItem, item.itemid, item.count); target.UpdateCriteria(CriteriaTypes.LootType, item.itemid, item.count, (ulong)loot.loot_type); target.UpdateCriteria(CriteriaTypes.LootEpicItem, item.itemid, item.count); // mark as looted item.count = 0; item.is_looted = true; loot.NotifyItemRemoved(slotid); --loot.unlootedCount; }
public void AddLootByName(string name, byte container) { if (ItemDataLists.AllItems.ContainsKey(name)) { LootItem lootItem = new LootItem((ushort)ItemDataLists.AllItems[name].Id, container, ItemDataLists.AllItems[name].Name); LootItems.Add(lootItem); } }