コード例 #1
0
        internal RoomItem(UInt32 Id, UInt32 RoomId, UInt32 BaseItem, IRoomItemData data, int extra, WallCoordinate wallCoord, Room pRoom)
        {
            this.Id                  = Id;
            this.RoomId              = RoomId;
            this.BaseItem            = BaseItem;
            this.data                = data;
            this.Extra               = extra;
            this.originalExtraData   = data;
            this.mX                  = 0;
            this.mY                  = 0;
            this.mZ                  = 0.0;
            this.UpdateNeeded        = false;
            this.UpdateCounter       = 0;
            this.InteractingUser     = 0;
            this.InteractingUser2    = 0;
            this.IsTrans             = false;
            this.interactingBallUser = 0;
            this.interactionCount    = 0;
            this.value               = 0;
            this.placedPosition      = new Point(0, 0);
            this.wallCoord           = wallCoord;

            mBaseItem = FirewindEnvironment.GetGame().GetItemManager().GetItem(BaseItem);
            mRoom     = pRoom;

            if (GetBaseItem() == null)
            {
                Logging.LogException("Unknown baseID: " + BaseItem);
            }

            mIsWallItem     = true;
            mIsFloorItem    = false;
            mAffectedPoints = new Dictionary <int, ThreeDCoord>();
        }
コード例 #2
0
ファイル: UserItem.cs プロジェクト: Habbotard/Firewind
 internal UserItem(UInt32 Id, UInt32 BaseItem, IRoomItemData data, int extra)
 {
     this.Id        = Id;
     this.BaseItem  = BaseItem;
     this.Data      = data;
     this.Extra     = extra;
     this.mBaseItem = GetBaseItem();
     if (mBaseItem == null)
     {
         Logging.WriteLine("Unknown baseItem ID: " + BaseItem);
         Logging.LogException("Unknown baseItem ID: " + BaseItem);
         return;
     }
     this.isWallItem = (mBaseItem.Type == 'i');
 }
コード例 #3
0
ファイル: UserItem.cs プロジェクト: TheNaked/Firewind
 internal UserItem(UInt32 Id, UInt32 BaseItem, IRoomItemData data, int extra)
 {
     this.Id = Id;
     this.BaseItem = BaseItem;
     this.Data = data;
     this.Extra = extra;
     this.mBaseItem = GetBaseItem();
     if (mBaseItem == null)
     {
         Logging.WriteLine("Unknown baseItem ID: " + BaseItem);
         Logging.LogException("Unknown baseItem ID: " + BaseItem);
         return;
     }
     this.isWallItem = (mBaseItem.Type == 'i');
 }
