コード例 #1
0
        public static int HandleRotation(int oldRotation, RotationState state)
        {
            int rotation = oldRotation;

            switch (state)
            {
            case RotationState.CLOCK_WISE:
            {
                HandleClockwiseRotation(ref rotation);
                return(rotation);
            }

            case RotationState.COUNTER_CLOCK_WISE:
            {
                HandleCounterClockwiseRotation(ref rotation);
                return(rotation);
            }

            case RotationState.RANDOM:
            {
                if (NeonEnvironment.GetRandomNumber(0, 3) == 1)
                {
                    HandleClockwiseRotation(ref rotation);
                }
                else
                {
                    HandleCounterClockwiseRotation(ref rotation);
                }

                return(rotation);
            }
            }

            return(rotation);
        }
コード例 #2
0
        public static Point HandleMovementDir(Point newCoordinate, MovementDirection state, int newRotation)
        {
            Point newPoint = new Point(newCoordinate.X, newCoordinate.Y);

            switch (state)
            {
            case MovementDirection.UP:
            case MovementDirection.DOWN:
            case MovementDirection.LEFT:
            case MovementDirection.RIGHT:
            case MovementDirection.DOWN_RIGHT:
            case MovementDirection.DOWN_LEFT:
            case MovementDirection.UP_RIGHT:
            case MovementDirection.UP_LEFT:
            {
                HandleMovementDir(ref newPoint, state);
                break;
            }

            case MovementDirection.RANDOM:
            {
                switch (NeonEnvironment.GetRandomNumber(1, 5))
                {
                case 1:
                {
                    HandleMovementDir(ref newPoint, MovementDirection.UP);
                    break;
                }

                case 2:
                {
                    HandleMovementDir(ref newPoint, MovementDirection.DOWN);
                    break;
                }

                case 3:
                {
                    HandleMovementDir(ref newPoint, MovementDirection.LEFT);
                    break;
                }

                case 4:
                {
                    HandleMovementDir(ref newPoint, MovementDirection.RIGHT);
                    break;
                }
                }
                break;
            }
            }

            return(newPoint);
        }
コード例 #3
0
        public void PetEnergy(bool Add)
        {
            int MaxE;

            if (Add)
            {
                if (Energy == 100) // If Energy is 100, no point.
                {
                    return;
                }

                if (Energy > 85)
                {
                    MaxE = MaxEnergy - Energy;
                }
                else
                {
                    MaxE = 10;
                }
            }
            else
            {
                MaxE = 15; // Remove Max Energy as 15
            }

            if (MaxE <= 4)
            {
                MaxE = 15;
            }

            int r = NeonEnvironment.GetRandomNumber(4, MaxE);

            if (!Add)
            {
                Energy = Energy - r;

                if (Energy < 0)
                {
                    Energy = 1;
                    r      = 1;
                }
            }
            else
            {
                Energy = Energy + r;
            }

            if (DBState != DatabaseUpdateState.NeedsInsert)
            {
                DBState = DatabaseUpdateState.NeedsUpdate;
            }
        }
