public bool CheckAgainstDroprate(Rag2Item item, uint droprate, double reducement) { int b = 9999 - (int)((double)random.Next(600, 1000) * (double)(reducement + Singleton.experience.Modifier_Drate)); int c = b > 2000 ? b : 2000; int i = random.Next(0, c); int a = i; if (i < droprate) { int increment = 4000; while (item.count < item.info.max_stack) { a += increment; c += increment; int d = random.Next(a, c); if (d < droprate) { item.count++; } else { break; } } return true; } else { return false; } }
/// <summary> /// Method deserializes byte code to a rag2item. /// </summary> /// <param name="item">Out rag2item container</param> /// <param name="buffer">byte array with supplied data</param> /// <param name="offset">starting offset where to deserialize</param> /// <returns>True if deserializing succeeds</returns> public static bool Deserialize(out Rag2Item item, byte[] buffer, int offset) { uint id = BitConverter.ToUInt32(buffer, offset); byte dyecolor = buffer[offset + 48]; byte clvl = buffer[offset + 49]; bool tradeable = (buffer[offset + 50] == 1) ? false : true; ushort dura = BitConverter.ToUInt16(buffer, offset + 51); byte itemcount = buffer[offset + 53]; uint AlterStone = BitConverter.ToUInt32(buffer, offset + 54); uint ParasiteStone = BitConverter.ToUInt32(buffer, offset + 58); bool result = Singleton.Item.TryGetItem(id, out item); if (result) { item.tradeable = tradeable; item.durabillty = dura; item.dyecolor = dyecolor; item.clvl = clvl; item.count = itemcount; item.Enchantments[0] = AlterStone; item.Enchantments[1] = ParasiteStone; } return(result); }
public void AddItem(Rag2Item item) { int offset = 2 + (this.index * 67); Rag2Item.Serialize(item, this.data, offset); this.data[offset + 66] = (byte)this.index; this.index++; }
public void AddItem(Rag2Item item, bool nostock) { int offset = 11 + (this.index * 68); Rag2Item.Serialize(item, this.data, offset); this.data[offset + 66] = (byte)this.index; this.data[offset + 67] = (byte)(nostock == true ? 1 : 0); this.index++; }
public void AddItem(Rag2Item item, int ItemIndex) { int offset = this.data.Length; Array.Resize<byte>(ref this.data, offset + 67); Rag2Item.Serialize(item, this.data, offset); this.data[offset + 66] = (byte)ItemIndex; this.data[1]++; }
public void AddItem(Rag2Item item, bool nostock, int index) { int offset = this.data.Length; Array.Resize<byte>(ref this.data, offset + 68); Rag2Item.Serialize(item, this.data, offset); this.data[0]++; this.data[offset + 66] = (byte)index; this.data[offset + 67] = (byte)(nostock == true ? 1 : 0); }
/// <summary> /// Clones the current item /// </summary> /// <returns>a cloned object</returns> public object Clone() { Rag2Item item = new Rag2Item(); item.durabillty = this.durabillty; item.clvl = this.clvl; item.info = this.info; return(item); }
/// <summary> /// Returns wether the item references are equal /// </summary> /// <param name="obj">Object to check against</param> /// <returns>True if object is the same</returns> public override bool Equals(object obj) { if (obj is Rag2Item) { Rag2Item item = obj as Rag2Item; return(ReferenceEquals(this.info, item.info)); } return(false); }
/// <summary> /// Clones the current item with the specified count /// </summary> /// <returns>a cloned object</returns> public Rag2Item Clone(int count) { Rag2Item item = new Rag2Item(); item.durabillty = this.durabillty; item.clvl = this.clvl; item.count = count; item.info = this.info; return(item); }
public bool TryGetItem(uint id, out Rag2Item item) { Rag2Item temp = new Rag2Item(); bool result = item_drops.TryGetValue(id, out temp.info); if (result == true) { item = temp; item.clvl = (byte)item.info.req_clvl; item.durabillty = (int)item.info.max_durability; } else { item = null; } return result; }
/// <summary> /// Method serializes a existing rag2item to byte code. /// </summary> /// <remarks> /// This byte code is regonized by the network trafic. And therefor /// it's used in both packet sending as in database storage. Using /// this central method. /// </remarks> /// <param name="item">Item to serialize</param> /// <param name="buffer">desination array to contain the bytes</param> /// <param name="offset">starting offset where to serialize</param> public static void Serialize(Rag2Item item, byte[] buffer, int offset) { //OTHER STUFF Array.Copy(BitConverter.GetBytes(item.info.item), 0, buffer, offset + 0, 4); //Array.Copy(BitConverter.GetBytes(0), 0, this.data, index + 4, 4); //Array.Copy(BitConverter.GetBytes(0), 0, this.data, index + 8, 4); //Encoding.Unicode.GetBytes(name, 0, Math.Min(name.Length, 16), this.data, index + 12); //Array.Copy(BitConverter.GetBytes(0), 0, this.data, index + 45, 4); buffer[offset + 48] = item.dyecolor; buffer[offset + 49] = item.clvl; buffer[offset + 50] = (item.tradeable == false) ? (byte)1 : (byte)0; Array.Copy(BitConverter.GetBytes(item.durabillty), 0, buffer, offset + 51, 2); buffer[offset + 53] = (byte)item.count; Array.Copy(BitConverter.GetBytes(item.Enchantments[0]), 0, buffer, offset + 54, 4); Array.Copy(BitConverter.GetBytes(item.Enchantments[1]), 0, buffer, offset + 58, 4); //this.data[index + 66] = (byte)ItemIndex; //buffer[offset + 67] = 1; }
public void AddItem(Rag2Item product, Rag2Item supply, Rag2Item supply2) { int count = this.data[4]; int newcount = count + 1; if (newcount > 25) return; if (product != null) { Rag2Item.Serialize(product, this.data, 0x6F + count * 66); Array.Copy(BitConverter.GetBytes(count), 0, this.data, 11 + count * 4, 4); this.data[4]++; } if (supply != null) { Rag2Item.Serialize(supply, this.data, 0x6E1 + count * 66); this.data[5]++; } if (supply2 != null) { Rag2Item.Serialize(supply2, this.data, 0xD53 + count * 66); this.data[6]++; } }
public void AddItem(Rag2Item item, byte Active, int ItemIndex) { int index = ItemIndex * 68; Rag2Item.Serialize(item, this.data, index); this.data[index + 67] = item.active; }
public void SetProducts(Rag2Item list) { int offset = 119 + (this.data[17] * 66); Rag2Item.Serialize(list, this.data, offset); this.data[17]++; }
public void SetMatrial(Rag2Item list) { int offset = 1769 + (this.data[18] * 66); Rag2Item.Serialize(list, this.data, offset); this.data[18]++; }
public static ItemSkillUsageEventArgs Create(Rag2Item item, MapObject sender, MapObject target) { ItemSkillUsageEventArgs skillusage = new ItemSkillUsageEventArgs(sender, target); skillusage.iteminfo = item.info; if (item == null) return null; else if (!Singleton.SpellManager.TryGetSpell(item.info.skill, out skillusage.info)) return null; else return skillusage; }
/// <summary> /// Clones the current item /// </summary> /// <returns>a cloned object</returns> public object Clone() { Rag2Item item = new Rag2Item(); item.durabillty = this.durabillty; item.clvl = this.clvl; item.info = this.info; return item; }
public void SetItem(Rag2Item item, int Index) { Rag2Item.Serialize(item, this.data, 2); this.data[68] = (byte)Index; }
/// <summary> /// Removes a item /// </summary> /// <param name="item">Item to remove</param> /// <returns>True if the item was removed</returns> public bool Remove(Rag2Item item) { foreach (KeyValuePair<byte, Rag2Item> pair in this.dictonairy) { if (pair.Value == item) { this.dictonairy.Remove(pair.Key); return true; } } return false; }
/// <Sql> /// UPDATE /// list_maildata /// SET /// Attachment=?Attachment /// WHERE /// MailId=?Id /// </Sql> public bool UpdateItemAttachment(uint MailId, Rag2Item Attachment) { MySqlConnection connection = ConnectionPool.Request(); MySqlCommand command = new MySqlCommand(_query_44, connection); command.Parameters.AddWithValue("Id", MailId); command.Parameters.AddWithValue("Attachment", Attachment); try { return command.ExecuteNonQuery() > 0; } catch (Exception e) { __dbtracelog.WriteError("Database", e.Message); return false; } finally { ConnectionPool.Release(connection); } }
/// <summary> /// Method deserializes byte code to a rag2item. /// </summary> /// <param name="item">Out rag2item container</param> /// <param name="buffer">byte array with supplied data</param> /// <param name="offset">starting offset where to deserialize</param> /// <returns>True if deserializing succeeds</returns> public static bool Deserialize(out Rag2Item item, byte[] buffer, int offset) { uint id = BitConverter.ToUInt32(buffer, offset); byte dyecolor = buffer[offset + 48]; byte clvl = buffer[offset + 49]; bool tradeable = (buffer[offset + 50] == 1) ? false : true; ushort dura = BitConverter.ToUInt16(buffer, offset + 51); byte itemcount = buffer[offset + 53]; uint AlterStone = BitConverter.ToUInt32(buffer, offset + 54); uint ParasiteStone = BitConverter.ToUInt32(buffer, offset + 58); bool result = Singleton.Item.TryGetItem(id, out item); if (result) { item.tradeable = tradeable; item.durabillty = dura; item.dyecolor = dyecolor; item.clvl = clvl; item.count = itemcount; item.Enchantments[0] = AlterStone; item.Enchantments[1] = ParasiteStone; } return result; }
/// <summary> /// Clones the current item with the specified count /// </summary> /// <returns>a cloned object</returns> public Rag2Item Clone(int count) { Rag2Item item = new Rag2Item(); item.durabillty = this.durabillty; item.clvl = this.clvl; item.count = count; item.info = this.info; return item; }
public DataEquipmentCollection(uint characterId, Rag2Item[] equipment) { owner = characterId; equips = equipment; }
/// <summary> /// Adds a item to the list /// </summary> /// <param name="item">Item to add</param> /// <returns>Index of the item</returns> public int Add(Rag2Item item) { int i = FindFirstFreeIndex(); this.dictonairy.Add((byte)i, item); return i; }
public bool UpdateItemAttachment(uint MailId, Rag2Item Attachment) { return InternalDatabaseProvider.UpdateItemAttachment(MailId, Attachment); }
public static bool Create(Rag2Item item, MapObject sender, MapObject target, out ItemSkillUsageEventArgs argument) { argument = Create(item, sender, target); return argument != null; }
bool IDatabase.UpdateItemAttachment(uint MailId, Rag2Item Attachment) { return UpdateItemAttachment(MailId, Attachment); }
/// <summary> /// Creates a new shoppair /// </summary> /// <param name="item">item to stock</param> /// <param name="NoStock">True if the item has infinite stock</param> public ShopPair(Rag2Item item, bool NoStock) { this.item = item; this.NoStock = NoStock; }
public void AddItem(Rag2Item item, int index) { Rag2Item.Serialize(item, this.data, 5 + (this.offset * 67)); this.data[5 + 66 + (this.offset * 67)] = (byte)index; this.offset++; }