Exemplo n.º 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);
                }
            }
        }
Exemplo n.º 2
0
        public static RoomTile GetNearestRoomTile(Point3D currentPoint, Point targetPoint, Room room, RoomUnit unit, bool calcDiagonal, bool walktrought)
        {
            double distance = DreamPathfinder.GetDistance(currentPoint.XY, targetPoint);

            RoomTile to   = null;
            RoomTile from = unit.CurrentTile;

            for (int i = 0; i < (calcDiagonal ? 8 : 4); i++)
            {
                Point direction = DreamPathfinder.Directions[i];

                RoomTile     testTile = room.RoomGamemapManager.GetTile(currentPoint.X + direction.X, currentPoint.Y + direction.Y);
                RoomUnitUser user     = unit as RoomUnitUser;
                if (testTile != null && ((user?.Override ?? false) || ((testTile.GetZ(true) - currentPoint.Y) <= 2.0)))
                {
                    bool targetTile = targetPoint.X == testTile.X && targetPoint.Y == testTile.Y;
                    if (!targetTile && (testTile.IsBed || testTile.IsSeat))
                    {
                        continue;
                    }

                    if (testTile.IsInUse && (targetTile || !walktrought)) //user is in the tile
                    {
                        continue;
                    }

                    if (!user?.Override ?? false)
                    {
                        if (testTile.HigestRoomItem is RoomItemHorseObstacle obstacle)
                        {
                            RoomItemHorseObstacle lastObstacle = from.HigestRoomItem as RoomItemHorseObstacle;
                            if (lastObstacle == null || lastObstacle.ID != obstacle.ID || i == 0 || i == 2 || i == 4 || i == 6)
                            {
                                if (obstacle.IsMiddlePart(testTile.X, testTile.Y)) //trying to enter middle part
                                {
                                    if (lastObstacle == null || lastObstacle.ID != obstacle.ID || lastObstacle.IsMiddlePart(from.X, from.Y))
                                    {
                                        continue;
                                    }
                                    else
                                    {
                                        if (!(testTile.X == targetPoint.X && testTile.Y == targetPoint.Y)) //middle ISINT the target tile
                                        {
                                            if (unit is RoomPet pet && pet.Rider != null)
                                            {
                                                if (pet.PetData.Type != 13 || pet.PetData.Energy < 3)
                                                {
                                                    continue;
                                                }
                                            }
                                            else
                                            {
                                                continue;
                                            }
                                        }
                                        else
                                        {
                                            continue;
                                        }
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        else if (testTile.HigestRoomItem is RoomItemSkateboardRail)
                        {
                            if (user?.ActiveEffect != 71)
                            {
                                continue;
                            }
                        }
                        else
                        {
                            if (testTile.ModelItemState == ModelItemState.LOCKED || testTile.IsHole || testTile.ItemsOnTile.Get(typeof(RoomItemBlackHole)).Count > 0) //item logic blocking to move to that tile skip the tile
                            {
                                continue;
                            }
                        }
                    }

                    double tileDistance = DreamPathfinder.GetDistance(testTile.X, testTile.Y, targetPoint.X, targetPoint.Y);
                    if (distance > tileDistance)
                    {
                        distance = tileDistance;
                        to       = testTile;
                    }
                }