void MovementSkyClicking(PacketReader Reader) { Character.Position.Walking = true; byte Type = Reader.Byte(); ushort Angle = Reader.UInt16(); Character.Information.Angle = (Angle) / 182.04166666666666; Character.Position.packetxSec = Character.Position.xSec; Character.Position.packetySec = Character.Position.ySec; Character.Position.packetX = (ushort)Formule.gamex(Character.Position.x, Character.Position.xSec); Character.Position.packetY = (ushort)Formule.gamex(Character.Position.y, Character.Position.ySec); double Distance = Formule.gamedistance(Character.Position.x, Character.Position.y, Formule.gamex((float)Character.Position.packetX, Character.Position.xSec), Formule.gamey((float)Character.Position.packetY, Character.Position.ySec)); PacketWriter writer = new PacketWriter(); writer.Create(0xb021); writer.DWord(Character.Information.UniqueID); writer.Byte(0); writer.Byte(Type); writer.Word(Angle); writer.Byte(1); writer.Byte(Character.Position.xSec); writer.Byte(Character.Position.ySec); writer.Word(Character.Position.packetX); writer.DWord(Character.Position.z); writer.Word(Character.Position.packetY); Send(writer.GetBytes()); Reader.Close(); StartSkyDromeTimer(1000); }
void GM_WP(byte xSec, byte ySec, float x, float z, float y) { //Close buffs BuffAllClose(); //Send teleport packet #1 client.Send(Packet.TeleportStart()); //Despawn objects ObjectDeSpawnCheck(); //Despawn player to other players DeSpawnMe(); //Set state Character.InGame = false; //Update location Character.Position.xSec = xSec; Character.Position.ySec = ySec; Character.Position.x = Formule.gamex(x, xSec); Character.Position.z = z; Character.Position.y = Formule.gamey(y, ySec); //Required client.Send(Packet.TeleportStart2()); //Send loading screen image client.Send(Packet.TeleportImage(xSec, ySec)); //Set bool Character.Teleport = true; SavePlayerPosition(); PlayerDataLoad(); }
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// // Forgotten world base entrance /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// void ForgottenWorld(int itemid) { try { //Spawn portal WorldMgr.Monsters o = new WorldMgr.Monsters(); float x = Character.Position.x; float z = Character.Position.z; float y = Character.Position.y; o.Ids = new GenerateUniqueID(GenerateUniqueID.IDS.Object); o.UniqueID = o.Ids.GetUniqueID; o.xSec = Character.Position.xSec; o.ySec = Character.Position.ySec; o.x = Formule.gamex(x, o.xSec); o.z = z; o.y = Formule.gamey(y, o.ySec); client.Send(Packet.SpawnPortal(o, Character, itemid)); } catch (Exception ex) { Log.Exception(ex); } }
protected void SavePlayerPosition() { //Wrap our function inside a catcher try { //Update database if (!FileDB.CheckCave(Character.Position.xSec, Character.Position.ySec)) { DB.query("update character set xsect='" + Character.Position.xSec + "', ysect='" + Character.Position.ySec + "', xpos='" + Formule.packetx(Character.Position.x, Character.Position.xSec) + "', ypos='" + Formule.packety(Character.Position.y, Character.Position.ySec) + "', zpos='" + Math.Round(Character.Position.z) + "' where id='" + Character.Information.CharacterID + "'"); } else { DB.query("update character set xsect='" + Character.Position.xSec + "', ysect='" + Character.Position.ySec + "', xpos='" + Formule.cavepacketx(Character.Position.x) + "', ypos='" + Formule.cavepackety(Character.Position.y) + "', zpos='" + Math.Round(Character.Position.z) + "' where id='" + Character.Information.CharacterID + "'"); } } catch (Exception ex) { Log.Exception(ex); } }
protected void SavePlayerReturn() { //Update database DB.query("update character_rev set revxsec='" + Character.Position.xSec + "', revysec='" + Character.Position.ySec + "', revx='" + Formule.packetx(Character.Position.x, Character.Position.xSec) + "', revy='" + Formule.packety(Character.Position.y, Character.Position.ySec) + "', revz='" + Math.Round(Character.Position.z) + "' where charname='" + Character.Information.Name + "'"); }
///////////////////////////////////////////////////////////////////////////////// // Cave movement teleport ///////////////////////////////////////////////////////////////////////////////// public void Movement_CaveTeleport()// This was changed due to going in and out of caves to change the movment patten { try { // if our destination is caveteleport foreach (ObjData.CaveTeleports r in ObjData.Manager.CaveTeleports) { if (!FileDB.CheckCave(Character.Position.xSec, Character.Position.ySec)) { if (Formule.gamedistance(Formule.packetx(Character.Position.x, Character.Position.xSec), Formule.packety(Character.Position.y, Character.Position.ySec), (float)r.x, (float)r.y) <= 10) { foreach (ObjData.cavepoint p in ObjData.Manager.cavePointBase) { if (p != null) { if (p.Name == r.name) { TeleportCave(p.Number); break; } } } break; } } else { if (Formule.gamedistance(Formule.cavepacketx(Character.Position.x), Formule.cavepackety(Character.Position.y), (float)r.x, (float)r.y) <= 10) { foreach (ObjData.cavepoint p in ObjData.Manager.cavePointBase) { if (p != null) { if (p.Name == r.name) { TeleportCave(p.Number); break; } } } break; } } } } catch (Exception ex) { Log.Exception(ex); } }
public void SetStat() { //Wrap our function inside a catcher try { //Update stats hp / mp Character.Stat.Hp = Formule.gamePhp(Character.Information.Level, Character.Stat.Strength); Character.Stat.Mp = Formule.gamePmp(Character.Information.Level, Character.Stat.Intelligence); //Send visual update packet client.Send(Packet.PlayerStat(Character)); } catch (Exception ex) { Log.Exception(ex); } }
//############################################################################## // Call backs //############################################################################## void Player_SkyDrome(object e) { try { double distance = Character.Speed.RunSpeed / 10; Character.Position.x += (float)(distance * Math.Cos((Math.PI / 180) * Character.Information.Angle)); Character.Position.y += (float)(distance * Math.Sin((Math.PI / 180) * Character.Information.Angle)); Character.Position.z = Formule.GetHeightAt(Character.Position.xSec, Character.Position.ySec, Character.Position.x, Character.Position.y); Console.WriteLine("x: {0} y: {1} z: {2} angle: {3}", Character.Position.x, Character.Position.y, Character.Position.z, Character.Information.Angle); } catch (Exception ex) { Log.Exception(ex); } }
///////////////////////////////////////////////////////////////////////////////// // Movement checks before picking ///////////////////////////////////////////////////////////////////////////////// void Player_PickUp() { try { if (Character.State.Sitting) { return; } if (Character.State.Exchanging) { return; } if (Character.Action.Target != 0) { WorldMgr.Items item = Helpers.GetInformation.GetWorldItem(Character.Action.Target); if (item == null) { return; } double distance = Formule.gamedistance(Character.Position.x, Character.Position.y, item.x, item.y); if (distance >= 1) { Character.Position.wX = item.x - Character.Position.x; Character.Position.wY = item.y - Character.Position.y; Send(Packet.Movement(new ObjData.vektor(Character.Information.UniqueID, Formule.packetx(item.x, item.xSec), Character.Position.z, Formule.packety(item.y, item.ySec), Character.Position.xSec, Character.Position.ySec))); StartMovementTimer(GetMovementTime(distance)); return; } Player_PickUpItem(); } } catch (Exception ex) { Log.Exception(ex); } }
void UpdateXY() { //Wrap our function inside a catcher try { //Update x and y of character if (!FileDB.CheckCave(Character.Position.xSec, Character.Position.ySec)) { Character.Position.x = Formule.gamex(Character.Position.x, Character.Position.xSec); Character.Position.y = Formule.gamey(Character.Position.y, Character.Position.ySec); } else { //New cave update x y Character.Position.x = Formule.cavegamex(Character.Position.x); Character.Position.y = Formule.cavegamey(Character.Position.y); } } catch (Exception ex) { Log.Exception(ex); } }
///////////////////////////////////////////////////////////////////////////////// // Pet movement ///////////////////////////////////////////////////////////////////////////////// public void MovementPet() { try { //Open our packet reader PacketReader Reader = new PacketReader(PacketInformation.buffer); //This one happens to all pets. int petid = Reader.Int32(); //We switch on type (2 = attack pet, 1 = horse). byte type = Reader.Byte(); switch (type) { //Horse pet movement case 1: byte movetype = Reader.Byte(); byte xsec = Reader.Byte(); byte ysec = Reader.Byte(); float x = Reader.Int16(); float z = Reader.Int16(); float y = Reader.Int16(); Reader.Close(); //Make sure attack timer is gone StopAttackTimer(); //Set pickup to false Character.Action.PickUping = false; //Set movement active Character.Position.Walking = true; double distance = Formule.gamedistance(Character.Position.x, Character.Position.y, Formule.gamex(x, xsec), Formule.gamey(y, ysec)); Character.Position.xSec = xsec; Character.Position.ySec = ysec; Character.Position.wX = Formule.gamex(x, xsec) - Character.Position.x; Character.Position.wZ = z; Character.Position.wY = Formule.gamey(y, ysec) - Character.Position.y; Character.Position.packetxSec = xsec; Character.Position.packetySec = ysec; Character.Position.packetX = (ushort)x; Character.Position.packetZ = (ushort)z; Character.Position.packetY = (ushort)y; Send(Packet.Movement(new ObjData.vektor(petid, x, z, y, xsec, ysec))); break; //Attack pet movement case 2: //Set pet info Character.Attackpet.Details.x = Character.Position.x; Character.Attackpet.Details.y = Character.Position.y; Character.Attackpet.Details.z = Character.Position.z; Character.Attackpet.Details.xSec = Character.Position.xSec; Character.Attackpet.Details.ySec = Character.Position.ySec; //Target id information int targetid = Reader.Int32(); Reader.Close(); //Set pet speed information Send(Packet.SetSpeed(petid, 50, 100)); //Need to make correct speed info later //Check distances / target detailed. //Send attack packet (new void pet attack to be created). break; } } catch (Exception ex) { Log.Exception(ex); } }
void MovementNormalClicking(PacketReader Reader) { float XPosition = 0; float YPosition = 0; float ZPosition = 0; byte xsec = Reader.Byte(); byte ysec = Reader.Byte(); double Distance = 0; Character.Position.Walking = true; if (!FileDB.CheckCave(xsec, ysec)) { XPosition = Reader.Int16(); ZPosition = Reader.Int16(); YPosition = Reader.Int16(); Distance = Formule.gamedistance(Character.Position.x, Character.Position.y, Formule.gamex(XPosition, xsec), Formule.gamey(YPosition, ysec)); Character.Position.xSec = xsec; Character.Position.ySec = ysec; Character.Position.wX = Formule.gamex(XPosition, xsec) - Character.Position.x; Character.Position.wZ = ZPosition; Character.Position.wY = Formule.gamey(YPosition, ysec) - Character.Position.y; Character.Position.packetxSec = xsec; Character.Position.packetySec = ysec; Character.Position.packetX = (ushort)XPosition; Character.Position.packetZ = (ushort)ZPosition; Character.Position.packetY = (ushort)YPosition; if ((xsec != 0) && (ysec != 0)) { Send(Packet.Movement(new ObjData.vektor(Character.Information.UniqueID, XPosition, ZPosition, YPosition, xsec, ysec))); } StartMovementTimer(GetMovementTime(Distance)); } else { XPosition = Formule.cavegamex((float)Reader.Int16(), (float)Reader.Int16()); ZPosition = Formule.cavegamez((float)Reader.Int16(), (float)Reader.Int16()); YPosition = Formule.cavegamey((float)Reader.Int16(), (float)Reader.Int16()); Distance = Formule.gamedistance(Character.Position.x, Character.Position.y, Formule.cavegamex(XPosition), Formule.cavegamey(YPosition)); Character.Position.xSec = xsec; Character.Position.ySec = ysec; Character.Position.wX = Formule.cavegamex(XPosition) - Character.Position.x; Character.Position.wZ = ZPosition; Character.Position.wY = Formule.cavegamey(YPosition) - Character.Position.y; Character.Position.packetxSec = xsec; Character.Position.packetySec = ysec; Character.Position.packetX = (ushort)XPosition; Character.Position.packetZ = (ushort)ZPosition; Character.Position.packetY = (ushort)YPosition; if ((xsec != 0) && (ysec != 0)) { Send(Packet.Movement(new ObjData.vektor(Character.Information.UniqueID, XPosition, ZPosition, YPosition, xsec, ysec))); } StartMovementTimer(GetMovementTime(Distance)); } Reader.Close(); if (Character.Grabpet.Active) { Send(Packet.Movement(new ObjData.vektor(Character.Grabpet.Details.UniqueID, XPosition + Rnd.Next(10, 15), ZPosition, YPosition + Rnd.Next(10, 15), xsec, ysec))); } if (Character.Attackpet.Active) { Send(Packet.Movement(new ObjData.vektor(Character.Attackpet.Details.UniqueID, XPosition + Rnd.Next(10, 15), ZPosition, YPosition + Rnd.Next(10, 15), xsec, ysec))); } }
///////////////////////////////////////////////////////////////////////////////// // Pickup item ///////////////////////////////////////////////////////////////////////////////// void Player_PickUpItem() { try { //First check if player allready is picking up an item if (Character.Action.PickUping) { //Get item information that the player has selected. WorldMgr.Items item = Helpers.GetInformation.GetWorldItem(Character.Action.Target); //Checks if (item == null) { Character.Action.PickUping = false; return; } //If the amount is lower then one if (item.amount < 1) { item.amount = 1; } //If not gold model if (item.Model > 3) { //Get our free slots byte slot = GetFreeSlot(); //If to low if (slot <= 12) { Character.Action.PickUping = false; client.Send(Packet.MoveItemError()); return; } //Else continue stop delete timer because its allready beeing removed. item.StopDeleteTimer(); //Remove the world item spawn Helpers.Manager.WorldItem.Remove(item); //Delete the global id GenerateUniqueID.Delete(item.UniqueID); //Move towards the item Send(Packet.StopMovement(new ObjData.vektor(Character.Information.UniqueID, (float)Formule.packetx((float)item.x, item.xSec), (float)Character.Position.z, (float)Formule.packety((float)(float)item.y, item.ySec), Character.Position.xSec, Character.Position.ySec))); //Send animation packet pickup Send(Packet.Pickup_Animation(Character.Information.UniqueID, 0)); //Check what item type we have (Etc, or armor / weapon). int amount = 0; //Set amount or plusvalue #region Amount definition if (ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.BLADE || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.CH_SHIELD || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_SHIELD || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.BOW || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_AXE || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_CROSSBOW || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_DAGGER || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_DARKSTAFF || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_HARP || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_STAFF || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_SWORD || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_TSTAFF || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EU_TSWORD || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.GLAVIE || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.SPEAR || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.SWORD || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.EARRING || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.RING || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.NECKLACE || ObjData.Manager.ItemBase[item.Model].Type == ObjData.item_database.ArmorType.ARMOR || ObjData.Manager.ItemBase[item.Model].Type == ObjData.item_database.ArmorType.GARMENT || ObjData.Manager.ItemBase[item.Model].Type == ObjData.item_database.ArmorType.GM || ObjData.Manager.ItemBase[item.Model].Type == ObjData.item_database.ArmorType.HEAVY || ObjData.Manager.ItemBase[item.Model].Type == ObjData.item_database.ArmorType.LIGHT || ObjData.Manager.ItemBase[item.Model].Type == ObjData.item_database.ArmorType.PROTECTOR || ObjData.Manager.ItemBase[item.Model].Itemtype == ObjData.item_database.ItemType.AVATAR || ObjData.Manager.ItemBase[item.Model].Type == ObjData.item_database.ArmorType.ROBE) { amount = item.PlusValue; } else { amount = item.amount; } #endregion //Send item creation packet client.Send(Packet.CREATEITEM(0, slot, item.Model, (short)amount, (int)ObjData.Manager.ItemBase[item.Model].Defans.Durability, ObjData.Manager.ItemBase[item.Model].ID, item.UniqueID)); //Save to database AddItem(item.Model, (short)amount, slot, Character.Information.CharacterID, item.Model); } //If the item is gold else { //Remove the spawned item Helpers.Manager.WorldItem.Remove(item); //Remove global id GenerateUniqueID.Delete(item.UniqueID); //Movement packet Send(Packet.StopMovement(new ObjData.vektor(Character.Information.UniqueID, (float)Formule.packetx((float)item.x, item.xSec), (float)Character.Position.z, (float)Formule.packety((float)(float)item.y, item.ySec), Character.Position.xSec, Character.Position.ySec))); //Send animation packet Send(Packet.Pickup_Animation(Character.Information.UniqueID, 0)); //Add gold to player information Character.Information.Gold += item.amount; //Send visual packet for gold client.Send(Packet.UpdateGold(Character.Information.Gold)); //Send message packet gold gained client.Send(Packet.GoldMessagePick(item.amount)); //Save player gold SaveGold(); } //Despawn item for us item.DeSpawnMe(); //Dispose of the item item.Dispose(); //Set picking to false Character.Action.PickUping = false; if (Timer.Pickup != null) { Timer.Pickup.Dispose(); } } } catch (Exception ex) { Console.WriteLine("Pickup Error {0}", ex); Log.Exception(ex); } }