Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
 public void LeaveWorld()
 {
     try {
         this.Player.InWorld = false;
         if (m_player.Group != null)
         {
             if (m_player.IsLeader || m_player.Group.Size < 3)
             {
                 m_player.Group.Destroy();
             }
             else
             {
                 m_player.Group.RemoveMember(m_player.Name);
             }
         }
         ChannelManager.Deconnection(this);
         m_player.SaveAndRemove();
         WorldServer.RemoveClient(this);
         WorldPacket pkg = new WorldPacket(WORLDMSG.PLAYER_LEAVE_WORLD);
         pkg.Write(m_character.ObjectId);
         WorldServer.Send(pkg);
     } catch (Exception exp) {
         DebugLogger.Logger.Log("", exp);
     }
 }
Ejemplo n.º 3
0
        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 bool Invite(WorldClient client, string name)
        {
            try
            {
                WorldClient t_client = (WorldClient)(WorldServer.GetClientByName(name));
                if (t_client != null)
                {
                    if (!Users.Contains(t_client))
                    {
                        BinWriter w = new BinWriter();
                        w.Write((byte)CHANNEL.INVITE);
                        w.Write((string)name);
                        w.Write(client.Player.GUID);
                        t_client.Send(SMSG.CHANNEL_NOTIFY, w);

                        Join(t_client);
                    }
                    else
                    {
                        BinWriter w = new BinWriter();
                        w.Write((byte)CHANNEL.ALREADYON);
                        w.Write((string)name);
                        w.Write(t_client.Player.GUID);
                        client.Send(SMSG.CHANNEL_NOTIFY, w);
                    }
                    return(true);
                }
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine("Channel Exception (Invite): " + e.Message);
                return(false);
            }
        }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        static void OnGroupCreate(WORLDMSG msgID, BinReader data)
        {
            uint        charID   = data.ReadUInt32();
            WorldClient client   = WorldServer.GetClientByCharacterID(charID);
            uint        leaderID = data.ReadUInt32();
            WorldClient leader   = WorldServer.GetClientByCharacterID(leaderID);

            if (leader == null)
            {
                Console.WriteLine("Leader not found");
                return;
            }

            if (leader.Player.Group == null)
            {
                leader.Player.Group = new GroupObject(client.Player, leader.Player);
            }
            else
            {
                for (uint i = 0; i < leader.Player.Group.Size; i++)
                {
                    if (leader.Player.Group.Members[i].CharacterID == charID)
                    {
                        return;
                    }
                }
                leader.Player.Group.AddMember(client.Player);
            }

            client.Player.Group            = leader.Player.Group;
            leader.Player.IsLeader         = true;
            client.Player.Group.LeaderGUID = leader.Player.GUID;
            client.Player.Group.SendGroupList();
        }
Ejemplo n.º 7
0
        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
Ejemplo n.º 8
0
        public WorldClient(DBCharacter character)
        {
            m_character = character;
            m_player    = WorldServer.Scripts.GetNewPlayerObject(character);

            WorldServer.AddClient(this);
        }
