Browse Source

【模块名称】

【问题原因】
    新增函数:查看HP和SP,未完成 。
【修改描述】

【测试结果】
sat23 3 years ago
parent
commit
1de6267bd9

+ 8 - 0
GameAssist/GameAssist/Assist.cpp

@@ -943,4 +943,12 @@ namespace ImgAssist
 		return (lv_nMaxVal >= lowestMatchValue ? TRUE : FALSE);
 	}
 
+	int GetColorOccupiedLength(std::string strImg, COLORREF color)
+	{
+		cv::Mat src = cv::imread(strImg.c_str());
+		// »ñȡͼƬµÄ¾ØÐδóС;
+		int width = src.cols;
+		int height = src.rows;
+	}
+
 };

+ 2 - 0
GameAssist/GameAssist/Assist.h

@@ -42,6 +42,8 @@ namespace ImgAssist {
 	BOOL IsMatchIcon(HWND hWnd, std::string strTempImg, RECT srcRect, RECT& matchRect, double lowestMatchValue = 0.900);
 	BOOL CropPicture(HWND hWnd, CRect rc, const char* szSaveName); // 剪裁图片;
 	BOOL IsSimilarPicture(const char* szp1, const char* szp2, double lowestMatchValue = 0.99);
+	// 获取指定颜色占用矩形长度比例;
+	int GetColorOccupiedLength(std::string strImg, COLORREF color);
 };
 
 // 所有坐标,都是基于游戏窗口的相对坐标值;

+ 44 - 10
GameAssist/GameAssist/CAction.cpp

@@ -238,7 +238,7 @@ SRAND(80,120);
 		return false;
 	}
 
-	bool CAction::IsBattle()
+	bool CAction::IsFighting()
 	{
 		CRect rc;
 		SRAND(100, 200);
@@ -480,11 +480,45 @@ SRAND(80,120);
 		return false;
 	}
 
