1
This commit is contained in:
parent
4687b5e8c0
commit
4af17b050b
@ -121,7 +121,6 @@ behaviac::EBTStatus AndroidAgent::DoAttack()
|
|||||||
}
|
}
|
||||||
|
|
||||||
a8::Vec2 dir = enemy->GetPos() - GetOwner()->GetPos();
|
a8::Vec2 dir = enemy->GetPos() - GetOwner()->GetPos();
|
||||||
dir.Rotate((10 + rand() % 360)/ 180.0f);
|
|
||||||
dir.Normalize();
|
dir.Normalize();
|
||||||
GetOwner()->SetMoveDir(dir);
|
GetOwner()->SetMoveDir(dir);
|
||||||
GetOwner()->SetAttackDir(dir);
|
GetOwner()->SetAttackDir(dir);
|
||||||
@ -160,25 +159,28 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
|
|||||||
}
|
}
|
||||||
|
|
||||||
a8::Vec2 dir = enemy->GetPos() - GetOwner()->GetPos();
|
a8::Vec2 dir = enemy->GetPos() - GetOwner()->GetPos();
|
||||||
dir.Rotate((10 + rand() % 360)/ 180.0f);
|
|
||||||
dir.Normalize();
|
dir.Normalize();
|
||||||
GetOwner()->SetMoveDir(dir);
|
GetOwner()->SetMoveDir(dir);
|
||||||
GetOwner()->SetAttackDir(dir);
|
GetOwner()->SetAttackDir(dir);
|
||||||
|
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
a8::Vec2 shot_dir = dir;
|
a8::Vec2 shot_dir = dir;
|
||||||
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
||||||
|
|
||||||
|
CreatureWeakPtr target = enemy->GetWeakPtrRef();
|
||||||
long long last_frameno = GetOwner()->room->GetFrameNo();
|
long long last_frameno = GetOwner()->room->GetFrameNo();
|
||||||
status_runing_cb_ =
|
status_runing_cb_ =
|
||||||
[this, last_frameno] ()
|
[this, last_frameno, target] () mutable
|
||||||
{
|
{
|
||||||
if (GetOwner()->room->GetFrameNo() - last_frameno > SERVER_FRAME_RATE * 3) {
|
if (GetOwner()->room->GetFrameNo() - last_frameno > SERVER_FRAME_RATE * 10 &&
|
||||||
|
target.Get()) {
|
||||||
status_ = behaviac::BT_SUCCESS;
|
status_ = behaviac::BT_SUCCESS;
|
||||||
return behaviac::BT_SUCCESS;
|
return behaviac::BT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
bool shot_ok = false;
|
a8::Vec2 dir = target.Get()->GetPos() - GetOwner()->GetPos();
|
||||||
a8::Vec2 shot_dir = GetOwner()->GetAttackDir();
|
dir.Normalize();
|
||||||
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
GetOwner()->SetMoveDir(dir);
|
||||||
|
GetOwner()->SetAttackDir(dir);
|
||||||
|
|
||||||
return behaviac::BT_RUNNING;
|
return behaviac::BT_RUNNING;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user