Ejemplo n.º 9
0
            public CombatEvent(PlayerObject player) : base(TimeSpan.FromMilliseconds(1))
            {
                aclient = WorldServer.GetClientByCharacterID((uint)player.GUID);
                aclient.Player.LastPosition = aclient.Player.Position;

                //target = (LivingObject)ObjectManager.GetWorldObjectByGUID(aclient.Player.Target);
                //Console.WriteLine("New combat event attacker: " + player.Name + " -> " + target.Name);
            }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        public void LeaveWorld()
        {
            m_player.SaveAndRemove();
            WorldServer.RemoveClient(this);
            WorldPacket pkg = new WorldPacket(WORLDMSG.PLAYER_LEAVE_WORLD);

            pkg.Write(m_character.ObjectId);
            WorldServer.Send(pkg);
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
 public void SendToGroup(ServerPacket grp)
 {
     grp.Finish();
     for (uint i = 0; i < Size; i++)
     {
         grp.AddDestination(Members[i].CharacterID);
     }
     WorldServer.Send(grp);
 }
Ejemplo n.º 15
0
        public override void FireEvent()
        {
            // Mob has changed target
            if (this.currenttarget != mob.Target)
            {
                client = (WorldClient)WorldServer.GetClientByCharacterID((uint)this.mob.Target);
                if (client == null)
                {
                    this.mob.StopCombat();
                }
                else
                {
                    this.currenttarget = mob.Target;
                }
            }
            //Console.WriteLine("ChasingEvent.FireEvent (" + (client != null ? client.Player.Name : "") + "): " + mob.Name);

            if (client != null && client.Player.InWorld && !client.Player.Dead && !mob.Dead)
            {
                try
                {
                    float distance = client.Player.Position.Distance(mob.Position);
                    //				if(distance > 4)
                    //				{
                    int          time = (int)((distance / mob.RunningSpeed) * 1000);
                    ServerPacket pkg  = new ServerPacket(SMSG.MONSTER_MOVE);
                    pkg.Write((char)0xFF);
                    pkg.Write(mob.GUID);
                    pkg.WriteVector(mob.Position);
                    pkg.Write(mob.Facing);
                    pkg.Write((byte)0);
                    pkg.Write(0x100);
                    pkg.Write(time);
                    pkg.Write(1);
                    if (client != null && client.Player != null)
                    {
                        mob.Position.Translate(client.Player.Position, 1.5f - (client.Player.Position.Distance(client.Player.LastPosition) * 0.5f));
                    }

                    pkg.Write(mob.Position.X);
                    pkg.Write(mob.Position.Y);
                    pkg.Write(mob.Position.Z);
                    pkg.Finish();
                    mob.MapTile.SendSurrounding(pkg);
                    mob.UpdateData();
                    client.Player.UpdateData();
                }
                catch (Exception exp)
                {
                    DebugLogger.Logger.Log("", exp);
                }
                //				eventTime = DateTime.Now.Add(TimeSpan.FromSeconds(1));
                //				EventManager.AddEvent(this);
            }
        }
Ejemplo n.º 16
0
 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);
     }
 }
Ejemplo n.º 17
0
        static void OnPlayerLeaveWorld(WORLDMSG msgID, BinReader data)
        {
            uint        id     = data.ReadUInt32();
            WorldClient client = WorldServer.GetClientByCharacterID(id);

            if (client == null)
            {
                Console.WriteLine("Failed to leave world. Client didn't exist on worldserver.");
                return;
            }
            client.LeaveWorld();
        }
Ejemplo n.º 18
0
        public static ulong NextGUID()
        {
            ulong guid = m_currentGUID++;

            if (m_currentGUID == m_currentMax)
            {
                m_currentGUID = (ulong)m_guidpool.Dequeue();
                m_currentMax  = (ulong)m_guidpool.Dequeue();
                WorldServer.Send(new WorldPacket(WORLDMSG.ACQUIRE_GUIDS));
            }
            return(guid);
        }
Ejemplo n.º 19
0
 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);
     }
 }
Ejemplo n.º 20
0
        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);
        }
Ejemplo n.º 21
0
        public void updateTime()
        {
            BinWriter w = new BinWriter();

            w.Write(WorldClock.GetTimeStamp());
            WorldServer.GetClientByCharacterID((uint)this.GUID).Send(SMSG.GAMETIME_UPDATE, w);

            /*		//BinWriter w = LoginClient.NewPacket(SMSG.LOGIN_SETTIMESPEED);
             *                      /*w.Write((float)0);
             *                      w.Write((int)0);*/
            /*w.Write((byte)1);
             * w.Write((byte)1);
             * w.Write((byte)1);
             * w.Write((byte)1);
             * w.Write((byte)1);
             * w.Write((byte)1);
             * w.Write((byte)1);
             * w.Write((byte)1);
             * Send(w);
             *
             * DateTime time = WorldServer.m_clock.time;	//Moved this code to WorldClock, so I could use the timestamp in other places.
             * uint timeSeq = 0;
             *
             * // 4 bytes of packed time data.  the bits are:
             * // high 2 bits - unknown
             * timeSeq|=(uint)0;
             * // next 5 bits - year
             * timeSeq<<=5;
             * timeSeq|=(uint)1;
             * // next 4 bits - month
             * timeSeq<<=4;
             * timeSeq|=(uint)time.Month;
             * // next 7 bits - day of month
             * timeSeq<<=7;
             * timeSeq|=(uint)time.Day;
             * // next 3 bits - day of week
             * timeSeq<<=3;
             * timeSeq|=(uint)time.DayOfWeek;
             * // next 5 bits - hours
             * timeSeq<<=5;
             * timeSeq|=(uint)((time.Hour==0) ? 24 : time.Hour );
             * // low 6 bits  - minutes
             * timeSeq<<=6;
             * timeSeq|=(uint)time.Minute;
             *
             * BinWriter w = new BinWriter();
             * w.Write(timeSeq);
             * WorldServer.GetClientByCharacterID((uint)this.GUID).Send(SMSG.GAMETIME_UPDATE,w);
             */
        }
