This commit is contained in:
aozhiwei 2023-10-19 17:01:48 +08:00
parent 7fc1233628
commit 27564fa261
2 changed files with 104 additions and 2 deletions

View File

@ -19,9 +19,11 @@
#include "team.h"
#include "master_agent.h"
#include "team_agent.h"
#include "skill.h"
#include "mt/Hero.h"
#include "mt/Equip.h"
#include "mt/Skill.h"
HeroAgent::HeroAgent():BaseAgent()
{
@ -619,9 +621,11 @@ behaviac::EBTStatus HeroAgent::CoSleep(int time)
behaviac::EBTStatus HeroAgent::CoUseSkill(int skill_id)
{
if (!current_target_agent->IsValid()) {
return behaviac::BT_FAILURE;
int wait_time = 0;
if (InternalUseSkill(skill_id, wait_time)) {
return behaviac::BT_SUCCESS;
}
return behaviac::BT_FAILURE;
}
Room* HeroAgent::GetRoom()
@ -848,3 +852,100 @@ bool HeroAgent::HasUseableSkill()
{
return owner_->HasUseableSkill();
}
bool HeroAgent::InternalUseSkill(int skill_id, int& wait_time)
{
if (!current_target_agent->IsValid()) {
return false;
}
if (GlmHelper::IsEqual2D(owner_->GetPos().ToGlmVec3(),
current_target_agent->GetPos())) {
return false;
}
Skill* skill = owner_->GetSkill(skill_id);
if (skill) {
wait_time = 500;
glm::vec3 skill_dir = current_target_agent->GetPos() - owner_->GetPos().ToGlmVec3();
float skill_distance = GlmHelper::Norm(skill_dir);
GlmHelper::Normalize(skill_dir);
switch (skill->GetCurrSkillMeta()->GetMagicId()) {
case MAGIC_20101_HL:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20701_BAO:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20801_LONG:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20901_XIONG:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_21001_NIU:
{
#if 0
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
#endif
}
break;
case MAGIC_20201_HX:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20401_MAO:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20601_DJS:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20301_XL:
{
skill_distance = 30;
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20501_TZ:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_60100_1_BOSS:
case MAGIC_60100_2_BOSS:
case MAGIC_60100_3_BOSS:
{
owner_->DoSkill(skill->GetSkillId(), current_target_agent->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
default:
{
}
break;
}
}
return false;
}

View File

@ -142,6 +142,7 @@ public:
protected:
behaviac::EBTStatus DoRunningCb();
behaviac::EBTStatus StartCoroutine(std::shared_ptr<BtCoroutine> coroutine);
bool InternalUseSkill(int skill_id, int& wait_time);
private:
Creature* owner_ = nullptr;