コード例 #1
0
        public static JsonSpellRange FromXml(SpellRange range)
        {
            if (range == null)
            {
                return(null);
            }

            return(new JsonSpellRange
            {
                Unit = range.Unit.ToString().ToCamelCase(),
                Value = range.SpecificValue,
            });
        }
コード例 #2
0
    void LoadSpellRanges()
    {
        SpellRanges = new Dictionary <int, SpellRange>();

        // Self cast : Referenced in spell helper
        var spellRange = new SpellRange()
        {
            Id    = 1,
            Flags = SpellRangeFlag.DEFAULT,
        };

        SpellRanges.Add(spellRange.Id, spellRange);
    }
コード例 #3
0
        public static bool Safe_CastSpell(WoWUnit unit, int spellId, SpellRange chkRng, SpellWait chkWait)
        {
            try
            {
                WoWSpell spell = WoWSpell.FromId(spellId);
                if (spell != null)
                    return Safe_CastSpell(unit, spell, chkRng, chkWait);
            }
            catch
            {
                ;
            }

            Slog("Error:  attempt to cast unknown spell #{0}", spellId);
            return false;
        }
コード例 #4
0
        public static bool Safe_CastSpell(WoWUnit unit, int spellId, SpellRange chkRng, SpellWait chkWait)
        {
            try
            {
                WoWSpell spell = WoWSpell.FromId(spellId);
                if (spell != null)
                {
                    return(Safe_CastSpell(unit, spell, chkRng, chkWait));
                }
            }
            catch
            {
                ;
            }

            Slog("Error:  attempt to cast unknown spell #{0}", spellId);
            return(false);
        }
コード例 #5
0
ファイル: SpellService.cs プロジェクト: JackSchaible/ganymede
        private Spell MapValues(Spell spell, string userId)
        {
            CastingTime time = _ctx.CastingTimes.FirstOrDefault(c => c.Amount == spell.CastingTime.Amount && c.Unit == spell.CastingTime.Unit && c.ReactionCondition == spell.CastingTime.ReactionCondition && c.Type == (int)spell.CastingTime.Type);

            if (time != null)
            {
                spell.CastingTime   = time;
                spell.CastingTimeID = time.ID;
            }

            SpellComponents components = _ctx.SpellComponents.FirstOrDefault(c => c.Somatic == spell.SpellComponents.Somatic && c.Verbal == spell.SpellComponents.Verbal && spell.SpellComponents.Material == c.Material);

            if (components != null)
            {
                spell.SpellComponents   = components;
                spell.SpellComponentsID = components.ID;
            }

            SpellDuration duration = _ctx.SpellDurations.FirstOrDefault(d => d.Amount == spell.SpellDuration.Amount && d.Concentration == spell.SpellDuration.Concentration && d.Type == spell.SpellDuration.Type && d.Unit == spell.SpellDuration.Unit && d.UpTo == spell.SpellDuration.UpTo);

            if (duration != null)
            {
                spell.SpellDuration   = duration;
                spell.SpellDurationID = duration.ID;
            }

            SpellRange range = _ctx.SpellRanges.FirstOrDefault(r => r.Amount == spell.SpellRange.Amount && r.Type == spell.SpellRange.Type && r.Shape == spell.SpellRange.Shape && r.Unit == spell.SpellRange.Unit);

            if (range != null)
            {
                spell.SpellRange   = range;
                spell.SpellRangeID = range.ID;
            }

            spell.Campaign   = _ctx.Campaigns.Where(c => c.ID == spell.CampaignID && c.AppUserId == userId).Single();
            spell.CampaignID = spell.Campaign.ID;

            return(spell);
        }
コード例 #6
0
 public Spell(Guid id, string spellName, string school, string components, string castingTime, SpellRange range, string customRange, string target, string area, string duration,
              SaveKind fortitudeSave, string customFortitudeSave, SaveKind reflexSave, string customReflexSave, SaveKind willSave, string customWillSave, SpellResistance spellResistance, string notes)
 {
     Id                  = id;
     SpellName           = spellName;
     School              = school;
     Components          = components;
     CastingTime         = castingTime;
     Range               = range;
     CustomRange         = customRange;
     Target              = target;
     Area                = area;
     Duration            = duration;
     FortitudeSave       = fortitudeSave;
     CustomFortitudeSave = customFortitudeSave;
     ReflexSave          = reflexSave;
     CustomReflexSave    = customReflexSave;
     WillSave            = willSave;
     CustomWillSave      = customWillSave;
     SpellResistance     = spellResistance;
     Notes               = notes;
 }