コード例 #4
0
        internal void ProcessUpdates()
        {
            this.UpdateCounter--;

            if (this.UpdateCounter <= 0 || IsTrans)
            {
                this.UpdateNeeded  = false;
                this.UpdateCounter = 0;

                RoomUser User  = null;
                RoomUser User2 = null;

                switch (GetBaseItem().InteractionType)
                {
                case InteractionType.gift:
                    // do nothing
                    break;

                case InteractionType.onewaygate:

                    User = null;

                    if (InteractingUser > 0)
                    {
                        User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);
                        //GetRoom().FreeSqareForUsers(mX, mY);
                    }

                    if (User != null && User.Coordinate == SquareBehind)
                    {
                        User.UnlockWalking();

                        //data =  new StringData("0");
                        InteractingUser = 0;

                        ServerMessage update = new ServerMessage(Outgoing.OneWayDoorStatus);
                        update.AppendUInt(Id);     // id
                        update.AppendInt32(0);     // status
                        mRoom.SendMessage(update);
                    }
                    else if (data.ToString() == "1")
                    {
                        //data =  new StringData("0");

                        ServerMessage update = new ServerMessage(Outgoing.OneWayDoorStatus);
                        update.AppendUInt(Id);     // id
                        update.AppendInt32(0);     // status
                        mRoom.SendMessage(update);
                    }

                    if (User == null)
                    {
                        InteractingUser = 0;
                    }

                    break;

                case InteractionType.teleport:
                    User  = null;
                    User2 = null;

                    bool keepDoorOpen   = false;
                    bool showTeleEffect = false;

                    // Do we have a primary user that wants to go somewhere?
                    if (InteractingUser > 0)
                    {
                        User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);

                        // Is this user okay?
                        if (User != null)
                        {
                            // Is he in the tele?
                            if (User.Coordinate == Coordinate)
                            {
                                //Remove the user from the square
                                User.AllowOverride = false;

                                if (TeleHandler.IsTeleLinked(Id, mRoom))
                                {
                                    showTeleEffect = true;

                                    if (true)
                                    {
                                        // Woop! No more delay.
                                        uint TeleId = TeleHandler.GetLinkedTele(Id, mRoom);
                                        uint RoomId = TeleHandler.GetTeleRoomId(TeleId, mRoom);

                                        // Do we need to tele to the same room or gtf to another?
                                        if (RoomId == this.RoomId)
                                        {
                                            RoomItem Item = GetRoom().GetRoomItemHandler().GetItem(TeleId);

                                            if (Item == null)
                                            {
                                                User.UnlockWalking();
                                            }
                                            else
                                            {
                                                // Set pos
                                                User.SetPos(Item.GetX, Item.GetY, Item.GetZ);
                                                User.SetRot(Item.Rot, false);

                                                // Force tele effect update (dirty)
                                                Item.data = new StringData("2");
                                                Item.UpdateState(false, true);

                                                // Set secondary interacting user
                                                Item.InteractingUser2 = InteractingUser;
                                            }
                                        }
                                        else
                                        {
                                            // Let's run the teleport delegate to take futher care of this.. WHY DARIO?!
                                            if (!User.IsBot && User != null && User.GetClient() != null && User.GetClient().GetHabbo() != null && User.GetClient().GetMessageHandler() != null)
                                            {
                                                User.GetClient().GetHabbo().IsTeleporting     = true;
                                                User.GetClient().GetHabbo().TeleportingRoomID = RoomId;
                                                User.GetClient().GetHabbo().TeleporterId      = TeleId;
                                                User.GetClient().GetMessageHandler().ForwardToRoom((int)RoomId);
                                            }
                                            else
                                            {
                                            }
                                            //FirewindEnvironment.GetGame().GetRoomManager().AddTeleAction(new TeleUserData(User.GetClient().GetMessageHandler(), User.GetClient().GetHabbo(), RoomId, TeleId));
                                        }

                                        // We're done with this tele. We have another one to bother.
                                        InteractingUser = 0;
                                    }
                                    else
                                    {
                                        // We're linked, but there's a delay, so decrease the delay and wait it out.
                                        //User.TeleDelay--;
                                    }
                                }
                                else
                                {
                                    // This tele is not linked, so let's gtfo.
                                    User.UnlockWalking();
                                    InteractingUser = 0;
                                }
                            }
                            // Is he in front of the tele?
                            else if (User.Coordinate == SquareInFront)
                            {
                                User.AllowOverride = true;
                                // Open the door
                                keepDoorOpen = true;

                                // Lock his walking. We're taking control over him. Allow overriding so he can get in the tele.
                                if (User.IsWalking && (User.GoalX != mX || User.GoalY != mY))
                                {
                                    User.ClearMovement(true);
                                }

                                User.CanWalk       = false;
                                User.AllowOverride = true;

                                // Move into the tele
                                User.MoveTo(Coordinate.X, Coordinate.Y, true);
                            }
                            // Not even near, do nothing and move on for the next user.
                            else
                            {
                                InteractingUser = 0;
                            }
                        }
                        else
                        {
                            // Invalid user, do nothing and move on for the next user.
                            InteractingUser = 0;
                        }
                    }

                    // Do we have a secondary user that wants to get out of the tele?
                    if (InteractingUser2 > 0)
                    {
                        User2 = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser2);

                        // Is this user okay?
                        if (User2 != null)
                        {
                            // If so, open the door, unlock the user's walking, and try to push him out in the right direction. We're done with him!
                            keepDoorOpen = true;
                            User2.UnlockWalking();
                            User2.MoveTo(SquareInFront);
                        }

                        // This is a one time thing, whether the user's valid or not.
                        InteractingUser2 = 0;
                    }

                    // Set the new item state, by priority
                    if (keepDoorOpen)
                    {
                        if (data.ToString() != "1")
                        {
                            data = new StringData("1");
                            UpdateState(false, true);
                        }
                    }
                    else if (showTeleEffect)
                    {
                        if (data.ToString() != "2")
                        {
                            data = new StringData("2");
                            UpdateState(false, true);
                        }
                    }
                    else
                    {
                        if (data.ToString() != "0")
                        {
                            data = new StringData("0");
                            UpdateState(false, true);
                        }
                    }

                    // We're constantly going!
                    ReqUpdate(1, false);

                    break;

                case InteractionType.bottle:

                    data = new StringData(FirewindEnvironment.GetRandomNumber(0, 7).ToString());
                    UpdateState();
                    break;

                case InteractionType.dice:

                    data = new StringData(FirewindEnvironment.GetRandomNumber(1, 6).ToString());
                    UpdateState();
                    break;

                case InteractionType.habbowheel:

                    data = new StringData(FirewindEnvironment.GetRandomNumber(1, 10).ToString());
                    UpdateState();
                    break;

                case InteractionType.loveshuffler:

                    if (data.GetData() == "0")
                    {
                        data = new StringData(FirewindEnvironment.GetRandomNumber(1, 4).ToString());
                        ReqUpdate(20, false);
                    }
                    else if (data.GetData() != "-1")
                    {
                        data = new StringData("-1");
                    }

                    UpdateState(false, true);
                    break;

                case InteractionType.alert:

                    if (data.GetData() == "1")
                    {
                        data = new StringData("0");
                        UpdateState(false, true);
                    }

                    break;

                case InteractionType.vendingmachine:

                    if (data.GetData() == "1")
                    {
                        User = GetRoom().GetRoomUserManager().GetRoomUserByHabbo(InteractingUser);

                        if (User != null)
                        {
                            User.UnlockWalking();

                            int randomDrink = GetBaseItem().VendingIds[FirewindEnvironment.GetRandomNumber(0, (GetBaseItem().VendingIds.Count - 1))];
                            User.CarryItem(randomDrink);
                        }

                        this.InteractingUser = 0;
                        data = new StringData("0");

                        UpdateState(false, true);
                    }

                    break;


                case InteractionType.scoreboard:
                {
                    if (string.IsNullOrEmpty((string)data.GetData()))
                    {
                        break;
                    }


                    int seconds = 0;

                    try
                    {
                        seconds = int.Parse((string)data.GetData());
                    }
                    catch { }

                    if (seconds > 0)
                    {
                        if (interactionCountHelper == 1)
                        {
                            seconds--;
                            interactionCountHelper = 0;

                            data = new StringData(seconds.ToString());
                            UpdateState();
                        }
                        else
                        {
                            interactionCountHelper++;
                        }

                        UpdateCounter = 1;
                    }
                    else
                    {
                        UpdateCounter = 0;
                    }

                    break;
                }

                case InteractionType.banzaicounter:
                {
                    if (string.IsNullOrEmpty((string)data.GetData()))
                    {
                        break;
                    }

                    int seconds = 0;

                    try
                    {
                        seconds = int.Parse((string)data.GetData());
                    }
                    catch { }

                    if (seconds > 0)
                    {
                        if (interactionCountHelper == 1)
                        {
                            seconds--;
                            interactionCountHelper = 0;

                            if (GetRoom().GetBanzai().isBanzaiActive)
                            {
                                ((StringData)data).Data = seconds.ToString();
                                UpdateState();
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            interactionCountHelper++;
                        }

                        UpdateCounter = 1;
                    }
                    else
                    {
                        UpdateCounter = 0;
                        GetRoom().GetBanzai().BanzaiEnd();
                    }

                    break;
                }

                case InteractionType.banzaitele:
                {
                    ((StringData)data).Data = string.Empty;
                    UpdateState();
                    break;
                }

                /*
                 * 3 = Red 1
                 * 4 = Red 2
                 * 5 = Red 3
                 *
                 * 6 = Green 1
                 * 7 = Green 2
                 * 8 = Green 3
                 *
                 * 9 = Blue 1
                 * 10= Blue 2
                 * 11= Blue 3
                 *
                 * 12= Yellow 1
                 * 13= Yellow 2
                 * 14= Yellow 3
                 */
                case InteractionType.banzaifloor:
                {
                    if (value == 3)
                    {
                        if (interactionCountHelper == 1)
                        {
                            interactionCountHelper = 0;

                            switch (team)
                            {
                            case Team.blue:
                            {
                                ((StringData)data).Data = "11";
                                break;
                            }

                            case Team.green:
                            {
                                ((StringData)data).Data = "8";
                                break;
                            }

                            case Team.red:
                            {
                                ((StringData)data).Data = "5";
                                break;
                            }

                            case Team.yellow:
                            {
                                ((StringData)data).Data = "14";
                                break;
                            }
                            }
                        }
                        else
                        {
                            ((StringData)data).Data = "";
                            interactionCountHelper++;
                        }

                        UpdateState();

                        interactionCount++;

                        if (interactionCount < 16)
                        {
                            UpdateCounter = 1;
                        }
                        else
                        {
                            UpdateCounter = 0;
                        }
                    }
                    break;
                }

                case InteractionType.banzaipuck:
                {
                    if (interactionCount > 4)
                    {
                        interactionCount++;
                        UpdateCounter = 1;
                    }
                    else
                    {
                        interactionCount = 0;
                        UpdateCounter    = 0;
                    }

                    break;
                }

                case InteractionType.freezetile:
                {
                    if (InteractingUser > 0)
                    {
                        ((StringData)data).Data = "11000";
                        UpdateState(false, true);

                        GetRoom().GetFreeze().onFreezeTiles(this, freezePowerUp, InteractingUser);
                        InteractingUser        = 0;
                        interactionCountHelper = 0;
                    }
                    break;
                }

                case InteractionType.freezetimer:
                {
                    if (string.IsNullOrEmpty((string)data.GetData()))
                    {
                        break;
                    }

                    int seconds = 0;

                    try
                    {
                        seconds = int.Parse(data.GetData().ToString());
                    }
                    catch { }

                    if (seconds > 0)
                    {
                        if (interactionCountHelper == 1)
                        {
                            seconds--;
                            interactionCountHelper = 0;
                            if (GetRoom().GetFreeze().GameIsStarted)
                            {
                                ((StringData)data).Data = seconds.ToString();
                                UpdateState();
                            }
                            else
                            {
                                break;
                            }
                        }
                        else
                        {
                            interactionCountHelper++;
                        }

                        UpdateCounter = 1;
                    }
                    else
                    {
                        UpdateNeeded = false;
                        GetRoom().GetFreeze().StopGame();
                    }

                    break;
                }
                }
            }
        }
