diff --git a/server/gameserver/creature.cc b/server/gameserver/creature.cc index b376c24a..ac958eda 100644 --- a/server/gameserver/creature.cc +++ b/server/gameserver/creature.cc @@ -4182,3 +4182,22 @@ bool Creature::IsOb() { return a8::HasBitFlag(status, CS_IsOb); } + +bool Creature::HaveBallingEnemy() +{ + bool have = false; + TraverseCreatures + ( + [this, &have] (Creature* c, bool& stop) + { + if (c->team_id != team_id && !c->HasBuffEffect(kBET_Hide) && !c->IsCar()) { + float distance = c->GetPos().Distance2D2(GetPos()); + if (distance <= mt::Param::s().battling_detection_range) { + have = true; + stop = true; + } + } + } + ); + return have; +} diff --git a/server/gameserver/creature.h b/server/gameserver/creature.h index 7be2aa73..5e71c645 100644 --- a/server/gameserver/creature.h +++ b/server/gameserver/creature.h @@ -411,6 +411,7 @@ class Creature : public MoveableEntity void AdjustMobaBornDir(); int GetBattleStartTime(); bool IsOb(); + bool HaveBallingEnemy(); protected: virtual void OnBuffRemove(Buff& buff);