Esempio n. 1
0
        public override bool DoActionWander()
        {
            // try breeding?
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.BreedingEnabled))
            {
                if (!m_Mobile.Female &&                                                                     // males do the finding
                    (double)m_Mobile.Hits / m_Mobile.HitsMax > MateHealthThreshold &&                       // must be minimum health
                    m_BecameIdle + MateIdleDelay < DateTime.Now &&                                          // wait after starting to wander
                    m_LastMate + MaleMateDelay < DateTime.Now &&                                            // wait after last mating - we gotta recoup!
                    m_NextMateAttempt < DateTime.Now)                                                       // gotta give it a while between looking
                {
                    FindMate();
                    m_NextMateAttempt += TimeSpan.FromSeconds(Utility.RandomMinMax(MinMateAttemptDelay, MaxMateAttemptDelay));

                    if (m_MateTarget != null && Utility.RandomDouble() < MateAttemptChance)
                    {
                        m_Mobile.DebugSay("Found a mate I like! Trying to mate...");

                        BreedingState = BreedState.Approaching;
                        Action        = ActionType.Interact;
                        m_Mobile.PlaySound(Utility.RandomList(111, 113, 114, 115));
                    }

                    return(true);
                }
            }

            return(base.DoActionWander());
        }
Esempio n. 2
0
        private static void OnHandshakeTimeout(object state)
        {
            Timer  t = null;
            Mobile m = state as Mobile;

            if (m == null)
            {
                return;
            }

            m_Table.Remove(m);

            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RazorNegotiateWarnAndKick))
            {
                if (!RazorFeatureControl.KickOnFailure)
                {
#pragma warning disable 0162
                    Console.WriteLine("Player '{0}' failed to negotiate Razor features.", m);
#pragma warning restore 0162
                }
                else if (m.NetState != null && m.NetState.Running)
                {
                    m.SendGump(new Gumps.WarningGump(1060635, 30720, RazorFeatureControl.WarningMessage, 0xFFC000, 420, 250, null, null));

                    if (m.AccessLevel <= AccessLevel.Player)
                    {
                        m_Table[m] = t = Timer.DelayCall(RazorFeatureControl.DisconnectDelay, OnForceDisconnect_Callback, m);
                        t.Start();
                    }
                }
            }
        }
Esempio n. 3
0
        public BaseRTTGump(Mobile from, string strNotice, string strSkill, int x, int y)
            : base(x, y)
        {
            m_Mobile    = from;
            m_strNotify = strNotice;
            m_strSkill  = strSkill;

            //close any other RTT gumps
            from.CloseGump(typeof(BaseRTTGump));

            // notify staff
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RTTNotifyEnabled))
            {
                Server.Scripts.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Administrator,
                                                                         0x482,
                                                                         String.Format("{0}({1}) is taking the RTT ({2}).", m_Mobile.Name, m_Mobile.Serial, strSkill));
            }

            // record the fact that the RTT test is being taken
            Scripts.Commands.LogHelper lh = new Server.Scripts.Commands.LogHelper("RTT.log", false, true);
            lh.Log(Scripts.Commands.LogType.Mobile, m_Mobile, String.Format("({0}) RTT Launched.", strSkill));
            lh.Finish();

            //This will call any child-gump's SetupGump and set it up like the child wants.
            SetupGump();

            //Save when we launched the gump for later recording
            m_RTTLaunched = DateTime.Now;

            // if the player fails to respond in 'timeout' time, then we will cound this as an RTT failure.
            //	this does two things: (1) makes the next test 5 minutes from now, (2) will move them closer to being counted as a macroer
            m_timeout = new RTTTimer(m_Mobile, TimeSpan.FromSeconds(Utility.RandomList(90, 120, 180)));
            m_timeout.Start();
        }