コード例 #5
0
        internal RoomItem(UInt32 Id, UInt32 RoomId, UInt32 BaseItem, IRoomItemData data, int extra, int X, int Y, Double Z, int Rot, Room pRoom)
        {
            this.Id       = Id;
            this.RoomId   = RoomId;
            this.BaseItem = BaseItem;
            //this.ExtraData = data;
            this.originalExtraData = data;
            this.data  = data;
            this.Extra = extra;
            this.mX    = X;
            this.mY    = Y;
            if (!double.IsInfinity(Z))
            {
                this.mZ = Z;
            }
            this.Rot                 = Rot;
            this.UpdateNeeded        = false;
            this.UpdateCounter       = 0;
            this.InteractingUser     = 0;
            this.InteractingUser2    = 0;
            this.IsTrans             = false;
            this.interactingBallUser = 0;
            this.interactionCount    = 0;
            this.value               = 0;
            this.placedPosition      = new Point(X, Y);

            mBaseItem = FirewindEnvironment.GetGame().GetItemManager().GetItem(BaseItem);
            mRoom     = pRoom; //Todo: rub my penis

            if (GetBaseItem() == null)
            {
                Logging.LogException("Unknown baseID: " + BaseItem);
            }


            switch (GetBaseItem().InteractionType)
            {
            case InteractionType.teleport:
                IsTrans = true;
                ReqUpdate(0, true);
                break;

            case InteractionType.roller:
                mIsRoller = true;
                pRoom.GetRoomItemHandler().GotRollers = true;
                break;

            case InteractionType.banzaiscoreblue:
            case InteractionType.footballcounterblue:
            case InteractionType.banzaigateblue:
            case InteractionType.freezebluegate:
            case InteractionType.freezebluecounter:
                team = Team.blue;
                break;

            case InteractionType.banzaiscoregreen:
            case InteractionType.footballcountergreen:
            case InteractionType.banzaigategreen:
            case InteractionType.freezegreencounter:
            case InteractionType.freezegreengate:
                team = Team.green;
                break;

            case InteractionType.banzaiscorered:
            case InteractionType.footballcounterred:
            case InteractionType.banzaigatered:
            case InteractionType.freezeredcounter:
            case InteractionType.freezeredgate:
                team = Team.red;
                break;

            case InteractionType.banzaiscoreyellow:
            case InteractionType.footballcounteryellow:
            case InteractionType.banzaigateyellow:
            case InteractionType.freezeyellowcounter:
            case InteractionType.freezeyellowgate:
                team = Team.yellow;
                break;

            case InteractionType.banzaitele:
            {
                this.data = new StringData("");
                break;
            }
            }

            mIsWallItem     = (GetBaseItem().Type.ToString().ToLower() == "i");
            mIsFloorItem    = (GetBaseItem().Type.ToString().ToLower() == "s");
            mAffectedPoints = Gamemap.GetAffectedTiles(GetBaseItem().Length, GetBaseItem().Width, mX, mY, Rot);
        }
