29#define MAX_DESYNC 5.0f
58 for (
auto const& pair : bounds)
61 if (other == creature)
64 if (itr->second->HasMember(other))
65 itr->second->RemoveMember(other);
71 TC_LOG_DEBUG(
"entities.unit",
"Group not found: {}. Creating new group.", leaderSpawnId);
76 itr->second->AddMember(creature);
101 QueryResult result =
WorldDatabase.Query(
"SELECT leaderGUID, memberGUID, dist, angle, groupAI, point_1, point_2 FROM creature_formations ORDER BY leaderGUID");
104 TC_LOG_INFO(
"server.loading",
">> Loaded 0 creatures in formations. DB table `creature_formations` is empty!");
109 std::unordered_set<ObjectGuid::LowType> leaderSpawnIds;
112 Field* fields = result->Fetch();
129 for (
uint8 i = 0; i < 2; ++i)
140 if (!
sObjectMgr->GetCreatureData(memberSpawnId))
142 TC_LOG_ERROR(
"sql.sql",
"creature_formations table member guid {} incorrect (not exist)", memberSpawnId);
151 }
while (result->NextRow());
157 TC_LOG_ERROR(
"sql.sql",
"creature_formation contains leader spawn {} which is not included on its formation, removing", leaderSpawnId);
160 if (itr->second.LeaderSpawnId == leaderSpawnId)
186 for (
uint8 i = 0; i < 2; ++i)
213 _members.emplace(member, formationInfo);
268 pair.first->GetMotionMaster()->MoveIdle();
287 float angle = pair.second->FollowAngle + float(
M_PI);
288 float dist = pair.second->FollowDist;
297 for (std::unordered_map<Creature*, FormationInfo*>::value_type
const& pair :
_members)
301 if (pair.first->IsEngaged() || pair.first->IsReturningHome())
@ FLAG_LEADER_ASSISTS_MEMBER
@ FLAG_MEMBERS_ASSIST_LEADER
std::shared_ptr< ResultSet > QueryResult
DatabaseWorkerPool< WorldDatabaseConnection > WorldDatabase
Accessor to the world database.
#define ASSERT_NOTNULL(pointer)
#define TC_LOG_DEBUG(filterType__,...)
#define TC_LOG_ERROR(filterType__,...)
#define TC_LOG_INFO(filterType__,...)
uint32 GetMSTimeDiffToNow(uint32 oldMSTime)
@ UNIT_STATE_FOLLOW_FORMATION
CreatureGroup(ObjectGuid::LowType leaderSpawnId)
void FormationReset(bool dismiss)
ObjectGuid::LowType GetLeaderSpawnId() const
void RemoveMember(Creature *member)
void LeaderStartedMoving()
void MemberEngagingTarget(Creature *member, Unit *target)
bool CanLeaderStartMoving() const
std::unordered_map< Creature *, FormationInfo * > _members
ObjectGuid::LowType _leaderSpawnId
void AddMember(Creature *member)
bool IsEngaged() const override
ObjectGuid::LowType GetSpawnId() const
void SetFormation(CreatureGroup *formation)
Class used to access individual fields of database query result.
std::unordered_map< ObjectGuid::LowType, CreatureGroup * > CreatureGroupHolder
CreatureBySpawnIdContainer & GetCreatureBySpawnIdStore()
void MoveFormation(Unit *leader, float range, float angle, uint32 point1, uint32 point2)
std::string ToString() const
static ObjectGuid GetGUID(Object const *o)
MotionMaster * GetMotionMaster()
void EngageWithTarget(Unit *who)
bool HasUnitState(const uint32 f) const
bool IsValidAttackTarget(WorldObject const *target, SpellInfo const *bySpell=nullptr) const
uint32 GetInstanceId() const
auto MapEqualRange(M &map, typename M::key_type const &key)
auto MapGetValuePtr(M &map, typename M::key_type const &key)