Browse Source

FindNPC的验证,未完成

Wang Jeff 4 năm trước cách đây
mục cha
commit
2b600d5147

+ 50 - 19
GameAssist/GameAssist/GameAssistDlg.cpp

@@ -36,18 +36,25 @@ VOID DebugLog(CHAR* pszStr, ...)
 
 void InitZYNPC()
 {
-	// "医师独侠","术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠", "弓手独侠", "禁卫独侠", "墨者独侠", "巫煞独侠", "魂武独侠"
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("医师独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("术士独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("道士独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("武师独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("浪子独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("剑客独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("弓手独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("禁卫独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("墨者独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("巫煞独侠"), { 0, 0 }));
-	g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("魂武独侠"), { 0, 0 }));
+	static bool bInit = false;
+	if (!bInit) {
+		// "医师独侠","术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠", "弓手独侠", "禁卫独侠", "墨者独侠", "巫煞独侠", "魂武独侠"
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("医师独侠"), { 305, 325 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("术士独侠"), { 305, 325 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("道士独侠"), { 305, 325 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("武师独侠"), { 305, 325 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("浪子独侠"), { 160, 435 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("剑客独侠"), { 420, 230 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("弓手独侠"), { 265, 230 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("禁卫独侠"), { 155, 205 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("墨者独侠"), { 155, 205 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("巫煞独侠"), { 155, 205 }));
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("魂武独侠"), { 165, 335 }));
+		// 应天府NPC
+		g_mapZYNPC.insert(std::pair<std::string, POINT>(_T("职业训导大师"), { 315, 415 }));
+
+		bInit = true;
+	}
 }
 
 BOOL FindNPC(HWND hWnd, LPCSTR lpszNPC)
@@ -90,18 +97,26 @@ BOOL FindNPC(HWND hWnd, LPCSTR lpszNPC)
 	return bFind;
 }
 
-BOOL FindNPC(HWND hWnd, POINT ptMap, LPCTSTR lpszTemplate)
+BOOL FindNPC(HWND hWnd, POINT ptMap, LPCTSTR lpszNPCName)
 {
-	WorldMapPositioning(hWnd, ptMap);
-	CRect rc = FindMatchIcon(hWnd, lpszTemplate);
+	TCHAR szNPC[MAX_PATH] = {0};
+	_stprintf_s(szNPC, _T("img\\npc\\%s.bmp"), lpszNPCName);
+	CRect rc = FindMatchIcon(hWnd, szNPC);
 	if (rc.IsRectEmpty() || rc.IsRectNull())
-		return FALSE;
+	{
+		WorldMapPositioning(hWnd, ptMap);
+		CRect rc = FindMatchIcon(hWnd, szNPC);
+		if (rc.IsRectEmpty() || rc.IsRectNull())
+		{
+			return FALSE;
+		}
+	}
 
 	// 找到目标,单击;
 	GAssist::MouseMove(hWnd, CPoint(rc.left, rc.top));
 	// 单击:我要挑战他们;
-	GAssist::MouseClick(hWnd, CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2), TRUE);
-	SRAND(900, 1500);// 等对话框出现;
+	GAssist::MouseClick(hWnd, { (rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2 }, TRUE);
+	SRAND(900, 1300);// 等对话框出现;
 
 	return TRUE;
 }
@@ -1750,9 +1765,25 @@ void CGameAssistDlg::OnBnClickedButton10()
 }
 
 
-void CGameAssistDlg::OnBnClickedButton11()
+void CGameAssistDlg::OnBnClickedButton11() // 刷新;
 {
 	// TODO: 在此添加控件通知处理程序代码
+	InitZYNPC();
+	HWND hWnd = GAssist::GetProcessMainWnd();
+
+	char szName[11][32] = {"医师独侠", "术士独侠","道士独侠","武师独侠","浪子独侠",
+		"剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
+
+	for ( int i = 0; i < 11; i++ )
+	{
+		auto it = g_mapZYNPC.find(szName[i]);
+		if (it != g_mapZYNPC.end())
+		{
+			FindNPC(hWnd, it->second, it->first.c_str());
+			Sleep(500);
+			GAssist::MouseRClick(hWnd);
+		}
+	}
 }
 
 

BIN
GameAssist/img/npc/剑客独侠.bmp


BIN
GameAssist/img/npc/医师独侠.bmp


BIN
GameAssist/img/npc/墨者独侠.bmp


BIN
GameAssist/img/npc/巫煞独侠.bmp


BIN
GameAssist/img/npc/弓手独侠.bmp


BIN
GameAssist/img/npc/术士独侠.bmp


BIN
GameAssist/img/npc/武师独侠.bmp


BIN
GameAssist/img/npc/浪子独侠.bmp


BIN
GameAssist/img/npc/禁卫独侠.bmp


BIN
GameAssist/img/npc/道士独侠.bmp