コード例 #7
0
        public static bool Safe_CastSpell(WoWUnit unit, string sSpellName, SpellRange chkRng, SpellWait chkWait)
        {
            WoWSpell spell = null;

            try
            {
                // spell = SpellManager.Spells[sSpellName];
                spell = SpellManager.Spells[sSpellName];
                System.Diagnostics.Debug.Assert(spell != null);
            }
            catch (ThreadAbortException) { throw; }
            catch (Exception e)
            {
                Log(Color.Red, "An Exception occured. Check debug log for details.");
                Logging.WriteDebug(">>> HB EXCEPTION in SpellManager.Spells[" + sSpellName + "]");
                Logging.WriteDebug(">>> Spell '" + sSpellName + "' believed to be " + (SpellManager.HasSpell(sSpellName) ? "KNOWN" : "UNKNOWN") + " was used ");
                Logging.WriteException(e);
                throw;
                // return false;
            }

            return(Safe_CastSpell(unit, spell, chkRng, chkWait));
        }
コード例 #8
0
        /// <summary>
        /// Chooses a nearby target for healing.  Selection is based upon
        /// which nearby friendly needs heals.  Includes _me in list so
        /// will handle self-healing to you low
        /// </summary>
        /// <returns>WOWPlayer reference of nearby player needing heals</returns>
        public static WoWPlayer ChooseHealTarget(double healLessThan, SpellRange rchk)
        {
#if COMMENT
            // use timer to ensure we aren't constantly rebuilding the list
            // .. player health and distance are very dynamic, but the number of players
            // .. in the vicinity won't change drastically in that time
            //--- NOTE:  timer is initially zero so first call builds list
            if (_healTargets == null || _refreshTimer.Done)
            {
                CreateHealTargetList();
            }

            _healTargets.Sort(CompareHealPriority);

#if LIST_HEAL_TARGETS
            for (int b = 0; b < _healTargets.Count; b++)
            {
                Slog("  {0:F0}% {1}[{2}] dist: {3:F1} in-los: {4}", _healTargets[b].HealthPercent, _healTargets[b].Name, _healTargets[b].Level, _healTargets[b].Distance, _healTargets[b].InLineOfSight);
            }
            Slog("  Total of " + _healTargets.Count);
#endif

            // restrict to 39 if movement has been disabled (so we only heal those within range of users movement)
            double searchFilter = IsMovementDisabled() ? 39 : cfg.GroupHeal.SearchRange;

            WoWPlayer lowPlayer = null;

            Dlog("ChooseHealTarget: checking {0} players within {1} yards", _healTargets.Count(), searchFilter);

            // Me and Tank okay, so choose lowest health player
            for (int a = 0; a < _healTargets.Count; a++)
            {
                try
                {
                    if (!Safe_IsValid(_healTargets[a]))
                    {
                        Dlog("ChooseHealTarget: entry[{0}] failed Safe_IsValid()", a);
                        continue;
                    }
                    if (!ObjectManager.ObjectList.Contains(_healTargets[a]))
                    {
                        Dlog("ChooseHealTarget: entry[{0}] failed Is In ObjectList()", a);
                        continue;
                    }

                    // stop looking in sorted list if we reach healing threshhold
                    if (_healTargets[a].HealthPercent > healLessThan)
                    {
                        Dlog("ChooseHealTarget:  no player currently below {0}%", healLessThan);
                        break;
                    }

                    // if target is out of range, then skip this entry
                    if (_healTargets[a].Distance > searchFilter)
                    {
                        continue;
                    }

                    // since we don't rebuild the list each time, always need to retest for dead players
                    if (_healTargets[a].CurrentHealth <= 1) // _healTargets[a].Dead || _healTargets[a].IsGhost
                    {
                        Dlog("ChooseHealTarget:  entry[{0}] is dead", a);
                    }
                    else if (rchk == SpellRange.NoCheck || (_healTargets[a].Distance < 39 && _healTargets[a].InLineOfSightOCD))
                    {
                        Dlog("ChooseHealTarget: {0}[{1}] at {2:F0}% dist: {3:F1} in-los: {4}", Safe_UnitName(_healTargets[a]), _healTargets[a].Level, _healTargets[a].HealthPercent, _healTargets[a].Distance, _healTargets[a].InLineOfSightOCD);
                        lowPlayer = _healTargets[a];
                        break;
                    }
                }
                catch (ThreadAbortException) { throw; }
                catch
                {
                    // if exception dealing with this WoWUnit, then try next in array
                    Dlog("ChooseHealTarget:  exception occurred accessing entry[{0}]", a);
                }
            }

            minGroupHealth = (int)(lowPlayer == null ? 100 : lowPlayer.HealthPercent);

            // if Me or the Tank (value in unitToSaveHeal) is at risk
            if (unitToSaveHeal != null && unitToSaveHeal.IsAlive)
            {
                if (rchk == SpellRange.NoCheck || (unitToSaveHeal.Distance < 38 && unitToSaveHeal.InLineOfSightOCD))
                {
                    Dlog("ChooseHealTarget: SAVING {0}[{1}] at {2:F0}% dist: {3:F1} in-los: {4}", Safe_UnitName(unitToSaveHeal), unitToSaveHeal.Level, unitToSaveHeal.HealthPercent, unitToSaveHeal.Distance, unitToSaveHeal.InLineOfSightOCD);
                    lowPlayer      = unitToSaveHeal.ToPlayer();
                    unitToSaveHeal = null;
                }
            }

            return(lowPlayer);
#else
            int       searchRange = IsMovementDisabled() ? 39 : (int)cfg.GroupHeal.SearchRange;
            WoWPlayer lowPlayer   = null;

            // heal Me or Tank if at risk
            try
            {
                if (unitToSaveHeal != null && unitToSaveHeal.CurrentHealth > 1)
                {
                    if (rchk == SpellRange.NoCheck || (unitToSaveHeal.Distance < 39 && unitToSaveHeal.InLineOfSightOCD))
                    {
                        Dlog("ChooseHealTarget: SAVING {0}[{1}] at {2:F0}% dist: {3:F1} in-los: {4}", Safe_UnitName(unitToSaveHeal), unitToSaveHeal.Level, unitToSaveHeal.HealthPercent, unitToSaveHeal.Distance, unitToSaveHeal.InLineOfSightOCD);
                        lowPlayer      = unitToSaveHeal.ToPlayer();
                        unitToSaveHeal = null;
                    }
                }
            }
            catch
            {
                // tank or healer needs saving but reference is invalid at the moment
                unitToSaveHeal = null;
            }

            // if no low player found yet, find if there is one
            if (lowPlayer == null)
            {
                try
                {
                    lowPlayer =
                        GroupMembers
                        .Where(u => CheckValidAndNearby(u, searchRange) && u.HealthPercent <= healLessThan)
                        .OrderBy(u => u.HealthPercent)
                        .FirstOrDefault();
                }
                catch (Exception e)
                {
                    Log(Color.Red, "An Exception occured. Check debug log for details.");
                    Logging.WriteDebug("HB EXCEPTION in ChooseHealTarget()");
                    Logging.WriteException(e);
                    lowPlayer = null;
                }
            }

            // now account for Me not being in GroupMembers
            if (lowPlayer == null)
            {
                lowPlayer = _me.HealthPercent <= healLessThan ? _me : null;
            }
            else if (_me.HealthPercent <= lowPlayer.HealthPercent)
            {
                lowPlayer = _me;
            }

            minGroupHealth = (int)(lowPlayer == null ? 100 : lowPlayer.HealthPercent);
            return(lowPlayer);
#endif
        }
