Several fixes: $char(speed), $char(ismoving), and more

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

Moderator: MacroQuest Developers

Amadeus
The Maestro
The Maestro
Posts: 2036
Joined: Sat Jun 29, 2002 3:51 pm

Several fixes: $char(speed), $char(ismoving), and more

Post by Amadeus » Wed Oct 15, 2003 9:49 pm

I can't take credit for the FindMount routine...I don't remember now who did it ..hehe. However, I realized today that all of the speed related things were broken because of mounts, so here is everything fixed.

If you guys don't like the formula in FindSpeed(), feel free to change it.


In EQLib_Utilities.cpp: (end of file) add

Code: Select all

// *************************************************************************** 
// FindMount(PSPAWNINFO) - Used to find the mount of a spawn, if one 
//                         exists. returns the spawn if one does not. 
// *************************************************************************** 
PSPAWNINFO FindMount(PSPAWNINFO pSpawn) 
{ 
   PSPAWNINFO pChar = NULL; 
   PSPAWNINFO pSpawnInfo = *EQADDR_SPAWNLIST; 
   CHAR szName[MAX_STRING] = {0}; 
   CHAR szTemp[MAX_STRING] = {0}; 

   if (!EQADDR_SPAWNLIST) return NULL; 
   if (!*EQADDR_SPAWNLIST) return NULL; 

   sprintf(szName, "%s`s Mount",pSpawn->Name); 

   for (pChar = pSpawnInfo; pChar; pChar=pChar->pNext) { 
      strcpy(szTemp,pChar->Name); 
      if (strstr(strlwr(szTemp),"'s mount")) 
         WriteChatBuffer(szTemp,USERCOLOR_WHO); 

      if (!stricmp(CleanupName(szTemp, FALSE), szName)) { 
         return pChar; 
      } 
   } 


   return pSpawn; 
} 

// *************************************************************************** 
// FindSpeed(PSPAWNINFO) - Used to find the speed of a Spawn taking a mount into
//                               consideration.
// *************************************************************************** 

FLOAT FindSpeed(PSPAWNINFO pSpawn)
{
	PSPAWNINFO pMount = NULL; 
    FLOAT fRunSpeed = 0; 

    pMount=FindMount(pSpawn); 

	if (pMount) 
	  if(!fRunSpeed) 
         fRunSpeed = pMount->SpeedRun * 10000 / 70; 


	return fRunSpeed;
}
In EQLib.h: (at line 45) add

Code: Select all

extern PSPAWNINFO FindMount(PSPAWNINFO pSpawn);
extern FLOAT FindSpeed(PSPAWNINFO pSpawn);

In EQLib_MacroParser.cpp: (at line 1069) modify what's in red

Code: Select all

    // $target(speed)
    } else if (!strncmp("target(speed)",szVar,13)) {
        CHAR szTemp[MAX_STRING] = {0};
        i+=12;
        if (!pTarget) {
            strcat(szOutput,"0");
        } else {
[color=red]            sprintf(szTemp,"%1.2f",FindSpeed(pTarget));[/color]
            strcat(szOutput,szTemp);
        }
(at line 1622) modify what's in red

Code: Select all

            // $spawn(#,speed)
            } else if (!strncmp("speed)",szRest,6)) {
                CHAR szTemp[MAX_STRING] = {0};
                i+=strstr(szVar,")")-szVar;
                if (!pSpawn) {
                    strcat(szOutput,"0");
                } else {
[color=red]                    sprintf(szTemp,"%1.2f",FindSpeed(pSpawn));[/color]
                    strcat(szOutput,szTemp);
                }
(at line 2037) modify what's in red

Code: Select all

    // $char(speed)
    } else if (!strncmp("char(speed)",szVar,11)) {
        CHAR szTemp[MAX_STRING] = {0};
        i+=10;
      [color=red]  sprintf(szTemp,"%1.2f",FindSpeed(pChar) );[/color]
       strcat(szOutput,szTemp);
(directly below....add what's in red)

Code: Select all

    // $char(ismoving)
    } else if (!strncmp("char(ismoving)",szVar,14)) {
        i+=13;
        if (gbMoving && (pChar->SpeedRun==0.0f)) {
            strcat(szOutput,"TRUE");
[color=red]	} else if (FindSpeed(pChar) > 0.0f ) {
		strcat(szOutput,"TRUE");[/color]
	} else {
            strcat(szOutput,"FALSE");
        }
Just a sidenote, that last routine isn't perfect since gbMoving is currently not working properly. However, at least ismoving will return TRUE if you're actually moving yourself either walking, running, or on a mount.

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

Post by EqMule » Thu Oct 16, 2003 5:25 am

in cvs. updated zip on downloads page 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.

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Wed Oct 22, 2003 9:43 am

I take credit for the FindMount() function, I wrote it. it's mine. thank you very much for not claiming it as your own. *grins*

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Oct 22, 2003 10:54 am

Well if y'all would comment your code you'd get credit :D

When I CVS in a change I try to add comments to show who is responsible for the changes, but I'm sure I miss a lot of them.
MQ2: Think of it as Evolution in action.

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Wed Oct 22, 2003 11:28 am

hah. I wrote it a long time ago for my /speed command, which was a gee-whiz type command to tell you the speed (in % of normal run speed) of your current target. I wanted it to find out how fast the different mount classes were... and btw, the fastest purchasable horse or drogmor is exactly as fast as a lvl 40 bard with selos.

Mckorr
Developer
Developer
Posts: 2326
Joined: Fri Oct 18, 2002 1:16 pm
Location: Texas

Post by Mckorr » Wed Oct 22, 2003 12:09 pm

Yeah, I remember when you wrote it :)

So how do those compare to pally/sk AA horses?
MQ2: Think of it as Evolution in action.

Valerian
a grimling bloodguard
a grimling bloodguard
Posts: 709
Joined: Sun Jul 28, 2002 3:29 am

Post by Valerian » Thu Oct 23, 2003 9:44 am

I've only seen one of those running around, and didn't get a name or /target in time to check their speed... definately faster than the fastest purchasable horse though

User avatar
blueninja
a grimling bloodguard
a grimling bloodguard
Posts: 541
Joined: Thu Aug 28, 2003 7:03 am
Location: Göteborg, Sweden

Post by blueninja » Fri Oct 24, 2003 8:02 am

Well, I've been wondering about various speeds too but never really got around to testing it. I have a 100k lizard myself and I have access to friend's accounts, one with white ornate chain bridle (emp horse) and one with holy steed (pally aa horse). Here are a few $char(speed) values.

Code: Select all

Duck (no runspeed aa)         32.86
Duck (with run3)              62.86
Walk (same w/ or w/o run3)    65.71
Run (no runspeed aa)            100
Run (with run3)                 130
100k Lizard                  214.29
Holy steed                      250
White ornate chain bridle       250