-	void CAction::BattleJY(BOOL bHasSummoner, int nZJType, BOOL bAggressiveSkill)
+	bool CAction::IsSPBelowSafeValue(BOOL IsRole, int nSafeValue /*= 30*/)
+	{
+		RECT rect = { 0,0,0,0 };
+		if (IsFighting())
+		{
+			rect = IsRole ? RECT{ 0, 0, 0, 0 } : RECT{ 0, 0, 0, 0 };
+		}
+		else
+		{
+			rect = IsRole ? RECT{ 0, 0, 0, 0 } : RECT{ 0, 0, 0, 0 };
+		}
+
+		// 截图;
+		TCHAR szSPImg[MAX_PATH] = {0};
+		_stprintf_s(szSPImg, _T("%s%p_SPValue.bmp"), GameGlobal::g_szTempDir, m_hGameWnd);
+		ImgAssist::CropPicture(m_hGameWnd, rect, szSPImg);
+
+		return false;
+	}
+
+	bool CAction::IsHPBelowSafeValue(BOOL IsRole, int nSafeValue /*= 30*/)
+	{
+		if (IsFighting())
+		{
+
+		}
+		else
+		{
+
+		}
+
+		return false;
+	}
+
+	void CAction::FightingJY(BOOL bHasSummoner, int nZJType, BOOL bAggressiveSkill)
 	{
 		BOOL bFirstAttack = TRUE;
 		// 1.是否在战斗中;
-		while (IsBattle()) { 
+		while (IsFighting()) {
 			// 2.是否我方攻击;
 			while (IsWattingAttack(0)) { // Bug:如果被镜妖打死了,无法中断;
 				DebugLog(_T("BattleJY:我方攻击……"));
@@ -630,7 +664,7 @@ SRAND(80,120);
 		}
 	}
 
-	void CAction::BattleYS(LPCTSTR lpszSkillName)
+	void CAction::FightingYS(LPCTSTR lpszSkillName)
 	{
 		CRect rc;
 		BOOL bBattle = FALSE;
@@ -765,7 +799,7 @@ SRAND(80,120);
 			// 将鼠标移动到指定位置;
 			POINT ptDest = { 625, 28 }; // 左上角;
 			MouseMove(ptDest);
-			while (IsBattle())
+			while (IsFighting())
 			{
 				// 判断是否我方攻击;
 				if (IsWattingAttack(1))
@@ -787,7 +821,7 @@ SRAND(80,120);
 		MouseRClick();
 	}
 
-	void CAction::BattleOthers(LPCTSTR lpszName, LPCTSTR lpszSkillName)
+	void CAction::FightingOthers(LPCTSTR lpszName, LPCTSTR lpszSkillName)
 	{
 		CRect rc;
 		BOOL bBattle = FALSE;
@@ -818,7 +852,7 @@ SRAND(80,120);
 			// 将鼠标移动到指定位置;
 			POINT ptDest = { 625, 28 }; // 左上角;
 			MouseMove(ptDest);
-			while (IsBattle())
+			while (IsFighting())
 			{
 				// 判断是否我方攻击;
 				if (IsWattingAttack(1))
@@ -997,7 +1031,7 @@ SRAND(80,120);
 						// 将鼠标移动到指定位置;
 						POINT ptDest = { 625, 28 }; // 左上角;
 						MouseMove(ptDest);
-						while (IsBattle())
+						while (IsFighting())
 						{
 							// 判断是否我方攻击;
 							if (IsWattingAttack(1))
@@ -1044,7 +1078,7 @@ SRAND(80,120);
 						// 将鼠标移动到指定位置;
 						POINT ptDest = { 625, 28 }; // 左上角;
 						MouseMove(ptDest);
-						while (IsBattle())
+						while (IsFighting())
 						{
 							// 判断是否我方攻击;
 							if (IsWattingAttack(1))
@@ -1114,7 +1148,7 @@ SRAND(80,120);
 		do 
 		{
 			DebugLog(_T("start.打镜妖 %d----------------------------"), i);
-			pThis->BattleJY(pThis->m_bHasSummoner, pThis->m_nSummonerSkillType, pThis->m_bTargetOfRoleSkill);
+			pThis->FightingJY(pThis->m_bHasSummoner, pThis->m_nSummonerSkillType, pThis->m_bTargetOfRoleSkill);
 			DebugLog(_T("end.打镜妖 %d----------------------------\n"), i++);
 		} while (WaitForSingleObject(pThis->m_hBattleJYEvent, 200) == WAIT_TIMEOUT);
 

+ 6 - 6
GameAssist/GameAssist/CAction.h

@@ -72,7 +72,7 @@ public:
 		// 是否停止走路;
 		bool IsWalkStop();
 		// 是否在战斗中;
-		bool IsBattle();
+		bool IsFighting();
 		// 在游戏窗口中查找匹配的图标;
 		CRect FindMatchIcon(LPCTSTR lpszTemplateImage);
 		// 是否在指定的地图上;
@@ -95,20 +95,20 @@ public:
 		// 查找NPC:查找map中的NPC;
 		bool FindNPCByMap(LPCTSTR lpszNPCName);
 		// 是否低于SP安全值
-		bool IsSPBelowSafeValue();
+		bool IsSPBelowSafeValue(BOOL IsRole, int nSafeValue = 30);
 		// 是否低于HP安全值
-		bool IsHPBelowSafeValue();
+		bool IsHPBelowSafeValue(BOOL IsRole, int nSafeValue = 30);
 
 	public:
 		// 与镜妖战斗;
 		// bHasSummoner是否有召唤兽;
 		// nZJType:重击类型;
 		// bAggressiveSkill:技能是作用在敌人身上还是自己身上; true:敌人, false:自己
-		void BattleJY(BOOL bHasSummoner, int nZJType, BOOL bAggressiveSkill);
+		void FightingJY(BOOL bHasSummoner, int nZJType, BOOL bAggressiveSkill);
 		// 与职业医师战斗;
-		void BattleYS(LPCTSTR lpszSkillName);
+		void FightingYS(LPCTSTR lpszSkillName);
 		// 与职业医师以外的战斗;
-		void BattleOthers(LPCTSTR lpszName, LPCTSTR lpszSkillName);
+		void FightingOthers(LPCTSTR lpszName, LPCTSTR lpszSkillName);
 
 		// 开宝箱;
 		void OpenChest(int nTimes=10);

+ 4 - 4
GameAssist/GameAssist/GameAssistDlg.cpp

@@ -476,10 +476,10 @@ void CGameAssistDlg::OnBnClickedButton6() // 职业
 			if (pAction->IsOnMap(_T("img\\gdd\\name.bmp")))
 			{
 				char szName[10][32] = { "术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
-				pAction->BattleYS("缚神诀");
+				pAction->FightingYS("缚神诀");
 				for (int i = 0; i < 10; i++)
 				{
-					pAction->BattleOthers(szName[i], "缚神诀");
+					pAction->FightingOthers(szName[i], "缚神诀");
 				}
 			}
 		}
@@ -501,7 +501,7 @@ void CGameAssistDlg::OnBnClickedButton8() // 职业
 		char szName[10][32] = { "术士独侠","道士独侠","武师独侠","浪子独侠","剑客独侠","弓手独侠","禁卫独侠","墨者独侠","巫煞独侠","魂武独侠" };
 		for (int i = 0; i < 10; i++)
 		{
-			pAction->BattleOthers(szName[i], "缚神诀");
+			pAction->FightingOthers(szName[i], "缚神诀");
 		}
 	}
 }
@@ -590,7 +590,7 @@ void CGameAssistDlg::OnBnClickedButton12()
 		while (true)
 		{
 			BOOL bFirst = TRUE;
-			while (pAction->IsBattle())
+			while (pAction->IsFighting())
 			{
 				if (pAction->IsWattingAttack(-1))
 				{