예제 #1
0
        public override void OnKilled(Mobile killed, Mobile killer)
        {
            base.OnKill(killed, killer);

            if (killer == null)
            {
                return;
            }

            XmlMobFactions.GroupTypes g = XmlMobFactions.GroupTypes.End_Unused;
            try{
                g = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), FactionType, true);
            } catch {}

            if (g != XmlMobFactions.GroupTypes.End_Unused)
            {
                // give the killer the faction
                // get XmlMobFaction type attachments and add the faction
                ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, killer, typeof(XmlMobFactions));
                if (list != null && list.Count > 0)
                {
                    foreach (XmlMobFactions x in list)
                    {
                        x.SetFactionLevel(g, x.GetFactionLevel(g) + Value);
                    }
                }

                killer.SendMessage("Receive {0}", OnIdentify(killer));
            }
        }
예제 #2
0
        private ArrayList Search(object target, out string status_str)
        {
            status_str = null;
            ArrayList newarray   = new ArrayList();
            Type      targetType = null;

            // if the type is specified then get the search type
            if (Dosearchtype && Searchtype != null)
            {
                targetType = SpawnerType.GetType(Searchtype);
                if (targetType == null)
                {
                    status_str = "Invalid type: " + Searchtype;
                    return(newarray);
                }
            }

            ArrayList attachments = XmlAttach.FindAttachments(target as IEntity);

            // do the search through attachments
            if (attachments != null)
            {
                foreach (XmlAttachment i in attachments)
                {
                    bool hastype = false;
                    bool hasname = false;

                    if (i == null || i.Deleted)
                    {
                        continue;
                    }

                    // check for type
                    if (Dosearchtype && (i.GetType().IsSubclassOf(targetType) || i.GetType().Equals(targetType)))
                    {
                        hastype = true;
                    }
                    if (Dosearchtype && !hastype)
                    {
                        continue;
                    }

                    // check for name
                    if (Dosearchname && (i.Name != null) && (Searchname != null) &&
                        (i.Name.ToLower().IndexOf(Searchname.ToLower()) >= 0))
                    {
                        hasname = true;
                    }
                    if (Dosearchname && !hasname)
                    {
                        continue;
                    }

                    // satisfied all conditions so add it
                    newarray.Add(i);
                }
            }

            return(newarray);
        }
예제 #3
0
        public static List <XmlGroup> GetGroups(IEntity m)
        {
            if (m == null)
            {
                return(null);
            }
            ArrayList alist = XmlAttach.FindAttachments(m);

            if (alist == null || alist.Count == 0)
            {
                return(null);
            }
            List <XmlGroup> output = new List <XmlGroup>();

            foreach (Object xmlattachment in alist)
            {
                if (xmlattachment is XmlGroup)
                {
                    output.Add(xmlattachment as XmlGroup);
                }
            }
            if (output.Count > 0)
            {
                return(output);
            }
            return(null);
        }
예제 #4
0
        public static void VerboseMobFactions_OnCommand(CommandEventArgs e)
        {
            // get the mob factions attachment
            ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, e.Mobile, typeof(XmlMobFactions), "Standard");

            if (list != null && list.Count > 0)
            {
                XmlMobFactions x = list[0] as XmlMobFactions;

                if (e.Arguments.Length > 0)
                {
                    try
                    {
                        x.verboseMobFactions = bool.Parse(e.Arguments[0]);
                    }
                    catch
                    {
                    }
                }

                e.Mobile.SendMessage("VerboseMobFactions is set to {0}", x.verboseMobFactions);
            }
            else
            {
                e.Mobile.SendMessage("Standard XmlMobFactions attachment not found");
            }
        }
예제 #5
0
        public static int GetFactionLevel(Mobile m, GroupTypes grouptype)
        {
            if (m == null || grouptype == GroupTypes.End_Unused)
            {
                return(0);
            }

            ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, m, typeof(XmlMobFactions), "Standard");

            if (list != null && list.Count > 0)
            {
                XmlMobFactions x = list[0] as XmlMobFactions;

                if (x.FactionList == null)
                {
                    return(0);
                }

                foreach (GroupStatus g in x.FactionList)
                {
                    if (g.GroupType == grouptype)
                    {
                        return(g.FactionLevel);
                    }
                }
            }
            return(0);
        }
