This commit is contained in:
aozhiwei 2023-10-14 14:20:20 +08:00
parent 3adb31ee09
commit f66025ad4e

View File

@ -11,6 +11,7 @@
#include "weapon.h"
#include "mapinstance.h"
#include "collision.h"
#include "human.h"
#include "mt/Hero.h"
#include "mt/Equip.h"
@ -270,7 +271,32 @@ bool HeroAgent::MasterInRange(float range)
behaviac::EBTStatus HeroAgent::SearchEnemy(float range)
{
abort();
Creature* myself = owner_;
Human* target = nullptr;
float last_distance = range + 1;
owner_->room->TraverseHumanList
(
[myself, &last_distance, &target, range] (Human* hum)
{
if (!hum->dead &&
!a8::HasBitFlag(hum->status, CS_Disable) &&
!hum->HasBuffEffect(kBET_Hide) &&
!hum->HasBuffEffect(kBET_Invincible) &&
hum->team_id != myself->team_id) {
if (a8::HasBitFlag(myself->status, CS_DisableAttackAndroid) &&
hum->IsAndroid()) {
} else {
float distance = hum->GetPos().Distance2D2(myself->GetPos());
if (distance <= range) {
if (distance < last_distance) {
target = hum;
last_distance = distance;
}
}
}
}
return true;
});
}
behaviac::EBTStatus HeroAgent::CoIdle(int min_val, int max_val)