diff --git a/server/gameserver/android_agent.cc b/server/gameserver/android_agent.cc index 7c349d79..cf401059 100644 --- a/server/gameserver/android_agent.cc +++ b/server/gameserver/android_agent.cc @@ -35,15 +35,17 @@ behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time) &GetOwner()->xtimer_attacher.timer_list_); std::weak_ptr timer_ptr = GetOwner()->room->xtimer.GetTimerPtr(timer); status_runing_cb_ = - [timer_ptr] () + [this, timer_ptr] () { if (timer_ptr.lock()) { return behaviac::BT_RUNNING; } else { + status_ = behaviac::BT_SUCCESS; return behaviac::BT_SUCCESS; } }; - return behaviac::BT_RUNNING; + status_ = behaviac::BT_RUNNING; + return status_; } behaviac::EBTStatus AndroidAgent::DoRandomWalk() @@ -56,12 +58,21 @@ behaviac::EBTStatus AndroidAgent::DoRandomWalk() dir.Rotate((10 + rand() % 360)/ 180.0f); dir.Normalize(); GetOwner()->GetMoveHelper()->CalcTargetPos(500); + if (GetOwner()->GetMoveHelper()->GetPathSize() <= 0) { + return behaviac::BT_FAILURE; + } status_runing_cb_ = - [] () + [this] () { - return behaviac::BT_SUCCESS; + if (GetOwner()->GetMoveHelper()->GetPathSize() <= 0) { + status_ = behaviac::BT_SUCCESS; + return behaviac::BT_SUCCESS; + } else { + return behaviac::BT_RUNNING; + } }; - return behaviac::BT_SUCCESS; + status_ = behaviac::BT_RUNNING; + return status_; } behaviac::EBTStatus AndroidAgent::DoRandomShot()