Exemple #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);
                        }
                    }
                }
            }
        }
Exemple #2
0
        public static void UnRegisterSkillTrigger(object o, SkillName s, Map map, bool all)
        {
            if (o == null || s == RegisteredSkill.Invalid)
            {
                return;
            }

            // go through the list and if the spawner is on it regardless of the skill registered, then remove it
            if (all)
            {
                for (int i = 0; i < RegisteredSkill.MaxSkills + 1; i++)
                {
                    ArrayList skilllist = RegisteredSkill.TriggerList((SkillName)i, map);

                    if (skilllist == null)
                    {
                        return;
                    }

                    foreach (RegisteredSkill rs in skilllist)
                    {
                        if (rs.target == o)
                        {
                            skilllist.Remove(rs);
                            break;
                        }
                    }
                }
            }
            else
            {
                ArrayList skilllist = RegisteredSkill.TriggerList(s, map);

                if (skilllist == null)
                {
                    return;
                }

                // if the all flag is not set then just remove the spawner from the list for the specified skill
                foreach (RegisteredSkill rs in skilllist)
                {
                    if ((rs.target == o) && (rs.sid == s))
                    {
                        skilllist.Remove(rs);
                        break;
                    }
                }
            }
        }
Exemple #3
0
        public static void RegisterSkillTrigger(object o, SkillName s, Map map)
        {
            if (o == null || s == RegisteredSkill.Invalid)
            {
                return;
            }

            // go through the list and if the spawner is not on it yet, then add it
            bool found = false;

            ArrayList skilllist = RegisteredSkill.TriggerList(s, map);

            if (skilllist == null)
            {
                return;
            }

            foreach (RegisteredSkill rs in skilllist)
            {
                if (rs.target == o && rs.sid == s)
                {
                    found = true;
                    // dont register a skill if it is already on the list for this spawner
                    break;
                }
            }

            // if it hasnt already been added to the list, then add it
            if (!found)
            {
                RegisteredSkill newrs = new RegisteredSkill
                {
                    target = o,
                    sid    = s
                };

                skilllist.Add(newrs);
            }
        }
        public static void RegisterSkillTrigger(object o, SkillName s, Map map)
        {
            if (o == null || s == RegisteredSkill.Invalid)
                return;

            // go through the list and if the spawner is not on it yet, then add it
            bool found = false;
            
            ArrayList skilllist = RegisteredSkill.TriggerList(s, map);

            if (skilllist == null)
                return;

            foreach (RegisteredSkill rs in skilllist)
            {
                if (rs.target == o && rs.sid == s)
                {
                    found = true;
                    // dont register a skill if it is already on the list for this spawner
                    break;
                }
            }

            // if it hasnt already been added to the list, then add it
            if (!found)
            {
                RegisteredSkill newrs = new RegisteredSkill();
                newrs.target = o;
                newrs.sid = s;

                skilllist.Add(newrs);
            }
        }