This commit is contained in:
aozhiwei 2023-06-01 16:54:16 +08:00
parent ac6c57a65c
commit 6dfb750f09

View File

@ -176,11 +176,35 @@ behaviac::EBTStatus BaseAgent::CoAttackTarget(int target_id)
is_shot = true;
}
if (is_shot) {
bool shot_ok = false;
glm::vec3 shot_dir = dir;
GetOwner()->SetAttackDir(dir);
GetOwner()->shot_hold = true;
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
bool use_skill_ok = false;
if (context->target.Get() &&
!context->target.Get()->dead) {
int skill_id = GetUseableSkill(context->target.Get());
if (skill_id >= 0) {
GetOwner()->shot_hold = false;
int wait_time = 0;
use_skill_ok = InternalUseSkill(skill_id, context->target, wait_time);
if (use_skill_ok) {
Sleep(wait_time);
}
}
}
#ifdef DEBUG
if (context->target.Get()->IsPlayer()) {
a8::XPrintf("DoAttack %d use_skill_ok:%d time:%d\n",
{GetOwner()->GetUniId(),
use_skill_ok ? 1 : 0,
GetOwner()->GetMainSkill() ? GetOwner()->GetMainSkill()->GetLeftTime() : 0
});
}
#endif
if (!use_skill_ok) {
bool shot_ok = false;
glm::vec3 shot_dir = dir;
GetOwner()->SetAttackDir(dir);
GetOwner()->shot_hold = true;
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
}
} else {
GetOwner()->shot_hold = false;
}