This commit is contained in:
aozhiwei 2021-03-30 14:35:18 +08:00
parent 418d98deea
commit e42c46ffd6
2 changed files with 6 additions and 15 deletions

View File

@ -482,7 +482,7 @@ void AndroidNewAI::UpdateThinking()
ChangeToStateNewAI(ASE_RandomWalk); ChangeToStateNewAI(ASE_RandomWalk);
} }
} else { } else {
Human* target = GetTarget(); Creature* target = GetTarget();
if (target) { if (target) {
node_.target.Attach(target); node_.target.Attach(target);
ChangeToStateNewAI(ASE_Attack); ChangeToStateNewAI(ASE_Attack);
@ -682,7 +682,7 @@ void AndroidNewAI::ChangeToStateNewAI(AndroidStateEx_e to_state)
node_.exec_frame_num = 0; node_.exec_frame_num = 0;
} }
Human* AndroidNewAI::GetTarget() Creature* AndroidNewAI::GetTarget()
{ {
if (GetAiLevel() <= 1) { if (GetAiLevel() <= 1) {
return nullptr; return nullptr;
@ -692,20 +692,11 @@ Human* AndroidNewAI::GetTarget()
return nullptr; return nullptr;
} }
Human* target = nullptr; Creature* target = nullptr;
myself->TouchAllLayerHumanList myself->TouchProperTargets
( (
[myself, &target] (Human* hum, bool& stop) [myself, &target] (Creature* hum, bool& stop)
{ {
if (hum->dead) {
return;
}
if (a8::HasBitFlag(hum->status, HS_Disable)) {
return;
}
if (myself->team_id == hum->team_id) {
return;
}
if (target) { if (target) {
if (myself->GetPos().ManhattanDistance(target->GetPos()) > if (myself->GetPos().ManhattanDistance(target->GetPos()) >
myself->GetPos().ManhattanDistance(hum->GetPos())) { myself->GetPos().ManhattanDistance(hum->GetPos())) {

View File

@ -82,7 +82,7 @@ private:
void ChangeToStateNewAI(AndroidStateEx_e to_state); void ChangeToStateNewAI(AndroidStateEx_e to_state);
void DoShotNewAI(); void DoShotNewAI();
Human* GetTarget(); Creature* GetTarget();
float GetAttackRange(); float GetAttackRange();
int GetAttackTimes(); int GetAttackTimes();