客户端之获取离我最近的目标函数 Delphi
单机社区 6月前

//获取离我最近的目标
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;
}
他们也来看过。
  • 古古怪怪
  • 老邢说吧
  • xzls2003
  • S304185
  • 只是玩玩
  • qaswed
  • 李有才
  • happy333
最新回复 (0)
  • happy333
    2
返回