Ejemplo n.º 1
0
            public override void Convert(byte[] rawData)
            {
                #region Parsing
                int currentIndex = 0;

                var spell = new Spell
                {
                    Id      = GetUInt32(rawData, currentIndex++),
                    SpellId = (SpellId)GetInt32(rawData, 0)
                };

                try
                {
                    spell.Category                = GetUInt32(rawData, currentIndex++);                           // 1+
                    spell.DispelType              = (DispelType)GetUInt32(rawData, currentIndex++);               // 2+
                    spell.Mechanic                = (SpellMechanic)GetUInt32(rawData, currentIndex++);            // 3+
                    spell.Attributes              = (SpellAttributes)GetUInt32(rawData, currentIndex++);          // 4+
                    spell.AttributesEx            = (SpellAttributesEx)GetUInt32(rawData, currentIndex++);        // 5+
                    spell.AttributesExB           = (SpellAttributesExB)GetUInt32(rawData, currentIndex++);       // 6+
                    spell.AttributesExC           = (SpellAttributesExC)GetUInt32(rawData, currentIndex++);       // 7+
                    spell.AttributesExD           = (SpellAttributesExD)GetUInt32(rawData, currentIndex++);       // 8+
                    spell.AttributesExE           = (SpellAttributesExE)GetUInt32(rawData, currentIndex++);       // 9
                    spell.AttributesExF           = (SpellAttributesExF)GetUInt32(rawData, currentIndex++);       // 10
                    spell.RequiredShapeshiftMask  = (ShapeshiftMask)GetUInt32(rawData, currentIndex++);           // 11-
                    spell.Unk_322_1               = GetUInt32(rawData, currentIndex++);                           // 12
                    spell.ExcludeShapeshiftMask   = (ShapeshiftMask)GetUInt32(rawData, currentIndex++);           // 13-
                    spell.Unk_322_2               = GetUInt32(rawData, currentIndex++);                           // 14
                    spell.TargetFlags             = (SpellTargetFlags)GetUInt32(rawData, currentIndex++);         // 15+
                    spell.Unk_322_3               = GetUInt32(rawData, currentIndex++);                           // 16
                    spell.CreatureMask            = (CreatureMask)GetUInt32(rawData, currentIndex++);             // 17-
                    spell.RequiredSpellFocus      = (SpellFocus)GetUInt32(rawData, currentIndex++);               // 18- 0
                    spell.FacingFlags             = (SpellFacingFlags)GetUInt32(rawData, currentIndex++);         // 19-
                    spell.RequiredCasterAuraState = (AuraState)GetUInt32(rawData, currentIndex++);                // 20+-
                    spell.RequiredTargetAuraState = (AuraState)GetUInt32(rawData, currentIndex++);                // 21+-
                    spell.ExcludeCasterAuraState  = (AuraState)GetUInt32(rawData, currentIndex++);                // 22+-
                    spell.ExcludeTargetAuraState  = (AuraState)GetUInt32(rawData, currentIndex++);                // 23+-
                    spell.RequiredCasterAuraId    = (SpellId)GetUInt32(rawData, currentIndex++);                  // 24+-
                    spell.RequiredTargetAuraId    = (SpellId)GetUInt32(rawData, currentIndex++);                  // 25+-
                    spell.ExcludeCasterAuraId     = (SpellId)GetUInt32(rawData, currentIndex++);                  // 26+-
                    spell.ExcludeTargetAuraId     = (SpellId)GetUInt32(rawData, currentIndex++);                  // 27+-

                    int castTimeIndex = GetInt32(rawData, currentIndex++);                                        // 28+
                    if (castTimeIndex > 0)
                    {
                        if (!mappeddbcCastTimeReader.Entries.TryGetValue(castTimeIndex, out spell.CastDelay))
                        {
                            ContentMgr.OnInvalidClientData("DBC Spell \"{0}\" referred to invalid CastTime-Entry: {1}", spell.Name, castTimeIndex);
                        }
                    }

                    spell.CooldownTime          = Math.Max(0, GetInt32(rawData, currentIndex++) - (int)spell.CastDelay);                // 29+
                    spell.categoryCooldownTime  = GetInt32(rawData, currentIndex++);                                                    // 30+-
                    spell.InterruptFlags        = (InterruptFlags)GetUInt32(rawData, currentIndex++);                                   // 31+-
                    spell.AuraInterruptFlags    = (AuraInterruptFlags)GetUInt32(rawData, currentIndex++);                               // 32+-
                    spell.ChannelInterruptFlags = (ChannelInterruptFlags)GetUInt32(rawData, currentIndex++);                            // 33+-
                    spell.ProcTriggerFlagsProp  = (ProcTriggerFlags)GetUInt32(rawData, currentIndex++);                                 // 34++-
                    spell.ProcChance            = GetUInt32(rawData, currentIndex++);                                                   // 35++-
                    spell.ProcCharges           = GetInt32(rawData, currentIndex++);                                                    // 36++-
                    spell.MaxLevel  = GetInt32(rawData, currentIndex++);                                                                // 37+
                    spell.BaseLevel = GetInt32(rawData, currentIndex++);                                                                // 38+
                    spell.Level     = GetInt32(rawData, currentIndex++);                                                                // 30+

                    var durationIndex = GetInt32(rawData, currentIndex++);                                                              // 40+
                    if (durationIndex > 0)
                    {
                        if (!mappeddbcDurationReader.Entries.TryGetValue(durationIndex, out spell.Durations))
                        {
                            ContentMgr.OnInvalidClientData("DBC Spell \"{0}\" referred to invalid Duration-Entry: {1}", spell.Name, durationIndex);
                        }
                    }

                    spell.PowerType              = (PowerType)GetUInt32(rawData, currentIndex++);               // 41+ always mana
                    spell.PowerCost              = GetInt32(rawData, currentIndex++);                           // 42+
                    spell.PowerCostPerlevel      = GetInt32(rawData, currentIndex++);                           // 43+
                    spell.PowerPerSecond         = GetInt32(rawData, currentIndex++);                           // 44+
                    spell.PowerPerSecondPerLevel = GetInt32(rawData, currentIndex++);                           // 45-

                    var rangeIndex = GetInt32(rawData, currentIndex++);                                         // 46+
                    if (rangeIndex > 0)
                    {
                        if (!mappeddbcRangeReader.Entries.TryGetValue(rangeIndex, out spell.Range))
                        {
                            ContentMgr.OnInvalidClientData("DBC Spell \"{0}\" referred to invalid Range-Entry: {1}", spell.Name, rangeIndex);
                        }
                    }

                    spell.ProjectileSpeed = GetFloat(rawData, currentIndex++);                                  // 47+
                    spell.ModalNextSpell  = (SpellId)GetUInt32(rawData, currentIndex++);                        // 48-

                    spell.MaxStackCount = GetInt32(rawData, currentIndex++);                                    // 49+ 1

                    spell.RequiredToolIds = new uint[2];                                                        // 50-51+-
                    for (var i = 0; i < spell.RequiredToolIds.Length; i++)
                    {
                        spell.RequiredToolIds[i] = GetUInt32(rawData, currentIndex++);
                    }

                    List <ItemStackDescription> reagents = null;
                    int reagentStart = currentIndex;
                    for (int i = 0; i < 8; i++)                                             //52-59 - spell.Reagents = ItemStackDescription.EmptyArray;
                    {
                        ReadReagent(rawData, reagentStart, i, out currentIndex, ref reagents);
                    }
                    if (reagents != null)
                    {
                        spell.Reagents = reagents.ToArray();
                    }
                    else
                    {
                        spell.Reagents = ItemStackDescription.EmptyArray;
                    }
                    spell.RequiredItemClass = (ItemClass)GetUInt32(rawData, currentIndex++);   //68+ spell.RequiredItemClass = ItemClass.None;
                    if (spell.RequiredItemClass < 0)
                    {
                        spell.RequiredItemClass = ItemClass.None;
                    }

                    spell.RequiredItemSubClassMask = (ItemSubClassMask)GetUInt32(rawData, currentIndex++); // 69+ spell.RequiredItemSubClassMask = ItemSubClassMask.None;
                    if (spell.RequiredItemSubClassMask < 0)
                    {
                        spell.RequiredItemSubClassMask = ItemSubClassMask.None;
                    }

                    spell.RequiredItemInventorySlotMask = (InventorySlotTypeMask)GetUInt32(rawData, currentIndex++); // 70 + spell.RequiredItemInventorySlotMask = InventorySlotTypeMask.None;
                    if (spell.RequiredItemInventorySlotMask < 0)
                    {
                        spell.RequiredItemInventorySlotMask = InventorySlotTypeMask.None;
                    }

                    var effects     = new List <SpellEffect>(3);                    // 71 - 127+
                    int effectStart = currentIndex;

                    for (int i = 0; i < 3; i++)
                    {
                        var effect = ReadEffect(spell, rawData, effectStart, i, out currentIndex);
                        if (effect != null &&
                            (effect.EffectType != SpellEffectType.None ||
                             effect.BasePoints > 0 ||
                             effect.AuraType != 0 ||
                             effect.TriggerSpellId != 0))
                        {
                            effects.Add(effect);
                        }
                    }
                    spell.Effects = effects.ToArray();

                    spell.Visual          = GetUInt32(rawData, currentIndex++);                      // 128-
                    spell.Visual2         = GetUInt32(rawData, currentIndex++);                      // 129-
                    spell.SpellbookIconId = GetUInt32(rawData, currentIndex++);                      // 130-
                    spell.BuffIconId      = GetUInt32(rawData, currentIndex++);                      // 131-
                    spell.Priority        = GetUInt32(rawData, currentIndex++);                      // 132-

                    spell.Name            = GetString(rawData, ref currentIndex);                    // 133+
                    spell.RankDesc        = GetString(rawData, ref currentIndex);                    // 124-
                    spell.Description     = GetString(rawData, ref currentIndex);                    // 125+
                    spell.BuffDescription = GetString(rawData, ref currentIndex);                    // 126-

                    spell.PowerCostPercentage   = GetInt32(rawData, currentIndex++);                 // 127+-
                    spell.StartRecoveryTime     = GetInt32(rawData, currentIndex++);                 // 128-
                    spell.StartRecoveryCategory = GetInt32(rawData, currentIndex++);                 // 129-
                    spell.MaxTargetLevel        = GetUInt32(rawData, currentIndex++);                // 130-
                    spell.SpellClassSet         = (SpellClassSet)GetUInt32(rawData, currentIndex++); // 131+

                    spell.SpellClassMask[0] = GetUInt32(rawData, currentIndex++);                    // 132-
                    spell.SpellClassMask[1] = GetUInt32(rawData, currentIndex++);                    // 133-
                    spell.SpellClassMask[2] = GetUInt32(rawData, currentIndex++);                    // 134-

                    spell.MaxTargets     = GetUInt32(rawData, currentIndex++);                       // 135+
                    spell.DamageType     = (DamageType)GetUInt32(rawData, currentIndex++);           // 136+
                    spell.PreventionType = (SpellPreventionType)GetUInt32(rawData, currentIndex++);  // 137+
                    spell.StanceBarOrder = GetInt32(rawData, currentIndex++);                        // 138-

                    for (int i = 0; i < spell.DamageMultipliers.Length; i++)                         // 139-141+
                    {
                        spell.DamageMultipliers[i] = GetFloat(rawData, currentIndex++);
                    }

                    spell.MinFactionId       = GetUInt32(rawData, currentIndex++);                // 142-
                    spell.MinReputation      = GetUInt32(rawData, currentIndex++);                // 143-
                    spell.RequiredAuraVision = GetUInt32(rawData, currentIndex++);                // 144-

                    spell.RequiredToolCategories = new ToolCategory[2];                           // 145-146+
                    for (int i = 0; i < spell.RequiredToolCategories.Length; i++)
                    {
                        spell.RequiredToolCategories[i] = (ToolCategory)GetUInt32(rawData, currentIndex++);
                    }

                    spell.AreaGroupId = GetUInt32(rawData, currentIndex++);                   //-
                    spell.SchoolMask  = (DamageSchoolMask)GetUInt32(rawData, currentIndex++); //+

                    var runeCostId = GetInt32(rawData, currentIndex++);                       //-
                    if (runeCostId != 0)
                    {
                        mappeddbcRuneCostReader.Entries.TryGetValue(runeCostId, out spell.RuneCostEntry);
                    }
                    spell.MissileId = GetUInt32(rawData, currentIndex++);                    //-

                    // New 3.1.0. Id from PowerDisplay.dbc
                    spell.PowerDisplayId = GetInt32(rawData, currentIndex++);                    //-

                    // 3.2.2 unk float (array?)
                    spell.Unk_322_4_1 = GetUInt32(rawData, currentIndex++);                    //-
                    spell.Unk_322_4_2 = GetUInt32(rawData, currentIndex++);                    //-
                    spell.Unk_322_4_3 = GetUInt32(rawData, currentIndex++);                    //-

                    // 3.2.2
                    spell.spellDescriptionVariablesID = GetUInt32(rawData, currentIndex++);                    //-
                }
                catch (Exception e)
                {
                    throw new Exception(string.Format("Unable to parse Spell from DBC file. Index: " + currentIndex), e);
                }
                #endregion

                SpellHandler.AddSpell(spell);
            }