예제 #6
0
파일: XmlTitle.cs 프로젝트: pallop/Servuo
        public static void AddTitles(object o, ObjectPropertyList list)
        {
            List <XmlAttachment> alist = XmlAttach.FindAttachments(o, typeof(XmlTitle));

            if (alist != null && alist.Count > 0)
            {
                string titlestring = null;
                bool   hastitle    = false;
                foreach (XmlTitle t in alist)
                {
                    if (t == null || t.Deleted)
                    {
                        continue;
                    }

                    if (hastitle)
                    {
                        titlestring += '\n';
                    }
                    titlestring += Utility.FixHtml(t.Title);
                    hastitle     = true;
                }
                if (hastitle)
                {
                    list.Add(1070722, "<BASEFONT COLOR=#E6CC80>{0}<BASEFONT COLOR=#FFFFFF>", titlestring);
                }
            }
        }
        public override bool CanEquip(Mobile from)
        {
            // check to see if the owners faction is sufficient
            ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, from, typeof(XmlMobFactions), "Standard");

            if (list != null && list.Count > 0)
            {
                int faclevel = 0;

                XmlMobFactions x = list[0] as XmlMobFactions;

                if (this.m_GroupType != XmlMobFactions.GroupTypes.End_Unused)
                {
                    faclevel = x.GetFactionLevel(this.m_GroupType);
                }

                if (faclevel < this.MinValue && this.AttachedTo is Item && this.AttachedTo != null)
                {
                    Item   item = this.AttachedTo as Item;
                    string name = item.Name;
                    if (name == null)
                    {
                        name = item.ItemData.Name;
                    }
                    from.SendMessage("Cannot equip {2}. Need {0} {1} faction.", this.MinValue, this.FactionType, name);
                    return(false);
                }
            }

            return(true);
        }
예제 #8
0
        public static void CheckMobFactions_OnCommand(CommandEventArgs e)
        {
            // get the mob factions attachment
            ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, e.Mobile, typeof(XmlMobFactions), "Standard");

            if (list != null && list.Count > 0)
            {
                XmlMobFactions x = list[0] as XmlMobFactions;
                e.Mobile.SendMessage("{0}", x.OnIdentify(e.Mobile));
            }
        }
예제 #9
0
        public static int GetCredits(Mobile m)
        {
            int val = 0;

            ArrayList list = XmlAttach.FindAttachments(m, typeof(XmlMobFactions), "Standard");

            if (list != null && list.Count > 0)
            {
                val = ((XmlMobFactions)list[0]).Credits;
            }

            return(val);
        }
        public static List <XmlValue> Search(string name)
        {
            var sortedXmlValues = new List <XmlValue>();

            foreach (Mobile mob in World.Mobiles.Values)
            {
                if (!(mob is PlayerMobile))
                {
                    continue;
                }

                ArrayList alist = XmlAttach.FindAttachments(mob);
                if (alist != null)
                {
                    foreach (XmlAttachment a in alist)
                    {
                        if (a is XmlValue && !a.Deleted && a.Name == name)
                        {
                            XmlValue xmlValue = a as XmlValue;
                            int      i        = 0;
                            bool     inserted = false;
                            // sort from highest to lowest value
                            while (i < sortedXmlValues.Count)
                            {
                                if (sortedXmlValues[i].Value < xmlValue.Value)
                                {
                                    sortedXmlValues.Insert(i, xmlValue);
                                    inserted = true;
                                    break;
                                }
                                i++;
                            }
                            if (!inserted)                             // append to the end
                            {
                                sortedXmlValues.Add(xmlValue);
                            }
                        }
                        //if (a != null && !a.Deleted &&  )
                        //{
                        //a.OnBeforeKill(m_killed, m_killer);
                        //}
                    }
                }
            }
            return(sortedXmlValues);
        }
