Skip to content

Commit

Permalink
SpawnGroup: Implement CREATURE_GROUP_FORMATION_MIRRORING
Browse files Browse the repository at this point in the history
  • Loading branch information
killerwife committed Feb 25, 2024
1 parent 0b0173d commit 4aecee7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 15 deletions.
13 changes: 7 additions & 6 deletions src/game/Maps/SpawnGroup.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1743,13 +1743,14 @@ bool FormationSlotData::IsFormationMaster()

float FormationSlotData::GetAngle()
{
#ifdef ENABLE_SPAWNGROUP_FORMATION_MIRRORING
if (!GetFormationData()->GetMirrorState())
return m_angleVariation;
return (2 * M_PI_F) - m_angleVariation;
#else
if (GetCreatureGroup()->GetGroupEntry().IsMirroring())
{
if (!GetFormationData()->GetMirrorState())
return m_angleVariation;
return (2 * M_PI_F) - m_angleVariation;
}

return m_angleVariation;
#endif // ENABLE_SPAWNGROUP_FORMATION_MIRRORING
}

float FormationSlotData::GetDistance() const
Expand Down
7 changes: 3 additions & 4 deletions src/game/Maps/SpawnGroupDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@
#include <map>
#include <memory>


// uncomment this if you want mirroring at start and end of the LINEAR_WP_MOTION_TYPE movement
//#define ENABLE_SPAWNGROUP_FORMATION_MIRRORING

struct FormationEntry;
class FormationData;
class FormationSlotData;
Expand Down Expand Up @@ -74,6 +70,7 @@ enum CreatureGroupFlags
CREATURE_GROUP_RESPAWN_TOGETHER = 0x02,
CREATURE_GROUP_EVADE_TOGETHER = 0x04,
// SPAWN_GROUP_DESPAWN_ON_COND_FAIL
CREATURE_GROUP_FORMATION_MIRRORING = 0x08, // mirrors position during linear path movement
};

enum CreatureGroupEvent : uint32
Expand Down Expand Up @@ -112,6 +109,8 @@ struct SpawnGroupEntry
auto const& itr = std::find_if(DbGuids.begin(), DbGuids.end(), [dbGuid](SpawnGroupDbGuids const& x) { return x.DbGuid == dbGuid; });
return itr != DbGuids.end() ? (*itr).SlotId : -1;
}

bool IsMirroring() const { return Flags & CREATURE_GROUP_FORMATION_MIRRORING; }
};

// Formation defines
Expand Down
6 changes: 1 addition & 5 deletions src/game/MotionGenerators/WaypointMovementGenerator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ bool WaypointMovementGenerator<Creature>::SetNextWaypoint(uint32 pointId)
return true;
}

void LinearWPMovementGenerator<Creature>::SwitchToNextNode(Creature& /*creature*/, WaypointPath::const_iterator& nodeItr)
void LinearWPMovementGenerator<Creature>::SwitchToNextNode(Creature& creature, WaypointPath::const_iterator& nodeItr)
{
// switch to next node
if (!m_driveWayBack)
Expand All @@ -624,11 +624,9 @@ void LinearWPMovementGenerator<Creature>::SwitchToNextNode(Creature& /*creature*
--nodeItr;

m_driveWayBack = true;
#ifdef ENABLE_SPAWNGROUP_FORMATION_MIRRORING
// call end of path hook
if (creature.GetFormationSlot())
creature.GetFormationSlot()->GetFormationData()->OnWPEndNode();
#endif
}
else
++nodeItr;
Expand All @@ -639,11 +637,9 @@ void LinearWPMovementGenerator<Creature>::SwitchToNextNode(Creature& /*creature*
{
m_driveWayBack = false;
++nodeItr;
#ifdef ENABLE_SPAWNGROUP_FORMATION_MIRRORING
// call start of path hook
if (creature.GetFormationSlot())
creature.GetFormationSlot()->GetFormationData()->OnWPStartNode();
#endif
}
else
--nodeItr;
Expand Down

0 comments on commit 4aecee7

Please sign in to comment.