コード例 #4
0
        public override void OnTimerTick()
        {
            RoomUser Pet = GetRoomUser();

            if (Pet == null)
            {
                return;
            }


            #region Speech

            if (SpeechTimer <= 0)
            {
                if (Pet.PetData.DBState != DatabaseUpdateState.NeedsInsert)
                {
                    Pet.PetData.DBState = DatabaseUpdateState.NeedsUpdate;
                }

                if (Pet != null)
                {
                    Random RandomSpeech = new Random();
                    RemovePetStatus();

                    string[] Speech  = NeonEnvironment.GetGame().GetChatManager().GetPetLocale().GetValue("speech.pet" + Pet.PetData.Type);
                    string   rSpeech = Speech[RandomNumber.GenerateRandom(0, Speech.Length - 1)];

                    if (rSpeech.Length != 3)
                    {
                        Pet.Chat(rSpeech, false);
                    }
                    else
                    {
                        Pet.Statusses.Add(rSpeech, TextHandling.GetString(Pet.Z));
                    }
                }
                SpeechTimer = NeonEnvironment.GetRandomNumber(20, 120);
            }
            else
            {
                SpeechTimer--;
            }

            #endregion

            #region Actions

            if (ActionTimer <= 0)
            {
                try
                {
                    RemovePetStatus();
                    ActionTimer = RandomNumber.GenerateRandom(15, 40 + GetRoomUser().PetData.VirtualId);
                    if (!GetRoomUser().RidingHorse)
                    {
                        // Remove Status
                        RemovePetStatus();

                        Point nextCoord = GetRoom().GetGameMap().GetRandomWalkableSquare();
                        if (GetRoomUser().CanWalk)
                        {
                            GetRoomUser().MoveTo(nextCoord.X, nextCoord.Y);
                        }
                    }
                }
                catch (Exception e)
                {
                    Logging.HandleException(e, "PetBot.OnTimerTick");
                }
            }
            else
            {
                ActionTimer--;
            }

            #endregion

            #region Energy

            if (EnergyTimer <= 0)
            {
                RemovePetStatus();                                  // Remove Status

                Pet.PetData.PetEnergy(true);                        // Add Energy

                EnergyTimer = RandomNumber.GenerateRandom(30, 120); // 2 Min Max
            }
            else
            {
                EnergyTimer--;
            }

            #endregion
        }