Esempio n. 4
0
        private static void EventSink_Login(LoginEventArgs e)
        {
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RazorNegotiateFeaturesEnabled))
            {
                Mobile m = e.Mobile;
                if (m != null && m.NetState != null && m.NetState.Running)
                {
                    Timer t;

                    m.Send(new BeginRazorHandshake());

                    if (m_Table.ContainsKey(m))
                    {
                        t = m_Table[m] as Timer;
                        if (t != null && t.Running)
                        {
                            t.Stop();
                        }
                    }

                    m_Table[m] = t = Timer.DelayCall(RazorFeatureControl.HandshakeTimeout, OnHandshakeTimeout_Callback, m);
                    t.Start();
                }
            }
        }
 public static void UsageReport(Mobile m, string text)
 {
     // Tell staff that an a player is using this system
     if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.SpiritSpeakUsageReport))
     {
         Server.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Administrator,
                                                          0x482,
                                                          String.Format("At location: {0}, {1} ", m.Location, text));
     }
 }
Esempio n. 6
0
    void Start()
    {
        bm               = BuildingManager.instance;
        wanderAI         = Resources.Load("PluggableAI/Wander") as WanderingAI;
        playerAI         = Resources.Load("PluggableAI/Player") as PlayerAI;
        goToClassAI      = Resources.Load("PluggableAI/GoingToClass") as GoingToClassAI;
        periodEndedEvent = Resources.Load("GameEvents/PeriodEnded") as GameEvent;
        dayHasEndedEvent = Resources.Load("GameEvents/dayHasEnded") as GameEvent;

        //ScriptableObjects don't reset
        currDay.currentPeriod = 0;
    }
            public static void AutoSetHomes(ushort buildingID, ref Building data, CoreAI core)
            {
                short[] config;

                ItemClass @class = core.m_info.m_class;
                int subservice = (int)@class.m_subService;
                if (VanillaData.LevelAutogenResidents.TryGetValue(subservice, out config))
                {
                    int level = (int)@class.m_level;
                    if (config.GetLength(0) >= level)
                    {
                        Randomizer r = new Randomizer((int)buildingID);
                        core.occupants.maxHomeCount = (short)(Mathf.Max(100, data.Width * data.Length * config[level] + r.Int32(100u)) / 100);
                        core.occupantsUpdated = true;
                    }
                }
            }
Esempio n. 8
0
            public static void AutoSetHomes(ushort buildingID, ref Building data, CoreAI core)
            {
                short[] config;

                ItemClass @class     = core.m_info.m_class;
                int       subservice = (int)@class.m_subService;

                if (VanillaData.LevelAutogenResidents.TryGetValue(subservice, out config))
                {
                    int level = (int)@class.m_level;
                    if (config.GetLength(0) >= level)
                    {
                        Randomizer r = new Randomizer((int)buildingID);
                        core.occupants.maxHomeCount = (short)(Mathf.Max(100, data.Width * data.Length * config[level] + r.Int32(100u)) / 100);
                        core.occupantsUpdated       = true;
                    }
                }
            }
Esempio n. 9
0
        public override void OnDoubleClick(Mobile from)
        {
            if (IsChildOf(from.Backpack))
            {
                if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.TowerAllowed) == false)
                {
                    from.SendMessage("Tower placement temporarily disabled");
                    return;
                }
                else
                {
                    // not necessarily an exploit, but lets track it
                    LogHelper.TrackIt(from, "Note: Tower placement attempt.", true);
                }
            }

            base.OnDoubleClick(from);
        }
 public static void AutoSetVisitors(ushort buildingID, ref Building data, CoreAI core)
 {
     short[] config;
     ItemClass @class = core.m_info.m_class;
     int subservice = (int)@class.m_subService;
     if (VanillaData.LevelAutogenVisitplace.TryGetValue(subservice, out config))
     {
         int level = (int)@class.m_level;
         if (config.GetLength(0) >= level)
         {
             var visitplaces = config[level];
             if (visitplaces > 0)
             {
                 core.occupants.maxVisitors = config[level];
                 core.occupantsUpdated = true;
             }
         }
     }
 }
