Exemple #1
0
        public void OnRoomCycle()
        {
            if (this.Rider == null)
            {
                if (this.ActionTick > 0)
                {
                    if (--this.ActionTick <= 0)
                    {
                        this.EndAction();
                    }
                }
                else
                {
                    if (--this.NextActionTick <= 0)
                    {
                        int x = RandomUtilies.GetRandom(0, this.Room.RoomGamemapManager.Model.MaxX);
                        int y = RandomUtilies.GetRandom(0, this.Room.RoomGamemapManager.Model.MaxY);
                        this.MoveTo(x, y);
                        this.PetData.NeedUpdate = true; //bcs we moved

                        this.NextActionTick = this.GetRandom().Next(10, 60);
                    }
                }
            }

            if (--this.NextEnergyTick <= 0)
            {
                if (this.PetData.Energy < this.PetData.MaxEnergy)
                {
                    this.PetData.Energy++;
                }

                this.NextEnergyTick = this.EnergyTick;
            }
        }
        public override void OnCycle()
        {
            if (this.UpdateNeeded)
            {
                this.UpdateTimer--;
                if (this.UpdateTimer <= 0)
                {
                    this.UpdateNeeded = false;

                    if (this.ExtraData == "0")
                    {
                        this.ExtraData = RandomUtilies.GetRandom(1, 4).ToString();
                        this.UpdateState(false, true);
                        this.DoUpdate(20);
                    }
                    else
                    {
                        if (this.ExtraData != "-1")
                        {
                            this.ExtraData = "-1";
                            this.UpdateState(false, true);
                        }
                    }
                }
            }
        }
 public void Hit(RoomUnitUser user, bool left)
 {
     if (user.WSPlayer.LeftSide)
     {
         if (user.WSPlayer.Location + 1 == this.RightUser.WSPlayer.Location)
         {
             this.RightUser.WSPlayer.Lean += left ? -10 - RandomUtilies.GetRandom().Next(0, 10) : 10 + RandomUtilies.GetRandom().Next(0, 10);
             this.RightUser.WSPlayer.HitsTakenTotal++;
             this.RightUser.WSPlayer.BeenHit = true;
         }
         else
         {
             user.WSPlayer.Lean += left ? -10 - RandomUtilies.GetRandom().Next(0, 10) : 10 + RandomUtilies.GetRandom().Next(0, 10);
         }
     }
     else
     {
         if (user.WSPlayer.Location - 1 == this.LeftUser.WSPlayer.Location)
         {
             this.LeftUser.WSPlayer.Lean -= left ? -10 - RandomUtilies.GetRandom().Next(0, 10) : 10 + RandomUtilies.GetRandom().Next(0, 10);
             this.LeftUser.WSPlayer.HitsTakenTotal++;
             this.LeftUser.WSPlayer.BeenHit = true;
         }
         else
         {
             user.WSPlayer.Lean += left ? -10 - RandomUtilies.GetRandom().Next(0, 10) : 10 + RandomUtilies.GetRandom().Next(0, 10);
         }
     }
 }
Exemple #4
0
        public override void DoWiredAction(RoomUnitUser triggerer, HashSet <uint> used)
        {
            if (this.SelectedItems.Count > 0)
            {
                RoomItemWiredMoveUser wired = (RoomItemWiredMoveUser)this;

                int      index = RandomUtilies.GetRandom(0, wired.SelectedItems.Count - 1);
                RoomItem item_ = wired.SelectedItems[index];
                if (item_ != null)
                {
                    if (triggerer != null)
                    {
                        triggerer.StopMoving();
                        triggerer.SetLocation(item_.X, item_.Y, item_.Z); //set new location
                        triggerer.UpdateState();

                        wired.Effect(triggerer);
                    }
                    else
                    {
                        foreach (RoomUnitUser user in this.Room.RoomUserManager.GetRealUsers())
                        {
                            user.StopMoving();
                            user.SetLocation(item_.X, item_.Y, item_.Z); //set new location
                            user.UpdateState();

                            wired.Effect(user);
                        }
                    }
                }
            }
        }
Exemple #5
0
        public virtual void OnRoomCycle()
        {
            this.RandomSpeechTimer--;
            if (this.RandomSpeechTimer <= 0)
            {
                if (this.Data.BotSpeechs.Count > 0)
                {
                    BotSpeech speech = this.Data.BotSpeechs[RandomUtilies.GetRandom(0, this.Data.BotSpeechs.Count - 1)];
                    this.Speak(speech.Text, speech.Shout);
                }
                this.RandomSpeechTimer = this.GetRandom().Next(10, 300);
            }

            this.RandomMoveTimer--;
            if (this.RandomMoveTimer <= 0)
            {
                if (this.Data.WalkMode == 0)
                {
                }
                else if (this.Data.WalkMode == 1)
                {
                    int x = RandomUtilies.GetRandom(0, this.Room.RoomGamemapManager.Model.MaxX);
                    int y = RandomUtilies.GetRandom(0, this.Room.RoomGamemapManager.Model.MaxY);
                    this.MoveTo(x, y);
                }
                else if (this.Data.WalkMode == 2)
                {
                    int x = RandomUtilies.GetRandom(this.Data.MinX, this.Data.MaxX);
                    int y = RandomUtilies.GetRandom(this.Data.MinY, this.Data.MinY);
                    this.MoveTo(x, y);
                }
                this.RandomMoveTimer = this.GetRandom().Next(10, 30);
            }
        }
