Random additions.. doability, ranged, etc for CVS

Moderator: MacroQuest Developers

Red-One
a ghoul
a ghoul
Posts: 143
Joined: Tue Dec 28, 2004 9:14 pm

Random additions.. doability, ranged, etc for CVS

Post by Red-One » Mon Nov 21, 2005 12:28 am

****These changes have added to CVS and are no longer necessary****

add to eqmain.h following the lines:
#include "ISXEQ\ISXEQUtilities.h"
#include "ISXEQ\ISXEQCommands.h"

Code: Select all

EQLIB_API VOID UseAbility(char *sAbility);
EQLIB_API VOID EzCommand(PCHAR Line);
EQLIB_API VOID UseRanged(int SpawnID);
change cmd_eqexecute in isxeqcommandsAPI to

Code: Select all

int CMD_EQExecute(int argc, char *argv[])
{
	if (gGameState!=GAMESTATE_INGAME)
	{
		WriteChatf("Cannot execute EQ command, not in game!");
		return 0;
	}
	if (argc<2)
	{
		WriteChatf("Syntax: %s <command>",argv[0]);
		return 0;
	}
	char Line[8192]={0};
	pISInterface->GetArgs(1,argc,argv,Line);
	EzCommand(Line);
	//((CCommandHook*)pEverQuest)->Trampoline((PSPAWNINFO)pLocalPlayer,Line);
	return 0;
}
than add in below it

Code: Select all

void EzCommand(PCHAR Line) {

	((CCommandHook*)pEverQuest)->Trampoline((PSPAWNINFO)pLocalPlayer,Line);
	return;
}
change cmd_do_ranged in isxeqcommands to

Code: Select all

int CMD_do_ranged(int argc, char *argv[])
{
	char szBuffer[MAX_STRING] = {0};
	pISInterface->GetArgs(1,1,argv,szBuffer);
	if (szBuffer) {
		UseRanged(atoi(szBuffer));
	} else if (pTarget) {
		UseRanged(((PSPAWNINFO)pTarget)->SpawnID);
	} else if (!pTarget) {
			printf("No target for ranged attack");
			return 0;
	}
		
	return 0;
}
change cmd_doability in isxeqcommand to

Code: Select all

int CMD_DoAbility(int argc, char *argv[]) 
{
	
    DWORD Index, DoIndex = 0xFFFFFFFF; 
    CHAR szBuffer[MAX_STRING] = {0}; 

    if (!stricmp(argv[1],"list") || !stricmp(argv[1], "-list")) { 
        WriteChatColor("Abilities:",USERCOLOR_DEFAULT); 
        for (Index=4;Index<10;Index++) { 
            if (EQADDR_DOABILITYLIST[Index]==0xFFFFFFFF) { 
                sprintf(szBuffer,"%d. <Empty>",Index-3); 
            } else if (szSkills[EQADDR_DOABILITYLIST[Index]]) { 
                sprintf(szBuffer,"%d. %s",Index-3,szSkills[EQADDR_DOABILITYLIST[Index]]); 
            } else { 
                sprintf(szBuffer,"%d. *Unknown%d",Index-3,EQADDR_DOABILITYLIST[Index]); 
            } 
            WriteChatColor(szBuffer,USERCOLOR_DEFAULT); 
        } 
        WriteChatColor("Combat Skills:",USERCOLOR_DEFAULT); 
        for (Index=0;Index<4;Index++) { 
            if (EQADDR_DOABILITYLIST[Index]==0xFFFFFFFF) { 
                sprintf(szBuffer,"%d. <Empty>",Index+7); 
            } else if (szSkills[EQADDR_DOABILITYLIST[Index]]) { 
                sprintf(szBuffer,"%d. %s",Index+7,szSkills[EQADDR_DOABILITYLIST[Index]]); 
            } else { 
                sprintf(szBuffer,"%d. *Unknown%d",Index+7,EQADDR_DOABILITYLIST[Index]); 
            } 
            WriteChatColor(szBuffer,USERCOLOR_DEFAULT); 
        } 
        WriteChatColor("Combat Abiilities:",USERCOLOR_DEFAULT); 
        for (Index=10;Index<18;Index++) { 
            if (EQADDR_DOABILITYLIST[Index]==0xFFFFFFFF) { 
                sprintf(szBuffer,"%d. <Empty>",Index+1); 
         } else if (EQADDR_DOABILITYLIST[Index] > 132) { // highest number we have defined so far 
            sprintf(szBuffer,"%d. *Unknown%d",Index+1,EQADDR_DOABILITYLIST[Index]); 
            } else if (szSkills[EQADDR_DOABILITYLIST[Index]]) { 
                sprintf(szBuffer,"%d. %s",Index+1,szSkills[EQADDR_DOABILITYLIST[Index]]); 
            } else { 
                sprintf(szBuffer,"%d. *Unknown%d",Index+1,EQADDR_DOABILITYLIST[Index]); 
            } 
            WriteChatColor(szBuffer,USERCOLOR_DEFAULT); 
        } 
        return 0; 
    } 

   pISInterface->GetArgs(1,argc,argv,szBuffer);
   UseAbility(szBuffer);

   return 0; 
}
...note it crashes without a param...

add in to isxeqcommands

Code: Select all

