Exemple #1
0
        /// <summary>
        /// Calculate time for midnight.
        /// </summary>
        private static double ComputeMidnightTime(Midnight method, double fajr, double sunrise, double sunset)
        {
            var duration     = method == Midnight.Jafari ? DateTimeMath.ComputeDuration(fajr, sunset) : DateTimeMath.ComputeDuration(sunrise, sunset);
            var midnightTime = sunset + (duration / 2.0);

            return(midnightTime);
        }
Exemple #2
0
 /// <summary>
 ///     Sets the calculation method parameters using custom parameters.
 /// </summary>
 /// <param name="fajrAngleParameter">
 ///     Custom fajr prayer angle calculation parameter.
 /// </param>
 /// <param name="maghribParameter">
 ///     Custom maghrib prayer calculation parameter value.
 /// </param>
 /// <param name="maghribParameterType">
 ///     Custom maghrib prayer calculation parameter type.
 /// </param>
 /// <param name="ishaParameter">
 ///     Custom isha prayer calculation parameter value.
 /// </param>
 /// <param name="ishaParameterType">
 ///     Custom isha prayer calculation parameter type.
 /// </param>
 /// <param name="midnight">
 ///     Midnight time calculation method.
 /// </param>
 public void SetCustomCalculationMethod(double fajrAngleParameter,
                                        double maghribParameter,
                                        PrayerCalculationParameterType maghribParameterType,
                                        double ishaParameter,
                                        PrayerCalculationParameterType ishaParameterType,
                                        Midnight midnight)
 {
     Preset = CalculationMethodPreset.Custom;
     FajrParameter.Value    = fajrAngleParameter;
     FajrParameter.Type     = PrayerCalculationParameterType.Angle;
     MaghribParameter.Value = maghribParameter;
     MaghribParameter.Type  = maghribParameterType;
     IshaParameter.Value    = ishaParameter;
     IshaParameter.Type     = ishaParameterType;
     MidnightMethod         = midnight;
 }
Exemple #3
0
        public override void UpdateAI(uint diff)
        {
            if (ResetTimer != 0)
            {
                if (ResetTimer <= diff)
                {
                    ResetTimer = 0;
                    Unit pMidnight = Global.ObjAccessor.GetUnit(me, Midnight);
                    if (pMidnight)
                    {
                        pMidnight.RemoveFlag(UnitFields.Flags, UnitFlags.NonAttackable);
                        pMidnight.SetVisible(true);
                    }
                    Midnight.Clear();
                    me.SetVisible(false);
                    me.KillSelf();
                }
                else
                {
                    ResetTimer -= diff;
                }
            }

            //Return since we have no target
            if (!UpdateVictim())
            {
                return;
            }

            if (me.HasFlag(UnitFields.Flags, UnitFlags.NonAttackable | UnitFlags.NotSelectable))
            {
                return;
            }

            if (CleaveTimer <= diff)
            {
                DoCastVictim(SpellIds.Shadowcleave);
                CleaveTimer = RandomHelper.URand(10000, 15000);
            }
            else
            {
                CleaveTimer -= diff;
            }

            if (CurseTimer <= diff)
            {
                DoCastVictim(SpellIds.IntangiblePresence);
                CurseTimer = 30000;
            }
            else
            {
                CurseTimer -= diff;
            }

            if (RandomYellTimer <= diff)
            {
                Talk(TextIds.SayRandom);
                RandomYellTimer = RandomHelper.URand(30000, 60000);
            }
            else
            {
                RandomYellTimer -= diff;
            }

            if (me.GetUInt32Value(UnitFields.DisplayId) == Misc.MountedDisplayid)
            {
                if (ChargeTimer <= diff)
                {
                    var         t_list      = me.GetThreatManager().getThreatList();
                    List <Unit> target_list = new List <Unit>();
                    foreach (var hostileRefe in t_list)
                    {
                        var unit = Global.ObjAccessor.GetUnit(me, hostileRefe.getUnitGuid());
                        if (unit && !unit.IsWithinDist(me, SharedConst.AttackDistance, false))
                        {
                            target_list.Add(unit);
                        }
                        unit = null;
                    }
                    Unit target = null;
                    if (!target_list.Empty())
                    {
                        target = target_list.SelectRandom();
                    }

                    DoCast(target, SpellIds.BerserkerCharge);
                    ChargeTimer = 20000;
                }
                else
                {
                    ChargeTimer -= diff;
                }
            }
            else
            {
                if (HealthBelowPct(25))
                {
                    Creature pMidnight = ObjectAccessor.GetCreature(me, Midnight);
                    if (pMidnight && pMidnight.IsTypeId(TypeId.Unit))
                    {
                        ((boss_midnight)pMidnight.GetAI()).Mount(me);
                        me.SetHealth(pMidnight.GetHealth());
                        DoResetThreat();
                    }
                }
            }

            DoMeleeAttackIfReady();
        }
