[4.0.3.13329] Spell.dbc -> SpellEffect.dbc access (use of Foreign Key) menu

User Tag List

Results 1 to 12 of 12
  1. #1
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    [4.0.3.13329] Spell.dbc -> SpellEffect.dbc access (use of Foreign Key)

    Hello,

    Pre-Cataclysm Spell.dbc held a foreign key to to SpellEffect.dbc. After Cataclysm hit, Spell.dbc has now been made smaller (250~ down to 46 entries per row), and no longer holds this foreign key to SpellEffect.dbc; which makes it hard to look up what effects each spell applies.

    Instead, now each row in SpellEffect.dbc holds a foreign key to Spell.dbc. There are also multiple rows in SpellEffect.dbc for each row in Spell.dbc, one row for each spell effect respectively (maximum of 3).

    I thought about a few different approaches I could take in order to access spell effect data for each spell.

    One, ugly approach was to parse SpellEffect.dbc against each spell stored in Spell.dbc upon initializing our code. This would be inefficient and just plain slow. So, I decided to find out how the game itself accessed SpellEffect.dbc, due to the nature of the database.

    The function at 0x49C400 (not rebased) is called when the game is initializing, and it creates a map of spell id's to spell effects. I honestly didn't reverse this function for long since I couldn't be ****ed, but you can see the general gist of it if you look at it.

    However, at 0x49B8D0 (also not rebased) there is a function that we can call to return a SpellEffect row. It takes in a spell id, and which SpellEffect index you want for that spell. If there isn't a SpellEffect for that index (0, 1, 2), it will return 0x0. Otherwise, it will return a pointer to the row.

    I won't enclose any code here, because I don't want it to be tasty copy pasta, but all you need to know is here.

    Enjoy

    EDIT: I can't seem to find where EffectBasePoints has gone. Does anyone want to fill me in? For example, to get the speed of a mount.
    Last edited by ramey; 12-26-2010 at 11:53 PM. Reason: Added quick question

    [4.0.3.13329] Spell.dbc -> SpellEffect.dbc access (use of Foreign Key)
  2. #2
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ramey View Post
    One, ugly approach was to parse SpellEffect.dbc against each spell stored in Spell.dbc upon initializing our code. This would be inefficient and just plain slow. So, I decided to find out how the game itself accessed SpellEffect.dbc, due to the nature of the database.

    The function at 0x49C400 (not rebased) is called when the game is initializing, and it creates a map of spell id's to spell effects.
    It sounds like the game is doing exactly the "ugly" method you didn't want to do. Are you just trying to avoid the overhead of keeping all the effects in-memory? Because with denormalized data like this (where leaf nodes refer to the parent, rather than the other way around), keeping an in-memory map is about the only way to do it.

    So -- and I apologize if I'm restating what you just said, but -- it sounds like maybe your best bet would be to figure out if WoW's map is something you can access from your code. That way you could at least avoid the overhead of loading the data and keeping it in memory, and just let WoW do that work for you...
    Don't believe everything you think.

  3. #3
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    It sounds like the game is doing exactly the "ugly" method you didn't want to do. Are you just trying to avoid the overhead of keeping all the effects in-memory? Because with denormalized data like this (where leaf nodes refer to the parent, rather than the other way around), keeping an in-memory map is about the only way to do it.

    So -- and I apologize if I'm restating what you just said, but -- it sounds like maybe your best bet would be to figure out if WoW's map is something you can access from your code. That way you could at least avoid the overhead of loading the data and keeping it in memory, and just let WoW do that work for you...
    Yup, that's exactly what WoW is doing. The function at 0x49B8D0 (not rebased) accesses this map that WoW has initialized when the game is created. Instead of doing the ugly method I talked about to look at our options, you can use this function to access the map that WoW initializes, and it saves us the hassle of creating our own map and storing it in memory. I was just sharing a way of accessing the SpellEffect.dbc

    Thanks for replying, no reason to apologize either! Any reply is good.

  4. #4
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you sure there is a maximum of 3 effects? One could argue that the reason they have the spell ID in spell effect now is so they can have an arbitrary amount of spell effects per spell.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  5. #5
    Apoc's Avatar Angry Penguin
    Reputation
    1388
    Join Date
    Jan 2008
    Posts
    2,750
    Thanks G/R
    0/13
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MaiN View Post
    Are you sure there is a maximum of 3 effects? One could argue that the reason they have the spell ID in spell effect now is so they can have an arbitrary amount of spell effects per spell.
    I've only seen a max of 3. But there could potentially be more.

  6. #6
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here's a noob question: what sort of useful info can you get from the effects database? I've been using Lua for my spell info for so long that I haven't poked much into the DBC for spells.
    Don't believe everything you think.

  7. #7
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by MaiN View Post
    Are you sure there is a maximum of 3 effects? One could argue that the reason they have the spell ID in spell effect now is so they can have an arbitrary amount of spell effects per spell.
    Well, you're completely right there could be more than 3 spells and that's maybe why they changed it! However for the moment 3 spell effects is hard coded into the client (you can see at 0x0049B8F0 - not rebased).

    Originally Posted by Apoc View Post
    I've only seen a max of 3. But there could potentially be more.
    I've looked through the DBC and there is also an index in each row which tells you what spellEffectIndex it is for that spell, I've only seen 0, 1 and 2. Do you have any idea where BasePoints etc which used to be in Spell.dbc went Apoc?

    Originally Posted by amadmonk View Post
    Here's a noob question: what sort of useful info can you get from the effects database? I've been using Lua for my spell info for so long that I haven't poked much into the DBC for spells.
    For example you can get a spell id from an item, then see if that spell id has an effect of healing over time, or healing instantly for example. You can also check if the spell applies an aura, and then if that aura is SPELL_AURA_MOUNTED - so you can check if the spell is a mount. Before you could check BasePoints to see how fast the mount was and select the fastest mount, however I can't seem to find that now.

  8. #8
    amadmonk's Avatar Active Member
    Reputation
    124
    Join Date
    Apr 2008
    Posts
    772
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ramey View Post
    For example you can get a spell id from an item, then see if that spell id has an effect of healing over time, or healing instantly for example. You can also check if the spell applies an aura, and then if that aura is SPELL_AURA_MOUNTED - so you can check if the spell is a mount. Before you could check BasePoints to see how fast the mount was and select the fastest mount, however I can't seem to find that now.
    Interesting. That might be a better, more general-purpose solution to the question of "do I have any items that can cast beneficial effects" than my current hard-coded solution is.
    Don't believe everything you think.

  9. #9
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by amadmonk View Post
    Interesting. That might be a better, more general-purpose solution to the question of "do I have any items that can cast beneficial effects" than my current hard-coded solution is.
    There is indeed a lot of possibilities. It's quite good too. Requires a bit of extra work though.

  10. #10
    andy012345's Avatar Active Member
    Reputation
    59
    Join Date
    Oct 2007
    Posts
    124
    Thanks G/R
    0/7
    Trade Feedback
    1 (100%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ramey View Post
    For example you can get a spell id from an item, then see if that spell id has an effect of healing over time, or healing instantly for example. You can also check if the spell applies an aura, and then if that aura is SPELL_AURA_MOUNTED - so you can check if the spell is a mount. Before you could check BasePoints to see how fast the mount was and select the fastest mount, however I can't seem to find that now.
    You'll need to look into the values sent with aura updates now. Most player based auras now use dynamic tooltips which are based on the values sent down by the server.

    That includes mounts too, because they scale on your riding skill now.

    It's also why you see the real dot/amp in other peoples dots for example Deals 522 damage every 1.94 sec.

  11. #11
    ramey's Avatar Member
    Reputation
    45
    Join Date
    Jan 2008
    Posts
    320
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by andy012345 View Post
    You'll need to look into the values sent with aura updates now. Most player based auras now use dynamic tooltips which are based on the values sent down by the server.

    That includes mounts too, because they scale on your riding skill now.

    It's also why you see the real dot/amp in other peoples dots for example Deals 522 damage every 1.94 sec.
    Right, thanks a lot.

  12. #12
    Tanaris4's Avatar Contributor Authenticator enabled
    Reputation
    148
    Join Date
    Oct 2008
    Posts
    646
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Here is my implementation (For mac). May help some that can't fire up IDA.

    Code:
    	MemoryAccess *memory = [[Controller sharedInstance] wowMemoryAccess];
    	
    	if ( memory && [memory isValid] ){
    		
    		
    		// get our spell effect table
    		// GetSpellEffectTable is mac (4.0.6a): 0x10DE6D4       windows (4.0.3): 0x88F6B0
    		UInt32 spellEffectTablePtr = [memory readUInt:[[OffsetController sharedInstance] offset:@"GetSpellEffectTable"]];
    		// the maximum spell ID is at GetSpellEffectTable - 0x4 (we could check this)
    		
    		
    		// This will point to a "struct":
    		//	MaxIndex		0x0
    		//	MaxIndex2		0x4 (same as the above?)
    		//	RowPtr			0x8
    		UInt32 structPtr = spellEffectTablePtr + 16 * [_spellID intValue];
    
    		// how many indexes do we have?
    		int maxIndex = [memory readInt:structPtr + 0x4];
    		
    		// max of 3 indexes!
    		if ( maxIndex < 3 ){
    			
    			UInt32 arrayPtr = [memory readUInt:structPtr+0x8];
    			
    			// read the entire effects array
    			UInt32 effectRows[maxIndex];
    			[memory loadDataForObject:self atAddress:arrayPtr Buffer:(Byte *)&effectRows BufLength:sizeof(effectRows)];
    	
    			//	http://www.madx.dk/wowdev/wiki/index.php?title=SpellEffect.dbc
    			
    		}
    	}
    Edit: Answered my question, leaving the above to help others
    Last edited by Tanaris4; 02-14-2011 at 10:38 AM.
    https://tanaris4.com

Similar Threads

  1. Spell DBC Error.
    By Ickybad in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 07-21-2008, 06:06 PM
  2. ArcEmu - Supporting 2.4.3, spell dbcs updated, fully working too! =)
    By Hasbro in forum World of Warcraft Emulator Servers
    Replies: 18
    Last Post: 07-17-2008, 08:18 PM
  3. Possible Invalid Format DBC/spell.dbc
    By jonny14 in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 05-08-2008, 01:48 PM
  4. [HELP] My spell.dbc is not working
    By kate1 in forum World of Warcraft Emulator Servers
    Replies: 9
    Last Post: 05-06-2008, 12:43 PM
  5. Release: Spell.dbc
    By meinson in forum World of Warcraft Emulator Servers
    Replies: 0
    Last Post: 11-13-2007, 04:09 PM
All times are GMT -5. The time now is 10:20 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search