Beispiel #1
0
        public static int DetermineMobileNotoriety(Mobile source, Mobile target, bool useVengeance)
        {
            BaseCreature bc_Source = source as BaseCreature;
            PlayerMobile pm_Source = source as PlayerMobile;

            Mobile       m_SourceController  = null;
            BaseCreature bc_SourceController = null;
            PlayerMobile pm_SourceController = null;

            BaseCreature bc_Target = target as BaseCreature;
            PlayerMobile pm_Target = target as PlayerMobile;

            Mobile       m_TargetController  = null;
            BaseCreature bc_TargetController = null;
            PlayerMobile pm_TargetController = null;

            if (bc_Source != null)
            {
                m_SourceController  = bc_Source.ControlMaster as Mobile;
                bc_SourceController = bc_Source.ControlMaster as BaseCreature;
                pm_SourceController = bc_Source.ControlMaster as PlayerMobile;
            }

            if (bc_Target != null)
            {
                m_TargetController  = bc_Target.ControlMaster as Mobile;
                bc_TargetController = bc_Target.ControlMaster as BaseCreature;
                pm_TargetController = bc_Target.ControlMaster as PlayerMobile;
            }

            ArenaController fromArenaController   = ArenaController.GetArenaAtLocation(source.Location, source.Map);
            ArenaController targetArenaController = ArenaController.GetArenaAtLocation(target.Location, target.Map);

            if (fromArenaController != null && targetArenaController != null && fromArenaController == targetArenaController)
            {
                if (fromArenaController.m_ArenaFight != null)
                {
                    if (fromArenaController.m_ArenaFight.m_FightPhase == ArenaFight.FightPhaseType.Fight)
                    {
                        if (fromArenaController.m_ArenaFight.m_ArenaMatch != null)
                        {
                            ArenaMatch arenaMatch = fromArenaController.m_ArenaFight.m_ArenaMatch;

                            if (ArenaMatch.IsValidArenaMatch(arenaMatch, null, false))
                            {
                                PlayerMobile rootPlayerFrom   = null;
                                PlayerMobile rootPlayerTarget = null;

                                if (pm_Source != null)
                                {
                                    rootPlayerFrom = pm_Source;
                                }

                                if (pm_Target != null)
                                {
                                    rootPlayerTarget = pm_Target;
                                }

                                if (pm_SourceController != null)
                                {
                                    rootPlayerFrom = pm_SourceController;
                                }

                                if (pm_TargetController != null)
                                {
                                    rootPlayerTarget = pm_TargetController;
                                }

                                ArenaParticipant fromArenaParticipant   = fromArenaController.m_ArenaFight.m_ArenaMatch.GetParticipant(rootPlayerFrom);
                                ArenaParticipant targetArenaParticipant = fromArenaController.m_ArenaFight.m_ArenaMatch.GetParticipant(rootPlayerTarget);

                                if (fromArenaParticipant != null && targetArenaParticipant != null)
                                {
                                    if (fromArenaParticipant.m_FightStatus == ArenaParticipant.FightStatusType.Alive && targetArenaParticipant.m_FightStatus == ArenaParticipant.FightStatusType.Alive)
                                    {
                                        ArenaTeam fromTeam   = null;
                                        ArenaTeam targetTeam = null;

                                        foreach (ArenaTeam team in arenaMatch.m_Teams)
                                        {
                                            if (team == null)
                                            {
                                                continue;
                                            }
                                            if (team.Deleted)
                                            {
                                                continue;
                                            }

                                            ArenaParticipant participant = team.GetPlayerParticipant(rootPlayerFrom);

                                            if (participant != null)
                                            {
                                                fromTeam = team;
                                            }

                                            participant = team.GetPlayerParticipant(rootPlayerTarget);

                                            if (participant != null)
                                            {
                                                targetTeam = team;
                                            }
                                        }

                                        if (fromTeam != null && targetTeam != null)
                                        {
                                            if (fromTeam == targetTeam)
                                            {
                                                return(Notoriety.Ally);
                                            }

                                            if (fromTeam != targetTeam)
                                            {
                                                return(Notoriety.Enemy);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            //Berserk Creatures
            if (bc_Source != null && (source is BladeSpirits || source is EnergyVortex))
            {
                if (bc_Source.ControlMaster != null && pm_Target != null)
                {
                    //Blade Spirits + Energy Vortexes Can Freely Attack Their Control Master Without Causing Criminal Action
                    if (bc_Source.ControlMaster == pm_Target)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }

                if (bc_Source.ControlMaster != null && bc_Target != null)
                {
                    //Blade Spirits + Energy Vortexes Can Freely Attack Other Followers Of Their Control Master Without Causing Criminal Action
                    if (bc_Source.ControlMaster == bc_Target.ControlMaster)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            if (target is BladeSpirits || target is EnergyVortex)
            {
                return(Notoriety.Murderer);
            }

            //Staff Members Always Attackable
            if (target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (m_TargetController != null)
            {
                //Creature Controlled By Staff Member
                if (m_TargetController.AccessLevel > AccessLevel.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Enemy of One
            if (pm_Source != null && bc_Target != null)
            {
                if (!bc_Target.Summoned && !bc_Target.Controlled && pm_Source.EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }
            }

            //Justice Free Zone
            if (SpellHelper.InBuccs(target.Map, target.Location) || SpellHelper.InYewOrcFort(target.Map, target.Location) || SpellHelper.InYewCrypts(target.Map, target.Location))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Grey Zone Totem Nearby
            if (GreyZoneTotem.InGreyZoneTotemArea(target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Hotspot Nearby
            if (Custom.Hotspot.InHotspotArea(target.Location, target.Map, true))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Player Notoriety
            if (pm_Target != null)
            {
                //Friendly
                if (pm_SourceController != null)
                {
                    if (pm_SourceController == pm_Target)
                    {
                        return(Notoriety.Ally);
                    }
                }

                //Murderer
                if (pm_Target.Murderer && !pm_Target.HideMurdererStatus)
                {
                    return(Notoriety.Murderer);
                }

                //Criminal
                if (pm_Target.Criminal)
                {
                    return(Notoriety.Criminal);
                }

                //Perma-Grey
                if (SkillHandlers.Stealing.ClassicMode && pm_Target.PermaFlags.Contains(source))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (pm_SourceController != null)
                {
                    //Target is Perma-Grey to Source Creature's Controller
                    if (SkillHandlers.Stealing.ClassicMode && pm_Target.PermaFlags.Contains(pm_SourceController))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            //Guilds
            //TEST: GUILD

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

            //Creature Notoriety
            if (bc_Target != null)
            {
                //Friendly
                if (m_TargetController != null)
                {
                    //Target is Source's Controller
                    if (source == m_TargetController)
                    {
                        return(Notoriety.Ally);
                    }
                }

                if (m_SourceController != null)
                {
                    //Source is Target's Controller
                    if (m_SourceController == bc_Target)
                    {
                        return(Notoriety.Ally);
                    }
                }

                //Murderer
                if (bc_Target.IsMurderer())
                {
                    return(Notoriety.Murderer);
                }

                if (pm_TargetController != null)
                {
                    if (pm_TargetController.Murderer)
                    {
                        return(Notoriety.Murderer);
                    }
                }

                if (bc_TargetController != null)
                {
                    if (bc_TargetController.IsMurderer())
                    {
                        return(Notoriety.Murderer);
                    }
                }

                //Criminal
                if (bc_Target.Criminal)
                {
                    return(Notoriety.Criminal);
                }

                if (pm_TargetController != null)
                {
                    if (pm_TargetController.Criminal)
                    {
                        return(Notoriety.Criminal);
                    }
                }

                if (bc_TargetController != null)
                {
                    if (bc_TargetController.Criminal)
                    {
                        return(Notoriety.Criminal);
                    }
                }

                //Perma-Grey
                if (pm_TargetController != null)
                {
                    if (SkillHandlers.Stealing.ClassicMode && pm_TargetController.PermaFlags.Contains(source))
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (pm_SourceController != null)
                    {
                        //Target is Perma-Grey to Source Creature's Controller
                        if (SkillHandlers.Stealing.ClassicMode && pm_TargetController.PermaFlags.Contains(pm_SourceController))
                        {
                            return(Notoriety.CanBeAttacked);
                        }
                    }
                }
            }

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

            //Aggressor: Source to Target
            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

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

            //Aggressor: Source Controller to Target
            if (m_SourceController != null)
            {
                if (CheckAggressor(m_SourceController.Aggressors, target))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(m_SourceController.Aggressed, target) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Aggressor: Source to Target's Controller
            if (m_TargetController != null)
            {
                if (CheckAggressor(source.Aggressors, m_TargetController))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(source.Aggressed, m_TargetController) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Aggressor: Source Controller to Target's Controller
            if (m_SourceController != null && m_TargetController != null)
            {
                if (CheckAggressor(m_SourceController.Aggressors, m_TargetController))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(m_SourceController.Aggressed, m_TargetController) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Player Followers: If A Player or Any of Their Followers Have been Aggressed or Barded, the Player and All Other Followers Can Attack the Aggressor
            PlayerMobile pm_Player = null;

            if (pm_Source != null)
            {
                pm_Player = pm_Source;
            }

            if (pm_SourceController != null)
            {
                pm_Player = pm_SourceController;
            }

            if (pm_Player != null)
            {
                if (pm_Player.AllFollowers.Count > 0)
                {
                    //Any of the Player's Other Followers
                    foreach (Mobile follower in pm_Player.AllFollowers)
                    {
                        BaseCreature bc_Follower = follower as BaseCreature;

                        if (bc_Follower == null)
                        {
                            continue;
                        }

                        //Follower Has Been Aggressed/Aggresor to Target
                        if (CheckAggressor(bc_Follower.Aggressors, target))
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        if (CheckAggressed(bc_Follower.Aggressed, target) && useVengeance)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        //Follower Has Been Aggressed/Aggresor by/to Target's Controller
                        if (m_TargetController != null)
                        {
                            if (CheckAggressor(bc_Follower.Aggressors, m_TargetController))
                            {
                                return(Notoriety.CanBeAttacked);
                            }

                            if (CheckAggressed(bc_Follower.Aggressed, m_TargetController) && useVengeance)
                            {
                                return(Notoriety.CanBeAttacked);
                            }
                        }
                    }
                }
            }

            //Ships: Players and Creatures Friendly to a Ship Can Freely Attack Non-Friendly Mobiles on their Ship
            BaseShip sourceShip = null;

            if (bc_Source != null)
            {
                if (bc_Source.ShipOccupied != null)
                {
                    sourceShip = bc_Source.ShipOccupied;
                }
            }

            if (pm_Source != null)
            {
                if (pm_Source.ShipOccupied != null)
                {
                    sourceShip = pm_Source.ShipOccupied;
                }
            }

            if (sourceShip != null)
            {
                BaseShip targetShip = null;

                if (bc_Target != null)
                {
                    if (bc_Target.ShipOccupied != null)
                    {
                        targetShip = bc_Target.ShipOccupied;
                    }
                }

                if (pm_Target != null)
                {
                    if (pm_Target.ShipOccupied != null)
                    {
                        targetShip = pm_Target.ShipOccupied;
                    }
                }

                //On Same Ship
                if (sourceShip != null && targetShip != null && !sourceShip.Deleted && !targetShip.Deleted && sourceShip == targetShip)
                {
                    bool sourceBelongs = false;
                    bool targetBelongs = false;

                    //Source Belongs n the Ship
                    if (sourceShip.Crew.Contains(source) || sourceShip.IsFriend(source) || sourceShip.IsCoOwner(source) || sourceShip.IsOwner(source))
                    {
                        sourceBelongs = true;
                    }

                    //Source's Owner Belongs on the Ship
                    else if (bc_Source != null)
                    {
                        if (m_SourceController != null)
                        {
                            if (sourceShip.Crew.Contains(m_SourceController) || sourceShip.IsFriend(m_SourceController) || sourceShip.IsCoOwner(m_SourceController) || sourceShip.IsOwner(m_SourceController))
                            {
                                sourceBelongs = true;
                            }
                        }
                    }

                    //Target Belongs On The Ship
                    if (sourceShip.Crew.Contains(target) || sourceShip.IsFriend(target) || sourceShip.IsCoOwner(target) || sourceShip.IsOwner(target))
                    {
                        targetBelongs = true;
                    }

                    //Target's Owner Belongs On the Ship
                    else if (bc_Target != null)
                    {
                        if (m_TargetController != null)
                        {
                            if (sourceShip.Crew.Contains(m_TargetController) || sourceShip.IsFriend(m_TargetController) || sourceShip.IsCoOwner(m_TargetController) || sourceShip.IsOwner(m_TargetController))
                            {
                                targetBelongs = true;
                            }
                        }
                    }

                    //Target May Be Freely Attacked on Ship
                    if (sourceBelongs && !targetBelongs)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            //Polymorph or Body Transformation
            if (!(bc_Target != null && bc_Target.InitialInnocent))
            {
                if (target.Player && target.BodyMod > 0)
                {
                }

                else if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bc_Target) && !TransformationSpellHelper.UnderTransformation(target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //If somehow a player is attacking us with their tamed creatures, and their creatures are flagged to us but the player isn't
            //if (pm_Source != null && pm_Target != null)
            //{
            //    if (pm_Target.AllFollowers.Count > 0)
            //    {
            //        //Any of the Player's Other Followers
            //        foreach (Mobile follower in pm_Target.AllFollowers)
            //        {
            //            int notorietyResult = Notoriety.Compute(source, follower);

            //            //Enemy Tamer Adopts Notoriety of Their Creature (Anything other than Innocent)
            //            if (notorietyResult != 1)
            //            {
            //                foreach(var aggressor in source.Aggressors)
            //                {
            //                    if (aggressor.Attacker == follower)
            //                        return notorietyResult;
            //                }
            //            }
            //        }
            //    }
            //}

            return(Notoriety.Innocent);
        }
Beispiel #2
0
        public static int DetermineMobileNotoriety(Mobile source, Mobile target, bool useVengeance)
        {
            BaseCreature bc_Source = source as BaseCreature;
            PlayerMobile pm_Source = source as PlayerMobile;

            Mobile       m_SourceController  = null;
            BaseCreature bc_SourceController = null;
            PlayerMobile pm_SourceController = null;

            BaseCreature bc_Target = target as BaseCreature;
            PlayerMobile pm_Target = target as PlayerMobile;

            Mobile       m_TargetController  = null;
            BaseCreature bc_TargetController = null;
            PlayerMobile pm_TargetController = null;

            #region UOACZ

            if (UOACZRegion.ContainsMobile(target))
            {
                if (pm_Target != null)
                {
                    UOACZPersistance.CheckAndCreateUOACZAccountEntry(pm_Target);

                    if (pm_Target.IsUOACZUndead)
                    {
                        if (pm_Source != null)
                        {
                            if (pm_Source.IsUOACZHuman)
                            {
                                return(Notoriety.Enemy);
                            }

                            if (pm_Source.IsUOACZUndead)
                            {
                                if (pm_Target.Criminal)
                                {
                                    return(Notoriety.CanBeAttacked);
                                }

                                return(Notoriety.Innocent);
                            }
                        }

                        return(Notoriety.CanBeAttacked);
                    }

                    if (pm_Target.IsUOACZHuman)
                    {
                        if (pm_Source != null)
                        {
                            if (pm_Source.IsUOACZUndead)
                            {
                                return(Notoriety.Enemy);
                            }
                        }

                        if (pm_Target.m_UOACZAccountEntry.HumanProfile.HonorPoints <= UOACZSystem.HonorAggressionThreshold)
                        {
                            return(Notoriety.Enemy);
                        }

                        if (pm_Target.Criminal)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        if (pm_Source != null)
                        {
                            return(Notoriety.Innocent);
                        }

                        return(Notoriety.CanBeAttacked);
                    }
                }

                if (bc_Target != null)
                {
                    if (bc_Target is UOACZBaseUndead)
                    {
                        UOACZBaseUndead bc_Undead = bc_Target as UOACZBaseUndead;

                        if (bc_Undead.ControlMaster == source)
                        {
                            return(Notoriety.Ally);
                        }

                        if (pm_Source != null && (bc_Undead == UOACZPersistance.UndeadChampion || bc_Undead == UOACZPersistance.UndeadBoss))
                        {
                            if (pm_Source.IsUOACZHuman)
                            {
                                return(Notoriety.Murderer);
                            }
                        }

                        return(Notoriety.CanBeAttacked);
                    }

                    if (bc_Target is UOACZBaseWildlife)
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (bc_Target is UOACZBaseHuman)
                    {
                        UOACZBaseHuman bc_Human = bc_Target as UOACZBaseHuman;

                        if (source is UOACZBaseWildlife || source is UOACZBaseUndead)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        if (pm_Source != null)
                        {
                            if (pm_Source.IsUOACZUndead)
                            {
                                if (bc_Human == UOACZPersistance.HumanChampion || bc_Human == UOACZPersistance.HumanBoss)
                                {
                                    return(Notoriety.Murderer);
                                }

                                return(Notoriety.CanBeAttacked);
                            }
                        }

                        return(Notoriety.Innocent);
                    }
                }

                return(Notoriety.Innocent);
            }

            #endregion

            if (bc_Source != null)
            {
                m_SourceController  = bc_Source.ControlMaster as Mobile;
                bc_SourceController = bc_Source.ControlMaster as BaseCreature;
                pm_SourceController = bc_Source.ControlMaster as PlayerMobile;
            }

            if (bc_Target != null)
            {
                m_TargetController  = bc_Target.ControlMaster as Mobile;
                bc_TargetController = bc_Target.ControlMaster as BaseCreature;
                pm_TargetController = bc_Target.ControlMaster as PlayerMobile;
            }

            //Berserk Creatures
            if (bc_Source != null && (source is BladeSpirits || source is EnergyVortex))
            {
                if (bc_Source.ControlMaster != null && pm_Target != null)
                {
                    //Blade Spirits + Energy Vortexes Can Freely Attack Their Control Master Without Causing Criminal Action
                    if (bc_Source.ControlMaster == pm_Target)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }

                if (bc_Source.ControlMaster != null && bc_Target != null)
                {
                    //Blade Spirits + Energy Vortexes Can Freely Attack Other Followers Of Their Control Master Without Causing Criminal Action
                    if (bc_Source.ControlMaster == bc_Target.ControlMaster)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            if (target is BladeSpirits || target is EnergyVortex)
            {
                return(Notoriety.Murderer);
            }

            //Staff Members Always Attackable
            if (target.AccessLevel > AccessLevel.Player)
            {
                return(Notoriety.CanBeAttacked);
            }

            if (m_TargetController != null)
            {
                //Creature Controlled By Staff Member
                if (m_TargetController.AccessLevel > AccessLevel.Player)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Consensual PvP
            if (pm_Source != null && pm_Target != null)
            {
                //Duel
                if (pm_Source.DuelContext != null && pm_Source.DuelContext.StartedBeginCountdown && !pm_Source.DuelContext.Finished && pm_Source.DuelContext == pm_Target.DuelContext)
                {
                    return(pm_Source.DuelContext.IsAlly(pm_Source, pm_Target) ? Notoriety.Ally : Notoriety.Enemy);
                }
            }

            //Enemy of One
            if (pm_Source != null && bc_Target != null)
            {
                if (!bc_Target.Summoned && !bc_Target.Controlled && pm_Source.EnemyOfOneType == target.GetType())
                {
                    return(Notoriety.Enemy);
                }
            }

            //Justice Free Zone
            if (SpellHelper.InBuccs(target.Map, target.Location) || SpellHelper.InYewOrcFort(target.Map, target.Location) || SpellHelper.InYewCrypts(target.Map, target.Location))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Grey Zone Totem Nearby
            if (GreyZoneTotem.InGreyZoneTotemArea(target.Location, target.Map))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Hotspot Nearby
            if (Custom.Hotspot.InHotspotArea(target.Location, target.Map, true))
            {
                return(Notoriety.CanBeAttacked);
            }

            //Player Notoriety
            if (pm_Target != null)
            {
                //Friendly
                if (pm_SourceController != null)
                {
                    if (pm_SourceController == pm_Target)
                    {
                        return(Notoriety.Ally);
                    }
                }

                //Murderer
                if (pm_Target.Murderer && !pm_Target.HideMurdererStatus)
                {
                    return(Notoriety.Murderer);
                }

                //Criminal
                if (pm_Target.Criminal)
                {
                    return(Notoriety.Criminal);
                }

                //Perma-Grey
                if (SkillHandlers.Stealing.ClassicMode && pm_Target.PermaFlags.Contains(source))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (pm_SourceController != null)
                {
                    //Target is Perma-Grey to Source Creature's Controller
                    if (SkillHandlers.Stealing.ClassicMode && pm_Target.PermaFlags.Contains(pm_SourceController))
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            //Guilds
            //TEST: GUILD

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

            //Creature Notoriety
            if (bc_Target != null)
            {
                //Friendly
                if (m_TargetController != null)
                {
                    //Target is Source's Controller
                    if (source == m_TargetController)
                    {
                        return(Notoriety.Ally);
                    }
                }

                if (m_SourceController != null)
                {
                    //Source is Target's Controller
                    if (m_SourceController == bc_Target)
                    {
                        return(Notoriety.Ally);
                    }
                }

                //Murderer
                if (bc_Target.IsMurderer())
                {
                    return(Notoriety.Murderer);
                }

                if (pm_TargetController != null)
                {
                    if (pm_TargetController.Murderer)
                    {
                        return(Notoriety.Murderer);
                    }
                }

                if (bc_TargetController != null)
                {
                    if (bc_TargetController.IsMurderer())
                    {
                        return(Notoriety.Murderer);
                    }
                }

                //Criminal
                if (bc_Target.Criminal)
                {
                    return(Notoriety.Criminal);
                }

                if (pm_TargetController != null)
                {
                    if (pm_TargetController.Criminal)
                    {
                        return(Notoriety.Criminal);
                    }
                }

                if (bc_TargetController != null)
                {
                    if (bc_TargetController.Criminal)
                    {
                        return(Notoriety.Criminal);
                    }
                }

                //Perma-Grey
                if (pm_TargetController != null)
                {
                    if (SkillHandlers.Stealing.ClassicMode && pm_TargetController.PermaFlags.Contains(source))
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (pm_SourceController != null)
                    {
                        //Target is Perma-Grey to Source Creature's Controller
                        if (SkillHandlers.Stealing.ClassicMode && pm_TargetController.PermaFlags.Contains(pm_SourceController))
                        {
                            return(Notoriety.CanBeAttacked);
                        }
                    }
                }
            }

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

            //Aggressor: Source to Target
            if (CheckAggressor(source.Aggressors, target))
            {
                return(Notoriety.CanBeAttacked);
            }

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

            //Aggressor: Source Controller to Target
            if (m_SourceController != null)
            {
                if (CheckAggressor(m_SourceController.Aggressors, target))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(m_SourceController.Aggressed, target) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Aggressor: Source to Target's Controller
            if (m_TargetController != null)
            {
                if (CheckAggressor(source.Aggressors, m_TargetController))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(source.Aggressed, m_TargetController) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Aggressor: Source Controller to Target's Controller
            if (m_SourceController != null && m_TargetController != null)
            {
                if (CheckAggressor(m_SourceController.Aggressors, m_TargetController))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (CheckAggressed(m_SourceController.Aggressed, m_TargetController) && useVengeance)
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //Player Followers: If A Player or Any of Their Followers Have been Aggressed or Barded, the Player and All Other Followers Can Attack the Aggressor
            PlayerMobile pm_Player = null;

            if (pm_Source != null)
            {
                pm_Player = pm_Source;
            }

            if (pm_SourceController != null)
            {
                pm_Player = pm_SourceController;
            }

            if (pm_Player != null)
            {
                if (pm_Player.AllFollowers.Count > 0)
                {
                    //Any of the Player's Other Followers
                    foreach (Mobile follower in pm_Player.AllFollowers)
                    {
                        BaseCreature bc_Follower = follower as BaseCreature;

                        if (bc_Follower == null)
                        {
                            continue;
                        }

                        //Follower Has Been Aggressed/Aggresor to Target
                        if (CheckAggressor(bc_Follower.Aggressors, target))
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        if (CheckAggressed(bc_Follower.Aggressed, target) && useVengeance)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        //Follower Has Been Aggressed/Aggresor by/to Target's Controller
                        if (m_TargetController != null)
                        {
                            if (CheckAggressor(bc_Follower.Aggressors, m_TargetController))
                            {
                                return(Notoriety.CanBeAttacked);
                            }

                            if (CheckAggressed(bc_Follower.Aggressed, m_TargetController) && useVengeance)
                            {
                                return(Notoriety.CanBeAttacked);
                            }
                        }
                    }
                }
            }

            //Boats: Players and Creatures Friendly to a Boat Can Freely Attack Non-Friendly Mobiles on their Boat
            BaseBoat sourceBoat = null;

            if (bc_Source != null)
            {
                if (bc_Source.BoatOccupied != null)
                {
                    sourceBoat = bc_Source.BoatOccupied;
                }
            }

            if (pm_Source != null)
            {
                if (pm_Source.BoatOccupied != null)
                {
                    sourceBoat = pm_Source.BoatOccupied;
                }
            }

            if (sourceBoat != null)
            {
                BaseBoat targetBoat = null;

                if (bc_Target != null)
                {
                    if (bc_Target.BoatOccupied != null)
                    {
                        targetBoat = bc_Target.BoatOccupied;
                    }
                }

                if (pm_Target != null)
                {
                    if (pm_Target.BoatOccupied != null)
                    {
                        targetBoat = pm_Target.BoatOccupied;
                    }
                }

                //On Same Boat
                if (sourceBoat != null && targetBoat != null && !sourceBoat.Deleted && !targetBoat.Deleted && sourceBoat == targetBoat)
                {
                    bool sourceBelongs = false;
                    bool targetBelongs = false;

                    //Source Belongs n the Boat
                    if (sourceBoat.Crew.Contains(source) || sourceBoat.IsFriend(source) || sourceBoat.IsCoOwner(source) || sourceBoat.IsOwner(source))
                    {
                        sourceBelongs = true;
                    }

                    //Source's Owner Belongs on the Boat
                    else if (bc_Source != null)
                    {
                        if (m_SourceController != null)
                        {
                            if (sourceBoat.Crew.Contains(m_SourceController) || sourceBoat.IsFriend(m_SourceController) || sourceBoat.IsCoOwner(m_SourceController) || sourceBoat.IsOwner(m_SourceController))
                            {
                                sourceBelongs = true;
                            }
                        }
                    }

                    //Target Belongs On The Boat
                    if (sourceBoat.Crew.Contains(target) || sourceBoat.IsFriend(target) || sourceBoat.IsCoOwner(target) || sourceBoat.IsOwner(target))
                    {
                        targetBelongs = true;
                    }

                    //Target's Owner Belongs On the Boat
                    else if (bc_Target != null)
                    {
                        if (m_TargetController != null)
                        {
                            if (sourceBoat.Crew.Contains(m_TargetController) || sourceBoat.IsFriend(m_TargetController) || sourceBoat.IsCoOwner(m_TargetController) || sourceBoat.IsOwner(m_TargetController))
                            {
                                targetBelongs = true;
                            }
                        }
                    }

                    //Target May Be Freely Attacked on Boat
                    if (sourceBelongs && !targetBelongs)
                    {
                        return(Notoriety.CanBeAttacked);
                    }
                }
            }

            //Polymorph or Body Transformation
            if (!(bc_Target != null && bc_Target.InitialInnocent))
            {
                if (target.Player && target.BodyMod > 0)
                {
                }

                else if (!target.Body.IsHuman && !target.Body.IsGhost && !IsPet(bc_Target) && !TransformationSpellHelper.UnderTransformation(target))
                {
                    return(Notoriety.CanBeAttacked);
                }
            }

            //If somehow a player is attacking us with their tamed creatures, and their creatures are flagged to us but the player isn't
            //if (pm_Source != null && pm_Target != null)
            //{
            //    if (pm_Target.AllFollowers.Count > 0)
            //    {
            //        //Any of the Player's Other Followers
            //        foreach (Mobile follower in pm_Target.AllFollowers)
            //        {
            //            int notorietyResult = Notoriety.Compute(source, follower);

            //            //Enemy Tamer Adopts Notoriety of Their Creature (Anything other than Innocent)
            //            if (notorietyResult != 1)
            //            {
            //                foreach(var aggressor in source.Aggressors)
            //                {
            //                    if (aggressor.Attacker == follower)
            //                        return notorietyResult;
            //                }
            //            }
            //        }
            //    }
            //}

            return(Notoriety.Innocent);
        }
Beispiel #3
0
        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)
            {
                //TEST: GUILD

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

                if (cretOwner.IsLoHBoss() || cretOwner.FreelyLootable)
                {
                    return(Notoriety.CanBeAttacked);
                }

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

                int actual = Notoriety.CanBeAttacked;

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

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

                Party sourceParty = Party.Get(source);

                List <Mobile> list = target.Aggressors;

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

                return(Notoriety.Innocent);
            }

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

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

                //TEST: GUILD

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

                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 (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature))
                {
                    return(Notoriety.CanBeAttacked);
                }

                List <Mobile> list = target.Aggressors;

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

                if (SpellHelper.InBuccs(target.Map, target.Location) || SpellHelper.InYewOrcFort(target.Map, target.Location) || SpellHelper.InYewCrypts(target.Map, target.Location))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (GreyZoneTotem.InGreyZoneTotemArea(target.Location, target.Map))
                {
                    return(Notoriety.CanBeAttacked);
                }

                //Hotspot Nearby
                if (Custom.Hotspot.InHotspotArea(target.Location, target.Map, true))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (target.IsBones)
                {
                    return(Notoriety.CanBeAttacked);
                }

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

            #region UOACZ

            if (UOACZRegion.ContainsItem(target))
            {
                PlayerMobile pm_Owner = target.Owner as PlayerMobile;
                BaseCreature bc_Owner = target.Owner as BaseCreature;

                if (pm_Owner != null)
                {
                    UOACZPersistance.CheckAndCreateUOACZAccountEntry(pm_Owner);

                    if (pm_Owner.IsUOACZUndead)
                    {
                        return(Notoriety.Murderer);
                    }

                    if (pm_Owner.m_UOACZAccountEntry.ActiveProfile == UOACZAccountEntry.ActiveProfileType.Human)
                    {
                        if (pm_Owner.m_UOACZAccountEntry.HumanProfile.HonorPoints <= UOACZSystem.HonorAggressionThreshold)
                        {
                            return(Notoriety.Enemy);
                        }

                        if (pm_Owner.Criminal)
                        {
                            return(Notoriety.CanBeAttacked);
                        }

                        return(Notoriety.Innocent);
                    }
                }

                if (bc_Owner != null)
                {
                    if (bc_Owner is UOACZBaseUndead)
                    {
                        if (bc_Owner.ControlMaster == source)
                        {
                            return(Notoriety.Ally);
                        }

                        return(Notoriety.CanBeAttacked);
                    }

                    if (bc_Owner is UOACZBaseWildlife)
                    {
                        return(Notoriety.CanBeAttacked);
                    }

                    if (bc_Owner is UOACZBaseHuman)
                    {
                        return(Notoriety.Innocent);
                    }
                }

                return(Notoriety.CanBeAttacked);
            }

            #endregion

            Body body = (Body)target.Amount;

            BaseCreature cretOwner = target.Owner as BaseCreature;

            if (cretOwner != null)
            {
                //TEST: GUILD

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

                if (cretOwner.IsLoHBoss() || cretOwner.FreelyLootable)
                {
                    return(Notoriety.CanBeAttacked);
                }

                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).IsMurderer() || ((BaseCreature)target.Owner).IsAnimatedDead)))
                {
                    actual = Notoriety.Murderer;
                }

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

                Party sourceParty = Party.Get(source);

                List <Mobile> list = target.Aggressors;

                for (int i = 0; i < list.Count; ++i)
                {
                    if (list[i] == source || (sourceParty != null && Party.Get(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).IsMurderer() || ((BaseCreature)target.Owner).IsAnimatedDead)))
                {
                    return(Notoriety.Murderer);
                }

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

                //TEST: GUILD

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

                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 (!(target.Owner is PlayerMobile) && !IsPet(target.Owner as BaseCreature))
                {
                    return(Notoriety.CanBeAttacked);
                }

                List <Mobile> list = target.Aggressors;

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

                if (SpellHelper.InBuccs(target.Map, target.Location) || SpellHelper.InYewOrcFort(target.Map, target.Location) || SpellHelper.InYewCrypts(target.Map, target.Location))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (GreyZoneTotem.InGreyZoneTotemArea(target.Location, target.Map))
                {
                    return(Notoriety.CanBeAttacked);
                }

                //Hotspot Nearby
                if (Custom.Hotspot.InHotspotArea(target.Location, target.Map, true))
                {
                    return(Notoriety.CanBeAttacked);
                }

                if (target.IsBones)
                {
                    return(Notoriety.CanBeAttacked);
                }

                return(Notoriety.Innocent);
            }
        }