Exemple #6
0
        public override bool OnUse(GameClient session, string[] args)
        {
            if (session.GetHabbo().GetRoomSession().GetRoom().RoomData.ExtraData.RoleplayEnabled)
            {
                if (args.Length >= 2)
                {
                    GameClient target = Skylight.GetGame().GetGameClientManager().GetGameClientByUsername(args[1]);
                    if (target != null)
                    {
                        RoomUnitUser me    = session.GetHabbo().GetRoomSession().GetRoomUser();
                        RoomUnitUser other = target.GetHabbo().GetRoomSession().GetRoomUser();
                        if (target.GetHabbo().GetRoomSession().IsInRoom&& target.GetHabbo().GetRoomSession().CurrentRoomID == session.GetHabbo().GetRoomSession().CurrentRoomID)
                        {
                            bool doit = true;
                            if ((me.X + 1 != other.X || me.Y != other.Y) && (me.X - 1 != other.X || me.Y != other.Y) && (me.Y + 1 != other.Y || me.X != other.X))
                            {
                                bool skip = false;
                                if (me.X - 1 == other.X)
                                {
                                    if (me.Y == other.Y)
                                    {
                                        skip = true;
                                    }
                                }

                                if (!skip)
                                {
                                    doit = me.X == other.X || me.Y == other.Y;
                                }
                            }

                            if (doit)
                            {
                                int damage = RandomUtilies.GetRandom(5, 12);
                                other.Health -= damage;
                                if (other.Health - damage < 0)
                                {
                                    me.Speak("*Hits " + target.GetHabbo().Username + ", and kills them!*", false);
                                    other.Speak("*dies*", false);
                                    session.GetHabbo().GetRoomSession().GetRoom().RoomUserManager.KickUser(target, true);
                                }
                                else
                                {
                                    me.Speak("*Hits " + target.GetHabbo().Username + ", causing " + damage + " damage *", false);
                                    other.Speak("*Suffers " + damage + " damage from " + me.Session.GetHabbo().Username + ", leaving me with " + other.Health + " health*", false);
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                session.SendNotif("RP is disabled on this room!");
            }

            return(true);
        }
Exemple #7
0
        public override void OnCycle()
        {
            if (this.UpdateNeeded)
            {
                this.UpdateTimer--;
                if (this.UpdateTimer <= 0)
                {
                    this.UpdateNeeded = false;

                    this.ExtraData = RandomUtilies.GetRandom(0, 7).ToString();
                    this.UpdateState(true, true);
                }
            }
        }
Exemple #8
0
        public Item GetGiftLook(int spriteId)
        {
            Item item = null;

            if (spriteId == 0) //use free gift
            {
                int random = RandomUtilies.GetRandom(0, this.OldPresents.Count - 1);
                item = this.OldPresents.ElementAt(random).Value;
            }
            else
            {
                this.NewPresents.TryGetValue(spriteId, out item);
            }
            return(item);
        }
Exemple #9
0
        public bool BreakIceBlock(RoomItem iceBlock)
        {
            if (iceBlock != null)
            {
                if (string.IsNullOrEmpty(iceBlock.ExtraData) || iceBlock.ExtraData == "0")
                {
                    switch (RandomUtilies.GetRandom(1, 9))
                    {
                    case 1:
                        iceBlock.ExtraData = "2000";
                        break;

                    case 2:
                        iceBlock.ExtraData = "3000";
                        break;

                    case 3:
                        iceBlock.ExtraData = "4000";
                        break;

                    case 4:
                        iceBlock.ExtraData = "5000";
                        break;

                    case 5:
                        iceBlock.ExtraData = "6000";
                        break;

                    case 6:
                        iceBlock.ExtraData = "7000";
                        break;

                    default:
                        iceBlock.ExtraData = "1000";
                        break;
                    }

                    iceBlock.UpdateState(false, true);
                    this.Room.RoomGamemapManager.GetTile(iceBlock.X, iceBlock.Y).UpdateTile();
                    return(true);
                }
            }
            return(false);
        }
Exemple #10
0
        public void LeaveTag(RoomUnitUser user)
        {
            this.TagPlayers.Remove(user.Session.GetHabbo().ID);
            user.IceSkateStatus = IceSkateStatus.None;

            foreach (RoomItemTagPole pole in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemTagPole)))
            {
                if (pole.Tagged == user)
                {
                    pole.Tagged = this.TagPlayers.Values.OrderBy(r => RandomUtilies.GetRandom(int.MinValue, int.MaxValue - 1)).FirstOrDefault(u => u.IceSkateStatus == IceSkateStatus.Playing);
                    if (pole.Tagged != null)
                    {
                        pole.Tagged.IceSkateStatus = IceSkateStatus.Tagged;
                        this.GiveEffect(pole.Tagged);
                    }
                }
            }

            this.GiveEffect(user);
        }
Exemple #11
0
        public void OnCycle()
        {
            this.RoomFootballManager.OnCycle();
            this.RoomBattleBanzaiManager.OnCycle();
            this.Room.RoomFreezeManager.OnCycle();
            this.RoomWobbleSquabbleManager.OnCycle();

            foreach (RoomItemTagPole pole in this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemTagPole)))
            {
                if (pole.Tagged == null)
                {
                    pole.Tagged = this.TagPlayers.Values.OrderBy(r => RandomUtilies.GetRandom(int.MinValue, int.MaxValue - 1)).FirstOrDefault(u => u.IceSkateStatus == IceSkateStatus.Playing);
                    if (pole.Tagged != null)
                    {
                        pole.Tagged.IceSkateStatus = IceSkateStatus.Tagged;
                        this.GiveEffect(pole.Tagged);
                    }
                }
            }
        }
Exemple #12
0
        public override void OnWalkOn(RoomUnit user)
        {
            this.ExtraData = "1";
            this.UpdateState(false, true);
            this.DoUpdate(1);

            IEnumerable <RoomItem> battleBanzaiTeleports = this.Room.RoomItemManager.FloorItems.Get(typeof(RoomItemBattleBanzaiRandomTeleport)).Where(i => i.ID != this.ID);

            if (battleBanzaiTeleports.Count() > 0)
            {
                RoomItem item = battleBanzaiTeleports.ElementAt(RandomUtilies.GetRandom(0, battleBanzaiTeleports.Count() - 1));
                item.ExtraData = "1";
                item.UpdateState(false, true);
                item.DoUpdate(1);

                user.StopMoving();
                user.SetLocation(item.X, item.Y, item.Z); //set new location
                user.UpdateState();
            }
        }
Exemple #13
0
        public virtual void Handle(GameClient session, ClientMessage message)
        {
            if (session?.GetHabbo() != null)
            {
                if (this.Type == "SafetyQuiz1")
                {
                    session.GetHabbo().GetUserAchievements().AchievementUnlocked("SafetyQuiz", 1);
                }
                else if (this.Type == "HabboWay1")
                {
                    HashSet <int> questions = new HashSet <int>();
                    while (questions.Count < 5)
                    {
                        questions.Add(RandomUtilies.GetRandom(0, 9));
                    }

                    session.GetHabbo().HabboWayQuestions = questions.ToList();
                    session.SendMessage(new SendQuizComposerHandler("HabboWay1", questions));
                }
            }
        }
Exemple #14
0
        public override void OnWalkOn(RoomUnit user)
        {
            RoomPet pet = user as RoomPet;

            if (pet != null && pet.Rider != null)
            {
                if (this.IsMiddlePart(pet.X, pet.Y))
                {
                    pet.JumpStatus = HorseJumpStatus.JUMPING;
                    pet.LastJump   = RandomUtilies.GetRandom(1, 4);

                    this.ExtraData = pet.LastJump.ToString();
                    this.UpdateState(false, true);
                    this.DoUpdate(2);
                }
                else
                {
                    pet.JumpStatus = HorseJumpStatus.ABOUT_TO_JUMP;

                    this.ExtraData = "5";
                    this.UpdateState(false, true);
                }
            }
        }
Exemple #15
0
        public bool WiredTrigger(RoomItem trigger, RoomUnitUser triggerer, HashSet <uint> used, object extraData = null)
        {
            uint wiredId = trigger?.ID ?? (extraData as RoomItem)?.ID ?? 0;                                                                                                         //Love the one line <3

            if (wiredId > 0 && used.Add(wiredId))                                                                                                                                   //prevent stackoverflow :O :)
            {
                if (extraData is RoomItemWiredCallStack || extraData is RoomItemActionTriggerStacks || (trigger as RoomItemWiredTrigger)?.TryTrigger(triggerer, extraData) == true) //it got triggered
                {
                    bool conditionBlocking = false;

                    IEnumerable <RoomItem> allTileItems = this.Room.RoomGamemapManager.GetTile(trigger.X, trigger.Y).ItemsOnTile.Values.OrderBy(i => i.Z);
                    if (!(extraData is RoomItemWiredCallStack))
                    {
                        trigger.ExtraData = "1";
                        trigger.UpdateState(false, true);
                        trigger.DoUpdate(1);

                        foreach (RoomItemWiredCondition item in allTileItems.Where(i => this.IsWiredCondition(i)))
                        {
                            if (conditionBlocking = item.IsBlocking(triggerer))
                            {
                                break;
                            }
                            else
                            {
                                item.ExtraData = "1";
                                item.UpdateState(false, true);
                                item.DoUpdate(1);
                            }
                        }
                    }

                    if (!conditionBlocking)                                                                    //conditions are fine
                    {
                        List <RoomItem> actionStack = allTileItems.Where(i => this.IsWiredAction(i)).ToList(); //we need get all actions ready

                        if (actionStack.Count > 1)                                                             //there is more then one so we should actually do something
                        {
                            foreach (RoomItem item in allTileItems.Where(i => this.IsWiredExtra(i)))           //only one works
                            {
                                if (item is RoomItemWiredRandom)
                                {
                                    RoomItem randomWired = actionStack[RandomUtilies.GetRandom(0, actionStack.Count - 1)];

                                    actionStack.Clear();
                                    actionStack.Add(randomWired);
                                }
                                else if (item is RoomItemWiredUnseen wired)
                                {
                                    if (wired.UnUsedWireds != null && wired.UnUsedWireds.Count > 0)
                                    {
                                        RoomItem nextWired = wired.UnUsedWireds.First();
                                        actionStack.Clear();
                                        actionStack.Add(nextWired);
                                        wired.UnUsedWireds.Remove(nextWired);
                                    }
                                    else
                                    {
                                        wired.UnUsedWireds = actionStack.ToList();

                                        RoomItem nextWired = wired.UnUsedWireds.First();
                                        actionStack.Clear();
                                        actionStack.Add(nextWired);
                                        wired.UnUsedWireds.Remove(nextWired);
                                    }
                                }
                                else
                                {
                                    continue; //???? why
                                }

                                item.ExtraData = "1";
                                item.UpdateState(false, true);
                                item.DoUpdate(1);

                                break;
                            }
                        }

                        //do the actions
                        foreach (RoomItemWiredAction item in actionStack)
                        {
                            if (item.Delay > 0)
                            {
                                this.WiredDelays.Add(new RoomWiredDelay(item, triggerer, item.Delay, used));
                            }
                            else
                            {
                                item.DoWiredAction(triggerer, used);
                            }

                            item.ExtraData = "1";
                            item.UpdateState(false, true);
                            item.DoUpdate(1);
                        }

                        return(true);
                    }
                    else
                    {
                        return(false);
                    }
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                return(false);
            }
        }
Exemple #16
0
        public override void DoWiredAction(RoomUnitUser user, HashSet <uint> used)
        {
            Random random = RandomUtilies.GetRandom();

            foreach (RoomItem item_ in this.SelectedItems)
            {
                if (!this.ActiveDirections.TryGetValue(item_.ID, out int direction))
                {
                    direction = this.Direction;
                }

                for (int i = 0; i < this.TriesCount(); i++)
                {
                    int x = item_.X;
                    int y = item_.Y;

                    if (direction == 0)
                    {
                        y--;
                    }
                    else if (direction == 1)
                    {
                        y--;
                        x++;
                    }
                    else if (direction == 2)
                    {
                        x++;
                    }
                    else if (direction == 3)
                    {
                        x++;
                        y++;
                    }
                    else if (direction == 4)
                    {
                        y++;
                    }
                    else if (direction == 5)
                    {
                        y++;
                        x--;
                    }
                    else if (direction == 6)
                    {
                        x--;
                    }
                    else if (direction == 7)
                    {
                        x--;
                        y--;
                    }

                    if (this.TryMoveItem(item_, x, y))
                    {
                        if (this.ActiveDirections.ContainsKey(item_.ID))
                        {
                            this.ActiveDirections[item_.ID] = direction;
                        }
                        else
                        {
                            this.ActiveDirections.Add(item_.ID, direction);
                        }

                        break;
                    }
                    else
                    {
                        if (this.Action > 0)
                        {
                            this.FindNewDirection(item_, ref direction);
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
        }
Exemple #17
0
        public void Handle(GameClient session, ClientMessage message)
        {
            if (session?.GetHabbo()?.GetRoomSession()?.GetRoom()?.RoomGameManager?.RoomWobbleSquabbleManager?.Status == WSStatus.Running)
            {
                if (!session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.NeedUpdate)
                {
                    session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.NeedUpdate = true;

                    string action = session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Action = message.ReadBytesAsString(1);
                    switch (action)
                    {
                    case "0":
                    {
                        if (!session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.HasUsedResetLean)
                        {
                            session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.HasUsedResetLean = true;
                            session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Lean = 0;
                        }
                    }
                    break;

                    case "A":
                    {
                        session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Lean -= 35 + RandomUtilies.GetRandom().Next(0, 10);
                    }
                    break;

                    case "D":
                    {
                        session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Lean += 35 + RandomUtilies.GetRandom().Next(0, 10);
                    }
                    break;

                    case "S":
                    {
                        if (session.GetHabbo().GetRoomSession().GetRoom().RoomGameManager.RoomWobbleSquabbleManager.IsOpen(session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Location + 1))
                        {
                            session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Location++;
                        }
                    }
                    break;

                    case "X":
                    {
                        if (session.GetHabbo().GetRoomSession().GetRoom().RoomGameManager.RoomWobbleSquabbleManager.IsOpen(session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Location - 1))
                        {
                            session.GetHabbo().GetRoomSession().GetRoomUser().WSPlayer.Location--;
                        }
                    }
                    break;

                    case "E":
                    {
                        session.GetHabbo().GetRoomSession().GetRoom().RoomGameManager.RoomWobbleSquabbleManager.Hit(session.GetHabbo().GetRoomSession().GetRoomUser(), false);
                    }
                    break;

                    case "W":
                    {
                        session.GetHabbo().GetRoomSession().GetRoom().RoomGameManager.RoomWobbleSquabbleManager.Hit(session.GetHabbo().GetRoomSession().GetRoomUser(), true);
                    }
                    break;
                    }
                }
            }
        }
        public void Handle(GameClient session, ClientMessage message)
        {
            int needLoadRooms = 9 - Skylight.GetGame().GetRoomManager().LoadedRoomData.Count; //9 loaded, 3 shown, this should be bit random

            if (needLoadRooms > 0)
            {
                DataTable rooms = null;
                using (DatabaseClient client = Skylight.GetDatabaseManager().GetClient())
                {
                    rooms = client.ReadDataTable("SELECT * FROM rooms ORDER BY RAND() LIMIT " + needLoadRooms);
                }

                if (rooms != null && rooms.Rows.Count > 0)
                {
                    foreach (DataRow dataRow in rooms.Rows)
                    {
                        //Skylight.GetGame().GetRoomManager().LoadRoomData((uint)dataRow["id"], dataRow);
                    }
                }
            }

            ServerMessage message_ = BasicUtilies.GetRevisionServerMessage(Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169);

            message_.Init(r26Outgoing.GetRandomRooms);
            message_.AppendInt32(Math.Min(3, Skylight.GetGame().GetRoomManager().LoadedRoomData.Count)); //count
            foreach (RoomData roomData in Skylight.GetGame().GetRoomManager().LoadedRoomData.Values.OrderBy(r => RandomUtilies.GetRandom(int.MinValue, int.MaxValue - 1)))
            {
                message_.AppendUInt(roomData.ID);
                message_.AppendString(roomData.Name);
                message_.AppendString(Skylight.GetGame().GetGameClientManager().GetUsernameByID(roomData.OwnerID));
                message_.AppendString(roomData.State == RoomStateType.OPEN ? "open" : roomData.State == RoomStateType.LOCKED ? "closed" : "password");
                message_.AppendInt32(roomData.UsersNow);
                message_.AppendInt32(roomData.UsersMax);
                message_.AppendString(roomData.Description);
            }
            session.SendMessage(message_);
        }
        public override void DoWiredAction(RoomUnitUser user, HashSet <uint> used)
        {
            if (this.Rotation != 0 || this.Movement != 0) //we are doing something
            {
                Random random = RandomUtilies.GetRandom();

                Dictionary <RoomItem, Tuple <int, int, int> > items = new Dictionary <RoomItem, Tuple <int, int, int> >(this.SelectedItems.Count);
                foreach (RoomItem item_ in this.SelectedItems)
                {
                    int x = item_.X;
                    int y = item_.Y;

                    if (this.Movement != 0)     //no movement
                    {
                        if (this.Movement == 1) //up, down, left or right
                        {
                            int movement = random.Next(0, 4);
                            if (movement == 0) //up
                            {
                                y--;
                            }
                            else if (movement == 1) //down
                            {
                                y++;
                            }
                            else if (movement == 2) //left
                            {
                                x--;
                            }
                            else if (movement == 3) //right
                            {
                                x++;
                            }
                        }
                        else if (this.Movement == 2) //left or right
                        {
                            int movement = random.Next(0, 2);
                            if (movement == 0) //left
                            {
                                x--;
                            }
                            else if (movement == 1) //right
                            {
                                x++;
                            }
                        }
                        else if (this.Movement == 3) //up or down
                        {
                            int movement = random.Next(0, 2);
                            if (movement == 0) //up
                            {
                                y--;
                            }
                            else if (movement == 1) //down
                            {
                                y++;
                            }
                        }
                        else if (this.Movement == 4) //up
                        {
                            y--;
                        }
                        else if (this.Movement == 5) //right
                        {
                            x++;
                        }
                        else if (this.Movement == 6) //down
                        {
                            y++;
                        }
                        else if (this.Movement == 7) //left
                        {
                            x--;
                        }
                    }

                    int rotation = item_.Rot;
                    if (this.Rotation != 0)     // no rotation
                    {
                        if (this.Rotation == 1) //clockwise
                        {
                            rotation += 2;
                            if (rotation > 6)
                            {
                                rotation = 0;
                            }
                        }
                        else if (this.Rotation == 2) //counter clockwise
                        {
                            rotation -= 2;
                            if (rotation < 0)
                            {
                                rotation = 6;
                            }
                        }
                        else if (this.Rotation == 3) //clockwise or counter clcokwise
                        {
                            int movement = random.Next(0, 2);
                            if (movement == 0)
                            {
                                rotation += 2;
                                if (rotation > 6)
                                {
                                    rotation = 0;
                                }
                            }
                            else if (movement == 1)
                            {
                                rotation -= 2;
                                if (rotation < 0)
                                {
                                    rotation = 6;
                                }
                            }
                        }
                    }

                    if (this.Room.RoomItemManager.CanPlaceItemAt(item_, x, y))
                    {
                        items.Add(item_, new Tuple <int, int, int>(x, y, rotation));
                    }
                }

                List <RoomItem> ignore = new List <RoomItem>(items.Keys);
                foreach (KeyValuePair <RoomItem, Tuple <int, int, int> > item_ in items.OrderBy(i => i.Key.Z))
                {
                    int    oldX = item_.Key.X;
                    int    oldY = item_.Key.Y;
                    double oldZ = item_.Key.Z;

                    if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_.Key, item_.Value.Item1, item_.Value.Item2, item_.Value.Item3, -1.0, false, ignore.ToArray()))
                    {
                        this.Room.RoomItemManager.MoveAnimation[item_.Key.ID] = new RoomItemRollerMovement(item_.Key.ID, oldX, oldY, oldZ, 0, item_.Key.X, item_.Key.Y, item_.Key.Z);
                    }

                    ignore.Remove(item_.Key);
                }
            }
        }
Exemple #20
0
        private void LetUserIn()
        {
            //if (this.Revision == Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169)
            //{
            //    ServerMessage weirdKeys = BasicUtilies.GetRevisionServerMessage(Revision.RELEASE63_35255_34886_201108111108);
            //    weirdKeys.Init(r26Outgoing.SomeKeysMaybe);
            //    weirdKeys.AppendString("QBHIIIKHJIPAIQAdd-MM-yyyy");
            //    weirdKeys.AppendString("SAHPB/client");
            //    weirdKeys.AppendString("QBH");
            //    this.SendMessage(weirdKeys);
            //}

            //send effects

            if (this.Revision > Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169)
            {
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.AvaiblityStatus).Handle());
            }
            this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.AuthOk).Handle());
            this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.Fuserights).Handle(new ValueHolder().AddValue("Session", this)));
            this.SendMessage(new NewbieIdentityComposerHandler(false)); //Removes all the anonying shit

            if (this.GetHabbo().HasPermission("acc_supporttool"))
            {
                this.SendMessage(Skylight.GetGame().GetModerationToolManager().SerializeModTool(this));
            }

            if (this.Revision > Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169)
            {
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.ShowNotifications).Handle());
            }

            if (this.Habbo.NewbieStatus == 0)
            {
                Room newbieRoom = Skylight.GetGame().GetRoomManager().NewbieRooms.Count > 0 ? Skylight.GetGame().GetRoomManager().CreateNewbieRoom(this, Skylight.GetGame().GetRoomManager().NewbieRooms.Keys.ElementAt(RandomUtilies.GetRandom(0, Skylight.GetGame().GetRoomManager().NewbieRooms.Count - 1))) : null;
                if (newbieRoom != null)
                {
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("userId", this.Habbo.ID);
                        dbClient.AddParamWithValue("roomId", newbieRoom.ID);
                        dbClient.ExecuteQuery("UPDATE users SET newbie_status = '1', " + (this.Habbo.HomeRoom == 0 ? "home_room = @roomId, " : "") + "newbie_room = @roomId WHERE id = @userId LIMIT 1");
                    }

                    this.Habbo.NewbieStatus = 1;
                    if (this.Habbo.HomeRoom == 0)
                    {
                        this.Habbo.HomeRoom = newbieRoom.ID;
                    }
                    this.Habbo.NewbieRoom = newbieRoom.ID;
                }
                else
                {
                    //no welcome room, no shit :(
                    using (DatabaseClient dbClient = Skylight.GetDatabaseManager().GetClient())
                    {
                        dbClient.AddParamWithValue("userId", this.Habbo.ID);
                        dbClient.ExecuteQuery("UPDATE users SET newbie_status = '2' WHERE id = @userId LIMIT 1");
                    }

                    this.Habbo.NewbieStatus = 2;
                }
            }

            if (this.Revision >= Revision.RELEASE63_201211141113_913728051)
            {
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.HomeRoom).Handle(new ValueHolder().AddValue("HomeRoom", this.Habbo.HomeRoom).AddValue("ForwardID", this.Habbo.NewbieStatus == 1 ? this.Habbo.NewbieRoom : this.Habbo.HomeRoom)));
            }
            else
            {
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.HomeRoom).Handle(new ValueHolder().AddValue("HomeRoom", this.Habbo.NewbieStatus == 1 ? this.Habbo.NewbieRoom : this.Habbo.HomeRoom)));
            }

            if (this.Revision > Revision.R26_20080915_0408_7984_61ccb5f8b8797a3aba62c1fa2ca80169)
            {
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.FavouriteRooms).Handle(new ValueHolder().AddValue("Max", 50).AddValue("FavouriteRooms", this.Habbo.FavouriteRooms)));
            }

            if (this.GetHabbo().CanReceiveActivityBonus())
            {
                this.GetHabbo().ReceiveActivityBonus();
            }

            if (!string.IsNullOrEmpty(ServerConfiguration.MOTD))
            {
                this.SendNotif(ServerConfiguration.MOTD, 2);
            }

            foreach (KeyValuePair <int, string> data in Skylight.GetGame().GetPermissionManager().GetBadges())
            {
                if (!string.IsNullOrEmpty(data.Value))
                {
                    if (this.GetHabbo().Rank >= data.Key)
                    {
                        this.GetHabbo().GetBadgeManager().AddBadge(data.Value, 0, true);
                    }
                    else
                    {
                        this.GetHabbo().GetBadgeManager().RemoveBadge(data.Value);
                    }
                }
            }

            this.GetHabbo().CheckDailyStuff(false); //daily respect, regular visitor
            this.GetHabbo().CheckHappyHour();       //happy hour achievement
            this.GetHabbo().GetUserAchievements().CheckAchievement("RegistrationDuration");
            this.GetHabbo().GetUserAchievements().CheckAchievement("OnlineTime");
            this.GetHabbo().GetUserAchievements().CheckAchievement("HCMember");
            this.GetHabbo().GetUserAchievements().CheckAchievement("VIPMember");
            this.GetHabbo().GetUserAchievements().CheckAchievement("Tags");
            this.GetHabbo().GetUserAchievements().CheckAchievement("GuideEnrollmentLifetime");
            this.GetHabbo().GetUserAchievements().CheckAchievement("GuideOnDutyPresence");
            if (this.GetHabbo().MailConfirmed)
            {
                Skylight.GetGame().GetAchievementManager().AddAchievement(this, "EmailVerification", 1);
            }

            foreach (uint roomId in this.GetHabbo().UserRooms)
            {
                Room room = Skylight.GetGame().GetRoomManager().TryGetRoom(roomId);
                if (room != null)
                {
                    room.EquestrianTrackHost(0);
                    room.FootballGoalHost(0);
                    room.RoomHost(0);
                }
            }

            if (this.Revision >= Revision.RELEASE63_201211141113_913728051)
            {
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.UserPerks).Handle(new ValueHolder("Session", this)));
            }

            if (this.Revision >= Revision.PRODUCTION_201601012205_226667486)
            {
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.NewNavigatorMetaData).Handle());
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.NewNavigatorLiftedRooms).Handle());
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.NewNavigatorSavedSearches).Handle());
                this.SendMessage(BasicUtilies.GetRevisionPacketManager(this.Revision).GetOutgoing(OutgoingPacketsEnum.NewNavigatorEventCategories).Handle());
            }
        }
