diff --git a/server/gameserver/hero_agent.cc b/server/gameserver/hero_agent.cc index 3ee249a4..56893eba 100644 --- a/server/gameserver/hero_agent.cc +++ b/server/gameserver/hero_agent.cc @@ -280,16 +280,20 @@ behaviac::EBTStatus HeroAgent::DoAttack() target.Get()->GetPos().ToGlmVec3())) { return behaviac::BT_FAILURE; } - bool shot_ok = false; - glm::vec3 shot_dir = GetOwner()->GetPos().CalcDir(target.Get()->GetPos());; - GlmHelper::Normalize(shot_dir); - GetOwner()->SetAttackDir(shot_dir); - if (bullet_trace_mode_) { - GetOwner()->Shot(shot_dir, shot_ok, 0, target.Get()->GetUniId()); - } else { - GetOwner()->Shot(shot_dir, shot_ok, 0, target.Get()->GetUniId()); + if (GetOwner()->dead) { + return behaviac::BT_FAILURE; + } + if (GetOwner()->CanShot(true)) { + bool shot_ok = false; + glm::vec3 shot_dir = GetOwner()->GetPos().CalcDir(target.Get()->GetPos());; + GlmHelper::Normalize(shot_dir); + GetOwner()->SetAttackDir(shot_dir); + if (bullet_trace_mode_) { + GetOwner()->Shot(shot_dir, shot_ok, 0, target.Get()->GetUniId()); + } else { + GetOwner()->Shot(shot_dir, shot_ok, 0, target.Get()->GetUniId()); + } } - return behaviac::BT_RUNNING; } },