Page 1 of 1

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

Posted: Sun Aug 03, 2003 1:21 pm
by EqMule
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...

Posted: Sun Aug 03, 2003 2:58 pm
by wassup
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);

Posted: Sun Aug 03, 2003 3:46 pm
by EqMule
do you have a #include <math.h> in that cpp?

I really dont know why u get that, it compiles fine here...

Posted: Sun Aug 03, 2003 5:05 pm
by wassup
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)) {
							

Posted: Mon Aug 04, 2003 1:34 am
by wassup
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)

Posted: Mon Aug 04, 2003 4:38 am
by EqMule
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?

Posted: Mon Aug 04, 2003 5:19 am
by wassup
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.

Posted: Mon Aug 04, 2003 5:21 am
by EqMule
its always negative, unless you have no focusitems, but then it's 0 so it wont matter... Ill give that a shot as well

Posted: Mon Aug 04, 2003 6:02 am
by kagonis
Very nice EQMule :)
I'm looking forward to what else you got up your sleeve :)

Posted: Mon Aug 04, 2003 3:54 pm
by wassup
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.

Posted: Mon Aug 04, 2003 6:42 pm
by dont_know_at_all
Tested and in CVS...

Posted: Mon Aug 04, 2003 9:57 pm
by EqMule
thanks

Posted: Tue Aug 05, 2003 4:40 pm
by renagade8
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