Exemple #21
0
        public ServerMessage Handle(T handler)
        {
            ServerMessage message = BasicUtilies.GetRevisionServerMessage(Revision.PRODUCTION_201601012205_226667486, r63cOutgoing.SendUserRelations);

            message.AppendUInt(handler.Profile.UserID);

            int total = 0;

            if (handler.Profile.Lovers.Count > 0 | handler.Profile.Friends.Count > 0 | handler.Profile.Haters.Count > 0)
            {
                total++;
            }

            message.AppendInt32(total);
            if (handler.Profile.Lovers.Count > 0)
            {
                message.AppendInt32(1);
                message.AppendInt32(handler.Profile.Lovers.Count);

                UserProfile random = Skylight.GetGame().GetUserProfileManager().GetProfile(handler.Profile.Lovers[RandomUtilies.GetRandom(0, handler.Profile.Lovers.Count - 1)]);
                message.AppendUInt(random.UserID);
                message.AppendString(random.Username);
                message.AppendString(random.Look);
            }

            if (handler.Profile.Friends.Count > 0)
            {
                message.AppendInt32(2);
                message.AppendInt32(handler.Profile.Friends.Count);

                UserProfile random = Skylight.GetGame().GetUserProfileManager().GetProfile(handler.Profile.Friends[RandomUtilies.GetRandom(0, handler.Profile.Friends.Count - 1)]);
                message.AppendUInt(random.UserID);
                message.AppendString(random.Username);
                message.AppendString(random.Look);
            }

            if (handler.Profile.Haters.Count > 0)
            {
                message.AppendInt32(3);
                message.AppendInt32(handler.Profile.Haters.Count);

                UserProfile random = Skylight.GetGame().GetUserProfileManager().GetProfile(handler.Profile.Haters[RandomUtilies.GetRandom(0, handler.Profile.Haters.Count - 1)]);
                message.AppendUInt(random.UserID);
                message.AppendString(random.Username);
                message.AppendString(random.Look);
            }
            return(message);
        }
        public override void DoWiredAction(RoomUnitUser user, HashSet <uint> used)
        {
            foreach (RoomItem item_ in this.SelectedItems)
            {
                if (item_ != null)
                {
                    bool foundUser = false;
                    for (int x = item_.X - 5; x < item_.X + 5; x++)
                    {
                        RoomTile tile = this.Room.RoomGamemapManager.GetTile(x, item_.Y);
                        if (tile != null)
                        {
                            RoomUnitUser user_ = (RoomUnitUser)tile.UsersOnTile.Values.FirstOrDefault(u => u.IsRealUser);
                            if (user_ != null)
                            {
                                int         direction = WalkRotation.Walk(item_.X, item_.Y, user_.X, user_.Y);
                                ThreeDCoord moveTo    = item_.TDCR(direction);

                                if (moveTo.x == user_.X && moveTo.y == user_.Y)
                                {
                                    this.Room.RoomWiredManager.UserCollide(user_, this, used);
                                }
                                else
                                {
                                    int    oldX = item_.X;
                                    int    oldY = item_.Y;
                                    double oldZ = item_.Z;
                                    if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, moveTo.x, moveTo.y, this.Rot))
                                    {
                                        this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                                    }
                                }

                                foundUser = true;
                                break;
                            }
                        }
                    }

                    if (!foundUser)
                    {
                        for (int y = item_.Y - 5; y < item_.Y + 5; y++)
                        {
                            RoomTile tile = this.Room.RoomGamemapManager.GetTile(item_.X, y);
                            if (tile != null)
                            {
                                RoomUnitUser user_ = (RoomUnitUser)tile.UsersOnTile.Values.FirstOrDefault(u => u.IsRealUser);
                                if (user_ != null)
                                {
                                    int         direction = WalkRotation.Walk(item_.X, item_.Y, user_.X, user_.Y);
                                    ThreeDCoord moveTo    = item_.TDCR(direction);

                                    if (moveTo.x == user_.X && moveTo.y == user_.Y)
                                    {
                                        this.Room.RoomWiredManager.UserCollide(user_, this, used);
                                    }
                                    else
                                    {
                                        int    oldX = item_.X;
                                        int    oldY = item_.Y;
                                        double oldZ = item_.Z;
                                        if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, moveTo.x, moveTo.y, this.Rot))
                                        {
                                            this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                                        }
                                    }

                                    foundUser = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!foundUser) //user STILL not found, lets do random movement
                    {
                        Random random = RandomUtilies.GetRandom();
                        int    x      = item_.X;
                        int    y      = item_.Y;

                        int movement = random.Next(0, 4);
                        if (movement == 0) //up
                        {
                            y--;
                        }
                        else if (movement == 1) //down
                        {
                            y++;
                        }
                        else if (movement == 2) //left
                        {
                            x--;
                        }
                        else if (movement == 3) //right
                        {
                            x++;
                        }

                        int    oldX = item_.X;
                        int    oldY = item_.Y;
                        double oldZ = item_.Z;
                        if (this.Room.RoomItemManager.MoveFloorItemOnRoom(null, item_, x, y, this.Rot))
                        {
                            this.Room.RoomItemManager.MoveAnimation[item_.ID] = new RoomItemRollerMovement(item_.ID, oldX, oldY, oldZ, 0, item_.X, item_.Y, item_.Z);
                        }
                    }
                }
            }
        }