コード例 #9
0
 public static Dictionary<int, SpellRange> LoadSpellRange()
 {
     Dictionary<int, SpellRange> list = new Dictionary<int, SpellRange>();
     SpellRange r0 = new SpellRange();
     r0.Description = "0 - 0";
     list.Add(0, r0);
     using (FileStream stream = File.OpenRead(DATA_PATH + "DBC/SpellRange.dbc"))
     {
         BinaryReader r = new BinaryReader(stream);
         DBCHeader header = DBC.ReadDBCHeader(r);
         int dataSize = header.RowSize * header.Records + 20;
         for (int i = 0; i != header.Records; ++i)
         {
             SpellRange range = new SpellRange();
             range.ID = r.ReadInt32();
             range.MinHostile = r.ReadSingle();
             range.MinFriend = r.ReadSingle();
             range.MaxHostile = r.ReadSingle();
             range.MaxFriend = r.ReadSingle();
             range.Type = r.ReadInt32();
             range.Name = DBC.ReadString(r, dataSize, 16, 44);
             r.ReadInt32(); // name flag
             range.ShortName = DBC.ReadString(r, dataSize, 16, 44);
             r.ReadInt32(); // name flag
             range.Description = String.Format("{4} - Hostile: {0:F2}-{1:F2} | Ally: {2:F2}-{3:F2}", range.MinHostile, range.MaxHostile, range.MinFriend, range.MaxFriend, range.ID);
             list.Add(range.ID, range);
         }
         r.Close();
         return list;
     }
 }