Esempio n. 11
0
            public static void AutoSetVisitors(ushort buildingID, ref Building data, CoreAI core)
            {
                short[]   config;
                ItemClass @class     = core.m_info.m_class;
                int       subservice = (int)@class.m_subService;

                if (VanillaData.LevelAutogenVisitplace.TryGetValue(subservice, out config))
                {
                    int level = (int)@class.m_level;
                    if (config.GetLength(0) >= level)
                    {
                        var visitplaces = config[level];
                        if (visitplaces > 0)
                        {
                            core.occupants.maxVisitors = config[level];
                            core.occupantsUpdated      = true;
                        }
                    }
                }
            }
Esempio n. 12
0
    public IEnumerator SpawnStudent(CoreAI ai)
    {
        isInSpawningCoroutine = true;

        //Instantiate student prefab
        Vector3 randSpawn = spawnLocations.list[Random.Range(0, spawnLocations.list.Count)].position;
        Vector3 homeSpawn = spawnLocations.list[Random.Range(0, spawnLocations.list.Count)].position;

        GameObject _student = Instantiate(student, transform);

        _student.GetComponent <NavMeshAgent>().Warp(randSpawn);
        _student.GetComponent <StudentAIController>().homePosition = homeSpawn;
        _student.GetComponent <StudentAIController>().ai           = ai;

        _student.GetComponent <StudentAIController>().enabled = true;

        yield return(new WaitForSeconds(spawnDelayInSeconds));

        isInSpawningCoroutine = false;
    }
Esempio n. 13
0
        protected override void OnTick()
        {
            try
            {
                // sanity
                if (m_Mobile == null || m_Mobile.Deleted == true || m_Mobile.NetState == null || Running == false)
                {
                    Stop();
                    return;
                }

                // Let new players join the NEW guild
                if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.NewPlayerGuild) && m_State == 0)
                {
                    NewPlayerGuild(m_Mobile);
                }

                // print welcome messages
                if (m_State < m_Count)
                {
                    m_Mobile.SendMessage(0x35, m_Messages[m_State]);
                }

                // stop the timer
                if (m_State == m_Count)
                {
                    Stop();
                }
            }
            catch (Exception ex)
            {
                LogHelper.LogException(ex);
            }
            finally
            {                   // make sure we keep marching forward no matter what
                m_State++;
            }
        }
Esempio n. 14
0
    public void SpawnPlayer(CoreAI ai)
    {
        Vector3 playerSpawnPosition = new Vector3(playerData.playerPointer.transform.position.x, 0.1f, playerData.playerPointer.transform.position.z);

        //Instantiate gameobject
        GameObject player = Instantiate(student, playerSpawnPosition, Quaternion.identity);

        //Setup line renderer reference
        DrawSchedulePath pathDrawer = transform.parent.GetComponentInChildren <DrawSchedulePath>();

        pathDrawer.isPlayerActive = true;
        //Set scriptable object play data
        playerData.playerPointer.transform.SetParent(player.transform);
        playerData.playerAgent = player.GetComponent <NavMeshAgent>();
        //Initalize AI component of prefab
        StudentAIController playerAIControl = player.GetComponent <StudentAIController>();

        playerAIControl.ai           = ai;
        playerAIControl.homePosition = spawnLocations.list[Random.Range(0, spawnLocations.list.Count)].position;
        //Position and enable player
        player.GetComponent <NavMeshAgent>().Warp(playerSpawnPosition);
        playerAIControl.enabled = true;
    }
