Exemplo n.º 1
0
        // determines whether  XmlSpawner, XmlAttachment, or XmlQuest OnSkillUse methods should be invoked.
        public static void CheckSkillUse(Mobile m, Skill skill, bool success)
        {
            if (!(m is PlayerMobile) || skill == null)
            {
                return;
            }

            /*
             * // first check for any attachments that might support OnSkillUse
             * ArrayList list = XmlAttach.FindAttachments(m);
             * if(list != null && list.Count > 0)
             * {
             *  foreach(XmlAttachment a in list)
             *  {
             *      if(a != null && !a.Deleted && a.HandlesOnSkillUse)
             *      {
             *          a.OnSkillUse(m, skill, success);
             *      }
             *  }
             * }
             */

            // then check for registered skills
            ArrayList skilllist = RegisteredSkill.TriggerList(skill.SkillName, m.Map);

            if (skilllist == null)
            {
                return;
            }

            // determine whether there are any registered objects for this skill
            foreach (RegisteredSkill rs in skilllist)
            {
                if (rs.sid == skill.SkillName)
                {
                    // if so then invoke their skill handlers
                    if (rs.target is XmlSpawner)
                    {
                        XmlSpawner spawner = (XmlSpawner)rs.target;

                        if (spawner.HandlesOnSkillUse)
                        {
                            // call the spawner handler
                            spawner.OnSkillUse(m, skill, success);
                        }
                    }
                    else
                    if (rs.target is IXmlQuest)
                    {
                        IXmlQuest quest = (IXmlQuest)rs.target;
                        if (quest.HandlesOnSkillUse)
                        {
                            // call the xmlquest handler
                            quest.OnSkillUse(m, skill, success);
                        }
                    }
                }
            }
        }