Beispiel #1
0
 public SpellModel(SpellInfo spellInfo, SpellDuration spellDuration, SpellCasting spellCasting, SpellAscension spellAscension, SpellComponents spellComponents)
 {
     SpellInfo       = spellInfo;
     SpellDuration   = spellDuration;
     SpellCasting    = spellCasting;
     SpellAscension  = spellAscension;
     SpellComponents = spellComponents;
 }
Beispiel #2
0
        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);
        }
 public static Dictionary<int, SpellDuration> LoadSpellDuration()
 {
     Dictionary<int, SpellDuration> list = new Dictionary<int, SpellDuration>();
     SpellDuration d0 = new SpellDuration();
     d0.Description = "0 - 0MS";
     list.Add(0, d0);
     using (FileStream stream = File.OpenRead(DATA_PATH + "DBC/SpellDuration.dbc"))
     {
         BinaryReader r = new BinaryReader(stream);
         DBCHeader header = DBC.ReadDBCHeader(r);
         for (int i = 0; i != header.Records; ++i)
         {
             SpellDuration duration = new SpellDuration();
             duration.ID = r.ReadInt32();
             duration.Duration = r.ReadInt32();
             duration.PerLevel = r.ReadInt32();
             duration.Max = r.ReadInt32();
             duration.Description = String.Format("{3} - {0}MS+{1}MS/Level | Max: {2}MS", duration.Duration, duration.PerLevel, duration.Max, duration.ID);
             list.Add(duration.ID, duration);
         }
         r.Close();
         return list;
     }
 }
Beispiel #4
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");
        }