Exemple #1
0
        /*	** OSI MODEL **
         *      1.  Legendary 120
         *      2.  Elder 110
         *      3.  Grandmaster 100
         *      4.  Master 90
         *      5.  Adept 80
         *      6.  Expert 70
         *      7.  Journeyman 60
         *      8.  Apprentice 50
         *      9.  Novice 40
         *      10. Neophyte 30
         *      No Title 29 or below
         */
        public static string ComputeTitle(Mobile beholder, Mobile beheld)
        {
            StringBuilder title = new StringBuilder();

            try
            {
                int fame  = beheld.Fame;
                int karma = beheld.Karma;

                bool showFameTitle  = beheld.ShowFameTitle;
                bool showSkillTitle = showFameTitle && ((beholder == beheld) || (fame >= 5000));

                /* Publish February 24,1999
                 * Members of the Thieves Guild do not display professional titles on the paperdoll to anyone except themselves, regardless of skill level or fame.
                 * http://www.uoguide.com/Publish_-_February_24,_1999#Stealing
                 */
                if ((beheld is PlayerMobile && beholder is PlayerMobile) && beholder != beheld && (beheld as PlayerMobile).NpcGuild == NpcGuild.ThievesGuild && !(Core.UOAI || Core.UOAR || Core.UOMO))
                {                       // no titles unless looking at self
                    showFameTitle = showSkillTitle = false;
                }

                if (beheld.Murderer && (Core.UOAI || Core.UOAR || Core.UOMO))
                {
                    title.AppendFormat(fame >= 10000 ?
                                       "{3}{1} {0}, Murderer of {2}" :
                                       "{3}{0}, Murderer of {2}",
                                       beheld.Name,
                                       beheld.Female ? "Lady" : "Lord",
                                       beheld.LongTermMurders,
                                       beheld.LongTermMurders >= 200 ? "The Legendary " : "");
                }
                else if (showFameTitle || (beholder == beheld))
                {
                    for (int i = 0; i < m_FameEntries.Length; ++i)
                    {
                        FameEntry fe = m_FameEntries[i];

                        if (fame <= fe.m_Fame || i == (m_FameEntries.Length - 1))
                        {
                            KarmaEntry[] karmaEntries = fe.m_Karma;

                            for (int j = 0; j < karmaEntries.Length; ++j)
                            {
                                KarmaEntry ke = karmaEntries[j];

                                if (karma <= ke.m_Karma || j == (karmaEntries.Length - 1))
                                {
                                    title.AppendFormat(ke.m_Title, beheld.Name, beheld.Female ? "Lady" : "Lord");
                                    break;
                                }
                            }

                            break;
                        }
                    }
                }
                else
                {
                    title.Append(beheld.Name);
                }

                if (beheld is PlayerMobile)
                {
                    PlayerMobile pm = (PlayerMobile)beheld;

                    #region mortal
                    if (pm.Mortal)
                    {
                        title.Append(" the Mortal");
                    }
                    #endregion

                    #region Ethics
                    if (Core.OldEthics)
                    {                           // old-school Hero/Evil titles
                                                // You will gain the title of "the Evil," and you will have "[evil]" attached to your name when looked at.
                        Ethics.Ethic ethic = Ethics.Ethic.Find(pm);
                        if (ethic == Ethics.Ethic.Hero && (pm.EthicPlayer.Power == 0 || pm.EthicPlayer.History == 0))
                        {
                            title.Append(" the Fallen Hero");
                        }
                        else if (ethic == Ethics.Ethic.Hero)
                        {
                            title.Append(" the Hero");
                        }
                        else if (ethic == Ethics.Ethic.Evil)
                        {
                            title.Append(" the Evil");
                        }
                    }
                    #endregion

                    #region IOB
                    string iobtitle = "";
                    if (pm.IOBAlignment != IOBAlignment.None)
                    {
                        try
                        {
                            iobtitle = IOBRankTitle.rank[(int)pm.IOBAlignment, (int)pm.IOBRank];
                        }
                        catch (Exception exc)
                        {
                            LogHelper.LogException(exc);
                            System.Console.WriteLine("Caught exception in Titles: " + exc.Message);
                            System.Console.WriteLine(exc.StackTrace);
                        }

                        if (iobtitle.Length > 0)
                        {
                            title.AppendFormat(", {0}", iobtitle);
                        }
                    }
                    #endregion
                }

                string customTitle = beheld.Title;

                if (customTitle != null && (customTitle = customTitle.Trim()).Length > 0)
                {
                    title.AppendFormat(" {0}", customTitle);
                }
                else if (showSkillTitle && beheld.Player && beheld.LongTermMurders < 5)
                {
                    Skill highest = GetHighestSkill(beheld);                    // beheld.Skills.Highest;

                    if (highest != null && highest.BaseFixedPoint >= 300)
                    {
                        string skillLevel = (string)Utility.GetArrayCap(m_Levels, (highest.BaseFixedPoint - 300) / 100);
                        string skillTitle = ComputeSkillTitle(beheld);

                        if (beheld.Female)
                        {
                            if (skillTitle.EndsWith("man"))
                            {
                                skillTitle = skillTitle.Substring(0, skillTitle.Length - 3) + "woman";
                            }
                        }

                        title.AppendFormat(", {0} {1}", skillLevel, skillTitle);
                    }
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }

            return(title.ToString());
        }
Exemple #2
0
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            if ((target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
            {
                return(Notoriety.Invulnerable);
            }

            if (AutoRestart.ServerWars || target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            #region Dueling
            if (source is PlayerMobile && target is PlayerMobile)
            {
                PlayerMobile pmFrom = (PlayerMobile)source;
                PlayerMobile pmTarg = (PlayerMobile)target;

                if (pmFrom.DuelContext != null && pmFrom.DuelContext.StartedBeginCountdown && !pmFrom.DuelContext.Finished && pmFrom.DuelContext == pmTarg.DuelContext)
                {
                    return(pmFrom.DuelContext.IsAlly(pmFrom, pmTarg) ? Notoriety.Ally : Notoriety.Enemy);
                }
            }
            #endregion

            // Alan mod: custom teams
            if (source.CustomTeam && target.CustomTeam)
            {
                List <XmlTeam> targetTeams = XmlAttach.GetTeams(target);
                List <XmlTeam> fromTeams   = XmlAttach.GetTeams(source);

                if (XmlTeam.SameTeam(fromTeams, targetTeams))
                {
                    if (XmlTeam.ShowGreen(fromTeams, targetTeams))
                    {
                        return(Notoriety.Ally);
                    }
                    // if not show green, use default notoriety
                }
                // they are on the enemy team, allow harmful
                else
                {
                    return(Notoriety.Enemy);
                }
            }
            // end Alan mod

            BaseCreature tbc = target as BaseCreature;
            BaseCreature sbc = source as BaseCreature;
            PlayerMobile tpm = target as PlayerMobile;
            PlayerMobile spm = source as PlayerMobile;

            if (source.Player && !target.Player && spm != null && tbc != null)
            {
                Mobile master = tbc.GetMaster();

                if (!tbc.AlwaysMurderer && tbc.Controlled && master != null)
                {
                    if (master.AccessLevel > AccessLevel.Player || (source == master && CheckAggressor(tbc.Aggressors, source)) || (CheckAggressor(source.Aggressors, tbc)))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    else
                    {
                        return(MobileNotoriety(source, master));
                    }
                }
            }

            if (target.Kills >= 5 || (target.Body.IsMonster && IsSummoned(tbc) && !(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem)) || (tbc != null && (tbc.AlwaysMurderer || tbc.IsAnimatedDead)))
            {
                return(Notoriety.Murderer);
            }

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            CustomRegion      region1  = target.Region as CustomRegion;
            CaptureZoneRegion regionCz = target.Region as CaptureZoneRegion;

            if (region1 != null && region1.AlwaysGrey() || regionCz != null && regionCz.Czone.AlwaysGrey)
            {
                return(Notoriety.CanBeAttacked);
            }

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (sourceGuild != null && targetGuild != null)
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }
                else if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }



            #region Ethics Checks of target or master of target
            Ethics.Ethic sourceEthic = Ethics.Ethic.Find(source, true, true);
            Ethics.Ethic targetEthic = Ethics.Ethic.Find(target, true, true);

            if (sourceEthic != null && targetEthic != null && targetEthic != sourceEthic)
            {
                return(Notoriety.Enemy);
            }
            #endregion

            Faction srcFaction = Faction.Find(source, true, true);
            Faction trgFaction = Faction.Find(target, true, true);

            if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
            {
                return(Notoriety.Enemy);
            }

            if (tpm != null && SkillHandlers.Stealing.ClassicMode && tpm.PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (tbc != null && tbc.AlwaysAttackable)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (!(tbc != null && (tbc.InitialInnocent || tbc.InnocentDefault)))   //If Target is NOT A baseCreature, OR it's a BC and the BC is initial innocent...
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(tbc) && tpm == null && !target.Player || !target.EraML && !target.CanBeginAction(typeof(Server.Spells.Seventh.PolymorphSpell)) && !target.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (tbc != null)
            {
                if (tbc.Controlled && tbc.ControlOrder == OrderType.Guard && tbc.ControlTarget == source)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (sbc != null)
            {
                Mobile smaster = sbc.GetMaster();

                if (smaster != null)
                {
                    if (CheckAggressor(smaster.Aggressors, target) || MobileNotoriety(smaster, target) == Notoriety.CanBeAttacked || tbc != null)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            return(Notoriety.Innocent);
        }
        public static int CorpseNotoriety(Mobile source, Corpse target)
        {
            if (target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            Body body = (Body)target.Amount;

            BaseCreature cretOwner = target.Owner as BaseCreature;

            if (cretOwner != null)
            {
                Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
                Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner);

                if (sourceGuild != null && targetGuild != null)
                {
                    if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                    {
                        return(Notoriety.Ally);
                    }
                    else if (sourceGuild.IsEnemy(targetGuild))
                    {
                        return(Notoriety.Enemy);
                    }
                }

                Faction srcFaction = Faction.Find(source, true, true);
                Faction trgFaction = Faction.Find(target.Owner, true, true);

                if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
                {
                    return(Notoriety.Enemy);
                }

                if (Core.OldEthics)
                {
                    Ethics.Ethic srcEthic = Ethics.Ethic.Find(source, true);
                    Ethics.Ethic trgEthic = Ethics.Ethic.Find(target.Owner, true);

                    // Hero/Evil always at war
                    if (srcEthic != null && trgEthic != null && srcEthic != trgEthic)
                    {
                        return(Notoriety.Enemy);
                    }
                }

                if (CheckHouseFlag(source, target.Owner, target.Location, target.Map))
                {
                    return(Notoriety.CanBeAttacked);
                }

                int actual = Notoriety.CanBeAttacked;

                if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead)))
                {
                    actual = Notoriety.Murderer;
                }

                if (DateTime.Now >= (target.TimeOfDeath + Corpse.MonsterLootRightSacrifice))
                {
                    return(actual);
                }

                Party sourceParty = Party.Get(source);

                ArrayList list = target.Aggressors;

                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i] == source || (sourceParty != null && Party.Get((Mobile)list[i]) == sourceParty))
                    {
                        return(actual);
                    }
                }

                return(Notoriety.Innocent);
            }
            else
            {
                if (target.Kills >= 5 || (body.IsMonster && IsSummoned(target.Owner as BaseCreature)) || (target.Owner is BaseCreature && (((BaseCreature)target.Owner).AlwaysMurderer || ((BaseCreature)target.Owner).IsAnimatedDead)))
                {
                    return(Notoriety.Murderer);
                }

                if (target.Criminal)
                {
                    return(Notoriety.Criminal);
                }

                Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
                Guild targetGuild = GetGuildFor(target.Guild as Guild, target.Owner);

                if (sourceGuild != null && targetGuild != null)
                {
                    if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                    {
                        return(Notoriety.Ally);
                    }
                    else if (sourceGuild.IsEnemy(targetGuild))
                    {
                        return(Notoriety.Enemy);
                    }
                }

                Faction srcFaction = Faction.Find(source, true, true);
                Faction trgFaction = Faction.Find(target.Owner, true, true);

                if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
                {
                    ArrayList secondList = target.Aggressors;

                    for (int i = 0; i < secondList.Count; ++i)
                    {
                        Mobile mob = secondList[i] as Mobile;

                        if (mob == null)
                        {
                            continue;
                        }

                        if (mob == source || mob is BaseFactionGuard)
                        {
                            return(Notoriety.Enemy);
                        }
                    }
                }

                if (Core.OldEthics)
                {
                    Ethics.Ethic srcEthic = Ethics.Ethic.Find(source, true, true);
                    Ethics.Ethic trgEthic = Ethics.Ethic.Find(target.Owner, true, true);

                    if (srcEthic != null && trgEthic != null && srcEthic != trgEthic)
                    {
                        return(Notoriety.Enemy);
                    }
                }

                if (target.Owner != null && target.Owner is BaseCreature && ((BaseCreature)target.Owner).AlwaysAttackable)
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckHouseFlag(source, target.Owner, target.Location, target.Map))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (!body.IsHuman && !body.IsGhost && !IsPet(target.Owner as BaseCreature))
                {
                    return(Notoriety.CanBeAttacked);
                }

                ArrayList list = target.Aggressors;

                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i] == source)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }

                return(Notoriety.Innocent);
            }
        }
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            #region Sanity
            // adam: sanity
            if (source == null || target == null)
            {
                if (source == null)
                {
                    Console.WriteLine("(source == null) in Notoriety::MobileNotoriety");
                }
                if (target == null)
                {
                    Console.WriteLine("(target == null) in Notoriety::MobileNotoriety");
                }
                //return;
            }
            #endregion

            if (Core.AOS && (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
            {
                return(Notoriety.Invulnerable);
            }

            if (target.AccessLevel > AccessLevel.Player && target.AccessLevel != AccessLevel.Ignore)
            {
                return(Notoriety.CanBeAttacked);
            }

            #region Duel

            /*
             * //Begin Challenge Duel Additions
             * if (target is PlayerMobile && source is PlayerMobile)
             * {
             *      bool tc = ((PlayerMobile)target).IsInChallenge;
             *      bool sc = (((PlayerMobile)source).IsInChallenge);
             *      if (tc && sc) //both in challenge
             *      {
             *              foreach (Item c in Challenge.Challenge.WorldStones)
             *              {
             *                      ChallengeStone cs = c as ChallengeStone;
             *                      if (cs.OpponentTeam.Contains(target) || cs.ChallengeTeam.Contains(target))
             *                      {
             *                              if (cs.OpponentTeam.Contains(source) || cs.ChallengeTeam.Contains(source))
             *                              {
             *                                      return Notoriety.CanBeAttacked;
             *                              }
             *                      }
             *              }
             *      }
             * }
             * //End Challenge Duel Additions
             */
            #endregion

            // it's a pet
            if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                Mobile master = bc.GetMaster();

                if (master != null && master.AccessLevel > AccessLevel.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (!bc.Summoned && !bc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }

                if (Core.OldEthics)
                {
                    Ethics.Ethic srcEthic = Ethics.Ethic.Find(source);
                    Ethics.Ethic trgEthic = Ethics.Ethic.Find(target, true);

                    // outside of town: evil's the target: evil's are red
                    if (trgEthic != null && trgEthic == Ethics.Ethic.Evil && !target.Region.IsGuarded && target.Map == Map.Felucca)
                    {
                        return(Notoriety.Murderer);
                    }
                    // a fallen hero will flag gray and not enemy – this is per the original docs
                    else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.FallenHero))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    // An innocent that attacks an evil (evil noto) will be attackable by all evils for two minutes
                    else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.EvilNoto))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    // Hero/Evil always at war
                    else if (srcEthic != null && trgEthic != null && srcEthic != trgEthic)
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }

            if (target.Murderer || (target.Body.IsMonster && IsSummoned(target as BaseCreature) && !(target is BaseFamiliar) && !(target is Golem)) || (target is BaseCreature && (((BaseCreature)target).AlwaysMurderer || ((BaseCreature)target).IsAnimatedDead)))
            {
                return(Notoriety.Murderer);
            }

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if ((sourceGuild != null && targetGuild != null) && (sourceGuild.Peaceful == false && targetGuild.Peaceful == false))
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }
                else if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }

            #region Fightbroker
            //If both are registered with the fightbroker, they can both attack each other
            if (FightBroker.IsAlreadyRegistered(source) && FightBroker.IsAlreadyRegistered(target) &&
                (source != target))
            {
                return(Notoriety.Enemy);
            }
            //If the source is registered on the fightbroker and the target is an interferer, make the target fair game
            if (FightBroker.IsAlreadyRegistered(source) && FightBroker.IsHealerInterferer(target) &&
                (source != target))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Now handle pets of the people registered with the fightbroker
            if (source is BaseCreature && target is BaseCreature)
            {
                BaseCreature src = (BaseCreature)source;
                BaseCreature tgt = (BaseCreature)target;
                if (src.ControlMaster != null && tgt.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(src.ControlMaster) &&
                        FightBroker.IsAlreadyRegistered(tgt.ControlMaster) &&
                        (src.ControlMaster != tgt.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            else if (source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature tgt = (BaseCreature)target;
                if (tgt.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(source) &&
                        FightBroker.IsAlreadyRegistered(tgt.ControlMaster) &&
                        (source != tgt.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            else if (source is BaseCreature && target is PlayerMobile)
            {
                BaseCreature src = (BaseCreature)source;
                if (src.ControlMaster != null)
                {
                    if (FightBroker.IsAlreadyRegistered(target) &&
                        FightBroker.IsAlreadyRegistered(src.ControlMaster) &&
                        (target != src.ControlMaster))
                    {
                        return(Notoriety.Enemy);
                    }
                }
            }
            //done with pets/fightbroker status
            #endregion

            #region Kin
            //Now handle IOB status hueing
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.IOBShardWide) ||
                (Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(source) &&
                 Server.Engines.IOBSystem.IOBRegions.IsInIOBRegion(target)))
            {
                IOBAlignment srcIOBAlignment = IOBAlignment.None;
                IOBAlignment trgIOBAlignment = IOBAlignment.None;
                if (source is BaseCreature)
                {
                    srcIOBAlignment = ((BaseCreature)source).IOBAlignment;
                }
                else if (source is PlayerMobile)
                {
                    srcIOBAlignment = ((PlayerMobile)source).IOBAlignment;
                }
                if (target is BaseCreature)
                {
                    trgIOBAlignment = ((BaseCreature)target).IOBAlignment;
                }
                else if (target is PlayerMobile)
                {
                    trgIOBAlignment = ((PlayerMobile)target).IOBAlignment;
                }

                if (srcIOBAlignment != IOBAlignment.None &&
                    trgIOBAlignment != IOBAlignment.None &&
                    srcIOBAlignment != IOBAlignment.Healer
                    )
                {
                    //If they're different alignments OR target is OutCast, then they're an enemy
                    //Pix 12/3/07: added healer target
                    //Pix: 12/4/07 - now kin-healers flag canbeattacked to kin instead of enemy
                    if (trgIOBAlignment == IOBAlignment.Healer)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    else if (srcIOBAlignment != trgIOBAlignment ||
                             trgIOBAlignment == IOBAlignment.OutCast)
                    {
                        return(Notoriety.Enemy);
                    }
                    else
                    {
                        if (source is PlayerMobile && target is BaseCreature)
                        {
                            return(Notoriety.Ally);
                        }
                        else
                        {
                            //Pix: 4/28/06 - removed Ally notoriety of same-aligned kin -
                            // this is now handled by guilds via allying
                            //return Notoriety.Ally;
                        }
                    }
                }

                //if we're looking at ourselves, and we're a KinHealer, show ourself as enemy
                if (source == target && srcIOBAlignment == IOBAlignment.Healer)
                {
                    return(Notoriety.Enemy);
                }
            }
            //done with IOB status hueing

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;
                if (bc.IOBFollower)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }
            #endregion

            Faction srcFaction = Faction.Find(source, true, true);
            Faction trgFaction = Faction.Find(target, true, true);

            if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && source.Map == Faction.Facet)
            {
                return(Notoriety.Enemy);
            }

            if (Core.OldEthics)
            {
                Ethics.Ethic srcEthic = Ethics.Ethic.Find(source);
                Ethics.Ethic trgEthic = Ethics.Ethic.Find(target);

                // outside of town: evil's the target: evil's are red
                if (trgEthic != null && trgEthic == Ethics.Ethic.Evil && !target.Region.IsGuarded && target.Map == Map.Felucca)
                {
                    return(Notoriety.Murderer);
                }
                // a fallen hero will flag gray and not enemy – this is per the original docs
                else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.FallenHero))
                {
                    return(Notoriety.CanBeAttacked);
                }
                // An innocent that attacks an evil (evil noto) will be attackable by all evils for two minutes
                else if (srcEthic == Ethics.Ethic.Evil && target.CheckState(Mobile.ExpirationFlagID.EvilNoto))
                {
                    return(Notoriety.CanBeAttacked);
                }
                // Hero/Evil always at war
                else if (srcEthic != null && trgEthic != null && srcEthic != trgEthic)
                {
                    return(Notoriety.Enemy);
                }
            }

            if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature && ((BaseCreature)target).AlwaysAttackable)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (!(target is BaseCreature && ((BaseCreature)target).InitialInnocent))
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature) && !TransformationSpellHelper.UnderTransformation(target) /*&& !AnimalForm.UnderTransformation(target) Ninja stuff*/)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

                if (bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (source is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)source;

                Mobile master = bc.GetMaster();
                if (master != null && CheckAggressor(master.Aggressors, target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            return(Notoriety.Innocent);
        }
Exemple #5
0
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            if (/*Core.AOS &&*/ (target.Blessed || (target is BaseVendor && ((BaseVendor)target).IsInvulnerable) || target is PlayerVendor || target is TownCrier))
            {
                return(Notoriety.Invulnerable);
            }

            if (target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            BaseCreature tbc = target as BaseCreature;
            BaseCreature sbc = source as BaseCreature;

            if (source.Player && !target.Player && source is PlayerMobile && tbc != null)
            {
                Mobile master = tbc.GetMaster();

                if (master != null && master.AccessLevel > AccessLevel.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (/*Core.ML &&*/ master != null)
                {
                    if ((source == master && CheckAggressor(target.Aggressors, source)) || (CheckAggressor(source.Aggressors, tbc)))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                    else
                    {
                        return(MobileNotoriety(source, master));
                    }
                }

                if (!tbc.Summoned && !tbc.Controlled && ((PlayerMobile)source).EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }
            }

            if (target.Kills >= Mobile.MurderCount || (target.Body.IsMonster && IsSummoned(tbc) && !(target is BaseFamiliar) && !(target is ArcaneFey) && !(target is Golem)) || (tbc != null && (tbc.AlwaysMurderer || tbc.IsAnimatedDead)))
            {
                return(Notoriety.Murderer);
            }

            if (target.Criminal)
            {
                return(Notoriety.Criminal);
            }

            Guild sourceGuild = GetGuildFor(source.Guild as Guild, source);
            Guild targetGuild = GetGuildFor(target.Guild as Guild, target);

            if (sourceGuild != null && targetGuild != null)
            {
                if (sourceGuild == targetGuild || sourceGuild.IsAlly(targetGuild))
                {
                    return(Notoriety.Ally);
                }
                else if (sourceGuild.IsEnemy(targetGuild))
                {
                    return(Notoriety.Enemy);
                }
            }

            Ethics.Ethic sourceEthic = Ethics.Ethic.Find(source);
            Ethics.Ethic targetEthic = Ethics.Ethic.Find(target);

            if (sourceEthic != null)
            {
                if (targetEthic != null)
                {
                    if (targetEthic != sourceEthic)
                    {
                        return(Notoriety.Enemy);
                    }
                }
                else if (sourceEthic.IsAggressed(target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            Faction srcFaction = Faction.Find(source, true, true);
            Faction trgFaction = Faction.Find(target, true, true);

            if (srcFaction != null && trgFaction != null && srcFaction != trgFaction && Faction.IsFactionFacet(source.Map))
            {
                return(Notoriety.Enemy);
            }

            if (SkillHandlers.Stealing.ClassicMode && target is PlayerMobile && ((PlayerMobile)target).PermaFlags.Contains(source))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (tbc != null && (tbc.AlwaysAttackable || (tbc.Controlled && tbc.ControlOrder == OrderType.Guard && tbc.ControlTarget == source)))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckHouseFlag(source, target, target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (!(tbc != null && tbc.InitialInnocent))
            {
                if ((!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(tbc) && !(target is PlayerMobile)) || (!Core.ML && !target.CanBeginAction(typeof(Server.Spells.Seventh.PolymorphSpell))))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

            if (CheckAggressed(source.Aggressed, target))
            {
                return(Notoriety.CanBeAttacked);
            }

/*
 *                      if( target is BaseCreature )
 *                      {
 *                              BaseCreature bc = (BaseCreature)target;
 *
 *                              if( bc.Controlled && bc.ControlOrder == OrderType.Guard && bc.ControlTarget == source )
 *                                      return Notoriety.CanBeAttacked;
 *                      }
 */

            if (sbc != null)
            {
                Mobile master = sbc.GetMaster();
                if (master != null && (CheckAggressor(master.Aggressors, target) || MobileNotoriety(master, target) == Notoriety.CanBeAttacked || tbc != null))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            return(Notoriety.Innocent);
        }