Esempio n. 15
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            if (!m_From.CheckAlive())
            {
                return;
            }

            int index = info.ButtonID - 1;

            if (index >= 0 && index < m_Entries.Length)
            {
                if (m_From.AccessLevel < AccessLevel.Player && BaseHouse.HasAccountHouse(m_From))
                {
                    m_From.SendLocalizedMessage(501271);                       // You already own a house, you may not place another!
                }
                else
                {
                    if (m_Entries[index].Type == typeof(Tower) && CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.TowerAllowed) == false)
                    {
                        m_From.SendMessage("Tower preview temporarily disabled");
                    }
                    else
                    {                           // not necessarily an exploit, but lets track it
                        if (m_Entries[index].Type == typeof(Tower))
                        {
                            LogHelper.TrackIt(m_From, "Note: Tower preview.", true);
                        }
                        m_From.Target = new NewSurveyToolTarget(m_Entries, m_Entries[index]);
                    }
                }
            }
            //else
            //{
            //m_From.SendGump( new SurveyToolCategoryGump( m_From ) );
            //}
        }
Esempio n. 16
0
 private bool CanChangeKin()
 {
     return(!CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.GuildKinChangeDisabled));
 }
Esempio n. 17
0
        public override void OnResponse(NetState state, RelayInfo info)
        {
            try
            {
                Mobile from = state.Mobile;

                PageType type = (PageType)(-1);

                switch (info.ButtonID)
                {
                case 0:                                          // Close/Cancel
                {
                    from.SendLocalizedMessage(501235, "", 0x35); // Help request aborted.

                    break;
                }

                case 1:                         // General question
                {
                    type = PageType.Question;
                    break;
                }

                case 2:                         // Stuck
                {
                    if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.HelpStuckDisabled))
                    {
                        from.SendMessage("Sorry, help stuck is unavailable at this time. Please page for GM assistance");
                        return;
                    }

                    if (StuckMenu.ValidUseLocation(from, from))
                    {
                        //if (!TryMoveStuckPlayer(from, 4))
                        //{
                        //	int staffonline = 0;
                        //	foreach (NetState ns in NetState.Instances)
                        //	{
                        //		Mobile m = ns.Mobile;
                        //		if (m != null && m.AccessLevel >= AccessLevel.Counselor && m.AutoPageNotify)
                        //			staffonline++;
                        //	}
                        //
                        //	if (staffonline == 0)
                        //	{
                        //		StuckMenu menu = new StuckMenu( from, from, true );
                        //
                        //		menu.BeginClose();
                        //
                        //		from.SendGump( menu );
                        //	}
                        //	else
                        //	{
                        //		type = PageType.Stuck;
                        //	}
                        //}


                        from.SendMenu(new HelpStuckQuestion(from));
                    }
                    else
                    {
                        type = PageType.Stuck;
                    }

                    break;
                }

                case 3:                         // Report bug or contact Origin
                {
                    type = PageType.Bug;
                    break;
                }

                case 4:                         // Game suggestion
                {
                    type = PageType.Suggestion;
                    break;
                }

                case 5:                         // Account management
                {
                    type = PageType.Account;
                    break;
                }

                case 6:                         // Other
                {
                    type = PageType.Other;
                    break;
                }

                case 7:                         // Harassment: verbal/exploit
                {
                    type = PageType.Harassment;
                    break;
                }

                case 8:                         // Harassment: physical
                {
                    type = PageType.PhysicalHarassment;
                    break;
                }

                case 9:                         // Young player transport
                {
                    /*
                     * if ( IsYoung( from ) )
                     * {
                     *      if ( from.Region is Regions.Jail )
                     *      {
                     *              from.SendLocalizedMessage( 1041530, "", 0x35 ); // You'll need a better jailbreak plan then that!
                     *      }
                     *      else if ( from.Region.Name == "Haven" )
                     *      {
                     *              from.SendLocalizedMessage( 1041529 ); // You're already in Haven
                     *      }
                     *      else
                     *      {
                     *              from.MoveToWorld( new Point3D( 3618, 2587, 0 ), Map.Trammel );
                     *      }
                     * }
                     */

                    break;
                }
                }

                if (type != (PageType)(-1) && PageQueue.CheckAllowedToPage(from))
                {
                    from.SendGump(new PagePromptGump(from, type));
                }
            }
            catch (Exception exc)
            {
                LogHelper.LogException(exc);
                System.Console.WriteLine("Exception caught in HelpGump.OnResponse: " + exc.Message);
                System.Console.WriteLine(exc.StackTrace.ToString());
            }
        }
            public static void SetCitizenCounts(ushort buildingID, ref Building data, CoreAI core)
            {
                foreach(var behavior in core.behaviorConfig.behaviors)
                {

                }
                int subservice;
                if (core.behaviorConfig.hasBehavior(VanillaData.vanillaServiceMapping[ItemClass.Service.Office])) subservice = VanillaData.OfficeSubservice;
                else subservice = (int)@class.m_subService;
            }
