Exemplo n.º 1
0
        public void DoWhisper()
        {
            LogLine("Enter name of player to whisper, or enter 'Q' to go back.", LogLevel.Detail);
            Log("To: ");
            var target = Game.UI.ReadLine();

            if (target == "Q")
            {
                return;
            }

            Log("Message: ");
            var message = Game.UI.ReadLine();

            var response = new OutPacket(WorldCommand.CMSG_MESSAGECHAT);

            response.Write((uint)ChatMessageType.Whisper);
            var race     = Game.World.SelectedCharacter.Race;
            var language = race.IsHorde() ? Language.Orcish : Language.Common;

            response.Write((uint)language);
            response.Write(target.ToCString());
            response.Write(message.ToCString());
            Game.SendPacket(response);

            //! Print on WhisperInform message
        }
Exemplo n.º 2
0
        protected void HandleMessage(InPacket packet)
        {
            var    chatType     = (Client.Chat.Definitions.ChatMessageType)packet.ReadByte();
            var    language     = (Client.Chat.Definitions.Language)packet.ReadInt32();
            UInt64 senderGuid   = packet.ReadUInt64();
            var    unkInt       = packet.ReadUInt32();
            var    receiverGuid = packet.ReadUInt64();
            UInt32 messageLen   = packet.ReadUInt32();
            string message      = packet.ReadCString();

            Console.WriteLine(chatType + "." + language + "." + senderGuid + "." + message);
            if (message == "heal")
            {
                var response = new OutPacket(WorldCommand.CMSG_CAST_SPELL);
                response.Write((Byte)1);
                response.Write((UInt32)2050);
                response.Write((Byte)0x00000000);
                response.Write((UInt32)0x00000000);

                SendPacket(response);
                Console.WriteLine("SendPacket Heal!");
            }
            else if (message == "targetme")
            {
                TargetLeader();
            }
        }
Exemplo n.º 3
0
        public void DoTextEmote(TextEmote emote)
        {
            var packet = new OutPacket(NetworkOperationCode.CMSG_TEXT_EMOTE);

            packet.Write((uint)emote);
            packet.Write((uint)0);
            packet.Write((ulong)0);
            SendPacket(packet);
        }
Exemplo n.º 4
0
        public void DoWhisperReply()
        {
            if (Game.World.LastWhisperers.Count == 0)
            {
                return;
            }

            var target = Game.World.LastWhisperers.Peek();

            LogLine("Hit <TAB> to cycle trough last whisperers, hit <ENTER> to select current recipient, hit <ESCAPE> to return.", LogLevel.Detail);
            LogLine(String.Format("To: {0}", target));
            while (true)
            {
                ConsoleKeyInfo key = Game.UI.ReadKey();
                switch (key.Key)
                {
                case ConsoleKey.Enter:
                    goto cont;

                case ConsoleKey.Tab:
                    //! To do: maybe a more efficient way for this:
                    var previous = Game.World.LastWhisperers.Dequeue();
                    Game.World.LastWhisperers.Enqueue(previous);
                    target = Game.World.LastWhisperers.Peek();
                    if (target != previous)
                    {
                        LogLine(String.Format("To: {0}", target));
                    }
                    continue;

                case ConsoleKey.Escape:
                    return;

                default:
                    continue;
                }
            }

cont:
            Log("Message: ");
            var message = Game.UI.ReadLine();

            var response = new OutPacket(WorldCommand.CMSG_MESSAGECHAT);

            response.Write((uint)ChatMessageType.Whisper);
            var race     = Game.World.SelectedCharacter.Race;
            var language = race.IsHorde() ? Language.Orcish : Language.Common;

            response.Write((uint)language);
            response.Write(target.ToCString());
            response.Write(message.ToCString());
            Game.SendPacket(response);

            //! Print on WhisperInform message
        }
Exemplo n.º 5
0
        public void DoWhisperChat(string message, string player)
        {
            var response = new OutPacket(NetworkOperationCode.CMSG_MESSAGECHAT);

            response.Write((uint)ChatMessageType.Whisper);
            var race     = World.SelectedCharacter.Race;
            var language = race.IsHorde() ? Language.Orcish : Language.Common;

            response.Write((uint)language);
            response.Write(player.ToCString());
            response.Write(message.ToCString());
            SendPacket(response);
        }
Exemplo n.º 6
0
        public void PresentCharacterList(Character[] characterList)
        {
            World.SelectedCharacter = characterList[Character];
            OutPacket packet = new OutPacket(WorldCommand.CMSG_PLAYER_LOGIN);

            packet.Write(World.SelectedCharacter.GUID);
            SendPacket(packet);
            LoggedIn = true;
        }
