Example #1
0
        public override bool OnMoveInto(Mobile m, Direction d, Point3D newLocation, Point3D oldLocation)
        {
            if (m.AccessLevel > AccessLevel.Player || Contains(oldLocation))
            {
                return(true);
            }

            // do they have enough faction to enter?
            XmlMobFactions a = (XmlMobFactions)XmlAttach.FindAttachment(m, typeof(XmlMobFactions));

            if (a == null)
            {
                return(false);
            }

            int fac = a.GetFactionLevel(m_FactionType);

            if (fac < FactionLevel)
            {
                // throttle message display
                if (DateTime.UtcNow - m_lastmsg > TimeSpan.FromSeconds(1))
                {
                    m.SendMessage("Your {0} faction is too low to enter here", FactionType);
                    m_lastmsg = DateTime.UtcNow;
                }
                return(false);
            }

            return(true);
        }
        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);
        }
Example #3
0
        public override void OnEnter(Mobile m)
        {
            if (m == null || m.AccessLevel > AccessLevel.Player)
            {
                return;
            }

            // do they have enough faction to enter?
            XmlMobFactions a = (XmlMobFactions)XmlAttach.FindAttachment(m, typeof(XmlMobFactions));

            if (a == null)
            {
                // kick them out
                KickOut(m);
                return;
            }

            int fac = a.GetFactionLevel(m_FactionType);

            if (fac < FactionLevel)
            {
                KickOut(m);
            }
        }
Example #4
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);
        }
Example #5
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);
        }
Example #6
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);
                    }
                }
            }
        }