private static void UserChat(Session Session, ClientMessage Message) { if (Session.CharacterInfo.IsMuted) { return; } RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor == null) { return; } bool Shout = (Message.Id == OpcodesIn.ROOM_CHAT_SHOUT); string MessageText = UserInputFilter.FilterString(Message.PopString()); if (MessageText.Length == 0) { return; } if (MessageText.Length > 100) { MessageText = MessageText.Substring(0, 100); } MessageText = Wordfilter.Filter(MessageText); if (MessageText.StartsWith(":") && (ChatCommands.HandleCommand(Session, MessageText) || Session.HasRight("moderation_tool"))) { return; } if (Instance.WiredManager.HandleChat(MessageText, Actor)) { Actor.Whisper(MessageText, 0); return; } Actor.Chat(MessageText, Shout, Session.HasRight("mute")); if (Instance.HumanActorCount > 1) { QuestManager.ProgressUserQuest(Session, QuestType.SOCIAL_CHAT); } }
private static void UserWhisper(Session Session, ClientMessage Message) { if (Session.CharacterInfo.IsMuted) { return; } RoomInstance Instance = RoomManager.GetInstanceByRoomId(Session.CurrentRoomId); if (Instance == null) { return; } RoomActor Actor = Instance.GetActorByReferenceId(Session.CharacterId); if (Actor == null) { return; } string MessageText = UserInputFilter.FilterString(Message.PopString().Trim()); if (MessageText.Length == 0) { return; } if (MessageText.Length > 100) { MessageText = MessageText.Substring(0, 100); } string[] Bits = MessageText.Split(' '); if (Bits.Length < 2) { return; } string UserBit = Bits[0]; MessageText = MessageText.Substring(UserBit.Length + 1); uint UserId = CharacterResolverCache.GetUidFromName(UserBit); if (UserId > 0) { Actor.Whisper(MessageText, UserId); } }
public void ExecuteActions(Item Item, RoomActor Actor) { Random rnd = new Random (); foreach (Item ActionItem in mInstance.GetItemsOnPosition(Item.RoomPosition.GetVector2())) { if (ActionItem.Definition.Behavior == ItemBehavior.WiredEffect) { ActionItem.DisplayFlags = "1"; ActionItem.BroadcastStateUpdate (mInstance); ActionItem.DisplayFlags = "2"; ActionItem.RequestUpdate (4); switch (WiredTypesUtil.EffectFromInt (ActionItem.Definition.BehaviorData)) { #region show_message case WiredEffectTypes.show_message: if (Actor == null) { continue; } Actor.Whisper (mWired [ActionItem.Id].Data1, 0, true); break; #endregion #region move_rotate case WiredEffectTypes.move_rotate: if (ActionItem.WiredData.Data2 == 0 && ActionItem.WiredData.Data3 == 0) { continue; } String[] ItemsToMove = ActionItem.WiredData.Data1.Split ('|'); foreach (String toMove in ItemsToMove) { uint ItemId; uint.TryParse (toMove, out ItemId); Item Move = mInstance.GetItem (ItemId); if (Move == null) { continue; } Vector2 NewPosition = new Vector2 (Move.RoomPosition.X, Move.RoomPosition.Y); switch (ActionItem.WiredData.Data2) { case 1: switch (rnd.Next (1, 5)) { case 1: NewPosition = new Vector2 (Move.RoomPosition.X - 1, Move.RoomPosition.Y); break; case 2: NewPosition = new Vector2 (Move.RoomPosition.X + 1, Move.RoomPosition.Y); break; case 3: NewPosition = new Vector2 (Move.RoomPosition.X, Move.RoomPosition.Y + 1); break; case 4: NewPosition = new Vector2 (Move.RoomPosition.X, Move.RoomPosition.Y - 1); break; } break; case 2: if (rnd.Next (0, 2) == 1) { NewPosition = new Vector2 (Move.RoomPosition.X - 1, Move.RoomPosition.Y); } else { NewPosition = new Vector2 (Move.RoomPosition.X + 1, Move.RoomPosition.Y); } break; case 3: if (rnd.Next (0, 2) == 1) { NewPosition = new Vector2 (Move.RoomPosition.X, Move.RoomPosition.Y - 1); } else { NewPosition = new Vector2 (Move.RoomPosition.X, Move.RoomPosition.Y + 1); } break; case 4: NewPosition = new Vector2 (Move.RoomPosition.X, Move.RoomPosition.Y - 1); break; case 5: NewPosition = new Vector2 (Move.RoomPosition.X + 1, Move.RoomPosition.Y); break; case 6: NewPosition = new Vector2 (Move.RoomPosition.X, Move.RoomPosition.Y + 1); break; case 7: NewPosition = new Vector2 (Move.RoomPosition.X - 1, Move.RoomPosition.Y); break; } int NewRotation = Move.RoomRotation; switch (ActionItem.WiredData.Data3) { case 1: NewRotation = NewRotation + 2; if (NewRotation == 8) { NewRotation = 0; } break; case 2: NewRotation = (NewRotation - 2); if (NewRotation == -2) { NewRotation = 6; } break; case 3: if (rnd.Next (0, 2) == 1) { goto case 1; } else { goto case 2; } } bool IsRotationOnly = (ActionItem.WiredData.Data2 == 0); Vector3 FinalizedPosition = mInstance.SetFloorItem (null, Move, NewPosition, NewRotation); if (FinalizedPosition != null) { Move.MoveToRoom (null, mInstance.RoomId, FinalizedPosition, NewRotation, ""); RoomManager.MarkWriteback (Move, false); mInstance.RegenerateRelativeHeightmap (); mInstance.BroadcastMessage (RoomItemUpdatedComposer.Compose (Move)); ItemEventDispatcher.InvokeItemEventHandler (null, Move, mInstance, ItemEventType.Moved, IsRotationOnly ? 1 : 0); } } break; #endregion #region match_to_sshot case WiredEffectTypes.match_to_sshot: String[] Selected = ActionItem.WiredData.Data5.Split ('+'); foreach (String FullData in Selected) { if (!FullData.Contains ('#')) { continue; } String[] Data = FullData.Split ('#'); if (Data.Length != 4) { continue; } uint Id = uint.Parse (Data [0]); String[] Position = Data [1].Split ('|'); int Rotation = int.Parse (Data [2]); String Flags = Data [3]; int X = int.Parse (Position [0]); int Y = int.Parse (Position [1]); uint Z = uint.Parse (Position [2]); Item AffectedItem = mInstance.GetItem (Id); if (AffectedItem == null) { continue; } Boolean IsRotationOnly = (X == AffectedItem.RoomPosition.X && Y == AffectedItem.RoomPosition.Y && Z == AffectedItem.RoomPosition.Z); Vector2 NewPosition = new Vector2 (X, Y); if (ActionItem.WiredData.Data2 == 1) { AffectedItem.Flags = Flags; AffectedItem.DisplayFlags = Item.Flags; AffectedItem.BroadcastStateUpdate (mInstance); } if (ActionItem.WiredData.Data3 == 0) { Rotation = AffectedItem.RoomRotation; } if (ActionItem.WiredData.Data4 == 0) { NewPosition = AffectedItem.RoomPosition.GetVector2 (); } if (ActionItem.WiredData.Data4 == 1 || ActionItem.WiredData.Data3 == 1) { Vector3 FinalizedPosition = mInstance.SetFloorItem (null, AffectedItem, NewPosition, Rotation); AffectedItem.MoveToRoom (null, mInstance.RoomId, FinalizedPosition, Rotation, ""); RoomManager.MarkWriteback (AffectedItem, false); mInstance.RegenerateRelativeHeightmap (); mInstance.BroadcastMessage (RoomItemUpdatedComposer.Compose (AffectedItem)); ItemEventDispatcher.InvokeItemEventHandler (null, AffectedItem, mInstance, ItemEventType.Moved, IsRotationOnly ? 1 : 0); } else if (ActionItem.WiredData.Data2 == 1) { RoomManager.MarkWriteback (AffectedItem, true); } } break; #endregion case WiredEffectTypes.teleport_to: if (Actor == null) { continue; } String[] Selected2 = ActionItem.WiredData.Data1.Split ('|'); String ItemIdS = Actor.FurniOnId.ToString (); while (Actor.FurniOnId.ToString() == ItemIdS) { ItemIdS = Selected2 [rnd.Next (0, Selected2.Length)]; } uint ItemId2; uint.TryParse (ItemIdS, out ItemId2); Item AffectedItem2 = mInstance.GetItem (ItemId2); if (AffectedItem2 == null) { continue; } Actor.PositionToSet = AffectedItem2.RoomPosition.GetVector2 (); Actor.UpdateNeeded = true; break; case WiredEffectTypes.toggle_state: String[] Selected3 = ActionItem.WiredData.Data1.Split ('|'); foreach (String ItemIdS2 in Selected3) { uint ItemId3; uint.TryParse (ItemIdS2, out ItemId3); Item AffectedItem3 = mInstance.GetItem (ItemId3); if (AffectedItem3 == null) { continue; } int CurrentState = 0; int.TryParse (AffectedItem3.Flags, out CurrentState); int NewState = CurrentState + 1; if (CurrentState < 0 || CurrentState >= (AffectedItem3.Definition.BehaviorData - 1)) { NewState = 0; } if (CurrentState != NewState) { AffectedItem3.Flags = NewState.ToString (); AffectedItem3.DisplayFlags = AffectedItem3.Flags; RoomManager.MarkWriteback (AffectedItem3, true); AffectedItem3.BroadcastStateUpdate (mInstance); } } break; } } } }