VOID Style(PSPAWNINFO pChar, PCHAR szLine) { if (!szLine || !szLine[0]) { char out[256] = { 0 }; sprintf_s(out,"Style 0x%X",MQChatWnd->WindowStyle); WriteChatColor(out); return; } if (szLine[0]=='!') { int TurnOff = 0; if(sscanf_s(&szLine[1],"%x",&TurnOff)) { //well we set it anyway i guess... } BitOff(MQChatWnd->WindowStyle, TurnOff); } else { int TurnOn = 0; if(sscanf_s(&szLine[0],"%x",&TurnOn)) { //hmm can error handle i guess } BitOn(MQChatWnd->WindowStyle,TurnOn); } char out[256]; sprintf_s(out,"Style 0x%X",MQChatWnd->WindowStyle); WriteChatColor(out); }
// *************************************************************************** // Function: PickZoneCmd // Description: '/pickzone' command // Adds the ability to do /pickzone # // Usage: /pickzone 2 will switch zone to number 2 pickzone 0 will pick main instance // *************************************************************************** //VOID PickZoneCmd(PSPAWNINFO pChar, PCHAR szLine) int CMD_PickZone(int argc, char *argv[]) { if (!cmdPickZone) { PCMDLIST pCmdListOrig = (PCMDLIST)EQADDR_CMDLIST; for (int i=0;pCmdListOrig[i].fAddress != 0;i++) { if (!strcmp(pCmdListOrig[i].szName,"/pickzone")) { cmdPickZone = (fEQCommand)pCmdListOrig[i].fAddress; } } } if (!cmdPickZone) return -1; PCHAR szLine = NULL; if (argc > 1) szLine = argv[1]; if (!szLine || (szLine && szLine[0]=='\0')) { WriteChatColor("Usage: /pickzone # where # is the instance number you want to pick"); if (PCHARINFO pCharInfo = GetCharInfo()) { cmdPickZone(pCharInfo->pSpawn, szLine); } return 0; } else { DWORD index = atoi(szLine); DWORD nThreadID = 0; CreateThread(NULL, 0, openpickzonewnd, (PVOID)index, 0, &nThreadID); } return 0; }
VOID MapActiveLayerCmd(PSPAWNINFO pChar, PCHAR szLine) { CHAR szBuffer[MAX_STRING] = { 0 }; bRunNextCommand = TRUE; int newActiveLayer = atoi(szLine); if (szLine == 0 || szLine[0] == 0 || newActiveLayer < 0 || newActiveLayer > 3) { SyntaxError("Usage: /mapactivelayer [0|1|2|3]"); return; }; activeLayer = newActiveLayer; sprintf_s(szBuffer, "Map Active Layer: %d", activeLayer); WriteChatColor(szBuffer); // Write setting to file char szTest[5]; sprintf_s(szTest, "%d", activeLayer); WritePrivateProfileString("Map Filters", "ActiveLayer", szTest, INIFileName); // refresh map MapClear(); MapGenerate(); }
VOID BackgroundHUD(PSPAWNINFO pChar, PCHAR szLine) { if (!_stricmp(szLine,"off")) { WritePrivateProfileString(HUDSection,"UpdateInBackground","off",INIFileName); WriteChatColor("MQ2HUD::Background updates are OFF"); } else if (!_stricmp(szLine,"on")) { WritePrivateProfileString(HUDSection,"UpdateInBackground","on",INIFileName); WriteChatColor("MQ2HUD::Background updates are ON"); } else { WriteChatColor("Usage: /backgroundhud [on|off]"); return; } HandleINI(); }
VOID ZoneHUD(PSPAWNINFO pChar, PCHAR szLine) { if (!_stricmp(szLine,"off")) { WritePrivateProfileString(HUDSection,"ZoneHUD","off",INIFileName); WriteChatColor("MQ2HUD::Auto-include HUD per zone name is OFF"); } else if (!_stricmp(szLine,"on")) { WritePrivateProfileString(HUDSection,"ZoneHUD","on",INIFileName); WriteChatColor("MQ2HUD::Auto-include HUD per zone name is ON"); } else { WriteChatColor("Usage: /zonehud [on|off]"); return; } HandleINI(); }
VOID DumpStack(PSPAWNINFO pChar, PCHAR szLine) { CHAR szTemp[MAX_STRING] = {0}; CHAR szSub[MAX_STRING] = {0}; PMACROSTACK pMS = gMacroStack; while (pMS!=NULL) { sprintf(szTemp,"%s@%d (%s): %s",pMS->Location->SourceFile,pMS->Location->LineNumber, GetSubFromLine(pMS->Location,szSub), pMS->Location->Line); WriteChatColor(szTemp,USERCOLOR_DEFAULT); if (bAllErrorsLog) MacroLog(NULL, szTemp); pMS=pMS->pNext; } }
int CMD_EQItems(int argc, char *argv[]) { if (!ppItemList) return 0; if (!pItemList) return 0; PSPAWNINFO pChar = (PSPAWNINFO)pLocalPlayer; PGROUNDITEM pItem = (PGROUNDITEM)pItemList; DWORD Count=0; CHAR szBuffer[MAX_STRING] = {0}; CHAR szName[MAX_STRING]={0}; WriteChatColor("Items on the ground:", USERCOLOR_DEFAULT); WriteChatColor("---------------------------", USERCOLOR_DEFAULT); while (pItem) { GetFriendlyNameForGroundItem(pItem,szName); if ((argc==1) || (!strnicmp(szName,argv[1],strlen(argv[1])))) { SPAWNINFO TempSpawn; FLOAT Distance; ZeroMemory(&TempSpawn,sizeof(TempSpawn)); strcpy(TempSpawn.Name,szName); TempSpawn.Y=pItem->Y; TempSpawn.X=pItem->X; TempSpawn.Z=pItem->Z; Distance = DistanceToSpawn(pChar,&TempSpawn); INT Angle = (INT)((atan2f(pChar->X - pItem->X, pChar->Y - pItem->Y) * 180.0f / PI + 360.0f) / 22.5f + 0.5f) % 16; sprintf(szBuffer,"%s: %1.2f away to the %s",szName,Distance,szHeading[Angle]); WriteChatColor(szBuffer,USERCOLOR_DEFAULT); Count++; } pItem = pItem->pNext; } if (Count==0) { WriteChatColor("No items found.",USERCOLOR_DEFAULT); } else { sprintf(szBuffer,"%d item%s found.",Count,(Count==1)?"":"s"); WriteChatColor(szBuffer,USERCOLOR_DEFAULT); } return 0; }
// /autorun int CMD_SetAutoRun(int argc, char *argv[]) { if (argc<2) { WriteChatf("Syntax: %s on|off",argv[0]); return 0; } #if 0 if(!stricmp(argv[1],"on") || !stricmp(argv[1],"off")) { CHAR szServerAndName[MAX_STRING] = {0}; sprintf(szServerAndName,"%s.%s",((PCHARINFO)pCharData)->Server,((PCHARINFO)pCharData)->Name); WritePrivateProfileString(szServerAndName,"AutoRun",argv[1],gszINIFilename); sprintf(szServerAndName,"Set autorun to: '%s'",argv[1]); WriteChatColor(szServerAndName,USERCOLOR_DEFAULT); } #endif return 0; }
BOOL Detour_ProcessGameEvents(VOID) { CAutoLock Lock(&gPulseCS); int ret = Heartbeat(); #ifdef ISXEQ if (!pISInterface->ScriptEngineActive()) pISInterface->LavishScriptPulse(); #endif int ret2 = Trampoline_ProcessGameEvents(); #ifndef ISXEQ if(ret==2 && bPluginCS==0) { OutputDebugString("I am loading in ProcessGameEvents"); //we are loading stuff DWORD oldscreenmode = ScreenMode; ScreenMode = 3; InitializeMQ2Commands(); InitializeMQ2Windows(); MQ2MouseHooks(1); Sleep(100); InitializeMQ2KeyBinds(); #ifndef ISXEQ InitializeMQ2Plugins(); #endif ScreenMode = oldscreenmode; SetEvent(hLoadComplete); } else if(ret==1) { OutputDebugString("I am unloading in ProcessGameEvents"); //we are unloading stuff DWORD oldscreenmode = ScreenMode; ScreenMode = 3; WriteChatColor(UnloadedString,USERCOLOR_DEFAULT); DebugSpewAlways("%s", UnloadedString); UnloadMQ2Plugins(); MQ2Shutdown(); DebugSpew("Shutdown completed"); g_Loaded = FALSE; ScreenMode = oldscreenmode; SetEvent(hUnloadComplete); } #endif return ret2; }
VOID MapClearLocationCmd(PSPAWNINFO pChar, PCHAR szLine) { if (szLine == 0 || szLine[0] == 0) { for (map<string, PMAPLOC>::iterator it = LocationMap.begin(); it != LocationMap.end(); it++) { PMAPLOC loc = it->second; ClearMapLocLines(loc); delete loc; LocationMap.erase(it); } LocationMap.clear(); WriteChatColor("MapLocs cleared", USERCOLOR_DEFAULT); return; } CHAR szBuffer[MAX_STRING] = { 0 }; PCHAR usage = "Usage: /clearloc [yloc xloc]"; stringstream ss(szLine); CHAR arg[MAX_STRING]; CHAR yloc[MAX_STRING] = { "not set" }; CHAR xloc[MAX_STRING] = { "not set" }; CHAR tag[MAX_STRING] = { 0 }; ss >> arg; if (strcmp(arg, std::to_string(atoi(arg)).c_str()) != 0) { SyntaxError(usage); return; } strcpy_s(yloc, arg); if (ss && !ss.eof()) { ss >> arg; if (strcmp(arg, std::to_string(atoi(arg)).c_str()) != 0) { SyntaxError(usage); return; } strcpy_s(xloc, arg); }
// *************************************************************************** // Function: CMD_Where // Description: Our '/where' command // Displays the direction and distance to the closest spawn // Usage: /where <spawn> // *************************************************************************** int CMD_Where(int argc, char* argv[]) { if (argc<2) { WriteChatf("Syntax: %s <spawn>",argv[0]); return 0; } if (!ppSpawnManager) return 0; if (!pSpawnList) return 0; PSPAWNINFO pChar = GetCharInfo()->pSpawn; PSPAWNINFO pSpawnClosest = NULL; SEARCHSPAWN SearchSpawn; ClearSearchSpawn(&SearchSpawn); CHAR szMsg[MAX_STRING] = {0}; CHAR szName[MAX_STRING] = {0}; CHAR szArg[MAX_STRING] = {0}; bRunNextCommand = TRUE; SearchSpawn.SpawnType= PC; ParseSearchSpawn(1,argc,argv,SearchSpawn); if (!(pSpawnClosest = SearchThroughSpawns(&SearchSpawn,pChar))) { sprintf(szMsg,"There were no matches for: %s",FormatSearchSpawn(szArg,&SearchSpawn)); } else { INT Angle = (INT)((atan2f(pChar->X - pSpawnClosest->X, pChar->Y - pSpawnClosest->Y) * 180.0f / PI + 360.0f) / 22.5f + 0.5f) % 16; sprintf(szMsg,"The closest '%s' is a level %d %s %s and %1.2f away to the %s, Z difference = %1.2f", CleanupName(strcpy(szName,pSpawnClosest->Name),FALSE), pSpawnClosest->Level, pEverQuest->GetRaceDesc(pSpawnClosest->Race), GetClassDesc(pSpawnClosest->Class), DistanceToSpawn(pChar,pSpawnClosest), szHeading[Angle], pSpawnClosest->Z-pChar->Z); DebugSpew("Where - %s",szMsg); } WriteChatColor(szMsg,USERCOLOR_WHO); return 0; }
int CMD_MapHide(int argc, char *argv[]) { if (argc<2) { WriteChatf("Syntax: %s <spawnfilter>|reset",argv[0]); return 0; }; if (!stricmp(argv[1],"reset")) { MapClear(); MapGenerate(); WriteChatColor("Map spawns regenerated",USERCOLOR_DEFAULT); return 0; } if (PCHARINFO pCharInfo=GetCharInfo()) { SEARCHSPAWN ssHide; ClearSearchSpawn(&ssHide); ParseSearchSpawn(1,argc,argv,ssHide); WriteChatf("%d mapped spawns hidden",MapHide(ssHide)); } return 0; }
// *************************************************************************** // Function: MapFilters // Description: Our '/mapfilter' command // Sets map filters // Usage: /mapfilter [options|help] // *************************************************************************** VOID MapFilterSetting(PSPAWNINFO pChar, DWORD nMapFilter, PCHAR szValue) { CHAR szBuffer[MAX_STRING] = { 0 }; CHAR Buff[MAX_STRING] = { 0 }; DWORD dwValue = 0; PCHAR szFilterMap[] = { "hide", "show", NULL }; if (!pChar) return; PMAPFILTER pMapFilter = &MapFilterOptions[nMapFilter]; if (!RequirementsMet(nMapFilter)) { sprintf_s(szBuffer, "'%s' requires '%s' option. Please enable this option first.", pMapFilter->szName, MapFilterOptions[pMapFilter->RequiresOption].szName); WriteChatColor(szBuffer, USERCOLOR_DEFAULT); return; } if (!szValue) { if (pMapFilter->bIsToggle) { sprintf_s(szBuffer, "%s: %s", pMapFilter->szName, szFilterMap[pMapFilter->Enabled]); } else if (nMapFilter == MAPFILTER_Custom) { if (IsOptionEnabled(nMapFilter) == 0) { sprintf_s(szBuffer, "%s: Off", pMapFilter->szName); } else { sprintf_s(szBuffer, "%s: %s", pMapFilter->szName, FormatSearchSpawn(Buff, sizeof(Buff), &MapFilterCustom)); } } else { sprintf_s(szBuffer, "%s: %d", pMapFilter->szName, pMapFilter->Enabled); } if (pMapFilter->DefaultColor != -1) { CHAR szBuffer2[MAX_STRING] = { 0 }; DWORD R, G, B; R = (pMapFilter->Color & 0xFF0000) / 0x10000; G = (pMapFilter->Color & 0xFF00) / 0x100; B = pMapFilter->Color & 0xFF; sprintf_s(szBuffer2, "%s (Color: %d %d %d)", szBuffer, R, G, B); strcpy_s(szBuffer, szBuffer2); } } else { if (pMapFilter->bIsToggle) { if (!_stricmp(szFilterMap[0], szValue)) { pMapFilter->Enabled = 0; } else if (!_stricmp(szFilterMap[1], szValue)) { pMapFilter->Enabled = 1; } else { pMapFilter->Enabled = 1 - pMapFilter->Enabled; } sprintf_s(szBuffer, "%s is now set to: %s", pMapFilter->szName, szFilterMap[IsOptionEnabled(nMapFilter)]); } else if (nMapFilter == MAPFILTER_Custom) { ClearSearchSpawn(&MapFilterCustom); if (szValue[0] == 0) { pMapFilter->Enabled = 0; sprintf_s(szBuffer, "%s is now set to: Off", pMapFilter->szName); } else { pMapFilter->Enabled = 1; ParseSearchSpawn(szValue, &MapFilterCustom); sprintf_s(szBuffer, "%s is now set to: %s", pMapFilter->szName, FormatSearchSpawn(Buff, sizeof(Buff), &MapFilterCustom)); } } else if (nMapFilter == MAPFILTER_Marker) { CHAR szBuffer2[MAX_STRING] = { 0 }; GetArg(szBuffer2, szValue, 1); if (!_stricmp(szFilterMap[0], szValue)) { pMapFilter->Enabled = 0; sprintf_s(szBuffer, "%s is now set to: %s", pMapFilter->szName, szFilterMap[IsOptionEnabled(nMapFilter)]); } else if (!_stricmp(szFilterMap[1], szValue)) { pMapFilter->Enabled = 1; sprintf_s(szBuffer, "%s is now set to: %s", pMapFilter->szName, szFilterMap[IsOptionEnabled(nMapFilter)]); } else { pMapFilter->Enabled = 1; sprintf_s(szBuffer, "%s %s", pMapFilter->szName, FormatMarker(szValue, Buff, sizeof(Buff))); } } else { pMapFilter->Enabled = atoi(szValue); sprintf_s(szBuffer, "%s is now set to: %d", pMapFilter->szName, pMapFilter->Enabled); } } WriteChatColor(szBuffer, USERCOLOR_DEFAULT); if (szValue) { _itoa_s(pMapFilter->Enabled, szBuffer, 10); WritePrivateProfileString("Map Filters", pMapFilter->szName, szBuffer, INIFileName); } }
VOID Click(PSPAWNINFO pChar, PCHAR szLine) { if(GetGameState()!=GAMESTATE_INGAME) { MacroError("Dont /click stuff(%s) when not in game... Gamestate is %d",szLine,GetGameState()); return; } CHAR szArg1[MAX_STRING] = {0}; PCHAR szMouseLoc; MOUSE_DATA_TYPES mdType = MD_Unknown; DWORD RightOrLeft = 0; GetArg(szArg1, szLine, 1); //left or right szMouseLoc = GetNextArg(szLine, 1); //location to click //parse location for click location (szMouseLoc) here if (szMouseLoc && szMouseLoc[0]!=0) { if (!strnicmp(szMouseLoc, "target", 6)) { if (!pTarget) { WriteChatColor("You must have a target selected for /click x target.",CONCOLOR_RED); return; } if (!strnicmp(szArg1, "left", 4)) { pEverQuest->LeftClickedOnPlayer(pTarget); gMouseEventTime = GetFastTime(); } else if (!strnicmp(szArg1, "right", 5)) { pEverQuest->RightClickedOnPlayer(pTarget, 0); gMouseEventTime = GetFastTime(); } return; } else if(!strnicmp(szMouseLoc,"center",6)) { sprintf(szMouseLoc,"%d %d",ScreenXMax/2,ScreenYMax/2); } else if (!strnicmp(szMouseLoc, "item", 4)) { if(pGroundTarget) { if (!strnicmp(szArg1, "left", 4)) { if(EnviroTarget.Name[0]!=0) { if(DistanceToSpawn(pChar,&EnviroTarget)<=20.0f) { //do stuff if(PEQSWITCH pSwitch = (PEQSWITCH)pGroundTarget->pSwitch) { *((DWORD*)__LMouseHeldTime)=((PCDISPLAY)pDisplay)->TimeStamp-0x45; //we "click" at -1000,-1000 because we know the user doesnt have any windows there... //if its possible, i would like to figure out a pixel //on the users screen that isnt covered by a window... //the click need to be issued on the main UI... //but for now this will work -eqmule 8 mar 2014 pEverQuest->LMouseUp(-1000,-1000); } } else { WriteChatf("You are to far away from the item, please move closer before issuing the /click left item command."); } } else { WriteChatf("No Item targeted, use /itemtarget <theid> before issuing a /click left item command."); } } else { WriteChatf("Invalid click args, use \"/click left item\", aborting: %s",szMouseLoc); } } else { WriteChatf("No Item targeted, use /itemtarget <theid> before issuing a /click left item command."); } return; } else if (!strnicmp(szMouseLoc, "door", 4)) { // a right clicked door spawn does nothing if(pDoorTarget) { if (!strnicmp(szArg1, "left", 4)) { if(DoorEnviroTarget.Name[0]!=0) { if(DistanceToSpawn(pChar,&DoorEnviroTarget)<20.0f) { EQSwitch *pSwitch = (EQSwitch *)pDoorTarget; srand((unsigned int)time(0)); int randclickY = rand() % 5; int randclickX = rand() % 5; int randclickZ = rand() % 5; PSWITCHCLICK pclick = new SWITCHCLICK; if(pclick) { pclick->Y=pDoorTarget->Y+randclickY; pclick->X=pDoorTarget->X+randclickX; pclick->Z=pDoorTarget->Z+randclickZ; randclickY = rand() % 5; randclickX = rand() % 5; randclickZ = rand() % 5; pclick->Y1=pclick->Y+randclickY; pclick->X1=pclick->X+randclickX; pclick->Z1=pclick->Z+randclickZ; pSwitch->UseSwitch(GetCharInfo()->pSpawn->SpawnID,0xFFFFFFFF,0,(DWORD)pclick); delete pclick; } //DoorEnviroTarget.Name[0]='\0'; if (pTarget==(EQPlayer*)&DoorEnviroTarget) {//this should NEVER happen pTarget=NULL; } return; } else { WriteChatf("You are to far away from the door, please move closer before issuing the /click left door command."); } } else { WriteChatf("No Door targeted, use /doortarget <theid> before issuing a /click left door command."); } } else { WriteChatf("Invalid click args, use \"/click left door\", aborting: %s",szMouseLoc); } } else { WriteChatf("No Door targeted, use /doortarget <theid> before issuing a /click left door command."); } return;; } ClickMouseLoc(szMouseLoc, szArg1); return; } if (szArg1[0]!=0) { if (!strnicmp(szArg1, "left", 4)) { ClickMouse(0); } else if (!strnicmp(szArg1, "right", 5)) { ClickMouse(1); } else { WriteChatColor("Usage: /click <left|right>",USERCOLOR_DEFAULT); DebugSpew("Bad command: %s",szLine); return; } } }
int CMD_MapFilter(int argc, char *argv[]) { // Display settings if (argc<2) { WriteChatColor("Map filtering settings:",USERCOLOR_DEFAULT); WriteChatColor("-----------------------",USERCOLOR_DEFAULT); for (DWORD i=0;MapFilterOptions[i].szName!=NULL;i++) if (RequirementsMet(i)) MapFilterSetting(i,argc,argc,argv); return 0; } if (!stricmp(argv[1],"help")) { // Display Help WriteChatColor("Map filtering options:",USERCOLOR_DEFAULT); for (DWORD i=0;MapFilterOptions[i].szName!=NULL;i++) { WriteChatf("%s%s: %s",MapFilterOptions[i].szName,(MapFilterOptions[i].bIsToggle)?"":" #",MapFilterOptions[i].szHelpString); } WriteChatColor("'option' color [r g b]: Set display color for 'option' (Omit to reset to default)",USERCOLOR_DEFAULT); return 0; } // Set option for (DWORD i=0;MapFilterOptions[i].szName!=NULL;i++) { if (!stricmp(argv[1],MapFilterOptions[i].szName)) { if (argc>=3 && !stricmp(argv[2],"color")) { if (MapFilterOptions[i].DefaultColor == -1) { WriteChatf("Option '%s' does not have a color.",MapFilterOptions[i].szName); } else { DWORD R,G,B; R = G = B = 255; if (argc<6) { MapFilterOptions[i].Color = MapFilterOptions[i].DefaultColor; } else { R=atoi(argv[3]); G=atoi(argv[4]); B=atoi(argv[5]); if (R>255) R=255; if (G>255) G=255; if (B>255) B=255; MapFilterOptions[i].Color = R*0x10000 + G*0x100 + B; } WriteChatf("Option '%s' color set to: %d %d %d",MapFilterOptions[i].szName,R,G,B); //itoa(MapFilterOptions[i].Color & 0xFFFFFF,szBuffer,10); char szBuffer[128]; sprintf(szBuffer,"%s Color",MapFilterOptions[i].szName); pISInterface->SetSettingi("ISXEQMap.XML","Map Filters",szBuffer,MapFilterOptions[i].Color & 0xFFFFFF); pISInterface->SaveSettings("ISXEQMap.XML"); MapFilterOptions[i].Color |= 0xFF000000; } } else { MapFilterSetting(i,2,argc,argv); } if (MapFilterOptions[i].RegenerateOnChange) { MapClear(); MapGenerate(); } return 0; } } WriteChatf("Usage: %s <option>|help",argv[0]); return 0; }
int CMD_DoorTarget(int argc, char *argv[]) { if (!ppSwitchMgr) return 0; if (!pSwitchMgr) return 0; PDOORTABLE pDoorTable = (PDOORTABLE)pSwitchMgr; DWORD Count; PSPAWNINFO pChar = (PSPAWNINFO)pLocalPlayer; CHAR szBuffer[MAX_STRING] = {0}; CHAR szSearch[MAX_STRING] = {0}; FLOAT cDistance = 100000.0f; BYTE ID = -1; ZeroMemory(&DoorEnviroTarget,sizeof(DoorEnviroTarget)); pDoorTarget = NULL; if (argc > 1 && !stricmp(argv[1], "id")) { if (argc < 3) { WriteChatf("DoorTarget: id specified but no number provided."); return 0; } ID = atoi(argv[2]); for (Count=0; Count<pDoorTable->NumEntries; Count++) { if (pDoorTable->pDoor[Count]->ID == ID) { strcpy(DoorEnviroTarget.Name, pDoorTable->pDoor[Count]->Name); DoorEnviroTarget.Y = pDoorTable->pDoor[Count]->Y; DoorEnviroTarget.X = pDoorTable->pDoor[Count]->X; DoorEnviroTarget.Z = pDoorTable->pDoor[Count]->Z; DoorEnviroTarget.Heading = pDoorTable->pDoor[Count]->Heading; DoorEnviroTarget.Type = SPAWN_NPC; DoorEnviroTarget.HPCurrent = 1; DoorEnviroTarget.HPMax = 1; pDoorTarget = pDoorTable->pDoor[Count]; break; } } } else { if (argc > 1) strcpy(szSearch, argv[1]); for (Count=0; Count<pDoorTable->NumEntries; Count++) { if (((szSearch[0]==0) || (!strnicmp(pDoorTable->pDoor[Count]->Name,szSearch,strlen(szSearch)))) && ((gZFilter >=10000.0f) || ((pDoorTable->pDoor[Count]->Z <= pChar->Z + gZFilter) && (pDoorTable->pDoor[Count]->Z >= pChar->Z - gZFilter)))) { SPAWNINFO tSpawn; ZeroMemory(&tSpawn,sizeof(tSpawn)); strcpy(tSpawn.Name,pDoorTable->pDoor[Count]->Name); tSpawn.Y=pDoorTable->pDoor[Count]->Y; tSpawn.X=pDoorTable->pDoor[Count]->X; tSpawn.Z=pDoorTable->pDoor[Count]->Z; tSpawn.Type = SPAWN_NPC; tSpawn.HPCurrent = 1; tSpawn.HPMax = 1; tSpawn.Heading=pDoorTable->pDoor[Count]->Heading; FLOAT Distance = DistanceToSpawn(pChar,&tSpawn); if (Distance<cDistance) { CopyMemory(&DoorEnviroTarget,&tSpawn,sizeof(DoorEnviroTarget)); pDoorTarget = pDoorTable->pDoor[Count]; cDistance=Distance; } } } } if (DoorEnviroTarget.Name[0]!=0) { sprintf(szBuffer,"Door %d '%s' targeted.", pDoorTarget->ID, DoorEnviroTarget.Name); WriteChatColor(szBuffer,USERCOLOR_DEFAULT); } else { WriteChatf("Couldn't find door to target."); } return 0; }
int CMD_Target(int argc, char* argv[]) { if (!ppSpawnManager) return 0; if (!pSpawnList) return 0; if (argc<2) { WriteChatf("Syntax: %s myself|mycorpse|clear|<spawn search>",argv[0]); return 0; } PSPAWNINFO pChar = GetCharInfo()->pSpawn; PSPAWNINFO pSpawnClosest = NULL; SEARCHSPAWN SearchSpawn; ClearSearchSpawn(&SearchSpawn); CHAR szMsg[MAX_STRING] = {0}; BOOL DidTarget = FALSE; BOOL bArg = TRUE; bRunNextCommand = TRUE; for(int i=1;i<argc;i++) { if (!stricmp(argv[i],"myself")) { if (pChar) { pSpawnClosest = pChar; DidTarget = TRUE; } } else if (!stricmp(argv[i],"mycorpse")) { if (pChar) { SearchSpawn.SpawnType = CORPSE; strcpy(SearchSpawn.szName,pChar->Name); } } else if (!stricmp(argv[i],"clear")) { pTarget = NULL; DebugSpew("Target cleared."); WriteChatColor("Target cleared.",USERCOLOR_WHO); return 0; } else { i+= ParseSearchSpawnArg(i,argc,argv,SearchSpawn); } } if (pTarget) SearchSpawn.FromSpawnID = ((PSPAWNINFO)pTarget)->SpawnID; if (!DidTarget) { pSpawnClosest = SearchThroughSpawns(&SearchSpawn,pChar); } if (!pSpawnClosest) { CHAR szTemp[MAX_STRING] = {0}; sprintf(szMsg,"There are no spawns matching: %s",FormatSearchSpawn(szTemp,&SearchSpawn)); } else { PSPAWNINFO *psTarget = NULL; if (ppTarget) { psTarget = (PSPAWNINFO*)ppTarget; *psTarget = pSpawnClosest; DebugSpew("Target - %s selected",pSpawnClosest->Name); szMsg[0]=0; } else { sprintf(szMsg,"Unable to target, address = 0"); } } if (szMsg[0]) if (!gFilterTarget) WriteChatColor(szMsg,USERCOLOR_WHO); return 0; }
VOID MQ2BzSrch(PSPAWNINFO pChar, PCHAR szLine) { WriteChatColor("Bazaar Search Plugin by DKAA",USERCOLOR_WHO); WriteChatColor("",USERCOLOR_WHO); WriteChatColor("usage: /bzsrch [params] [name]",USERCOLOR_WHO); WriteChatColor(" params:",USERCOLOR_WHO); WriteChatColor(" [trader any value you see in that box or an index, remember to enclose values with spaces in them with quotes like: \"some value\"]", USERCOLOR_WHO); WriteChatColor(" [race any|barbarian|dark elf|dwarf|erudite|froglok|gnome|half elf|halfling|high elf|human|iksar|ogre|troll|vah shir|wood elf|drakkin]", USERCOLOR_WHO); WriteChatColor(" [class any|bard|beastlord|berserkers|cleric|druid|enchanter|magician|monk|necromancer|paladin|ranger|rogue|shadow knight|shaman|warrior|wizard]", USERCOLOR_WHO); WriteChatColor(" [stat any value you see in that box or an index, remember to enclose values with spaces in them with quotes like: \"some value\"]", USERCOLOR_WHO); WriteChatColor(" [slot any value you see in that box or an index, remember to enclose values with spaces in them with quotes like: \"some value\"]", USERCOLOR_WHO); WriteChatColor(" [type any value you see in that box or an index, remember to enclose values with spaces in them with quotes like: \"some value\"]", USERCOLOR_WHO); WriteChatColor(" [price <low> <high>]", USERCOLOR_WHO); WriteChatColor(" [prestige any value you see in that box or an index, remember to enclose values with spaces in them with quotes like: \"some value\"]", USERCOLOR_WHO); WriteChatColor(" [augment any value you see in that box or an index, remember to enclose values with spaces in them with quotes like: \"some value\"]", USERCOLOR_WHO); WriteChatColor("", USERCOLOR_WHO); WriteChatColor("values are returned in $bazaar variable", USERCOLOR_WHO); WriteChatColor("$bazaar -- TRUE if there are search results", USERCOLOR_WHO); WriteChatColor("$bazaar[count] -- number of search results", USERCOLOR_WHO); WriteChatColor("$bazaar[n,name] -- name of the nth item", USERCOLOR_WHO); WriteChatColor("$bazaar[n,price] -- price of the nth item", USERCOLOR_WHO); WriteChatColor("$bazaar[n,id] -- id of the nth item", USERCOLOR_WHO); WriteChatColor("$bazaar[n,trader] -- trader id of the nth item", USERCOLOR_WHO); }
VOID Detour(PSPAWNINFO pChar, PCHAR szFullLine) { DebugSpew("CCommandHook::Detour(%s)",szFullLine); CHAR szFullCommand[MAX_STRING] = {0}; CHAR szCommand[MAX_STRING] = {0}; CHAR szArgs[MAX_STRING] = {0}; CHAR szOrig[MAX_STRING] = {0}; CHAR szSub[MAX_STRING] = {0}; string szSubFullCommand = ""; unsigned int k=0; bool OneCharacterSub = false; PALIAS pLoop = pAliases; PSUB pSubLoop = pSubs; if (szFullLine[0]!=0) { strcpy(szFullCommand,szFullLine); GetArg(szCommand,szFullCommand,1); if (!stricmp(szCommand,"/camp")) { if (gMacroBlock) { WriteChatColor("A macro is currently running. You may wish to /endmacro before you finish camping.", CONCOLOR_YELLOW ); } } szSubFullCommand = szFullCommand; for (unsigned int i=0; i < sizeof(szFullCommand); i++ ) { if (szFullCommand[i] == '%') { if (szFullCommand[i+2] == ' ' || szFullCommand[i+2] == '\0' || !isalnum(szFullCommand[i+2]) ) { if (szFullCommand[i+1] == 'm' || szFullCommand[i+1] == 'M' || szFullCommand[i+1] == 'o' || szFullCommand[i+1] == 'O' || szFullCommand[i+1] == 'p' || szFullCommand[i+1] == 'P' || szFullCommand[i+1] == 'r' || szFullCommand[i+1] == 'R' || szFullCommand[i+1] == 's' || szFullCommand[i+1] == 'S' || szFullCommand[i+1] == 't' || szFullCommand[i+1] == 'T' ) continue; else { szOrig[0] = szFullCommand[i+1]; szOrig[1] = '\0'; k = 1; OneCharacterSub = true; } } if (!OneCharacterSub) { for (unsigned int j=i+1; j < sizeof(szFullCommand); j++ ) { if (szFullCommand[j] == ' ' || szFullCommand[j] == '\0' ) break; else if (!isalnum(szFullCommand[j])) break; szOrig[k] = szFullCommand[j]; k++; } } while (pSubLoop) { if (!stricmp(szOrig, pSubLoop->szOrig)) { sprintf( szSub, "%s", pSubLoop->szSub ); break; } pSubLoop = pSubLoop->pNext; } if (szSub[0] != '\0' ) { szSubFullCommand.replace(i,k+1,szSub); sprintf( szFullCommand, "%s",szSubFullCommand.c_str() ); } szOrig[0] = '\0'; szSub[0] = '\0'; k=0; OneCharacterSub = false; pSubLoop = pSubs; } } sprintf(szFullCommand, "%s", szSubFullCommand.c_str() ); while (pLoop) { if (!stricmp(szCommand,pLoop->szName)) { sprintf(szCommand,"%s%s",pLoop->szCommand,szFullCommand+strlen(pLoop->szName)); strncpy(szFullCommand,szCommand,MAX_STRING); break; } pLoop = pLoop->pNext; } GetArg(szCommand,szFullCommand,1); strcpy(szArgs, GetNextArg(szFullCommand)); PMQCOMMAND pCommand=pCommands; while(pCommand) { if (pCommand->InGameOnly && gGameState!=GAMESTATE_INGAME) { pCommand=pCommand->pNext; continue; } int Pos=strnicmp(szCommand,pCommand->Command,strlen(szCommand)); if (Pos<0) {// command not found break; } if (Pos==0) { if (pCommand->Parse && bAllowCommandParse) ParseMacroParameter(pChar,szArgs); if (pCommand->EQ) { strcat(szCommand," "); strcat(szCommand,szArgs); Trampoline(pChar,szCommand); } else { pCommand->Function(pChar,szArgs); } strcpy(szLastCommand,szFullCommand); return; } pCommand=pCommand->pNext; } } Trampoline(pChar,szFullLine); strcpy(szLastCommand,szFullCommand); }
VOID Detour(PSPAWNINFO pChar, PCHAR szFullLine) { lockit lk(ghCCommandLock,"CCommandHook::Detour"); DebugSpew("CCommandHook::Detour(%s)",szFullLine); CHAR szFullCommand[MAX_STRING] = {0}; CHAR szCommand[MAX_STRING] = {0}; CHAR szArgs[MAX_STRING] = {0}; CHAR szOrig[MAX_STRING] = {0}; CHAR szSub[MAX_STRING] = {0}; std::string szSubFullCommand = ""; unsigned int k=0; bool OneCharacterSub = false; PSUB pSubLoop = pSubs; if (szFullLine[0]!=0) { strcpy_s(szFullCommand,szFullLine); GetArg(szCommand,szFullCommand,1); if (!_stricmp(szCommand,"/camp")) { if (GetmacroBlockCount()) { WriteChatColor("A macro is currently running. You may wish to /endmacro before you finish camping.", CONCOLOR_YELLOW ); } } szSubFullCommand = szFullCommand; size_t len = strnlen_s(szFullCommand, MAX_STRING); for (unsigned int i=0; i < sizeof(szFullCommand); i++ ) { if (szFullCommand[i] == '%' && ((i+2)<len)) { if (szFullCommand[i+2] == ' ' || szFullCommand[i+2] == '\0' || !isalnum(szFullCommand[i+2]) ) { if (szFullCommand[i+1] == 'm' || szFullCommand[i+1] == 'M' || szFullCommand[i+1] == 'o' || szFullCommand[i+1] == 'O' || szFullCommand[i+1] == 'p' || szFullCommand[i+1] == 'P' || szFullCommand[i+1] == 'r' || szFullCommand[i+1] == 'R' || szFullCommand[i+1] == 's' || szFullCommand[i+1] == 'S' || szFullCommand[i+1] == 't' || szFullCommand[i+1] == 'T' ) continue; else { szOrig[0] = szFullCommand[i+1]; szOrig[1] = '\0'; k = 1; OneCharacterSub = true; } } if (!OneCharacterSub) { for (unsigned int j=i+1; j < sizeof(szFullCommand); j++ ) { if (szFullCommand[j] == ' ' || szFullCommand[j] == '\0' ) break; else if (!isalnum(szFullCommand[j])) break; szOrig[k] = szFullCommand[j]; k++; } } while (pSubLoop) { if (!_stricmp(szOrig, pSubLoop->szOrig)) { sprintf_s( szSub, "%s", pSubLoop->szSub ); break; } pSubLoop = pSubLoop->pNext; } if (szSub[0] != '\0' ) { szSubFullCommand.replace(i,k+1,szSub); sprintf_s( szFullCommand, "%s",szSubFullCommand.c_str() ); } szOrig[0] = '\0'; szSub[0] = '\0'; k=0; OneCharacterSub = false; pSubLoop = pSubs; } } sprintf_s(szFullCommand, "%s", szSubFullCommand.c_str() ); std::string sName = szCommand; std::transform(sName.begin(), sName.end(), sName.begin(), tolower); if (mAliases.find(sName) != mAliases.end()) { sprintf_s(szCommand,"%s%s",mAliases[sName].c_str(),szFullCommand+sName.size()); strcpy_s(szFullCommand,szCommand); } GetArg(szCommand,szFullCommand,1); strcpy_s(szArgs, GetNextArg(szFullCommand)); PMQCOMMAND pCommand=pCommands; while(pCommand) { if (pCommand->InGameOnly && gGameState!=GAMESTATE_INGAME) { pCommand=pCommand->pNext; continue; } int Pos=_strnicmp(szCommand,pCommand->Command,strlen(szCommand)); if (Pos<0) {// command not found break; } if (Pos==0) { if (pCommand->Parse && bAllowCommandParse) { ParseMacroParameter(pChar, szArgs); } if (pCommand->EQ) { strcat_s(szCommand," "); strcat_s(szCommand,szArgs); Trampoline(pChar,szCommand); } else { pCommand->Function(pChar,szArgs); } strcpy_s(szLastCommand,szFullCommand); return; } pCommand=pCommand->pNext; } PBINDLIST pBind = pBindList; PMACROBLOCK pBlock = GetCurrentMacroBlock(); while( pBind ) { if( gGameState != GAMESTATE_INGAME ) { // Macro Binds only supported in-game pBind = pBind->pNext; continue; } int Pos = _strnicmp( szCommand, pBind->szName, strlen( szCommand ) ); if( Pos == 0 ) { // found it! if( pBind->szFuncName ) { if( PCHARINFO pCharInfo = GetCharInfo() ) { std::string sCallFunc( pBind->szFuncName ); sCallFunc += " "; sCallFunc += szArgs; CHAR szCallFunc[MAX_STRING] = { 0 }; strcpy_s(szCallFunc, sCallFunc.c_str()); ParseMacroData(szCallFunc, MAX_STRING); if (pBlock && !pBlock->BindCmd.size()) { if (!gBindInProgress) { gBindInProgress = true; pBlock->BindCmd = szCallFunc; } else { Beep(1000, 100); WriteChatf("Can't execute bind while another bind is on progress"); } } //CHAR szOrg[MAX_STRING] = {"${Time}"}; //ParseMacroData(szOrg, MAX_STRING); //WriteChatf("[%s] %s called",szOrg, szCallFunc.c_str()); //Beep(1000, 100); } } strcpy_s( szLastCommand, szFullCommand ); return; } pBind = pBind->pNext; } } Trampoline(pChar,szFullLine); strcpy_s(szLastCommand,szFullCommand); }
// *************************************************************************** // Function: CMD_CastSpell // Description: Our '/cast' command // Displays the direction and distance to the closest spawn // Usage: /cast [list|#|"name of spell"|item "name of item"] // *************************************************************************** int CMD_CastSpell(int argc, char* argv[]) { DWORD Index; if (gGameState!=GAMESTATE_INGAME) return -1; if (!cmdCast) { PCMDLIST pCmdListOrig = (PCMDLIST)EQADDR_CMDLIST; for (int i=0;pCmdListOrig[i].fAddress != 0;i++) { if (!strcmp(pCmdListOrig[i].szName,"/cast")) { cmdCast = (fEQCommand)pCmdListOrig[i].fAddress; } } } if (!cmdCast) return -1; if (argc<2) { WriteChatf("Syntax: %s list|#|<name of spell>|item <name of item>",argv[0]); return 0; } if ( !ppSpellMgr || !ppCharData || !pCharData) { return -1; } PCHARINFO pCharInfo = GetCharInfo(); if (NULL == pCharInfo) return -1; if (argc == 2 && atoi(argv[1])){ cmdCast((PSPAWNINFO)pLocalPlayer, argv[1]); return 0; } // CHAR szArg1[MAX_STRING] = {0}; // CHAR szArg2[MAX_STRING] = {0}; if (!stricmp(argv[1],"list")) { WriteChatColor("Spells:",USERCOLOR_DEFAULT); for (Index=0;Index<NUM_SPELL_GEMS;Index++) { if (GetCharInfo2()->MemorizedSpells[Index]==0xFFFFFFFF) { WriteChatf("%d. <Empty>",Index+1); } else { WriteChatf("%d. %s",Index+1,GetSpellByID(GetCharInfo2()->MemorizedSpells[Index])); } } return 0; } // GetArg(szArg1,szLine,1); // GetArg(szArg2,szLine,2); // DebugSpew("Cast: szArg1 = %s szArg2 = %s",szArg1,szArg2); if (!stricmp(argv[1],"item")) { BOOL FOUND = FALSE; DWORD item = 0; DWORD slot = 0; DWORD SpawnFooter = NULL; SpawnFooter = (DWORD)pLocalPlayer; PITEMINFO pItem=0; for (int i=0;i<NUM_INV_SLOTS;i++) { if (GetCharInfo2()->pInventoryArray->InventoryArray[i]) if (!_stricmp(argv[2],GetItemFromContents(GetCharInfo2()->pInventoryArray->InventoryArray[i])->Name)) { DebugSpew("cast test slot %d = %s address is %x",i,GetItemFromContents(GetCharInfo2()->pInventoryArray->InventoryArray[i])->Name,&(GetCharInfo2()->pInventoryArray->InventoryArray[i])); item = (DWORD)&GetCharInfo2()->pInventoryArray->InventoryArray[i]; pItem=GetItemFromContents(GetCharInfo2()->pInventoryArray->InventoryArray[i]); slot = (DWORD)i; FOUND = TRUE; break; } } if (FOUND) { if(CInvSlot *pSlot = pInvSlotMgr->FindInvSlot(slot)) { CXPoint p; p.A=0; p.B=0; pSlot->HandleRButtonUp(&p); } return 0; } } for (Index=0;Index<NUM_SPELL_GEMS;Index++) { if (GetCharInfo2()->MemorizedSpells[Index]!=0xFFFFFFFF) { PCHAR SpellName = GetSpellNameByID(GetCharInfo2()->MemorizedSpells[Index]); if (!stricmp(argv[1],SpellName)) { DebugSpew("SpellName = %s",SpellName); char szBuffer[256]; cmdCast((PSPAWNINFO)pLocalPlayer,itoa(Index+1,szBuffer,10)); DebugSpew("pChar = %x SpellName = %s %d",pCharInfo,SpellName,Index+1); return 0; } } } WriteChatColor("You do not seem to have that spell memorized.",USERCOLOR_DEFAULT); return 0; }
VOID MapFilters(PSPAWNINFO pChar, PCHAR szLine) { bRunNextCommand = TRUE; CHAR szArg[MAX_STRING] = { 0 }; GetArg(szArg, szLine, 1); PCHAR szRest = GetNextArg(szLine); CHAR szBuffer[MAX_STRING] = { 0 }; // Display settings if (szArg[0] == 0) { WriteChatColor("Map filtering settings:", USERCOLOR_DEFAULT); WriteChatColor("-----------------------", USERCOLOR_DEFAULT); for (DWORD i = 0; MapFilterOptions[i].szName != NULL; i++) if (RequirementsMet(i)) MapFilterSetting(pChar, i); // Display Help } else if (!_strnicmp(szArg, "help", 4)) { WriteChatColor("Map filtering options:", USERCOLOR_DEFAULT); for (DWORD i = 0; MapFilterOptions[i].szName != NULL; i++) { sprintf_s(szBuffer, "%s%s: %s", MapFilterOptions[i].szName, (MapFilterOptions[i].bIsToggle) ? "" : " #", MapFilterOptions[i].szHelpString); WriteChatColor(szBuffer, USERCOLOR_DEFAULT); } WriteChatColor("'option' color [r g b]: Set display color for 'option' (Omit to reset to default)", USERCOLOR_DEFAULT); // Set option } else { PMAPFILTER Found = 0; for (DWORD i = 0; MapFilterOptions[i].szName != NULL; i++) { if (!_stricmp(szArg, MapFilterOptions[i].szName)) { if (!_strnicmp(szRest, "color", 5)) { if (MapFilterOptions[i].DefaultColor == -1) { sprintf_s(szBuffer, "Option '%s' does not have a color.", MapFilterOptions[i].szName); WriteChatColor(szBuffer, USERCOLOR_DEFAULT); } else { DWORD R, G, B; CHAR szBuffer2[MAX_STRING] = { 0 }; GetArg(szArg, szRest, 2); if (szArg[0] == 0) { MapFilterOptions[i].Color = MapFilterOptions[i].DefaultColor; } else { R = atoi(szArg); G = atoi(GetArg(szArg, szRest, 3)); B = atoi(GetArg(szArg, szRest, 4)); if (R>255) R = 255; if (G>255) G = 255; if (B>255) B = 255; MapFilterOptions[i].Color = R * 0x10000 + G * 0x100 + B; } sprintf_s(szBuffer, "Option '%s' color set to: %d %d %d", MapFilterOptions[i].szName, R, G, B); WriteChatColor(szBuffer, USERCOLOR_DEFAULT); _itoa_s(MapFilterOptions[i].Color & 0xFFFFFF, szBuffer, 10); sprintf_s(szBuffer2, "%s-Color", MapFilterOptions[i].szName); WritePrivateProfileString("Map Filters", szBuffer2, szBuffer, INIFileName); MapFilterOptions[i].Color |= 0xFF000000; } } else { MapFilterSetting(pChar, i, szRest); } Found = &MapFilterOptions[i]; } } if (!Found) SyntaxError("Usage: /mapfilter [option|help]"); else if (Found->RegenerateOnChange) { MapClear(); MapGenerate(); } } }
int CMD_EQFace(int argc, char *argv[]) { //VOID Face(PSPAWNINFO pChar, PCHAR szLine) //{ if (!ppSpawnManager) return 0; if (!pSpawnList) return 0; PSPAWNINFO pSpawnClosest = NULL; PSPAWNINFO psTarget = NULL; SPAWNINFO LocSpawn = {0}; PSPAWNINFO pChar = (PSPAWNINFO)pLocalPlayer; SEARCHSPAWN SearchSpawn; ClearSearchSpawn(&SearchSpawn); CHAR szMsg[MAX_STRING] = {0}; CHAR szName[MAX_STRING] = {0}; CHAR szArg[MAX_STRING] = {0}; PCHAR pszArg = NULL; BOOL bArg = TRUE; BOOL bOtherArgs = FALSE; BOOL Away = FALSE; BOOL Predict = FALSE; BOOL Fast = FALSE; BOOL Look = TRUE; BOOL Parsing = TRUE; DOUBLE Distance; for(int qq=1; qq<argc; qq++) { if (!strcmp(argv[qq],"predict")) { Predict=TRUE; } else if (!strcmp(argv[qq],"fast")) { Fast = TRUE; } else if (!strcmp(argv[qq],"away")) { Away = TRUE; } else if (!strcmp(argv[qq],"nolook")) { Look = FALSE; } else if (!strnicmp(argv[qq], "loc", 3)) { pSpawnClosest = &LocSpawn; strcpy(LocSpawn.Name,"location"); if (((++qq)<argc) && strstr(argv[qq],",")) { pSpawnClosest->Y = (FLOAT)atof(argv[qq]); pszArg = strstr(argv[qq],",")+1; pSpawnClosest->X = (FLOAT)atof(pszArg); } } else if (!stricmp(argv[qq], "item")) { if (EnviroTarget.Name[0]==0) { printf("%s: item specified but no item targetted.", argv[0]); return 0; } pSpawnClosest = &EnviroTarget; } else if (!stricmp(argv[qq], "door")) { if (DoorEnviroTarget.Name[0] == 0) { printf("%s: door specified but no door targetted.", argv[0]); return 0; } pSpawnClosest = &DoorEnviroTarget; } else if (!strcmp(szArg,"help")) { printf("Usage: %s [spawn] [item] [door] [id #] [heading <ang>] [loc <y>,<x>] [away] [alert #]",argv[0]); return 0; } else { bOtherArgs = TRUE; qq+=ParseSearchSpawnArg(qq,argc,argv,SearchSpawn); // szFilter = ParseSearchSpawnArgs(szArg,szFilter,&SearchSpawn); } } if (!pSpawnClosest) { if (!bOtherArgs) { if (ppTarget && pTarget) { pSpawnClosest = (PSPAWNINFO)pTarget; } } else { pSpawnClosest = SearchThroughSpawns(&SearchSpawn,pChar); } } szMsg[0]=0; if (!pSpawnClosest) { printf("There were no matches for: %s",FormatSearchSpawn(szArg,&SearchSpawn)); } else { if (Predict) { Distance = DistanceToSpawn(pChar, pSpawnClosest); gFaceAngle = ( atan2((pSpawnClosest->X + (pSpawnClosest->SpeedX * Distance)) - pChar->X, (pSpawnClosest->Y + (pSpawnClosest->SpeedY * Distance)) - pChar->Y) * 256.0f / PI); } else { gFaceAngle = ( atan2(pSpawnClosest->X - pChar->X, pSpawnClosest->Y - pChar->Y) * 256.0f / PI); } if (Look) { Distance = DistanceToSpawn(pChar, pSpawnClosest); gLookAngle = ( atan2(pSpawnClosest->Z + pSpawnClosest->AvatarHeight*StateHeightMultiplier(pSpawnClosest->StandState) - pChar->Z - pChar->AvatarHeight*StateHeightMultiplier(pChar->StandState), (FLOAT)Distance) * 256.0f / PI); if (Away) gLookAngle = -gLookAngle; if (Fast) { pChar->CameraAngle = (FLOAT)gLookAngle; gLookAngle=10000.0f; } } if (Away) { gFaceAngle += 256.0f; } if (gFaceAngle>=512.0f) gFaceAngle -= 512.0f; if (gFaceAngle<0.0f) gFaceAngle += 512.0f; if (Fast) { ((PSPAWNINFO)pCharSpawn)->Heading = (FLOAT)gFaceAngle; gFaceAngle=10000.0f; } sprintf(szMsg,"Facing %s'%s'...",(Away)?"away from ":"", CleanupName(strcpy(szName,pSpawnClosest->Name),FALSE)); } if (ppTarget && pTarget) { psTarget = (PSPAWNINFO)pTarget; } if (szMsg[0] && ((pSpawnClosest != &LocSpawn) && ((Away) || (pSpawnClosest != psTarget)))) WriteChatColor(szMsg,USERCOLOR_WHO); DebugSpew("Face - %s",szMsg); return 0; }
// *************************************************************************** // Function: DoAbility // Description: Our '/doability' command // Does (or lists) your abilities // Usage: /doability [list|ability|#] // *************************************************************************** int CMD_DoAbility(int argc, char *argv[]) { if (argc<2) { printf("Syntax: %s list|<ability>",argv[0]); return 0; } DWORD Index, DoIndex = 0xFFFFFFFF; if (!stricmp(argv[1],"list") || !stricmp(argv[1], "-list")) { WriteChatColor("Abilities:",USERCOLOR_DEFAULT); for (Index=4;Index<10;Index++) { if (EQADDR_DOABILITYLIST[Index]==0xFFFFFFFF) { WriteChatf("%d. <Empty>",Index-3); } else if (szSkills[EQADDR_DOABILITYLIST[Index]]) { WriteChatf("%d. %s",Index-3,szSkills[EQADDR_DOABILITYLIST[Index]]); } else { WriteChatf("%d. *Unknown%d",Index-3,EQADDR_DOABILITYLIST[Index]); } } WriteChatColor("Combat Skills:"); for (Index=0;Index<4;Index++) { if (EQADDR_DOABILITYLIST[Index]==0xFFFFFFFF) { WriteChatf("%d. <Empty>",Index+7); } else if (szSkills[EQADDR_DOABILITYLIST[Index]]) { WriteChatf("%d. %s",Index+7,szSkills[EQADDR_DOABILITYLIST[Index]]); } else { WriteChatf("%d. *Unknown%d",Index+7,EQADDR_DOABILITYLIST[Index]); } } WriteChatColor("Combat Abiilities:",USERCOLOR_DEFAULT); for (Index=10;Index<18;Index++) { if (EQADDR_DOABILITYLIST[Index]==0xFFFFFFFF) { WriteChatf("%d. <Empty>",Index+1); } else if (EQADDR_DOABILITYLIST[Index] > 132) { // highest number we have defined so far WriteChatf("%d. *Unknown%d",Index+1,EQADDR_DOABILITYLIST[Index]); } else if (szSkills[EQADDR_DOABILITYLIST[Index]]) { WriteChatf("%d. %s",Index+1,szSkills[EQADDR_DOABILITYLIST[Index]]); } else { WriteChatf("%d. *Unknown%d",Index+1,EQADDR_DOABILITYLIST[Index]); } } return 0; } UseAbility(argv[1]); return 0; }
// *************************************************************************** // Function: EndMacro // Description: Our '/endmacro' command // Usage: /endmacro // *************************************************************************** VOID EndMacro(PSPAWNINFO pChar, PCHAR szLine) { CHAR Buffer[MAX_STRING] = {0}; DWORD i; PMACROBLOCK pPrev; PMACROSTACK pStack; PEVENTQUEUE pEvent; PEVENTLIST pEventL; BOOL bKeepKeys = gKeepKeys; if (szLine[0]!=0) { GetArg(Buffer,szLine,1); szLine = GetNextArg(szLine); if (stricmp(Buffer,"keep")) { SyntaxError("Usage: /endmacro [keep keys]"); return; } while (szLine[0]!=0) { GetArg(Buffer,szLine,1); szLine = GetNextArg(szLine); if (!stricmp(Buffer,"keys")) bKeepKeys = TRUE; } } if (!gMacroBlock) { MacroError("Cannot end a macro when one isn't running."); return; } /////////////// // Code allowing for a routine for "OnExit" while (gMacroBlock->pNext) { gMacroBlock=gMacroBlock->pNext; //DebugSpew("%s",gMacroBlock->Line); if (!stricmp(":OnExit",gMacroBlock->Line)) { if (gReturn) // return to the macro the first time around { gReturn = false; // We don't want to return the 2nd time. return; } else break; } } gReturn = true; // reset for next time // /////////////// #ifdef MQ2_PROFILING // How many performance counters in 1 second? LARGE_INTEGER PerformanceFrequency; QueryPerformanceCounter(&PerformanceFrequency); // Move to first macro line while (gMacroBlock->pPrev) gMacroBlock = gMacroBlock->pPrev; CHAR Filename[MAX_STRING] = {0}; FILE *fMacro = NULL; while (gMacroBlock) { // Is this a different macro file? if (strcmp(Filename, gMacroBlock->SourceFile)) { // Close existing file if (fMacro) { fclose(fMacro); } // Open new profiling log file strcpy(Filename, gMacroBlock->SourceFile); sprintf(Buffer, "%s\\%s.mqp", gszMacroPath, Filename); fMacro = fopen(Buffer, "w"); if (fMacro) { fprintf(fMacro, " Execute | Total | Avg uSec | Line | Macro Source Code\n"); fprintf(fMacro, " Count | uSec | Per 1000 |\n"); fprintf(fMacro, "------------------------------------------------------------------------------------------------------------- \n"); } } // Log execution/profiling information. Output format is: // Execution Count | Microseconds | Line # | Macro Source if (fMacro) { DWORD count = gMacroBlock->ExecutionCount; DWORD total = (DWORD)(gMacroBlock->ExecutionTime * 1000000 / PerformanceFrequency.QuadPart); DWORD avg = 0; if (count > 0) { avg = total * 1000 / count; } fprintf(fMacro, "%8lu | %8lu | %8lu | %4lu | %s\n", count, total, avg, gMacroBlock->LineNumber, gMacroBlock->Line); } // Terminate on last macro line if (gMacroBlock->pNext) { gMacroBlock = gMacroBlock->pNext; } else { break; } } // Close existing file if (fMacro) { fclose(fMacro); } #endif while (gMacroBlock->pNext) gMacroBlock=gMacroBlock->pNext; while (gMacroBlock) { pPrev = gMacroBlock->pPrev; free(gMacroBlock); gMacroBlock = pPrev; } while (gMacroStack) { pStack = gMacroStack->pNext; if (gMacroStack->LocalVariables) ClearMQ2DataVariables(&gMacroStack->LocalVariables); if (gMacroStack->Parameters) ClearMQ2DataVariables(&gMacroStack->Parameters); free(gMacroStack); gMacroStack = pStack; } gMacroSubLookupMap.clear(); while (gEventQueue) { pEvent = gEventQueue->pNext; free(gEventQueue); gEventQueue = pEvent; } while (pEventList) { pEventL = pEventList->pNext; free(pEventList); pEventList = pEventL; } #ifdef USEBLECHEVENTS pEventBlech->Reset(); #endif for (i=0;i<NUM_EVENTS;i++) { gEventFunc[i]=NULL; } gMacroPause = FALSE; gEventChat=0; gFaceAngle=10000.0f; gLookAngle=10000.0f; gDelay = 0; gTurbo = FALSE; pDoorTarget = NULL; #ifdef ISXEQ_LEGACY char ShortName[128]; ShortName[0]=0; _splitpath(gszMacroName,0,0,ShortName,0); IS_ScriptEngineScriptEnds(pExtension,pISInterface,hScriptEngineService,&g_LegacyEngine,ShortName); #endif gszMacroName[0]=0; gRunning = 0; if (!bKeepKeys) { KeyCombo TempCombo; for (i=0;gDiKeyID[i].szName[0];i++) { TempCombo.Data[3]=(unsigned char)gDiKeyID[i].Id; MQ2HandleKeyUp(TempCombo); } } ClearMQ2DataVariables(&pMacroVariables); DebugSpewNoFile("EndMacro - Ended"); if (gFilterMacro != FILTERMACRO_NONE && gFilterMacro != FILTERMACRO_MACROENDED) WriteChatColor("The current macro has ended.",USERCOLOR_DEFAULT); }
VOID CustomBindCmd(PSPAWNINFO pChar, PCHAR szLine) { if (szLine[0]==0) { SyntaxError("Usage: /custombind <list|add <name>|delete <name>|clear <name><-down|-up>|set <name><-down|-up> <command>>"); return; } CHAR szBuffer[MAX_STRING]; CHAR szArg[MAX_STRING] = {0}; CHAR szArg2[MAX_STRING] = {0}; GetArg(szArg,szLine,1); GetArg(szArg2,szLine,2); PCHAR szRest = GetNextArg(szLine,2); if (!_stricmp(szArg,"list")) { WriteChatColor("Custom binds"); WriteChatColor("--------------"); for (unsigned long N = 0 ; N < CustomBinds.Size ; N++) if (PCUSTOMBIND pBind=CustomBinds[N]) { sprintf_s(szBuffer,"[\ay%s\ax] [Down:\at%s\ax] [Up:\at%s\ax]",pBind->Name,pBind->CommandDown,pBind->CommandUp); WriteChatColor(szBuffer); } WriteChatColor("--------------"); WriteChatColor("End custom binds"); return; } if (!_stricmp(szArg,"add")) { if (strchr(szArg2,'-')) { WriteChatColor("'-' is not allowed in a custom bind name"); } if (PCUSTOMBIND pBind=AddCustomBind(szArg2,0,0)) { WriteChatColor("Custom bind added. Use /custombind set to set the custom commands."); } else { WriteChatColor("Failed to add custom bind (name in use)"); } return; } if (!_stricmp(szArg,"delete")) { int N=FindCustomBind(szArg2); if (N>=0) { RemoveCustomBind(N); WriteChatColor("Custom bind deleted"); } else { WriteChatColor("Could not find custom bind with that name to delete"); } return; } if (!_stricmp(szArg,"set")) { BOOL Down=true; if (PCHAR minus=strchr(szArg2,'-')) { minus[0]=0; if (!_stricmp(&minus[1],"up")) Down=false; } int N=FindCustomBind(szArg2); if (N<0) { sprintf_s(szBuffer,"Could not find custom bind '%s'",szArg2); WriteChatColor(szBuffer); return; } PCUSTOMBIND pBind=CustomBinds[N]; if (Down) strcpy_s(pBind->CommandDown,szRest); else strcpy_s(pBind->CommandUp,szRest); sprintf_s(szBuffer,"[\ay%s\ax] [Down:\at%s\ax] [Up:\at%s\ax]",pBind->Name,pBind->CommandDown,pBind->CommandUp); WriteChatColor(szBuffer); SaveCustomBinds(); return; } if (!_stricmp(szArg,"clear")) { BOOL Down=true; if (PCHAR minus=strchr(szArg2,'-')) { minus[0]=0; if (!_stricmp(&minus[1],"up")) Down=false; } int N=FindCustomBind(szArg2); if (N<0) { sprintf_s(szBuffer,"Could not find custom bind '%s'",szArg2); WriteChatColor(szBuffer); return; } PCUSTOMBIND pBind=CustomBinds[N]; if (Down) pBind->CommandDown[0]=0; else pBind->CommandUp[0]=0; sprintf_s(szBuffer,"[\ay%s\ax] [Down:\at%s\ax] [Up:\at%s\ax]",pBind->Name,pBind->CommandDown,pBind->CommandUp); WriteChatColor(szBuffer); SaveCustomBinds(); return; } }