예제 #11
0
        public override void OnAttach()
        {
            base.OnAttach();

            // apply the mod
            if (this.AttachedTo is PlayerMobile)
            {
                // for players just add it immediately
                // lookup the group type
                XmlMobFactions.GroupTypes g = XmlMobFactions.GroupTypes.End_Unused;
                try
                {
                    g = (XmlMobFactions.GroupTypes)Enum.Parse(typeof(XmlMobFactions.GroupTypes), this.FactionType, true);
                }
                catch
                {
                }

                if (g != XmlMobFactions.GroupTypes.End_Unused)
                {
                    // get XmlMobFaction type attachments and add the faction
                    List <XmlAttachment> list = XmlAttach.FindAttachments(this.AttachedTo, typeof(XmlMobFactions));
                    if (list != null && list.Count > 0)
                    {
                        foreach (XmlMobFactions x in list)
                        {
                            x.SetFactionLevel(g, x.GetFactionLevel(g) + this.Value);
                        }
                    }

                    ((Mobile)this.AttachedTo).SendMessage("Receive {0}", this.OnIdentify((Mobile)this.AttachedTo));
                }
                else
                {
                    ((Mobile)this.AttachedTo).SendMessage("{0}: no such faction", this.FactionType);
                }
                // and then remove the attachment
                this.Delete();
            }
            else if (this.AttachedTo is Item)
            {
                // dont allow item attachments
                this.Delete();
            }
        }
예제 #12
0
        public virtual void ValidateSkillMods(Mobile from)
        {
            ArrayList a = XmlAttach.FindAttachments(from);

            foreach (XmlAttachment x in a)
            {
                if (x is LokaiSkillMod)
                {
                    if (((LokaiSkillMod)x).CheckCondition())
                    {
                        continue;
                    }
                    else
                    {
                        InternalRemoveSkillMod(from, x as LokaiSkillMod);
                    }
                }
            }
        }
예제 #13
0
        public static void AddAllMobFactions_OnCommand(CommandEventArgs e)
        {
            int count = 0;

            foreach (Mobile m in World.Mobiles.Values)
            {
                if (m.Player)
                {
                    // does this player already have a points attachment?
                    ArrayList list = XmlAttach.FindAttachments(m, typeof(XmlMobFactions), "Standard");
                    if (list == null || list.Count == 0)
                    {
                        XmlAttachment x = new XmlMobFactions();
                        XmlAttach.AttachTo(e.Mobile, m, x);
                        count++;
                    }
                }
            }
            e.Mobile.SendMessage("Added XmlMobFaction attachments to {0} players", count);
        }
예제 #14
0
        public virtual void UpdateSkillMods(Mobile from)
        {
            ValidateSkillMods(from);

            ArrayList a = XmlAttach.FindAttachments(from);

            foreach (XmlAttachment x in a)
            {
                if (x is LokaiSkillMod)
                {
                    LokaiSkillMod mod = x as LokaiSkillMod;

                    LokaiSkill sk = LokaiSkillUtilities.XMLGetSkills(from)[this.Skill];

                    if (sk != null)
                    {
                        sk.Update();
                    }
                }
            }
        }
예제 #15
0
        public static void RemoveAllMobFactions_OnCommand(CommandEventArgs e)
        {
            int count = 0;

            foreach (Mobile m in World.Mobiles.Values)
            {
                if (m.Player)
                {
                    ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, m, typeof(XmlMobFactions), "Standard");
                    if (list != null && list.Count > 0)
                    {
                        foreach (XmlAttachment x in list)
                        {
                            x.Delete();
                        }
                    }
                    count++;
                }
            }
            e.Mobile.SendMessage("Removed XmlMobFaction attachments from {0} players", count);
        }