Exemplo n.º 7
0
        public override void PresentCharacterList(Character[] characterList)
        {
            World.SelectedCharacter = characterList[Character];
            OutPacket packet = new OutPacket(NetworkOperationCode.CMSG_PLAYER_LOGIN);

            packet.Write(World.SelectedCharacter.GUID);
            SendPacket(packet);
            LoggedIn    = true;
            Player.GUID = World.SelectedCharacter.GUID;
        }
Exemplo n.º 8
0
        protected void HandleMoveTeleportAck(InPacket packet)
        {
            var packGuid = packet.ReadPackedGuid();

            packet.ReadUInt32();
            var movementFlags      = packet.ReadUInt32();
            var extraMovementFlags = packet.ReadUInt16();
            var time = packet.ReadUInt32();

            Player.X = packet.ReadSingle();
            Player.Y = packet.ReadSingle();
            Player.Z = packet.ReadSingle();
            Player.O = packet.ReadSingle();

            CancelActionsByFlag(ActionFlag.Movement, false);

            OutPacket result = new OutPacket(NetworkOperationCode.MSG_MOVE_TELEPORT_ACK);

            result.WritePacketGuid(Player.GUID);
            result.Write((UInt32)0);
            result.Write(time);
            SendPacket(result);
        }
Exemplo n.º 9
0
    public void EnterWorldFun()
    {
        OutPacket packet = new OutPacket(WorldCommand.CMSG_PLAYER_LOGIN);

        packet.Write(Exchange.SelectedCharacter.GUID);
        Exchange.gameClient.SendPacket(packet);
        Exchange.playerIsInGame = true;
        UnityEngine.GameObject.Find("GameObject").name = Exchange.SelectedCharacter.GUID.ToString();
        UnityEngine.GameObject.Find(Exchange.SelectedCharacter.GUID.ToString()).GetComponent <Transform>().position = new Vector3(Exchange.SelectedCharacter.X, Exchange.SelectedCharacter.Z, Exchange.SelectedCharacter.Y);
        Destroy(UnityEngine.GameObject.Find("CharacterUI"));
        Destroy(UnityEngine.GameObject.Find("MainLogo"));

        var PlayerUIframe = Resources.Load("PlayerUI") as UnityEngine.GameObject;

        UnityEngine.GameObject PlayerUI = Instantiate(PlayerUIframe, new Vector3(PlayerUIframe.transform.position.x, PlayerUIframe.transform.position.y, PlayerUIframe.transform.position.z), Quaternion.identity);
        PlayerUI.transform.SetParent(UnityEngine.GameObject.Find("Canvas").gameObject.transform, false);
        PlayerUI.transform.localScale = new Vector3(1, 1, 1);
        PlayerUI.name = "PlayerUI";
    }
Exemplo n.º 10
0
    public void setTarget(WorldObject obj)
    {
        if (UnityEngine.GameObject.Find("targetFrame"))
        {
            Destroy(UnityEngine.GameObject.Find("targetFrame"));
        }

        Exchange.gameClient.Player.Target = obj;

        var frame = Resources.Load("targetFrame") as UnityEngine.GameObject;

        UnityEngine.GameObject targetFrame = Instantiate(frame, new Vector3(frame.transform.position.x, frame.transform.position.y, 0), Quaternion.identity);
        targetFrame.transform.SetParent(UnityEngine.GameObject.Find("Canvas").gameObject.transform, false);
        targetFrame.transform.localScale = new Vector3(1, 1, 1);
        targetFrame.name = "targetFrame";

        Transform[] ts = targetFrame.transform.GetComponentsInChildren <Transform>(true);
        foreach (Transform t in ts)
        {
            if (t.gameObject.name == "targetName")
            {
                Text temo = t.gameObject.GetComponent <Text>();
                temo.text = obj.Name;
            }

            if (obj is Unit)
            {
                Unit unit = obj as Unit;
                if (t.gameObject.name == "targetLevel")
                {
                    Text temo = t.gameObject.GetComponent <Text>();
                    if (obj is Unit)
                    {
                        temo.text = unit.Level.ToString();
                    }
                }

                if (t.gameObject.name == "targetHealth")
                {
                    Text temp = t.gameObject.GetComponent <Text>();
                    temp.text = unit.Health.ToString();
                }
            }

            if (obj is Player)
            {
                Player player = obj as Player;
                if (t.gameObject.name == "targetLevel")
                {
                    Text temo = t.gameObject.GetComponent <Text>();
                    temo.text = player.Level.ToString();
                }

                if (t.gameObject.name == "targetHealth")
                {
                    Text temp = t.gameObject.GetComponent <Text>();
                    temp.text = player.Health.ToString();
                }
            }
        }

        var packet = new OutPacket(WorldCommand.CMSG_SET_SELECTION);

        packet.Write(obj.GUID);
        Exchange.gameClient.SendPacket(packet);
    }
