1
This commit is contained in:
parent
4af17b050b
commit
2e4749584e
@ -158,19 +158,11 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
|
||||
return behaviac::BT_FAILURE;
|
||||
}
|
||||
|
||||
a8::Vec2 dir = enemy->GetPos() - GetOwner()->GetPos();
|
||||
dir.Normalize();
|
||||
GetOwner()->SetMoveDir(dir);
|
||||
GetOwner()->SetAttackDir(dir);
|
||||
|
||||
bool shot_ok = false;
|
||||
a8::Vec2 shot_dir = dir;
|
||||
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
||||
|
||||
CreatureWeakPtr target = enemy->GetWeakPtrRef();
|
||||
long long last_frameno = GetOwner()->room->GetFrameNo();
|
||||
long long last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
status_runing_cb_ =
|
||||
[this, last_frameno, target] () mutable
|
||||
[this, last_frameno, target, last_pursuit_frameno] () mutable
|
||||
{
|
||||
if (GetOwner()->room->GetFrameNo() - last_frameno > SERVER_FRAME_RATE * 10 &&
|
||||
target.Get()) {
|
||||
@ -179,8 +171,30 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
|
||||
} else {
|
||||
a8::Vec2 dir = target.Get()->GetPos() - GetOwner()->GetPos();
|
||||
dir.Normalize();
|
||||
GetOwner()->SetMoveDir(dir);
|
||||
GetOwner()->SetAttackDir(dir);
|
||||
bool is_shot = false;
|
||||
if (dir.Norm() > 500) {
|
||||
if (GetOwner()->GetMoveHelper()->GetPathSize() < 1) {
|
||||
GetOwner()->SetMoveDir(dir);
|
||||
GetOwner()->SetAttackDir(dir);
|
||||
GetOwner()->GetMoveHelper()->CalcTargetPos(200);
|
||||
last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
} else {
|
||||
if (GetOwner()->room->GetFrameNo() - last_pursuit_frameno > SERVER_FRAME_RATE * 1) {
|
||||
GetOwner()->SetMoveDir(dir);
|
||||
GetOwner()->SetAttackDir(dir);
|
||||
GetOwner()->GetMoveHelper()->CalcTargetPos(200);
|
||||
last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
}
|
||||
}
|
||||
} else {
|
||||
is_shot = true;
|
||||
}
|
||||
|
||||
if (is_shot) {
|
||||
bool shot_ok = false;
|
||||
a8::Vec2 shot_dir = dir;
|
||||
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
||||
}
|
||||
|
||||
return behaviac::BT_RUNNING;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user