NEW FEATURE! $spell("name of spell",mycasttime)

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:

NEW FEATURE! $spell("name of spell",mycasttime)

Post by EqMule » Sun Aug 03, 2003 1:21 pm

this function gets your real casttime if you have focusitems on... it will report normal casttime if you dont have anything that will reduce the casttime...

in EQLib_MacroParser.cpp

Code: Select all

 [color=red]} else if (!strncmp(szArg,"casttime",8)) {
								sprintf(szTemp,"%1.2f",(FLOAT)pSpell->CastTime/1000);
							}[/color] else if (!strncmp(szArg,"mycasttime",10)) {
								DWORD CharInfo = NULL;
								CharInfo = (DWORD)*EQADDR_CHAR_INFO;
								DWORD mycasttime = 0;
							__asm{
									push ecx;
									mov ecx, dword ptr [CharInfo];
									push 0;
									push dword ptr [pSpell];
									call dword ptr [EQADDR_GETFOCUSCASTINGTIMEMODIFIER];
									mov [mycasttime], eax;
									pop ecx;
								   };
								mycasttime = pSpell->CastTime + mycasttime;
								DebugSpew("mycasttime %d pSpell->CastTime = %d",mycasttime,pSpell->CastTime);
								sprintf(szTemp,"%1.2f",(FLOAT)mycasttime/1000);
							}[color=red] else if (!strncmp(szArg,"recoverytime",12)) {[/color] 
in EQLib_Main.cpp

Code: Select all

DWORD EQADDR_GETFOCUSCASTINGTIMEMODIFIER=0;

Code: Select all

	GetPrivateProfileString("Function Locations","GetFocusCastingTimeModifier","0",szBuffer,MAX_STRING,ClientINI);	EQADDR_GETFOCUSCASTINGTIMEMODIFIER = (DWORD)strtoul(szBuffer,NULL,16); 
in EQLib.h

Code: Select all

extern DWORD EQADDR_GETFOCUSCASTINGTIMEMODIFIER;
and finally you need a new offset in eqgame.ini

Code: Select all

[Function Locations]
GetFocusCastingTimeModifier=0046DF33
ok, I wrote this function to cut down castingtime in a certain tradeskill which requires casting... it reduces my chars castingtime alot, as a sidebonus it will give you an extra edge when timing is crucial in high end encounters.. it is GREAT!

just replace this line in your spellsub.mac

Code: Select all

/varset CastTime $spell("$SpellName",casttime)
with

Code: Select all

/varset CastTime $spell("$SpellName",mycasttime)
and you are set to go!


Can I get this tested and cvsed please?
edit 04 Aug 2003 for Wassup's fix of a VS.NET issue...
Last edited by EqMule on Mon Aug 04, 2003 5:47 pm, edited 1 time in total.
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

Post by wassup » Sun Aug 03, 2003 2:58 pm

Trying to compile and get this error:

f:\Compile\macroquest\EQLib\EQLib_MacroParser.cpp(2607): error C2668: 'abs' : ambiguous call to overloaded function

which points to this line:

Code: Select all

mycasttime = pSpell->CastTime - abs(mycasttime);

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

Post by EqMule » Sun Aug 03, 2003 3:46 pm

do you have a #include <math.h> in that cpp?

I really dont know why u get that, it compiles fine here...
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

Post by wassup » Sun Aug 03, 2003 5:05 pm

Yes, the include is there... I just checked it.

here is the entire section fo the code I have, maybe I am just missing something:

Code: Select all

                     } else if (!strncmp(szArg,"casttime",8)) {
								sprintf(szTemp,"%1.2f",(FLOAT)pSpell->CastTime/1000);
							} else if (!strncmp(szArg,"mycasttime",10)) { 
								DWORD CharInfo = NULL; 
								CharInfo = (DWORD)*EQADDR_CHAR_INFO; 
								DWORD mycasttime = 0; 
							__asm{ 
										push ecx; 
										mov ecx, dword ptr [CharInfo]; 
										push 0; 
										push dword ptr [pSpell]; 
										call dword ptr [EQADDR_GETFOCUSCASTINGTIMEMODIFIER]; 
										mov [mycasttime], eax; 
										pop ecx; 
							     }; 
								mycasttime = pSpell->CastTime - abs(mycasttime); 
								DebugSpew("mycasttime %d pSpell->CastTime = %d",mycasttime,pSpell->CastTime); 
								sprintf(szTemp,"%1.2f",(FLOAT)mycasttime/1000); 
							} else if (!strncmp(szArg,"recoverytime",12)) {
							

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

Post by wassup » Mon Aug 04, 2003 1:34 am

OK, I did some searching on the wweb.

It seems there is a problem using abs in VC.net.

I am guessing you are using VC6 when you compile.

Will see if I can find a workaround but for now I changed your abs(mycasttime) to int(mycasttime)

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

Post by EqMule » Mon Aug 04, 2003 4:38 am

yeah im using vc6...

I wonder what happens if you use int... abs takes the negative number an turns it into a positive... Lets take Spirit of Wolf as an example, I have golden efreeti boots on, effect is enhancement haste II, ok here goes, the casting time without a modifier is 4.50 sec , we run it through the function and it will return -1350 (0xFFFFFABA) so we need to either reverse it by using abs or the calculation can be done as follows 4500 + (-1350) because if you just do 4500 - (-1350) you will not get the correct modifier? (I think, Im not a math genious) ... ok correct me if im wrong...

I tried doing a int test = 4500 + (0xFFFFFABA); to see if it would return 3150 in test, and it will, but I get a compile warning when I have the code like that, so I changed it to the abs thing... maybe someone have a better idea?
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

Post by wassup » Mon Aug 04, 2003 5:19 am

If the value of mycasttime in the abs(mycasttime) is negative, it should be fine if you just use addition to avoid the problem, and removing the use of the abs function will speed things up a bit (not that it matters with todays pc's).

so change

Code: Select all

mycasttime = pSpell->CastTime - abs(mycasttime); 
to

Code: Select all

mycasttime = pSpell->CastTime + mycasttime;
should work as intended providing mycasttime in the calculation is always a negative number.

I'll give it a try and see how it works.

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

Post by EqMule » Mon Aug 04, 2003 5:21 am

its always negative, unless you have no focusitems, but then it's 0 so it wont matter... Ill give that a shot as well
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 » Mon Aug 04, 2003 6:02 am

Very nice EQMule :)
I'm looking forward to what else you got up your sleeve :)

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

Post by wassup » Mon Aug 04, 2003 3:54 pm

EQMule:

Works fine with:

Code: Select all

mycasttime = pSpell->CastTime + mycasttime;

Wish I could get a good handle on finding offsets, I would really love to be able to have AA effects taken into account also.

Some spells affected by AA don't report a reduced cast time using this.

PS: Just so I don;t appear to be a moron... I changed it to (int)mycasttime before so it would compile.

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 6:42 pm

Tested and in CVS...

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

Post by EqMule » Mon Aug 04, 2003 9:57 pm

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

renagade8
orc pawn
orc pawn
Posts: 28
Joined: Sat Oct 19, 2002 9:17 pm

Post by renagade8 » Tue Aug 05, 2003 4:40 pm

I crash when i try to use this and here is the call stack for the debug:

ChildEBP RetAddr
000c1c0c 0157a03c 0x0
0012bed8 0156b527 EQLib!ParseMacroParameter+0x810c (CONV: cdecl) [EQLib_MacroParser.cpp @ 2647]
0012d6f8 004c7368 EQLib!CCommandHook::Detour+0x2c7 (FPO: [EBP 0x0012d6fc] [2,1537,4]) (CONV: thiscall) [EQLib_Hooks.cpp @ 215]
WARNING: Stack unwind information not available. Following frames may be wrong.
0012d768 029ac86c eqgame+0xc7368
00000001 00000000 EQGfx_Dx8!t3dSetTrackDefaultSpeed+0x8c

-ren