public void AddObject(world_item w) { if (added % 10 == 0) this.StartData(); buff_data[added / 10].DWord(w.Model); if (w.Type == 1) { buff_data[added / 10].DWord(w.amount); buff_data[added / 10].DWord(w.UniqueID); buff_data[added / 10].Byte(w.xSec); buff_data[added / 10].Byte(w.ySec); buff_data[added / 10].Float(Formule.packetx((float)w.x, w.xSec)); buff_data[added / 10].Float(w.z); buff_data[added / 10].Float(Formule.packety((float)w.y, w.ySec)); buff_data[added / 10].DWord(0); } else if (w.Type == 2) { buff_data[added / 10].Byte(w.PlusValue); buff_data[added / 10].DWord(w.UniqueID); buff_data[added / 10].Byte(w.xSec); buff_data[added / 10].Byte(w.ySec); buff_data[added / 10].Float(Formule.packetx((float)w.x, w.xSec)); buff_data[added / 10].Float(w.z); buff_data[added / 10].Float(Formule.packety((float)w.y, w.ySec)); buff_data[added / 10].Byte(0); buff_data[added / 10].Byte(0); buff_data[added / 10].Bool(w.downType); if (w.downType) buff_data[added / 10].DWord(w.Owner); buff_data[added / 10].Byte(0); } else if (w.Type == 3) { buff_data[added / 10].DWord(w.UniqueID); buff_data[added / 10].Byte(w.xSec); buff_data[added / 10].Byte(w.ySec); buff_data[added / 10].Float(Formule.packetx((float)w.x, w.xSec)); buff_data[added / 10].Float(w.z); buff_data[added / 10].Float(Formule.packety((float)w.y, w.ySec)); buff_data[added / 10].Word(0); buff_data[added / 10].Bool(w.downType); if (w.downType) buff_data[added / 10].DWord(w.Owner); buff_data[added / 10].Byte(0); } added++; }
public static byte[] ObjectSpawn(world_item w) { PacketWriter Writer = new PacketWriter(); Writer.Create(Systems.SERVER_SOLO_SPAWN); Writer.DWord(w.Model); switch (w.Type) { case 1: Writer.DWord(w.amount); Writer.DWord(w.UniqueID); Writer.Byte(w.xSec); Writer.Byte(w.ySec); Writer.Float(Formule.packetx((float)w.x, w.xSec)); Writer.Float(w.z); Writer.Float(Formule.packety((float)w.y, w.ySec)); Writer.DWord(0); Writer.Byte(w.fromType); Writer.DWord(0); break; case 2: //Weapon and armory drops Writer.Byte(w.PlusValue); Writer.DWord(w.UniqueID); Writer.Byte(w.xSec); Writer.Byte(w.ySec); Writer.Float(Formule.packetx((float)w.x, w.xSec)); Writer.Float(w.z); Writer.Float(Formule.packety((float)w.y, w.ySec)); Writer.Byte(0); Writer.Byte(0); Writer.Bool(w.downType); if (w.downType) Writer.DWord(w.Owner); Writer.Byte(0); Writer.Byte(w.fromType); Writer.DWord(w.fromOwner); break; case 3: //Other item types //TODO: Define more detailed drops (Quest items, Mall types etc). Writer.DWord(w.UniqueID); Writer.Byte(w.xSec); Writer.Byte(w.ySec); Writer.Float(Formule.packetx((float)w.x, w.xSec)); Writer.Float(w.z); Writer.Float(Formule.packety((float)w.y, w.ySec)); Writer.Word(0); Writer.Bool(w.downType); if (w.downType) Writer.DWord(w.Owner); Writer.Byte(0); Writer.Byte(w.fromType); Writer.DWord(w.fromOwner); break; //Case 4 will be for event drop treasure box etc. case 4: Writer.Word(0); Writer.DWord(w.fromOwner); Writer.Byte(w.xSec); Writer.Byte(w.ySec); Writer.Float(Formule.packetx((float)w.x, w.xSec)); Writer.Float(w.z); Writer.Float(Formule.packety((float)w.y, w.ySec)); Writer.Byte(1); Writer.DWord(w.UniqueID); Writer.Byte(0); Writer.Byte(5); Writer.DWord(0); break; } return Writer.GetBytes(); }
public static double gamedistance(world_item p1, DarkEmu_GameServer.character._pos p2) { // Nukei: for test with range checking on objects, maybe faster than only calculating distance if ((p1.xSec >= p2.xSec - 1) && (p1.xSec <= p2.xSec + 1) && (p1.ySec >= p2.ySec - 1) && (p1.ySec <= p2.ySec + 1)) { return gamedistance((float)p1.x, (float)p1.y, p2.x, p2.y); } else { return 99999999999999; } }
public void Pet_PickupItem(world_item item) { }
///////////////////////////////////////////////////////////////////////////////// // Drop Item ///////////////////////////////////////////////////////////////////////////////// void Player_DropItem(byte slot) { #region Drop Item try { if (Character.Action.nAttack) return; if (Character.Action.sAttack) return; if (Character.Stall.Stallactive) return; if (Character.State.Exchanging) return; if (Character.Alchemy.working) return; if (Character.State.Busy) return; if (Character.Network.Guild.UsingStorage) return; //Else we continue else { //Get item information from slot. Global.slotItem item = GetItem((uint)Character.Information.CharacterID, slot, 0); //Check if the item is a item mall item before dropping. if (Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.AVATAR28D || Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.CHANGESKIN || Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.GLOBALCHAT || Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.INVENTORYEXPANSION || Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.REVERSESCROLL || Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.STALLDECORATION || Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.WAREHOUSE || Data.ItemBase[item.ID].Etctype == Global.item_database.EtcType.AVATAR28D || Data.ItemBase[item.ID].Type == Global.item_database.ArmorType.AVATAR || Data.ItemBase[item.ID].Type == Global.item_database.ArmorType.AVATARATTACH || Data.ItemBase[item.ID].Type == Global.item_database.ArmorType.AVATARHAT || Data.ItemBase[item.ID].Pettype == Global.item_database.PetType.ATTACKPET || Data.ItemBase[item.ID].Pettype == Global.item_database.PetType.GRABPET) return; //If the id model is lower then 4 dont allow to drop. //Gold drop requires another drop part. if (item.ID < 4) return; //Anti hack check int owner = MsSQL.GetDataInt("SELECT * FROM char_items WHERE id='" + item.dbID + "'", "owner"); //If the player really is the owner of this item we continue to drop it. if (owner == Character.Information.CharacterID) { //Check for item amount. if (item.Amount <= Data.ItemBase[item.ID].Max_Stack) { //Spawn new item globally world_item sitem = new world_item(); sitem.Model = item.ID; sitem.Ids = new Global.ID(Global.ID.IDS.World); sitem.UniqueID = sitem.Ids.GetUniqueID; sitem.amount = item.Amount; sitem.PlusValue = item.PlusValue; sitem.x = Character.Position.x; sitem.z = Character.Position.z; sitem.y = Character.Position.y; Systems.aRound(ref sitem.x, ref sitem.y, 1); sitem.xSec = Character.Position.xSec; sitem.ySec = Character.Position.ySec; //Todo sniff structure for ticket / jewelry box item drop if (Data.ItemBase[sitem.Model].Etctype == Global.item_database.EtcType.EVENT) sitem.Type = 4; #region Amount definition else if (Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.BLADE || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.CH_SHIELD || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_SHIELD || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.BOW || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_AXE || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_CROSSBOW || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_DAGGER || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_DARKSTAFF || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_HARP || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_STAFF || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_SWORD || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_TSTAFF || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EU_TSWORD || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.GLAVIE || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.SPEAR || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.SWORD || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.EARRING || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.RING || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.NECKLACE || Data.ItemBase[sitem.Model].Type == Global.item_database.ArmorType.ARMOR || Data.ItemBase[sitem.Model].Type == Global.item_database.ArmorType.GARMENT || Data.ItemBase[sitem.Model].Type == Global.item_database.ArmorType.GM || Data.ItemBase[sitem.Model].Type == Global.item_database.ArmorType.HEAVY || Data.ItemBase[sitem.Model].Type == Global.item_database.ArmorType.LIGHT || Data.ItemBase[sitem.Model].Type == Global.item_database.ArmorType.PROTECTOR || Data.ItemBase[sitem.Model].Itemtype == Global.item_database.ItemType.AVATAR || Data.ItemBase[sitem.Model].Type == Global.item_database.ArmorType.ROBE) sitem.Type = 2; else sitem.Type = 3; #endregion sitem.fromType = 6; sitem.fromOwner = Character.Information.UniqueID; sitem.downType = false; sitem.Owner = 0; sitem.Send(Packet.ObjectSpawn(sitem), true); Systems.WorldItem.Add(sitem); //Send visual packet for removing the item from inventory. client.Send(Packet.DespawnFromInventory(sitem.UniqueID)); client.Send(Packet.MoveItem(7, slot, 0, 0, 0, "DELETE_ITEM")); //Update database and remove the item MsSQL.UpdateData("delete from char_items where itemnumber='item" + slot + "' AND owner='" + Character.Information.CharacterID + "'"); //Save player information SavePlayerInfo(); } else return; } //If the player is not the owner of the item beeing dropped we ban the player. else { Disconnect("ban"); Console.WriteLine("Autobanned user: "******" Due to hacking"); } } } catch (Exception ex) { Console.WriteLine("Player_DropItem Error {0}", ex); Systems.Debugger.Write(ex); } #endregion }
///////////////////////////////////////////////////////////////////////////////// // Drop Gold ///////////////////////////////////////////////////////////////////////////////// void Player_DropGold(ulong Gold) { #region Drop Gold try { if (Character.Action.nAttack) return; if (Character.Action.sAttack) return; if (Character.Stall.Stallactive) return; if (Character.State.Exchanging) return; if (Character.Alchemy.working) return; if ((ulong)Character.Information.Gold >= Gold) { GetFreeSlot(); world_item item = new world_item(); item.amount = (int)Gold; item.Model = 1; if (item.amount < 1000) item.Model = 1; else if (item.amount > 1000 && item.amount < 10000) item.Model = 2; else if (item.amount > 10000) item.Model = 3; item.Ids = new Global.ID(Global.ID.IDS.World); item.UniqueID = item.Ids.GetUniqueID; item.x = Character.Position.x; item.z = Character.Position.z; item.y = Character.Position.y; Systems.aRound(ref item.x, ref item.y, 1); item.xSec = Character.Position.xSec; item.ySec = Character.Position.ySec; item.Type = 1; item.fromType = 6; item.Owner = 0; Systems.WorldItem.Add(item); item.Send(Packet.ObjectSpawn(item), true); Character.Information.Gold -= (long)Gold; client.Send(Packet.InfoUpdate(1, (int)Character.Information.Gold, 0)); client.Send(Packet.MoveItem(0x0A, 0, 0, 0, (long)Gold, "DELETE_GOLD")); SaveGold(); } else { client.Send(Packet.IngameMessages(SERVER_UPDATEGOLD, IngameMessages.UIIT_MSG_STRGERR_NOT_ENOUGH_GOLD)); } } catch (Exception ex) { Console.WriteLine("Player_DropGold error: {0}", ex); Systems.Debugger.Write(ex); } #endregion }