Ejemplo n.º 1
0
 public RealmServerCmdArgs(IUser user, bool dbl, IGenericChatTarget chatTarget)
 {
     m_user       = user;
     m_chr        = m_user as Character;
     m_chatTarget = chatTarget;
     Role         = m_user != null ? m_user.Role : PrivilegeMgr.Instance.HighestRole;
     m_dbl        = dbl;
     InitArgs();
 }
Ejemplo n.º 2
0
 public RealmServerCmdArgs(IUser user, bool dbl, IGenericChatTarget chatTarget)
 {
     this.m_user       = user;
     this.m_chr        = this.m_user as Character;
     this.m_chatTarget = chatTarget;
     this.Role         = this.m_user != null ? this.m_user.Role : Singleton <PrivilegeMgr> .Instance.HighestRole;
     this.m_dbl        = dbl;
     this.InitArgs();
 }
Ejemplo n.º 3
0
 public RealmServerCmdArgs(RealmServerCmdArgs args)
 {
     m_user       = args.m_user;
     m_chr        = args.Character;
     m_chatTarget = args.m_chatTarget;
     Role         = args.Role;
     m_dbl        = args.m_dbl;
     InitArgs();
 }
Ejemplo n.º 4
0
        /// <summary>
        /// Check if a Character forgave an Ambusher
        /// </summary>
        static void CheckAmbusherRelease(IChatter chatter, string message,
                                         ChatLanguage lang, ChatMsgType chatType, IGenericChatTarget target)
        {
            if (chatter is Character)                   // make sures its a Character (could also be a broadcast or an IRC bot etc)
            {
                var chr      = (Character)chatter;
                var selected = chr.Target as NPC;
                if (selected != null &&
                    selected.FactionId == FactionId.Friendly &&                                                 // Ambusher is frienddly
                    selected.FirstAttacker == chr &&                                                            // Ambusher was tagged by Chr
                    selected.Entry.NPCId == NPCId.WitchwingAmbusher &&                                          // Chr selected the ambusher
                    (chatType == ChatMsgType.Say || chatType == ChatMsgType.Yell) &&                            // Chr speaks out loud
                    message == "I forgive thee!")                                                               // Chr says the right words
                {
                    if (!selected.IsInFrontOf(chr))
                    {
                        // the char was not talking towards the ambusher
                        selected.Say("What? I couldn't hear you!");
                    }
                    else
                    {
                        // The Killer has forgiven the Ambusher

                        // Standup
                        selected.StandState = StandState.Stand;

                        // delay (because standing up takes time)
                        selected.CallDelayed(800, obj => {
                            if (selected.IsInWorld)                             // ensure that Chr and selected didn't disappear in the meantime
                            {
                                if (chr.IsInWorld)
                                {
                                    selected.Yell("Thank you so much! - Now I can leave this place.");
                                }

                                selected.Emote(EmoteType.SimpleApplaud);

                                selected.CallDelayed(1000, obj2 => {
                                    if (selected.IsInWorld)
                                    {
                                        // Finally die
                                        selected.Kill();
                                    }
                                });
                            }
                        });
                    }
                }
            }
        }