Exemplo n.º 11
0
        public void PresentCharacterList(Character[] characterList)
        {
            LogLine("\n\tName\tLevel Class Race");

            int index = 0;

            foreach (Character character in characterList)
            {
                LogLine
                (
                    string.Format("{4}\t{0}\t{1} {2} {3}",
                                  character.Name,
                                  character.Level,
                                  character.Race,
                                  character.Class,
                                  index++)
                );
            }

            if (characterList.Length < 10)
            {
                LogLine(string.Format("{0}\tCreate a new character. (NOT YET IMPLEMENTED)", index));
            }

            int length = characterList.Length == 10 ? 10 : (characterList.Length + 1);

            index = Settings.Default.CharID;

            while (index > length || index < 0)
            {
                Log("Choose a character:  ");
                if (!int.TryParse(Console.ReadLine(), out index))
                {
                    LogLine();
                }
            }

            if (index < characterList.Length)
            {
                Game.World.SelectedCharacter = characterList[index];
                // TODO: enter world

                if (Settings.Default.LagServer == 0)
                {
                    LogLine(string.Format("Entering pseudo-world with character {0}", Game.World.SelectedCharacter.Name));

                    OutPacket packet = new OutPacket(WorldCommand.CMSG_PLAYER_LOGIN);
                    packet.Write(Game.World.SelectedCharacter.GUID);
                    Game.SendPacket(packet);
                }
                else
                {
                    LogLine(string.Format("Entering lag mode with character {0}", Game.World.SelectedCharacter.Name));


                    for (ulong i = 0; i < Settings.Default.LagServer; ++i)
                    {
                        OutPacket packet1 = new OutPacket(WorldCommand.CMSG_CHAR_CUSTOMIZE);
                        packet1.Write(Game.World.SelectedCharacter.GUID);
                        packet1.Write(Game.World.SelectedCharacter.Name);
                        packet1.Write(0);
                        packet1.Write(0);
                        packet1.Write(0);
                        packet1.Write(0);
                        packet1.Write(0);
                        packet1.Write(0);
                        Game.SendPacket(packet1);

                        //Thread.Sleep(1000);

                        OutPacket keelpack = new OutPacket(WorldCommand.ClientEnumerateCharacters);
                        Game.SendPacket(keelpack);

                        //Thread.Sleep(1000);
                    }
                }
            }
            else
            {
                // TODO: character creation
            }
        }
Exemplo n.º 12
0
        private void SendPacket(OutPacket packet)
        {
            Opcode packet_opcode = this.GetOpcode(packet.GetType());

            base.Send((byte)packet_opcode, packet.Write());
        }
Exemplo n.º 13
0
            private void HandleUpdateData()
            {
                if (guid == game.Player.GUID)
                {
                    foreach (var pair in updateFields)
                    {
                        game.Player[pair.Key] = pair.Value;
                    }
                }
                else
                {
                    switch (updateType)
                    {
                    case ObjectUpdateType.UPDATETYPE_VALUES:
                    {
                        WorldObject worldObject = game.Objects[guid];
                        foreach (var pair in updateFields)
                        {
                            worldObject[pair.Key] = pair.Value;
                        }
                        break;
                    }

                    case ObjectUpdateType.UPDATETYPE_MOVEMENT:
                    {
                        if (movementInfo != null)
                        {
                            WorldObject worldObject = game.Objects[guid];
                            worldObject.Set(movementInfo.Position);
                            worldObject.O = movementInfo.O;
                        }
                        break;
                    }

                    case ObjectUpdateType.UPDATETYPE_CREATE_OBJECT:
                    case ObjectUpdateType.UPDATETYPE_CREATE_OBJECT2:
                    {
                        WorldObject worldObject = new WorldObject();
                        worldObject.GUID = guid;
                        if (movementInfo != null)
                        {
                            worldObject.Set(movementInfo.Position);
                            worldObject.O = movementInfo.O;
                        }
                        worldObject.MapID = game.Player.MapID;
                        foreach (var pair in updateFields)
                        {
                            worldObject[pair.Key] = pair.Value;
                        }

#if DEBUG
                        if (game.Objects.ContainsKey(guid))
                        {
                            game.Log($"{updateType} called with guid 0x{guid:X} already added", LogLevel.Debug);
                        }
#endif
                        game.Objects[guid] = worldObject;

                        if (worldObject.GUID.isType(HighGuid.Player))
                        {
                            OutPacket nameQuery = new OutPacket(NetworkOperationCode.CMSG_NAME_QUERY);
                            nameQuery.Write(guid);
                            game.SendPacket(nameQuery);
                        }
                        break;
                    }

                    default:
                        break;
                    }
                }

                foreach (var outOfRangeGuid in outOfRangeGuids)
                {
                    WorldObject worldObject;
                    if (game.Objects.TryGetValue(outOfRangeGuid, out worldObject))
                    {
                        worldObject.ResetPosition();
                        game.Objects.Remove(outOfRangeGuid);
                    }
                }
            }