コード例 #10
0
        /// <summary>
        /// Chooses a nearby target for healing.  Selection is based upon
        /// which nearby friendly needs heals.  Includes _me in list so
        /// will handle self-healing to you low
        /// </summary>
        /// <returns>WOWPlayer reference of nearby player needing heals</returns>
        public static WoWPlayer ChooseHealTarget(double healLessThan, SpellRange rchk)
        {
#if COMMENT
            // use timer to ensure we aren't constantly rebuilding the list
            // .. player health and distance are very dynamic, but the number of players
            // .. in the vicinity won't change drastically in that time
            //--- NOTE:  timer is initially zero so first call builds list
            if (_healTargets == null || _refreshTimer.Done )
            {
                CreateHealTargetList();
            }

            _healTargets.Sort(CompareHealPriority);

#if LIST_HEAL_TARGETS
			for (int b = 0; b < _healTargets.Count; b++)
			{
				Slog("  {0:F0}% {1}[{2}] dist: {3:F1} in-los: {4}", _healTargets[b].HealthPercent, _healTargets[b].Name, _healTargets[b].Level, _healTargets[b].Distance, _healTargets[b].InLineOfSight );
			}
			Slog("  Total of " + _healTargets.Count);
#endif

            // restrict to 39 if movement has been disabled (so we only heal those within range of users movement)
            double searchFilter = IsMovementDisabled() ? 39 : cfg.GroupHeal.SearchRange;

            WoWPlayer lowPlayer = null;

            Dlog("ChooseHealTarget: checking {0} players within {1} yards", _healTargets.Count(), searchFilter );

            // Me and Tank okay, so choose lowest health player
            for (int a = 0; a < _healTargets.Count; a++)
            {
                try
                {
                    if (!Safe_IsValid(_healTargets[a]))
                    {
                        Dlog("ChooseHealTarget: entry[{0}] failed Safe_IsValid()", a);
                        continue;
                    }
                    if (!ObjectManager.ObjectList.Contains(_healTargets[a]))
                    {
                        Dlog("ChooseHealTarget: entry[{0}] failed Is In ObjectList()", a);
                        continue;
                    }

                    // stop looking in sorted list if we reach healing threshhold
                    if (_healTargets[a].HealthPercent > healLessThan)
                    {
                        Dlog("ChooseHealTarget:  no player currently below {0}%", healLessThan);
                        break;
                    }

                    // if target is out of range, then skip this entry
                    if (_healTargets[a].Distance > searchFilter )
                        continue;

                    // since we don't rebuild the list each time, always need to retest for dead players
                    if (_healTargets[a].CurrentHealth <= 1) // _healTargets[a].Dead || _healTargets[a].IsGhost
                    {
                        Dlog("ChooseHealTarget:  entry[{0}] is dead", a);
                    }
                    else if (rchk == SpellRange.NoCheck || (_healTargets[a].Distance < 39 && _healTargets[a].InLineOfSightOCD))
                    {
                        Dlog("ChooseHealTarget: {0}[{1}] at {2:F0}% dist: {3:F1} in-los: {4}", Safe_UnitName(_healTargets[a]), _healTargets[a].Level, _healTargets[a].HealthPercent, _healTargets[a].Distance, _healTargets[a].InLineOfSightOCD);
                        lowPlayer = _healTargets[a];
                        break;
                    }
                }
                catch (ThreadAbortException) { throw; }
                catch
                {
                    // if exception dealing with this WoWUnit, then try next in array
                    Dlog("ChooseHealTarget:  exception occurred accessing entry[{0}]", a);
                }
            }

            minGroupHealth = (int) (lowPlayer == null ? 100 : lowPlayer.HealthPercent);

            // if Me or the Tank (value in unitToSaveHeal) is at risk 
            if (unitToSaveHeal != null && unitToSaveHeal.IsAlive)
            {
                if (rchk == SpellRange.NoCheck || (unitToSaveHeal.Distance < 38 && unitToSaveHeal.InLineOfSightOCD))
                {
                    Dlog("ChooseHealTarget: SAVING {0}[{1}] at {2:F0}% dist: {3:F1} in-los: {4}", Safe_UnitName(unitToSaveHeal), unitToSaveHeal.Level, unitToSaveHeal.HealthPercent, unitToSaveHeal.Distance, unitToSaveHeal.InLineOfSightOCD);
                    lowPlayer = unitToSaveHeal.ToPlayer();
                    unitToSaveHeal = null;
                }
            }

            return lowPlayer;
#else
            int searchRange = IsMovementDisabled() ? 39 : (int) cfg.GroupHeal.SearchRange;
            WoWPlayer lowPlayer = null;

            // heal Me or Tank if at risk 
            try
            {
                if (unitToSaveHeal != null && unitToSaveHeal.CurrentHealth > 1)
                {
                    if (rchk == SpellRange.NoCheck || (unitToSaveHeal.Distance < 39 && unitToSaveHeal.InLineOfSightOCD))
                    {
                        Dlog("ChooseHealTarget: SAVING {0}[{1}] at {2:F0}% dist: {3:F1} in-los: {4}", Safe_UnitName(unitToSaveHeal), unitToSaveHeal.Level, unitToSaveHeal.HealthPercent, unitToSaveHeal.Distance, unitToSaveHeal.InLineOfSightOCD);
                        lowPlayer = unitToSaveHeal.ToPlayer();
                        unitToSaveHeal = null;
                    }
                }
            }
            catch
            {
                // tank or healer needs saving but reference is invalid at the moment
                unitToSaveHeal = null;
            }

            // if no low player found yet, find if there is one
            if (lowPlayer == null)
            {
                try
                {
                    lowPlayer = 
                        GroupMembers
                            .Where(u => CheckValidAndNearby(u, searchRange) && u.HealthPercent <= healLessThan)
                            .OrderBy(u => u.HealthPercent)
                            .FirstOrDefault();
                }
                catch (Exception e)
                {
                    Log(Color.Red, "An Exception occured. Check debug log for details.");
                    Logging.WriteDebug("HB EXCEPTION in ChooseHealTarget()");
                    Logging.WriteException(e);
                    lowPlayer = null;
                }
            }

            // now account for Me not being in GroupMembers
            if (lowPlayer == null)
                lowPlayer = _me.HealthPercent <= healLessThan ? _me : null;
            else if (_me.HealthPercent <= lowPlayer.HealthPercent)
                lowPlayer = _me;

            minGroupHealth = (int)(lowPlayer == null ? 100 : lowPlayer.HealthPercent);
            return lowPlayer;
#endif
        }