Ejemplo n.º 5
0
		/// <summary>
		/// Check if a Character forgave an Ambusher
		/// </summary>
		static void CheckAmbusherRelease(IChatter chatter, string message,
			ChatLanguage lang, ChatMsgType chatType, IGenericChatTarget target)
		{
			if (chatter is Character)	// make sures its a Character (could also be a broadcast or an IRC bot etc)
			{
				var chr = (Character)chatter;
				var selected = chr.Target as NPC;
				if (selected != null &&
					selected.FactionId == FactionId.Friendly &&							// Ambusher is frienddly
					selected.FirstAttacker == chr &&									// Ambusher was tagged by Chr
					selected.Entry.NPCId == NPCId.WitchwingAmbusher &&					// Chr selected the ambusher
					(chatType == ChatMsgType.Say || chatType == ChatMsgType.Yell) &&	// Chr speaks out loud
					message == "I forgive thee!")										// Chr says the right words
				{
					if (!selected.IsInFrontOf(chr))
					{
						// the char was not talking towards the ambusher
						selected.Say("What? I couldn't hear you!");
					}
					else
					{
						// The Killer has forgiven the Ambusher

						// Standup
						selected.StandState = StandState.Stand;

						// delay (because standing up takes time)
						selected.CallDelayed(800, obj => {
							if (selected.IsInWorld) // ensure that Chr and selected didn't disappear in the meantime
							{
								if (chr.IsInWorld)
								{
									selected.Yell("Thank you so much! - Now I can leave this place.");
								}

								selected.Emote(EmoteType.SimpleApplaud);

								selected.CallDelayed(1000, obj2 => {
									if (selected.IsInWorld)
									{
										// Finally die
										selected.Kill();
									}
								});
							}
						});
					}
				}
			}
		}
Ejemplo n.º 6
0
		/// <summary>
		/// Triggers a chat notification event.
		/// </summary>
		/// <param name="chatter">the person chatting</param>
		/// <param name="message">the chat message</param>
		/// <param name="language">the chat language</param>
		/// <param name="chatType">the type of chat</param>
		/// <param name="target">the target of the message (channel, whisper, etc)</param>
		public static void ChatNotify(IChatter chatter, string message, ChatLanguage language, ChatMsgType chatType, IGenericChatTarget target)
		{
			var chatNotify = MessageSent;

			if (chatNotify != null)
			{
				chatNotify(chatter, message, language, chatType, target);
			}
		}
Ejemplo n.º 7
0
        /// <summary>
        /// Default Command-Handling method
        /// </summary>
        /// <returns>Whether the given msg triggered a command</returns>
        public static bool HandleCommand(IUser user, string msg, IGenericChatTarget target)
        {
            if (msg.Length > 0 && user.Role.Commands.Count > 0)
            {
                bool isCall;
                char prefix;
                if (!(isCall = !IsCommandPrefix(prefix = msg[0])) || (prefix == ExecCommandPrefix))
                {
                    if (msg.Length != 2 || msg[1] != '?')                       // help command is special!
                    {
                        var found = false;
                        foreach (var c in msg)
                        {
                            if (c >= 'A')
                            {
                                // only try to parse command if it contains any actual characters
                                // (which can form a Command-alias)
                                found = true;
                                break;
                            }
                        }
                        if (!found)
                        {
                            return(false);
                        }
                    }

                    var dbl    = false;
                    var offset = 1;

                    if (msg[1] == prefix)
                    {
                        // double prefix
                        if (!user.Role.CanUseCommandsOnOthers)
                        {
                            user.SendMessage("You are not allowed to use Commands on others.");
                            return(true);
                        }
                        else
                        {
                            if (user.Target == null)
                            {
                                user.SendMessage("Invalid target.");
                                return(true);
                            }
                            else
                            {
                                dbl = true;
                                offset++;
                            }
                        }
                    }

                    var trigger = new IngameCmdTrigger(new StringStream(msg.Substring(offset)), user, target, dbl);

                    if (trigger.InitTrigger())
                    {
                        if (trigger.Args.Context != null)
                        {
                            trigger.Args.Context.ExecuteInContext(() =>
                            {
                                if (!isCall)
                                {
                                    Instance.Execute(trigger, false);
                                }
                                else
                                {
                                    Call(trigger);
                                }
                            });
                        }
                        else
                        {
                            if (!isCall)
                            {
                                Instance.Execute(trigger, false);
                            }
                            else
                            {
                                Call(trigger);
                            }
                        }
                    }
                    return(true);
                }

                if (prefix == SelectCommandPrefix && user.Role.IsStaff)
                {
                    return(SelectCommand(user, msg.Substring(1)));
                }
            }
            return(false);
        }