Esempio n. 19
0
        public static int MobileNotoriety(Mobile source, Mobile target)
        {
            // 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;
            }

            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);
            }

            /*
             * //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
             */


            if (source.Player && !target.Player && source is PlayerMobile && target is BaseCreature)
            {
                BaseCreature bc = (BaseCreature)target;

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

            if (target.Kills >= 5 || (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);
                }
            }

            //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

            //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 (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 && ((BaseCreature)target).Controlled == false))
            {
                if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(target as BaseCreature))
                {
                    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)                  // here we're dealing with 2 BC
                {
                    BaseCreature sbc = (BaseCreature)source;
                    if (sbc.Controlled && bc.Controlled && sbc.ControlMaster == bc.ControlMaster)
                    {
                        //return Notoriety.CanBeAttacked;
                        return(Notoriety.Ally);
                    }
                }
            }

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

/*
 * Adam didn't want this way.
 *                      //Last check -- see if the target's region is a NoCount zone...
 *                      // if so, notoriety should be CanBeAttacked
 *                      CustomRegion targetRegion = target.Region as CustomRegion;
 *                      if( targetRegion != null )
 *                      {
 *                              RegionControl rc = targetRegion.GetRegionControler();
 *                              if( rc != null && rc.NoMurderZone )
 *                              {
 *                                      return Notoriety.CanBeAttacked;
 *                              }
 *                      }
 */
            return(Notoriety.Innocent);
        }
