This commit is contained in:
aozhiwei 2023-06-01 14:25:21 +08:00
parent 33e5342666
commit 7c0f51f73d
3 changed files with 94 additions and 1 deletions

View File

@ -7,10 +7,12 @@
#include "movement.h" #include "movement.h"
#include "glmhelper.h" #include "glmhelper.h"
#include "trigger.h" #include "trigger.h"
#include "skill.h"
#include "f8/btmgr.h" #include "f8/btmgr.h"
#include "mt/Equip.h" #include "mt/Equip.h"
#include "mt/Skill.h"
void DumpBt(BaseAgent* agent) void DumpBt(BaseAgent* agent)
{ {
@ -286,16 +288,100 @@ bool BaseAgent::CanUseSkill(int skill_id)
int BaseAgent::GetUseableSkill(Creature* target) int BaseAgent::GetUseableSkill(Creature* target)
{ {
if (GetOwner()->IsHuman()) {
Skill* skill = GetOwner()->GetMainSkill();
if (skill && CanUseSkill(skill->GetSkillId())) {
return skill->GetSkillId();
}
}
return -1; return -1;
} }
behaviac::EBTStatus BaseAgent::DoUseSkill(int skill_id) behaviac::EBTStatus BaseAgent::DoUseSkill(int skill_id)
{ {
return behaviac::BT_SUCCESS;
} }
bool BaseAgent::InternalUseSkill(int skill_id, CreatureWeakPtr target, int& wait_time) bool BaseAgent::InternalUseSkill(int skill_id, CreatureWeakPtr target, int& wait_time)
{ {
if (GlmHelper::IsEqual2D(GetOwner()->GetPos().ToGlmVec3(),
target.Get()->GetPos().ToGlmVec3())) {
return false;
}
Skill* skill = GetOwner()->GetSkill(skill_id);
if (skill) {
wait_time = 0;
glm::vec3 skill_dir = target.Get()->GetPos().ToGlmVec3() - GetOwner()->GetPos().ToGlmVec3();
float skill_distance = GlmHelper::Norm(skill_dir);
GlmHelper::Normalize(skill_dir);
switch (skill->GetCurrSkillMeta()->GetMagicId()) {
case MAGIC_20101_HL:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20701_BAO:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20801_LONG:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20901_XIONG:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_21001_NIU:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20201_HX:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20401_MAO:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20601_DJS:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20301_XL:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
case MAGIC_20501_TZ:
{
GetOwner()->DoSkill(skill->GetSkillId(), target.Get()->GetUniId(), skill_dir, skill_distance);
return true;
}
break;
default:
{
}
break;
}
}
return false; return false;
} }

View File

@ -558,3 +558,9 @@ const mt::Skill* Skill::GetCurrSkillMeta()
return meta; return meta;
} }
} }
int Skill::GetSkillId()
{
return meta->skill_id();
}

View File

@ -52,6 +52,7 @@ class Skill
void Clear(); void Clear();
void Reset(); void Reset();
const mt::Skill* GetCurrSkillMeta(); const mt::Skill* GetCurrSkillMeta();
int GetSkillId();
private: private:
void InitActiveSkill(); void InitActiveSkill();