Exemple #1
0
        public override void ReceiveDamage(Mobile from, int damage, BreakableStatic.InteractionType interactionType)
        {
            base.ReceiveDamage(from, damage, interactionType);

            double hitPointsPercent = (double)HitPoints / (double)MaxHitPoints;

            if (m_NextDamageStateNotification > 0.05 && hitPointsPercent < m_NextDamageStateNotification)
            {
                foreach (NetState state in NetState.Instances)
                {
                    Mobile       mobile = state.Mobile;
                    PlayerMobile player = mobile as PlayerMobile;

                    if (player == null)
                    {
                        continue;
                    }

                    if (UOACZRegion.ContainsMobile(player))
                    {
                        player.SendMessage(UOACZSystem.yellowTextHue, "The Corruption Sourcestone is under attack and at " + Utility.CreatePercentageString(m_NextDamageStateNotification) + " durability.");
                    }
                }

                m_NextDamageStateNotification -= NotificationInterval;
            }
        }
Exemple #2
0
        public static List <UOACZBoneBox> GetActiveInstances()
        {
            List <UOACZBoneBox> m_ActiveInstances = new List <UOACZBoneBox>();

            for (int a = 0; a < m_Instances.Count; a++)
            {
                UOACZBoneBox instance = m_Instances[a];

                if (instance.Deleted)
                {
                    continue;
                }

                if (UOACZRegion.ContainsItem(instance))
                {
                    m_ActiveInstances.Add(instance);
                }
            }

            return(m_ActiveInstances);
        }
        public static List <UOACZBaseCivilian> GetActiveInstances()
        {
            List <UOACZBaseCivilian> m_ActiveInstances = new List <UOACZBaseCivilian>();

            for (int a = 0; a < m_Instances.Count; a++)
            {
                UOACZBaseCivilian instance = m_Instances[a];

                if (instance.Deleted)
                {
                    continue;
                }

                if (UOACZRegion.ContainsMobile(instance))
                {
                    m_ActiveInstances.Add(instance);
                }
            }

            return(m_ActiveInstances);
        }
        public UOACZOverviewGump(PlayerMobile player) : base(10, 10)
        {
            if (player == null)
            {
                return;
            }
            if (player.Deleted)
            {
                return;
            }

            m_Player = player;

            Closable   = true;
            Disposable = true;
            Dragable   = true;
            Resizable  = false;

            AddImage(2, 3, 9390);
            AddImage(513, 5, 9392);
            AddImage(2, 386, 9396);
            AddImage(514, 386, 9398);
            AddImageTiled(2, 139, 118, 250, 9393);
            AddImageTiled(115, 4, 400, 142, 9391);
            AddImageTiled(115, 386, 400, 140, 9397);
            AddImageTiled(513, 143, 104, 250, 9395);
            AddImageTiled(115, 142, 400, 250, 9394);

            //------------

            int textHue = 2655;

            AddLabel(28, 9, 149, "UOACZ Guide Website");
            AddButton(47, 30, 2095, 2094, 1, GumpButtonType.Reply, 0);

            AddLabel(243, 35, 2606, "UOACZ Session Overview");

            int humanPlayers       = 0;
            int undeadPlayers      = 0;
            int averageHumanScore  = 0;
            int averageUndeadScore = 0;

            int totalHumanScores  = 0;
            int totalUndeadScores = 0;

            if (UOACZPersistance.Active)
            {
                foreach (NetState state in NetState.Instances)
                {
                    Mobile       mobile    = state.Mobile;
                    PlayerMobile pm_Mobile = mobile as PlayerMobile;

                    if (pm_Mobile == null)
                    {
                        continue;
                    }

                    if (UOACZRegion.ContainsMobile(pm_Mobile))
                    {
                        if (pm_Mobile.AccessLevel > AccessLevel.Player)
                        {
                            continue;
                        }
                    }

                    if (pm_Mobile.IsUOACZHuman)
                    {
                        humanPlayers++;
                        totalHumanScores += pm_Mobile.m_UOACZAccountEntry.CurrentSessionHumanScore;
                    }

                    if (pm_Mobile.IsUOACZUndead)
                    {
                        undeadPlayers++;
                        totalUndeadScores += pm_Mobile.m_UOACZAccountEntry.CurrentSessionUndeadScore;
                    }
                }
            }

            if (humanPlayers > 0)
            {
                averageHumanScore = (int)(Math.Ceiling((double)totalHumanScores / (double)humanPlayers));
            }

            if (undeadPlayers > 0)
            {
                averageUndeadScore = (int)(Math.Ceiling((double)totalUndeadScores / (double)undeadPlayers));
            }

            int humanPlayersTextHue     = UOACZSystem.whiteTextHue;
            int undeadPlayersTextHue    = UOACZSystem.whiteTextHue;
            int humanTotalScoreTextHue  = UOACZSystem.whiteTextHue;
            int undeadTotalScoreTextHue = UOACZSystem.whiteTextHue;

            double humanUnderdogBonus  = UOACZPersistance.HumanBalanceScalar - 1;
            double undeadUnderdogBonus = UOACZPersistance.UndeadBalanceScalar - 1;

            string humanUnderdogBonusText  = Utility.CreateDecimalPercentageString(humanUnderdogBonus, 0);
            string undeadUnderdogBonusText = Utility.CreateDecimalPercentageString(undeadUnderdogBonus, 0);

            int humanUnderdogBonusTextHue  = UOACZSystem.whiteTextHue;
            int undeadUnderdogBonusTextHue = UOACZSystem.whiteTextHue;

            bool humanRecommended  = false;
            bool undeadRecommended = false;

            if (humanPlayers > undeadPlayers)
            {
                humanPlayersTextHue = UOACZSystem.greenTextHue;
            }

            if (undeadPlayers > humanPlayers)
            {
                undeadPlayersTextHue = UOACZSystem.greenTextHue;
            }

            if (totalHumanScores > totalUndeadScores)
            {
                humanTotalScoreTextHue = UOACZSystem.greenTextHue;
            }

            if (totalUndeadScores > totalHumanScores)
            {
                undeadTotalScoreTextHue = UOACZSystem.greenTextHue;
            }

            if (humanUnderdogBonus > undeadUnderdogBonus)
            {
                humanUnderdogBonusTextHue = UOACZSystem.greenTextHue;
                humanRecommended          = true;
            }

            if (undeadUnderdogBonus > humanUnderdogBonus)
            {
                undeadUnderdogBonusTextHue = UOACZSystem.greenTextHue;
                undeadRecommended          = true;
            }

            if (humanUnderdogBonus == undeadUnderdogBonus)
            {
                humanRecommended  = true;
                undeadRecommended = false;
            }

            //Active Players + Avg Score
            AddLabel(118, 60, 1164, "Human Team");
            AddLabel(49, 85, 1164, "Active Players");
            AddLabel(Utility.CenteredTextOffset(95, humanPlayers.ToString()), 105, humanPlayersTextHue, humanPlayers.ToString());
            AddLabel(186, 85, 1164, "Total Score");
            AddLabel(Utility.CenteredTextOffset(215, totalHumanScores.ToString()), 105, humanTotalScoreTextHue, totalHumanScores.ToString());

            AddLabel(446, 60, 2115, "Undead Team");
            AddLabel(380, 85, 2115, "Active Players");
            AddLabel(Utility.CenteredTextOffset(425, undeadPlayers.ToString()), 105, undeadPlayersTextHue, undeadPlayers.ToString());
            AddLabel(516, 85, 2115, "Total Score");
            AddLabel(Utility.CenteredTextOffset(545, totalUndeadScores.ToString()), 105, undeadTotalScoreTextHue, totalUndeadScores.ToString());

            //Human Objectives
            #region Objectives Determination

            int humanObjectivesCompleted  = 0;
            int undeadObjectivesCompleted = 0;

            int humanTotalObjectives  = UOACZSystem.ObjectivesNeededForVictory;
            int undeadTotalObjectives = UOACZSystem.ObjectivesNeededForVictory;

            bool humanObjective1Completed = false;
            bool humanObjective2Completed = false;
            bool humanObjective3Completed = false;
            bool humanObjective4Completed = false;
            bool humanObjective5Completed = false;

            bool undeadObjective1Completed = false;
            bool undeadObjective2Completed = false;
            bool undeadObjective3Completed = false;
            bool undeadObjective4Completed = false;
            bool undeadObjective5Completed = false;

            string humanObjective1Progress = "0%";
            string humanObjective2Progress = "0%";
            string humanObjective3Progress = "0%";
            string humanObjective4Progress = "0%";
            string humanObjective5Progress = "0%";

            string undeadObjective1Progress = "0%";
            string undeadObjective2Progress = "0%";
            string undeadObjective3Progress = "0%";
            string undeadObjective4Progress = "0%";
            string undeadObjective5Progress = "0%";

            double progress = 0;

            //Human Objective Progress
            if (UOACZPersistance.m_HumanObjective1Target != 0)
            {
                progress = UOACZPersistance.m_HumanObjective1 / UOACZPersistance.m_HumanObjective1Target;
                humanObjective1Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_HumanObjective1 == UOACZPersistance.m_HumanObjective1Target)
                {
                    humanObjective1Completed = true;
                    humanObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_HumanObjective2Target != 0)
            {
                progress = UOACZPersistance.m_HumanObjective2 / UOACZPersistance.m_HumanObjective2Target;
                humanObjective2Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_HumanObjective2 == UOACZPersistance.m_HumanObjective2Target)
                {
                    humanObjective2Completed = true;
                    humanObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_HumanObjective3Target != 0)
            {
                progress = UOACZPersistance.m_HumanObjective3 / UOACZPersistance.m_HumanObjective3Target;
                humanObjective3Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_HumanObjective3 == UOACZPersistance.m_HumanObjective3Target)
                {
                    humanObjective3Completed = true;
                    humanObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_HumanObjective4Target != 0)
            {
                progress = UOACZPersistance.m_HumanObjective4 / UOACZPersistance.m_HumanObjective4Target;
                humanObjective4Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_HumanObjective4 == UOACZPersistance.m_HumanObjective4Target)
                {
                    humanObjective4Completed = true;
                    humanObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_HumanObjective5Target != 0)
            {
                progress = UOACZPersistance.m_HumanObjective5 / UOACZPersistance.m_HumanObjective5Target;
                humanObjective5Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_HumanObjective5 == UOACZPersistance.m_HumanObjective5Target)
                {
                    humanObjective5Completed = true;
                    humanObjectivesCompleted++;
                }
            }

            if (humanObjectivesCompleted > humanTotalObjectives)
            {
                humanObjectivesCompleted = humanTotalObjectives;
            }

            //Undead Objectives
            if (UOACZPersistance.m_UndeadObjective1Target != 0)
            {
                progress = UOACZPersistance.m_UndeadObjective1 / UOACZPersistance.m_UndeadObjective1Target;
                undeadObjective1Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_UndeadObjective1 == UOACZPersistance.m_UndeadObjective1Target)
                {
                    undeadObjective1Completed = true;
                    undeadObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_UndeadObjective2Target != 0)
            {
                progress = UOACZPersistance.m_UndeadObjective2 / UOACZPersistance.m_UndeadObjective2Target;
                undeadObjective2Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_UndeadObjective2 == UOACZPersistance.m_UndeadObjective2Target)
                {
                    undeadObjective2Completed = true;
                    undeadObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_UndeadObjective3Target != 0)
            {
                progress = UOACZPersistance.m_UndeadObjective3 / UOACZPersistance.m_UndeadObjective3Target;
                undeadObjective3Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_UndeadObjective3 == UOACZPersistance.m_UndeadObjective3Target)
                {
                    undeadObjective3Completed = true;
                    undeadObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_UndeadObjective4Target != 0)
            {
                progress = UOACZPersistance.m_UndeadObjective4 / UOACZPersistance.m_UndeadObjective4Target;
                undeadObjective4Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_UndeadObjective4 == UOACZPersistance.m_UndeadObjective4Target)
                {
                    undeadObjective4Completed = true;
                    undeadObjectivesCompleted++;
                }
            }

            if (UOACZPersistance.m_UndeadObjective5Target != 0)
            {
                progress = UOACZPersistance.m_UndeadObjective5 / UOACZPersistance.m_UndeadObjective5Target;
                undeadObjective5Progress = Utility.CreateDecimalPercentageString(progress, 1);

                if (UOACZPersistance.m_UndeadObjective5 == UOACZPersistance.m_UndeadObjective5Target)
                {
                    undeadObjective5Completed = true;
                    undeadObjectivesCompleted++;
                }
            }

            if (undeadObjectivesCompleted > undeadTotalObjectives)
            {
                undeadObjectivesCompleted = undeadTotalObjectives;
            }

            #endregion

            AddLabel(35, 136, 1164, "Human Objectives (" + humanObjectivesCompleted.ToString() + "/" + humanTotalObjectives.ToString() + ")");

            if (humanObjective1Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            AddLabel(35, 156, textHue, "Destroy Corruption Sourcestone");
            AddLabel(250, 156, textHue, humanObjective1Progress);

            if (humanObjective2Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            AddLabel(35, 176, textHue, "Build the Outpost");
            AddLabel(250, 176, textHue, humanObjective2Progress);

            if (humanObjective3Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            AddLabel(35, 196, textHue, "Gather Bones");
            AddLabel(250, 195, textHue, humanObjective3Progress);

            if (humanObjective4Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            if (UOACZPersistance.UndeadChampion == null && !humanObjective4Completed)
            {
                int    minutesUntilSpawn = UOACZSystem.UndeadChampionSpawnMinutes - UOACZPersistance.m_MinutesActive;
                string timeRemaining     = Utility.CreateTimeRemainingString(DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromMinutes(minutesUntilSpawn), true, false, true, true, false);

                AddLabel(35, 215, textHue, "Undead Champion");
                AddLabel(250, 215, textHue, "(" + timeRemaining + ")");
            }

            else
            {
                AddLabel(35, 215, textHue, "Slay Undead Champion");
                AddLabel(250, 215, textHue, humanObjective4Progress);
            }

            if (humanObjective5Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            if (UOACZPersistance.UndeadBoss == null && !humanObjective5Completed)
            {
                int    minutesUntilSpawn = UOACZSystem.UndeadBossSpawnMinutes - UOACZPersistance.m_MinutesActive;
                string timeRemaining     = Utility.CreateTimeRemainingString(DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromMinutes(minutesUntilSpawn), true, false, true, true, false);

                AddLabel(35, 235, textHue, "Undead Boss");
                AddLabel(250, 235, textHue, "(" + timeRemaining + ")");
            }

            else
            {
                AddLabel(35, 235, textHue, "Slay Undead Boss");
                AddLabel(250, 235, textHue, humanObjective5Progress);
            }

            //Undead Objectives
            AddLabel(380, 136, 2115, "Undead Objectives (" + undeadObjectivesCompleted.ToString() + "/" + undeadTotalObjectives.ToString() + ")");

            if (undeadObjective1Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            AddLabel(380, 156, textHue, "Destroy Town Stockpiles");
            AddLabel(548, 156, textHue, undeadObjective1Progress);

            if (undeadObjective2Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            AddLabel(380, 176, textHue, "Kill Town Civilians");
            AddLabel(547, 175, textHue, undeadObjective2Progress);

            if (undeadObjective3Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            AddLabel(380, 196, textHue, "Spread Corruption");
            AddLabel(548, 196, textHue, undeadObjective3Progress);

            if (undeadObjective4Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            if (UOACZPersistance.HumanChampion == null && !undeadObjective4Completed)
            {
                int    minutesUntilSpawn = UOACZSystem.HumanChampionSpawnMinutes - UOACZPersistance.m_MinutesActive;
                string timeRemaining     = Utility.CreateTimeRemainingString(DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromMinutes(minutesUntilSpawn), true, false, true, true, false);

                AddLabel(380, 216, textHue, "Human Champion");
                AddLabel(547, 216, textHue, "(" + timeRemaining + ")");
            }

            else
            {
                AddLabel(380, 216, textHue, "Slay Human Champion");
                AddLabel(547, 216, textHue, undeadObjective4Progress);
            }

            if (undeadObjective5Completed)
            {
                textHue = UOACZSystem.greenTextHue;
            }
            else
            {
                textHue = UOACZSystem.whiteTextHue;
            }

            if (UOACZPersistance.HumanBoss == null && !undeadObjective5Completed)
            {
                int    minutesUntilSpawn = UOACZSystem.HumanBossSpawnMinutes - UOACZPersistance.m_MinutesActive;
                string timeRemaining     = Utility.CreateTimeRemainingString(DateTime.UtcNow, DateTime.UtcNow + TimeSpan.FromMinutes(minutesUntilSpawn), true, false, true, true, false);

                AddLabel(379, 236, textHue, "Human Boss");
                AddLabel(547, 236, textHue, "(" + timeRemaining + ")");
            }
            else
            {
                AddLabel(379, 236, textHue, "Slay Human Boss");
                AddLabel(547, 236, textHue, undeadObjective5Progress);
            }

            //Underdog Bonus
            AddLabel(248, 263, 2550, "Team Underdog Bonus");
            AddLabel(111, 282, UOACZSystem.blueTextHue, "Bonus to Upgrade Chances, Loot Drops, and Ability Effectiveness");

            AddLabel(61, 314, 1164, "Human Player Underdog Bonus");
            AddImage(123, 338, 24019, 0);
            AddLabel(173, 348, humanUnderdogBonusTextHue, humanUnderdogBonusText);

            AddLabel(388, 314, 2115, "Undead Player Underdog Bonus");
            AddImage(450, 338, 24012, 0);
            AddLabel(503, 348, undeadUnderdogBonusTextHue, undeadUnderdogBonusText);

            //Human Team Selection
            if (humanRecommended)
            {
                AddLabel(100, 392, 149, "(Recommended)");
            }

            if (player.m_UOACZAccountEntry.CurrentTeam == UOACZAccountEntry.ActiveProfileType.Human)
            {
                AddLabel(Utility.CenteredTextOffset(145, "Currently Playing as Human"), 412, UOACZSystem.greenTextHue, "Currently Playing as Human");
            }
            else
            {
                AddLabel(Utility.CenteredTextOffset(145, "Become Human Player"), 412, UOACZSystem.whiteTextHue, "Become Human Player");
            }

            if (player.m_UOACZAccountEntry.m_TeamSelectIndex == 0)
            {
                AddButton(102, 447, 9724, 9721, 2, GumpButtonType.Reply, 0);
            }
            else
            {
                AddButton(102, 447, 9721, 9724, 2, GumpButtonType.Reply, 0);
            }
            AddImage(140, 437, 11012, 0);

            //Undead Team Selection
            if (undeadRecommended)
            {
                AddLabel(423, 392, 149, "(Recommended)");
            }

            if (player.m_UOACZAccountEntry.CurrentTeam == UOACZAccountEntry.ActiveProfileType.Undead)
            {
                AddLabel(Utility.CenteredTextOffset(470, "Currently Playing as Undead"), 412, UOACZSystem.greenTextHue, "Currently Playing as Undead");
            }
            else
            {
                AddLabel(Utility.CenteredTextOffset(470, "Become Undead Player"), 412, UOACZSystem.whiteTextHue, "Become Undead Player");
            }

            if (player.m_UOACZAccountEntry.m_TeamSelectIndex == 1)
            {
                AddButton(424, 447, 9724, 9721, 3, GumpButtonType.Reply, 0);
            }
            else
            {
                AddButton(424, 447, 9721, 9724, 3, GumpButtonType.Reply, 0);
            }
            AddImage(462, 437, 11011, 0);

            if ((player.m_UOACZAccountEntry.CurrentTeam == UOACZAccountEntry.ActiveProfileType.Human && player.m_UOACZAccountEntry.m_TeamSelectIndex == 1) ||
                (player.m_UOACZAccountEntry.CurrentTeam == UOACZAccountEntry.ActiveProfileType.Undead && player.m_UOACZAccountEntry.m_TeamSelectIndex == 0))
            {
                if (UOACZPersistance.Active)
                {
                    if (player.m_UOACZAccountEntry.NextTeamSwitchAllowed > DateTime.UtcNow)
                    {
                        string timeRemaining = Utility.CreateTimeRemainingString(DateTime.UtcNow, player.m_UOACZAccountEntry.NextTeamSwitchAllowed, true, true, true, true, true);

                        AddLabel(Utility.CenteredTextOffset(315, "Cannot change teams for " + timeRemaining), 436, 149, "Cannot change teams for " + timeRemaining);
                    }

                    else
                    {
                        AddLabel(Utility.CenteredTextOffset(315, "Confirm Team Change"), 436, 149, "Confirm Team Change");
                        AddButton(283, 459, 238, 238, 4, GumpButtonType.Reply, 0);
                    }
                }

                else
                {
                    AddLabel(Utility.CenteredTextOffset(315, "Confirm Team Change"), 436, 149, "Confirm Team Change");
                    AddButton(283, 459, 238, 238, 4, GumpButtonType.Reply, 0);
                }
            }
        }
Exemple #5
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);
        }
Exemple #6
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);
            }
        }
Exemple #7
0
        public override void OnSingleClick(Mobile from)
        {
            if (from.AccessLevel == AccessLevel.Player)
            {
                return;
            }

            switch (Behavior)
            {
            case WaypointBehavior.NextWaypoint:
                LabelTo(from, "Waypoint: Next");
                break;

            case WaypointBehavior.ReverseOrder:
                LabelTo(from, "Waypoint: Reverse Order");
                break;

            case WaypointBehavior.ReturnToStart:
                LabelTo(from, "Waypoint: Return to Start");
                break;

            case WaypointBehavior.SetHomeHere:
                LabelTo(from, "Waypoint: Set Home Here");
                break;

            case WaypointBehavior.Idle10secThenNextWaypoint:
                LabelTo(from, "Waypoint: 10s Next");
                break;

            case WaypointBehavior.Idle30secThenNextWaypoint:
                LabelTo(from, "Waypoint: 30s Next");
                break;

            case WaypointBehavior.Idle10secThenReverseOrder:
                LabelTo(from, "Waypoint: 10s Reverse");
                break;

            case WaypointBehavior.Idle30secThenReverseOrder:
                LabelTo(from, "Waypoint: 30s Reverse");
                break;
            }

            string splitGroupText = "";

            if (m_GotoSplitGroup > -1)
            {
                splitGroupText += "Goto Split: " + m_GotoSplitGroup.ToString() + " ";
            }

            if (m_SplitGroup > -1)
            {
                splitGroupText += "Split Group is: " + m_SplitGroup.ToString();
            }

            if (splitGroupText != "")
            {
                LabelTo(from, splitGroupText);
            }

            LabelTo(from, "Previous Waypoints: " + PreviousWaypoints.Count);

            if (m_GotoSplitGroup > -1)
            {
                int splitWaypointTargets = 0;

                from.SendMessage(2550, "Waypoint split destinations at:");

                foreach (UOACZWayPoint waypoint in m_UOACZWaypoints)
                {
                    if (!UOACZRegion.ContainsItem(waypoint))
                    {
                        continue;
                    }

                    if (waypoint.m_WaypointType == m_WaypointType && waypoint.m_SplitGroup == m_GotoSplitGroup)
                    {
                        splitWaypointTargets++;
                        from.SendMessage(waypoint.Location.X.ToString() + "," + waypoint.Location.Y.ToString() + "," + waypoint.Location.Z.ToString());
                    }
                }

                from.SendMessage(2550, splitWaypointTargets.ToString() + " potential split destinations.");
            }

            else
            {
                if (NextWaypoint != null)
                {
                    from.SendMessage(2550, "Next Waypoint at: " + NextWaypoint.Location.X.ToString() + ", " + NextWaypoint.Location.Y.ToString() + ", " + NextWaypoint.Location.Z.ToString());
                }
            }
        }
Exemple #8
0
            protected override void OnTick()
            {
                if (m_UOACZSpawner == null)
                {
                    Stop();
                    return;
                }

                if (m_UOACZSpawner.Deleted)
                {
                    Stop();
                    return;
                }

                if (!UOACZRegion.ContainsItem(m_UOACZSpawner))
                {
                    return;
                }
                if (!UOACZPersistance.Active)
                {
                    return;
                }
                if (!m_UOACZSpawner.Activated || m_UOACZSpawner.RootParentEntity != null)
                {
                    return;
                }

                if (m_UOACZSpawner.TotalSpawnsOccured >= m_UOACZSpawner.MaxTotalSpawns)
                {
                    return;
                }

                int spawnsNeeded = m_UOACZSpawner.GetAvailableSpawnAmount();

                if (spawnsNeeded == 0)
                {
                    m_UOACZSpawner.m_LastActivity = DateTime.UtcNow;

                    double spawnDelay = m_UOACZSpawner.m_MinSpawnTime + (Utility.RandomDouble() * (m_UOACZSpawner.m_MaxSpawnTime - m_UOACZSpawner.m_MinSpawnTime));
                    m_UOACZSpawner.m_NextActivity = TimeSpan.FromMinutes(spawnDelay);

                    return;
                }

                DateTime nextSpawnTime = m_UOACZSpawner.m_LastActivity + m_UOACZSpawner.m_NextActivity;

                if (nextSpawnTime <= DateTime.UtcNow)
                {
                    int spotsSpawned = 0;

                    if (spawnsNeeded > 0)
                    {
                        if (!m_UOACZSpawner.SpawnAllAvailable)
                        {
                            spawnsNeeded = 1;
                        }

                        m_UOACZSpawner.PerformSpawns(spawnsNeeded);

                        m_UOACZSpawner.m_LastActivity = DateTime.UtcNow;

                        double spawnDelay = m_UOACZSpawner.m_MinSpawnTime + (Utility.RandomDouble() * (m_UOACZSpawner.m_MaxSpawnTime - m_UOACZSpawner.m_MinSpawnTime));
                        m_UOACZSpawner.m_NextActivity = TimeSpan.FromMinutes(spawnDelay);
                    }
                }
            }
Exemple #9
0
        public virtual void PerformSpawns(int spawnsNeeded)
        {
            for (int a = 0; a < spawnsNeeded; a++)
            {
                bool spawnCreated = false;

                for (int b = 0; b < 25; b++)
                {
                    if (spawnCreated)
                    {
                        break;
                    }

                    Point3D newLocation = new Point3D();

                    int x = X;

                    int xOffset = Utility.RandomMinMax(0, SpawnRange);
                    if (Utility.RandomDouble() >= .5)
                    {
                        xOffset *= -1;
                    }

                    x += xOffset;

                    int y = Y;

                    int yOffset = Utility.RandomMinMax(0, SpawnRange);
                    if (Utility.RandomDouble() >= .5)
                    {
                        yOffset *= -1;
                    }

                    y += yOffset;

                    newLocation.X = x;
                    newLocation.Y = y;
                    newLocation.Z = Z;

                    SpellHelper.AdjustField(ref newLocation, Map, 12, false);

                    UOACZSpawnRedirector spawnRedirector = null;

                    if (!IgnoreRedirector)
                    {
                        foreach (UOACZSpawnRedirector redirector in UOACZSpawnRedirector.m_Instances)
                        {
                            if (!UOACZRegion.ContainsItem(redirector))
                            {
                                continue;
                            }

                            if (Utility.GetDistance(redirector.Location, newLocation) <= redirector.TriggerRadius)
                            {
                                spawnRedirector = redirector;
                                break;
                            }
                        }
                    }

                    if (spawnRedirector != null)
                    {
                        newLocation.X = spawnRedirector.Location.X + Utility.RandomMinMax(-1 * spawnRedirector.TriggerRadius, spawnRedirector.TriggerRadius);
                        newLocation.Y = spawnRedirector.Location.Y + Utility.RandomMinMax(-1 * spawnRedirector.TriggerRadius, spawnRedirector.TriggerRadius);
                        newLocation.Z = spawnRedirector.Location.Z;

                        int redirectionX = 0;
                        int redirectionY = 0;

                        switch (Utility.RandomMinMax(1, 3))
                        {
                        case 1:
                            redirectionX = Utility.RandomMinMax(spawnRedirector.MinRedirection, spawnRedirector.MaxRedirection);

                            if (Utility.RandomDouble() <= .5)
                            {
                                redirectionX *= -1;
                            }

                            newLocation.X = spawnRedirector.Location.X + redirectionX;
                            break;

                        case 2:
                            redirectionY = Utility.RandomMinMax(spawnRedirector.MinRedirection, spawnRedirector.MaxRedirection);

                            if (Utility.RandomDouble() <= .5)
                            {
                                redirectionY *= -1;
                            }

                            newLocation.Y = spawnRedirector.Location.Y + redirectionY;
                            break;

                        case 3:
                            redirectionX = Utility.RandomMinMax(spawnRedirector.MinRedirection, spawnRedirector.MaxRedirection);

                            if (Utility.RandomDouble() <= .5)
                            {
                                redirectionX *= -1;
                            }

                            newLocation.X = spawnRedirector.Location.X + redirectionX;

                            redirectionY = Utility.RandomMinMax(spawnRedirector.MinRedirection, spawnRedirector.MaxRedirection);

                            if (Utility.RandomDouble() <= .5)
                            {
                                redirectionY *= -1;
                            }

                            newLocation.Y = spawnRedirector.Location.Y + redirectionY;
                            break;
                        }

                        SpellHelper.AdjustField(ref newLocation, Map, 12, false);
                    }

                    bool areaIsBlocked = false;

                    foreach (UOACZSpawnAreaBlocker spawnAreaBlocker in UOACZSpawnAreaBlocker.m_Instances)
                    {
                        if (!UOACZRegion.ContainsItem(spawnAreaBlocker))
                        {
                            continue;
                        }

                        if (spawnAreaBlocker.BlockedArea.Contains(newLocation))
                        {
                            areaIsBlocked = true;
                            break;
                        }
                    }

                    if (areaIsBlocked)
                    {
                        continue;
                    }

                    if (UOACZSystem.IsValidSpawnLocation(newLocation, Map, CheckSpawnForAdjacentBlocking))
                    {
                        Spawn(newLocation, Map);

                        TotalSpawnsOccured++;

                        m_LastActivity = DateTime.UtcNow;
                        spawnCreated   = true;
                    }
                }
            }
        }
Exemple #10
0
        public override void OnThink()
        {
            base.OnThink();

            Point3D location = Location;
            Map     map      = Map;

            //Outside of Guard Area
            if (GuardsHome && !(ControlMaster is PlayerMobile))
            {
                if (Utility.GetDistance(Home, location) > MaxDistanceAllowedFromHome)
                {
                    TimedStatic dirt = new TimedStatic(Utility.RandomList(7681, 7682), 5);
                    dirt.Name = "dirt";
                    dirt.MoveToWorld(location, map);

                    dirt.PublicOverheadMessage(MessageType.Regular, 0, false, ReturnHomeString);

                    Effects.PlaySound(location, map, 0x657);

                    int projectiles   = 6;
                    int particleSpeed = 4;

                    for (int a = 0; a < projectiles; a++)
                    {
                        Point3D newLocation = new Point3D(location.X + Utility.RandomList(-5, -4, -3, -2, -1, 1, 2, 3, 4, 5), location.Y + Utility.RandomList(-5, -4, -3, -2, -1, 1, 2, 3, 4, 5), location.Z);
                        SpellHelper.AdjustField(ref newLocation, map, 12, false);

                        IEntity effectStartLocation = new Entity(Serial.Zero, new Point3D(location.X, location.Y, location.Z + 5), map);
                        IEntity effectEndLocation   = new Entity(Serial.Zero, new Point3D(newLocation.X, newLocation.Y, newLocation.Z + 5), map);

                        Effects.SendMovingEffect(effectStartLocation, effectEndLocation, Utility.RandomList(0x3728), particleSpeed, 0, false, false, 0, 0);
                    }

                    Location  = Home;
                    Combatant = null;

                    return;
                }
            }

            if (m_NeedWaypoint && m_CanTeleportToBaseNode && !(ControlMaster is PlayerMobile))
            {
                Dictionary <UOACZWayPoint, int> DictWaypoints = new Dictionary <UOACZWayPoint, int>();

                foreach (UOACZWayPoint waypoint in UOACZWayPoint.m_UOACZWaypoints)
                {
                    if (!UOACZRegion.ContainsItem(waypoint))
                    {
                        continue;
                    }
                    if (!waypoint.IsBaseNode)
                    {
                        continue;
                    }

                    int distanceToWaypoint = (Utility.GetDistance(Location, waypoint.Location));

                    if (distanceToWaypoint >= UOACZSystem.UndeadMaxDynamicWaypointRange)
                    {
                        continue;
                    }

                    int distanceWeight = (int)(Math.Round(((double)UOACZSystem.UndeadMaxDynamicWaypointRange - (double)distanceToWaypoint) * .05));

                    if (distanceWeight < 1)
                    {
                        distanceWeight = 1;
                    }

                    DictWaypoints.Add(waypoint, distanceWeight);
                }

                if (DictWaypoints.Count > 0)
                {
                    int TotalValues = 0;

                    foreach (KeyValuePair <UOACZWayPoint, int> pair in DictWaypoints)
                    {
                        TotalValues += pair.Value;
                    }

                    double ItemCheck = Utility.RandomDouble();

                    double CumulativeAmount = 0.0;
                    double AdditionalAmount = 0.0;

                    foreach (KeyValuePair <UOACZWayPoint, int> pair in DictWaypoints)
                    {
                        AdditionalAmount = (double)pair.Value / (double)TotalValues;

                        if (ItemCheck >= CumulativeAmount && ItemCheck < (CumulativeAmount + AdditionalAmount))
                        {
                            UOACZWayPoint waypoint = pair.Key;

                            if (waypoint != null)
                            {
                                if (!waypoint.Deleted)
                                {
                                    CurrentWaypoint = pair.Key;
                                    m_NeedWaypoint  = false;

                                    return;
                                }
                            }

                            break;
                        }

                        CumulativeAmount += AdditionalAmount;
                    }
                }

                else
                {
                    m_NeedWaypoint = false;
                }
            }

            if ((DateTime.UtcNow >= m_LastActivity + InactivityThreshold) && !(ControlMaster is PlayerMobile))
            {
                //Send to Random Town Waypoint BaseNode
                if (m_CanTeleportToBaseNode)
                {
                    List <UOACZWayPoint> m_ValidBaseNodes = new List <UOACZWayPoint>();

                    foreach (UOACZWayPoint waypoint in UOACZWayPoint.m_UOACZWaypoints)
                    {
                        if (waypoint == null)
                        {
                            continue;
                        }
                        if (waypoint.Deleted)
                        {
                            continue;
                        }
                        if (!UOACZRegion.ContainsItem(waypoint))
                        {
                            continue;
                        }
                        if (!waypoint.IsBaseNode)
                        {
                            continue;
                        }
                        if (waypoint.WaypointType == UOACZWayPoint.UOACZWaypointType.UndeadWilderness)
                        {
                            continue;
                        }

                        m_ValidBaseNodes.Add(waypoint);
                    }

                    if (m_ValidBaseNodes.Count > 0)
                    {
                        UOACZWayPoint targetWaypoint = m_ValidBaseNodes[Utility.RandomMinMax(0, m_ValidBaseNodes.Count - 1)];

                        MoveToWorld(targetWaypoint.Location, targetWaypoint.Map);
                        CurrentWaypoint = targetWaypoint;
                        m_LastActivity  = DateTime.UtcNow;

                        m_NeedWaypoint = false;
                        return;
                    }
                }

                m_NeedWaypoint = true;
                return;
            }

            if (Utility.RandomDouble() < 0.005)
            {
                if (Combatant == null)
                {
                    Say(idleSpeech[Utility.Random(idleSpeech.Length - 1)]);
                }

                else
                {
                    Say(combatSpeech[Utility.Random(combatSpeech.Length - 1)]);
                }
            }

            bool ignoreBreakableStatics = false;

            if (Hidden && ControlMaster is PlayerMobile)
            {
                ignoreBreakableStatics = true;
            }

            if (DateTime.UtcNow >= m_NextBreakableStaticCheckAllowed && DateTime.UtcNow >= m_NextBreakableStaticAttackAllowed && !ignoreBreakableStatics)
            {
                m_NextBreakableStaticCheckAllowed = DateTime.UtcNow + BreakableStaticCheckDelay;

                BreakableStatic targetBreakableStatic = null;
                Dictionary <BreakableStatic, int> DictBreakableStatics = new Dictionary <BreakableStatic, int>();

                IPooledEnumerable nearbyItems = Map.GetItemsInRange(Location, 1);

                foreach (Item item in nearbyItems)
                {
                    if (item.Deleted)
                    {
                        continue;
                    }

                    if (item is BreakableStatic)
                    {
                        if (!Map.InLOS(Location, item.Location))
                        {
                            continue;
                        }

                        BreakableStatic breakableStatic = item as BreakableStatic;

                        if (breakableStatic is UOACZBreakableStatic)
                        {
                            UOACZBreakableStatic uoaczBreakableStatic = breakableStatic as UOACZBreakableStatic;

                            if (uoaczBreakableStatic.AllowHumanDamage)
                            {
                                continue;
                            }
                        }

                        if (breakableStatic.DamageState == BreakableStatic.DamageStateType.Broken)
                        {
                            continue;
                        }

                        int weight = 5;

                        if (breakableStatic == m_LastBreakableStaticAttacked)
                        {
                            weight += 10;
                        }

                        int damageBonus = (int)Math.Round((10 * (1 - (double)breakableStatic.HitPoints / (double)breakableStatic.MaxHitPoints)));

                        weight += damageBonus;

                        DictBreakableStatics.Add(breakableStatic, weight);
                    }
                }

                nearbyItems.Free();

                int TotalValues = 0;

                foreach (KeyValuePair <BreakableStatic, int> pair in DictBreakableStatics)
                {
                    TotalValues += pair.Value;
                }

                double ItemCheck = Utility.RandomDouble();

                double CumulativeAmount = 0.0;
                double AdditionalAmount = 0.0;

                foreach (KeyValuePair <BreakableStatic, int> pair in DictBreakableStatics)
                {
                    AdditionalAmount = (double)pair.Value / (double)TotalValues;

                    if (ItemCheck >= CumulativeAmount && ItemCheck < (CumulativeAmount + AdditionalAmount))
                    {
                        targetBreakableStatic = pair.Key;
                        break;
                    }

                    CumulativeAmount += AdditionalAmount;
                }

                if (targetBreakableStatic != null)
                {
                    double minHinder = 1;
                    double maxHinder = 1;

                    double weaponUsageDelay = 3;

                    BaseWeapon weapon = Weapon as BaseWeapon;

                    if (weapon != null)
                    {
                        weaponUsageDelay = weapon.GetDelay(this, false).TotalSeconds;
                    }

                    bool stockpileNearby = false;

                    if (targetBreakableStatic is UOACZStockpile)
                    {
                        stockpileNearby = true;
                    }

                    else
                    {
                        switch (targetBreakableStatic.DamageState)
                        {
                        case BreakableStatic.DamageStateType.Normal:
                            minHinder = weaponUsageDelay * .5;
                            maxHinder = weaponUsageDelay;
                            break;

                        case BreakableStatic.DamageStateType.LightlyDamaged:
                            minHinder = weaponUsageDelay * .65;
                            maxHinder = weaponUsageDelay;
                            break;

                        case BreakableStatic.DamageStateType.HeavilyDamaged:
                            minHinder = weaponUsageDelay * .8;
                            maxHinder = weaponUsageDelay;
                            break;
                        }
                    }

                    double delay = minHinder + ((maxHinder - minHinder) * Utility.RandomDouble());

                    if (ControlMaster is PlayerMobile)
                    {
                        delay = 1;
                        SpecialAbilities.EntangleSpecialAbility(1.0, null, this, 1, delay, 0, false, "", "", "-1");
                    }

                    else
                    {
                        if (stockpileNearby)
                        {
                            delay = 10;

                            SpecialAbilities.EntangleSpecialAbility(1.0, null, this, 1, delay, 0, false, "", "", "-1");
                            m_NextBreakableStaticAttackAllowed = DateTime.UtcNow + BreakableStaticAttackDelay;
                        }

                        else
                        {
                            if (Utility.RandomDouble() <= .5)
                            {
                                SpecialAbilities.HinderSpecialAbility(1.0, null, this, 1, delay, true, 0, false, "", "", "-1");
                            }

                            else
                            {
                                SpecialAbilities.EntangleSpecialAbility(1.0, null, this, 1, delay, 0, false, "", "", "-1");
                            }

                            m_NextBreakableStaticAttackAllowed = DateTime.UtcNow + BreakableStaticAttackDelay;
                        }
                    }

                    targetBreakableStatic.Interact(this, BreakableStatic.InteractionType.Weapon);
                }
            }
        }
        public override void Spawn(Point3D point, Map map)
        {
            if (!UOACZPersistance.Active)
            {
                return;
            }

            int creatureThreatLevel = UOACZPersistance.m_ThreatLevel;

            if (!m_Wilderness)
            {
                creatureThreatLevel -= 30;
            }

            int minThreatLevel = 0;
            int maxThreatLevel = creatureThreatLevel;

            if (m_MinThreatLevel > -1)
            {
                minThreatLevel = m_MinThreatLevel;
            }

            if (m_MaxThreatLevel > -1)
            {
                maxThreatLevel = m_MaxThreatLevel;
            }

            Type creatureType = UOACZBaseUndead.GetRandomUndeadType(minThreatLevel, maxThreatLevel);

            if (creatureType != null)
            {
                UOACZBaseUndead creature = (UOACZBaseUndead)Activator.CreateInstance(creatureType);

                if (creature != null)
                {
                    creature.RangeHome             = HomeRange;
                    creature.Home                  = point;
                    creature.m_Spawner             = this;
                    creature.InWilderness          = m_Wilderness;
                    creature.CanTeleportToBaseNode = m_AllowTeleportToBaseNode;

                    creature.MoveToWorld(point, map);
                    m_Mobiles.Add(creature);

                    if (m_AllowTeleportToBaseNode)
                    {
                        if (m_GotoSplitGroup == -1)
                        {
                            creature.m_NeedWaypoint = true;
                        }

                        else
                        {
                            UOACZWayPoint closestWaypoint         = null;
                            int           closestWaypointDistance = 100000;

                            foreach (UOACZWayPoint waypoint in UOACZWayPoint.m_UOACZWaypoints)
                            {
                                if (waypoint == null)
                                {
                                    continue;
                                }
                                if (waypoint.Deleted)
                                {
                                    continue;
                                }
                                if (waypoint.m_GotoSplitGroup == -1)
                                {
                                    continue;
                                }
                                if (!UOACZRegion.ContainsItem(waypoint))
                                {
                                    continue;
                                }
                                if (waypoint.WaypointType == UOACZWayPoint.UOACZWaypointType.UndeadTown && m_Wilderness)
                                {
                                    continue;
                                }
                                if (waypoint.WaypointType == UOACZWayPoint.UOACZWaypointType.UndeadWilderness && !m_Wilderness)
                                {
                                    continue;
                                }

                                if (waypoint.SplitGroup == m_GotoSplitGroup)
                                {
                                    int distanceToWaypoint = Utility.GetDistance(creature.Location, waypoint.Location);

                                    if (distanceToWaypoint <= closestWaypointDistance)
                                    {
                                        closestWaypoint         = waypoint;
                                        closestWaypointDistance = distanceToWaypoint;
                                    }
                                }
                            }

                            if (closestWaypoint != null)
                            {
                                creature.CurrentWaypoint = closestWaypoint;
                            }
                        }
                    }
                }
            }
        }