public static bool CanUse(Item_Info Info, Player Plr, bool IgnoreLevel, bool IgnoreSkills, bool IgnoreRace, bool IgnoreCareer, bool IgnoreRenown) { if (!IgnoreSkills) { uint Skills = Info.Skills << 1; long PlayerSkill = Plr._Value.Skills; if (Skills != 0 && (PlayerSkill &= Skills) != Skills) return false; } if (!IgnoreCareer) { int Career = (int)Info.Career; int PlayerCareer = 1 << (Plr._Info.CareerLine - 1); if (Career != 0 && (Career & PlayerCareer) == 0) return false; } if (!IgnoreRace) { int Race = (int)Info.Race; int PlayerRace = 1 << (Plr._Info.Race - 1); if (Race != 0 && (Race & PlayerRace) == 0) return false; } if (!IgnoreLevel) { if (Plr.Level < Info.MinRank) return false; } if (!IgnoreRenown) { if (Plr.Renown < Info.MinRenown) return false; } return true; }
public LootInfo(Item_Info Item) { this.Item = Item; }
public bool Load(Character_item Item) { if (Item == null) return false; Info = WorldMgr.GetItem_Info(Item.Entry); if (Info == null) { Log.Error("ItemInterface", "Load : Info==null,Entry=" + Item.Entry); return false; } CharItem = Item; return true; }
static public void BuildItem(ref PacketOut Out,Item Itm,Item_Info Info,ushort SlotId,ushort Count) { SlotId = SlotId == 0 ? (Itm == null ? SlotId : Itm.SlotId ) : SlotId; Count = Count == 0 ? (Itm == null ? Count : Itm.Count) : Count; Info = Info == null ? (Itm == null ? null : Itm.Info) : Info; if(SlotId != 0) Out.WriteUInt16(SlotId); Out.WriteByte(0); Out.WriteUInt32((uint)(Info != null ? Info.Entry : 0)); if (Info == null) return; Out.WriteUInt16((ushort)Info.ModelId); // Valid 1.4.8 Out.Fill(0, 7); // Valid 1.4.8 Out.WriteUInt16(Info.SlotId); // Valid 1.4.8 Out.WriteByte(Info.Type); // Valid 1.4.8 Out.WriteByte(Info.MinRank); // Min Level Out.WriteByte(Info.ObjectLevel); // 1.3.5, Object Level Out.WriteByte(Info.MinRenown); // 1.3.5, Min Renown Out.WriteByte(Info.MinRenown); // ? Out.WriteByte(Info.UniqueEquiped); // Unique - Equiped Out.WriteByte(Info.Rarity); Out.WriteByte(Info.Bind); Out.WriteByte(Info.Race); // Trophys have some extra bytes if (Info.Type == (byte)GameData.ItemTypes.ITEMTYPES_TROPHY) { Out.WriteUInt32(0); Out.WriteUInt16(0x0080); } Out.WriteUInt32(Info.Career); Out.WriteUInt32(0); Out.WriteUInt32(Info.SellPrice); Out.WriteUInt16((UInt16)(Count > 0 ? Count : 1)); Out.WriteUInt16((UInt16)(Count > 0 ? Count : 1)); Out.WriteUInt32(0); Out.WriteUInt32(Info.Skills); // Valid 1.4.8 Out.WriteUInt16(Info.Dps > 0 ? Info.Dps : Info.Armor); // Valid 1.4.8 Out.WriteUInt16(Info.Speed); // Valid 1.4.8 Out.WritePascalString(Info.Name); // Valid 1.4.8 Out.WriteByte((byte)Info._Stats.Count); // Valid 1.4.8 foreach (KeyValuePair<byte, UInt16> Key in Info._Stats) { Out.WriteByte(Key.Key); Out.WriteUInt16(Key.Value); Out.Fill(0, 5); } Out.WriteByte(0); // Equip Effects Out.WriteByte((byte)Info._Spells.Count); // OK foreach (KeyValuePair<UInt32, UInt32> Kp in Info._Spells) { Out.WriteUInt32(Kp.Key); Out.WriteUInt32(Kp.Value); } // (uint32)Entry, uint16 X, uint16 Y Out.WriteByte((byte)Info._Crafts.Count); // OK foreach (KeyValuePair<byte, ushort> Kp in Info._Crafts) { Out.WriteByte(Kp.Key); Out.WriteUInt16(Kp.Value); } Out.WriteByte(0); // ?? Out.WriteByte(Info.TalismanSlots); Item_Info TalismanInfo = null; for (int i = 0; i < Info.TalismanSlots; ++i) { if (Itm != null) TalismanInfo = Itm.GetTalisman((byte)i); if (TalismanInfo == null) Out.WriteUInt32(0); // Entry; else { Out.WriteUInt32(TalismanInfo.Entry); Out.WritePascalString(TalismanInfo.Name); Out.Fill(0, 15); } } Out.WritePascalString(Info.Description); Out.Write(Info.Unk27); /*Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(0); Out.WriteUInt16(0x0302); Out.Fill(0, 8); Out.WriteByte(0); // Type , Culture, etc etc Out.WriteByte(0); // Type, Recipian , Soil , etc etc Out.Fill(0, 11);*/ }
public bool Load(Item_Info Info, UInt16 SlotId, UInt16 Count) { this.Info = Info; if (Info == null) return false; if (Count <= 0) Count = 1; _SlotId = SlotId; _ModelId = Info.ModelId; _Count = Count; return true; }
public bool Load(uint Entry, UInt16 SlotId, UInt16 Count) { Info = WorldMgr.GetItem_Info(Entry); if (Info == null) return false; if (Count <= 0) Count = 1; _SlotId = SlotId; _ModelId = Info.ModelId; _Count = Count; return true; }
private void SendItem(Player Plr, UInt16 Slot, Item_Info Info) { PacketOut Out = new PacketOut((byte)Opcodes.F_GET_ITEM); Out.WriteByte(1); Out.Fill(0, 3); Item.BuildItem(ref Out, null, Info, Slot, 1); Plr.SendPacket(Out); }
List<UInt16> ToSend = new List<ushort>(); // List des Objets mis a jours public ItemError CreateItem(Item_Info Info, UInt16 Count) { if(Info == null) return ItemError.RESULT_ITEMID_INVALID; lock (ToSend) { Stacked.Clear(); ToSend.Clear(); UInt16 CanStack = 0; // Nombre d'objet qui peuvent être stacker UInt16 ToCreate = (UInt16)Math.Ceiling((decimal)(Count / Info.MaxStack) + 1); // Nombre d'objet qui doit être créé Count/MaxStack if (Info.MaxStack > 1) // Si l'objet a créer est stackable on recherche les objets déja dans l'inventaire { Stacked = GetStackItem(Info.Entry); CanStack = GetStackableCount(Stacked); if (CanStack >= Count) // Si on a + de place pour le stack que pour le créer alors on n'en créer aucun { ToCreate = 0; // Nombre de slots a créé CanStack = Count; } else { Count -= CanStack; ToCreate = (UInt16)Math.Ceiling((decimal)(Count / Info.MaxStack) + 1); // On supprime le nombre stackable et on recalcul le nombre de slot necessaire } } UInt16 TotalFreeSlot = GetTotalFreeInventorySlot(); // Nombre de slots total dont je dispose //Log.Info("ItemsInterface", "Count=" + Count + ",FreeSlot=" + TotalFreeSlot + ",ToCreate=" + ToCreate+",CanStack="+CanStack); if (TotalFreeSlot < ToCreate) // Je n'ai pas assez de slots disponible pour créer ces objets return ItemError.RESULT_MAX_BAG; foreach (UInt16 StackableSlot in Stacked) { Item Itm = Items[StackableSlot]; if (Itm == null || Itm.Count >= Itm.Info.MaxStack) continue; UInt16 ToAdd = (UInt16)Math.Min(Itm.Info.MaxStack - Itm.Count, CanStack); //Log.Info("ItemsInterface", "StackableSlot Add : " + ToAdd); Itm.Count += ToAdd; CanStack -= ToAdd; Count -= ToAdd; ToSend.Add(StackableSlot); if (CanStack <= 0) break; } for (int i = 0; i < ToCreate && Count > 0; ++i) { UInt16 FreeSlot = GetFreeInventorySlot(); if (FreeSlot == 0) return ItemError.RESULT_MAX_BAG; UInt16 ToAdd = Math.Min(Count, Info.MaxStack); Count -= ToAdd; Item Itm = new Item(_Owner); if (!Itm.Load(Info, FreeSlot, ToAdd)) return ItemError.RESULT_ITEMID_INVALID; //Log.Info("ItemsInterface", "New Item ToAdd : " + ToAdd + ",Count=" + Count); Items[FreeSlot] = Itm; ToSend.Add(FreeSlot); } if (_Owner.IsPlayer()) _Owner.GetPlayer().QtsInterface.HandleEvent(Objective_Type.QUEST_GET_ITEM, Info.Entry, Count, false); SendItems(GetPlayer(), ToSend); } return ItemError.RESULT_OK; }
public static void BuildItem(ref PacketOut Out,Item Itm,Item_Info Info,ushort SlotId,ushort Count) { SlotId = SlotId == 0 ? (Itm == null ? SlotId : Itm.SlotId ) : SlotId; Count = Count == 0 ? (Itm == null ? Count : Itm.Count) : Count; Info = Info == null ? (Itm == null ? null : Itm.Info) : Info; if(SlotId != 0) Out.WriteUInt16(SlotId); Out.WriteByte(0); Out.WriteUInt32((uint)(Info != null ? Info.Entry : 0)); if (Info == null) return; Out.WriteUInt16((ushort)Info.ModelId); Out.Fill(0, 7); Out.WriteUInt16(Info.SlotId); Out.WriteByte(Info.Type); Out.WriteByte(Info.MinRank); Out.WriteByte((byte)(Info.MinRank + 1)); // 1.3.5 Out.WriteByte(Info.MinRenown); // 1.3.5 Out.WriteByte(Info.MinRenown); Out.WriteByte(Info.MinRenown); Out.WriteByte(Info.Rarity); Out.WriteByte(Info.Bind); Out.WriteByte(Info.Race); Out.WriteUInt32(Info.Career); Out.WriteUInt32(0); Out.WriteUInt32(Info.SellPrice); Out.WriteUInt16((UInt16)(Count > 0 ? Count : 1)); Out.WriteUInt16((UInt16)(Count > 0 ? Count : 1)); Out.WriteUInt32(0); Out.WriteUInt32(Info.Skills); Out.WriteUInt16(Info.Dps > 0 ? Info.Dps : Info.Armor); Out.WriteUInt16(Info.Speed); Out.WritePascalString(Info.Name); Out.WriteByte((byte)Info._Stats.Count); foreach (KeyValuePair<byte, UInt16> Key in Info._Stats) { Out.WriteByte(Key.Key); Out.WriteUInt16(Key.Value); Out.Fill(0, 5); } Out.WriteByte(0); Out.WriteByte(0); // SpellCounts // (uint32)Entry, uint16 X, uint16 Y Out.WriteByte(0); // Artisana Info , 3 bytes pour chaque artisana Out.WriteByte(0); Out.WriteByte(Info.TalismanSlots); for (int i = 0; i < Info.TalismanSlots; ++i) Out.WriteUInt32(0); // Entry; Out.WritePascalString(Info.Description); Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(0); Out.WriteByte(0); Out.WriteUInt16(0x0302); Out.Fill(0, 8); Out.WriteByte(0); // Type , Culture, etc etc Out.WriteByte(0); // Type, Recipian , Soil , etc etc Out.Fill(0, 11); }