コード例 #11
0
        public GanttChart(CombinedStats currentStats, List <PlayerStats> selected, List <List <ActionBlock> > groups)
        {
            InitializeComponent();

            Selected  = selected;
            StartTime = groups.Min(group => group.First().BeginTime) - BUFFS_OFFSET;
            EndTime   = groups.Max(group => group.Last().BeginTime) + 1;
            Length    = EndTime - StartTime;

            switch (Selected.Count)
            {
            case 1:
                titleLabel1.Content = Selected[0].OrigName + "'s ADPS | " + currentStats?.ShortTitle;
                break;

            case 2:
                titleLabel1.Content = Selected[0].OrigName + " vs ";
                titleLabel2.Content = Selected[1].OrigName + "'s ";
                titleLabel3.Content = "ADPS | " + currentStats?.ShortTitle;
                break;
            }

            for (int i = 0; i < Selected.Count; i++)
            {
                var player     = Selected[i].OrigName;
                var spellClass = PlayerManager.Instance.GetPlayerClassEnum(player);

                DataManager.Instance.GetReceivedSpellsDuring(StartTime, EndTime).ForEach(group =>
                {
                    foreach (var action in group.Actions.Where(action => action is ReceivedSpell spell && spell.Receiver == player &&
                                                               spell.SpellData.Adps > 0 && (spell.SpellData.MaxHits > 0 || spell.SpellData.Duration <= 1800)))
                    {
                        var received  = action as ReceivedSpell;
                        var spellData = received.SpellData;

                        if (DataManager.Instance.CheckForSpellAmbiguity(spellData, spellClass, out SpellData replaced))
                        {
                            spellData = replaced;
                        }

                        var spellName = spellData.NameAbbrv;

                        if (string.IsNullOrEmpty(spellData.LandsOnOther))
                        {
                            SelfOnly[spellName] = 1;
                        }

                        if (!SpellRanges.TryGetValue(spellName, out SpellRange spellRange))
                        {
                            spellRange = new SpellRange()
                            {
                                Adps = spellData.Adps
                            };
                            var duration = GetDuration(spellData, EndTime, group.BeginTime);
                            spellRange.Ranges.Add(new TimeRange()
                            {
                                BlockBrush = BlockBrushes[i], BeginSeconds = (int)(group.BeginTime - StartTime), Duration = duration
                            });
                            SpellRanges[spellName] = spellRange;
                        }
                        else
                        {
                            var last          = spellRange.Ranges.LastOrDefault(range => range.BlockBrush == BlockBrushes[i]);
                            var offsetSeconds = (int)(group.BeginTime - StartTime);
                            if (last != null && offsetSeconds >= last.BeginSeconds && offsetSeconds <= (last.BeginSeconds + last.Duration))
                            {
                                last.Duration = GetDuration(spellData, EndTime, group.BeginTime) + (offsetSeconds - last.BeginSeconds);
                            }
                            else
                            {
                                var duration = GetDuration(spellData, EndTime, group.BeginTime);
                                spellRange.Ranges.Add(new TimeRange()
                                {
                                    BlockBrush = BlockBrushes[i], BeginSeconds = (int)(group.BeginTime - StartTime), Duration = duration
                                });
                            }
                        }
                    }
                });
            }

            showSelfOnly.IsEnabled = showCasterAdps.IsEnabled = showMeleeAdps.IsEnabled = SpellRanges.Count > 0;

            addHeaderLabel(0, "Buffs (T-90)", 20);
            addHeaderLabel(BUFFS_OFFSET, DateUtil.FormatSimpleTime(StartTime), 10);

            int minutes = 1;

            for (int more = (int)(BUFFS_OFFSET + 60); more < Length; more += 60)
            {
                addHeaderLabel(more, minutes + "m", 0);
                minutes++;
            }

            Display();
        }
