AD商业广告自由选择
AD商业广告自由选择

客户端之获取离我最近的目标函数

正文概述 开源人   2024-11-15 20:50:32  
//获取离我最近的目标
TActor* GameScene::GetRecentTarget(AttackTargetType type/* = attMon*/, bool noBOBO, bool noNPC, bool noStone)
{
	TActor* result = nullptr;
	TActor* cur = nullptr;
	int disMin = 99999999;
	int disX = 0;
	int disY = 0;
	//不找NPC 不找宝宝 不找卫士12 不找死亡目标 不找自己  //m_wAppearance71弓箭护卫
	for (int i = (int)m_ActorList.size() - 1; i >= 0; i--)
	{
		cur = m_ActorList[i];
		if (!isEnemy(cur, noBOBO, noNPC, noStone))
		{
			continue;
		}
		int btRace = cur->m_btRace;
		if (type == attMon)
		{
			if (btRace == RC_PLAYOBJECT || cur->m_nMaster != TInt64() || cur->IsNameWith("练功师"))
			{
				continue;
			}
		}
		if (type == attHum && btRace != RC_PLAYOBJECT)
		{
			continue;
		}
		disX = cur->m_nCurrX - g_MySelf->m_nCurrX;
		disY = cur->m_nCurrY - g_MySelf->m_nCurrY;
		if ((disX == 0) && (disY == 0))
		{
			continue;
		}
		int dis = GetDistance(cur->m_nCurrX, cur->m_nCurrY, g_MySelf->m_nCurrX, g_MySelf->m_nCurrY);
		if (dis < disMin)
		{
			//logIt("%d", dis);
			result = cur;
			disMin = dis;
		}
	}
	return result;
}
 


声明:本文系互联网搜索而收集整理,不以盈利性为目的,文字、图文资料源于互联网且共享于互联网。
如有侵权,请联系 yao4fvip#qq.com (#改@) 删除。