Exemple #4
0
 public override void Reset()
 {
     ResetTimer = 0;
     Midnight.Clear();
 }
Exemple #5
0
        /// <summary>
        ///     Sets the calculation method parameters from given method preset.
        /// </summary>
        /// <param name="instant">
        ///     <see cref="Instant" /> of time.
        /// </param>
        /// <param name="preset">
        ///     <see cref="CalculationMethodPreset" /> to set.
        /// </param>
        public void SetCalculationMethodPreset(Instant instant, CalculationMethodPreset preset)
        {
            //
            // Umm Al-Qura University, Makkah
            if (preset == CalculationMethodPreset.UmmAlQuraUniversity)
            {
                // Convert Gregorian date to Hijri.
                var calendarSystem = CalendarSystem.IslamicBcl;
                var hijri          = instant.InUtc().WithCalendar(calendarSystem);
                var isBefore1430H  = hijri.Year < 1430;
                var isRamadhan     = hijri.Month == 9;

                Preset = CalculationMethodPreset.UmmAlQuraUniversity;
                FajrParameter.Value    = isBefore1430H ? 19 : 18.5;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = isRamadhan ? 120.0 : 90.0;
                IshaParameter.Type     = PrayerCalculationParameterType.MinutesAdjust;
                MidnightMethod         = Midnight.Standard;
                return;
            }

            switch (preset)
            {
            case CalculationMethodPreset.IthnaAshari:
                Preset = CalculationMethodPreset.IthnaAshari;
                FajrParameter.Value    = 16.0;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 4.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.Angle;
                IshaParameter.Value    = 14.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Jafari;
                return;

            case CalculationMethodPreset.UniversityOfIslamicSciencesKarachi:
                Preset = CalculationMethodPreset.UniversityOfIslamicSciencesKarachi;
                FajrParameter.Value    = 18.0;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = 18.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Standard;
                return;

            case CalculationMethodPreset.IslamicSocietyOfNorthAmerica:
                Preset = CalculationMethodPreset.IslamicSocietyOfNorthAmerica;
                FajrParameter.Value    = 15.0;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = 15.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Standard;
                return;

            case CalculationMethodPreset.MuslimWorldLeague:
                Preset = CalculationMethodPreset.MuslimWorldLeague;
                FajrParameter.Value    = 18.0;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = 17.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Standard;
                return;

            case CalculationMethodPreset.EgyptianGeneralAuthorityOfSurvey:
                Preset = CalculationMethodPreset.EgyptianGeneralAuthorityOfSurvey;
                FajrParameter.Value    = 19.5;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = 17.5;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Standard;
                return;

            case CalculationMethodPreset.InstituteOfGeophysicsUniversityOfTehran:
                Preset = CalculationMethodPreset.InstituteOfGeophysicsUniversityOfTehran;
                FajrParameter.Value    = 17.7;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 4.5;
                MaghribParameter.Type  = PrayerCalculationParameterType.Angle;
                IshaParameter.Value    = 14.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Jafari;
                return;

            case CalculationMethodPreset.UnionDesOrganisationsIslamiquesDeFrance:
                Preset = CalculationMethodPreset.UnionDesOrganisationsIslamiquesDeFrance;
                FajrParameter.Value    = 12.0;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = 12.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Standard;
                return;

            case CalculationMethodPreset.MajlisUgamaIslamSingapura:
                Preset = CalculationMethodPreset.MajlisUgamaIslamSingapura;
                FajrParameter.Value    = 20.0;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = 18.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Standard;
                return;

            case CalculationMethodPreset.DepartmentOfIslamicAdvancementOfMalaysia:
                Preset = CalculationMethodPreset.DepartmentOfIslamicAdvancementOfMalaysia;
                FajrParameter.Value    = 20.0;
                FajrParameter.Type     = PrayerCalculationParameterType.Angle;
                MaghribParameter.Value = 0.0;
                MaghribParameter.Type  = PrayerCalculationParameterType.MinutesAdjust;
                IshaParameter.Value    = 18.0;
                IshaParameter.Type     = PrayerCalculationParameterType.Angle;
                MidnightMethod         = Midnight.Standard;
                return;

            default:
                throw new ArgumentOutOfRangeException(nameof(preset));
            }
        }