1
This commit is contained in:
parent
bbf5535158
commit
f9bf8342f0
@ -70,6 +70,15 @@ Creature::Creature():MoveableEntity()
|
|||||||
|
|
||||||
Creature::~Creature()
|
Creature::~Creature()
|
||||||
{
|
{
|
||||||
|
for (auto itr = slave_heros_.begin(); itr != slave_heros_.end(); ++itr) {
|
||||||
|
while (!list_empty(&itr->second)) {
|
||||||
|
Hero* hero = list_first_entry(&itr->second,
|
||||||
|
Hero,
|
||||||
|
entry);
|
||||||
|
list_del_init(&hero->entry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
slave_heros_.clear();
|
||||||
xtimer_attacher.ClearTimerList();
|
xtimer_attacher.ClearTimerList();
|
||||||
ClearBuffList();
|
ClearBuffList();
|
||||||
skill_hash_.clear();
|
skill_hash_.clear();
|
||||||
|
@ -74,5 +74,5 @@ void GlmHelper::FillVert(const glm::vec3& v, float* vert)
|
|||||||
|
|
||||||
bool GlmHelper::IsEqual2D(const glm::vec3& v1, const glm::vec3& v2)
|
bool GlmHelper::IsEqual2D(const glm::vec3& v1, const glm::vec3& v2)
|
||||||
{
|
{
|
||||||
return std::abs(v1.x - v2.x) > 0.00001f || std::abs(v1.z - v2.z) > 0.00001f;
|
return std::abs(v1.x - v2.x) < 0.00001f && std::abs(v1.z - v2.z) < 0.00001f;
|
||||||
}
|
}
|
||||||
|
@ -208,6 +208,10 @@ behaviac::EBTStatus HeroAgent::DoAttack()
|
|||||||
if (!enemy) {
|
if (!enemy) {
|
||||||
return behaviac::BT_FAILURE;
|
return behaviac::BT_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (GlmHelper::IsEqual2D(GetOwner()->GetPos().ToGlmVec3(), enemy->GetPos().ToGlmVec3())) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
enemy = ((Hero*)GetOwner())->master.Get();
|
||||||
|
|
||||||
glm::vec3 dir = GetOwner()->GetPos().CalcDir(enemy->GetPos());
|
glm::vec3 dir = GetOwner()->GetPos().CalcDir(enemy->GetPos());
|
||||||
GlmHelper::Normalize(dir);
|
GlmHelper::Normalize(dir);
|
||||||
@ -217,17 +221,31 @@ behaviac::EBTStatus HeroAgent::DoAttack()
|
|||||||
glm::vec3 shot_dir = dir;
|
glm::vec3 shot_dir = dir;
|
||||||
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
CreatureWeakPtr target = enemy->GetWeakPtrRef();
|
||||||
|
#endif
|
||||||
long long last_frameno = GetOwner()->room->GetFrameNo();
|
long long last_frameno = GetOwner()->room->GetFrameNo();
|
||||||
return StartCoroutine
|
return StartCoroutine
|
||||||
(
|
(
|
||||||
[this, last_frameno] ()
|
[this, last_frameno, target] () mutable
|
||||||
{
|
{
|
||||||
if (GetOwner()->room->GetFrameNo() - last_frameno > SERVER_FRAME_RATE * 3) {
|
if (GetOwner()->room->GetFrameNo() - last_frameno > SERVER_FRAME_RATE * 3) {
|
||||||
status_ = behaviac::BT_SUCCESS;
|
status_ = behaviac::BT_SUCCESS;
|
||||||
return behaviac::BT_SUCCESS;
|
return behaviac::BT_SUCCESS;
|
||||||
} else {
|
} else {
|
||||||
|
if (!target.Get()) {
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
if (target.Get()->dead) {
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
if (GlmHelper::IsEqual2D(GetOwner()->GetPos().ToGlmVec3(),
|
||||||
|
target.Get()->GetPos().ToGlmVec3())) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
bool shot_ok = false;
|
bool shot_ok = false;
|
||||||
glm::vec3 shot_dir = GetOwner()->GetAttackDir();
|
glm::vec3 shot_dir = GetOwner()->GetPos().CalcDir(target.Get()->GetPos());;
|
||||||
|
GetOwner()->SetAttackDir(shot_dir);
|
||||||
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
GetOwner()->Shot(shot_dir, shot_ok, 0, 0);
|
||||||
|
|
||||||
return behaviac::BT_RUNNING;
|
return behaviac::BT_RUNNING;
|
||||||
|
@ -140,7 +140,7 @@ public:
|
|||||||
{
|
{
|
||||||
double result = 0.0f;
|
double result = 0.0f;
|
||||||
if (context_.buff->GetCaster().Get()) {
|
if (context_.buff->GetCaster().Get()) {
|
||||||
result = context_.buff->GetCaster().Get()->GetSkillRaycastDistance();
|
result = context_.buff->GetCaster().Get()->GetSkillRaycastDistance();
|
||||||
}
|
}
|
||||||
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
||||||
});
|
});
|
||||||
@ -177,6 +177,40 @@ public:
|
|||||||
}
|
}
|
||||||
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
RegisterCProc
|
||||||
|
(
|
||||||
|
"caster.get_skill_target_pos_x",
|
||||||
|
[this] (const a8::lisp::List& params) -> std::shared_ptr<a8::lisp::Value>
|
||||||
|
{
|
||||||
|
double result = 0.0f;
|
||||||
|
if (context_.buff->GetCaster().Get()) {
|
||||||
|
result = context_.buff->GetCaster().Get()->context_pos.GetX();
|
||||||
|
}
|
||||||
|
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
||||||
|
});
|
||||||
|
RegisterCProc
|
||||||
|
(
|
||||||
|
"caster.get_skill_target_pos_y",
|
||||||
|
[this] (const a8::lisp::List& params) -> std::shared_ptr<a8::lisp::Value>
|
||||||
|
{
|
||||||
|
double result = 0.0f;
|
||||||
|
if (context_.buff->GetCaster().Get()) {
|
||||||
|
result = context_.buff->GetCaster().Get()->context_pos.GetY();
|
||||||
|
}
|
||||||
|
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
||||||
|
});
|
||||||
|
RegisterCProc
|
||||||
|
(
|
||||||
|
"caster.get_skill_target_pos_z",
|
||||||
|
[this] (const a8::lisp::List& params) -> std::shared_ptr<a8::lisp::Value>
|
||||||
|
{
|
||||||
|
double result = 0.0f;
|
||||||
|
if (context_.buff->GetCaster().Get()) {
|
||||||
|
result = context_.buff->GetCaster().Get()->context_pos.GetZ();
|
||||||
|
}
|
||||||
|
return std::make_shared<a8::lisp::Value>(a8::lisp::Atom(result));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
float Eval(std::shared_ptr<a8::lisp::Value> expr,
|
float Eval(std::shared_ptr<a8::lisp::Value> expr,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user