diff --git a/server/gameserver/base_agent.cc b/server/gameserver/base_agent.cc index e74ae053..b4ef05b2 100644 --- a/server/gameserver/base_agent.cc +++ b/server/gameserver/base_agent.cc @@ -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; }