An interesting addition to exts2.cpp

A forum for feature requests/discussions and user submitted patches that improve MQ2

Moderator: MacroQuest Developers

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

An interesting addition to exts2.cpp

Post by Amadeus » Sat Jul 26, 2003 4:38 pm

This little tidbit of code for exts2.cpp will allow you to export a tilde delimited output of the entire spells database that is stored in memory. Of course, the beauty of this is that you can import this file to MS Excel and have a nice database.

You could use this same logic to create functions for the other databases that are stored in memory (ie, zones, etc..)

In mqext.def..add (under the EXPORTS heading)

Code: Select all

    exportallspells
In exts2.cpp...add

Code: Select all

// This routine exports all spell information in the game (stored
// in memory) into a tilde delimited format which works well with 
// Microsoft Excel.
// Note:  Add "Levels"
DECLARE_API ( exportallspells )
{
    SPELLLIST *p, *pnull=NULL, ci, *r;
	DWORD *q, cb;
	CHAR Name[MAX_STRING] = {0};
	CHAR Target[MAX_STRING] = {0};
	CHAR CastOnYou[MAX_STRING] = {0};
	CHAR CastOnAnother[MAX_STRING] = {0};
	CHAR WearOff[MAX_STRING] = {0};
	int i=1;
	int j=0;
	int k=0;



	dprintf("ID~Name~Range~CastTime~FizzleTime~RecastTime~DurationType~DurationValue1~Mana~");
	dprintf("Target~CastOnYou~CastOnAnother~WearOff~");
	dprintf("BookIcon~GemIcon~SpellIcon~");
	dprintf("CastingAnim~SpellAnim~");
	for (k=0;k<4;k++) dprintf("ReagentID%d~ReagentCount%d~",k+1,k+1);
	for (k=0;k<12;k++) dprintf("Base%d~",k+1);
	for (k=0;k<12;k++) dprintf("Max%d~",k+1);
	for (k=0;k<12;k++) dprintf("Calc%d~",k+1);
	for (k=0;k<12;k++) dprintf("Attrib%d~",k+1);
	dprintf("DescNum~FizzLeadj\n");

	while( i <= (TOTAL_SPELL_COUNT+2) )
	{
		q = (DWORD*) GetExpression(args)+j;
		ReadMemory((PARAM1)q, &r, sizeof(r), &cb);

		p = (SPELLLIST * )r;
		ReadMemory((PARAM1)p,&ci,sizeof(ci),&cb); 

		//Read some memory locations into buffers
		ReadMemory((PARAM1)ci.Name,Name,256,&cb);
		ReadMemory((PARAM1)ci.Target,Target,256,&cb);
		ReadMemory((PARAM1)ci.CastOnYou,CastOnYou,256,&cb);
		ReadMemory((PARAM1)ci.CastOnAnother,CastOnAnother,256,&cb);
		ReadMemory((PARAM1)ci.WearOff,WearOff,256,&cb);
		//

		dprintf("%d~%s~%2f~%d~%d~%d~%d~%d~%d~", ci.ID, Name, ci.Range, ci.CastTime, ci.FizzleTime, ci.RecastTime, ci.DurationType, ci.DurationValue1, ci.Mana );
		dprintf("%s~%s~Someone%s~%s~", Target, CastOnYou, CastOnAnother, WearOff );
		dprintf("%d~%d~%d~", ci.BookIcon, ci.GemIcon, ci.SpellIcon );
		dprintf("%d~%d~", ci.CastingAnim, ci.SpellAnim );
		for (k=0;k<4;k++)  dprintf("%d~%d~", ci.ReagentId[k], ci.ReagentCount[k] );
		for (k=0;k<12;k++) dprintf("%d~", ci.Base[k]);
		for (k=0;k<12;k++) dprintf("%d~", ci.Max[k]);
		for (k=0;k<12;k++) dprintf("%d~", ci.Calc[k]);
		for (k=0;k<12;k++) dprintf("%d~", ci.Attrib[k]);
		dprintf("%d~%d\n", ci.descnum, ci.FizzLeadj );

	
		//Clean up (always better to be safe than sorry)
		Name[0] = Target[0] = CastOnYou[0] = CastOnAnother[0] = WearOff[0] = '\0';
		i++;
		j++;
	} 
}

Syntax (in windbg):

> dd SPELLLIST_OFFSET
> !mqext.exportallspells <value given from command above>+0x24

(I think that's right..I havn't used it in a while ..hehe)

compuboy
a ghoul
a ghoul
Posts: 108
Joined: Thu Apr 24, 2003 8:19 am
Location: Good Question, if anyone finds out, let me know

Post by compuboy » Sat Jul 26, 2003 10:30 pm

i take it by replacing key tidles with something else you could deliminate it by anything, or does C++ not like that too much?
ya know, i cant think of anything profound to say here, so....

GO DEVS

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Post by Amadeus » Sat Jul 26, 2003 10:42 pm

nope...no reason why MOST other things wouldn't work. Things such as slashes and quotation marks would be the ones to avoid though...

EqMule
Developer
Developer
Posts: 2697
Joined: Fri Jan 03, 2003 9:57 pm
Contact:

awesome!

Post by EqMule » Thu Jul 31, 2003 1:55 pm

good job Amadeus! :D
My status o/
If you like MQ2 and would like to contribute, please do. My goal is 25 donations per month.
So far I've received Image donations for this month's patches.

Bitcoin: 1Aq8ackjQ4f7AUvbUL7BE6oPfT8PmNP4Zq
Krono: PM me.
I can always use characters for testing, PM me if you can donate one.

kagonis
a hill giant
a hill giant
Posts: 228
Joined: Sat May 24, 2003 8:48 pm

Post by kagonis » Sun Aug 03, 2003 6:59 am

Ooh, my very own personal spell db. Nice.