コード例 #5
0
        public bool Execute(params object[] Params)
        {
            if (Params == null || Params.Length == 0)
            {
                return(false);
            }

            Habbo Owner = NeonEnvironment.GetHabboById(Item.UserID);

            if (Owner == null || !Owner.GetPermissions().HasRight("room_item_wired_rewards"))
            {
                return(false);
            }

            Habbo Player = (Habbo)Params[0];

            if (Player == null || Player.GetClient() == null)
            {
                return(false);
            }

            RoomUser User = Player.CurrentRoom.GetRoomUserManager().GetRoomUserByHabbo(Player.Username);

            if (User == null)
            {
                return(false);
            }

            Room Room = Player.CurrentRoom;

            if (string.IsNullOrEmpty(StringData))
            {
                return(false);
            }

            int    SplitNumber  = -1;
            int    oftenforuser = int.Parse(StringData.Split('-')[3]);
            int    amountLeft   = int.Parse(StringData.Split('-')[2]);
            int    often        = int.Parse(StringData.Split('-')[1]);
            string Reward       = StringData.Split('-')[0];
            bool   unique       = BoolData;
            int    totalrewards = (StringData.Split('-')[0]).Split(';').Count();
            bool   premied      = false;

            /*
             * Often numbers
             * 3- 1/min
             * 2- 1/Hour
             * 1- 1/Day
             * 0- Once
             *
             */

            if (amountLeft == 1)
            {
                Player.GetClient().SendMessage(new WiredRewardAlertComposer(0));
                return(true);
            }

            if (!unique)
            {
                int percentage1     = 0;
                int percentage2     = 0;
                int percentage3     = 0;
                int percentage4     = 0;
                int percentage5     = 0;
                int totalpercentage = 0;

                if (totalrewards > 0)
                {
                    percentage1 = int.Parse(((StringData.Split('-')[0]).Split(';')[0]).Split(',')[2]);
                }
                else if (totalrewards > 1)
                {
                    percentage2 = int.Parse(((StringData.Split('-')[0]).Split(';')[1]).Split(',')[2]) + percentage1;
                }
                else if (totalrewards > 2)
                {
                    percentage3 = int.Parse(((StringData.Split('-')[0]).Split(';')[2]).Split(',')[2]) + percentage2;
                }
                else if (totalrewards > 3)
                {
                    percentage4 = int.Parse(((StringData.Split('-')[0]).Split(';')[3]).Split(',')[2]) + percentage3;
                }
                else if (totalrewards > 4)
                {
                    percentage5 = int.Parse(((StringData.Split('-')[0]).Split(';')[4]).Split(',')[2]) + percentage4;
                }

                totalpercentage = percentage5 + percentage4 + percentage3 + percentage2 + percentage1;

                int random = NeonEnvironment.GetRandomNumber(0, 100);

                if (random > totalpercentage)
                {
                    Player.GetClient().SendMessage(new WiredRewardAlertComposer(4));
                    return(true);
                }


                if (percentage1 >= random)
                {
                    SplitNumber = 0;
                }
                else if (percentage1 <= random && random <= percentage2)
                {
                    SplitNumber = 1;
                }
                else if (percentage2 <= random && random <= percentage3)
                {
                    SplitNumber = 2;
                }
                else if (percentage3 <= random && random <= percentage4)
                {
                    SplitNumber = 3;
                }
                else if (percentage4 <= random && random <= percentage5 || random >= percentage5)
                {
                    SplitNumber = 4;
                }

                Player.GetClient().SendWhisper(random + " | " + SplitNumber + " | " + totalpercentage);

                string[] dataArray = ((StringData.Split('-')[0]).Split(';')[SplitNumber]).Split(',');

                bool   isbadge    = dataArray[0] == "0";
                string code       = dataArray[1];
                int    percentage = int.Parse(dataArray[2]);

                premied = true;

                if (isbadge)
                {
                    if (code.StartsWith("diamonds:"))
                    {
                        foreach (string reward in code.Split('-'))
                        {
                            string[] dataArray2 = code.Split(':');
                            int      diamonds   = int.Parse(dataArray2[1]);
                            if (diamonds > 100)
                            {
                                Player.GetClient().SendMessage(new RoomCustomizedAlertComposer("¡Ha ocurrido un error! Avisa a un miembro del equipo Staff."));
                                NeonEnvironment.GetGame().GetClientManager().StaffAlert(RoomNotificationComposer.SendBubble("advice", "" + Player.GetClient().GetHabbo().Username + " ha usado un wired que no sigue las normas del hotel.\n             Click aquí.", "event:navigator/goto/" + Player.GetClient().GetHabbo().CurrentRoomId));
                            }
                            else
                            {
                                Player.GetClient().GetHabbo().Diamonds += diamonds;
                                Player.GetClient().SendMessage(new HabboActivityPointNotificationComposer(Player.GetClient().GetHabbo().Diamonds, diamonds, 5));
                            }
                        }
                    }
                    else if (Player.GetBadgeComponent().HasBadge(code))
                    {
                        Player.GetClient().SendMessage(new WiredRewardAlertComposer(5));
                    }
                    else
                    {
                        Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                        Player.GetClient().SendMessage(new WiredRewardAlertComposer(7));
                    }
                }
                else
                {
                    if (!NeonEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData ItemData))
                    {
                        Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "No se pudo obtener Item ID: " + code, 0, User.LastBubble));
                        return(false);
                    }

                    Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0);


                    if (Item != null)
                    {
                        Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item);
                        Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1));
                        Player.GetClient().SendMessage(new PurchaseOKComposer());
                        Player.GetClient().SendMessage(new FurniListAddComposer(Item));
                        Player.GetClient().SendMessage(new FurniListUpdateComposer());
                        Player.GetClient().SendMessage(new WiredRewardAlertComposer(6));
                    }
                }
            }
            else
            {
                foreach (string dataStr in (StringData.Split('-')[0]).Split(';'))
                {
                    string[] dataArray = dataStr.Split(',');

                    bool   isbadge    = dataArray[0] == "0";
                    string code       = dataArray[1];
                    int    percentage = int.Parse(dataArray[2]);

                    int random = NeonEnvironment.GetRandomNumber(0, 100);

                    premied = true;

                    if (isbadge)
                    {
                        if (code.StartsWith("diamonds:"))
                        {
                            foreach (string reward in code.Split('-'))
                            {
                                string[] dataArray2 = code.Split(':');
                                int      diamonds   = int.Parse(dataArray2[1]);
                                if (diamonds > 100)
                                {
                                    Player.GetClient().SendMessage(new RoomCustomizedAlertComposer("¡Ha ocurrido un error! Avisa a un miembro del equipo Staff."));
                                    NeonEnvironment.GetGame().GetClientManager().StaffAlert(RoomNotificationComposer.SendBubble("advice", "" + Player.GetClient().GetHabbo().Username + " ha usado un wired que no sigue las normas del hotel.\n             Click aquí.", "event:navigator/goto/" + Player.GetClient().GetHabbo().CurrentRoomId));
                                }
                                else
                                {
                                    Player.GetClient().GetHabbo().Diamonds += diamonds;
                                    Player.GetClient().SendMessage(new HabboActivityPointNotificationComposer(Player.GetClient().GetHabbo().Diamonds, diamonds, 5));
                                }
                            }
                        }
                        if (Player.GetBadgeComponent().HasBadge(code))
                        {
                            Player.GetClient().SendMessage(new WiredRewardAlertComposer(5));
                        }
                        else
                        {
                            Player.GetBadgeComponent().GiveBadge(code, true, Player.GetClient());
                            Player.GetClient().SendMessage(new WiredRewardAlertComposer(7));
                        }
                    }
                    else
                    {
                        if (!NeonEnvironment.GetGame().GetItemManager().GetItem(int.Parse(code), out ItemData ItemData))
                        {
                            Player.GetClient().SendMessage(new WhisperComposer(User.VirtualId, "No se pudo obtener Item ID: " + code, 0, User.LastBubble));
                            return(false);
                        }

                        Item Item = ItemFactory.CreateSingleItemNullable(ItemData, Player.GetClient().GetHabbo(), "", "", 0, 0, 0);


                        if (Item != null)
                        {
                            Player.GetClient().GetHabbo().GetInventoryComponent().TryAddItem(Item);
                            Player.GetClient().SendMessage(new FurniListNotificationComposer(Item.Id, 1));
                            Player.GetClient().SendMessage(new PurchaseOKComposer());
                            Player.GetClient().SendMessage(new FurniListAddComposer(Item));
                            Player.GetClient().SendMessage(new FurniListUpdateComposer());
                            Player.GetClient().SendMessage(new WiredRewardAlertComposer(6));
                        }
                    }
                }
            }

            if (premied)
            {
            }
            else if (!premied)
            {
                Player.GetClient().SendMessage(new WiredRewardAlertComposer(4));
            }
            else if (amountLeft > 1)
            {
                amountLeft--;
                StringData = Reward + "-" + often + "-" + amountLeft + "-" + oftenforuser;
            }

            return(true);
        }
