Пример #1
0
        public void HandleBotAction(BotAction action)
        {
            this.Unidle();

            if (action.Action == "setname")
            {
                this.Data.Name = action.Value;

                if (action.Tick != -1)
                {
                    this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.SetRoomUser, new ValueHolder("RoomUser", new List <RoomUnit>()
                    {
                        this
                    })));
                }
            }
            else if (action.Action == "setlook")
            {
                this.Data.Look = action.Value;

                if (action.Tick != -1)
                {
                    this.Update();
                }
            }
            else if (action.Action == "setmotto")
            {
                this.Data.Motto = action.Value;

                if (action.Tick != -1)
                {
                    this.Update();
                }
            }
            else if (action.Action == "setlocation")
            {
                string[] data = action.Value.Split(',');

                if (data.Length == 2)
                {
                    RoomTile tile = this.Room.RoomGamemapManager.GetTile(int.Parse(data[0]), int.Parse(data[1]));
                    if (tile != null)
                    {
                        this.SetLocation(int.Parse(data[0]), int.Parse(data[1]), tile.GetZ(true));
                    }
                    else
                    {
                        this.SetLocation(int.Parse(data[0]), int.Parse(data[1]), 0);
                    }
                }
                else
                {
                    this.SetLocation(int.Parse(data[0]), int.Parse(data[1]), double.Parse(data[2]));
                }
            }
            else if (action.Action == "setrotation")
            {
                this.SetRotation(int.Parse(action.Value), true);
            }
            else if (action.Action == "move")
            {
                string[] data = action.Value.Split(',');
                this.MoveTo(int.Parse(data[0]), int.Parse(data[1]));
            }
            else if (action.Action == "say")
            {
                this.Speak(TextUtilies.FormatString(action.Value, Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID)), false);
            }
            else if (action.Action == "whisper")
            {
                ServerMessage whisper = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
                whisper.Init(r63aOutgoing.Whisper);
                whisper.AppendInt32(this.VirtualID);
                whisper.AppendString(TextUtilies.FormatString(action.Value, Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID)));
                whisper.AppendInt32(0); //gesture
                whisper.AppendInt32(0); //links count
                this.Room.SendToAll(whisper);
            }
            else if (action.Action == "shout")
            {
                this.Speak(TextUtilies.FormatString(action.Value, Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID)), true);
            }
            else if (action.Action == "wave")
            {
                this.Room.SendToAll(new MultiRevisionServerMessage(OutgoingPacketsEnum.Wave, new ValueHolder("VirtualID", this.VirtualID)));
            }
            else if (action.Action == "effect")
            {
                this.ApplyEffect(int.Parse(action.Value));
            }
            else if (action.Action == "handitem")
            {
                this.SetHanditem(int.Parse(action.Value));
            }
            else if (action.Action == "leave")
            {
                GameClient roomOwner = Skylight.GetGame().GetGameClientManager().GetGameClientById(this.Room.RoomData.OwnerID);
                if (roomOwner != null)
                {
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("userId", roomOwner.GetHabbo().ID);
                        dbClient.ExecuteQuery("UPDATE users SET newbie_status = '2' WHERE id = @userId");
                    }
                    roomOwner.GetHabbo().NewbieStatus = 2;

                    Skylight.GetGame().GetAchievementManager().AddAchievement(roomOwner, "Graduate", 1);

                    this.Room.RoomUserManager.LeaveRoom(this);
                }
            }
        }