1
This commit is contained in:
parent
2e4749584e
commit
31c819ee66
@ -5,6 +5,7 @@
|
||||
#include "room.h"
|
||||
#include "app.h"
|
||||
#include "android_agent.h"
|
||||
#include "movehelper.h"
|
||||
|
||||
#include "framework/cpp/btmgr.h"
|
||||
|
||||
|
@ -3,6 +3,7 @@
|
||||
#include "android_agent.h"
|
||||
#include "android.h"
|
||||
#include "room.h"
|
||||
#include "movehelper.h"
|
||||
|
||||
AndroidAgent::AndroidAgent():BaseAgent()
|
||||
{
|
||||
@ -164,38 +165,42 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
|
||||
status_runing_cb_ =
|
||||
[this, last_frameno, target, last_pursuit_frameno] () mutable
|
||||
{
|
||||
if (GetOwner()->room->GetFrameNo() - last_frameno > SERVER_FRAME_RATE * 10 &&
|
||||
target.Get()) {
|
||||
if (GetOwner()->room->GetFrameNo() - last_frameno > SERVER_FRAME_RATE * 10 ||
|
||||
!target.Get() || target.Get()->dead) {
|
||||
status_ = behaviac::BT_SUCCESS;
|
||||
return behaviac::BT_SUCCESS;
|
||||
} else {
|
||||
a8::Vec2 dir = target.Get()->GetPos() - GetOwner()->GetPos();
|
||||
dir.Normalize();
|
||||
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) {
|
||||
if (dir.Norm() <= 1.0f) {
|
||||
GetOwner()->GetMoveHelper()->CalcTargetPos(60);
|
||||
last_pursuit_frameno = GetOwner()->room->GetFrameNo();
|
||||
} else {
|
||||
bool is_shot = false;
|
||||
dir.Normalize();
|
||||
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()->SetAttackDir(dir);
|
||||
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
||||
}
|
||||
} 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;
|
||||
}
|
||||
};
|
||||
|
@ -23,7 +23,7 @@ bool BaseAgent::HasTarget(float range)
|
||||
{
|
||||
Human* enemy = GetOwner()->room->FindEnemy(GetOwner()->AsHuman());
|
||||
if (enemy) {
|
||||
float distance = (enemy->GetPos() - GetOwner()->GetPos()).Norm();
|
||||
float distance = enemy->GetPos().Distance(GetOwner()->GetPos());
|
||||
return distance <= range;
|
||||
}
|
||||
return false;
|
||||
|
@ -15,6 +15,7 @@
|
||||
#include "bullet.h"
|
||||
#include "skillhelper.h"
|
||||
#include "shot.h"
|
||||
#include "movehelper.h"
|
||||
|
||||
#include "framework/cpp/utils.h"
|
||||
|
||||
|
@ -6,7 +6,6 @@
|
||||
#include "ability.h"
|
||||
#include "weapon.h"
|
||||
#include "battledatacontext.h"
|
||||
#include "movehelper.h"
|
||||
|
||||
#include "cs_proto.pb.h"
|
||||
|
||||
@ -68,6 +67,7 @@ class Team;
|
||||
class Car;
|
||||
class Trigger;
|
||||
class DelayAddBuffHandle;
|
||||
class MoveHelper;
|
||||
class Creature : public MoveableEntity
|
||||
{
|
||||
public:
|
||||
|
@ -39,6 +39,7 @@
|
||||
#include "shot.h"
|
||||
#include "battledatacontext.h"
|
||||
#include "mapinstance.h"
|
||||
#include "movehelper.h"
|
||||
|
||||
const int kReviveTimeAdd = 12;
|
||||
const int kSkinNum = 4;
|
||||
|
@ -24,6 +24,7 @@
|
||||
#include "team.h"
|
||||
#include "httpproxy.h"
|
||||
#include "roommgr.h"
|
||||
#include "movehelper.h"
|
||||
|
||||
const int kREVIVE_BUFF_ID = 1005;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user