This commit is contained in:
aozhiwei 2023-06-29 16:40:30 +08:00
parent 95a25be38b
commit d62d418f50
3 changed files with 17 additions and 3 deletions

View File

@ -22,7 +22,7 @@ public:
behaviac::EBTStatus DoPursuit();
private:
glm::vec3& AdjustShotDir(glm::vec3& shot_dir);
virtual glm::vec3& AdjustShotDir(glm::vec3& shot_dir) override;
private:
Android* owner_ = nullptr;

View File

@ -446,7 +446,20 @@ bool BaseAgent::ShotCanReach(const glm::vec3& target_pos)
behaviac::EBTStatus BaseAgent::CoShot()
{
return behaviac::BT_FAILURE;
if (!current_target_.Get()) {
return behaviac::BT_FAILURE;
}
if (GlmHelper::IsEqual2D(GetOwner()->GetPos().ToGlmVec3(),
current_target_.Get()->GetPos().ToGlmVec3())) {
return behaviac::BT_FAILURE;
}
bool shot_ok = false;
glm::vec3 dir = GetOwner()->GetPos().CalcDir(current_target_.Get()->GetPos());
GlmHelper::Normalize(dir);
GetOwner()->SetAttackDir(dir);
GetOwner()->shot_hold = true;
GetOwner()->Shot(AdjustShotDir(dir), shot_ok, 0, 0);
return behaviac::BT_SUCCESS;
}
bool BaseAgent::IsNearGas(float distance)
@ -461,7 +474,7 @@ behaviac::EBTStatus BaseAgent::CoRunGas()
float BaseAgent::GetSafeAreaRadius()
{
return 500;
return GetOwner()->room->GetGasData().gas_progress;
}
bool BaseAgent::IsDead()

View File

@ -81,6 +81,7 @@ public:
public:
void SetOwner(Creature* owner) { owner_ = owner; };
Creature* GetOwner() { return owner_; };
virtual glm::vec3& AdjustShotDir(glm::vec3& shot_dir) { return shot_dir; };
protected:
behaviac::EBTStatus DoRunningCb();