|
@@ -1,2 +1,507 @@
|
|
#include "stdafx.h"
|
|
#include "stdafx.h"
|
|
#include "CAction.h"
|
|
#include "CAction.h"
|
|
|
|
+
|
|
|
|
+namespace GameAssist
|
|
|
|
+{
|
|
|
|
+#define SETGAMEFOREGROUND AutoThreadSection ats(&m_ts);\
|
|
|
|
+if (!::IsWindow(m_hGameWnd)) return;\
|
|
|
|
+::ShowWindow(m_hGameWnd, SW_SHOWNORMAL);\
|
|
|
|
+::SetForegroundWindow(m_hGameWnd);
|
|
|
|
+
|
|
|
|
+ ThreadSection CAction::m_ts;
|
|
|
|
+ VOID DebugLog(CHAR* pszStr, ...)
|
|
|
|
+ {
|
|
|
|
+ char szData[MAX_PATH] = { 0 };
|
|
|
|
+ _stprintf_s(szData, _T("%s %s "), _T("[GameAssist] "), CTime::GetCurrentTime().Format(_T("%Y-%m-%d %H:%M:%S")).GetString());
|
|
|
|
+ int len = strlen(szData);
|
|
|
|
+ va_list args;
|
|
|
|
+ va_start(args, pszStr);
|
|
|
|
+ _vsnprintf_s(szData + len, MAX_PATH - len, MAX_PATH - len, pszStr, args);
|
|
|
|
+ va_end(args);
|
|
|
|
+ strcat_s(szData, "\n");
|
|
|
|
+ OutputDebugStringA(szData);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CAction::CAction(HWND hWnd) :m_hGameWnd(hWnd)
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CAction::~CAction()
|
|
|
|
+ {
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseMove(POINT pt, bool bSetCurPos)
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::GamePos2Screen(m_hGameWnd, pt);
|
|
|
|
+ GameAssist::MouseMove(pt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseClick()
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::MouseClick();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseClick(POINT pt)
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::GamePos2Screen(m_hGameWnd, pt);
|
|
|
|
+ GameAssist::MouseClick(pt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseDbClick()
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::MouseDbClick();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseDbClick(POINT pt)
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::GamePos2Screen(m_hGameWnd, pt);
|
|
|
|
+ GameAssist::MouseDbClick(pt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseRClick()
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::MouseRClick();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseRClick(POINT pt)
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::GamePos2Screen(m_hGameWnd, pt);
|
|
|
|
+ GameAssist::MouseRClick(pt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::MouseDrag(POINT pt)
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::GamePos2Screen(m_hGameWnd, pt);
|
|
|
|
+ GameAssist::MouseDrag(pt);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::SendKey(DWORD key, BOOL bCtrl, BOOL bAtl, BOOL bShift)
|
|
|
|
+ {
|
|
|
|
+ SETGAMEFOREGROUND;
|
|
|
|
+ GameAssist::SendKey(key, bCtrl, bAtl, bShift);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::SetGameForeground()
|
|
|
|
+ {
|
|
|
|
+ AutoThreadSection ats(&m_ts);
|
|
|
|
+ if (!::IsWindow(m_hGameWnd)) return;
|
|
|
|
+ ::ShowWindow(m_hGameWnd, SW_SHOWNORMAL);
|
|
|
|
+ ::SetForegroundWindow(m_hGameWnd); // 窗口前置才能单击成功;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::IsWalkStop()
|
|
|
|
+ {
|
|
|
|
+ if (!::IsWindow(m_hGameWnd))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ // 将鼠标移走,不要在抠图区域;
|
|
|
|
+ // 截图,抠指定区域;
|
|
|
|
+ // 再截图,抠指定区域与上次抠图结果比较;
|
|
|
|
+ // 比较结果相同,表示停止走路;
|
|
|
|
+ //POINT pt1 = { 635, 20 };
|
|
|
|
+ //POINT pt2 = { 780, 38 };
|
|
|
|
+ CRect rc = { 630, 40, 800, 65 };
|
|
|
|
+ CRect rc2 = { 640, 45, 770, 63 };
|
|
|
|
+ for (int i = 0; i < 100; i++)
|
|
|
|
+ {
|
|
|
|
+ std::string strImg = GameGlobal::BuildImgPath(m_hGameWnd, "walk1");
|
|
|
|
+ std::string strImg2 = GameGlobal::BuildImgPath(m_hGameWnd, "walk2");
|
|
|
|
+ ImgAssist::CropPicture(m_hGameWnd, rc, strImg.c_str());
|
|
|
|
+ Sleep(600);
|
|
|
|
+ ImgAssist::CropPicture(m_hGameWnd, rc2, strImg2.c_str());
|
|
|
|
+ // 判断2张图片是否一样;
|
|
|
|
+ if (ImgAssist::IsSimilarPicture(strImg.c_str(), strImg2.c_str()))
|
|
|
|
+ {
|
|
|
|
+ DebugLog(_T("停止走路"));
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::IsBattle()
|
|
|
|
+ {
|
|
|
|
+ CRect rc;
|
|
|
|
+ SRAND(100, 200);
|
|
|
|
+ if (ImgAssist::IsMatchIcon(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\活动\\镜妖\\非战斗中.bmp"), { 630, 25, 805, 45 }, rc)) {
|
|
|
|
+ DebugLog(_T("Battle:非战斗中"));
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ DebugLog(_T("Battle:战斗中"));
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ CRect CAction::FindMatchIcon(LPCTSTR lpszTemplateImage)
|
|
|
|
+ {
|
|
|
|
+ CRect rc;
|
|
|
|
+ TCHAR szTemplateImage[MAX_PATH] = { 0 };
|
|
|
|
+ // 先截图;
|
|
|
|
+ DebugLog(_T("FindMatchIcon=%s"), lpszTemplateImage);
|
|
|
|
+ ImgAssist::CaptureGameWnd(m_hGameWnd); SRAND(200, 500);
|
|
|
|
+ _stprintf_s(szTemplateImage, _T("%s%s"), GameGlobal::g_strAppdir.c_str(), lpszTemplateImage);
|
|
|
|
+ if (ImgAssist::GetImgMatchtemplate(GameGlobal::BuildImgPath(m_hGameWnd, _T("Game")), szTemplateImage, rc)) {
|
|
|
|
+ // 找到匹配的模块;
|
|
|
|
+ DebugLog(_T("====> 找到匹配目标:%s"), lpszTemplateImage);
|
|
|
|
+ return rc;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ rc.SetRectEmpty();
|
|
|
|
+ DebugLog(_T("<==== 没找到匹配目标:%s"), lpszTemplateImage);
|
|
|
|
+ return rc;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::IsOnMap(LPCTSTR lpszTemplateImage)
|
|
|
|
+ {
|
|
|
|
+ CRect rc = FindMatchIcon(lpszTemplateImage);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::WorldMapPositioning(POINT ptMap)
|
|
|
|
+ {
|
|
|
|
+ CRect rc;
|
|
|
|
+ //// 打开世界地图;
|
|
|
|
+ SendKey(VK_TAB); SRAND(300, 500);
|
|
|
|
+ // 判断是否打开了地图;
|
|
|
|
+ if (!ImgAssist::GetImgMatchtemplate(m_hGameWnd, GAssist::g_strAppdir + _T("img\\世界地图.bmp"), rc))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ //// 单击寻路窗口;
|
|
|
|
+ MouseClick(ptMap); SRAND(300, 600);
|
|
|
|
+ //// 退出世界地址;
|
|
|
|
+ GameAssist::SendKey(VK_TAB); SRAND(200, 300);
|
|
|
|
+
|
|
|
|
+ IsWalkStop();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::IsWattingAttack(int nAttackNPCType)
|
|
|
|
+ {
|
|
|
|
+ CRect rc;
|
|
|
|
+ BOOL bIsAttack = FALSE;
|
|
|
|
+ switch (nAttackNPCType)
|
|
|
|
+ {
|
|
|
|
+ case 0:
|
|
|
|
+ { // 将鼠标移动到指定位置;
|
|
|
|
+ DebugLog(_T("IsWattingAttack:镜妖中……"));
|
|
|
|
+ POINT ptDest = { 20, 50 }; // 左上角;
|
|
|
|
+ MouseMove(ptDest);
|
|
|
|
+ if (ImgAssist::IsMatchIcon(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\我方攻击.bmp"), { 0, 50, 60, 115 }, rc)) {
|
|
|
|
+ DebugLog(_T("IsWattingAttack:我方攻击"));
|
|
|
|
+ bIsAttack = TRUE;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ case 1:
|
|
|
|
+ {
|
|
|
|
+ // 将鼠标移动到指定位置;
|
|
|
|
+ DebugLog(_T("IsWattingAttack:职业挑战中……"));// 要求角色:自定全黑头像;
|
|
|
|
+ //POINT ptDest = { 625, 28 }; // 左上角;
|
|
|
|
+ //GAssist::MouseMove(hWnd, ptDest);
|
|
|
|
+ if (!ImgAssist::IsMatchIcon(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\战斗中.bmp"), { 600, 25, 655, 80 }, rc)) {
|
|
|
|
+ DebugLog(_T("IsWattingAttack:我方攻击"));
|
|
|
|
+ bIsAttack = TRUE;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ default:
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return bIsAttack;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::ClickDlgSetup(LPCSTR lpszTemplateImage)
|
|
|
|
+ {
|
|
|
|
+ CRect rc = FindMatchIcon(lpszTemplateImage);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ // 单击目标;
|
|
|
|
+ MouseClick(CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3));
|
|
|
|
+ // 单击后,系统切图可能要的时间会比较长;
|
|
|
|
+ SRAND(350, 600);
|
|
|
|
+ // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
|
|
|
|
+ MouseMove(CPoint(rc.top - RAND(5, 12), rc.left - RAND(5, 10))); // 移动到左上角;
|
|
|
|
+ SRAND(300, 500);
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::FindNPCByWorldMap(LPCTSTR lpszNPCName)
|
|
|
|
+ {
|
|
|
|
+ CRect rc;
|
|
|
|
+ //// 打开世界地图;
|
|
|
|
+ SendKey(VK_TAB); SRAND(500, 600);
|
|
|
|
+ if (!ImgAssist::GetImgMatchtemplate(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\寻路窗口.bmp"), rc))
|
|
|
|
+ return false;
|
|
|
|
+
|
|
|
|
+ //// 单击寻路窗口;
|
|
|
|
+ MouseClick( CPoint((rc.right + rc.left) / 2 + rand() % 2, (rc.top + rc.bottom) / 2 + rand() % 2)); SRAND(500, 800);
|
|
|
|
+ //// 设置剪切板:职业大挑战;
|
|
|
|
+ GameAssist::SetClipboardString(lpszNPCName); SRAND(200, 500);
|
|
|
|
+ //// Ctrl+V
|
|
|
|
+ SendKey(0x56, TRUE); SRAND(300, 500);
|
|
|
|
+ // 先移动到目标后,才能实现单击;
|
|
|
|
+ MouseMove(CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); SRAND(200, 300);
|
|
|
|
+ //// 寻路窗口往下50就是目标;
|
|
|
|
+ MouseDbClick(CPoint((rc.right + rc.left) / 2 + 5 + rand() % 2, (rc.top + rc.bottom) / 2 + 60 + rand() % 2)); SRAND(200, 300);
|
|
|
|
+ //// 退出世界地址;
|
|
|
|
+ SendKey(VK_TAB); SRAND(200, 300);
|
|
|
|
+
|
|
|
|
+ // 直到停止走动为止;
|
|
|
|
+ IsWalkStop();
|
|
|
|
+
|
|
|
|
+ // 遍历3次;
|
|
|
|
+ bool bFind = false;
|
|
|
|
+ for (int i = 0; i < 3; i++)
|
|
|
|
+ {
|
|
|
|
+ Sleep(600 - i * 150);
|
|
|
|
+ rc = FindMatchIcon(_T("img\\对话框关闭按钮.bmp"));
|
|
|
|
+ if (!rc.IsRectEmpty() && !rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ bFind = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return bFind;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::FindNPCByIcon(POINT ptMap, LPCTSTR lpszNPCName)
|
|
|
|
+ {
|
|
|
|
+ TCHAR szNPC[MAX_PATH] = { 0 };
|
|
|
|
+ _stprintf_s(szNPC, _T("img\\npc\\%s.bmp"), lpszNPCName);
|
|
|
|
+ CRect rc = FindMatchIcon(szNPC);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ WorldMapPositioning(ptMap);
|
|
|
|
+ Sleep(600); // 有时走到目标点,NPC还未刷新出来;
|
|
|
|
+ rc = FindMatchIcon(szNPC);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ // 可能还是未刷新出来,再次等待;
|
|
|
|
+ Sleep(300);
|
|
|
|
+ rc = FindMatchIcon(szNPC);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 找到目标,单击;
|
|
|
|
+ MouseMove(CPoint(rc.left, rc.top));
|
|
|
|
+ // 单击:我要挑战他们;
|
|
|
|
+ MouseClick({ (rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2 });
|
|
|
|
+ SRAND(900, 1300);// 等对话框出现;
|
|
|
|
+ // 移动鼠标:不要停留在人物身上;
|
|
|
|
+ MouseMove({ rc.left - rand() % 10, rc.top - rand() % 10 });
|
|
|
|
+
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bool CAction::FindNPCByIconAndPos(LPCTSTR lpszNPCName, POINT ptMap, POINT ptNpc)
|
|
|
|
+ {
|
|
|
|
+ TCHAR szNPC[MAX_PATH] = { 0 };
|
|
|
|
+ _stprintf_s(szNPC, _T("img\\npc\\%s.bmp"), lpszNPCName);
|
|
|
|
+ CRect rc = FindMatchIcon(szNPC);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ WorldMapPositioning(ptMap);
|
|
|
|
+ Sleep(600); // 有时走到目标点,NPC还未刷新出来;
|
|
|
|
+ rc = FindMatchIcon(szNPC);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ // 可能还是未刷新出来,再次等待;
|
|
|
|
+ Sleep(300);
|
|
|
|
+ rc = FindMatchIcon(szNPC);
|
|
|
|
+ if (rc.IsRectEmpty() || rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 找到目标,单击;
|
|
|
|
+ MouseMove(CPoint(rc.left, rc.top));
|
|
|
|
+ // 单击:我要挑战他们;
|
|
|
|
+ MouseClick(ptNpc);
|
|
|
|
+
|
|
|
|
+ // 遍历3次;
|
|
|
|
+ bool bFind = false;
|
|
|
|
+ for (int i = 0; i < 3; i++)
|
|
|
|
+ {
|
|
|
|
+ Sleep(800 - i * 150);
|
|
|
|
+ CRect rc = FindMatchIcon("img\\对话框关闭按钮.bmp");
|
|
|
|
+ if (!rc.IsRectEmpty() && !rc.IsRectNull())
|
|
|
|
+ {
|
|
|
|
+ bFind = true;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 移动鼠标:不要停留在人物身上;
|
|
|
|
+ MouseMove({ ptNpc.x - rand() % 10, ptNpc.y - rand() % 10 });
|
|
|
|
+
|
|
|
|
+ return bFind;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ void CAction::BattleJY(BOOL bHasSummoner, int nZJType, BOOL bAggressiveSkill)
|
|
|
|
+ {
|
|
|
|
+ BOOL bFirstAttack = TRUE;
|
|
|
|
+ while (IsBattle()) { // 是否在战斗中;
|
|
|
|
+ // 是否我方攻击;
|
|
|
|
+ while (IsWattingAttack(0)) { // Bug:如果被镜妖打死了,无法中断;
|
|
|
|
+ DebugLog(_T("BattleJY:我方攻击……"));
|
|
|
|
+ if (bFirstAttack)
|
|
|
|
+ {
|
|
|
|
+ SRAND(250, 300);
|
|
|
|
+ DebugLog(_T("BattleJY:第一次攻击……"));
|
|
|
|
+ // 根据角色选择技能;
|
|
|
|
+ SendKey(VK_F1);
|
|
|
|
+ SRAND(300, 350);
|
|
|
|
+ if (bAggressiveSkill) // 打镜妖喽罗;
|
|
|
|
+ {
|
|
|
|
+ MouseClick(CPoint(290 - 3, 140 - 20));
|
|
|
|
+ //GAssist::MouseMove(hWnd, CPoint(220 - 5, 180 - 10));// 打主镜妖;
|
|
|
|
+ SRAND(350, 500);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (bHasSummoner) {
|
|
|
|
+ CRect rc;
|
|
|
|
+ // 召唤兽技能;
|
|
|
|
+ DebugLog(_T("BattleJY:召唤兽技能选择"));
|
|
|
|
+
|
|
|
|
+ // 选择重击;
|
|
|
|
+ if (nZJType) {
|
|
|
|
+ SRAND(150, 350);
|
|
|
|
+ SendKey(VK_S, FALSE, TRUE);
|
|
|
|
+ DebugLog(_T("BattleJY:召唤兽技能选择:%d"), nZJType);
|
|
|
|
+ if (ImgAssist::GetImgMatchtemplate(m_hGameWnd, nZJType == 1 ? GameGlobal::g_strAppdir + _T("img\\活动\\镜妖\\重击.bmp") : GameGlobal::g_strAppdir + _T("img\\活动\\镜妖\\重击2.bmp"), rc))
|
|
|
|
+ {
|
|
|
|
+ SRAND(150, 300);
|
|
|
|
+ MouseClick(CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SRAND(300, 500);
|
|
|
|
+ MouseMove(CPoint(290 - 3, 140 - 15));
|
|
|
|
+ MouseClick(CPoint(290 - 3, 140 - 20));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ bFirstAttack = FALSE;
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ DebugLog(_T("BattleJY:不是第一次攻击……"));
|
|
|
|
+ SendKey(VK_A, FALSE, TRUE);
|
|
|
|
+ SRAND(80, 100);
|
|
|
|
+ if (bFirstAttack) {
|
|
|
|
+ SendKey(VK_A, FALSE, TRUE);
|
|
|
|
+ SRAND(80, 120);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ SRAND(500, 850);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 非战斗中,是否在贫民房中;
|
|
|
|
+ if (!IsOnMap(_T("img\\地图\\贫民房.bmp"))) {
|
|
|
|
+ // 找小米;
|
|
|
|
+ CRect rc;
|
|
|
|
+ if (!FindNPCByWorldMap("臭美的小米"))
|
|
|
|
+ return;
|
|
|
|
+
|
|
|
|
+ // 选择进入;
|
|
|
|
+ BOOL bMatch = FALSE;
|
|
|
|
+ int trySize = 15;
|
|
|
|
+ // 我要挑战他们;
|
|
|
|
+ while (!(bMatch = ClickDlgSetup(_T("img\\活动\\镜妖\\1-我帮您抓.bmp")))) {
|
|
|
|
+ SRAND(800, 1200);
|
|
|
|
+ if (!trySize--) break;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (bMatch) {
|
|
|
|
+ MouseMove(CPoint(rc.left, rc.top));
|
|
|
|
+ // 单击:我要挑战他们;
|
|
|
|
+ MouseClick(CPoint((rc.right + rc.left) / 2, (rc.top + rc.bottom) / 2));
|
|
|
|
+ SRAND(1000, 1500);// 等出图;
|
|
|
|
+
|
|
|
|
+ // 移动一下;
|
|
|
|
+ MouseMove(CPoint(rc.left, rc.top));
|
|
|
|
+ ::SetCursorPos(rc.left + rand() % 6, rc.top + rand() % 8);
|
|
|
|
+
|
|
|
|
+ // 是否第一次进入地图;
|
|
|
|
+ if (ClickDlgSetup(_T("img\\活动\\镜妖\\2-我这就去.bmp")))
|
|
|
|
+ {
|
|
|
|
+ SRAND(600, 1200);
|
|
|
|
+ if (ClickDlgSetup(_T("img\\活动\\镜妖\\3-战意镜妖.bmp")))
|
|
|
|
+ {
|
|
|
|
+ SRAND(600, 1800);
|
|
|
|
+ if ((bMatch = ClickDlgSetup(_T("img\\活动\\镜妖\\4-我就选择它.bmp"))))
|
|
|
|
+ {
|
|
|
|
+ SRAND(800, 1800);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ // 找到镜妖;
|
|
|
|
+ CRect rc;
|
|
|
|
+ POINT spt[4] = { { 250, 335 }, { 310,360}, { 385, 315}, { 280,295 } };
|
|
|
|
+ for (int i = 0; !ImgAssist::GetImgMatchtemplate(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\活动\\镜妖\\镜妖1.bmp"), rc); i++)
|
|
|
|
+ {
|
|
|
|
+ // 打开世界地图;
|
|
|
|
+ SendKey(VK_TAB); SRAND(200, 300);
|
|
|
|
+ // 选择坐标点;
|
|
|
|
+ MouseClick(spt[i % 4]);
|
|
|
|
+ // 退出世界地图;
|
|
|
|
+ SendKey(VK_TAB); SRAND(500, 900);
|
|
|
|
+ // 等待跑完成;
|
|
|
|
+ //SRAND(600, 800);
|
|
|
|
+ IsWalkStop();
|
|
|
|
+
|
|
|
|
+ if (i > 10) {
|
|
|
|
+ DebugLog(_T("未找到镜妖+10"));
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ // 找到镜妖;
|
|
|
|
+ MouseMove(CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
|
|
|
|
+ DebugLog(_T("移动鼠标"));
|
|
|
|
+ MouseClick(CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3));
|
|
|
|
+ SRAND(390, 600);
|
|
|
|
+ // 单击目标后,要往移走鼠标,防止下面匹配的时候被鼠标挡住;
|
|
|
|
+ MouseMove(CPoint(rc.right + RAND(10, 20), rc.bottom + RAND(10, 20)));
|
|
|
|
+ SRAND(300, 500);
|
|
|
|
+ DebugLog(_T("找到目标并单击成功:%s"));
|
|
|
|
+
|
|
|
|
+ // 我来抓你;
|
|
|
|
+ if (ImgAssist::GetImgMatchtemplate(m_hGameWnd, GameGlobal::g_strAppdir + _T("img\\活动\\镜妖\\我来抓您的.bmp"), rc)) {
|
|
|
|
+ // 找到匹配的模块;
|
|
|
|
+ SRAND(200, 300);
|
|
|
|
+ //GAssist::MouseMove(hWnd, CPoint(rc.left + rand() % 10, rc.top + rand() % 10));
|
|
|
|
+ DebugLog(_T("我来抓你:移动鼠标"));
|
|
|
|
+ MouseClick(CPoint((rc.right + rc.left) / 2 + rand() % 3, (rc.top + rc.bottom) / 2 + rand() % 3));
|
|
|
|
+ SRAND(1000, 1500);
|
|
|
|
+ DebugLog(_T("我来抓你:找到目标并单击成功:%s"));
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+};
|