Esempio n. 20
0
        public static void EventSink_GameLogin(GameLoginEventArgs e)
        {
            if (!IPLimiter.SocketBlock && !IPLimiter.Verify(e.State.Address))
            {
                e.Accepted = false;

                Console.WriteLine("Login: {0}: Past IP limit threshold", e.State);

                using (StreamWriter op = new StreamWriter("ipLimits.log", true))
                    op.WriteLine("{0}\tPast IP limit threshold\t{1}", e.State, DateTime.Now);

                // tell other accounts on this IP what's going on
                IPLimiter.Notify(e.State.Address);
                return;
            }

            // before a new logon to this shard, make sure to read in all queued password changes from all shards
            Account.ReadAllPasswords();

            string un = e.Username;
            string pw = e.Password;

            Account acct = Accounts.GetAccount(un);


            //PIX: Note - this won't work where the login server lives (in our case, AI), but it will work for
            // servers not the login server.  That's because the IPs get logged on those after this check.
            // On login servers, we'd have to move this code before the account access was logged.
            // Note also that we only check the last IP logged in from.  So if Person A has account a1 and
            // Person B has account b1, they can both play from IP address I1.  However, both won't be able
            // to access any other accounts.  If Person B then logs in from IP I2, another account can then
            // be accessed from IP I1, but then account b1 won't be able to log in from IP I1.
            // The idea of this is that we only ever let two accounts at a time log in from a single IP
            // address.  If one (or more) accounts move to a different IP, then another account can login
            // from the old IP.  This effectively stops any more than 2 accounts having a single IP as their
            // last accessed.
            #region IPBinderEnabled
            if (!Core.LoginServer && CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.IPBinderEnabled))                    //Adam: disable via IPBinderEnabled for now until we can better understand the logon problems people are having
            {
                AccessLevel    aal      = AccessLevel.Player;
                List <Account> acctList = new List <Account>();
                int            countIP  = CountOfLastIPsEqualing(e.State.Address, out aal, out acctList);
                bool           boot     = false;

                if (acct != null &&
                    acctList.Contains(acct)
                    )
                {
                    //if we've got a valid account and the account's last ip is the current ip, allow login
                }
                else
                {
                    //Here then we're in the case where it's either a new account
                    // or the accout has a different last-game-login-ip, so make sure that
                    // that IP doesn't already have 2+ accounts
                    if (countIP >= 2 && aal <= AccessLevel.Player)
                    {
                        boot = true;                         //allow only 2 for Players
                    }
                    else if (countIP >= 3 && aal < AccessLevel.Administrator)
                    {
                        boot = true;                         //allow 3 for staff
                    }
                    else if (countIP >= 3)
                    {
                        //allow unlimited for Admins or greater
                        Console.WriteLine("Allowing unlimited IP access for {0} from {1}", e.Username, e.State);
                    }
                }

                if (boot)
                {
                    e.Accepted = false;

                    string strAccts = "";
                    foreach (Account a1 in acctList)
                    {
                        strAccts += ("[" + a1.Username + "]");
                    }

                    Console.WriteLine("Login: {0}({1}): Past OFFLINE IP limit threshold.  Accts: {2} ", e.Username, e.State, strAccts);
                    using (StreamWriter sw1 = new StreamWriter("offlineIPLimits.log", true))
                    {
                        sw1.WriteLine("{0}:{1}\tPast OFFLINE IP limit threshold\t{2}\tAccounts:{3}", e.Username, e.State, DateTime.Now, strAccts);

                        for (int i = 0; i < NetState.Instances.Count; ++i)
                        {
                            NetState compState = NetState.Instances[i];
                            if (e.State.Address.Equals(compState.Address) && compState.Mobile != null)
                            {
                                compState.Mobile.SendMessage(0x35, "You have exceeded the number of accounts authorized to connect from this address.");
                            }
                        }
                    }

                    return;
                }
            }
            #endregion

            //if we have a valid account on a non-primary shard, create it (assuming AutoAccountCreation is on)
            if (acct == null && !Core.LoginServer)
            {
                // there are NO STAFF accounts with this username and either you have NO accounts, or you have a matching account name and password for another shard.
                if (AutoAccountCreation && !Account.CheckAllStaff(null, un, false) && (!Account.CheckAllAccounts(un) || (Account.CheckAllAccounts(un) && Account.CheckAllPasswords(un, pw))))
                {
                    acct = CreateAccount(e.State, un, pw);
                }
                else
                {
                    if (Account.CheckAllStaff(null, un, false))
                    {
                        Console.WriteLine("Login: {0}: Invalid password for staff account '{1}'", e.State, un);
                    }
                    else if (Account.CheckAllAccounts(un))
                    {
                        Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                    }
                    else
                    {
                        Console.WriteLine("Login: {0}: Invalid username '{1}'", e.State, un);
                    }
                }
            }

            if (acct == null)
            {
                e.Accepted = false;
            }
            else if (IPLimiter.IPStillHot(acct, e.State.Address))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'. IP too hot", e.State, un);
                e.Accepted = false;
            }
            else if (!acct.HasAccess(e.State))
            {
                Console.WriteLine("Login: {0}: Access denied for '{1}'", e.State, un);
                e.Accepted = false;
            }
            // You succeed login when your password matches some shard and no shards have a user with the same name with greater access
            else if (!(Account.CheckAllPasswords(un, pw) && !Account.CheckAllStaff(acct, un, true)))
            {
                if (Account.CheckAllStaff(acct, un, true))
                {
                    Console.WriteLine("Login: {0}: Invalid password or access level for staff account '{1}'", e.State, un);
                }
                else
                {
                    Console.WriteLine("Login: {0}: Invalid password for '{1}'", e.State, un);
                }
                e.Accepted = false;
            }
            else if (acct.Banned)
            {
                Console.WriteLine("Login: {0}: Banned account '{1}'", e.State, un);
                e.Accepted = false;
            }
            else
            {
                acct.LogAccess(e.State);
                acct.LogGAMELogin(e.State);

                Console.WriteLine("Login: {0}: Account '{1}' at character list", e.State, un);
                e.State.Account = acct;
                e.Accepted      = true;
                e.CityInfo      = StartingCities;
            }

            if (!e.Accepted)
            {
                AccountAttackLimiter.RegisterInvalidAccess(e.State);
            }
        }