コード例 #6
0
        internal UserItem AddNewItem(UInt32 Id, UInt32 BaseItem, IRoomItemData data, int extra, bool insert, bool fromRoom, UInt32 songID = 0)
        {
            isUpdated = false;
            if (insert)
            {
                if (fromRoom)
                {
                    using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.runFastQuery("REPLACE INTO items_users VALUES (" + Id + "," + UserId + ")");

                        //dbClient.setQuery("REPLACE INTO user_items (id, user_id,base_item,extra_data) VALUES ('" + Id + "','" + UserId + "','" + BaseItem + "',@extra_data)");
                        //dbClient.addParameter("extra_data", ExtraData);
                        //dbClient.runQuery();
                    }

                    Item baseItem = FirewindEnvironment.GetGame().GetItemManager().GetItem(BaseItem);

                    if (baseItem != null && baseItem.InteractionType == InteractionType.musicdisc)
                    {
                        using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            dbClient.runFastQuery("DELETE FROM items_rooms_songs WHERE item_id = " + Id);
                            //dbClient.runFastQuery("REPLACE INTO user_items_songs (item_id,user_id,song_id) VALUES (" + Id + "," + UserId + "," + songID + ")");
                        }
                    }
                }
                else
                {
                    using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + BaseItem + ")");
                        Id = (uint)dbClient.insertQuery();

                        //if (!string.IsNullOrEmpty(ExtraData))
                        {
                            dbClient.setQuery("INSERT INTO items_extradata VALUES (" + Id + ",@datatype,@data,@extra)");
                            dbClient.addParameter("datatype", data.GetTypeID());
                            dbClient.addParameter("data", data);
                            dbClient.addParameter("extra", extra);
                            dbClient.runQuery();
                        }

                        dbClient.runFastQuery("INSERT INTO items_users VALUES (" + Id + "," + UserId + ")");
                        //dbClient.setQuery("INSERT INTO user_items (user_id,base_item,extra_data) VALUES ('" + UserId + "','" + BaseItem + "',@extra_data)");
                        //dbClient.addParameter("extra_data", ExtraData);
                        //Id = (uint)dbClient.insertQuery();
                    }
                }
            }
            UserItem ItemToAdd = new UserItem(Id, BaseItem, data, extra);

            if (UserHoldsItem(Id))
            {
                RemoveItem(Id, false);
            }

            if (ItemToAdd.GetBaseItem().InteractionType == InteractionType.musicdisc)
                discs.Add(ItemToAdd.Id, ItemToAdd);
            if (ItemToAdd.isWallItem)
                wallItems.Add(ItemToAdd.Id, ItemToAdd);
            else
                floorItems.Add(ItemToAdd.Id, ItemToAdd);

            if (mRemovedItems.Contains(Id))
                mRemovedItems.Remove(Id);

            if (!mAddedItems.ContainsKey(Id))
                mAddedItems.Add(Id, ItemToAdd);

            return ItemToAdd;
            //Logging.WriteLine("Item added: " + BaseItem);
        }