コード例 #12
0
        public static async void Load()
        {
            Parallel.ForEach(
                typeof(DBC).GetProperties(BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), dbc =>
            {
                if (!dbc.PropertyType.IsGenericType ||
                    dbc.PropertyType.GetGenericTypeDefinition() != typeof(Storage <>))
                {
                    return;
                }

                var name = dbc.Name;

                try
                {
                    dbc.SetValue(dbc.GetValue(null),
                                 Activator.CreateInstance(dbc.PropertyType, $@"{ Settings.Default.DbcPath }\{ Settings.Default.Locale }\{ name }.db2", true));
                }
                catch (DirectoryNotFoundException)
                {
                }
                catch (TargetInvocationException tie)
                {
                    if (tie.InnerException is ArgumentException)
                    {
                        throw new ArgumentException($"Failed to load {name}.db2: {tie.InnerException.Message}");
                    }
                    throw;
                }
            });

            foreach (var spell in Spell)
            {
                SpellInfoStore[spell.Value.ID] = new SpellInfo(spell.Value);
            }

            await Task.WhenAll(Task.Run(() =>
            {
                foreach (var effect in SpellInfoStore.Where(effect => SpellMisc.ContainsKey(effect.Value.Spell.MiscID)))
                {
                    effect.Value.Misc = SpellMisc[effect.Value.Spell.MiscID];

                    if (SpellDuration.ContainsKey(effect.Value.Misc.DurationIndex))
                    {
                        effect.Value.DurationEntry = SpellDuration[effect.Value.Misc.DurationIndex];
                    }

                    if (SpellRange.ContainsKey(effect.Value.Misc.RangeIndex))
                    {
                        effect.Value.Range = SpellRange[effect.Value.Misc.RangeIndex];
                    }
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellEffect)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"Spell effect {effect.Value.ID} is referencing unknown spell {effect.Value.SpellID}, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Effects.Add(effect.Value);
                    SpellInfoStore[effect.Value.SpellID].SpellEffectInfoStore[effect.Value.EffectIndex] = new SpellEffectInfo(effect.Value); // Helper

                    var triggerId = (int)effect.Value.EffectTriggerSpell;
                    if (triggerId != 0)
                    {
                        if (SpellTriggerStore.ContainsKey(triggerId))
                        {
                            SpellTriggerStore[triggerId].Add(effect.Value.SpellID);
                        }
                        else
                        {
                            SpellTriggerStore.Add(triggerId, new SortedSet <int> {
                                effect.Value.SpellID
                            });
                        }
                    }
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellTargetRestrictions)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellTargetRestrictions: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].TargetRestrictions.Add(effect.Value);
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellXSpellVisual.Where(effect =>
                                                               effect.Value.DifficultyID == 0 && effect.Value.PlayerConditionID == 0))
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellXSpellVisual: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].SpellXSpellVisual = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellScaling)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellScaling: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Scaling = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellAuraOptions)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellAuraOptions: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].AuraOptions = effect.Value;
                    if (effect.Value.SpellProcsPerMinuteID != 0)
                    {
                        SpellInfoStore[effect.Value.SpellID].ProcsPerMinute = SpellProcsPerMinute[effect.Value.SpellProcsPerMinuteID];
                    }
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellAuraRestrictions)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellAuraRestrictions: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].AuraRestrictions = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellCategories)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellCategories: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Categories = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellCastingRequirements)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellCastingRequirements: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        return;
                    }

                    SpellInfoStore[effect.Value.SpellID].CastingRequirements = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellClassOptions)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellClassOptions: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].ClassOptions = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellCooldowns)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellCooldowns: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Cooldowns = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellEffectScaling)
                {
                    if (!SpellEffect.ContainsKey(effect.Value.SpellEffectId))
                    {
                        Console.WriteLine(
                            $"SpellEffectScaling: Unknown spell effect {effect.Value.SpellEffectId} referenced, ignoring!");
                        continue;
                    }

                    SpellEffect[effect.Value.SpellEffectId].SpellEffectScalingEntry = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellInterrupts)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellInterrupts: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Interrupts = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellEquippedItems)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellEquippedItems: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].EquippedItems = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellLevels)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine($"SpellLevels: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Levels = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellReagents)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellReagents: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Reagents = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var reagentsCurrency in SpellReagentsCurrency)
                {
                    if (!SpellInfoStore.ContainsKey(reagentsCurrency.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellReagentsCurrency: Unknown spell {reagentsCurrency.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[reagentsCurrency.Value.SpellID].ReagentsCurrency.Add(reagentsCurrency.Value);
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellShapeshift)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine(
                            $"SpellShapeshift: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Shapeshift = effect.Value;
                }
            }), Task.Run(() =>
            {
                foreach (var effect in SpellTotems)
                {
                    if (!SpellInfoStore.ContainsKey(effect.Value.SpellID))
                    {
                        Console.WriteLine($"SpellTotems: Unknown spell {effect.Value.SpellID} referenced, ignoring!");
                        continue;
                    }

                    SpellInfoStore[effect.Value.SpellID].Totems = effect.Value;
                }
            }));

            GameTable <GtSpellScalingEntry> .Open($@"{Settings.Default.GtPath}\SpellScaling.txt");
        }