コード例 #6
0
ファイル: Freeze.cs プロジェクト: AlexanderM1927/NeonServer
 public Item GetRandomExitTile()
 {
     return(ExitTeleports.Values.ToList()[NeonEnvironment.GetRandomNumber(0, ExitTeleports.Count - 1)]);
 }
コード例 #7
0
        public static Point HandleMovement(Point newCoordinate, MovementState state, int newRotation)
        {
            Point newPoint = new Point(newCoordinate.X, newCoordinate.Y);

            switch (state)
            {
            case MovementState.UP:
            case MovementState.DOWN:
            case MovementState.LEFT:
            case MovementState.RIGHT:
            {
                HandleMovement(ref newPoint, state);
                break;
            }

            case MovementState.LEFT_RIGHT:
            {
                if (NeonEnvironment.GetRandomNumber(0, 2) == 1)
                {
                    HandleMovement(ref newPoint, MovementState.LEFT);
                }
                else
                {
                    HandleMovement(ref newPoint, MovementState.RIGHT);
                }

                break;
            }

            case MovementState.UP_DOWN:
            {
                if (NeonEnvironment.GetRandomNumber(0, 2) == 1)
                {
                    HandleMovement(ref newPoint, MovementState.UP);
                }
                else
                {
                    HandleMovement(ref newPoint, MovementState.DOWN);
                }

                break;
            }

            case MovementState.RANDOM:
            {
                switch (NeonEnvironment.GetRandomNumber(1, 5))
                {
                case 1:
                {
                    HandleMovement(ref newPoint, MovementState.UP);
                    break;
                }

                case 2:
                {
                    HandleMovement(ref newPoint, MovementState.DOWN);
                    break;
                }

                case 3:
                {
                    HandleMovement(ref newPoint, MovementState.LEFT);
                    break;
                }

                case 4:
                {
                    HandleMovement(ref newPoint, MovementState.RIGHT);
                    break;
                }
                }
                break;
            }
            }

            return(newPoint);
        }