void UseRanged(int SpawnID) {

	EQPlayer *pRangedTarget=pTarget;
	if (SpawnID)
	{
		pRangedTarget=GetSpawnByID(SpawnID);
		if (!pRangedTarget)
		{
			printf("Invalid spawn ID.  Use /ranged with no parameters, or with a spawn ID");
			return;
		}
	}
	if (!pRangedTarget)
	{
		printf("No target for ranged attack");
		return;
	}
	if (gbRangedAttackReady)
	{
		pLocalPlayer->DoAttack(0x0B,0,pRangedTarget);
		gbRangedAttackReady=0;
	}
	return;
}

...I think that is everything. I am assuming that these it could be the wrong way to go or not be optimized. Open to feedback. This is an attempt to seperate commands from functionality.

-Red
Last edited by Red-One on Tue Nov 29, 2005 7:44 am, edited 3 times in total.

Red-One
a ghoul
a ghoul
Posts: 143
Joined: Tue Dec 28, 2004 9:14 pm

...

Post by Red-One » Mon Nov 21, 2005 12:29 am

also add to isxeqcommands

Code: Select all

void UseAbility(char *sAbility) {
	
	CHAR szBuffer[MAX_STRING] = {0};
	sprintf(szBuffer, "%s",sAbility);

	if (!cmdDoAbility) 
    { 
      PCMDLIST pCmdListOrig = (PCMDLIST)EQADDR_CMDLIST; 
      for (int i=0;pCmdListOrig[i].fAddress != 0;i++) { 
         if (!strcmp(pCmdListOrig[i].szName,"/doability")) { 
            cmdDoAbility = (fEQCommand)pCmdListOrig[i].fAddress; 
         } 
      } 
    } 
    if (!cmdDoAbility) return; 
	
	//if (argc<2 || atoi(argv[1]) || !EQADDR_DOABILITYLIST) { 
	if (atoi(szBuffer) || !EQADDR_DOABILITYLIST) { 
        cmdDoAbility((PSPAWNINFO)pLocalPlayer,szBuffer); 
        return; 
    }
	
	DWORD Index, DoIndex = 0xFFFFFFFF;
	PSPAWNINFO pChar =(PSPAWNINFO)pCharSpawn;

    for (Index=0;Index<10;Index++) { 
        if (EQADDR_DOABILITYLIST[Index]!= 0xFFFFFFFF) { 
            if (!strnicmp(szBuffer,szSkills[EQADDR_DOABILITYLIST[Index]],strlen(szSkills[EQADDR_DOABILITYLIST[Index]]))) { 
                if (Index<4) { 
                    DoIndex = Index+7; // 0-3 = Combat abilities (7-10) 
                } else { 
                    DoIndex = Index-3; // 4-9 = Abilities (1-6) 
                } 
			}
        } 
    } 
	
    if (DoIndex!=0xFFFFFFFF) { 
		cmdDoAbility(pChar,itoa(DoIndex,szBuffer,10)); 
    } else { 
		PSPELL pCA = NULL; 
        for (Index=0;Index<NUM_COMBAT_ABILITIES;Index++) { 
			
         if (GetCharInfo2()->CombatAbilities[Index]) { 
			 
            pCA = GetSpellByID(GetCharInfo2()->CombatAbilities[Index]);
			if (!stricmp(pCA->Name, szBuffer)) { 
               //We got the cookie, let's try and do it  
               pCharData->DoCombatAbility(pCA->ID); 
               break; 
            } 
         } 
        } 
      if (Index >= NUM_COMBAT_ABILITIES) 
         WriteChatColor("You do not seem to have that ability available",USERCOLOR_DEFAULT); 
    } 
	return;
}
-Red

echoism
a ghoul
a ghoul
Posts: 131
Joined: Tue Oct 19, 2004 9:59 am

Post by echoism » Fri Dec 02, 2005 1:56 pm

While I know these have been added to the csv, I had some questions:

In the cmd_doability function (ISXEQCommands.cpp), did you mean to strip this out from the beginning?
This would prevent crashing due to not having a param.

Code: Select all

	if (argc<2)
	{
		printf("Syntax: %s list|<ability>",argv[0]);
		return 0;
	}
Also, I noticed that you copied the UseAbility function from MQ2Utilities, couldn't that be avoided by moving it outside the #ifndef ISXEQ_LEGACY condition?

Lax
We're not worthy!
We're not worthy!
Posts: 3524
Joined: Thu Oct 17, 2002 1:01 pm
Location: ISBoxer
Contact:

Post by Lax » Fri Dec 02, 2005 2:48 pm

The current zip has the issues you brought up dealt with, echoism (as of nov 28 zip)
Lax Lacks
Master of MQ2 Disaster
Purveyor of premium, EULA-safe MMORPG Multiboxing Software
* Multiboxing with ISBoxer: Quick Start Video
* EQPlayNice, WinEQ 2.0

echoism
a ghoul
a ghoul
Posts: 131
Joined: Tue Oct 19, 2004 9:59 am

Post by echoism » Fri Dec 02, 2005 5:14 pm

Alright.
I assume, no UseRanged function then.
I was trying to get ISXEQMelee to work without having to do much work to it.
Maybe after dinner.

Red-One
a ghoul
a ghoul
Posts: 143
Joined: Tue Dec 28, 2004 9:14 pm

Post by Red-One » Fri Dec 02, 2005 7:30 pm

Since lax added these to the CVS you just have to download, compile and go. Or form the ismod forums... just download and go


-Red