Page 1 of 1

$char(gem,xxx) fixed!

Posted: Wed Jul 30, 2003 9:46 pm
by EqMule
ok I set out to fix this a long time ago, and it seems to be one of the most wanted features as well, I have tried to keep the function as it was before new UI, so here give it a try:

it will return -2 if a spell is not ready to be cast...

this code goes in EQLib_MacroParser.cpp

Code: Select all

 [color=green]					// $char(gem,xxx) example: /echo $char(gem,"Spirit of Wolf")[/color]
						} else if (!strncmp("char(gem,",szVar,9)) {
							if (!strstr(szVar,")")) {
								DebugSpew("PMP - Bad $char() '%s'",szVar);
								i--;
								szOutput[j] = '@';
								j++;
							} else {
								PEQCASTSPELLWINDOW pCastSpellWindow = NULL;
								PEQCASTSPELLWINDOW pSpellSlot = NULL;
								pCastSpellWindow = (PEQCASTSPELLWINDOW)*EQADDR_CLASSCASTSPELLWND;
								i += (strstr(szVar,")")-szVar);
								CHAR szTemp[MAX_STRING] = "0";
								PCHAR szArg = szVar+9;
								WORD Gem = atoi(szArg);
								if (Gem==0 && szArg[0]!='0') {
									if (szArg[0]=='"') szArg++;
									DWORD sp;
									for (sp=0;sp<8;sp++) {
										pSpellSlot = NULL;
										pSpellSlot = (PEQCASTSPELLWINDOW)pCastSpellWindow->SpellSlots[sp];
										DebugSpew("%x",pSpellSlot->spellstate);
										if (pCharInfo->MemorizedSpells[sp] != 0xFFFFFFFF) {
											PCHAR SpellName = GetSpellByID(pCharInfo->MemorizedSpells[sp]);
											if (!strnicmp(szArg,SpellName,strlen(SpellName))) {
												if (!EQADDR_CLASSCASTSPELLWND) {
													itoa(sp+1,szTemp,10);
												} else {
													if (pSpellSlot->spellstate != 0) {
														strcpy(szTemp,"-2");
													} else {
														itoa(sp+1,szTemp,10);
													}
												}
											}
										}
									}
								} [color=red]else {
									if (Gem>0 && Gem<9) {[/color] 
and in EQLib_Main.cpp

Code: Select all

DWORD *EQADDR_CLASSCASTSPELLWND;

Code: Select all

	GetPrivateProfileString("Class Locations","ClassCastSpellWnd","0",szBuffer,MAX_STRING,ClientINI);		EQADDR_CLASSCASTSPELLWND = (PDWORD)strtoul(szBuffer,NULL,16);
and in EQLib.h

Code: Select all

extern DWORD *EQADDR_CLASSCASTSPELLWND;
Now... I know you all hate this, but for this to work we need a new structure, I couldnt use the "generic" EQWINDOW because there where differences I couldnt fix... (yes I know now that its not really windows its more like trees, but maybe ill do a revamp someday of my structs and shit...) so I HAD to copy it and make a structure for just this function, go figure... anyway here it is...

in MQ.h

Code: Select all

typedef struct _EQCASTSPELLWINDOW {
			DWORD   WindowID; 
			DWORD   TimeMouseOver;         //how many ms the window has had the mouse over it... 
			DWORD   Unknown0x008;      // 2000 seems a common value 
			DWORD   Unknown0x00c;      //500 seems a common value 
			BYTE    Flag; 
			BYTE    MouseOver;         //01 yes 00 no 
			BYTE    Unknown0x012; 
			BYTE    Unknown0x013; 
			BYTE    Unknown0x014[12]; 
			struct  _EQWINDOW *pDownTheTreeOnSameWindow; 
			struct  _EQWINDOW *pNextWindow; 
			DWORD   Flags4; 
			DWORD   Z;               //not sure but its logical to assume it at this point... 
			DWORD   X; 
			DWORD   Y; 
			DWORD   Height; 
			DWORD   Width; 
            DWORD   Depth;            //hmmm... 
            BYTE    Unknown0x040[12]; 
            BYTE    Open;            //1 open 0 closed 
            BYTE    Unknown0x051[7]; 
            DWORD   somekindofID; 
            DWORD   *pUnknownStruct0x060; 
            struct  _EQWINDOWINFO *Info; 
			BYTE	Unknown[88];
			BYTE	Unknown1[68];
			DWORD	SlotID;			
			BYTE	Unknown2[16];
			BYTE	Selector;		//this graphically selects an item on/off
			BYTE	Unknown3[7];
			BYTE	Unknown4[32];
struct _EQCASTSPELLWINDOW	*SpellSlots[8];
			DWORD   Unknown5[3];
			DWORD	spellicon;//if this is equal to FFFFFFFF there is no spell memmed in this slot...
			DWORD	spellstate;// 1 = cast in progress or refreshtime not met 2 means we ducked or aborted cast, 0 means its ok to cast
} EQCASTSPELLWINDOW, *PEQCASTSPELLWINDOW;
and as usual we got a new offset to play with in eqgame.ini

Code: Select all

[Class Locations]
ClassCastSpellWnd=005fe254
and as always, if Plaz releases his code for this, you should use that instead. Im just patching stuff as I go...

Nice!

Posted: Thu Jul 31, 2003 12:36 am
by wassup
Added and did the build... will test it later.

Bombing

Posted: Sun Aug 03, 2003 5:12 pm
by serberus
ok, this just makes EQ bomb whenever I type "/echo $char(gem,1)"

Anyway I can get some sort of debug output?

Thanks

Serberus

Re: Bombing

Posted: Sun Aug 03, 2003 7:09 pm
by wassup
serberus wrote:ok, this just makes EQ bomb whenever I type "/echo $char(gem,1)"

Anyway I can get some sort of debug output?

Thanks

Serberus
Pretty sure you need to be using the spell name instead of 1, just like this part shows:

Code: Select all

// $char(gem,xxx) example: /echo $char(gem,"Spirit of Wolf")

Still Bombs

Posted: Sun Aug 03, 2003 8:11 pm
by serberus
It still bombs if I use a spellname instead of a number.

All the other macroquest features and function seem to be functioning perfectly.

No errors upon compiling.

Just that the $char(gem,xxx) function causes it to bomb...

Serberus

Posted: Sun Aug 03, 2003 8:34 pm
by EqMule
hopefully someone managed to compile and get it working, I guess we just have to wait and hope someone posts that it works, I know it works perfectly here... I didnt really change how the function works... just the place it gets the info, so u need to use "spell name" it was always like that, gem,1 just wont work...

maybe u pasted the structure in the wrong place? it needs to be under the _EQWINDOW struct

or forgot to add the offset in eqgame.ini ?

Bomb

Posted: Mon Aug 04, 2003 4:08 pm
by serberus
ok, I moved the struct below the _EQWINDOW struct and recompiled.

Still bombs when I try to use that function in EQ.

My MacroQuest directory is viewable here:

http://81.6.197.227/macroquest

It's the latest CVS with your changes incorporated, all works but the $char(gem,xxx) function.

If you're feeling very helpful i've made a little spot where you can upload files too =)

ftp://macroquest:macroquest@81.6.197.227

Thanks

Serberus

Posted: Mon Aug 04, 2003 5:35 pm
by EqMule
I will take a lok at it Ill PM you when I have. Ill put something precompiled for u on the ftp as well, so we can rule out a compiling issue

Thanks

Posted: Mon Aug 04, 2003 5:58 pm
by serberus
Thanks very much, that'll be much appreciated =)

Serberus

Posted: Mon Aug 04, 2003 7:43 pm
by dont_know_at_all
In cvs with a caveat: this doesn't work correctly for bards. If a song is playing, it always returns -2 even if the gems are ungreyed.

Updated on downloads page.

Posted: Mon Aug 04, 2003 10:00 pm
by EqMule
ok, I dont have a bard, but I can create one and see if it can be easily fixed. I will take a look at it. Thanks for putting it in though. I take it you got it to work? we had one user so far that says it doesnt work.

Posted: Mon Aug 04, 2003 10:21 pm
by dont_know_at_all
I changed one place where you were setting pSpellSlot before checking if pCastSpellWindow was valid. This would cause a crash if eqgame.ini was not updated.

I assume that was the problem...

EQgame.ini

Posted: Tue Aug 05, 2003 4:06 am
by serberus
I definately had eqgame.ini updated.

ClassCastSpellWnd=005fe254

put that at the bottom of the [ClassLocations] section.

I'll try rebuilding from the new CVS.

Serberus

Working

Posted: Tue Aug 05, 2003 7:38 pm
by serberus
Using the IRC-latest.zip from todays date I now have the $char(gem,xxx) function working.

Thanks very much EqMule00 and dont_know_at_all

Serberus

Posted: Tue Aug 05, 2003 7:44 pm
by EqMule
glad to hear u worked it out. 8)