コード例 #7
0
        internal UserItem AddNewItem(UInt32 Id, UInt32 BaseItem, IRoomItemData data, int extra, bool insert, bool fromRoom, UInt32 songID = 0)
        {
            isUpdated = false;
            if (insert)
            {
                if (fromRoom)
                {
                    using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.runFastQuery("REPLACE INTO items_users VALUES (" + Id + "," + UserId + ")");

                        //dbClient.setQuery("REPLACE INTO user_items (id, user_id,base_item,extra_data) VALUES ('" + Id + "','" + UserId + "','" + BaseItem + "',@extra_data)");
                        //dbClient.addParameter("extra_data", ExtraData);
                        //dbClient.runQuery();
                    }

                    Item baseItem = FirewindEnvironment.GetGame().GetItemManager().GetItem(BaseItem);

                    if (baseItem != null && baseItem.InteractionType == InteractionType.musicdisc)
                    {
                        using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                        {
                            dbClient.runFastQuery("DELETE FROM items_rooms_songs WHERE item_id = " + Id);
                            //dbClient.runFastQuery("REPLACE INTO user_items_songs (item_id,user_id,song_id) VALUES (" + Id + "," + UserId + "," + songID + ")");
                        }
                    }
                }
                else
                {
                    using (IQueryAdapter dbClient = FirewindEnvironment.GetDatabaseManager().getQueryreactor())
                    {
                        dbClient.setQuery("INSERT INTO items (base_id) VALUES (" + BaseItem + ")");
                        Id = (uint)dbClient.insertQuery();

                        //if (!string.IsNullOrEmpty(ExtraData))
                        {
                            dbClient.setQuery("INSERT INTO items_extradata VALUES (" + Id + ",@datatype,@data,@extra)");
                            dbClient.addParameter("datatype", data.GetTypeID());
                            dbClient.addParameter("data", data.ToString());
                            dbClient.addParameter("extra", extra);
                            dbClient.runQuery();
                        }

                        dbClient.runFastQuery("INSERT INTO items_users VALUES (" + Id + "," + UserId + ")");
                        //dbClient.setQuery("INSERT INTO user_items (user_id,base_item,extra_data) VALUES ('" + UserId + "','" + BaseItem + "',@extra_data)");
                        //dbClient.addParameter("extra_data", ExtraData);
                        //Id = (uint)dbClient.insertQuery();
                    }
                }
            }
            UserItem ItemToAdd = new UserItem(Id, BaseItem, data, extra);

            if (UserHoldsItem(Id))
            {
                RemoveItem(Id, false);
            }

            if (ItemToAdd.GetBaseItem().InteractionType == InteractionType.musicdisc)
            {
                discs.Add(ItemToAdd.Id, ItemToAdd);
            }
            if (ItemToAdd.isWallItem)
            {
                wallItems.Add(ItemToAdd.Id, ItemToAdd);
            }
            else
            {
                floorItems.Add(ItemToAdd.Id, ItemToAdd);
            }

            if (mRemovedItems.Contains(Id))
            {
                mRemovedItems.Remove(Id);
            }

            if (!mAddedItems.ContainsKey(Id))
            {
                mAddedItems.Add(Id, ItemToAdd);
            }

            return(ItemToAdd);
            //Logging.WriteLine("Item added: " + BaseItem);
        }