diff --git a/server/gameserver/android_agent.cc b/server/gameserver/android_agent.cc index c8abb28d..400be199 100644 --- a/server/gameserver/android_agent.cc +++ b/server/gameserver/android_agent.cc @@ -47,7 +47,6 @@ behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time) Creature* c = std::any_cast(args.at(0)); *last_attacker = c->GetWeakPtrRef(); *last_attacked_frameno = c->room->GetFrameNo(); - //FireEvent("OnAttacked", c->GetUniId(), c->room->GetFrameNo()); }); return StartCoroutine @@ -63,9 +62,12 @@ behaviac::EBTStatus AndroidAgent::DoIdle(int min_time, int max_time) return behaviac::BT_SUCCESS; } }, - [this, last_attacker, last_attacked_frameno] (bool& has_event) + [this, last_attacker, last_attacked_frameno] (bool is_test, bool& has_event) { - + has_event = last_attacker->Get() ? true : false; + if (!is_test && has_event) { + FireEvent("OnAttacked", last_attacker->Get()->GetUniId(), *last_attacked_frameno); + } }, "CoIdle" ); @@ -109,7 +111,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomWalk() return behaviac::BT_RUNNING; } }, - [this] (bool& has_event) + [this] (bool is_test, bool& has_event) { }, @@ -159,7 +161,7 @@ behaviac::EBTStatus AndroidAgent::DoRandomShot() return behaviac::BT_RUNNING; } }, - [this] (bool& has_event) + [this] (bool is_test, bool& has_event) { }, @@ -201,7 +203,7 @@ behaviac::EBTStatus AndroidAgent::DoAttack() return behaviac::BT_RUNNING; } }, - [this] (bool& has_event) + [this] (bool is_test, bool& has_event) { }, @@ -267,7 +269,7 @@ behaviac::EBTStatus AndroidAgent::DoPursuit() return behaviac::BT_RUNNING; } }, - [this] (bool& has_event) + [this] (bool is_test, bool& has_event) { }, diff --git a/server/gameserver/base_agent.cc b/server/gameserver/base_agent.cc index 0f077bd0..18afd9e3 100644 --- a/server/gameserver/base_agent.cc +++ b/server/gameserver/base_agent.cc @@ -27,11 +27,11 @@ void BaseAgent::Exec() behaviac::EBTStatus status = f8::BtMgr::Instance()->BtExec(this); if (status == behaviac::BT_RUNNING && event_cb_) { bool has_event = false; - event_cb_(has_event); + event_cb_(true, has_event); if (has_event) { status_= behaviac::BT_INVALID; runing_cb_ = nullptr; - event_cb_(has_event); + event_cb_(false, has_event); } } } @@ -62,7 +62,7 @@ behaviac::EBTStatus BaseAgent::DoRunningCb() } behaviac::EBTStatus BaseAgent::StartCoroutine(std::function cb, - std::function event_cb, + std::function event_cb, const char* name) { #ifdef DEBUG @@ -136,7 +136,7 @@ behaviac::EBTStatus BaseAgent::CoAttackTarget(int target_id) } return behaviac::BT_RUNNING; }, - [this] (bool& has_event) + [this] (bool is_test, bool& has_event) { }, diff --git a/server/gameserver/base_agent.h b/server/gameserver/base_agent.h index 36afd570..a2eb9e41 100644 --- a/server/gameserver/base_agent.h +++ b/server/gameserver/base_agent.h @@ -27,7 +27,7 @@ public: protected: behaviac::EBTStatus DoRunningCb(); behaviac::EBTStatus StartCoroutine(std::function cb, - std::function event_cb, + std::function event_cb, const char* name); protected: @@ -38,7 +38,7 @@ protected: #endif behaviac::EBTStatus status_= behaviac::BT_SUCCESS; std::function runing_cb_; - std::function event_cb_; + std::function event_cb_; private: Creature* owner_ = nullptr;