/// <summary> /// 56 - "@x" /// </summary> public void WHISPER() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); if (!Me.isMuted) { string whisperBody = Request.getParameter(0); string receiverName = whisperBody.Substring(0, whisperBody.IndexOf(' ')); string Text = whisperBody.Substring(receiverName.Length + 1); stringFunctions.filterVulnerableStuff(ref Text, true); serverMessage Whisper = new serverMessage(25); // "@Y" Whisper.appendWired(Me.ID); Whisper.appendClosedValue(Text); Session.gameConnection.sendMessage(Whisper); if (receiverName.Length > 0 && receiverName != Session.User.Username) { roomUser Receiver = Session.roomInstance.getRoomUser(receiverName); if (Receiver != null) { Receiver.Session.gameConnection.sendMessage(Whisper); } ObjectTree.Game.Moderation.addChatMessageToLogStack(Session.ID, Session.User.ID, Session.roomID, Receiver.Session.User.ID, chatType.whisper, ref Text); } } }
public static void setHandItem(ref roomUser User, string Item) { int ID = 0; if (int.TryParse(Item, out ID)) { try { string carryStatus = ""; string useStatus = ""; handItemType iType = handItemTypes[ID]; if (iType == handItemType.eat) { carryStatus = "carryf"; useStatus = "eat"; } else if (iType == handItemType.drink) { carryStatus = "carryd"; useStatus = "drink"; } else if (iType == handItemType.item) { carryStatus = "cri"; useStatus = "usei"; } User.removeStatus("dance"); User.addStatus("handitem", carryStatus, ID.ToString(), 120, useStatus, 12, 1); } catch { } } }
/// <summary> /// Tries to unregister a session's user with the room, releasing the session's room user ID and broadcoasting the 'user has left' message to the remaining room users. If the leaving of this user results in abandoning of the room, the room instance is destroyed. /// </summary> /// <param name="sessionID">The ID of the registered session to unregister.</param> public void unRegisterSession(uint sessionID) { if (this.enteringSessions.Contains(sessionID)) // User was entering room { this.enteringSessions.Remove(sessionID); } else { if (this.roomUsers.ContainsKey(sessionID)) // User was in room { lock (this.roomUsers) { roomUser leavingUser = this.roomUsers[sessionID]; this.roomUsers.Remove(sessionID); if (this.userAmount == 0) // Last user leaves the room { ObjectTree.Game.Rooms.destroyRoomInstance(this.roomID); return; } else { releaseRoomUnit(leavingUser.ID, leavingUser.X, leavingUser.Y); this.updateUserAmount(); Logging.Log("Unregistered session " + sessionID + " from room " + this.roomID + ".", Logging.logType.roomUserRegisterEvent); } } } } }
/// <summary> /// Activates a room user and makes it appear in the door of the room. /// </summary> /// <param name="Session">The Woodpecker.Sessions.Session object of the user that is ready to interact with the room.</param> public void startUser(Session Session) { if (!enteringSessions.Contains(Session.ID)) // Invalid entry { return; } roomUser newUser = new roomUser(Session); if (Session.authenticatedTeleporter == 0) { roomModel Model = this.getModel(); if (Model == null) { return; } newUser.X = Model.doorX; newUser.Y = Model.doorY; newUser.Z = Model.doorZ; } else { Items.floorItem pItem = this.getFloorItem(Session.authenticatedTeleporter); if (pItem != null && pItem.Definition.Behaviour.isTeleporter) { newUser.X = pItem.X; newUser.Y = pItem.Y; newUser.Z = pItem.Z; Session.authenticatedTeleporter = 0; this.broadcoastTeleportActivity(pItem.ID, Session.User.Username, false); } else { return; // Invalid item used to enter flat } } newUser.ID = this.getFreeRoomUnitIdentifier(); if (this.Information.isUserFlat) { newUser.isOwner = (Session.User.Username == this.Information.Owner || Session.User.hasFuseRight("fuse_any_room_controller")); newUser.hasRights = (newUser.isOwner || this.Information.superUsers || Engine.Game.Rooms.userHasRightsInRoom(Session.User.ID, this.roomID)); newUser.refreshRights(); } // User has entered Session.roomID = this.roomID; this.enteringSessions.Remove(Session.ID); this.roomUsers.Add(Session.ID, newUser); this.castRoomUnit(newUser.ToString()); this.updateUserAmount(); }
/// <summary> /// 87 - "AW" /// </summary> public void CARRYITEM() { string Item = "20"; // Camera roomUser Me = Session.roomInstance.getRoomUser(Session.ID); Items.carryItemHelper.setHandItem(ref Me, Item); }
/// <summary> /// Tries to process a given chat message and checks if the current room bot should respond. /// </summary> /// <param name="Text">The chat message to process.</param> private void handleBotResponse(string Text) { if (Session.roomInstance.getRoomBot(Session.roomID) != null) { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); roomUser Bot = Session.roomInstance.getRoomBot(Session.roomID); if (Bot != null) { BotResponse bResponse = Bot.bInfo.GetResponse(Text); if (bResponse != null) { if (bResponse.ResponseText != null && bResponse.ResponseType != null) { switch (bResponse.ResponseType) { case "say": Session.roomInstance.sendTalk(Bot.ID, Bot.X, Bot.Y, bResponse.ResponseText); break; case "shout": Session.roomInstance.sendShout(Bot.ID, Bot.X, Bot.Y, bResponse.ResponseText); break; } } if (bResponse.ServeId != 0) { Items.carryItemHelper.setHandItem(ref Me, bResponse.ServeId.ToString()); } } } } /*if (Bot != null) * if (Bot.bInfo.triggerResponse != null) * foreach (KeyValuePair<string, string> pair in Bot.bInfo.triggerResponse) * if (Text.ToLower().Contains(pair.Key)) * { * if (pair.Value.Contains("}")) * { * String[] pairArgs = pair.Value.Split('}'); * Items.carryItemHelper.setHandItem(ref Me, pairArgs[0]); * Session.roomInstance.sendShout(Bot.ID, Bot.X, Bot.Y, pairArgs[1]); * } * else * { * Session.roomInstance.sendShout(Bot.ID, Bot.X, Bot.Y, pair.Value); * } * break; * } * }*/ }
/// <summary> /// Updates the badge status of a given room user in the room. /// </summary> /// <param name="sessionID">The session ID of the session where the target room user belongs to.</param> public void updateUserBadge(uint sessionID) { serverMessage Notify = new serverMessage(228); // "Cd" roomUser rUser = roomUsers[sessionID]; Notify.appendWired(rUser.ID); if (rUser.Session.User.Badge.Length > 0) { Notify.appendClosedValue(rUser.Session.User.Badge); } sendMessage(Notify); }
/// <summary> /// Removes a bot with a given nest ID from the room bot collection, updates the bot information in the database, releases it's map spot and makes it disappear for clients. /// </summary> /// <param name="nestID">The database ID of the nest item of the bot.</param> /// <param name="removedFromRoom">Supply true if this bot is removed from the room by someone with flat admin, and it's coordinates should be reset.</param> public void unloadRoomBot(int botID, bool removedFromRoom) { roomUser pBot = roomBots[botID]; foreach (roomUser bUser in this.roomBots) { if (bUser.bInfo.ID == botID) { this.releaseRoomUnit(pBot.ID, pBot.X, pBot.Y); this.roomBots.Remove(bUser); } } }
private void operateTeleporter(uint sessionID, int itemID) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isTeleporter) // Valid item { Thread.Sleep(550); // Wait for room worker thread to locate user into teleporter roomUser pUser = this.getRoomUser(sessionID); if (pUser != null && pUser.X == pItem.X && pUser.Y == pItem.Y) // In teleporter { int roomID = ObjectTree.Game.Items.getTeleporterRoomID(pItem.teleporterID); if (roomID == 0) { return; } pUser.Clamped = true; this.broadcoastTeleportActivity(pItem.ID, pUser.Session.User.Username, true); this.gridUnit[pItem.X, pItem.Y] = false; // Unblock teleporter if (roomID == this.roomID) { Thread.Sleep(500); floorItem pTeleporter2 = this.getFloorItem(pItem.teleporterID); pUser.X = pTeleporter2.X; pUser.Y = pTeleporter2.Y; pUser.Z = pTeleporter2.Z; pUser.rotationHead = pTeleporter2.Rotation; pUser.rotationBody = pTeleporter2.Rotation; this.gridUnit[pUser.X, pUser.Y] = true; // Block teleporter 2 this.broadcoastTeleportActivity(pTeleporter2.ID, pUser.Session.User.Username, false); pUser.Clamped = false; pUser.requiresUpdate = true; } else { pUser.Session.authenticatedFlat = roomID; pUser.Session.authenticatedTeleporter = pItem.teleporterID; serverMessage Message = new serverMessage(62); // "@~" Message.appendWired(pItem.teleporterID); Message.appendWired(roomID); pUser.Session.gameConnection.sendMessage(Message); } } } }
/// <summary> /// 79 - "AO" /// </summary> public void LOOKTO() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); if (!Me.hasStatus("sit") && !Me.hasStatus("lay")) // Can rotate { string[] Coords = Request.Content.Split(' '); int toX = int.Parse(Coords[0]); int toY = int.Parse(Coords[1]); Me.rotationHead = rotationCalculator.calculateHumanDirection(Me.X, Me.Y, toX, toY); Me.rotationBody = Me.rotationHead; Me.requiresUpdate = true; } }
/// <summary> /// 96 - "A`" /// </summary> public void ASSIGNRIGHTS() { if (Session.roomInstance.sessionHasFlatAdmin(Session.ID)) { roomUser Target = Session.roomInstance.getRoomUser(Request.Content); if (Target == null || Target.hasRights) // Invalid { return; } Target.hasRights = true; Target.refreshRights(); ObjectTree.Game.Rooms.addRoomRights(Session.roomID, Target.Session.User.ID); } }
/// <summary> /// 95 - "A_" /// </summary> public void KICKUSER() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); if (Me.hasRights) { roomUser Target = Session.roomInstance.getRoomUser(Request.Content); if (Target == null || (Target.hasRights && !Me.isOwner) || (Target.Session.User.Role > Session.User.Role)) // Invalid { return; } Target.Session.kickFromRoom(""); } }
/// <summary> /// 55 - "@w" /// </summary> public void SHOUT() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); if (!Me.isMuted) { string Text = Request.getParameter(0); stringFunctions.filterVulnerableStuff(ref Text, true); if (!this.handleSpecialChatCommand(Text)) { Session.roomInstance.sendShout(Me.ID, Me.X, Me.Y, Text); Session.roomInstance.animateTalkingUnit(Me, ref Text, true); ObjectTree.Game.Moderation.addChatMessageToLogStack(Session.ID, Session.User.ID, Session.roomID, 0, chatType.shout, ref Text); } } }
/// <summary> /// 97 - "Aa" /// </summary> public void REMOVERIGHTS() { if (Session.roomInstance.sessionHasFlatAdmin(Session.ID)) { roomUser Target = Session.roomInstance.getRoomUser(Request.Content); if (Target == null || !Target.hasRights || Target.isOwner) // Invalid { return; } Target.hasRights = false; Target.refreshRights(); Target.Session.gameConnection.sendMessage(new Net.Game.Messages.serverMessage(43)); // "@k" ObjectTree.Game.Rooms.removeRoomRights(Session.roomID, Target.Session.User.ID); } }
public void interactWithDice(int itemID, uint sessionID, bool spinDice) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isDice) // Valid item { roomUser pUser = this.getRoomUser(sessionID); if (pUser == null || !tilesTouch(pItem.X, pItem.Y, pUser.X, pUser.Y)) { return; // Invalid position of room user and dice item } pUser = null; serverMessage Message = new serverMessage(90); // "AZ" Message.Append(itemID); itemID *= 38; int randomNumber = 0; if (spinDice) // New spin { this.sendMessage(Message); // Start spin animation for clients // Generate random number randomNumber = new Random(DateTime.Now.Millisecond).Next(1, 7); // 1-6 itemID += randomNumber; } Message.Append(" " + itemID.ToString()); // Append 'new' item ID if (spinDice) // New spin, send delayed message { this.sendMessage(Message.ToString(), 1000); } else // Send message immediately { this.sendMessage(Message); } pItem.customData = randomNumber.ToString(); // Set custom data pItem.requiresUpdate = true; // Request update of dice customdata } }
/// <summary> /// 71 - "AG" /// </summary> public void TRADE_OPEN() { if (Session.itemStripHandler.isTrading || !Session.User.hasFuseRight("fuse_trade")) // Can't trade { return; } int tradePartnerRoomUserID = int.Parse(Request.Content); roomUser tradePartner = Session.roomInstance.getRoomUser(tradePartnerRoomUserID); if (tradePartner == null || tradePartner.Session.itemStripHandler.isTrading) // Can't trade { return; } Session.roomInstance.getRoomUser(Session.ID).addStatus("trd", "trd", null, 0, null, 0, 0); tradePartner.addStatus("trd", "trd", null, 0, null, 0, 0); Session.itemStripHandler.initTrade(tradePartner.Session.ID); tradePartner.Session.itemStripHandler.initTrade(Session.ID); Session.refreshTradeBoxes(); }
/// <summary> /// 93 - "A]" /// </summary> public void DANCE() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); if (Me.hasStatus("sit") || Me.hasStatus("lay") || Me.hasStatus("swim")) // Can't dance right now { return; } string danceType = null; if (Request.Content.Length > 0) // Club dance { int danceID = Request.getNextWiredParameter(); if (danceID < 1 || danceID > 4 || !Session.User.hasFuseRight("fuse_use_club_dance")) { return; } danceType = danceID.ToString(); } Me.removeStatus("handitem"); Me.addStatus("dance", "dance", danceType, 0, null, 0, 0); }
/// <summary> /// Tries to load a bot from the database and makes it visible in the room. If the X and Y parameters are not both zero, then the bot will be placed at the new position. /// </summary> /// <param name="nestID">The database ID of the nest item of the bot to load.</param> /// <param name="newX">The new X position of the bot. Supply 0 to set the last saved X position of the bot.</param> /// <param name="newY">The new Y position of the bot. Supply 0 to set the last saved Y position of the bot.</param> public void loadRoomBot(int botID, byte newX, byte newY) { if (this.roomBots != null) { bInfo = Engine.Game.Items.getBotInformation(botID); if (bInfo != null) { roomUser bUser = new roomUser(bInfo); bUser.ID = this.getFreeRoomUnitIdentifier(); bUser.X = bInfo.startX; bUser.Y = bInfo.startY; bUser.Z = this.gridHeight[bUser.X, bUser.Y]; this.gridUnit[bUser.X, bUser.Y] = true; this.roomBots.Add(bUser); //this.roomUsers.Add((uint)bUser.ID, bUser); Woodpecker.Core.Logging.Log("We tried jeeves."); castRoomUnit(bUser.ToString()); refreshRoomUnitOnTile((byte)0, (byte)0); refreshRoomUnitOnTile(bInfo.startX, bInfo.startY); } } }
public void enterTeleporter(uint sessionID, int itemID) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.Behaviour.isTeleporter) // Valid item { roomUser pUser = this.getRoomUser(sessionID); if (pItem.Rotation == 2 && !(pUser.X == pItem.X + 1 && pUser.Y == pItem.Y)) { return; // Invalid position of room user } if (pItem.Rotation == 4 && !(pUser.X == pItem.X && pUser.Y == pItem.Y + 1)) { return; // Invalid position of room user } pUser.Path.Clear(); blisterMoleNode pNode = new blisterMoleNode(); pNode.X = pItem.X; pNode.Y = pItem.Y; pUser.Path.Add(pNode); requestStartRoomUnitWalk(pUser.Session.ID, pNode.X, pNode.Y, true); } }
public void requestStartRoomUnitWalk(uint sessionID, byte goalX, byte goalY, bool allowOverideNextTile) { roomUser pUser = this.getRoomUser(sessionID); if (pUser != null && !pUser.Clamped) // Able to move { if (!allowOverideNextTile) { pUser.Path.Clear(); } if (tileExists(goalX, goalY) && !tileBlockedByRoomUnit(goalX, goalY)) { pUser.goalX = goalX; pUser.goalY = goalY; pUser.allowOverideNextTile = allowOverideNextTile; pUser.Moves = true; } else { pUser.Moves = false; } pUser.requiresUpdate = true; } }
/// <summary> /// 80 - "AP" /// </summary> public void CARRYDRINK() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); Items.carryItemHelper.setHandItem(ref Me, Request.Content); }
/// <summary> /// Tries to process a given chat message as a chat command and returns true if the operation has succeeded. /// </summary> /// <param name="Text">The chat message to process.</param> private bool handleSpecialChatCommand(string Text) { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); switch (Text) { case "o/": case "\\o": case "\\o/": Me.addStatus("wave", "wave", null, 2, null, 0, 0); break; } if (Text[0] == ':' && Text.Length > 3) // Could be a chat command (emotes too btw) { try { string Command = Text.Substring(1).Split(' ')[0]; string Body = ""; if (Text.Contains(" ")) { Body = Text.Substring(Command.Length + 2); } switch (Command) { #region Common commands for all users case "about": { Response.Initialize(139); // "BK" Response.Append("About Woodpecker"); Response.Append("<br>"); Response.Append("Woodpecker is a V13 Habbo Hotel emulator written in C# .NET by Nils (Nillus)."); Response.Append("<br><br>"); Response.Append("There is currently "); Response.Append(Engine.Game.Users.userCount); Response.Append(" user(s) online."); sendResponse(); } break; case "glow": { Response.Initialize(Specialized.Encoding.base64Encoding.Decode("AG")); Response.Append("lamp setlamp " + Body); sendResponse(); } break; #endregion #region Fancy commands case "descenditem": { if (!Session.User.hasFuseRight("fuse_funchatcommands")) { return(false); } int itemID = int.Parse(Body); if (Session.roomInstance.containsFloorItem(itemID)) { Woodpecker.Game.Items.floorItem pItem = Session.roomInstance.getFloorItem(itemID); Woodpecker.Net.Game.Messages.serverMessage Message = new Woodpecker.Net.Game.Messages.serverMessage(230); // "Cf" Message.appendWired(pItem.X - 1); Message.appendWired(pItem.Y + 1); Message.appendWired(pItem.X); Message.appendWired(pItem.Y); Message.appendWired(true); Message.appendWired(itemID); Message.appendClosedValue("12.0"); Message.appendClosedValue(Woodpecker.Specialized.Text.stringFunctions.formatFloatForClient(pItem.Z)); Message.appendWired(new Random(DateTime.Now.Millisecond).Next(0, 10000)); Session.roomInstance.sendMessage(Message); } } break; case "lingo": { if (!Session.User.hasFuseRight("fuse_funchatcommands")) { return(false); } Session.roomInstance.getRoomUser(Session.ID).addStatus("lingo", "cri", Body, 10, null, 0, 0); } break; case "voice": { if (!Session.User.hasFuseRight("fuse_funchatcommands")) { return(false); } Session.roomInstance.sendMessage(FunUtils.CreateVoiceSpeakMessage(Body)); } break; case "ufos": { if (!Session.User.hasFuseRight("fuse_funchatcommands")) { return(false); } // Hide windows? bool hideWindows = (Body == "1"); if (hideWindows) { Session.roomInstance.getRoomUser(Session.ID).addStatus("lingo", "cri", "hideWindows()", 1, null, 0, 0); } Random rnd = new Random(DateTime.Now.Millisecond * DateTime.Now.Second); int ufoAmount = 50 + rnd.Next(0, 45); Woodpecker.Net.Game.Messages.serverMessage Message = new Woodpecker.Net.Game.Messages.serverMessage(); // Send voice Message = FunUtils.CreateVoiceSpeakMessage("Help, unknown flying objects! The aliens! There's a swarm of " + ufoAmount + " ufos coming this way! UFOS! Help! The hotel is attacked! Zap zap zap... Houston, we have a problem! Aliens! soi soi soi soi soi. The aliens are coming! We didn't listen! The end of the world! Aargh! Help, Aliens everywhere! I see ufos! I dream about cheese! I mean, beep beep beep! Meep meep meep! Code Red! Code Red! Area 51! Marihuana! Cape Canaveral! Aaron is a f*g! Ufos! " + ufoAmount + " of them! I see them everywhere! Oh and I see dead people! UFOS! UFOs from Mars! Or from the Moon! F**k knows! Whatever! Oh my god! They look like f*****g weirdos! Space monsters! They look even worse than Rick Astley! UFOs! It's the end of the world! Ufos! Ufos! Ufos!"); Session.roomInstance.sendMessage(Message); for (int ufoID = 0; ufoID < ufoAmount; ufoID++) { rnd.Next(); rnd.Next(); // Create ufo Woodpecker.Game.Items.floorItem pUfo = new Woodpecker.Game.Items.floorItem(); pUfo.ID = Int32.MinValue - (ufoID + 1); pUfo.Definition = new Items.itemDefinition(); pUfo.Definition.Sprite = "nest"; pUfo.Definition.Length = 1; pUfo.Definition.Width = 1; pUfo.Definition.Color = "0,0,0"; pUfo.X = (byte)rnd.Next(0, 45); pUfo.Y = (byte)rnd.Next(0, 45); pUfo.Z = rnd.Next(-3, 10); int destX = rnd.Next(-(20 + (pUfo.X * 2)), 20 + (pUfo.Y * 2)); int destY = rnd.Next(-(20 + (pUfo.Y * 2)), 20 + (pUfo.X * 2)) + rnd.Next(-10, -20); float destZ = rnd.Next(-9, 10); // Send ufo Message.Initialize(93); // "A]" Message.Append(pUfo.ToString()); Session.roomInstance.sendMessage(Message); // Move ufo Message.Initialize(230); Message.appendWired(destX); Message.appendWired(destY); Message.appendWired(pUfo.X); Message.appendWired(pUfo.Y); Message.appendWired(true); Message.appendWired(pUfo.ID); Message.appendClosedValue(Woodpecker.Specialized.Text.stringFunctions.formatFloatForClient(destZ)); Message.appendClosedValue(Woodpecker.Specialized.Text.stringFunctions.formatFloatForClient(pUfo.Z)); Message.appendWired(rnd.Next(0, 100000)); Session.roomInstance.sendMessage(Message); System.Threading.Thread.Sleep(10); Core.Logging.Log("Ufo " + pUfo.ID + ": [" + pUfo.X + "," + pUfo.Y + "] >> [" + destX + "," + destY + "];", Woodpecker.Core.Logging.logType.debugEvent); } } break; case "handitem": { Items.carryItemHelper.setHandItem(ref Me, Body); } break; #endregion #region Moderation commands case "alert": { if (!Session.User.hasFuseRight("fuse_alert")) { return(false); } string Username = Body.Substring(0, Body.IndexOf(' ')); string Message = Body.Substring(Body.IndexOf(' ') + 1); if (Username.Length > 0 && Message.Length > 0) { if (Engine.Game.Moderation.requestAlert(Session.User.ID, Username, Message, "")) { Session.castWhisper("User has been alerted."); } } } break; case "kick": { if (!Session.User.hasFuseRight("fuse_kick")) { return(false); } string Username = Body.Substring(0, Body.IndexOf(' ')); string Message = Body.Substring(Body.IndexOf(' ') + 1); if (Username.Length > 0) { if (Engine.Game.Moderation.requestKickFromRoom(Session.User.ID, Username, Message, "")) { Session.castWhisper("User has been kicked."); } } } break; case "ban": { if (!Session.User.hasFuseRight("fuse_ban")) { return(false); } string Username = Body.Substring(0, Body.IndexOf(' ')); Body = Body.Substring(Body.IndexOf(' ') + 1); int Hours = int.Parse(Body.Substring(0, Body.IndexOf(' '))); string Message = Body.Substring(Body.IndexOf(' ') + 1); if (Message.Length > 0) { if (Engine.Game.Moderation.requestBan(Session.User.ID, Username, Hours, false, false, Message, "")) { Session.castWhisper("Leet verbannen voor " + Hours + " uur(en)."); } } } break; case "unban": { if (!Session.User.hasFuseRight("fuse_superban")) // Only mods can unban { return(false); } if (Body.Length > 0) { if (Engine.Game.Moderation.requestUnban(Session.User.ID, Body, null, null)) { Session.castWhisper("The ban has been lifted."); Engine.Game.Moderation.logModerationAction(Session.User.ID, "unban", Engine.Game.Users.getUserID(Body), "", "Unban via :unban %username%"); } } } break; case "blacklist": { if (!Session.User.hasFuseRight("fuse_administrator_access")) { return(false); } if (Body.Length > 0) { int userID = Engine.Game.Users.getUserID(Body); if (userID > 0) { userAccessInformation lastAccess = Engine.Game.Users.getLastAccess(userID); if (lastAccess != null) { Engine.Net.Game.blackListIpAddress(lastAccess.IP); Engine.Sessions.destroySessions(lastAccess.IP); Session.castWhisper("IP " + lastAccess.IP + " has been added to the blacklist."); } } } } break; case "roomalert": { if (!Session.User.hasFuseRight("fuse_room_alert")) { return(false); } if (Body.Length > 0) { if (Engine.Game.Moderation.requestRoomAlert(Session.User.ID, Session.roomID, Body, "")) { Session.castWhisper("Room Alerted."); } } } break; case "roomkick": { if (!Session.User.hasFuseRight("fuse_room_kick")) { return(false); } if (Body.Length > 0) { if (Engine.Game.Moderation.requestRoomKick(Session.User.ID, Session.roomID, Body, "")) { Session.castWhisper("The room has been emptied."); } } } break; case "ha": case "hotelalert": { if (!Session.User.hasFuseRight("fuse_hotelalert")) { return(false); } if (Body.Length > 0) { Engine.Game.Moderation.castHotelAlert(Session.User.ID, Body); Session.castWhisper("Hotel Alert has been sent!"); } } break; #endregion #region Debug commands case "debug": { if (!Session.User.hasFuseRight("fuse_debug")) { return(false); } switch (Body) { case "reloadstore": Engine.Game.Items.loadDefinitions(); Engine.Game.Store.loadSales(); Engine.Game.Store.loadCataloguePages(); Session.castWhisper("Re-loaded item definitions, store sales and catalogue pages."); break; case "handitems": Session.itemStripHandler.loadHandItems(); Session.castWhisper("Re-loaded handitems."); break; } } break; case "createitem": { if (!Session.User.hasFuseRight("fuse_debug")) { return(false); } string[] args = Body.Split(' '); // Parse data int definitionID = int.Parse(args[0]); int Amount = int.Parse(args[1]); string customData = null; if (args.Length >= 3) { customData = args[2]; } for (int x = 1; x <= Amount; x++) { Engine.Game.Items.createItemInstance(definitionID, Session.User.ID, customData); } Session.itemStripHandler.loadHandItems(); Session.sendHandStrip("last"); } break; case "woodpecker": { if (Body.Length > 0) { //Engine.Game.Items.createItemInstance(messageID, Session.User.ID, customMessage); Engine.Game.Moderation.castHotelAlert(Session.User.ID, Body); Session.castWhisper("Bedankt Nillus voor de test <3"); //Session.sendHandStrip("last"); } } break; case "multiplier": int.TryParse(Body, out this.Session.PurchaseMultiplier); break; case "stack": this.Session.StackAnything = float.TryParse(Body, out this.Session.StackHeight); break; #endregion default: return(false); } } catch { Session.castWhisper("Error occurred during processing of the chat command, check your parameters."); } return(true); } return(false); }
/// <summary> /// Attempts to set custom data to a floor item, refreshes it in the room, flags it for 'requires database update' and performs optional actions regarding the map etc. /// </summary> /// <param name="itemID">The database ID of the item.</param> /// <param name="sessionID">The ID of the session who's room users requests this action.</param> /// <param name="Data">The new custom data for this floor item as a string.</param> public void setFloorItemData(int itemID, uint sessionID, string Data) { floorItem pItem = this.getFloorItem(itemID); if (pItem != null && pItem.Definition.canContainCustomData) // Valid item { if (pItem.Definition.Behaviour.requiresRightsForInteraction && !this.sessionHasRights(sessionID)) { return; // Item only allows users with room rights to set the custom data, and this user does not have room rights } if (pItem.Definition.Behaviour.requiresTouchingForInteraction) // Item requires room user to stand one tile removed from the item in order to interact { roomUser pUser = this.getRoomUser(sessionID); if (!this.tilesTouch(pItem.X, pItem.Y, pUser.X, pUser.Y)) { return; // Tile of floor item and tile of room user do not 'touch' } } if (!pItem.Definition.Behaviour.isDoor) { if (pItem.Definition.Behaviour.customDataTrueFalse && Data != "TRUE" && Data != "I") { Data = "FALSE"; } else if (pItem.Definition.Behaviour.customDataNumericOnOff && Data != "2") { Data = "1"; } else if (pItem.Definition.Behaviour.customDataOnOff && Data != "ON") { Data = "OFF"; } else if (pItem.Definition.Behaviour.customDataNumericState) // Verify numeric state { if (Data != "x") // EXCEPTION: 00-99 for hockey light = 'x' { int stateID = 0; if (int.TryParse(Data, out stateID) && stateID >= 0 && stateID <= 99) { Data = stateID.ToString(); } else { return; // Invalid numeric state } } } } else { if (Data == "C") // Request to close door { foreach (roomTile lTile in getAffectedTiles(pItem, true).Values) { if (gridUnit[lTile.X, lTile.Y]) { return; // User is on tile, can't close door } } } else { Data = "O"; } pItem.customData = Data; generateFloorMap(); } pItem.customData = Data; if (!pItem.Definition.Behaviour.customDataTrueFalse) { pItem.requiresUpdate = true; } this.broadcoastFloorItemCustomDataUpdate(pItem); } }
/// <summary> /// 94 - "A^" /// </summary> public void WAVE() { roomUser Me = Session.roomInstance.getRoomUser(Session.ID); Me.addStatus("wave", "wave", null, 2, null, 0, 0); }
/// <summary> /// Returns true if a given session has rights in this room. /// </summary> /// <param name="sessionID">The session ID of the session to check.</param> public bool sessionHasRights(uint sessionID) { roomUser pUser = this.getRoomUser(sessionID); return(pUser != null && pUser.hasRights); }
/// <summary> /// Returns true if a given session has flat admin rights ('room owner') in this room. /// </summary> /// <param name="sessionID">The session ID of the session to check.</param> public bool sessionHasFlatAdmin(uint sessionID) { roomUser pUser = this.getRoomUser(sessionID); return(pUser != null && pUser.isOwner); }