Ejemplo n.º 22
0
 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);
         }
     }
 }
Ejemplo n.º 23
0
        public static void DeleteDBObject(DBObject obj)
        {
            if (obj.PendingCreate)
            {
                obj.PendingDelete = true;
                return;
            }
            RemoveDBObject(obj);
            WorldPacket pkg = new WorldPacket(WORLDMSG.DELETE_DBOBJECT);

            pkg.Write(obj.GetType().ToString());
            pkg.Write(obj.ObjectId);
            WorldServer.Send(pkg);
        }
Ejemplo n.º 24
0
        public static void CreateDBObject(DBObject obj)
        {
            if (obj.PendingCreate)
            {
                return;
            }
            obj.PendingCreate = true;
            int id = currentRequestID++;

            createDBRequests[id] = obj;
            WorldPacket pkg = new WorldPacket(WORLDMSG.CREATE_DBOBJECT);

            pkg.Write(id);
            pkg.Write(obj.GetType().ToString());
            WorldServer.Send(pkg);
        }
Ejemplo n.º 25
0
        public static ulong NextGUID()
        {
            ulong guid = m_currentGUID++;

            try {
                if (m_currentGUID == m_currentMax)
                {
                    m_currentGUID = (ulong)m_guidpool.Dequeue();
                    m_currentMax  = (ulong)m_guidpool.Dequeue();
                    WorldServer.Send(new WorldPacket(WORLDMSG.ACQUIRE_GUIDS));
                }
            } catch (Exception exp) {
                DebugLogger.Log("", exp);
            }
            return(guid);
        }
Ejemplo n.º 26
0
        public override void FireEvent()
        {
            m_clock.time = m_clock.time.AddMinutes(1);

            // Temp massive update, when I could change speed time client based,
            // we just have to sync it with save char.
            System.Collections.IDictionaryEnumerator EnumClients;
            EnumClients = WorldServer.GetClientsEnum();
            while (EnumClients.MoveNext())
            {
                if (((WorldClient)(EnumClients.Value)).Player.InWorld)
                {
                    ((WorldClient)(EnumClients.Value)).Player.updateTime();
                }
            }
            eventTime = DateTime.Now.AddSeconds(60 / m_clock.SpeedRatio);
            EventManager.AddEvent(this);
        }
Ejemplo n.º 27
0
        public static void SaveDBObject(DBObject obj)
        {
            if (obj.Dirty == false)
            {
                return;
            }
            if (obj.PendingCreate)
            {
                obj.PendingSave = true;
                return;
            }
            WorldPacket pkg = new WorldPacket(WORLDMSG.DESERIALIZE_OBJ);

            pkg.Write(obj.GetType().ToString());
            pkg.Write(obj.ObjectId);
            obj.Serialize(pkg);
            WorldServer.Send(pkg);
            obj.Dirty = false;
        }
Ejemplo n.º 28
0
        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);
            }
        }
Ejemplo n.º 29
0
        public void Enter(WorldObject obj)
        {
            MapTile mapTile = GetTileByLoc(obj.Position);

            obj.MapTile = mapTile;
            ServerPacket pkg  = MakeCreatePacket(obj);
            bool         send = false;

            foreach (MapTile tile in mapTile.Adjacents)
            {
                if (tile != null)
                {
                    send |= tile.CreateObject(obj, pkg);
                }
            }
            if (send)
            {
                WorldServer.Send(pkg);
            }
            mapTile.EnterTile(obj);
        }
Ejemplo n.º 30
0
        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);
        }