Changes to Spell handling...

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

Moderator: MacroQuest Developers

NealThorpayt
Developer
Developer
Posts: 66
Joined: Thu Mar 13, 2003 2:14 pm
Location: Miskatonic University
Contact:

Changes to Spell handling...

Post by NealThorpayt » Thu Apr 24, 2003 6:00 pm

Greetings Constructs,

There were some changes to the way the spell list is handled. To get spell functions working again make the following changes.

In MQ.h add the following before the _SPELLLIST struct:

Code: Select all

#define	SPELLLIST_STARTOFFSET		0x24
#define	TOTAL_SPELL_COUNT			0x0FA0		// # of spells in game
In EQLib.cpp replace the following functions:

Code: Select all

PCHAR GetSpellByID(DWORD dwSpellID) {
	PCHAR szUnknown = "Unknown Spell";
	PSPELLLIST pSpell = NULL;
	if (EQADDR_SPELLS != NULL) {
		PSPELLLIST *pList = (PSPELLLIST*)(((DWORD)*EQADDR_SPELLS) + SPELLLIST_STARTOFFSET);
		pSpell =  pList[dwSpellID];
		if (pSpell != NULL) {
			if (pSpell->Name != NULL) {
				return pSpell->Name;
			}
		}
	}
	return szUnknown;
}

Code: Select all

PSPELLLIST GetSpellByName(PCHAR szName) {
	PSPELLLIST pSpell = NULL;
	if (EQADDR_SPELLS != NULL) {
		PSPELLLIST *pList = (PSPELLLIST*)(((DWORD)*EQADDR_SPELLS) + SPELLLIST_STARTOFFSET);
		for (DWORD dwSpellID = 0; dwSpellID < TOTAL_SPELL_COUNT; dwSpellID++) {
			 pSpell = pList[dwSpellID];
			 if ((pSpell->ID > 0) && (pSpell->ID < TOTAL_SPELL_COUNT)) {
				 if (pSpell->Name != NULL) {
					 if (!strnicmp(szName, pSpell->Name, strlen(szName))) {
						 return pSpell;
					 }
				 }
			 }
		}
	}
	return NULL;
}
Change the line in MemSpell from:

Code: Select all

				PSPELLLIST *pList = *EQADDR_SPELLS;
to

Code: Select all

				PSPELLLIST *pList = (PSPELLLIST*)(((DWORD)*EQADDR_SPELLS) + SPELLLIST_STARTOFFSET);
End of line...
By the pricking of my thumb, something wicked this way comes...

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Thu Apr 24, 2003 7:08 pm

Are there really 4000 spells?

Wow, don't ever use spell names.

NealThorpayt
Developer
Developer
Posts: 66
Joined: Thu Mar 13, 2003 2:14 pm
Location: Miskatonic University
Contact:

Number of spells...

Post by NealThorpayt » Thu Apr 24, 2003 7:28 pm

Greetings constructs,

Actually, there appear to be only 0x0F46 (3910) spells (including bard songs). However, the code in eqgame.exe checks the spell id against 0x0FA0. If you make the changes that I have posted, it will be able to pass over the extra, blank, spells.

End of line...
By the pricking of my thumb, something wicked this way comes...

User avatar
dont_know_at_all
Developer
Developer
Posts: 5450
Joined: Sun Dec 01, 2002 4:15 am
Location: Florida, USA
Contact:

Post by dont_know_at_all » Thu Apr 24, 2003 7:48 pm

Here that peeps?

If you have an underpowered machine don't use spellnames to invoke spells. Use their numeric equivalent instead.

not:

Code: Select all

/cast "Yaulp"
but

Code: Select all

#define Yaulp v20
/vaset v20 $char(gem, "Yaulp")   | once on startup
and later

Code: Select all

/cast $Yaulp