internal void CallGuideBot() { if (Session.GetHabbo().SpectatorMode) { Session.GetHabbo().SpectatorMode = false;// Only for disable Spectator Mode Session.SendNotif(LanguageLocale.GetValue("invisible.disabled")); } else { Room Room = ButterflyEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (Room == null || !Room.CheckRights(Session, true)) { return; } if (Room.guideBotIsCalled) { Session.GetMessageHandler().GetResponse().Init(33); Session.GetMessageHandler().GetResponse().AppendInt32(4009); Session.GetMessageHandler().SendResponse(); return; } if (Session.GetHabbo().CalledGuideBot) { Session.GetMessageHandler().GetResponse().Init(33); Session.GetMessageHandler().GetResponse().AppendInt32(4010); Session.GetMessageHandler().SendResponse(); return; } RoomUser NewUser = Room.DeployBot(ButterflyEnvironment.GetGame().GetBotManager().GetBot(55)); NewUser.SetPos(Room.GetGameMap().Model.DoorX, Room.GetGameMap().Model.DoorY, Room.GetGameMap().Model.DoorZ); NewUser.UpdateNeeded = true; RoomUser RoomOwner = Room.GetRoomUserManager().GetRoomUserByHabbo(Room.Owner); if (RoomOwner != null) { NewUser.MoveTo(RoomOwner.Coordinate); NewUser.SetRot(Rotation.Calculate(NewUser.X, NewUser.Y, RoomOwner.X, RoomOwner.Y), false); } Session.GetHabbo().CalledGuideBot = true; } }
/// <summary> /// Adds user to a MWTeam /// </summary> public bool AddUserToGame(GameClient User, string TeamString) { if (User == null || User.GetHabbo() == null || User.GetRoleplay() == null) { return(false); } if (User.GetRoleplay().InMafiaWars == true) { return(false); } // Gets the MWTeam the user requested to join via the dictionary MWTeam MWTeamRequested = MWTeams[TeamString]; if (MWTeamRequested == null) { return(false); } if (MWTeamRequested.WaitingAreaPOS == null) { return(false); } RoomUser RUser = User.GetHabbo().GetRoomUser(); if (RUser == null) { return(false); } User.GetRoleplay().TeamString = TeamString; User.GetRoleplay().InMafiaWars = true; MWTeamRequested.Players.Add(User, 0); User.GetRoleplay().figBeforeWar = User.GetHabbo().Look; User.GetHabbo().Look = RoleplayManager.SplitFigure(User.GetHabbo().Look) + MWTeamRequested.Look; User.GetRoleplay().RefreshVals(); RUser.SetPos(MWTeamRequested.WaitingAreaPOS.X, MWTeamRequested.WaitingAreaPOS.Y, 0); RUser.ClearMovement(); // Attempt to start the game StartGame(); return(true); }
internal void CallGuideBot() { Room Room = FirewindEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (Room == null || !Room.CheckRights(Session, true)) { return; } if (Room.guideBotIsCalled) { Session.GetMessageHandler().GetResponse().Init(33); Session.GetMessageHandler().GetResponse().AppendInt32(4009); Session.GetMessageHandler().SendResponse(); return; } if (Session.GetHabbo().CalledGuideBot) { Session.GetMessageHandler().GetResponse().Init(33); Session.GetMessageHandler().GetResponse().AppendInt32(4010); Session.GetMessageHandler().SendResponse(); return; } RoomUser NewUser = Room.DeployBot(FirewindEnvironment.GetGame().GetBotManager().GetBot(55)); NewUser.SetPos(Room.GetGameMap().Model.DoorX, Room.GetGameMap().Model.DoorY, Room.GetGameMap().Model.DoorZ); NewUser.UpdateNeeded = true; RoomUser RoomOwner = Room.GetRoomUserManager().GetRoomUserByHabbo(Room.Owner); if (RoomOwner != null) { NewUser.MoveTo(RoomOwner.Coordinate); NewUser.SetRot(Rotation.Calculate(NewUser.X, NewUser.Y, RoomOwner.X, RoomOwner.Y), false); } Session.GetHabbo().CalledGuideBot = true; }
public void parse(GameClient Session, ClientMessage Event) { Room @class = PhoenixEnvironment.GetGame().GetRoomManager().GetRoom(Session.GetHabbo().CurrentRoomId); if (@class != null && @class.CheckRights(Session, true)) { for (int i = 0; i < @class.UserList.Length; i++) { RoomUser class2 = @class.UserList[i]; if (class2 != null && (class2.IsBot && class2.BotData.AiType == AIType.Guide)) { ServerMessage Message = new ServerMessage(33u); Message.AppendInt32(4009); Session.SendMessage(Message); return; } } if (Session.GetHabbo().CalledGuideBot) { ServerMessage Message = new ServerMessage(33u); Message.AppendInt32(4010); Session.SendMessage(Message); } else { RoomUser class3 = @class.method_3(PhoenixEnvironment.GetGame().GetBotManager().GetBot(2u)); class3.SetPos(@class.Model.DoorX, @class.Model.DoorY, @class.Model.DoorZ); class3.UpdateNeeded = true; RoomUser class4 = @class.GetRoomUserByHabbo(@class.Owner); if (class4 != null) { class3.MoveTo(class4.Coordinate); class3.SetRot(Rotation.Calculate(class3.X, class3.Y, class4.X, class4.Y)); } PhoenixEnvironment.GetGame().GetAchievementManager().UnlockAchievement(Session, 6u, 1); Session.GetHabbo().CalledGuideBot = true; } } }
public static void ForceAddPlayerToTeam(GameClient Player, string team, RoomItem BanZaiTele = null, bool ForceAdd = false, bool sendToRoom = false) { try { // If we actually have a player if (Player != null && Player.GetRoleplay() != null && Player.GetHabbo() != null) { // If the match has not started if (!Started) { // If the player is not in colour wars if (!Player.GetRoleplay().inColourWars) { // Get the team selected Team ActualTeam = GetTeamByName(team); // Now get the team based on balance // Lets attempt to add the user to the team ActualTeam.AddPlayerToTeam(Player); // TODO: Change user motto, game state CustomizePlayer(Player, ActualTeam); // Set the players set & game state Player.GetRoleplay().ColourWarTeam = ActualTeam; Player.GetRoleplay().inColourWars = true; if (Player.GetHabbo().CurrentRoomId != 96 && !sendToRoom) { Player.GetMessageHandler().PrepareRoomForUser(96, ""); } // Get the room user RoomUser RUser = Player.GetHabbo().GetRoomUser(); // If it created the room user if (RUser != null) { // Set the users position RUser.SetPos(ActualTeam.WAX, ActualTeam.WAY, ActualTeam.WAZ); // Set effect if (Player.GetRoleplay() != null) { Player.GetRoleplay().EffectSeconds--; } RUser.ApplyEffect(4); // Clear movement RUser.ClearMovement(); } // Hmm, let's see if we can actually start the game TryStart(); } } else { if (!Player.GetRoleplay().inColourWars) { // Get the team selected Team ActualTeam = GetTeamByName(team); // Now get the team based on balance // Lets attempt to add the user to the team ActualTeam.AddPlayerToTeam(Player); // TODO: Change user motto, game state CustomizePlayer(Player, ActualTeam); // Set the players set & game state Player.GetRoleplay().ColourWarTeam = ActualTeam; Player.GetRoleplay().inColourWars = true; // Get the room user RoomUser RUser = Player.GetHabbo().GetRoomUser(); // If it created the room user if (RUser != null) { // Set the users position if (!sendToRoom) { Player.GetMessageHandler().PrepareRoomForUser(ActualTeam.BaseRID, ""); } Player.GetRoleplay().CurHealth = 120; Player.GetRoleplay().Energy = 100; Player.GetRoleplay().Hunger = 0; } } } } } catch (Exception ex) { Logging.LogCriticalException("Error in ForceAddPlayerToTeam() void " + ex.Message + "::" + ex.StackTrace); } }
/// <summary> /// Adds the player to the team /// </summary> /// <param name="Player">The player to add</param> public static void AddPlayerToTeam(GameClient Player, string team, RoomItem BanZaiTele = null) { try { // If we actually have a player if (Player != null && Player.GetRoleplay() != null && Player.GetHabbo() != null) { // If the match has not started if (!Started) { // If the player is not in colour wars if (!Player.GetRoleplay().inColourWars) { if (getPlayerCount() < 24) { // Get the team selected Team TeamSelected = GetTeamByName(team); // Now get the team based on balance Team ActualTeam = GetTeamBalanced(TeamSelected, Player); // Lets attempt to add the user to the team ActualTeam.AddPlayerToTeam(Player); // TODO: Change user motto, game state CustomizePlayer(Player, ActualTeam); // Set the players set & game state Player.GetRoleplay().ColourWarTeam = ActualTeam; Player.GetRoleplay().inColourWars = true; // Get the room user RoomUser RUser = Player.GetHabbo().GetRoomUser(); // If it created the room user if (RUser != null) { // Set the users position RUser.SetPos(ActualTeam.WAX, ActualTeam.WAY, ActualTeam.WAZ); // Set effect if (Player.GetRoleplay() != null) { Player.GetRoleplay().EffectSeconds--; } RUser.ApplyEffect(4); // Clear movement RUser.ClearMovement(); } // Hmm, let's see if we can actually start the game TryStart(); } } else { Player.SendWhisper("No spaces left sorry!"); } } else { // Tell the user they can't join this late Player.SendWhisper("You cannot join the match as it has started!"); if (BanZaiTele != null) { if (Player.GetHabbo() != null) { if (Player.GetHabbo().GetRoomUser() != null) { Player.GetHabbo().GetRoomUser().MoveTo(BanZaiTele.SquareInFront); } } } } } } catch (Exception ex) { Logging.LogCriticalException("Error in AddPlayerToTeam() void " + ex.Message + "::" + ex.StackTrace); } }
/// <summary> /// Handles the <see cref="E:UserAdd" /> event. /// </summary> /// <param name="user"></param> private void OnUserAdd(RoomUser user) { try { if (user?.GetClient() == null || user.GetClient().GetHabbo() == null) return; GameClient client = user.GetClient(); if (client?.GetHabbo() == null || _userRoom == null) return; if (!user.IsSpectator) { DynamicRoomModel model = _userRoom.GetGameMap().Model; if (model == null) return; user.SetPos(model.DoorX, model.DoorY, model.DoorZ); user.SetRot(model.DoorOrientation, false); user.AddStatus(_userRoom.CheckRights(client, true) ? "flatctrl 4" : "flatctrl 1", string.Empty); user.CurrentItemEffect = ItemEffectType.None; if (!user.IsBot && client.GetHabbo().IsTeleporting) { client.GetHabbo().IsTeleporting = false; client.GetHabbo().TeleportingRoomId = 0; RoomItem item = _userRoom.GetRoomItemHandler().GetItem(client.GetHabbo().TeleporterId); if (item != null) { item.ExtraData = "2"; item.UpdateState(false, true); user.SetPos(item.X, item.Y, item.Z); user.SetRot(item.Rot, false); item.InteractingUser2 = client.GetHabbo().Id; item.ExtraData = "0"; item.UpdateState(false, true); } } if (!user.IsBot && client.GetHabbo().IsHopping) { client.GetHabbo().IsHopping = false; client.GetHabbo().HopperId = 0; RoomItem item2 = _userRoom.GetRoomItemHandler().GetItem(client.GetHabbo().HopperId); if (item2 != null) { item2.ExtraData = "1"; item2.UpdateState(false, true); user.SetPos(item2.X, item2.Y, item2.Z); user.SetRot(item2.Rot, false); user.AllowOverride = false; item2.InteractingUser2 = client.GetHabbo().Id; item2.ExtraData = "2"; item2.UpdateState(false, true); } } if (!user.IsSpectator) { ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SetRoomUserMessageComposer")); serverMessage.AppendInteger(1); user.Serialize(serverMessage, _userRoom.GetGameMap().GotPublicPool); _userRoom.SendMessage(serverMessage); } if (!user.IsBot) { ServerMessage serverMessage2 = new ServerMessage(); serverMessage2.Init(LibraryParser.OutgoingRequest("UpdateUserDataMessageComposer")); serverMessage2.AppendInteger(user.VirtualId); serverMessage2.AppendString(client.GetHabbo().Look); serverMessage2.AppendString(client.GetHabbo().Gender.ToLower()); serverMessage2.AppendString(client.GetHabbo().Motto); serverMessage2.AppendInteger(client.GetHabbo().AchievementPoints); _userRoom.SendMessage(serverMessage2); } if (_userRoom.RoomData.Owner != client.GetHabbo().UserName) { Yupi.GetGame() .GetAchievementManager() .ProgressUserAchievement(client, "ACH_RoomEntry", 1); } } if (client.GetHabbo().GetMessenger() != null) client.GetHabbo().GetMessenger().OnStatusChanged(true); client.GetMessageHandler().OnRoomUserAdd(); //if (client.GetHabbo().HasFuse("fuse_mod")) client.GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(102); //if (client.GetHabbo().Rank == Convert.ToUInt32(Yupi.GetDbConfig().DbData["ambassador.minrank"])) client.GetHabbo().GetAvatarEffectsInventoryComponent().ActivateCustomEffect(178); if (OnUserEnter != null) OnUserEnter(user, null); if (_userRoom.GotMusicController() && _userRoom.GotMusicController()) _userRoom.GetRoomMusicController().OnNewUserEnter(user); _userRoom.OnUserEnter(user); } catch (Exception ex) { ServerLogManager.LogCriticalException(ex.ToString()); } }
/// <summary> /// Deploys the bot. /// </summary> /// <param name="bot">The bot.</param> /// <param name="petData">The pet data.</param> /// <returns>RoomUser.</returns> internal RoomUser DeployBot(RoomBot bot, Pet petData) { int virtualId = _primaryPrivateUserId++; RoomUser roomUser = new RoomUser(0u, _userRoom.RoomId, virtualId, _userRoom, false); int num = _secondaryPrivateUserId++; roomUser.InternalRoomId = num; UserList.TryAdd(num, roomUser); OnUserAdd(roomUser); DynamicRoomModel model = _userRoom.GetGameMap().Model; Point coord = new Point(bot.X, bot.Y); if ((bot.X > 0) && (bot.Y >= 0) && (bot.X < model.MapSizeX) && (bot.Y < model.MapSizeY)) { _userRoom.GetGameMap().AddUserToMap(roomUser, coord); roomUser.SetPos(bot.X, bot.Y, bot.Z); roomUser.SetRot(bot.Rot, false); } else { bot.X = model.DoorX; bot.Y = model.DoorY; roomUser.SetPos(model.DoorX, model.DoorY, model.DoorZ); roomUser.SetRot(model.DoorOrientation, false); } bot.RoomUser = roomUser; roomUser.BotData = bot; roomUser.BotAi = bot.GenerateBotAi(roomUser.VirtualId, (int) bot.BotId); if (roomUser.IsPet) { roomUser.BotAi.Init(bot.BotId, roomUser.VirtualId, _userRoom.RoomId, roomUser, _userRoom); roomUser.PetData = petData; roomUser.PetData.VirtualId = roomUser.VirtualId; } else roomUser.BotAi.Init(bot.BotId, roomUser.VirtualId, _userRoom.RoomId, roomUser, _userRoom); UpdateUserStatus(roomUser, false); roomUser.UpdateNeeded = true; ServerMessage serverMessage = new ServerMessage(LibraryParser.OutgoingRequest("SetRoomUserMessageComposer")); serverMessage.AppendInteger(1); roomUser.Serialize(serverMessage, _userRoom.GetGameMap().GotPublicPool); _userRoom.SendMessage(serverMessage); roomUser.BotAi.OnSelfEnterRoom(); if (roomUser.IsPet) { if (_pets.Contains(roomUser.PetData.PetId)) _pets[roomUser.PetData.PetId] = roomUser; else _pets.Add(roomUser.PetData.PetId, roomUser); PetCount++; } roomUser.BotAi.Modified(); if (roomUser.BotData.AiType != AiType.Generic) return roomUser; if (_bots.Contains(roomUser.BotData.BotId)) _bots[roomUser.BotData.BotId] = roomUser; else _bots.Add(roomUser.BotData.BotId, roomUser); serverMessage.Init(LibraryParser.OutgoingRequest("DanceStatusMessageComposer")); serverMessage.AppendInteger(roomUser.VirtualId); serverMessage.AppendInteger(roomUser.BotData.DanceId); _userRoom.SendMessage(serverMessage); PetCount++; return roomUser; }
internal void ProcessUpdates() { this.UpdateCounter--; if (this.UpdateCounter <= 0) { this.UpdateNeeded = false; this.UpdateCounter = 0; if (this.TimerRunning && this.int_0 > 0) { this.int_0 += 500; this.GetRoom().int_13 += 500; this.UpdateNeeded = true; if (this.int_0 > SongManager.GetSong(Convert.ToInt32(this.ExtraData)).Length) { ServerMessage Message = new ServerMessage(327); Message.AppendInt32(7); Message.AppendInt32(6); Message.AppendInt32(7); Message.AppendInt32(0); Message.AppendInt32(0); this.GetRoom().SendMessage(Message, null); this.int_0 = 1; this.GetRoom().int_13 = 0; } } else { string text = this.GetBaseItem().InteractionType.ToLower(); switch (text) { case "onewaygate": { RoomUser roomUserByHabbo = null; if (this.InteractingUser > 0) { roomUserByHabbo = this.GetRoom().GetRoomUserByHabbo(this.InteractingUser); } if (roomUserByHabbo != null && roomUserByHabbo.X == this.mX && roomUserByHabbo.Y == this.mY && this.Extra1 != "tried") { this.ExtraData = "1"; this.Extra1 = "tried"; roomUserByHabbo.UnlockWalking(); roomUserByHabbo.MoveTo(this.SquareBehind); this.ReqUpdate(0); this.UpdateState(false, true); } else { if ((roomUserByHabbo != null && (roomUserByHabbo.Coordinate != this.SquareBehind)) || this.Extra1 == "tried") { this.Extra1 = ""; this.ExtraData = "0"; this.InteractingUser = 0; this.UpdateState(false, true); this.GetRoom().GenerateMaps(); } else { if (this.ExtraData == "1") { this.ExtraData = "0"; this.UpdateState(false, true); } } } if (roomUserByHabbo == null) { this.InteractingUser = 0u; } break; } case "teleport": { bool flag = false; bool flag2 = false; if (this.InteractingUser > 0u) { RoomUser roomUserByHabbo = this.GetRoom().GetRoomUserByHabbo(this.InteractingUser); if (roomUserByHabbo != null) { if (!(roomUserByHabbo.Coordinate == this.Coordinate)) { roomUserByHabbo.AllowOverride = false; if (roomUserByHabbo.TeleDelay == -1) { roomUserByHabbo.TeleDelay = 1; } if (TeleHandler.IsTeleLinked(this.Id)) { flag2 = true; if (roomUserByHabbo.TeleDelay == 0) { uint num2 = TeleHandler.GetLinkedTele(this.Id); uint num3 = TeleHandler.GetTeleRoomId(num2); if (num3 == this.RoomId) { RoomItem class2 = this.GetRoom().GetItem(num2); if (class2 == null) { roomUserByHabbo.UnlockWalking(); } else { roomUserByHabbo.SetPos(class2.GetX, class2.GetY, class2.GetZ); roomUserByHabbo.SetRot(class2.Rot); class2.ExtraData = "2"; class2.UpdateState(false, true); class2.InteractingUser2 = this.InteractingUser; } } else { if (!roomUserByHabbo.IsBot) { PhoenixEnvironment.GetGame().GetRoomManager().method_5(new TeleUserData(roomUserByHabbo.GetClient().GetMessageHandler(), roomUserByHabbo.GetClient().GetHabbo(), num3, num2)); } } this.InteractingUser = 0u; } else { roomUserByHabbo.TeleDelay--; } } else { roomUserByHabbo.UnlockWalking(); this.InteractingUser = 0u; roomUserByHabbo.MoveTo(this.SquareInFront); } } else { if ((roomUserByHabbo.Coordinate == this.SquareInFront) && roomUserByHabbo.Item == this) { roomUserByHabbo.AllowOverride = true; flag = true; if (roomUserByHabbo.IsWalking && (roomUserByHabbo.GoalX != this.mX || roomUserByHabbo.GoalY != this.mY)) { roomUserByHabbo.ClearMovement(true); } roomUserByHabbo.CanWalk = false; roomUserByHabbo.AllowOverride = true; roomUserByHabbo.MoveTo(this.Coordinate); } else { this.InteractingUser = 0u; } } } else { this.InteractingUser = 0u; } } if (this.InteractingUser2 > 0u) { RoomUser user2 = this.GetRoom().GetRoomUserByHabbo(this.InteractingUser2); if (user2 != null) { flag = true; user2.UnlockWalking(); if (user2.Coordinate == this.Coordinate) { user2.MoveTo(this.SquareInFront); } } this.InteractingUser2 = 0u; } if (flag) { if (this.ExtraData != "1") { this.ExtraData = "1"; this.UpdateState(false, true); } } else { if (flag2) { if (this.ExtraData != "2") { this.ExtraData = "2"; this.UpdateState(false, true); } } else { if (this.ExtraData != "0") { this.ExtraData = "0"; this.UpdateState(false, true); } } } this.ReqUpdate(1); break; } case "bottle": { int num = PhoenixEnvironment.GetRandomNumber(0, 7); this.ExtraData = num.ToString(); this.UpdateState(); break; } case "dice": try { RoomUser @class = this.GetRoom().GetRoomUserByHabbo(this.InteractingUser); if (@class.GetClient().GetHabbo().Rigger > 0) { this.ExtraData = @class.GetClient().GetHabbo().Rigger.ToString(); @class.GetClient().GetHabbo().Rigger = 0; } else { int num = PhoenixEnvironment.GetRandomNumber(1, 6); this.ExtraData = num.ToString(); } } catch { int num = PhoenixEnvironment.GetRandomNumber(1, 6); this.ExtraData = num.ToString(); } this.UpdateState(); break; case "habbowheel": { int num = PhoenixEnvironment.GetRandomNumber(1, 10); this.ExtraData = num.ToString(); this.UpdateState(); break; } case "loveshuffler": if (this.ExtraData == "0") { int num = PhoenixEnvironment.GetRandomNumber(1, 4); this.ExtraData = num.ToString(); this.ReqUpdate(20); } else { if (this.ExtraData != "-1") { this.ExtraData = "-1"; } } this.UpdateState(false, true); break; case "alert": if (this.ExtraData == "1") { this.ExtraData = "0"; this.UpdateState(false, true); } break; case "vendingmachine": if (this.ExtraData == "1") { RoomUser @class = this.GetRoom().GetRoomUserByHabbo(this.InteractingUser); if (@class != null) { @class.UnlockWalking(); int int_ = this.GetBaseItem().VendingIds[PhoenixEnvironment.GetRandomNumber(0, this.GetBaseItem().VendingIds.Count - 1)]; @class.CarryItem(int_); } this.InteractingUser = 0u; this.ExtraData = "0"; this.UpdateState(false, true); } break; case "wf_trg_onsay": case "wf_trg_enterroom": case "wf_trg_furnistate": case "wf_trg_onfurni": case "wf_trg_offfurni": case "wf_trg_gameend": case "wf_trg_gamestart": case "wf_trg_attime": case "wf_trg_atscore": case "wf_act_saymsg": case "wf_act_togglefurni": case "wf_act_givepoints": case "wf_act_moverotate": case "wf_act_matchfurni": case "wf_act_give_phx": case "wf_cnd_trggrer_on_frn": case "wf_cnd_furnis_hv_avtrs": case "wf_cnd_has_furni_on": case "wf_cnd_phx": case "bb_teleport": if (this.ExtraData == "1") { this.ExtraData = "0"; this.UpdateState(false, true); } break; case "wf_trg_timer": if (this.ExtraData == "1") { this.ExtraData = "0"; this.UpdateState(false, true); } if (this.Extra1.Length > 0) { this.GetRoom().method_15(this); this.ReqUpdate(Convert.ToInt32(Convert.ToDouble(this.Extra1) * 2.0)); } break; case "wf_act_moveuser": if (this.dictionary_1.Count > 0 && this.GetRoom().UserList != null) { int num4 = 0; RoomUser[] RoomUser_ = this.GetRoom().UserList; for (int i = 0; i < RoomUser_.Length; i++) { RoomUser class4 = RoomUser_[i]; if (class4 != null) { if (class4.IsBot) { this.dictionary_1.Remove(class4); } if (this.dictionary_1.ContainsKey(class4)) { if (this.dictionary_1[class4] > 0) { if (this.dictionary_1[class4] == 10 && !class4.IsBot) { class4.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyEffect(4, true); } Dictionary <RoomUser, int> dictionary; RoomUser key; (dictionary = this.dictionary_1)[key = class4] = dictionary[key] - 1; num4++; } else { this.dictionary_1.Remove(class4); class4.GetClient().GetHabbo().GetAvatarEffectsInventoryComponent().ApplyEffect(0, true); } } } } if (num4 > 0) { this.ReqUpdate(0); } else { this.dictionary_1.Clear(); } } break; case "counter": if (this.TimerRunning && this.Extra1 != "1") { this.ExtraData = Convert.ToString(Convert.ToInt32(this.ExtraData) - 1); if (Convert.ToInt32(this.ExtraData) <= 0) { this.ExtraData = "0"; this.TimerRunning = false; this.GetRoom().method_89(0, this, true); } this.UpdateState(true, true); this.GetRoom().method_16((double)Convert.ToInt32(this.ExtraData)); this.Extra1 = "1"; this.ReqUpdate(1); } else { if (this.TimerRunning) { this.GetRoom().method_16((double)Convert.ToInt32(this.ExtraData) - 0.5); this.Extra1 = "0"; this.ReqUpdate(1); } } break; } } } }
internal RoomUser DeployBot(RoomBot Bot, Pet PetData) { 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(28); EnterMessage.AppendInt32(1); BotUser.Serialize(EnterMessage, room.GetGameMap().gotPublicPool); 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 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; } } } }
internal RoomUser DeployBot(RoomBot Bot, Pet PetData) { int virtualId = this.primaryPrivateUserID++; RoomUser roomUser = new RoomUser(0u, this.room.RoomId, virtualId, this.room, false); int num = this.secondaryPrivateUserID++; roomUser.InternalRoomID = num; this.userlist.Add(num, roomUser); DynamicRoomModel model = this.room.GetGameMap().Model; Point coord = new Point(Bot.X, Bot.Y); if (Bot.X > 0 && Bot.Y > 0 && Bot.X < model.MapSizeX && Bot.Y < model.MapSizeY) { this.room.GetGameMap().AddUserToMap(roomUser, coord); roomUser.SetPos(Bot.X, Bot.Y, Bot.Z); roomUser.SetRot(Bot.Rot, false); } else { Bot.X = model.DoorX; Bot.Y = model.DoorY; roomUser.SetPos(model.DoorX, model.DoorY, model.DoorZ); roomUser.SetRot(model.DoorOrientation, false); } roomUser.BotData = Bot; checked { roomUser.BotAI = Bot.GenerateBotAI(roomUser.VirtualId, (int)Bot.BotId); if (roomUser.IsPet) { roomUser.BotAI.Init(Bot.BotId, roomUser.VirtualId, this.room.RoomId, roomUser, this.room); roomUser.PetData = PetData; roomUser.PetData.VirtualId = roomUser.VirtualId; } else { roomUser.BotAI.Init(Bot.BotId, roomUser.VirtualId, this.room.RoomId, roomUser, this.room); } this.UpdateUserStatus(roomUser, false); roomUser.UpdateNeeded = true; ServerMessage serverMessage = new ServerMessage(Outgoing.SetRoomUserMessageComposer); serverMessage.AppendInt32(1); roomUser.Serialize(serverMessage, this.room.GetGameMap().gotPublicPool); this.room.SendMessage(serverMessage); roomUser.BotAI.OnSelfEnterRoom(); if (roomUser.IsPet) { if (this.pets.Contains(roomUser.PetData.PetId)) { this.pets[roomUser.PetData.PetId] = roomUser; } else { this.pets.Add(roomUser.PetData.PetId, roomUser); } this.petCount++; } if (roomUser.BotData.AiType == AIType.Generic) { if (this.bots.Contains(roomUser.BotData.BotId)) { this.bots[roomUser.BotData.BotId] = roomUser; } else { this.bots.Add(roomUser.BotData.BotId, roomUser); } serverMessage.Init(Outgoing.DanceStatusMessageComposer); serverMessage.AppendInt32(roomUser.VirtualId); serverMessage.AppendInt32(roomUser.BotData.DanceId); this.room.SendMessage(serverMessage); this.petCount++; } return roomUser; } }
public static RoomUser DeployBotByID(int RoleplayBotsID, string SpawnType = "default", int RoomID = 0) { lock (SyncLock) { try { if (!RoleplayBotManager.CachedRoleplayBots.ContainsKey(RoleplayBotsID)) { return(null); } #region If the bot already exists simply transfer it RoleplayBot DeployingBot = RoleplayBotManager.CachedRoleplayBots[RoleplayBotsID]; if (DeployingBot.DRoomUser != null) { if (DeployingBot.DRoom != null) { if (DeployingBot.DRoom.Id != RoomID) { RoleplayBotManager.TransportDeployedBot(DeployingBot.DRoomUser, (RoomID == 0 ? DeployingBot.SpawnId : RoomID)); } } return(null); } #endregion Room RoleplayBotsRoom; if (RoomID == 0) { if (RoleplayManager.GenerateRoom(DeployingBot.SpawnId, false) == null) { return(null); } else { RoleplayBotsRoom = RoleplayManager.GenerateRoom(DeployingBot.SpawnId, false); } } else { if (RoleplayManager.GenerateRoom(RoomID, false) == null) { return(null); } else { RoleplayBotsRoom = RoleplayManager.GenerateRoom(RoomID, false); } DeployingBot.SpawnId = RoleplayBotsRoom.RoomId; } #region Misc variables RoomUserManager RoomManager = RoleplayBotsRoom.GetRoomUserManager(); RoomUser BotsRoomUserInstance = new RoomUser(0, RoleplayBotsRoom.RoomId, RoomManager.primaryPrivateUserID++, RoleplayBotsRoom); List <RandomSpeech> BotsSpeech = new List <RandomSpeech>(); int BotsPersonalID = RoomManager.secondaryPrivateUserID++; BotsRoomUserInstance.InternalRoomID = BotsPersonalID; RoomManager._users.TryAdd(BotsPersonalID, BotsRoomUserInstance); DynamicRoomModel RoleplayBotsModel = RoleplayBotsRoom.GetGameMap().Model; #endregion #region Spawning & Positioning if (DeployingBot.Dead) { RoleplayManager.SpawnBeds(null, "hosptl_bed", BotsRoomUserInstance); } else { #region Spawn at origin if (SpawnType == "default") { if ((DeployingBot.X > 0 && DeployingBot.Y > 0) && DeployingBot.X < RoleplayBotsModel.MapSizeX && DeployingBot.Y < RoleplayBotsModel.MapSizeY) { BotsRoomUserInstance.SetPos(DeployingBot.X, DeployingBot.Y, DeployingBot.Z); BotsRoomUserInstance.SetRot(DeployingBot.SpawnRot, false); } else { DeployingBot.X = RoleplayBotsModel.DoorX; DeployingBot.Y = RoleplayBotsModel.DoorY; BotsRoomUserInstance.SetPos(RoleplayBotsModel.DoorX, RoleplayBotsModel.DoorY, RoleplayBotsModel.DoorZ); BotsRoomUserInstance.SetRot(RoleplayBotsModel.DoorOrientation, false); } } #endregion #region Spawn at work item if (SpawnType == "workitem") { Item Item; if (DeployingBot.GetStopWorkItem(RoleplayBotsRoom, out Item)) { var Point = new Point(Item.GetX, Item.GetY); BotsRoomUserInstance.X = Point.X; BotsRoomUserInstance.Y = Point.Y; BotsRoomUserInstance.SetPos(Point.X, Point.Y, RoleplayBotsRoom.GetGameMap().GetHeightForSquare(Point)); BotsRoomUserInstance.SetRot(Item.Rotation, false); } else { BotsRoomUserInstance.X = RoleplayBotsModel.DoorX; BotsRoomUserInstance.Y = RoleplayBotsModel.DoorY; BotsRoomUserInstance.SetPos(RoleplayBotsModel.DoorX, RoleplayBotsModel.DoorY, RoleplayBotsModel.DoorZ); BotsRoomUserInstance.SetRot(RoleplayBotsModel.DoorOrientation, false); } } #endregion #region Spawn at owner if (SpawnType == "owner" && DeployingBot.Owner != null) { RoomUser OwnerInstance = DeployingBot.Owner.GetRoomUser(); int X = OwnerInstance.SquareInFront.X; int Y = OwnerInstance.SquareInFront.Y; double Z = OwnerInstance.Z; if ((OwnerInstance != null) && (X > 0 && Y > 0) && X < RoleplayBotsModel.MapSizeX && Y < RoleplayBotsModel.MapSizeY) { BotsRoomUserInstance.SetPos(X, Y, Z); BotsRoomUserInstance.SetRot(DeployingBot.SpawnRot, false); } else { X = OwnerInstance.X; Y = OwnerInstance.Y; DeployingBot.X = X; DeployingBot.Y = Y; BotsRoomUserInstance.SetPos(X, Y, OwnerInstance.Z); BotsRoomUserInstance.SetRot(DeployingBot.SpawnRot, false); } } #endregion } #endregion #region Generate Roleplay Bot's data, timers BotsRoomUserInstance.BotData = new RoomBot(DeployingBot.Id, DeployingBot.SpawnId, DeployingBot.AITypeString, "stand", DeployingBot.Name, "Motto", DeployingBot.Figure, DeployingBot.X, DeployingBot.Y, DeployingBot.Z, DeployingBot.SpawnRot, DeployingBot.X, DeployingBot.Y, DeployingBot.X, DeployingBot.Y, ref BotsSpeech, DeployingBot.Gender, 0, 0, false, 0, false, 0); BotsRoomUserInstance.RPBotAI = RoleplayBotManager.GetRoleplayBotAI(DeployingBot.AIType, BotsRoomUserInstance.VirtualId); BotsRoomUserInstance.BotAI = BotsRoomUserInstance.BotData.GenerateBotAI(BotsRoomUserInstance.VirtualId); if (DeployingBot.IsPet) { BotsRoomUserInstance.PetData = DeployingBot.PetInstance; BotsRoomUserInstance.PetData.VirtualId = BotsRoomUserInstance.VirtualId; } BotsRoomUserInstance.RPBotAI.Init(DeployingBot.Id, DeployingBot, BotsRoomUserInstance.VirtualId, DeployingBot.SpawnId, BotsRoomUserInstance, RoleplayBotsRoom); BotsRoomUserInstance.BotAI.Init(DeployingBot.Id, BotsRoomUserInstance.VirtualId, DeployingBot.SpawnId, BotsRoomUserInstance, RoleplayBotsRoom); if (DeployingBot.TimerManager == null) { DeployingBot.TimerManager = new BotTimerManager(DeployingBot); } else { DeployingBot.TimerManager.CachedBot = DeployingBot; } if (DeployingBot.CooldownManager == null) { DeployingBot.CooldownManager = new BotCooldownManager(DeployingBot); } else { DeployingBot.CooldownManager.CachedBot = DeployingBot; } RoomManager.UpdateUserStatus(BotsRoomUserInstance, false); BotsRoomUserInstance.UpdateNeeded = true; #region Set general variables DeployingBot.Teleporting = false; DeployingBot.TeleporterEntering = null; DeployingBot.TeleporterExiting = null; DeployingBot.Teleported = false; DeployingBot.Deployed = true; DeployingBot.RoomStayTime = new CryptoRandom().Next(0, DeployingBot.RoomStayInterval); DeployingBot.FollowCooldown = new CryptoRandom().Next(0, DeployingBot.FollowInterval); DeployingBot.AttackCooldown = new CryptoRandom().Next(0, DeployingBot.AttackInterval); DeployingBot.RoamCooldown = new CryptoRandom().Next(0, DeployingBot.RoamInterval); DeployingBot.RoomStayTime = new CryptoRandom().Next(0, DeployingBot.RoomStayInterval); DeployingBot.LookCooldown = new CryptoRandom().Next(0, DeployingBot.LookCooldown); #endregion #endregion #region Compose Roleplay Bot's visibility & insert into deployed bots DeployingBot.Invisible = false; if (!DeployingBot.Invisible) { RoleplayBotsRoom.SendMessage(new UsersComposer(BotsRoomUserInstance)); } if (RoomManager._bots.ContainsKey(DeployingBot.Id)) { RoomManager._bots[DeployingBot.Id] = BotsRoomUserInstance; } else { RoomManager._bots.TryAdd(DeployingBot.Id, BotsRoomUserInstance); } RoleplayBotsRoom.SendMessage(new DanceComposer(BotsRoomUserInstance, 0)); #endregion #region Attach RoleplayBot Instance to RoomUser & deliver its respective data BotsRoomUserInstance.RPBotData = DeployingBot; if (!RoleplayBotManager.DeployedRoleplayBots.ContainsKey(DeployingBot.Id)) { RoleplayBotManager.DeployedRoleplayBots.TryAdd(DeployingBot.Id, BotsRoomUserInstance); } else { RoomUser NullBot; RoleplayBotManager.ClearRoleplayBotClones(DeployingBot.Id); RoleplayBotManager.DeployedRoleplayBots.TryAdd(DeployingBot.Id, BotsRoomUserInstance); } #region Start roaming if (DeployingBot.RoamBot) { DeployingBot.MoveRandomly(); } #endregion DeployingBot.DRoomUser.GetBotRoleplayAI().OnDeployed(DeployingBot.Owner); #endregion return(BotsRoomUserInstance); } catch (Exception ex) { Console.WriteLine(ex.Message); } } return(null); }
internal RoomUser DeployBot(RoomBot Bot, Pet PetData) { int num2; this.primaryPrivateUserID = (num2 = this.primaryPrivateUserID) + 1; RoomUser BotUser = new RoomUser(0, this.room.RoomId, num2, this.room, false); this.secondaryPrivateUserID = (num2 = this.secondaryPrivateUserID) + 1; int key = num2; BotUser.InternalRoomID = key; this.userlist.Add(key, BotUser); DynamicRoomModel Model = this.room.GetGameMap().Model; Point myPoint = new Point(Bot.X,Bot.Y); if ((Bot.X > 0 && Bot.Y > 0) && Bot.X < Model.MapSizeX && Bot.Y < Model.MapSizeY) { room.GetGameMap().AddUserToMap(BotUser, myPoint); 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,(int)Bot.BotId); if (BotUser.IsPet) { BotUser.BotAI.Init(Bot.BotId, BotUser.VirtualId, room.RoomId, BotUser, room); BotUser.PetData = PetData; BotUser.PetData.VirtualId = BotUser.VirtualId; } else { BotUser.BotAI.Init(Bot.BotId, BotUser.VirtualId, room.RoomId, BotUser, room); } this.UpdateUserStatus(BotUser, false); BotUser.UpdateNeeded = true; ServerMessage EnterMessage = new ServerMessage(Outgoing.PlaceBot); EnterMessage.AppendInt32(1); BotUser.Serialize(EnterMessage, room.GetGameMap().gotPublicPool); room.SendMessage(EnterMessage); BotUser.BotAI.OnSelfEnterRoom(); 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++; } if (BotUser.BotData.AiType == AIType.Generic) { if (bots.ContainsKey(BotUser.BotData.BotId)) bots[BotUser.BotData.BotId] = BotUser; else { bots.Add(BotUser.BotData.BotId, BotUser); } EnterMessage.Init(Outgoing.Dance); EnterMessage.AppendInt32(BotUser.VirtualId); EnterMessage.AppendInt32(BotUser.BotData.DanceId); room.SendMessage(EnterMessage); petCount++; } return BotUser; }
internal RoomUser DeployBot(RoomBot Bot, Pet PetData) { DynamicRoomModel Model = room.GetGameMap().Model; RoomUser BotUser = new RoomUser(0, string.Empty, room.RoomId, primaryPrivateUserID++, room, false); BotUser.InternalRoomID = ++secondaryPrivateUserID; //this.UserList[PersonalID] = BotUser; userlist.Add(BotUser.InternalRoomID, BotUser); 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(Bot.ownerID > 0 ? (int)Bot.BotId : -1, BotUser.VirtualId, room.RoomId, BotUser, room); } UpdateUserStatus(BotUser, false); BotUser.UpdateNeeded = true; ServerMessage EnterMessage = PacketHandelingManager.GetRecycledItem(OutputCode.UsersMessageEvent); EnterMessage.AddInt32(1); BotUser.Serialize(EnterMessage); room.SendMessage(EnterMessage); BotUser.BotAI.OnSelfEnterRoom(); 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; }