$char(gem,xxx) fixed!

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

Moderator: MacroQuest Developers

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

$char(gem,xxx) fixed!

Post by EqMule » Wed Jul 30, 2003 9:46 pm

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...
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.

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Nice!

Post by wassup » Thu Jul 31, 2003 12:36 am

Added and did the build... will test it later.

serberus
a lesser mummy
a lesser mummy
Posts: 58
Joined: Tue Nov 19, 2002 5:04 am

Bombing

Post by serberus » Sun Aug 03, 2003 5:12 pm

ok, this just makes EQ bomb whenever I type "/echo $char(gem,1)"

Anyway I can get some sort of debug output?

Thanks

Serberus

wassup
Official Guardian and Writer of TFM
Official Guardian and Writer of TFM
Posts: 1487
Joined: Sat Oct 26, 2002 5:15 pm

Re: Bombing

Post by wassup » Sun Aug 03, 2003 7:09 pm

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")

serberus
a lesser mummy
a lesser mummy
Posts: 58
Joined: Tue Nov 19, 2002 5:04 am

Still Bombs

Post by serberus » Sun Aug 03, 2003 8:11 pm

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

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

Post by EqMule » Sun Aug 03, 2003 8:34 pm

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 ?
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.

serberus
a lesser mummy
a lesser mummy
Posts: 58
Joined: Tue Nov 19, 2002 5:04 am

Bomb

Post by serberus » Mon Aug 04, 2003 4:08 pm

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

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

Post by EqMule » Mon Aug 04, 2003 5:35 pm

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
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.

serberus
a lesser mummy
a lesser mummy
Posts: 58
Joined: Tue Nov 19, 2002 5:04 am

Thanks

Post by serberus » Mon Aug 04, 2003 5:58 pm

Thanks very much, that'll be much appreciated =)

Serberus

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 Aug 04, 2003 7:43 pm

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.

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

Post by EqMule » Mon Aug 04, 2003 10:00 pm

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.
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.

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 Aug 04, 2003 10:21 pm

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...

serberus
a lesser mummy
a lesser mummy
Posts: 58
Joined: Tue Nov 19, 2002 5:04 am

EQgame.ini

Post by serberus » Tue Aug 05, 2003 4:06 am

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

serberus
a lesser mummy
a lesser mummy
Posts: 58
Joined: Tue Nov 19, 2002 5:04 am

Working

Post by serberus » Tue Aug 05, 2003 7:38 pm

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

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

Post by EqMule » Tue Aug 05, 2003 7:44 pm

glad to hear u worked it out. 8)
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.