Esempio n. 21
0
            public static void SetCitizenCounts(ushort buildingID, ref Building data, CoreAI core)
            {
                foreach (var behavior in core.behaviorConfig.behaviors)
                {
                }
                int subservice;

                if (core.behaviorConfig.hasBehavior(VanillaData.vanillaServiceMapping[ItemClass.Service.Office]))
                {
                    subservice = VanillaData.OfficeSubservice;
                }
                else
                {
                    subservice = (int)@class.m_subService;
                }
            }
Esempio n. 22
0
        public override void OnResponse(Server.Network.NetState sender, RelayInfo info)
        {
            try
            {
                // kill our timeout timer
                if (m_timeout != null)
                {
                    m_timeout.Stop();
                    m_timeout = null;
                }

                int      button = info.ButtonID;
                TimeSpan diff   = DateTime.Now - m_RTTLaunched;

                if (button == m_CorrectResponse + m_CorrectResponseOffset)
                {
                    // record answer
                    Scripts.Commands.LogHelper lh = new Server.Scripts.Commands.LogHelper("RTT.log", false, true);
                    lh.Log(Scripts.Commands.LogType.Mobile, m_Mobile, string.Format("PASSED the RTT in {0} ms", diff.TotalMilliseconds));
                    lh.Finish();

                    m_Mobile.SendMessage("Thanks for verifying that you're at your computer.");
                    ((PlayerMobile)m_Mobile).RTTResult(true);

                    if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RTTNotifyEnabled))
                    {
                        if (diff <= TimeSpan.FromSeconds(1.0))
                        {
                            Server.Scripts.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor,
                                                                                     0x22,
                                                                                     String.Format("{0}({1}) has quickly passed the RTT ({2} ms) ({3}).", m_Mobile.Name, m_Mobile.Serial, diff.TotalMilliseconds, m_strNotify));
                        }
                        else
                        {
                            Server.Scripts.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor,
                                                                                     0x482,
                                                                                     String.Format("{0}({1}) has passed the RTT ({2} ms).  ({3})", m_Mobile.Name, m_Mobile.Serial, diff.TotalMilliseconds, m_strNotify));
                        }

                        // Look for and record suspiciously fast answers
                        if (diff <= TimeSpan.FromSeconds(3.0))
                        {
                            Scripts.Commands.LogHelper lh2 = new Server.Scripts.Commands.LogHelper("RTTAlert.log", false, true);
                            lh2.Log(Scripts.Commands.LogType.Mobile, m_Mobile, string.Format("{0} ms", diff.TotalMilliseconds));
                            lh2.Finish();
                        }
                    }
                }
                else
                {
                    // record answer
                    Scripts.Commands.LogHelper lh = new Server.Scripts.Commands.LogHelper("RTT.log", false, true);
                    lh.Log(Scripts.Commands.LogType.Mobile, m_Mobile, string.Format("FAILED the RTT in {0} ms", diff.TotalMilliseconds));
                    lh.Finish();

                    m_Mobile.SendMessage("You have failed the AFK test.");
                    ((PlayerMobile)m_Mobile).RTTResult(false);

                    if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.RTTNotifyEnabled))
                    {
                        Server.Scripts.Commands.CommandHandlers.BroadcastMessage(AccessLevel.Counselor,
                                                                                 0x482,
                                                                                 String.Format("{0}({1}) has failed the RTT. ({2})", m_Mobile.Name, m_Mobile.Serial, this.m_strNotify));
                    }
                }
            }
            catch (Exception e)
            {
                Scripts.Commands.LogHelper.LogException(e);
            }
        }
