BUG: $char(book,spellname)

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

Moderator: MacroQuest Developers

chickenisgoot
a ghoul
a ghoul
Posts: 84
Joined: Tue Oct 07, 2003 10:52 am

BUG: $char(book,spellname)

Post by chickenisgoot » Fri Nov 07, 2003 2:44 pm

If a spell is towards the back of the spellbook (on page 49/50 for sure), $char(book,spellname) returns null. If I move the spell to page 1, it returns the correct value.

MacroFiend
a grimling bloodguard
a grimling bloodguard
Posts: 662
Joined: Mon Jul 28, 2003 2:47 am

Post by MacroFiend » Fri Nov 07, 2003 3:47 pm

The $char(book,xxx) command only parses through the first 250 spells in the spell book. Below is the correction as of the 11/5 patch (spellbook is 0x200 long in charinfo) This should allow you to search through the entire spell book by name or slot number.

Code: Select all

            if (Gem==0 && szArg[0]!='0') {
                if (szArg[0]=='"') szArg++;
                DWORD sp;
                for (sp=0;sp<[color=red]512[/color];sp++) {
                    if (pCharInfo->SpellBook[sp] != 0xFFFFFFFF) {
                        PCHAR SpellName = GetSpellByID(pCharInfo->SpellBook[sp]);
                        if (!strnicmp(szArg,SpellName,strlen(SpellName))) {
                            itoa(sp+1,szTemp,10);
                        }
                    }
                }
            } else {
                if (Gem>0 && Gem<[color=red]512[/color]) {
                    if (pCharInfo->SpellBook[Gem-1] != 0xFFFFFFFF) {

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 Nov 13, 2003 1:24 am

CVSed.

NotSoCSharp
a ghoul
a ghoul
Posts: 85
Joined: Sat Oct 25, 2003 10:48 am

Post by NotSoCSharp » Thu Nov 13, 2003 7:44 am

I wrote a little macro to dump all the spells in my spell book to a log file with the spell id, spell name, and spell level. Everything worked great except these spells show a spell id of -1 and a spell level of -1. Not sure if this is the case with any of the other LDoN spells. Anyone else see this??


Wuggan's Greater Appraisal
Wuggan's Greater Discombobulation
Wuggan's Greater Extrication

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 Nov 13, 2003 1:30 pm

Spell ids are 0 to 4497.

0xffffffff or -1 means there is no spell in that slot.

NotSoCSharp
a ghoul
a ghoul
Posts: 85
Joined: Sat Oct 25, 2003 10:48 am

Post by NotSoCSharp » Thu Nov 13, 2003 2:53 pm

Thats the thing. The spells are in the slot. I don't dump them if the function returns NULL. These spells are in the book but return -1 for those values.

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 Nov 13, 2003 3:11 pm

Post your macro.

NotSoCSharp
a ghoul
a ghoul
Posts: 85
Joined: Sat Oct 25, 2003 10:48 am

Post by NotSoCSharp » Thu Nov 13, 2003 3:15 pm

Here ya go. These spells do not return NULL so they get dumped into the log with -1 for spell id and level. All the other spells show up just fine.

Let me know if you see anything I am missing.

Code: Select all


#turbo

Sub Main

    /declare i local
    
    /mqlog clear
    /for i 1 to 512
       /if "$char(book,@i)"=="NULL" /goto :End
       /mqlog "$spell("$char(book,@i)",id) , $char(book,@i) , $spell("$char(book,@i)",level)"
    :End
    /next i
/return


NotSoCSharp
a ghoul
a ghoul
Posts: 85
Joined: Sat Oct 25, 2003 10:48 am

Post by NotSoCSharp » Tue Dec 02, 2003 11:10 am

This appears to still be a problem in MQ2. Someone may want to move this thread to the MQ2 area.

MQ2Parms.cpp:

Code: Select all

            if (Gem==0 && szArg[0]!='0') {
                if (szArg[0]=='"') szArg++;
                DWORD sp;
                for (sp=0;sp<[color=red]250[/color];sp++) {
                    if (pCharInfo->SpellBook[sp] != 0xFFFFFFFF) {
                        PCHAR SpellName = GetSpellByID(pCharInfo->SpellBook[sp]);
                        if (!strnicmp(szArg,SpellName,strlen(SpellName))) {
                            itoa(sp+1,szTemp,10);
                        }
                    }
                }
            } else {
                if (Gem>0 && Gem<[color=red]251[/color]) {
                    if (pCharInfo->SpellBook[Gem-1] != 0xFFFFFFFF) {
                        strcpy(szTemp,GetSpellByID(pCharInfo->SpellBook[Gem-1]));
                    } else {
                        strcpy(szTemp,"NULL");
                    }
                } else {
                    strcpy(szTemp,"NULL");
                }
            }

NotSoCSharp
a ghoul
a ghoul
Posts: 85
Joined: Sat Oct 25, 2003 10:48 am

Post by NotSoCSharp » Mon Dec 08, 2003 8:41 am

Anyone know if this got fixed in MQ2? I have a macro that needs this is why I am asking. I did fix it myself but it would be nice if it were put in the CVS/ZIP.

Thanks!

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 » Mon Dec 08, 2003 3:36 pm

CVSed.