int MyCommand(int argc, char *argv[]) { // IS Commands work just like console programs. argc is the argument (aka parameter) count, // argv is an array containing them. The name of the command is always the first argument. if (argc<2) { // This command requires arguments WriteChatf("Syntax: %s <text>", argv[0]); return 0; } char FullText[8192] = { 0 }; pISInterface->GetArgs(1, argc, argv, FullText, sizeof(FullText)); // this gets the rest of the arguments, from 1 to argc WriteChatf("You passed the following text to the command:"); WriteChatf("%s", FullText); // For most commands, you need to deal with only one argument at a time, instead of the entire line. for (int i = 1; i < argc; i++) { WriteChatf("argv[%d]=\"%s\"", i, argv[i]); } // return 0 or greater for normal conditions, or return -1 for an error that should stop // a script. return 0; }
DWORD __stdcall openpickzonewnd(PVOID pData) { if(!cmdPickZone) return 0; lockit lk(ghLockPickZone); int nInst = (int)pData; CHAR szInst[32] = { 0 }; itoa(nInst, szInst, 10); if (PCHARINFO pCharInfo = GetCharInfo()) { cmdPickZone(pCharInfo->pSpawn, NULL); Sleep(2000);//i need to make this hardcoded wait dynamic but im in a hurry ill do it later -eqmule if (CXWnd *krwnd = FindMQ2Window("MIZoneSelectWnd")) { if (krwnd->dShow) { if (CListWnd *clist = (CListWnd*)krwnd->GetChildItem("MIZ_ZoneList")) { if (DWORD numitems = ((CSidlScreenWnd*)clist)->Items) { if (CButtonWnd *cbutt = (CButtonWnd*)krwnd->GetChildItem("MIZ_SelectButton")) { CHAR szOut[255] = { 0 }; CXStr Str; std::string s; bool itsmain = false; bool clickit = false; for (DWORD i = 0; i<numitems; i++) { clist->GetItemText(&Str, i, 0); GetCXStr(Str.Ptr, szOut, 254); if (szOut[0] != '\0') { s = szOut; if (std::string::npos == s.find_first_of("123456789")) { itsmain = true; } if (itsmain && nInst == 0) { clickit = true; } else if (nInst >= 1) { if (std::string::npos != s.find_first_of(szInst)) { clickit = true; } } if (clickit) { SendListSelect("MIZoneSelectWnd", "MIZ_ZoneList", i); Sleep(500); SendWndClick2((CXWnd*)cbutt, "leftmouseup"); WriteChatf("%s selected.", szOut); return 0; } } } WriteChatf("%s instance %d NOT found in list", GetFullZone(pCharInfo->zoneId), nInst); } } } } } } return 0; }
int CMD_WhoFilter(int argc, char* argv[]) { if (argc < 3) { WriteChatf("Syntax: %s <lastname|class|race|level|gm|guild|holding|ld|sneak|anon|lfg|npctag|spawnid|trader|afk|concolor|invisible> [on|off]",0); return 0; } if (!stricmp(argv[1],"Lastname")) { SetDisplaySWhoFilter(&gFilterSWho.Lastname,"Lastname",argv[2]); } else if (!stricmp(argv[1],"Class")) { SetDisplaySWhoFilter(&gFilterSWho.Class,"Class",argv[2]); } else if (!stricmp(argv[1],"Race")) { SetDisplaySWhoFilter(&gFilterSWho.Race,"Race",argv[2]); } else if (!stricmp(argv[1],"Body")) { SetDisplaySWhoFilter(&gFilterSWho.Body,"Body",argv[2]); } else if (!stricmp(argv[1],"Level")) { SetDisplaySWhoFilter(&gFilterSWho.Level,"Level",argv[2]); } else if (!stricmp(argv[1],"GM")) { SetDisplaySWhoFilter(&gFilterSWho.GM,"GM",argv[2]); } else if (!stricmp(argv[1],"Guild")) { SetDisplaySWhoFilter(&gFilterSWho.Guild,"Guild",argv[2]); } else if (!stricmp(argv[1],"LD")) { SetDisplaySWhoFilter(&gFilterSWho.LD,"LD",argv[2]); } else if (!stricmp(argv[1],"Sneak")) { SetDisplaySWhoFilter(&gFilterSWho.Sneak,"Sneak",argv[2]); } else if (!stricmp(argv[1],"LFG")) { SetDisplaySWhoFilter(&gFilterSWho.LFG,"LFG",argv[2]); } else if (!stricmp(argv[1],"NPCTag")) { SetDisplaySWhoFilter(&gFilterSWho.NPCTag,"NPCTag",argv[2]); } else if (!stricmp(argv[1],"SpawnID")) { SetDisplaySWhoFilter(&gFilterSWho.SpawnID,"SpawnID",argv[2]); } else if (!stricmp(argv[1],"Trader")) { SetDisplaySWhoFilter(&gFilterSWho.Trader,"Trader",argv[2]); } else if (!stricmp(argv[1],"AFK")) { SetDisplaySWhoFilter(&gFilterSWho.AFK,"AFK",argv[2]); } else if (!stricmp(argv[1],"Anon")) { SetDisplaySWhoFilter(&gFilterSWho.Anon,"Anon",argv[2]); } else if (!stricmp(argv[1],"Distance")) { SetDisplaySWhoFilter(&gFilterSWho.Distance,"Distance",argv[2]); } else if (!stricmp(argv[1],"Light")) { SetDisplaySWhoFilter(&gFilterSWho.Light,"Light",argv[2]); } else if (!stricmp(argv[1],"Holding")) { SetDisplaySWhoFilter(&gFilterSWho.Holding,"Holding",argv[2]); } else if (!stricmp(argv[1],"ConColor")) { SetDisplaySWhoFilter(&gFilterSWho.ConColor,"ConColor",argv[2]); } else if (!stricmp(argv[1],"Invisible")) { SetDisplaySWhoFilter(&gFilterSWho.Invisible,"Invisible",argv[2]); } else { WriteChatf("Syntax: %s <lastname|class|race|level|gm|guild|holding|ld|sneak|anon|lfg|npctag|spawnid|trader|afk|concolor|invisible> [on|off]",0); } return 0; }
//EQLIB_API VOID DoMappable(PSPAWNINFO pChar, PCHAR szLine) int CMD_Keypress(int argc, char *argv[]) { if (argc<2) { WriteChatf("Syntax: %s <eqcommand|keycombo> [hold|chat]",argv[0]); return 0; } bool bHold=false; bool bChat=false; if (argc==3) { if (!stricmp(argv[2],"hold")) { bHold=true; } else if (!stricmp(argv[2],"chat")) { bChat=true; } } if (!PressMQ2KeyBind(argv[1],bHold)) { int N=FindMappableCommand(argv[1]); if (N>=0) { ExecuteCmd(N,1,0); if (!bHold) ExecuteCmd(N,0,0); return 0; } KeyCombo Temp; if (ParseKeyCombo(argv[1],Temp)) { if (bChat) { pWndMgr->HandleKeyboardMsg(Temp.Data[3],1); pWndMgr->HandleKeyboardMsg(Temp.Data[3],0); } else { MQ2HandleKeyDown(Temp); if (!bHold) MQ2HandleKeyUp(Temp); } return 0; } WriteChatf("Invalid mappable command or key combo '%s'",argv[1]); return -1; } return 0; }
// Initialize is called by Inner Space when the extension should initialize. bool ISXEQLabels::Initialize(ISInterface *p_ISInterface) { pISInterface=p_ISInterface; // retrieve basic ISData types pStringType=pISInterface->FindLSType("string"); pIntType=pISInterface->FindLSType("int"); pBoolType=pISInterface->FindLSType("bool"); pFloatType=pISInterface->FindLSType("float"); pTimeType=pISInterface->FindLSType("time"); pByteType=pISInterface->FindLSType("byte"); pISInterface->OpenSettings(XMLFileName); LoadSettings(); ConnectServices(); RegisterCommands(); RegisterAliases(); RegisterDataTypes(); RegisterTopLevelObjects(); RegisterServices(); EzDetour(CLabel__Draw,&CLabelHook::Draw_Detour,&CLabelHook::Draw_Trampoline); EzDetour(CSidlManager__CreateLabel,&CSidlManagerHook::CreateLabel_Detour,&CSidlManagerHook::CreateLabel_Trampoline); // currently in testing: // EasyClassDetour(CGauge__Draw,CGaugeHook,Draw_Detour,VOID,(VOID),Draw_Trampoline); // EasyDetour(__GetGaugeValueFromEQ,GetGaugeValueFromEQ_Hook,int,(int,class CXStr *,bool *),GetGaugeValueFromEQ_Trampoline); WriteChatf("ISXEQLabels Loaded"); return true; }
// Initialize is called by Inner Space when the extension should initialize. bool ISXEQHUDMove::Initialize(ISInterface *p_ISInterface) { pISInterface = p_ISInterface; // retrieve basic ISData types pStringType = pISInterface->FindLSType("string"); pIntType = pISInterface->FindLSType("int"); pBoolType = pISInterface->FindLSType("bool"); pFloatType = pISInterface->FindLSType("float"); pTimeType = pISInterface->FindLSType("time"); pByteType = pISInterface->FindLSType("byte"); pISInterface->OpenSettings(XMLFileName); LoadSettings(); ConnectServices(); RegisterCommands(); RegisterAliases(); RegisterDataTypes(); RegisterTopLevelObjects(); RegisterServices(); WriteChatf("ISXEQHUDMove Loaded"); return true; }
// Initialize is called by Inner Space when the extension should initialize. bool ISXEQItemDisplay::Initialize(ISInterface *p_ISInterface) { pISInterface=p_ISInterface; // retrieve basic ISData types pStringType=pISInterface->FindLSType("string"); pIntType=pISInterface->FindLSType("int"); pBoolType=pISInterface->FindLSType("bool"); pFloatType=pISInterface->FindLSType("float"); pTimeType=pISInterface->FindLSType("time"); pByteType=pISInterface->FindLSType("byte"); pISInterface->OpenSettings(XMLFileName); ConnectServices(); RegisterCommands(); RegisterAliases(); RegisterDataTypes(); RegisterTopLevelObjects(); RegisterServices(); EzDetour(CItemDisplayWnd__SetSpell,&ItemDisplayHook::SetSpell_Detour,&ItemDisplayHook::SetSpell_Trampoline); EzDetour(CItemDisplayWnd__UpdateStrings, &ItemDisplayHook::UpdateStrings_Detour, &ItemDisplayHook::UpdateStrings_Trampoline); //EzDetour(CXWnd__DrawTooltipAtPoint,&XWndHook::DrawTooltipAtPoint_Detour,&XWndHook::DrawTooltipAtPoint_Trampoline); //EzDetour(CInvSlotWnd__DrawTooltip, &InvSlotWndHook::DrawTooltip_Detour, &InvSlotWndHook::DrawTooltip_Trampoline); WriteChatf("ISXEQItemDisplay Loaded"); return true; }
// CMD_EQModKey int CMD_EQModKey(int argc, char *argv[]) { CHAR chCommand[2048] = {0}; bool KeyboardFlags[4] = {false,false,false,false}; if (argc<1) { WriteChatf("Usage: %s <command>", argv[0]); return 0; } pISInterface->GetArgs(1,argc,argv,chCommand,sizeof(chCommand)); *(DWORD*)&KeyboardFlags=*(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags; if (!stricmp(argv[0],"nomodkey")) *(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags=0; else if (!stricmp(argv[0],"shift")) ((PCXWNDMGR)pWndMgr)->KeyboardFlags[0]=1; else if (!stricmp(argv[0],"ctrl")) ((PCXWNDMGR)pWndMgr)->KeyboardFlags[1]=1; else if (!stricmp(argv[0],"alt")) ((PCXWNDMGR)pWndMgr)->KeyboardFlags[2]=1; DebugSpew("CMD_EQModKey Executing %s", chCommand); pISInterface->ExecuteCommand(chCommand); *(DWORD*)&((PCXWNDMGR)pWndMgr)->KeyboardFlags=*(DWORD*)&KeyboardFlags; return 0; }
// /loginname int CMD_DisplayLoginName(int argc, char *argv[]) { PCHAR szLogin = GetLoginName(); if (!szLogin) { printf("Unable to retrieve login name."); } else { WriteChatf("Login name: \ay%s\ax",szLogin); free(szLogin); } return 0; }
int CMD_MapHighlight(int argc, char *argv[]) { if (argc<2) { WriteChatf("Syntax: /highlight reset|<spawnfilter>|color <#> <#> <#>"); return 0; }; if (!stricmp(argv[1],"color")) { if (argc<5) { WriteChatf("Highlight color: %d %d %d",(HighlightColor&0x00FF0000)>>16,(HighlightColor&0x0000FF00)>>8,(HighlightColor&0x000000FF)); return 0; } unsigned char R = (unsigned char)atoi(argv[2]); unsigned char G = (unsigned char)atoi(argv[3]); unsigned char B = (unsigned char)atoi(argv[4]); HighlightColor=0xFF000000 | (R << 16) | (G << 8) | (B); WriteChatf("Highlight color: %d %d %d",R,G,B); return 0; }
void MQ2NavigationPlugin::Stop() { if (m_isActive) { WriteChatf(PLUGIN_MSG "Stopping navigation"); MQ2Globals::ExecuteCmd(FindMappableCommand("FORWARD"), 0, 0); } m_activePath.reset(); m_isActive = false; m_pEndingDoor = nullptr; m_pEndingItem = nullptr; }
int CMD_MapShow(int argc, char *argv[]) { if (argc<2) { WriteChatf("Syntax: %s <spawnfilter>|reset",argv[0]); return 0; }; if (!stricmp(argv[1],"reset")) { MapClear(); MapGenerate(); WriteChatf("Map spawns regenerated"); return 0; } if (PCHARINFO pCharInfo=GetCharInfo()) { SEARCHSPAWN ssShow; ClearSearchSpawn(&ssShow); ParseSearchSpawn(1,argc,argv,ssShow); WriteChatf("%d previously hidden spawns shown",MapShow(ssShow)); } 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; }
void DumpWarning(PCHAR pStart, int index) { if (PMACROBLOCK pBlock = GetCurrentMacroBlock()) { MACROLINE ml = pBlock->Line[index]; BOOL oldbAllErrorsDumpStack = bAllErrorsDumpStack; BOOL oldbAllErrorsFatal = bAllErrorsFatal; bAllErrorsDumpStack = FALSE; bAllErrorsFatal = FALSE; WriteChatf("\arWARNING: \awUndefined Variable \ag%s\aw used on line %d@%s \ay%s\ax\nMacro Paused.", pStart, ml.LineNumber, ml.SourceFile.c_str(), ml.Command.c_str()); pBlock->Paused = 1; bAllErrorsDumpStack = oldbAllErrorsDumpStack; bAllErrorsFatal = oldbAllErrorsFatal; } }
VOID MQChatFont(PSPAWNINFO pChar, PCHAR Line) { if (MQChatWnd) { if (Line[0]) { int size=atoi(Line); if (size<0 || size>10) { WriteChatf("Usage: /mqfont 0-10"); return; } MQChatWnd->SetChatFont(size); SaveChatToINI((PCSIDLWND)MQChatWnd); } } }
int CMD_SellItem(int argc, char *argv[]) { if (argc<2) { WriteChatf("Syntax: %s <quantity>",argv[0]); return 0; } if (!pMerchantWnd) return 0; PCHARINFO pCharInfo; if (NULL == (pCharInfo = GetCharInfo())) return 0; DWORD Qty = (DWORD)atoi(argv[1]); if (Qty > 20 || Qty < 1) return 0; pMerchantWnd->RequestSellItem(Qty); return 0; }
void MQ2NavigationPlugin::BeginNavigation(const glm::vec3& pos) { // first clear existing state m_isActive = false; m_activePath.reset(); if (!Get<NavMeshLoader>()->IsNavMeshLoaded()) { WriteChatf(PLUGIN_MSG "\arCannot navigate - No mesh file loaded."); return; } m_activePath = std::make_unique<NavigationPath>(); m_activePath->FindPath(pos); m_isActive = m_activePath->GetPathSize() > 0; }
void SaveSettings(bool showMessage/* = true*/) { if (showMessage) { WriteChatf(PLUGIN_MSG "Saving settings..."); } // default settings SaveBoolSetting("AutoBreak", g_settings.autobreak); SaveBoolSetting("AutoPause", g_settings.autopause); SaveBoolSetting("AutoReload", g_settings.autoreload); SaveBoolSetting("ShowUI", g_settings.show_ui); SaveBoolSetting("ShowNavMesh", g_settings.show_navmesh_overlay); SaveBoolSetting("ShowNavPath", g_settings.show_nav_path); // debug settings SaveBoolSetting("DebugRenderPathing", g_settings.debug_render_pathing); }
// /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; }
int CMD_MemSpell(int argc, char *argv[]) { if (argc < 3) { WriteChatf("Syntax: %s <gem #> <spellname>",argv[0]); return 0; } if (!ppSpellBookWnd) return -1; DWORD Favorite = (DWORD)&MemSpellFavorite; DWORD sp; WORD Gem = -1; PCHARINFO pCharInfo = NULL; if (!pSpellBookWnd) return -1; if (NULL == (pCharInfo = GetCharInfo())) return -1; Gem = atoi(argv[1]); if (Gem<1 || Gem>NUM_SPELL_GEMS) return -1; Gem--; GetCharInfo2()->SpellBook; PSPELL pSpell=0; for (DWORD N = 0 ; N < NUM_BOOK_SLOTS ; N++) if (PSPELL pTempSpell=GetSpellByID(GetCharInfo2()->SpellBook[N])) { if (!stricmp(argv[2],pTempSpell->Name)) { pSpell=pTempSpell; break; } } if (!pSpell) return -1; if (pSpell->ClassLevel[GetCharInfo2()->Class]>GetCharInfo2()->Level) return -1; ZeroMemory(&MemSpellFavorite,sizeof(MemSpellFavorite)); strcpy(MemSpellFavorite.Name,"Mem a Spell"); MemSpellFavorite.inuse=1; for (sp=0;sp<NUM_SPELL_GEMS;sp++) MemSpellFavorite.SpellId[sp]=0xFFFFFFFF; MemSpellFavorite.SpellId[Gem] = pSpell->ID; pSpellBookWnd->MemorizeSet((int*)Favorite,NUM_SPELL_GEMS); return 0; }
VOID LoadHUD(PSPAWNINFO pChar, PCHAR szLine) { CHAR HUDTemp[MAX_STRING] = {0}; CHAR CurrentHUD[MAX_STRING]; int argn=1; GetArg(CurrentHUD,HUDNames,argn,0,0,0,','); while (*CurrentHUD) { if (!strcmp(CurrentHUD,szLine)) { WriteChatf("Hud \"%s\" already loaded",szLine); return; } if (HUDTemp[0]) strcat_s(HUDTemp,","); strcat_s(HUDTemp,CurrentHUD); GetArg(CurrentHUD,HUDNames,++argn,0,0,0,','); } if (HUDTemp[0]) strcat_s(HUDTemp,","); strcat_s(HUDTemp,szLine); strcpy_s(HUDNames,HUDTemp); HandleINI(); }
// *************************************************************************** // 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; }
VOID UnLoadHUD(PSPAWNINFO pChar, PCHAR szLine) { CHAR HUDTemp[MAX_STRING] = {0}; CHAR CurrentHUD[MAX_STRING]; bool found=false; int argn=1; GetArg(CurrentHUD,HUDNames,argn,0,0,0,','); while (*CurrentHUD) { if (!strcmp(CurrentHUD,szLine)) { found=true; } else { if (HUDTemp[0]) strcat_s(HUDTemp,","); strcat_s(HUDTemp,CurrentHUD); } GetArg(CurrentHUD,HUDNames,++argn,0,0,0,','); } strcpy_s(HUDNames,HUDTemp); if (!found) WriteChatf("Hud \"%s\" not loaded",szLine); HandleINI(); }
void LoadSettings(bool showMessage/* = true*/) { if (showMessage) { WriteChatf(PLUGIN_MSG "Loading settings..."); } SettingsData defaults, &settings = g_settings; settings.autobreak = LoadBoolSetting("AutoBreak", defaults.autobreak); settings.autopause = LoadBoolSetting("AutoPause", defaults.autopause); settings.autoreload = LoadBoolSetting("AutoReload", defaults.autoreload); settings.show_ui = LoadBoolSetting("ShowUI", defaults.show_ui); settings.show_navmesh_overlay = LoadBoolSetting("ShowNavMesh", defaults.show_navmesh_overlay); settings.show_nav_path = LoadBoolSetting("ShowNavPath", defaults.show_nav_path); settings.attempt_unstuck = LoadBoolSetting("AttemptUnstuck", defaults.attempt_unstuck); // debug settings settings.debug_render_pathing = LoadBoolSetting("DebugRenderPathing", defaults.debug_render_pathing); SaveSettings(false); }
VOID PluginsAddSpawn(PSPAWNINFO pNewSpawn) { DWORD BodyType=GetBodyType(pNewSpawn); PluginDebug("PluginsAddSpawn(%s,%d,%d)",pNewSpawn->Name,pNewSpawn->mActorClient.Race,BodyType); if (!bPluginCS) return; if (GetGameState()>GAMESTATE_CHARSELECT) SetNameSpriteState(pNewSpawn,1); if (GetBodyTypeDesc(BodyType)[0]=='*') { WriteChatf("Spawn '%s' has unknown bodytype %d",pNewSpawn->Name,BodyType); } CAutoLock Lock(&gPluginCS); PMQPLUGIN pPlugin=pPlugins; while(pPlugin) { if (pPlugin->AddSpawn) { pPlugin->AddSpawn(pNewSpawn); } pPlugin=pPlugin->pNext; } }
bool NavMeshLoader::LoadNavMesh() { // At this point, we expect the zone short name to be set, so we know // which map file we need to load. // Upon successful completion of this load, we will have set the dtNavMesh // and the filename that we loaded. if (m_zoneShortName.empty()) return false; // the root path is where we look for all of our mesh files std::string root_path = GetMeshDirectory() + "\\"; // The mesh filename std::string mesh_filename = m_zoneShortName + ".bin"; std::string data_file = root_path + mesh_filename; // this is what we do after we successfully read from a file. We are given the // data, its length, and the file that provided the data. If the load succeeds, // we'll store the filename and process the mesh. If the load fails, we'll move // onto the next file. // The code is broken up this way to maintain consistency between loading from a // rar file, and loading from a plain .bin file auto next_load_stage = [&](const auto& load_ret_val, const std::string& load_filename) -> bool { std::shared_ptr<char> data = load_ret_val.first; DWORD dataLen = load_ret_val.second; LoadResult result = LoadZoneMeshData(data, dataLen); if (result == SUCCESS) { WriteChatf(PLUGIN_MSG "\agSuccessfully loaded mesh for \am%s\ax (%s)", m_zoneShortName.c_str(), load_filename.c_str()); m_loadedDataFile = load_filename; // Get filetime HANDLE hFile = CreateFile(m_loadedDataFile.c_str(), GENERIC_READ, FILE_SHARE_READ, NULL, OPEN_EXISTING, 0, NULL); if (hFile != INVALID_HANDLE_VALUE) { GetFileTime(hFile, NULL, NULL, &m_fileTime); } CloseHandle(hFile); return true; } if (result == CORRUPT) { WriteChatf(PLUGIN_MSG "\arFailed to load mesh file, the file is corrupt (%s)", load_filename.c_str()); } else if (result == VERSION_MISMATCH) { WriteChatf(PLUGIN_MSG "\arCouldn't load mesh file due to version mismatch (%s)", load_filename.c_str()); } return false; }; // load raw mesh file first auto file_data = ReadFile(data_file); if (file_data.first) { if (next_load_stage(file_data, data_file)) return true; } WriteChatf(PLUGIN_MSG "\ayNo nav mesh available for \am%s\ax", m_zoneShortName.c_str()); return false; }
VOID MapFilterSetting( DWORD nMapFilter, int arg, int argc, char *argv[]) { CHAR szBuffer[MAX_STRING] = {0}; CHAR Buff[MAX_STRING]={0}; PCHAR szFilterMap[] = { "hide", "show", NULL }; PMAPFILTER pMapFilter=&MapFilterOptions[nMapFilter]; if (!RequirementsMet(nMapFilter)) { WriteChatf("'%s' requires '%s' option. Please enable this option first.",pMapFilter->szName,MapFilterOptions[pMapFilter->RequiresOption].szName); return; } if (arg>=argc) { // NO VALUE char szBuffer[2048]={0}; if (pMapFilter->bIsToggle) { sprintf(szBuffer,"%s: %s",pMapFilter->szName,szFilterMap[pMapFilter->Enabled]); } else if (nMapFilter == MAPFILTER_Custom) { if (IsOptionEnabled(nMapFilter)==0) { sprintf(szBuffer,"%s: Off",pMapFilter->szName); } else { sprintf(szBuffer,"%s: %s",pMapFilter->szName,FormatSearchSpawn(Buff,&MapFilterCustom)); } } else { sprintf(szBuffer,"%s: %d",pMapFilter->szName,pMapFilter->Enabled); } if (pMapFilter->DefaultColor != -1) { DWORD R,G,B; R= (pMapFilter->Color&0xFF0000)/0x10000; G= (pMapFilter->Color&0xFF00)/0x100; B= pMapFilter->Color&0xFF; WriteChatf("%s (Color: %d %d %d)",szBuffer,R,G,B); } else WriteChatf("%s",szBuffer); return; } if (pMapFilter->bIsToggle) { if (!stricmp(szFilterMap[0],argv[arg])) { pMapFilter->Enabled = 0; } else if (!stricmp(szFilterMap[1],argv[arg])) { pMapFilter->Enabled = 1; } else { pMapFilter->Enabled = 1 - pMapFilter->Enabled; } WriteChatf("%s is now set to: %s",pMapFilter->szName,szFilterMap[IsOptionEnabled(nMapFilter)]); } else if (nMapFilter == MAPFILTER_Custom) { ClearSearchSpawn(&MapFilterCustom); { pMapFilter->Enabled = 1; ParseSearchSpawn(arg+1,argc,argv,MapFilterCustom); WriteChatf("%s is now set to: %s",pMapFilter->szName,FormatSearchSpawn(Buff,&MapFilterCustom)); } } else { pMapFilter->Enabled = atoi(argv[arg]); WriteChatf("%s is now set to: %d",pMapFilter->szName,pMapFilter->Enabled); } itoa(pMapFilter->Enabled,szBuffer,10); pISInterface->SetSettingi("ISXEQMap.xml","Map Filters",pMapFilter->szName,pMapFilter->Enabled); pISInterface->SaveSettings("ISXEQMap.xml"); }
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; }
void NavigationPath::UpdatePath(bool force) { if (m_navMesh == nullptr) return; if (m_query == nullptr) { m_query.reset(new dtNavMeshQuery); m_query->init(m_navMesh, 10000 /* MAX_NODES */); } PSPAWNINFO me = GetCharInfo()->pSpawn; if (me == nullptr) return; float startOffset[3] = { me->X, me->Feet, me->Y }; float endOffset[3] = { m_destination.x, m_destination.z, m_destination.y }; float spos[3]; float epos[3]; glm::vec3 thisPos(startOffset[0], startOffset[1], startOffset[2]); if (thisPos == m_lastPos && !force) return; m_lastPos = thisPos; m_currentPathCursor = 0; m_currentPathSize = 0; dtPolyRef startRef, endRef; m_query->findNearestPoly(startOffset, m_extents, &m_filter, &startRef, spos); if (!startRef) { WriteChatf(PLUGIN_MSG "No start reference"); return; } dtPolyRef polys[MAX_POLYS]; int numPolys = 0; if (!m_corridor) { if (m_useCorridor) { // initialize planning m_corridor.reset(new dtPathCorridor); m_corridor->init(MAX_PATH_SIZE); m_corridor->reset(startRef, startOffset); } m_query->findNearestPoly(endOffset, m_extents, &m_filter, &endRef, epos); if (!endRef) { WriteChatf(PLUGIN_MSG "No end reference"); return; } dtStatus status = m_query->findPath(startRef, endRef, spos, epos, &m_filter, polys, &numPolys, MAX_POLYS); if (status & DT_OUT_OF_NODES) DebugSpewAlways("findPath from %.2f,%.2f,%.2f to %.2f,%.2f,%.2f failed: out of nodes", startOffset[0], startOffset[1], startOffset[2], endOffset[0], endOffset[1], endOffset[2]); if (status & DT_PARTIAL_RESULT) DebugSpewAlways("findPath from %.2f,%.2f,%.2f to %.2f,%.2f,%.2f returned a partial result.", startOffset[0], startOffset[1], startOffset[2], endOffset[0], endOffset[1], endOffset[2]); if (m_corridor) { m_corridor->setCorridor(endOffset, polys, numPolys); } } else { // this is an update m_corridor->movePosition(startOffset, m_query.get(), &m_filter); } if (m_corridor) { m_corridor->optimizePathTopology(m_query.get(), &m_filter); m_currentPathSize = m_corridor->findCorners(m_currentPath, m_cornerFlags, polys, 10, m_query.get(), &m_filter); } if (m_debugDrawGrp) m_debugDrawGrp->Reset(); if (numPolys > 0) { m_query->findStraightPath(spos, epos, polys, numPolys, m_currentPath, 0, 0, &m_currentPathSize, MAX_POLYS, 0); // The 0th index is the starting point. Begin by trying to reach the // 2nd point... if (m_currentPathSize > 1) m_currentPathCursor = 1; if (m_debugDrawGrp && mq2nav::GetSettings().debug_render_pathing) { DebugDrawDX dd(m_debugDrawGrp.get()); // draw current position duDebugDrawCross(&dd, me->X, me->Feet, me->Y, 0.5, DXColor(51, 255, 255), 1); // Draw the waypoints. Green is next point for (int i = 0; i < m_currentPathSize; ++i) { int color = DXColor(255, 255, 255); if (i < m_currentPathCursor) color = DXColor(0, 102, 204); if (i == m_currentPathCursor) color = DXColor(0, 255, 0); if (i == m_currentPathSize - 1) color = DXColor(255, 0, 0); duDebugDrawCross(&dd, m_currentPath[i * 3], m_currentPath[i * 3 + 1], m_currentPath[i * 3 + 2], 0.5, color, 1); } } } if (m_line && mq2nav::GetSettings().show_nav_path) { m_line->Update(); } }
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; } } }