Exemple #23
0
        public void OnUserSpeak(RoomUnitUser user, string message, bool shout)
        {
            if (!shout)
            {
                if (message == this.PetData.Name)
                {
                    this.SetRotation(WalkRotation.Walk(this.X, this.Y, user.X, user.Y), false);
                }
                else if (message.StartsWith(this.PetData.Name + " ") && user.UserID == this.PetData.OwnerID) //pet commands
                {
                    int random = RandomUtilies.GetRandom(1, 100);
                    if (random <= this.PetData.Happiness)
                    {
                        string command = message.Split(' ')[1];
                        switch (command)
                        {
                        case "free":
                        {
                            this.EndAction();
                        }
                        break;

                        case "sit":
                        {
                            if (this.PetData.Energy >= 10)
                            {
                                this.AddExpirience(10);
                                this.PetData.Energy    -= 10;
                                this.PetData.NeedUpdate = true;
                                this.AddStatus("sit", TextUtilies.DoubleWithDotDecimal(this.Z));

                                this.Moving = false;
                                if (this.HasStatus("mv"))
                                {
                                    this.RemoveStatus("mv");
                                }

                                this.ActionTick = 8;
                                this.Action     = "sit";
                            }
                            else
                            {
                                this.Speak("Too tired! :(", false);
                            }
                        }
                        break;

                        default:
                            this.Speak("*not yet implemented*", false);
                            break;
                        }
                    }
                    else
                    {
                        this.PetData.Energy -= 10;
                        if (this.PetData.Energy < 0)
                        {
                            this.PetData.Energy = 0;
                        }
                        this.PetData.NeedUpdate = true;

                        this.Speak("NO! >:(", false);
                    }
                }
            }
        }
        public override void OnCycle()
        {
            if (this.UpdateNeeded)
            {
                this.UpdateTimer--;
                if (this.UpdateTimer <= 0)
                {
                    this.UpdateNeeded = false;

                    if (this.ExtraData == "1")
                    {
                        if (this.Interactor != null)
                        {
                            this.Interactor.RestrictMovementType &= ~RestrictMovementType.Client;
                            this.Interactor.SetHanditem(this.GetBaseItem().VendingIds[RandomUtilies.GetRandom(0, this.GetBaseItem().VendingIds.Length - 1)]);
                        }

                        this.Interactor = null;
                        this.ExtraData  = "0";
                        this.UpdateState(false, true);
                    }
                }
            }
        }