private void FreezeUser(RoomUser user) { if (user.shieldActive || user.Team == Team.none) return; if (user.Freezed) { user.Freezed = false; user.ApplyEffect((int)user.Team + 39); return; } user.Freezed = true; user.FreezeCounter = 0; user.FreezeLives--; if (user.FreezeLives <= 0) { ServerMessage message2 = new ServerMessage(); message2.Init(Outgoing.UpdateFreezeLives); message2.AppendInt32(user.VirtualID); message2.AppendInt32(user.FreezeLives); user.GetClient().SendMessage(message2); user.ApplyEffect(-1); room.GetGameManager().AddPointToTeam(user.Team, -20, user); TeamManager t = room.GetTeamManagerForFreeze(); t.OnUserLeave(user); user.Team = Team.none; if (exitTeleport != null) room.GetGameMap().TeleportToItem(user, exitTeleport); user.Freezed = false; user.SetStep = false; user.IsWalking = false; user.UpdateNeeded = true; if (t.BlueTeam.Count <= 0 && t.RedTeam.Count <= 0 && t.GreenTeam.Count <= 0 && t.YellowTeam.Count > 0) this.StopGame(); // yellow team win else if (t.BlueTeam.Count > 0 && t.RedTeam.Count <= 0 && t.GreenTeam.Count <= 0 && t.YellowTeam.Count <= 0) this.StopGame(); // blue team win else if (t.BlueTeam.Count <= 0 && t.RedTeam.Count > 0 && t.GreenTeam.Count <= 0 && t.YellowTeam.Count <= 0) this.StopGame(); // red team win else if (t.BlueTeam.Count <= 0 && t.RedTeam.Count <= 0 && t.GreenTeam.Count > 0 && t.YellowTeam.Count <= 0) this.StopGame(); // green team win return; } room.GetGameManager().AddPointToTeam(user.Team, -10, user); user.ApplyEffect(12); ServerMessage message = new ServerMessage(); message.Init(Outgoing.UpdateFreezeLives); message.AppendInt32(user.VirtualID); message.AppendInt32(user.FreezeLives); user.GetClient().SendMessage(message); }
private void PickUpPowerUp(RoomItem item, RoomUser user) { switch (item.freezePowerUp) { case FreezePowerUp.Heart: { if (user.FreezeLives < 3) { user.FreezeLives++; room.GetGameManager().AddPointToTeam(user.Team, 10, user); } ServerMessage message = new ServerMessage(); message.Init(Outgoing.UpdateFreezeLives); message.AppendInt32(user.VirtualID); message.AppendInt32(user.FreezeLives); user.GetClient().SendMessage(message); break; } case FreezePowerUp.Shield: { ActivateShield(user); break; } case FreezePowerUp.BlueArrow: case FreezePowerUp.GreenArrow: case FreezePowerUp.OrangeSnowball: { user.banzaiPowerUp = item.freezePowerUp; break; } } item.freezePowerUp = FreezePowerUp.None; ((StringData)item.data).Data = "1" + ((StringData)item.data).Data; item.UpdateState(false, true); }
internal bool HasActiveTrade(RoomUser User) { return HasActiveTrade(User.GetClient().GetHabbo().Id); }
internal void TryStartTrade(RoomUser UserOne, RoomUser UserTwo) { if (UserOne == null || UserTwo == null || UserOne.IsTrading || UserTwo.IsTrading || HasActiveTrade(UserOne) || HasActiveTrade(UserTwo)) return; ActiveTrades.Add(new Trade(UserOne.GetClient().GetHabbo().Id, UserTwo.GetClient().GetHabbo().Id, RoomId)); }
internal void OnNewUserEnter(RoomUser user) { if (user.GetClient() == null || mSong == null) return; user.GetClient().SendMessage(JukeboxComposer.ComposePlayingComposer(mSong.SongData.Id, mSongQueuePosition, SongSyncTimestamp)); }
internal void OnUserWalk(RoomUser User) { if (User == null) return; foreach (RoomItem item in balls.Values) { int differenceX = User.X - item.GetX; int differenceY = User.Y - item.GetY; if (differenceX <= 1 && differenceX >= -1 && differenceY <= 1 && differenceY >= -1) { int NewX = differenceX * -1; int NewY = differenceY * -1; NewX = NewX + item.GetX; NewY = NewY + item.GetY; if (item.GetX == User.X && item.GetY == User.Y) { NewX = NewX * 2; NewY = NewY * 2; } if (item.interactingBallUser == User.ID && item.GetRoom().GetGameMap().ValidTile(NewX, NewY)) { item.interactingBallUser = 0; item.interactionCountHelper = 0; MoveBall(item, User.GetClient(), User.Coordinate, item.Coordinate, 6); } else if (item.GetRoom().GetGameMap().ValidTile(NewX, NewY)) { if (item.interactionCountHelper == 0) { MoveBall(item, User.GetClient(), User.Coordinate, item.Coordinate, new Random().Next(0, 6)); item.interactionCountHelper++; } else MoveBall(item, User.GetClient(), NewX, NewY); } } } }
private bool isValid(RoomUser user) { if (user.GetClient() == null) return false; if (user.GetClient().GetHabbo() == null) return false; if (user.GetClient().GetHabbo().CurrentRoomId != room.RoomId) return false; return true; }
//internal RoomUser DeployBot(RoomAI Bot) //{ // RoomUser BotUser = new RoomUser(0, room.RoomId, primaryPrivateUserID++, room, false); // int PersonalID = secondaryPrivateUserID++; // BotUser.InternalRoomID = PersonalID; // //this.UserList[PersonalID] = BotUser; // userlist.Add(PersonalID, BotUser); // DynamicRoomModel Model = room.GetGameMap().Model; // if ((Bot.X > 0 && Bot.Y > 0) && Bot.X < Model.MapSizeX && Bot.Y < Model.MapSizeY) // { // BotUser.SetPos(Bot.X, Bot.Y, Bot.Z); // BotUser.SetRot(Bot.Rot, false); // } // else // { // Bot.X = Model.DoorX; // Bot.Y = Model.DoorY; // BotUser.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ); // BotUser.SetRot(Model.DoorOrientation, false); // } // BotUser.BotData = Bot; // BotUser.BotAI = Bot.GenerateBotAI(BotUser.VirtualId); // if (BotUser.IsPet) // { // BotUser.BotAI.Init((int)Bot.BotId, BotUser.VirtualId, room.RoomId, BotUser, room); // BotUser.PetData = PetData; // BotUser.PetData.VirtualId = BotUser.VirtualId; // } // else // { // BotUser.BotAI.Init(-1, BotUser.VirtualId, room.RoomId, BotUser, room); // } // UpdateUserStatus(BotUser, false); // BotUser.UpdateNeeded = true; // ServerMessage EnterMessage = new ServerMessage(Outgoing.PlaceBot); // EnterMessage.AppendInt32(1); // BotUser.Serialize(EnterMessage); // room.SendMessage(EnterMessage); // BotUser.BotAI.OnSelfEnterRoom(); // if (BotUser.BotData.AiType == AIType.Guide) // room.guideBotIsCalled = true; // if (BotUser.IsPet) // { // if (pets.ContainsKey(BotUser.PetData.PetId)) //Pet allready placed // pets[BotUser.PetData.PetId] = BotUser; // else // pets.Add(BotUser.PetData.PetId, BotUser); // petCount++; // } // return BotUser; //} //internal void RemoveBot(int VirtualId, bool Kicked) //{ // RoomUser User = GetRoomUserByVirtualId(VirtualId); // if (User == null || !User.IsBot) // { // return; // } // if (User.IsPet) // { // pets.Remove(User.PetData.PetId); // petCount--; // } // User.BotAI.OnSelfLeaveRoom(Kicked); // ServerMessage LeaveMessage = new ServerMessage(Outgoing.UserLeftRoom); // LeaveMessage.AppendRawInt32(User.VirtualId); // room.SendMessage(LeaveMessage); // userlist.Remove(User.InternalRoomID); // //freeIDs[User.InternalRoomID] = null; //} private void UpdateUserEffect(RoomUser User, int x, int y) { byte NewCurrentUserItemEffect = room.GetGameMap().EffectMap[x, y]; if (NewCurrentUserItemEffect > 0) { ItemEffectType Type = ByteToItemEffectEnum.Parse(NewCurrentUserItemEffect); if (Type != User.CurrentItemEffect) { switch (Type) { case ItemEffectType.Iceskates: { if (User.GetClient().GetHabbo().Gender == "M") User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(38); else User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(39); User.CurrentItemEffect = ItemEffectType.Iceskates; break; } case ItemEffectType.Normalskates: { if (User.GetClient().GetHabbo().Gender == "M") { User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(55); } else { User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(56); } //56=girls //55= User.CurrentItemEffect = Type; break; } case ItemEffectType.Swim: { User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(29); User.CurrentItemEffect = Type; break; } case ItemEffectType.SwimLow: { User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(30); User.CurrentItemEffect = Type; break; } case ItemEffectType.SwimHalloween: { User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(37); User.CurrentItemEffect = Type; break; } case ItemEffectType.None: { User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyCustomEffect(-1); User.CurrentItemEffect = Type; break; } case ItemEffectType.PublicPool: { User.AddStatus("swim", string.Empty); User.CurrentItemEffect = Type; break; } } } } else if (User.CurrentItemEffect != ItemEffectType.None && NewCurrentUserItemEffect == 0) { User.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyEffect(-1); User.CurrentItemEffect = ItemEffectType.None; User.RemoveStatus("swim"); } }
internal void AddUserToRoom(GameClient Session) { RoomUser User = new RoomUser(primaryPrivateUserID++, Session, room); Users.Habbo loadingHabbo = User.GetClient().GetHabbo(); if (loadingHabbo.spamProtectionBol == true) { TimeSpan SinceLastMessage = DateTime.Now - loadingHabbo.spamFloodTime; if (SinceLastMessage.TotalSeconds < loadingHabbo.spamProtectionTime) { ServerMessage Packet = new ServerMessage(Outgoing.FloodFilter); int timeToWait = loadingHabbo.spamProtectionTime - SinceLastMessage.Seconds; Packet.AppendInt32(timeToWait); //Blocked for X sec User.GetClient().SendMessage(Packet); } } User.ID = (int)Session.GetHabbo().Id; string username = Session.GetHabbo().Username; uint userID = (uint)User.ID; if (usersByUserID.ContainsKey(userID)) usersByUserID.Remove(userID); usersByUserID.Add(Session.GetHabbo().Id, User); Session.CurrentRoomUserID = User.VirtualID; Session.GetHabbo().CurrentRoomId = room.RoomId; UnitList.Add(User.VirtualID, User); }
internal void OnUserWalk(RoomUser user) { if (user == null) return; foreach (RoomItem item in pucks.Values) { int differenceX = user.X - item.GetX; int differenceY = user.Y - item.GetY; if (differenceX <= 1 && differenceX >= -1 && differenceY <= 1 && differenceY >= -1) { int NewX = differenceX * -1; int NewY = differenceY * -1; NewX = NewX + item.GetX; NewY = NewY + item.GetY; if (item.interactingBallUser == user.ID && room.GetGameMap().ValidTile(NewX, NewY)) { item.interactingBallUser = 0; MovePuck(item, user.GetClient(), user.Coordinate, item.Coordinate, 6, user.Team); } else if (room.GetGameMap().ValidTile(NewX, NewY)) { MovePuck(item, user.GetClient(), NewX, NewY, user.Team); } } } if (banzaiStarted) { HandleBanzaiTiles(user.Coordinate, user.Team, user); } }
public void AddUser(RoomUser user) { //Logging.WriteLine("Add user to team! (" + Game + ")"); if (user.Team.Equals(Team.blue)) this.BlueTeam.Add(user); else if (user.Team.Equals(Team.red)) this.RedTeam.Add(user); else if (user.Team.Equals(Team.yellow)) this.YellowTeam.Add(user); else if (user.Team.Equals(Team.green)) this.GreenTeam.Add(user); switch (Game.ToLower()) { case "banzai": { Room room = user.GetClient().GetHabbo().CurrentRoom; foreach (RoomItem Item in room.GetRoomItemHandler().mFloorItems.Values) { if (Item.GetBaseItem().InteractionType.Equals(InteractionType.banzaigateblue)) { ((StringData)Item.data).Data = BlueTeam.Count.ToString(); Item.UpdateState(); } else if (Item.GetBaseItem().InteractionType.Equals(InteractionType.banzaigatered)) { ((StringData)Item.data).Data = RedTeam.Count.ToString(); Item.UpdateState(); } else if (Item.GetBaseItem().InteractionType.Equals(InteractionType.banzaigategreen)) { ((StringData)Item.data).Data = GreenTeam.Count.ToString(); Item.UpdateState(); } else if (Item.GetBaseItem().InteractionType.Equals(InteractionType.banzaigateyellow)) { ((StringData)Item.data).Data = YellowTeam.Count.ToString(); Item.UpdateState(); } } break; } case "freeze": { Room room = user.GetClient().GetHabbo().CurrentRoom; foreach (RoomItem Item in room.GetRoomItemHandler().mFloorItems.Values) { if (Item.GetBaseItem().InteractionType.Equals(InteractionType.freezebluegate)) { ((StringData)Item.data).Data = BlueTeam.Count.ToString(); Item.UpdateState(); } else if (Item.GetBaseItem().InteractionType.Equals(InteractionType.freezeredgate)) { ((StringData)Item.data).Data = RedTeam.Count.ToString(); Item.UpdateState(); } else if (Item.GetBaseItem().InteractionType.Equals(InteractionType.freezegreengate)) { ((StringData)Item.data).Data = GreenTeam.Count.ToString(); Item.UpdateState(); } else if (Item.GetBaseItem().InteractionType.Equals(InteractionType.freezeyellowgate)) { ((StringData)Item.data).Data = YellowTeam.Count.ToString(); Item.UpdateState(); } } break; } } }