public RoomUser DeployBot(RoomBot Bot, Pet PetData) { RoomUser BotUser = new RoomUser(0, RoomId, UserCounter++); 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); } else { Bot.X = Model.DoorX; Bot.Y = Model.DoorY; BotUser.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ); BotUser.SetRot(Model.DoorOrientation); } UserMatrix[Bot.X, Bot.Y] = true; BotUser.BotData = Bot; BotUser.BotAI = Bot.GenerateBotAI(BotUser.VirtualId); if (BotUser.IsPet) { BotUser.BotAI.Init((int)Bot.BotId, BotUser.VirtualId, RoomId); BotUser.PetData = PetData; BotUser.PetData.VirtualId = BotUser.VirtualId; } else { BotUser.BotAI.Init(-1, BotUser.VirtualId, RoomId); } UserList.Add(BotUser); UpdateUserStatus(BotUser); BotUser.UpdateNeeded = true; ServerPacket EnterMessage = new ServerPacket(28); EnterMessage.AppendInt32(1); BotUser.Serialize(EnterMessage); SendMessage(EnterMessage); BotUser.BotAI.OnSelfEnterRoom(); return BotUser; }
public void AddUserToRoom(GameClient Session, bool Spectator) { RoomUser User = new RoomUser(Session.GetHabbo().Id, RoomId, UserCounter++); if (Spectator) { User.IsSpectator = true; } else { User.SetPos(Model.DoorX, Model.DoorY, Model.DoorZ); User.SetRot(Model.DoorOrientation); if (CheckRights(Session, true)) { User.AddStatus("flatcrtl", "useradmin"); } else if (CheckRights(Session)) { User.AddStatus("flatcrtl", ""); } if (!User.IsBot && User.GetClient().GetHabbo().IsTeleporting) { RoomItem Item = GetItem(User.GetClient().GetHabbo().TeleporterId); if (Item != null) { User.SetPos(Item.X, Item.Y, Item.Z); User.SetRot(Item.Rot); Item.InteractingUser2 = Session.GetHabbo().Id; Item.ExtraData = "2"; Item.UpdateState(false, true); } } User.GetClient().GetHabbo().IsTeleporting = false; User.GetClient().GetHabbo().TeleporterId = 0; ServerPacket EnterMessage = new ServerPacket(28); EnterMessage.AppendInt32(1); User.Serialize(EnterMessage); SendMessage(EnterMessage); } UserList.Add(User); Session.GetHabbo().OnEnterRoom(Id); if (!Spectator) { UpdateUserCount(); foreach (RoomUser Usr in UserList) { if (!Usr.IsBot) { continue; } Usr.BotAI.OnUserEnterRoom(User); } } }