Beispiel #1
0
        private void Pan(RoomUser Bot, Room Room)
        {
            MovementDirection movement = MovementManagement.GetMovementByDirection(Bot.RotBody);

            int WeaponEanble = this.WeaponGun.Enable;

            Bot.ApplyEffect(WeaponEanble, true);
            Bot.TimerResetEffect = this.WeaponGun.FreezeTime + 1;

            if (Bot.FreezeEndCounter <= this.WeaponGun.FreezeTime)
            {
                Bot.Freeze           = true;
                Bot.FreezeEndCounter = this.WeaponGun.FreezeTime;
            }

            for (int i = 0; i < this.WeaponGun.FreezeTime; i++)
            {
                if (this.GunCharger <= 0)
                {
                    return;
                }

                this.GunCharger--;
                int Dmg = ButterflyEnvironment.GetRandomNumber(this.WeaponGun.DmgMin, this.WeaponGun.DmgMax);

                Room.GetProjectileManager().AddProjectile(Bot.VirtualId, Bot.SetX, Bot.SetY, Bot.SetZ, movement, Dmg, this.WeaponGun.Distance, this.Config.TeamId);
            }
        }
Beispiel #2
0
        public void Execute(GameClient Session, Room Room, RoomUser UserRoom, string[] Params)
        {
            if (!Room.RpRoom || !Room.Pvp || UserRoom.Freeze)
            {
                return;
            }

            RolePlayer Rp = UserRoom.Roleplayer;

            if (Rp == null)
            {
                return;
            }

            if (Rp.Dead || !Rp.PvpEnable || Rp.SendPrison)
            {
                return;
            }

            if (Rp.Munition <= 0)
            {
                UserRoom.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("rp.munitionnotfound", Session.Langue));
                return;
            }

            if (Rp.GunLoad <= 0)
            {
                UserRoom.SendWhisperChat(ButterflyEnvironment.GetLanguageManager().TryGetValue("rp.reloadweapon", Session.Langue));
                return;
            }

            MovementDirection movement = MovementManagement.GetMovementByDirection(UserRoom.RotBody);

            int WeaponEanble = Rp.WeaponGun.Enable;

            UserRoom.ApplyEffect(WeaponEanble, true);
            UserRoom.TimerResetEffect = Rp.WeaponGun.FreezeTime + 1;

            Rp.AggroTimer = 30;

            if (UserRoom.FreezeEndCounter <= Rp.WeaponGun.FreezeTime)
            {
                UserRoom.Freeze           = true;
                UserRoom.FreezeEndCounter = Rp.WeaponGun.FreezeTime;
            }

            for (int i = 0; i < Rp.WeaponGun.FreezeTime; i++)
            {
                if (Rp.Munition <= 0 || Rp.GunLoad <= 0)
                {
                    break;
                }

                Rp.Munition--;
                Rp.GunLoad--;

                int Dmg = ButterflyEnvironment.GetRandomNumber(Rp.WeaponGun.DmgMin, Rp.WeaponGun.DmgMax);
                Room.GetProjectileManager().AddProjectile(UserRoom.VirtualId, UserRoom.SetX, UserRoom.SetY, UserRoom.SetZ, movement, Dmg, Rp.WeaponGun.Distance);
            }

            Rp.SendUpdate();
        }