コード例 #13
0
        public static bool Safe_CastSpell(WoWUnit unit, string sSpellName, SpellRange chkRng, SpellWait chkWait)
        {
            WoWSpell spell = null;

            try
            {
                // spell = SpellManager.Spells[sSpellName];
                spell = SpellManager.Spells[sSpellName];
                System.Diagnostics.Debug.Assert(spell != null);
            }
            catch (ThreadAbortException) { throw; }
            catch (Exception e)
            {
                Log(Color.Red, "An Exception occured. Check debug log for details.");
                Logging.WriteDebug(">>> HB EXCEPTION in SpellManager.Spells[" + sSpellName + "]");
                Logging.WriteDebug(">>> Spell '" + sSpellName + "' believed to be " + (SpellManager.HasSpell(sSpellName) ? "KNOWN" : "UNKNOWN") + " was used ");
                Logging.WriteException(e);
                throw;
                // return false;
            }

            return Safe_CastSpell(unit, spell, chkRng, chkWait);
        }
コード例 #14
0
        public static bool Safe_CastSpell(WoWUnit unit, WoWSpell spell, SpellRange chkRng, SpellWait chkWait)
        {
            bool bCastSuccessful = false;

            // enoughPower = (_me.GetCurrentPower(spell.PowerType) >= spell.PowerCost);
            if (MeSilenced())
            {
                ;
            }
            else if (chkRng == SpellRange.Check && spell.HasRange &&
                     ((unit != null && unit.Distance >= spell.MaxRange) || (unit == null && _me.GotTarget && _me.CurrentTarget.Distance >= spell.MaxRange)))
            {
                Dlog("Safe_CastSpell: Spell '{0}' has max range of {1:F1} but target is {2:F1} yds away - not cast", spell.Name, spell.MaxRange, unit != null ? unit.Distance : (_me.GotTarget ? _me.CurrentTarget.Distance : -1));
            }
            else
            {
                WaitForCurrentSpell(spell);
                if (!SpellManager.CanCast(spell))
                {
                    Dlog("Safe_CastSpell: cannot cast spell '{0}' yet - cd={1}, gcd={2}, casting={3}, cost={4}, mana={5}, ",
                         spell.Name,
                         spell.Cooldown,
                         SpellManager.GlobalCooldown,
                         _me.IsCasting,
                         spell.PowerCost,
                         _me.CurrentMana
                         );
                }
                //      else if (SpellManager.GlobalCooldown)
                //      Dlog("status:  GCD is active -- not cast");
                //      else if (spell.Cooldown)
                //      Dlog("status:  spell [{0}] on cooldown - not cast", spell.Name );
                //      else if (!enoughPower)
                //      Dlog("warning:  not enough mana/energy for spell - " + spell.Name);
                //      else if ( !SpellManager.CastableSpell( spell ))
                //      Dlog("status:  missing proc/reagent/totem to cast spell - " + spell.Name);
                //      else if (!SpellManager.CanCast( spell.Id ))                    // unclear what this spell does other than periodically
                //      Dlog("warning:  cannot cast spell {0} due to missing proc/reagent/totem", spell.Name  );       // .. block casting which otherwise can occur... disabled
                else
                {
                    double udist   = -1;
                    double uhealth = -1;

                    try
                    {
                        if (unit == null)
                        {
                            bCastSuccessful = SpellManager.Cast(spell);
                        }
                        else
                        {
                            udist           = unit.Distance;
                            uhealth         = unit.HealthPercent;
                            bCastSuccessful = SpellManager.Cast(spell, unit);
                        }
                    }

                    catch (ThreadAbortException) { throw; }
                    catch (Exception e)
                    {
                        Log(Color.Red, "An Exception occured. Check debug log for details.");
                        Logging.WriteDebug("HB EXCEPTION in spell.Cast([" + spell.Id + ":" + spell.Name + "])");
                        Logging.WriteException(e);
                        return(false);
                    }

                    unitLastSpellTarget = unit;

                    if (!bCastSuccessful)
                    {
                        Dlog("Safe_CastSpell: cast of {0} failed", spell.Name);
                    }
                    else
                    {
                        string info = "";
                        System.Drawing.Color clr = spell.Mechanic == WoWSpellMechanic.Healing ?
                                                   Color.ForestGreen : Color.DodgerBlue;

                        // spell.Mechanic always equals None currently
                        if (unit != null) // && spell.Mechanic == WoWSpellMechanic.Healing)
                        {
                            info = string.Format(" on {0} at {1:F1} yds at {2:F1}%", Safe_UnitName(unit), udist, uhealth);
                        }

                        Log(clr, "*" + spell.Name + info);

                        StyxWoW.SleepForLagDuration();
                        if (chkWait == SpellWait.Complete)
                        {
                            WaitForCurrentSpell(null);
                        }
                    }
                }
            }

            return(bCastSuccessful);
        }
