1
This commit is contained in:
parent
87a8e7dbb6
commit
27d1fada8d
@ -334,18 +334,78 @@ behaviac::EBTStatus BaseAgent::SelectUseableSkill(const behaviac::vector<int> sk
|
|||||||
|
|
||||||
behaviac::EBTStatus BaseAgent::CoFindPathToCurrentTarget(float distance)
|
behaviac::EBTStatus BaseAgent::CoFindPathToCurrentTarget(float distance)
|
||||||
{
|
{
|
||||||
|
if (status_ == behaviac::BT_RUNNING) {
|
||||||
|
return DoRunningCb();
|
||||||
|
}
|
||||||
if (!current_target_.Get()) {
|
if (!current_target_.Get()) {
|
||||||
return behaviac::BT_FAILURE;
|
return behaviac::BT_FAILURE;
|
||||||
}
|
}
|
||||||
|
bool ret = GetOwner()->GetMovement()->FindPath(current_target_.Get()->GetPos().ToGlmVec3(), distance);
|
||||||
|
if (!ret) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
auto context = MAKE_BTCONTEXT
|
||||||
|
(
|
||||||
|
);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CoFindPathToCurrentTarget %d\n", {current_target_.Get()->GetUniId()});
|
||||||
|
#endif
|
||||||
|
auto co = std::make_shared<BtCoroutine>(context, "CoFindPathToCurrentTarget");
|
||||||
|
co->runing_cb =
|
||||||
|
[this, context] ()
|
||||||
|
{
|
||||||
|
if (GetOwner()->dead) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
if (GetOwner()->GetMovement()->GetPathSize() <= 0) {
|
||||||
return behaviac::BT_SUCCESS;
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
return behaviac::BT_RUNNING;
|
||||||
|
};
|
||||||
|
return StartCoroutine(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
behaviac::EBTStatus BaseAgent::CoMoveToCurrentTarget(float distance)
|
behaviac::EBTStatus BaseAgent::CoMoveToCurrentTarget(float distance)
|
||||||
{
|
{
|
||||||
|
if (status_ == behaviac::BT_RUNNING) {
|
||||||
|
return DoRunningCb();
|
||||||
|
}
|
||||||
if (!current_target_.Get()) {
|
if (!current_target_.Get()) {
|
||||||
return behaviac::BT_FAILURE;
|
return behaviac::BT_FAILURE;
|
||||||
}
|
}
|
||||||
|
if (GlmHelper::IsEqual2D(GetOwner()->GetPos().ToGlmVec3(),
|
||||||
|
current_target_.Get()->GetPos().ToGlmVec3())) {
|
||||||
return behaviac::BT_SUCCESS;
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
auto context = MAKE_BTCONTEXT
|
||||||
|
(
|
||||||
|
CreatureWeakPtr target;
|
||||||
|
);
|
||||||
|
|
||||||
|
context->target = current_target_;
|
||||||
|
glm::vec3 dir = GetOwner()->GetPos().CalcDir(context->target.Get()->GetPos());
|
||||||
|
GlmHelper::Normalize(dir);
|
||||||
|
GetOwner()->SetMoveDir(dir);
|
||||||
|
GetOwner()->SetAttackDir(dir);
|
||||||
|
GetOwner()->GetMovement()->CalcTargetPos(60);
|
||||||
|
|
||||||
|
#ifdef DEBUG
|
||||||
|
a8::XPrintf("CoMoveToCurrentTarget %d\n", {current_target_.Get()->GetUniId()});
|
||||||
|
#endif
|
||||||
|
auto co = std::make_shared<BtCoroutine>(context, "CoMoveToCurrentTarget");
|
||||||
|
co->runing_cb =
|
||||||
|
[this, context] ()
|
||||||
|
{
|
||||||
|
if (GetOwner()->dead) {
|
||||||
|
return behaviac::BT_FAILURE;
|
||||||
|
}
|
||||||
|
if (GetOwner()->GetMovement()->GetPathSize() <= 0) {
|
||||||
|
return behaviac::BT_SUCCESS;
|
||||||
|
}
|
||||||
|
return behaviac::BT_RUNNING;
|
||||||
|
};
|
||||||
|
return StartCoroutine(co);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool BaseAgent::CurrentTargetIsValid()
|
bool BaseAgent::CurrentTargetIsValid()
|
||||||
|
@ -2352,19 +2352,15 @@ void Creature::UpdateMove()
|
|||||||
if (room->GetGasData().GetGasMode() == GasInactive &&
|
if (room->GetGasData().GetGasMode() == GasInactive &&
|
||||||
room->IsSandTableRoom()) {
|
room->IsSandTableRoom()) {
|
||||||
} else {
|
} else {
|
||||||
|
if (IsPlayer() || HasBuffEffect(kBET_Sprint)) {
|
||||||
GetMovement()->CalcTargetPos(mt::Param::s().move_step_len);
|
GetMovement()->CalcTargetPos(mt::Param::s().move_step_len);
|
||||||
if (!GetMovement()->UpdatePosition()) {
|
if (!GetMovement()->UpdatePosition()) {
|
||||||
#if 1
|
|
||||||
{
|
|
||||||
#else
|
|
||||||
if (IsPlayer()) {
|
|
||||||
#endif
|
|
||||||
if (HasBuffEffect(kBET_Sprint)) {
|
if (HasBuffEffect(kBET_Sprint)) {
|
||||||
SprintBuff* buff = (SprintBuff*)GetBuffByEffectId(kBET_Sprint);
|
SprintBuff* buff = (SprintBuff*)GetBuffByEffectId(kBET_Sprint);
|
||||||
if (buff) {
|
if (buff) {
|
||||||
buff->SprintEnd();
|
buff->SprintEnd();
|
||||||
}
|
}
|
||||||
} else {
|
} else if (IsPlayer()) {
|
||||||
ShortFindPath();
|
ShortFindPath();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user