예제 #16
0
        public static bool HasCredits(Mobile m, int credits)
        {
            if (m == null || m.Deleted)
            {
                return(false);
            }

            ArrayList list = XmlAttach.FindAttachments(m, typeof(XmlMobFactions), "Standard");

            if (list != null && list.Count > 0)
            {
                XmlMobFactions x = list[0] as XmlMobFactions;

                if (x.Credits >= credits)
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #17
0
        public static string Title(object o)
        {
            if (o == null)
            {
                return(null);
            }

            StringBuilder title = new StringBuilder();

            // look for any attachments on the object that match this one
            ArrayList list = XmlAttach.FindAttachments(o, typeof(XmlDynamicFaction));

            if (list != null && list.Count > 0)
            {
                foreach (XmlAttachment a in list)
                {
                    title.AppendFormat(" [{0}]", a.Name);
                }
            }
            return(title.ToString());
        }
예제 #18
0
        public static bool MatchFaction(object o, string name)
        {
            if (o == null || name == null)
            {
                return(false);
            }

            // look for any attachments on the object that match this one
            ArrayList list = XmlAttach.FindAttachments(o, typeof(XmlDynamicFaction));

            if (list != null && list.Count > 0)
            {
                foreach (XmlAttachment a in list)
                {
                    if (a.Name.ToLower() == name.ToLower())
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
예제 #19
0
        public static double GetScaledFaction(Mobile from, Mobile mob, double min, double max, double scale)
        {
            if (from == null || mob == null || !from.Player)
            {
                return(0);
            }

            double facvalue = 0;

            //XmlMobFactions x = (XmlMobFactions)XmlAttach.FindAttachment(XmlAttach.MobileAttachments, from, typeof(XmlMobFactions), "Standard");

            XmlMobFactions x = XmlAttach.FindAttachment(from, typeof(XmlMobFactions), "Standard") as XmlMobFactions;

            if (x != null)
            {
                //if(x != null)
                //{

                int count = 0;
                // find any static groups that this mob belongs to.  Note, if it belongs to more than one group, calculate the average.
                List <GroupTypes> glist = FindGroups(mob);

                if (glist != null && glist.Count > 0)
                {
                    foreach (GroupTypes g in glist)
                    {
                        if (g != GroupTypes.End_Unused)
                        {
                            facvalue += x.GetFactionLevel(g) * scale;
                            count++;
                        }
                    }
                }

                // does this mob have dynamic faction assignments?
                List <XmlAttachment> dlist = XmlAttach.FindAttachments(mob, typeof(XmlDynamicFaction));
                if (dlist != null && dlist.Count > 0)
                {
                    //if(XmlAttach.FindAttachment(XmlAttach.MobileAttachments, mob, typeof(XmlDynamicFaction)) != null)
                    //{
                    // do this for dynamic factions as well
                    List <GroupTypes> dglist = DynamicFindGroups(mob);

                    if (dglist != null && dglist.Count > 0)
                    {
                        foreach (GroupTypes g in dglist)
                        {
                            if (g != GroupTypes.End_Unused)
                            {
                                facvalue += x.GetFactionLevel(g) * scale;
                                count++;
                            }
                        }
                    }
                }

                // compute the average faction value
                if (count > 0)
                {
                    facvalue /= count;
                }
            }
            if (facvalue > max)
            {
                facvalue = max;
            }
            if (facvalue < min)
            {
                facvalue = min;
            }

            return(facvalue);
        }
예제 #20
0
        public XmlQuestStatusGump(IXmlQuest questitem, string gumptitle, int X, int Y, bool solid, int screen)
            : base(X, Y)
        {
            Closable    = true;
            Dragable    = true;
            m_X         = X;
            m_Y         = Y;
            m_solid     = solid;
            m_questitem = questitem;
            m_gumptitle = gumptitle;
            m_screen    = screen;

            AddPage(0);

            if (!solid)
            {
                AddImageTiled(54, 33, 369, 400, 2624);
                AddAlphaRegion(54, 33, 369, 400);
            }
            else
            {
                AddBackground(54, 33, 369, 400, 5054);
            }

            AddImageTiled(416, 39, 44, 389, 203);

            //			AddButton( 338, 392, 2130, 2129, 3, GumpButtonType.Reply, 0 ); // Okay button

            AddHtmlLocalized(139, 59, 200, 30, 1046026, 0x7fff, false, false); // Quest Log
            AddImage(97, 49, 9005);                                            // quest ribbon

            AddImageTiled(58, 39, 29, 390, 10460);                             // left hand border
            AddImageTiled(412, 37, 31, 389, 10460);                            // right hand border
            AddImage(430, 9, 10441);
            AddImageTiled(40, 38, 17, 391, 9263);
            AddImage(6, 25, 10421);
            AddImage(34, 12, 10420);
            AddImageTiled(94, 25, 342, 15, 10304);  // top border
            AddImageTiled(40, 414, 415, 16, 10304); // bottom border
            AddImage(-10, 314, 10402);
            AddImage(56, 150, 10411);

            AddImage(136, 84, 96);
            AddImage(372, 57, 1417);
            AddImage(381, 66, 5576);

            // add the status and journal tabs
            AddImageTiled(90, 34, 322, 5, 0x145E); // top border
            int tab1 = 0x138F;
            int tab2 = 0x138E;

            if (screen == 1)
            {
                tab1 = 0x138E;
                tab2 = 0x138F;
            }
            AddButton(100, 18, tab1, tab2, 900, GumpButtonType.Reply, 0);
            AddLabel(115, 17, 0, "Status");
            AddButton(189, 18, tab2, tab1, 901, GumpButtonType.Reply, 0);
            AddLabel(205, 17, 0, "Journal");

            if (screen == 1)
            {
                // display the journal
                if (questitem.Journal != null && questitem.Journal.Count > 0)
                {
                    string journaltext = null;
                    for (int i = 0; i < questitem.Journal.Count; i++)
                    {
                        journaltext += "<u>";
                        journaltext += ((XmlQuest.JournalEntry)questitem.Journal[i]).EntryID;
                        journaltext += ":</u><br>";
                        journaltext += ((XmlQuest.JournalEntry)questitem.Journal[i]).EntryText;
                        journaltext += "<br><br>";
                    }
                    AddHtml(100, 90, 270, 300, journaltext, true, true);
                }

                // add the add journal entry button
                AddButton(300, 49, 0x99C, 0x99D, 952, GumpButtonType.Reply, 0);
                //AddButton(300, 49, 0x159E, 0x159D, 952, GumpButtonType.Reply, 0);
            }
            else
            {
                if (gumptitle != null && gumptitle.Length > 0)
                {                            // display the title if it is there
                    AddImage(146, 91, 2103); // bullet
                    AddHtml(164, 86, 200, 30, XmlSimpleGump.Color(gumptitle, "00FF42"), false, false);
                }

                if (questitem.NoteString != null && questitem.NoteString.Length > 0)
                { // display the note string if it is there
                    AddHtml(100, 106, 270, 80, questitem.NoteString, true, true);
                }

                DisplayQuestStatus(130, 192, questitem.Objective1, questitem.State1, questitem.Completed1, questitem.Description1);
                DisplayQuestStatus(130, 224, questitem.Objective2, questitem.State2, questitem.Completed2, questitem.Description2);
                DisplayQuestStatus(130, 256, questitem.Objective3, questitem.State3, questitem.Completed3, questitem.Description3);
                DisplayQuestStatus(130, 288, questitem.Objective4, questitem.State4, questitem.Completed4, questitem.Description4);
                DisplayQuestStatus(130, 320, questitem.Objective5, questitem.State5, questitem.Completed5, questitem.Description5);

                //if(questitem.HasCollect){
                AddButton(100, 350, 0x2A4E, 0x2A3A, 700, GumpButtonType.Reply, 0);
                AddLabel(135, 356, 0x384, "Collect");
                //}

                if ((questitem.RewardItem != null && !questitem.RewardItem.Deleted))
                {
                    m_questitem.CheckRewardItem();

                    if (questitem.RewardItem.Amount > 1)
                    {
                        AddLabel(230, 356, 55, String.Format("Reward: {0} ({1})", questitem.RewardItem.GetType().Name,
                                                             questitem.RewardItem.Amount));
                        AddLabel(230, 373, 55, String.Format("Weight: {0}", questitem.RewardItem.Weight * questitem.RewardItem.Amount));
                    }
                    else
                    if (questitem.RewardItem is Container)
                    {
                        AddLabel(230, 356, 55, String.Format("Reward: {0} ({1} items)", questitem.RewardItem.GetType().Name,
                                                             questitem.RewardItem.TotalItems));
                        AddLabel(230, 373, 55, String.Format("Weight: {0}", questitem.RewardItem.TotalWeight + questitem.RewardItem.Weight));
                    }
                    else
                    {
                        AddLabel(230, 356, 55, String.Format("Reward: {0}", questitem.RewardItem.GetType().Name));
                        AddLabel(230, 373, 55, String.Format("Weight: {0}", questitem.RewardItem.Weight));
                    }
                    AddImageTiled(330, 373, 81, 40, 200);
                    AddItem(340, 376, questitem.RewardItem.ItemID);
                }
                if (questitem.RewardAttachment != null && !questitem.RewardAttachment.Deleted)
                {
                    AddLabel(230, 339, 55, String.Format("Bonus: {0}", questitem.RewardAttachment.GetType().Name));
                }

                if ((questitem.RewardItem != null && !questitem.RewardItem.Deleted) || (questitem.RewardAttachment != null && !questitem.RewardAttachment.Deleted))
                {
                    if (questitem.CanSeeReward)
                    {
                        AddButton(400, 380, 2103, 2103, 800, GumpButtonType.Reply, 0);
                    }
                }

                // indicate any status info
                XmlQuest.VerifyObjectives(questitem);
                if (questitem.Status != null)
                {
                    AddLabel(100, 392, 33, questitem.Status);
                }
                else
                // indicate the expiration time
                if (questitem.IsValid)
                {
                    //AddHtmlLocalized(150, 400, 50, 37, 1046033, 0xf0000 , false , false ); // Expires
                    AddHtml(130, 392, 200, 37, XmlSimpleGump.Color(questitem.ExpirationString, "00FF42"), false, false);
                }
                else
                if (questitem.AlreadyDone)
                {
                    if (!questitem.Repeatable)
                    {
                        AddLabel(100, 392, 33, "Already done - cannot be repeated");
                    }
                    else
                    {
                        ArrayList a = XmlAttach.FindAttachments(questitem.Owner, typeof(XmlQuestAttachment), questitem.Name);
                        if (a != null && a.Count > 0)
                        {
                            AddLabel(100, 392, 33, String.Format("Repeatable in {0}", ((XmlQuestAttachment)a[0]).Expiration));
                        }
                        else
                        {
                            AddLabel(150, 392, 33, "Already done - ???");
                        }
                    }
                }
                else
                {
                    //AddHtml( 150, 384, 200, 37, XmlSimpleGump.Color( "No longer valid", "00FF42" ), false, false );
                    AddLabel(150, 392, 33, "No longer valid");
                }
                if (XmlQuest.QuestPointsEnabled)
                {
                    AddHtml(250, 40, 200, 30, XmlSimpleGump.Color(String.Format("Difficulty Level {0}", questitem.Difficulty), "00FF42"), false, false);
                }
                if (questitem.PartyEnabled)
                {
                    AddHtml(250, 55, 200, 30, XmlSimpleGump.Color("Party Quest", "00FF42"), false, false);
                    if (questitem.PartyRange >= 0)
                    {
                        AddHtml(250, 70, 200, 30, XmlSimpleGump.Color(String.Format("Party Range {0}", questitem.PartyRange), "00FF42"), false, false);
                    }
                    else
                    {
                        AddHtml(250, 70, 200, 30, XmlSimpleGump.Color("No Range Limit", "00FF42"), false, false);
                    }
                }
                else
                {
                    AddHtml(250, 55, 200, 30, XmlSimpleGump.Color("Solo Quest", "00FF42"), false, false);
                }
            }
        }
예제 #21
0
        public override void OnKill(Mobile killed, Mobile killer)
        {
            base.OnKill(killed, killer);

            // supports ignoring XmlPoints challenges
            if (this.m_ChallengeStatus)
            {
                this.m_ChallengeStatus = false;
                return;
            }

            if (killed == null || killer == null || killer == killed)
            {
                return;
            }

            // check for within guild kills and ignore them
            if (this.SameGuild(killed, killer))
            {
                return;
            }

            // this calculates the base faction level that will be gained/lost based upon the fame of the killed mob
            double value = (double)(killed.Fame / 1000.0);

            if (value <= 0)
            {
                value = 1;
            }

            // calculates credits gained in a similar way
            int cval = (int)(killed.Fame * m_CreditScale);

            if (cval <= 0)
            {
                cval = 1;
            }

            this.Credits += cval;

            // prepare the group lists that will be checked for faction
            ArrayList glist  = null;
            ArrayList dglist = null;

            // check to see whether this mob type has already been hashed into a group list
            if (GroupHash.Contains(killed.GetType()))
            {
                glist = (ArrayList)GroupHash[killed.GetType()];
            }
            else
            {
                // otherwise look it up the slow way and prepare a hash entry for it at the same time
                // unless it is using dynamic faction
                glist = new ArrayList();
                foreach (Group g in KillGroups)
                {
                    if (MatchType(g.Members, killed))
                    {
                        glist.Add(g);
                    }
                }
                GroupHash.Add(killed.GetType(), glist);
            }

            // have to look up dynamic factions the exhaustive way
            // does this mob have dynamic faction assignments?
            ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, killed, typeof(XmlDynamicFaction));

            if (list != null && list.Count > 0)
            {
                //if(XmlAttach.FindAttachment(XmlAttach.MobileAttachments, killed, typeof(XmlDynamicFaction)) != null)
                //{
                dglist = new ArrayList();
                foreach (Group g in KillGroups)
                {
                    if (DynamicMatchType(g.Members, killed))
                    {
                        dglist.Add(g);
                    }
                }
            }

            ArrayList alist = new ArrayList();

            if (glist != null && glist.Count > 0)
            {
                alist.Add(glist);
            }
            if (dglist != null && dglist.Count > 0)
            {
                alist.Add(dglist);
            }

            //  go through this with static and dynamic factions
            foreach (ArrayList al in alist)
            {
                foreach (Group g in al)
                {
                    // tabulate the faction loss from target group allies
                    if (g.Allies != null && g.Allies.Length > 0)
                    {
                        for (int i = 0; i < g.Allies.Length; i++)
                        {
                            Group ally = g.Allies[i];

                            int facloss = 0;
                            try
                            {
                                facloss = (int)(value * g.AllyLoss[i]);
                            }
                            catch
                            {
                            }
                            if (facloss <= 0)
                            {
                                facloss = 1;
                            }

                            int p = this.GetFactionLevel(ally.GroupType) - facloss;
                            this.SetFactionLevel(ally.GroupType, p);
                            if (this.verboseMobFactions)
                            {
                                killer.SendMessage("lost {0} faction {1}", ally.GroupType, facloss);
                            }
                        }
                    }

                    // tabulate the faction gain from target group opponents
                    if (g.Opponents != null && g.Opponents.Length > 0)
                    {
                        for (int i = 0; i < g.Opponents.Length; i++)
                        {
                            Group opp = g.Opponents[i];

                            int facgain = 0;
                            try
                            {
                                facgain = (int)(value * g.OpponentGain[i]);
                            }
                            catch
                            {
                            }
                            if (facgain <= 0)
                            {
                                facgain = 1;
                            }

                            int p = this.GetFactionLevel(opp.GroupType) + facgain;
                            this.SetFactionLevel(opp.GroupType, p);
                            if (this.verboseMobFactions)
                            {
                                killer.SendMessage("gained {0} faction {1}", opp.GroupType, facgain);
                            }
                        }
                    }
                }
            }

            this.m_EndTime = DateTime.Now + this.Refractory;
        }
예제 #22
0
        // note that this method will be called when attached to either a mobile or a weapon
        // when attached to a weapon, only that weapon will do additional damage
        // when attached to a mobile, any weapon the mobile wields will do additional damage
        public override void OnWeaponHit(Mobile attacker, Mobile defender, BaseWeapon weapon, int damageGiven)
        {
            if (m_Chance <= 0 || Utility.Random(100) > m_Chance)
            {
                return;
            }

            if (defender != null && attacker != null && m_EnemyType != XmlMobFactions.GroupTypes.End_Unused)
            {
                // check to the owner's faction levels
                ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, attacker, typeof(XmlMobFactions), "Standard");

                if (list != null && list.Count > 0)
                {
                    XmlMobFactions x = list[0] as XmlMobFactions;

                    double increase = 0;

                    // go through all of the factions the defender might belong to
                    ArrayList glist = XmlMobFactions.FindGroups(defender);

                    if (glist != null && glist.Count > 0)
                    {
                        foreach (XmlMobFactions.GroupTypes targetgroup in glist)
                        {
                            // found the group that matches the enemy type for this attachment
                            if (targetgroup == m_EnemyType)
                            {
                                // get the percent damage increase based upon total faction level of opponent groups
                                int totalfac = 0;

                                // get the target enemy group
                                XmlMobFactions.Group g = XmlMobFactions.FindGroup(m_EnemyType);

                                if (g.Opponents != null)
                                {
                                    // go through all of the opponents of this group
                                    for (int i = 0; i < g.Opponents.Length; i++)
                                    {
                                        // and sum the faction levels
                                        try{
                                            totalfac += (int)(x.GetFactionLevel(g.Opponents[i].GroupType) * g.OpponentGain[i]);
                                        } catch {}
                                    }
                                }

                                // what is the damage increase based upon the total opponent faction level
                                increase = (double)ComputeIncrease(totalfac) / 100.0;

                                break;
                            }
                        }
                    }

                    if (increase > 0)
                    {
                        // apply the additional damage if any
                        defender.Damage((int)(damageGiven * increase), attacker);
                    }
                }
            }
        }
예제 #23
0
        public override string OnIdentify(Mobile from)
        {
            if (from == null)
            {
                if (Expiration > TimeSpan.Zero)
                {
                    return(String.Format("Faction Mastery : increased damage vs {0}, {1}% hitchance, expires in {2} mins",
                                         m_Enemy, Chance, Expiration.TotalMinutes));
                }
                else
                {
                    return(String.Format("Faction Mastery : increased damage vs {0}, {1}% hitchance", m_Enemy, Chance));
                }
            }

            string msg             = null;
            string raisestr        = "improve ";
            int    percentincrease = 0;

            // compute the damage increase based upon the owner's faction level for the specified enemy type
            ArrayList list = XmlAttach.FindAttachments(XmlAttach.MobileAttachments, from, typeof(XmlMobFactions), "Standard");

            if (list != null && list.Count > 0)
            {
                XmlMobFactions x = list[0] as XmlMobFactions;

                // get the percent damage increase based upon total faction level of opponent groups
                int totalfac = 0;

                // get the target enemy group
                XmlMobFactions.Group g = XmlMobFactions.FindGroup(m_EnemyType);

                if (g != null && g.Opponents != null)
                {
                    // go through all of the opponents
                    for (int i = 0; i < g.Opponents.Length; i++)
                    {
                        try{
                            totalfac += (int)(x.GetFactionLevel(g.Opponents[i].GroupType) * g.OpponentGain[i]);
                            raisestr  = String.Format("{0}{1}, ", raisestr, g.Opponents[i].GroupType);
                        } catch {}
                    }
                }

                percentincrease = ComputeIncrease(totalfac);
            }



            if (Expiration > TimeSpan.Zero)
            {
                msg = String.Format("Faction Mastery : +{3}% damage vs {0} ({4}% max), {1}% hitchance, expires in {2} mins",
                                    m_Enemy, Chance, Expiration.TotalMinutes, percentincrease, PercentCap);
            }
            else
            {
                msg = String.Format("Faction Mastery : +{2}% damage vs {0} ({3}% max), {1}% hitchance", m_Enemy, Chance, percentincrease, PercentCap);
            }

            msg = String.Format("{0} : {1}faction to enhance damage.", msg, raisestr);

            return(msg);
        }