Beispiel #3
0
        public void ProcessUpdates()
        {
            this.UpdateCounter--;
            if (this.UpdateCounter > 0)
            {
                return;
            }

            this.UpdateCounter = 0;

            switch (this.GetBaseItem().InteractionType)
            {
            case InteractionType.football:
                if (this.interactionCountHelper <= 0 || this.interactionCountHelper > 6)
                {
                    this.ExtraData = "0";
                    this.UpdateState(false, true);

                    this.interactionCountHelper = 0;
                    break;
                }

                int Length = 1;
                int OldX   = this.GetX;
                int OldY   = this.GetY;

                int NewX = this.GetX;
                int NewY = this.GetY;

                Point NewPoint = this.GetMoveCoord(OldX, OldY, 1);

                if (this.interactionCountHelper > 3)
                {
                    Length = 3;

                    this.ExtraData = "6";
                    this.UpdateState(false, true);
                }
                else if (this.interactionCountHelper > 1 && this.interactionCountHelper < 4)
                {
                    Length = 2;

                    this.ExtraData = "4";
                    this.UpdateState(false, true);
                }
                else
                {
                    Length = 1;

                    this.ExtraData = "2";
                    this.UpdateState(false, true);
                }


                if (Length != 1 && !this.GetRoom().GetGameMap().CanStackItem(NewPoint.X, NewPoint.Y, true))
                {
                    this.GetNewDir(NewX, NewY);
                    this.interactionCountHelper--;
                }

                for (int i = 1; i <= Length; i++)
                {
                    NewPoint = this.GetMoveCoord(OldX, OldY, i);


                    if ((this.interactionCountHelper <= 3 && this.GetRoom().GetGameMap().SquareHasUsers(NewPoint.X, NewPoint.Y)))
                    {
                        this.interactionCountHelper = 0;
                        break;
                    }

                    if (this.GetRoom().GetGameMap().CanStackItem(NewPoint.X, NewPoint.Y, true))
                    {
                        NewX = NewPoint.X;
                        NewY = NewPoint.Y;
                        this.GetRoom().GetSoccer().HandleFootballGameItems(new Point(NewPoint.X, NewPoint.Y));
                    }
                    else
                    {
                        this.GetNewDir(NewX, NewY);
                        this.interactionCountHelper--;
                        break;
                    }

                    if (!this.GetRoom().GetGameMap().SquareTakingOpen(NewPoint.X, NewPoint.Y))
                    {
                        List <RoomUser> Users = this.GetRoom().GetGameMap().GetNearUsers(new Point(NewPoint.X, NewPoint.Y), 1);
                        if (Users != null)
                        {
                            bool BreakMe = false;
                            foreach (RoomUser User in Users)
                            {
                                if (User == null || this.InteractingUser == User.VirtualId)
                                {
                                    continue;
                                }

                                if (User.SetX != NewPoint.X || User.SetY != NewPoint.Y)
                                {
                                    continue;
                                }

                                if (User.SetStep && User.SetX == User.GoalX && User.SetY == User.GoalY)
                                {
                                    this.interactionCountHelper = 6;
                                    this.InteractingUser        = User.VirtualId;
                                    this.MovementDir            = MovementManagement.GetMovementByDirection(User.RotBody);
                                    BreakMe = true;
                                    break;
                                }
                            }

                            if (BreakMe)
                            {
                                break;
                            }
                        }
                    }

                    this.interactionCountHelper--;
                }

                double Z = this.GetRoom().GetGameMap().SqAbsoluteHeight(NewX, NewY);
                this.GetRoom().GetRoomItemHandler().PositionReset(this, NewX, NewY, Z);

                this.UpdateCounter = 1;
                break;

            case InteractionType.ChronoTimer:
                if (string.IsNullOrEmpty(this.ExtraData))
                {
                    break;
                }
                int NumChrono = 0;
                if (!int.TryParse(this.ExtraData, out NumChrono))
                {
                    break;
                }
                if (!this.ChronoStarter)
                {
                    break;
                }

                if (NumChrono > 0)
                {
                    if (this.interactionCountHelper == 1)
                    {
                        NumChrono--;

                        /*if (!this.GetRoom().GetBanzai().isBanzaiActive || !this.GetRoom().GetFreeze().isGameActive)
                         * {
                         *  NumChrono = 0;
                         * }*/
                        this.interactionCountHelper = 0;
                        this.ExtraData = NumChrono.ToString();
                        this.UpdateState();
                    }
                    else
                    {
                        this.interactionCountHelper++;
                    }

                    this.UpdateCounter = 1;
                    break;
                }
                else
                {
                    this.ChronoStarter = false;
                    this.GetRoom().GetGameManager().StopGame();
                    break;
                }

            case InteractionType.banzaitele:
                if (this.InteractingUser == 0)
                {
                    this.ExtraData = string.Empty;
                    this.UpdateState();
                    break;
                }

                this.ExtraData = "1";
                this.UpdateState();

                this.UpdateCounter = 1;

                RoomUser roomUserByHabbo = this.GetRoom().GetRoomUserManager().GetRoomUserByHabboId(this.InteractingUser);
                if (roomUserByHabbo != null)
                {
                    this.GetRoom().GetGameMap().TeleportToItem(roomUserByHabbo, this);
                    roomUserByHabbo.SetRot(ButterflyEnvironment.GetRandomNumber(0, 7), false);
                    roomUserByHabbo.CanWalk = true;
                }
                this.InteractingUser = 0;

                break;

            case InteractionType.freezetile:
                if (this.InteractingUser <= 0)
                {
                    break;
                }
                RoomUser roomUserByHabbo3 = this.GetRoom().GetRoomUserManager().GetRoomUserByHabboId(this.InteractingUser);
                if (roomUserByHabbo3 != null)
                {
                    roomUserByHabbo3.CountFreezeBall = 1;
                }
                this.ExtraData = "11000";
                this.UpdateState(false, true);
                this.GetRoom().GetFreeze().onFreezeTiles(this, this.freezePowerUp, this.InteractingUser);
                this.InteractingUser        = 0;
                this.interactionCountHelper = (byte)0;
                break;

            case InteractionType.scoreboard:
                if (string.IsNullOrEmpty(this.ExtraData))
                {
                    break;
                }
                int num4 = 0;
                try
                {
                    num4 = int.Parse(this.ExtraData);
                }
                catch
                {
                }
                if (num4 > 0)
                {
                    if (this.interactionCountHelper == 1)
                    {
                        int num2 = num4 - 1;
                        this.interactionCountHelper = (byte)0;
                        this.ExtraData = num2.ToString();
                        this.UpdateState();
                    }
                    else
                    {
                        this.interactionCountHelper++;
                    }
                    this.UpdateCounter = 1;
                    break;
                }
                else
                {
                    this.UpdateCounter = 0;
                    break;
                }

            case InteractionType.vendingmachine:
                if (!(this.ExtraData == "1"))
                {
                    break;
                }
                RoomUser roomUserByHabbo1 = this.GetRoom().GetRoomUserManager().GetRoomUserByHabboId(this.InteractingUser);
                if (roomUserByHabbo1 != null)
                {
                    int num2 = this.GetBaseItem().VendingIds[ButterflyEnvironment.GetRandomNumber(0, this.GetBaseItem().VendingIds.Count - 1)];
                    roomUserByHabbo1.CarryItem(num2);
                }
                this.InteractingUser = 0;
                this.ExtraData       = "0";
                this.UpdateState(false, true);
                break;

            case InteractionType.vendingenablemachine:
                if (!(this.ExtraData == "1"))
                {
                    break;
                }
                RoomUser roomUserByHabboEnable = this.GetRoom().GetRoomUserManager().GetRoomUserByHabboId(this.InteractingUser);
                if (roomUserByHabboEnable != null)
                {
                    int num2 = this.GetBaseItem().VendingIds[ButterflyEnvironment.GetRandomNumber(0, this.GetBaseItem().VendingIds.Count - 1)];
                    roomUserByHabboEnable.ApplyEffect(num2);
                }
                this.InteractingUser = 0;
                this.ExtraData       = "0";
                this.UpdateState(false, true);
                break;

            case InteractionType.alert:
                if (!(this.ExtraData == "1"))
                {
                    break;
                }
                this.ExtraData = "0";
                this.UpdateState(false, true);
                break;

            case InteractionType.onewaygate:
                RoomUser roomUser3 = (RoomUser)null;
                if (this.InteractingUser > 0)
                {
                    roomUser3 = this.GetRoom().GetRoomUserManager().GetRoomUserByHabboId(this.InteractingUser);
                }

                if (roomUser3 == null)
                {
                    this.InteractingUser = 0;
                    break;
                }

                if (roomUser3.Coordinate == this.SquareBehind || !Gamemap.TilesTouching(this.GetX, this.GetY, roomUser3.X, roomUser3.Y))
                {
                    roomUser3.UnlockWalking();
                    this.ExtraData       = "0";
                    this.InteractingUser = 0;
                    this.UpdateState(false, true);
                }
                else
                {
                    roomUser3.CanWalk       = false;
                    roomUser3.AllowOverride = true;
                    roomUser3.MoveTo(this.SquareBehind);

                    this.UpdateCounter = 1;
                }

                break;

            case InteractionType.loveshuffler:
                if (this.ExtraData == "0")
                {
                    this.ExtraData = ButterflyEnvironment.GetRandomNumber(1, 4).ToString();
                    this.ReqUpdate(20);
                }
                else if (this.ExtraData != "-1")
                {
                    this.ExtraData = "-1";
                }
                this.UpdateState(false, true);
                break;

            case InteractionType.habbowheel:
                this.ExtraData = ButterflyEnvironment.GetRandomNumber(1, 10).ToString();
                this.UpdateState();
                break;

            case InteractionType.dice:
                this.ExtraData = ButterflyEnvironment.GetRandomNumber(1, 6).ToString();
                this.UpdateState();
                break;

            case InteractionType.bottle:
                this.ExtraData = ButterflyEnvironment.GetRandomNumber(0, 7).ToString();
                this.UpdateState();
                break;

            case InteractionType.TELEPORT:
            case InteractionType.ARROW:
                bool keepDoorOpen   = false;
                bool showTeleEffect = false;
                if (this.InteractingUser > 0)
                {
                    RoomUser roomUserByHabbo2 = this.GetRoom().GetRoomUserManager().GetRoomUserByHabboId(this.InteractingUser);
                    if (roomUserByHabbo2 != null)
                    {
                        if (roomUserByHabbo2.Coordinate == this.Coordinate)
                        {
                            roomUserByHabbo2.AllowOverride = false;
                            if (ItemTeleporterFinder.IsTeleLinked(this.Id, this.mRoom))
                            {
                                showTeleEffect = true;
                                int linkedTele = ItemTeleporterFinder.GetLinkedTele(this.Id);
                                int teleRoomId = ItemTeleporterFinder.GetTeleRoomId(linkedTele, this.mRoom);
                                if (teleRoomId == this.RoomId)
                                {
                                    Item roomItem = this.GetRoom().GetRoomItemHandler().GetItem(linkedTele);
                                    if (roomItem == null)
                                    {
                                        roomUserByHabbo2.UnlockWalking();
                                    }
                                    else
                                    {
                                        roomUserByHabbo2.SetRot(roomItem.Rotation, false);
                                        roomItem.GetRoom().GetGameMap().TeleportToItem(roomUserByHabbo2, roomItem);
                                        roomItem.ExtraData = "2";
                                        roomItem.UpdateState(false, true);
                                        roomItem.InteractingUser2 = this.InteractingUser;
                                        roomItem.ReqUpdate(2);
                                    }
                                }
                                else if (!roomUserByHabbo2.IsBot && roomUserByHabbo2 != null && (roomUserByHabbo2.GetClient() != null && roomUserByHabbo2.GetClient().GetHabbo() != null))
                                {
                                    roomUserByHabbo2.GetClient().GetHabbo().IsTeleporting     = true;
                                    roomUserByHabbo2.GetClient().GetHabbo().TeleportingRoomID = teleRoomId;
                                    roomUserByHabbo2.GetClient().GetHabbo().TeleporterId      = linkedTele;
                                    roomUserByHabbo2.GetClient().GetHabbo().PrepareRoom(teleRoomId, "");
                                }
                                this.InteractingUser = 0;
                            }
                            else
                            {
                                roomUserByHabbo2.UnlockWalking();
                                this.InteractingUser = 0;
                            }
                        }
                        else if (roomUserByHabbo2.Coordinate == this.SquareInFront)
                        {
                            roomUserByHabbo2.AllowOverride = true;
                            keepDoorOpen = true;

                            roomUserByHabbo2.CanWalk       = false;
                            roomUserByHabbo2.AllowOverride = true;
                            roomUserByHabbo2.MoveTo(this.Coordinate.X, this.Coordinate.Y, true);
                        }
                        else
                        {
                            this.InteractingUser = 0;
                        }
                    }
                    else
                    {
                        this.InteractingUser = 0;
                    }

                    this.UpdateCounter = 1;
                }
                if (this.InteractingUser2 > 0)
                {
                    RoomUser roomUserByHabbo2 = this.GetRoom().GetRoomUserManager().GetRoomUserByHabboId(this.InteractingUser2);
                    if (roomUserByHabbo2 != null)
                    {
                        keepDoorOpen = true;
                        roomUserByHabbo2.UnlockWalking();
                        roomUserByHabbo2.MoveTo(this.SquareInFront);
                    }
                    this.UpdateCounter    = 1;
                    this.InteractingUser2 = 0;
                }
                if (keepDoorOpen)
                {
                    if (this.ExtraData != "1")
                    {
                        this.ExtraData = "1";
                        this.UpdateState(false, true);
                    }
                }
                else if (showTeleEffect)
                {
                    if (this.ExtraData != "2")
                    {
                        this.ExtraData = "2";
                        this.UpdateState(false, true);
                    }
                }
                else if (this.ExtraData != "0")
                {
                    this.ExtraData = "0";
                    this.UpdateState(false, true);
                }

                break;
            }
        }
        public void OnCycle()
        {
            if (_projectile.Count == 0 && _queueProjectile.Count == 0)
            {
                return;
            }

            foreach (ItemTemp Item in _projectile.ToArray())
            {
                if (Item == null)
                {
                    continue;
                }

                bool            EndProjectile = false;
                List <RoomUser> UsersTouch    = new List <RoomUser>();
                Point           newPoint      = new Point(Item.X, Item.Y);
                int             newX          = Item.X;
                int             newY          = Item.Y;
                double          newZ          = Item.Z;

                if (Item.InteractionType == InteractionTypeTemp.GRENADE)
                {
                    newPoint = MovementManagement.GetMoveCoord(Item.X, Item.Y, 1, Item.Movement);
                    newX     = newPoint.X;
                    newY     = newPoint.Y;

                    if (Item.Distance > 2)
                    {
                        newZ += 1;
                    }
                    else
                    {
                        newZ -= 1;
                    }

                    if (Item.Distance <= 0)
                    {
                        //explosion
                        UsersTouch = _room.GetGameMap().GetNearUsers(new Point(newPoint.X, newPoint.Y), 2);

                        EndProjectile = true;
                    }

                    Item.Distance--;
                }
                else
                {
                    for (int i = 1; i <= 3; i++)
                    {
                        newPoint = MovementManagement.GetMoveCoord(Item.X, Item.Y, i, Item.Movement);

                        UsersTouch = _room.GetGameMap().GetRoomUsers(newPoint);

                        foreach (RoomUser UserTouch in UsersTouch)
                        {
                            if (CheckUserTouch(UserTouch, Item))
                            {
                                EndProjectile = true;
                            }
                        }

                        if ((_room.GetGameMap().CanStackItem(newPoint.X, newPoint.Y, true) && (_room.GetGameMap().SqAbsoluteHeight(newPoint.X, newPoint.Y) <= Item.Z + 0.5)))
                        {
                            newX = newPoint.X;
                            newY = newPoint.Y;
                        }
                        else
                        {
                            EndProjectile = true;
                        }

                        if (EndProjectile)
                        {
                            break;
                        }

                        Item.Distance--;
                        if (Item.Distance <= 0)
                        {
                            EndProjectile = true;
                            break;
                        }
                    }
                }

                ServerPacket Message = new ServerPacket(ServerPacketHeader.SlideObjectBundleMessageComposer);
                Message.WriteInteger(Item.X);
                Message.WriteInteger(Item.Y);
                Message.WriteInteger(newX);
                Message.WriteInteger(newY);
                Message.WriteInteger(1);
                Message.WriteInteger(Item.Id);
                Message.WriteString(Item.Z.ToString().Replace(',', '.'));
                Message.WriteString(newZ.ToString().Replace(',', '.'));
                Message.WriteInteger(0);
                _messages.Add(Message);

                Item.X = newX;
                Item.Y = newY;
                Item.Z = newZ;

                if (EndProjectile)
                {
                    foreach (RoomUser UserTouch in UsersTouch)
                    {
                        this.CheckUserHit(UserTouch, Item);
                    }

                    RemoveProjectile(Item);
                }
            }

            Dictionary <int, int> BulletUser = new Dictionary <int, int>();

            if (this._queueProjectile.Count > 0)
            {
                List <ItemTemp> toAdd = new List <ItemTemp>();
                while (this._queueProjectile.Count > 0)
                {
                    ItemTemp Item = (ItemTemp)null;
                    if (this._queueProjectile.TryDequeue(out Item))
                    {
                        if (!BulletUser.ContainsKey(Item.VirtualUserId))
                        {
                            BulletUser.Add(Item.VirtualUserId, 1);
                            this._projectile.Add(Item);
                        }
                        else
                        {
                            BulletUser[Item.VirtualUserId]++;

                            //if (BulletUser[Item.VirtualUserId] > 3)
                            //this._room.GetRoomItemHandler().RemoveTempItem(Item.Id);
                            //else
                            toAdd.Add(Item);
                        }
                    }
                }
                foreach (ItemTemp Item in toAdd)
                {
                    this._queueProjectile.Enqueue(Item);
                }

                toAdd.Clear();
            }

            BulletUser.Clear();
            _room.SendMessage(_messages);
            _messages.Clear();
        }