Esempio n. 23
0
        private static void EventSink_CharacterCreated(CharacterCreatedEventArgs args)
        {
            Mobile newChar = CreateMobile(args.Account as Account);

            if (newChar == null)
            {
                Console.WriteLine("Login: {0}: Character creation failed, account full", args.State);
                return;
            }

            args.Mobile = newChar;
            m_Mobile    = newChar;

            newChar.Player      = true;
            newChar.AccessLevel = ((Account)args.Account).AccessLevel;
            newChar.Female      = args.Female;
            newChar.Body        = newChar.Female ? 0x191 : 0x190;
            newChar.Hue         = Utility.ClipSkinHue(args.Hue & 0x3FFF) | 0x8000;
            newChar.Hunger      = 20;

            if (newChar is PlayerMobile)
            {
                ((PlayerMobile)newChar).Profession = args.Profession;
            }

            //Pix: default to warrior if chosen is paladin, necro, etc.
            if (((PlayerMobile)newChar).Profession > 3)
            {
                ((PlayerMobile)newChar).Profession = 1;
            }

            SetName(newChar, args.Name);

            AddBackpack(newChar);

            SetStats(newChar, args.Str, args.Dex, args.Int);
            SetSkills(newChar, args.Skills, args.Profession);

            AddHair(newChar, args.HairID, Utility.ClipHairHue(args.HairHue & 0x3FFF));
            AddBeard(newChar, args.BeardID, Utility.ClipHairHue(args.BeardHue & 0x3FFF));

            if (!Core.AOS || (args.Profession != 4 && args.Profession != 5))
            {
                AddShirt(newChar, args.ShirtHue);
                AddPants(newChar, args.PantsHue);
                AddShoes(newChar);
            }

            if (TestCenter.Enabled)
            {
                FillBankbox(newChar);
            }

            /*
             * Our numbers have been so low lately (< 50), it's once again important
             * to concentrate playerss so that they do not log into what seems to be an empty shard.
             * We can stem the griefing by:
             * 1. Changing the look of starting players (remove noob look)
             * 2. Have a wider entry area
             * 3. Have them 'Recall in' so they look like they've been here for a while
             * 4. Give them a 1 minute 'young' status?
             */

            //Comment out the following line to let the player choose where to start.
            CityInfo city; // = args.City;
            Map      spawnMap = Map.Felucca;

            //Comment out the following line to have them always start at Brit Inn
            //CityInfo city = new CityInfo( "Britain", "Sweet Dreams Inn", 1496, 1628, 10 );

            // this NewPlayerStartingArea probably needs to be based on IP address and account age etc.
            if (CoreAI.IsDynamicFeatureSet(CoreAI.FeatureBits.NewPlayerStartingArea))
            {
                city     = new CityInfo("New Player Starting Area", "Starting Area", 5731, 953, 0);
                spawnMap = Map.Trammel;
            }
            else
            {
                //if( city.City == "Britain" )
                {
                    Point3D p = NewCharacterSpawnLocation();
                    city = new CityInfo("Britain", "West Brit Bank", p.X, p.Y, p.Z);
                }
            }

            newChar.MoveToWorld(city.Location, spawnMap);

            Console.WriteLine("Login: {0}: New character being created (account={1})", args.State, ((Account)args.Account).Username);
            Console.WriteLine(" - Character: {0} (serial={1})", newChar.Name, newChar.Serial);
            Console.WriteLine(" - Started: {0} {1}", city.City, city.Location);

            new WelcomeTimer(newChar).Start();
        }
Esempio n. 24
0
        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);
        }