コード例 #15
0
 public static bool Safe_CastSpell(string sSpellName, SpellRange chkRng, SpellWait chkWait)
 {
     return Safe_CastSpell(null, sSpellName, chkRng, chkWait);
 }
コード例 #16
0
        public static bool Safe_CastSpell(WoWUnit unit, WoWSpell spell, SpellRange chkRng, SpellWait chkWait)
        {
            bool bCastSuccessful = false;

            // enoughPower = (_me.GetCurrentPower(spell.PowerType) >= spell.PowerCost);
            if (MeSilenced())
                ;
            else if (chkRng == SpellRange.Check && spell.HasRange
                && ((unit != null && unit.Distance >= spell.MaxRange) || (unit == null && _me.GotTarget && _me.CurrentTarget.Distance >= spell.MaxRange)))
                Dlog("Safe_CastSpell: Spell '{0}' has max range of {1:F1} but target is {2:F1} yds away - not cast", spell.Name, spell.MaxRange, unit != null ? unit.Distance : (_me.GotTarget ? _me.CurrentTarget.Distance : -1));
            else
            {
                WaitForCurrentSpell(spell);
                if (!SpellManager.CanCast(spell))
                {
                    Dlog("Safe_CastSpell: cannot cast spell '{0}' yet - cd={1}, gcd={2}, casting={3}, cost={4}, mana={5}, ", 
                        spell.Name, 
                        spell.Cooldown, 
                        SpellManager.GlobalCooldown, 
                        _me.IsCasting,
                        spell.PowerCost,
                        _me.CurrentMana
                        );
                }
                //      else if (SpellManager.GlobalCooldown)
                //      Dlog("status:  GCD is active -- not cast");
                //      else if (spell.Cooldown)
                //      Dlog("status:  spell [{0}] on cooldown - not cast", spell.Name );
                //      else if (!enoughPower)
                //      Dlog("warning:  not enough mana/energy for spell - " + spell.Name);
                //      else if ( !SpellManager.CastableSpell( spell ))
                //      Dlog("status:  missing proc/reagent/totem to cast spell - " + spell.Name);
                //      else if (!SpellManager.CanCast( spell.Id ))                    // unclear what this spell does other than periodically
                //      Dlog("warning:  cannot cast spell {0} due to missing proc/reagent/totem", spell.Name  );       // .. block casting which otherwise can occur... disabled
                else
                {
                    double udist = -1;
                    double uhealth = -1;
                  
                    try
                    {
                        if (unit == null)
                            bCastSuccessful = SpellManager.Cast(spell);
                        else
                        {
                            udist = unit.Distance;
                            uhealth = unit.HealthPercent;
                            bCastSuccessful = SpellManager.Cast(spell, unit);
                        }
                    }

                    catch (ThreadAbortException) { throw; }
                    catch (Exception e)
                    {
                        Log(Color.Red, "An Exception occured. Check debug log for details.");
                        Logging.WriteDebug("HB EXCEPTION in spell.Cast([" + spell.Id + ":" + spell.Name + "])");
                        Logging.WriteException(e);
                        return false;
                    }

                    unitLastSpellTarget = unit;

                    if (!bCastSuccessful)
                        Dlog("Safe_CastSpell: cast of {0} failed", spell.Name);
                    else
                    {
                        string info = "";
                        System.Drawing.Color clr = spell.Mechanic == WoWSpellMechanic.Healing ?
                            Color.ForestGreen : Color.DodgerBlue;

                        // spell.Mechanic always equals None currently
                        if (unit != null) // && spell.Mechanic == WoWSpellMechanic.Healing)
                            info = string.Format(" on {0} at {1:F1} yds at {2:F1}%", Safe_UnitName(unit), udist, uhealth);

                        Log(clr, "*" + spell.Name + info);

                        StyxWoW.SleepForLagDuration();
                        if (chkWait == SpellWait.Complete)
                        {
                            WaitForCurrentSpell(null);
                        }
                    }
                }
            }

            return bCastSuccessful;
        }
コード例 #17
0
 public static bool Safe_CastSpell(string sSpellName, SpellRange chkRng, SpellWait chkWait)
 {
     return(Safe_CastSpell(null, sSpellName, chkRng, chkWait));
 }