Ejemplo n.º 2
0
        public void FinalizeDataHolder()
        {
            try
            {
                //Id
                SpellId   = (SpellId)Id;
                PowerType = PowerType.Mana;
                Durations = new DurationEntry()
                {
                    Min = Duration, Max = Duration
                };

                Range = new SimpleRange(0, MaxRange);

                ProjectileSpeed   = 1;
                RequiredToolIds   = new uint[2];
                Reagents          = ItemStackDescription.EmptyArray;
                RequiredItemClass = ItemClass.None;

                RequiredItemSubClassMask = ItemSubClassMask.None;
                if (Id == 2228 || Id == 2231 || Id == 2234 || Id == 2237 || Id == 2240 || Id == 2243 || Id == 2246 || Id == 2249 || Id == 2252)
                {
                    SoulGuardProffLevel = 1;
                }
                if (Id == 2229 || Id == 2232 || Id == 2235 || Id == 2238 || Id == 2241 || Id == 2244 || Id == 2247 || Id == 2250 || Id == 2253)
                {
                    SoulGuardProffLevel = 2;
                }
                if (Id == 2230 || Id == 2233 || Id == 2236 || Id == 2239 || Id == 2242 || Id == 2245 || Id == 2248 || Id == 2251 || Id == 2254)
                {
                    SoulGuardProffLevel = 3;
                }

                RequiredItemInventorySlotMask = InventorySlotTypeMask.None;


                var effects = new List <SpellEffect>(3); // 71 - 127+

                #region read effects

                var effect = new SpellEffect(this, EffectIndex.Zero)
                {
                    EffectType          = Effect0_EffectType,
                    DiceSides           = 0,
                    RealPointsPerLevel  = 0,
                    BasePoints          = 0,
                    Mechanic            = Effect0_Mehanic,
                    ImplicitTargetA     = Effect0_ImplicitTargetA,
                    ImplicitTargetB     = Effect0_ImplicitTargetB,
                    Radius              = Effect0_Radius,
                    AuraType            = Effect0_AuraType,
                    Amplitude           = Effect0_Amplitude,
                    ProcValue           = Effect0_ProcValue,
                    ChainTargets        = 0,
                    MiscValue           = Effect0_MiscValue,
                    MiscValueB          = Effect0_MiscValueB,
                    MiscValueC          = Effect0_MiscValueC,
                    TriggerSpellId      = SpellId.None,
                    PointsPerComboPoint = 0
                };
                effect.AffectMask[0] = 0;
                effect.AffectMask[1] = 0;
                effect.AffectMask[2] = 0;
                // Fix: This is a default AoE effect, thus doesn't have a fact at destination
                if (effect.ImplicitTargetA == ImplicitSpellTargetType.AllEnemiesAroundCaster &&
                    effect.ImplicitTargetB == ImplicitSpellTargetType.AllEnemiesInArea)
                {
                    effect.ImplicitTargetB = ImplicitSpellTargetType.None;
                }
                effects.Add(effect);

                effect = new SpellEffect(this, EffectIndex.One)
                {
                    EffectType          = Effect1_EffectType,
                    DiceSides           = 0,
                    RealPointsPerLevel  = 0,
                    BasePoints          = 0,
                    Mechanic            = Effect1_Mehanic,
                    ImplicitTargetA     = Effect1_ImplicitTargetA,
                    ImplicitTargetB     = Effect1_ImplicitTargetB,
                    Radius              = Effect1_Radius,
                    AuraType            = Effect1_AuraType,
                    Amplitude           = Effect1_Amplitude,
                    ProcValue           = Effect1_ProcValue,
                    ChainTargets        = 0,
                    MiscValue           = Effect1_MiscValue,
                    MiscValueB          = Effect1_MiscValueB,
                    MiscValueC          = Effect1_MiscValueC,
                    TriggerSpellId      = SpellId.None,
                    PointsPerComboPoint = 0
                };
                effect.AffectMask[0] = 0;
                effect.AffectMask[1] = 0;
                effect.AffectMask[2] = 0; // Fix: This is a default AoE effect, thus doesn't have a fact at destination
                if (effect.ImplicitTargetA == ImplicitSpellTargetType.AllEnemiesAroundCaster &&
                    effect.ImplicitTargetB == ImplicitSpellTargetType.AllEnemiesInArea)
                {
                    effect.ImplicitTargetB = ImplicitSpellTargetType.None;
                }
                effects.Add(effect);

                #endregion

                Effects = effects.ToArray();

                PowerCostPercentage = 0;                     // 127+-
                SpellClassSet       = SpellClassSet.Generic; // 131+
                MaxTargets          = 100;                   // 135+

                PreventionType = DamageType == DamageType.Magic ? SpellPreventionType.Magic : SpellPreventionType.Melee;
                //DamageMultipliers

                RequiredToolCategories = new ToolCategory[2]; // 145-146+
                for (int i = 0; i < RequiredToolCategories.Length; i++)
                {
                    RequiredToolCategories[i] = ToolCategory.None;
                }
                RuneCostEntry = new RuneCostEntry();
                if (CooldownTime > 5000)
                {
                    CooldownTime -= 1000;
                }
                else if (CooldownTime > 0)
                {
                    CooldownTime -= 500;
                }

                if (Name.Contains("Party"))
                {
                    Effect0_ImplicitTargetA = ImplicitSpellTargetType.AllParty;
                    Effect1_ImplicitTargetA = ImplicitSpellTargetType.AllParty;
                }
                SpellHandler.AddSpell(this);
            }
            catch (Exception ex)
            {
                LogUtil.WarnException("Error when finalizing data holder of spell {0}. {1}", Name, ex);
            }
        }