This commit is contained in:
aozhiwei 2022-12-07 14:55:45 +08:00
parent 2e4749584e
commit 31c819ee66
7 changed files with 32 additions and 23 deletions

View File

@ -5,6 +5,7 @@
#include "room.h"
#include "app.h"
#include "android_agent.h"
#include "movehelper.h"
#include "framework/cpp/btmgr.h"

View File

@ -3,6 +3,7 @@
#include "android_agent.h"
#include "android.h"
#include "room.h"
#include "movehelper.h"
AndroidAgent::AndroidAgent():BaseAgent()
{
@ -164,14 +165,18 @@ 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();
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);
@ -189,13 +194,13 @@ behaviac::EBTStatus AndroidAgent::DoPursuit()
} 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);
}
}
return behaviac::BT_RUNNING;
}
};

View File

@ -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;

View File

@ -15,6 +15,7 @@
#include "bullet.h"
#include "skillhelper.h"
#include "shot.h"
#include "movehelper.h"
#include "framework/cpp/utils.h"

View File

@ -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:

View File

@ -39,6 +39,7 @@
#include "shot.h"
#include "battledatacontext.h"
#include "mapinstance.h"
#include "movehelper.h"
const int kReviveTimeAdd = 12;
const int kSkinNum = 4;

View File

@ -24,6 +24,7 @@
#include "team.h"
#include "httpproxy.h"
#include "roommgr.h"
#include "movehelper.h"
const int kREVIVE_BUFF_ID = 1005;