//internal ServerMessage UpdateItemOnRoller(RoomItem pItem, Point NextCoord, uint pRolledID, Double NextZ) //{ // return UpdateItemOnRoller(pItem, NextCoord, pRolledID, NextZ); //} //internal ServerMessage UpdateUserOnRoller(RoomUser pUser, Point pNextCoord, uint pRollerID, Double NextZ) //{ // return UpdateUserOnRoller(pUser, pNextCoord.X, pNextCoord.Y, pRollerID, NextZ); //} internal ServerMessage UpdateUserOnRoller(RoomUser pUser, int newX, int newY, ref int newCoord, uint pRollerID, Double NextZ) { ServerMessage mMessage = PacketHandelingManager.GetRecycledItem(OutputCode.SlideObjectBundleMessageEvent); mMessage.AddInt32(pUser.X); mMessage.AddInt32(pUser.Y); mMessage.AddInt32(newX); mMessage.AddInt32(newY); mMessage.AddInt32(0); mMessage.AddUInt32(pRollerID); mMessage.AddInt32(2); mMessage.AddInt32(pUser.VirtualId); mMessage.AddString(TextHandling.GetString(pUser.Z)); mMessage.AddString(TextHandling.GetString(NextZ)); mMessage.AddInt32(0); mMessage.AddInt32(0); int userCoord = pUser.GetDoubleCoordinate(); room.GetGameMap().UpdateUserMovement(ref userCoord, ref newCoord, pUser); room.GetGameMap().GameMap[pUser.X, pUser.Y] = 1; pUser.X = newX; pUser.Y = newY; pUser.Z = NextZ; room.GetGameMap().GameMap[pUser.X, pUser.Y] = 0; room.GetRoomUserManager().UpdateUserStatus(pUser, true); return mMessage; }
internal void TeleportToItem(RoomUser user, RoomItem item) { if (user.SetStep) room.GetGameMap().GameMap[user.SetX, user.SetY] = user.SqState; else room.GetGameMap().GameMap[user.X, user.Y] = user.SqState; int itemCoord = item.GetDoubleCoordinate(); int userCoord = user.GetDoubleCoordinate(); UpdateUserMovement(ref userCoord, ref itemCoord, user); user.X = item.GetX; user.Y = item.GetY; user.Z = item.GetZ; if (user.isFlying) user.Z += 4 + 0.5 * Math.Sin(0.7 * user.flyk); user.SqState = GameMap[item.GetX, item.GetY]; GameMap[user.X, user.Y] = 1; user.GoalX = user.X; user.GoalY = user.Y; user.SetStep = false; user.IsWalking = false; user.UpdateNeeded = true; user.OnStopWalk(); if (item.GetBaseItem().IsSeat) { if (!user.Statusses.ContainsKey("sit")) { user.Statusses.Add("sit", TextHandling.GetString(item.Height)); } } else if (item.GetBaseItem().InteractionType == InteractionType.bed) { if (!user.Statusses.ContainsKey("lay")) { user.Statusses.Add("lay", TextHandling.GetString(item.Height) + " null"); } } user.Z = item.GetZ; if (user.isFlying) user.Z += 4 + (0.2 * 0.5 * Math.Sin(0.7 * user.flyk)); user.RotHead = item.Rot; user.RotBody = item.Rot; user.UpdateNeeded = true; //item.OnUserWalk(user, false); BE GONE BUG }
private void RemoveRoomUser(RoomUser user) { UserList.Remove(user.InternalRoomID); if (user.SetStep) room.GetGameMap().GameMap[user.SetX, user.SetY] = user.SqState; else room.GetGameMap().GameMap[user.X, user.Y] = user.SqState; int coordinate = user.GetDoubleCoordinate(); room.GetGameMap().RemoveUserFromMap(user, ref coordinate); if (!user.IsBot) { usersByUsername.Remove(user.username); usersByUserID.Remove(user.userID); } ServerMessage LeaveMessage = PacketHandelingManager.GetRecycledItem(OutputCode.UserRemoveMessageEvent); LeaveMessage.AddString(user.VirtualId.ToString()); room.SendMessage(LeaveMessage); }
internal void UpdateUserStatus(RoomUser User, bool cyclegameitems) { if (User == null) return; bool isBot = User.IsBot; if (isBot) cyclegameitems = false; if (User.Statusses.ContainsKey("lay") || User.Statusses.ContainsKey("sit")) { User.Statusses.Remove("lay"); if (!User.forcesit) User.Statusses.Remove("sit"); User.UpdateNeeded = true; } //List<RoomItem> ItemsOnSquare = GetFurniObjects(User.X, User.Y); //CoordItemSearch ItemSearch = new CoordItemSearch(room.GetGameMap().CoordinatedItems); int userCoord = User.GetDoubleCoordinate(); List<RoomItem> ItemsOnSquare = room.GetGameMap().GetCoordinatedItems(ref userCoord); //ItemSearch.GetAllRoomItemForSquare(User.X, User.Y); double newZ = room.GetGameMap().GetNewZForUser(User.X, User.Y, User.Z); if (newZ != User.Z) { if (User.isFlying) newZ += 4 + (0.5 * Math.Sin(0.7 * User.flyk)); if (User.UserIsRidingAHorse()) newZ += 1; User.Z = newZ; User.UpdateNeeded = true; } DynamicRoomModel Model = room.GetGameMap().Model; if (Model.SqState[User.X, User.Y] == SquareState.SEAT) { if (!User.Statusses.ContainsKey("sit")) { User.Statusses.Add("sit", "1.0"); } User.Z = Model.SqFloorHeight[User.X, User.Y]; if (User.isFlying) User.Z += 4 + (0.5 * Math.Sin(0.7 * User.flyk)); User.RotHead = Model.SqSeatRot[User.X, User.Y]; User.RotBody = Model.SqSeatRot[User.X, User.Y]; User.UpdateNeeded = true; } RoomItem[] items = room.GetGameMap().GetCoordinatedHeighestItems(ref userCoord).ToArray(); foreach (RoomItem item in items) item.OnUserWalk(User, cyclegameitems); if (User.pressurePlate != 0) { if (User.PressurePlateReset) { RoomItem plate = room.GetRoomItemHandler().GetItem(User.pressurePlate); if (plate == null) return; User.pressurePlate = 0; plate.ExtraData = "0"; plate.UpdateState(false, true); } User.PressurePlateReset = true; } if (cyclegameitems) { if (room.GotSoccer()) room.GetSoccer().OnUserWalk(User); if (room.GotBanzai()) room.GetBanzai().OnUserWalk(User); if (room.GotFreeze()) room.GetFreeze().OnUserWalk(User); } }
private bool SetStepForUser(RoomUser User) { if (room.GetGameMap().CanWalk(User.SetX, User.SetY, User.SetZ, User.AllowOverride) || User.ignoreMap || User.PetGotUserRiding()) { int currentCoord = User.GetDoubleCoordinate(); int newCoord = TextHandling.CombineXYCoord(User.SetX, User.SetY); room.GetGameMap().UpdateUserMovement(ref currentCoord, ref newCoord, User); RoomItem[] items = room.GetGameMap().GetCoordinatedHeighestItems(ref currentCoord); User.X = User.SetX; User.Y = User.SetY; User.Z = User.SetZ; if (User.isFlying) { User.Z += 4 + 0.5 * Math.Sin(0.7 * User.flyk); } else { foreach (RoomItem item in items) { item.UserWalksOffFurni(User); } } if (User.X == room.GetGameMap().Model.DoorX && User.Y == room.GetGameMap().Model.DoorY && !ToRemove.Contains(User) && !User.IsBot) { ToRemove.Add(User); return true; } UpdateUserStatus(User, true); } User.SetStep = false; return false; }