Ejemplo n.º 8
0
 public IngameCmdTrigger(StringStream text, IUser user, IGenericChatTarget target, bool dbl)
     : base(text, new RealmServerCmdArgs(user, dbl, target))
 {
 }
Ejemplo n.º 9
0
        /// <summary>Default Command-Handling method</summary>
        /// <returns>Whether the given msg triggered a command</returns>
        public static bool HandleCommand(IUser user, string msg, IGenericChatTarget target)
        {
            if (msg.Length > 0 && user.Role.Commands.Count > 0)
            {
                char ch1;
                bool isCall;
                if (!(isCall = !RealmCommandHandler.IsCommandPrefix(ch1 = msg[0])) ||
                    (int)ch1 == (int)RealmCommandHandler.ExecCommandPrefix)
                {
                    if (msg.Length != 2 || msg[1] != '?')
                    {
                        bool flag = false;
                        foreach (char ch2 in msg)
                        {
                            if (ch2 >= 'A')
                            {
                                flag = true;
                                break;
                            }
                        }

                        if (!flag)
                        {
                            return(false);
                        }
                    }

                    bool dbl        = false;
                    int  startIndex = 1;
                    if ((int)msg[1] == (int)ch1)
                    {
                        if (!user.Role.CanUseCommandsOnOthers)
                        {
                            user.SendMessage("You are not allowed to use Commands on others.");
                            return(true);
                        }

                        if (user.Target == null)
                        {
                            user.SendMessage("Invalid target.");
                            return(true);
                        }

                        dbl = true;
                        ++startIndex;
                    }

                    IngameCmdTrigger trigger =
                        new IngameCmdTrigger(new StringStream(msg.Substring(startIndex)), user, target, dbl);
                    if (trigger.InitTrigger())
                    {
                        if (trigger.Args.Context != null)
                        {
                            trigger.Args.Context.ExecuteInContext((Action)(() =>
                            {
                                if (!isCall)
                                {
                                    RealmCommandHandler.Instance.Execute((CmdTrigger <RealmServerCmdArgs>)trigger,
                                                                         false);
                                }
                                else
                                {
                                    RealmCommandHandler.Call((CmdTrigger <RealmServerCmdArgs>)trigger);
                                }
                            }));
                        }
                        else if (!isCall)
                        {
                            RealmCommandHandler.Instance.Execute((CmdTrigger <RealmServerCmdArgs>)trigger, false);
                        }
                        else
                        {
                            RealmCommandHandler.Call((CmdTrigger <RealmServerCmdArgs>)trigger);
                        }
                    }

                    return(true);
                }

                if ((int)ch1 == (int)RealmCommandHandler.SelectCommandPrefix && user.Role.IsStaff)
                {
                    return(RealmCommandHandler.SelectCommand(user, msg.Substring(1)));
                }
            }

            return(false);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Sends a system message to the target.
 /// </summary>
 /// <param name="target">the target being sent a system message</param>
 /// <param name="msg">the message to send</param>
 /// <param name="args">any arguments to be formatted in the message</param>
 public static void SendMessage(this IGenericChatTarget target, string msg, params object[] args)
 {
     target.SendMessage(string.Format(msg, args));
 }
Ejemplo n.º 11
0
        /// <summary>
        /// Triggers a chat notification event.
        /// </summary>
        /// <param name="chatter">the person chatting</param>
        /// <param name="message">the chat message</param>
        /// <param name="language">the chat language</param>
        /// <param name="chatType">the type of chat</param>
        /// <param name="target">the target of the message (channel, whisper, etc)</param>
        public static void ChatNotify(IChatter chatter, string message, ChatLanguage language, ChatMsgType chatType, IGenericChatTarget target)
        {
            var chatNotify = MessageSent;

            if (chatNotify != null)
            {
                chatNotify(chatter, message, language, chatType, target);
            }
        }