internal void DestroyObject(WorldObject obj) { if (m_objects[(int)OBJECTTYPE.PLAYER].Count > 0) { ServerPacket pkg = new ServerPacket(SMSG.OBJECT_DESTROY); pkg.Write(obj.GUID); pkg.Finish(); if (obj.ObjectType == OBJECTTYPE.PLAYER) { PlayerObject player = obj as PlayerObject; foreach (PlayerObject plr in m_objects[(int)OBJECTTYPE.PLAYER].Values) { pkg.AddDestination(plr.CharacterID); player.Inventory.SendDestroyInventory(plr.CharacterID); } } else { foreach (PlayerObject plr in m_objects[(int)OBJECTTYPE.PLAYER].Values) { pkg.AddDestination(plr.CharacterID); } } WorldServer.Send(pkg); } }
public static void ChangeMap(WorldClient client) { if (client.Player.MapTile == null) { return; } MapInstance map = GetMap(client.Player.WorldMapID); if (map == null) { WorldPacket pkg = new WorldPacket(WORLDMSG.CHANGE_MAP); pkg.Write(client.CharacterID); WorldServer.Send(pkg); client.LeaveWorld(); return; } else { client.Player.MapTile.Map.Leave(client.Player); client.Player.Continent = (uint)map.Continent; map.SetObjectPositionInBounds(client.Player); ServerPacket pkg = new ServerPacket(SMSG.NEW_WORLD); pkg.Write((byte)client.Player.Continent); pkg.WriteVector(client.Player.Position); pkg.Write(client.Player.Facing); pkg.Finish(); pkg.AddDestination(client.CharacterID); WorldServer.Send(pkg); } }
public void SendGroupList() { Console.WriteLine("Sending Group List"); for (uint i = 0; i < Size; i++) { ServerPacket grp = new ServerPacket(SMSG.GROUP_LIST); grp.Write((int)Size - 1); // Counter for (uint j = 0; j < Size; j++) { if (j != i) { grp.Write(Members[j].Name); // Member Name grp.Write(Members[j].GUID); // Member GUID grp.Write(Members[j].IsLeader); // Is Member Leader? } } grp.Write(LeaderGUID); // Leader GUID grp.Write(LootMethod); grp.Write(LootMasterName); grp.Write(LootMaster); // grp.Write((byte)0); // grp.Write(LootMaster); // Trying LootMaster GUID - Phaze grp.Finish(); grp.AddDestination(Members[i].CharacterID); WorldServer.Send(grp); } } //SendGroupList
public void LevelUp() { int maxhealth = this.MaxHealth; int maxpower = this.MaxPower; this.Level++; StatManager.CalculateNextLevelExp(this); this.Exp = 0; StatManager.CalculateNewStats(this); this.Health = this.MaxHealth; this.Power = this.MaxPower; UpdateData(); Save(); ServerPacket pkg = new ServerPacket(SMSG.LEVELUP_INFO); pkg.Write((uint)this.Level); pkg.Write((uint)(this.MaxHealth - maxhealth)); pkg.Write((uint)(this.MaxPower - maxpower)); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Write((uint)0); pkg.Finish(); pkg.AddDestination(this.CharacterID); WorldServer.Send(pkg); }
internal static void LoadScreen(WorldClient client) { ServerPacket pkg = new ServerPacket(SMSG.TRANSFER_PENDING); pkg.Write((int)0); pkg.Finish(); pkg.AddDestination(client.CharacterID); WorldServer.Send(pkg); }
public void Send(SMSG msgID, BinWriter data) { ServerPacket pkg = new ServerPacket(msgID); pkg.Write(data.GetBuffer(), 0, (int)data.BaseStream.Length); pkg.Finish(); pkg.AddDestination(m_character.ObjectId); WorldServer.Send(pkg); }
public void Send(SMSG msgID, byte[] data, int index, int count) { ServerPacket pkg = new ServerPacket(msgID); pkg.Write(data, index, count); pkg.Finish(); pkg.AddDestination(m_character.ObjectId); WorldServer.Send(pkg); }
public void SendToGroup(ServerPacket grp) { grp.Finish(); for (uint i = 0; i < Size; i++) { grp.AddDestination(Members[i].CharacterID); } WorldServer.Send(grp); }
public void Send(SMSG msgID, BinWriter data) { try { ServerPacket pkg = new ServerPacket(msgID); pkg.Write(data.GetBuffer(), 0, (int)data.BaseStream.Length); pkg.Finish(); pkg.AddDestination(m_character.ObjectId); WorldServer.Send(pkg); } catch (Exception exp) { DebugLogger.Logger.Log("", exp); } }
public void Send(SMSG msgID, byte[] data, int index, int count) { try { ServerPacket pkg = new ServerPacket(msgID); pkg.Write(data, index, count); pkg.Finish(); pkg.AddDestination(m_character.ObjectId); WorldServer.Send(pkg); } catch (Exception exp) { DebugLogger.Logger.Log("", exp); } }
static void System(string msg, uint to) { ServerPacket pkg = new ServerPacket(SMSG.MESSAGECHAT); pkg.Write((byte)CHATMESSAGETYPE.SYSTEM); pkg.Write((int)0); pkg.Write((ulong)0); pkg.Write(msg); pkg.Write((byte)0); pkg.Finish(); pkg.AddDestination(to); WorldServer.Send(pkg); }
public void SendDestroyInventory(uint toCharacterID) { for (int i = 0; i <= (int)INVSLOT.EQUIPPEDFIRST; i++) { if (m_slots[i] != 0) { ServerPacket pkg = new ServerPacket(SMSG.DESTROY_OBJECT); pkg.Write(m_slots[i]); pkg.Finish(); pkg.AddDestination(toCharacterID); WorldServer.Send(pkg); } } }
public void Send(ServerPacket pkg, Vector position, float range) { long pos = pkg.BaseStream.Position; foreach (MapTile tile in GetTilesInRange((int)position.X, (int)position.Y, (int)range)) { foreach (PlayerObject player in tile.GetObjects(OBJECTTYPE.PLAYER)) { if (position.Distance(player.Position) < range) { pkg.AddDestination(player.CharacterID); } } } if (pkg.BaseStream.Position > pos) { WorldServer.Send(pkg); } }
public override void UpdateData() { ServerPacket pkg = new ServerPacket(SMSG.UPDATE_OBJECT); pkg.Write(1); pkg.Write((byte)0); // A9 Fix by Phaze UpdateData(pkg, false, false); pkg.Finish(); if (MapTile != null) { MapTile.SendSurrounding(pkg, this); } ServerPacket pkg2 = new ServerPacket(SMSG.UPDATE_OBJECT); pkg2.Write(1); pkg2.Write((byte)0); // A9 Fix by Phaze UpdateData(pkg2, true, true); pkg2.Finish(); pkg2.AddDestination(this.CharacterID); WorldServer.Send(pkg2); }
public void GainXp(int exp, ulong targetguid) { ServerPacket pkg = new ServerPacket(SMSG.LOG_XPGAIN); pkg.Write(targetguid); pkg.Write((uint)exp); pkg.Write((byte)0); pkg.Write((ushort)exp); pkg.Write((byte)0); pkg.Write((byte)0); pkg.Finish(); pkg.AddDestination(this.CharacterID); WorldServer.Send(pkg); this.Exp += exp; this.UpdateData(); if (this.Exp >= this.NextLevelExp) { LevelUp(); } }
public void SendSurrounding(ServerPacket pkg, PlayerObject notPlayer) { bool send = false; foreach (MapTile tile in Adjacents) { if (tile != null) { foreach (PlayerObject player in tile.GetObjects(OBJECTTYPE.PLAYER)) { if (notPlayer.CharacterID != player.CharacterID) { send = true; pkg.AddDestination(player.CharacterID); } } } } if (send) { WorldServer.Send(pkg); } }
public void SendSurrounding(ServerPacket pkg) { bool send = false; foreach (MapTile tile in Adjacents) { if (tile != null) { ICollection Players = tile.GetObjects(OBJECTTYPE.PLAYER); if (Players.Count > 0) { send = true; foreach (PlayerObject player in Players) { pkg.AddDestination(player.CharacterID); } } } } if (send) { WorldServer.Send(pkg); } }
/// <summary> /// /// </summary> /// <param name="obj">Object to create for the players on this maptile</param> /// <param name="objCreationPkg">creation packet of obj</param> /// <returns>Returns true if there was any players to send objCreationPkg to</returns> internal bool CreateObject(WorldObject obj, ServerPacket objCreationPkg) { if (obj.ObjectType == OBJECTTYPE.PLAYER) { // we might want to change this incase there would be alot // of objects on a single maptile cause it could possibly // overgo the packet size limit (which is 0xFFFF or less, not sure) // and only send one at a time or X at a time. Hopefully we // won't have to since it's compressed... bool ret = false; BinWriter w = new BinWriter(); w.Write(0); int objcount = 0; for (int i = 0; i < (int)OBJECTTYPE.PLAYER; i++) { if (m_objects[i].Count > 0) { objcount += m_objects[i].Count; foreach (WorldObject anObject in m_objects[i].Values) { anObject.AddCreateObject(w, false, true); } } } if (m_objects[(int)OBJECTTYPE.PLAYER].Count > 0) { ret = true; objcount += m_objects[(int)OBJECTTYPE.PLAYER].Count; foreach (PlayerObject plr in m_objects[(int)OBJECTTYPE.PLAYER].Values) { objCreationPkg.AddDestination(plr.CharacterID); plr.AddCreateObject(w, false, true); objcount += plr.Inventory.AddCreateInventory(w, false); } } for (int i = ((int)OBJECTTYPE.PLAYER) + 1; i < (int)OBJECTTYPE.MAX; i++) { if (m_objects[i].Count > 0) { objcount += m_objects[i].Count; foreach (WorldObject anObject in m_objects[i].Values) { anObject.AddCreateObject(w, false, true); } } } if (objcount > 0) { w.Set(0, objcount); ServerPacket pkg = new ServerPacket(SMSG.COMPRESSED_UPDATE_OBJECT); byte[] compressed = ZLib.Compress(w.GetBuffer(), 0, (int)w.BaseStream.Length); pkg.Write((int)w.BaseStream.Length); pkg.Write(compressed); pkg.Finish(); pkg.AddDestination((obj as PlayerObject).CharacterID); WorldServer.Send(pkg); } return(ret); } else { if (m_objects[(int)OBJECTTYPE.PLAYER].Count > 0) { foreach (PlayerObject plr in m_objects[(int)OBJECTTYPE.PLAYER].Values) { objCreationPkg.AddDestination(plr.CharacterID); } return(true); } return(false); } }