Menu

Welcome, Guest. Please login or register.
June 16, 2019, 03:10:37 am

Login with username, password and session length

Author Topic: [QUESTION] [WotLk] Spell.dbc and SpellMask  (Read 771 times)

Makpptfox

  • Contributors
  • Loreweaver
  • *****
  • Posts: 103
    • View Profile
[QUESTION] [WotLk] Spell.dbc and SpellMask
« on: January 07, 2017, 06:41:07 am »
Hello guys,

I work on some spells and have fun with the spell effects 107 and 108 (MOD_FLAT_MODIFIER and MOD_PCT_MODIFIER) but I have a problem.

I get the point that the spells are stored by classes with the spell_family and looked into blizzard's spells with SpellWork and found that the spells are stored in a SpellMask (wich is unique for each spell_family, meaning that SpellMask "100" will be different for spell_family Warrior and Priest) but here's my question :

How the hell did I find (or calculate) the SpellMask of the spells I need to be affected by my modifier, I searched and found nothing helpful on the forum.

Cheers.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
For support, send your Discord's ID by PM.

Grymskvll

  • Registred Member
  • Polygonshifter
  • *****
  • Posts: 63
    • View Profile
Re: [QUESTION] [WotLk] Spell.dbc and SpellMask
« Reply #1 on: January 07, 2017, 04:08:30 pm »
Edit: woops, code parts got mangled a bit. Copy+paste them into notepad and use a fixed-width font (such as Courier) to display correctly

It's been a while so take what I say with some caution.

If you want a spell to affect another one (for example, Improved Renew affects all Renew spells but not other spells), you need to:
  • set the SpellFamilyName (aka SpellClassSet) to the same value for both (maybe not?)
  • set the SpellFamilyFlags (aka SpellClassMask) in the AFFECTED spell (Renew in this case)
  • set the EffectSpellClassMasks in the AFFECTING spell (Improved Renew in this case)

The SpellFamilyName is just the identifier of the class that has the spells. SpellFamilyFlags and EffectSpellClassMasks are a bitmasking system. To better understand, turn the values in both into binary.

Renew rank 1 (Id=139) has the following SpellFamilyFlags by default, first in hex and below it the same value represented in binary (the exact name of the field may differ, I'm looking at the fields in Stoneharry's spell editor/accompanying database):
Code: [Select]
Id     SpellName0     SpellFamilyFlags     SpellFamilyFlags1     SpellFamilyFlags2
139    Renew          0x40                 0x0                   0x400
                      0000 0000 0100 0000  0                     0000 0100 0000 0000

Improved Renew rank 1 (Id=14908) has the following EffectSpellClassMasks for effect 1 by default, again first in hex and below it in binary. Imp Renew only has one effect (out of a possible 3), so the other two effects' EffectSpellClassMask (B1, B2, B3, C1, C2, C3) fields are left out:
Code: [Select]
Id     SpellName0     EffectSpellClassMaskA1 EffectSpellClassMaskA2 EffectSpellClassMaskA3
14908  Improved Renew 0x40                   0x0                     0x0
                      0000 0000 0100 0000    0                       0

Because Renew has the 7th bit set in SpellFamilyFlags, and Imp Renew has the 7th bit set in EffectSpellClassMaskA1, Imp Renew affects Renew.

If the bit was set in the second flags field for Renew instead, it wouldn't work.
SpellFamilyFlags is checked by EffectSpellClassMaskA1, EffectSpellClassMaskB1, EffectSpellClassMaskC1
SpellFamilyFlags1 is checked by EffectSpellClassMaskA2, EffectSpellClassMaskB2, EffectSpellClassMaskC2
SpellFamilyFlags2 is checked by EffectSpellClassMaskA3, EffectSpellClassMaskB3, EffectSpellClassMaskC3

It doesn't matter if Renew has a bit set set that Imp Renew doesn't match. So long as a single bit in a corresponding field is set, then the spell is affected.
If Imp Renew has a bit set that Renew doesn't have, that just means Imp Renew might affect other spells.
If Renew has a bit set that Imp Renew doesn't have, that just means Renew might be affected by other spells.


As an experiment, we can make the talent Shadow Reach affect Renew by adding a bit to Renew's flags that Shadow Reach already matches. Doing it this way is likely to have side effects. The "cleaner" way would be to take a bit that's unused among priest spells (in any of the SpellFamilyFlags fields), and set that in both the AFFECTING and AFFECTED spells.

We'll look at Shadow Reach rank 2 (Id=17323) because I can't find rank 3 for some reason. Again, it only has 1 effect:
Code: [Select]
Id     EffectSpellClassMaskA1               EffectSpellClassMaskA2         EffectSpellClassMaskA3
17323  0x682A004                            0x300502                       0x2040
       0110 1000 0010 1010 0000 0000 0100   0011 0000 0000 0101 0000 0010  0010 0000 0100 0000

If we set any of these bits in Renew's flags (in the appropriate field), Renew should have its range extended by 13%.

So I'll just open Stoneharry's spell editor, make a duplicate of Renew, set any of the bits from Shadow Reach's masks in an appropriate flags field of Renew, save and export the modified Spell.DBC, then copy it over to the server's DBC directory, put it in a client-side patch so I can learn the new spell, learn the original Renew and the modified version, then learn Shadow Reach (rank shouldn't matter, come to think of it, since all ranks affect identical spells).

As you can see, there were some side effects besides the increased range (the heal is stronger and costs less mana). Presumably because the bit by which I allowed Renew to be targeted by Shadow Reach is also targeted by other spells that have that effect.


Tips: use as few bits as possible. Depending on where you look, flags/masks will be in hex, binary or decimal. Use online converters.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »

Makpptfox

  • Contributors
  • Loreweaver
  • *****
  • Posts: 103
    • View Profile
Re: [QUESTION] [WotLk] Spell.dbc and SpellMask
« Reply #2 on: January 08, 2017, 04:12:21 am »
Oh man, thanks for this one.

I was totally lost on the way to calculate the SpellClassMask, but you learned me more on this thing that I was asking for !

You have all my sympathy mate.
« Last Edit: January 01, 1970, 01:00:00 am by Admin »
For support, send your Discord's ID by PM.