Core/Instances: New ZoneScript hook - OnCreatureGroupDepleted
Port From (https://github.com/TrinityCore/TrinityCore/commit/ec2631eca3a397dffd2e525b34c131c283beb167)
This commit is contained in:
@@ -2028,8 +2028,15 @@ namespace Game.Entities
|
|||||||
SetNoSearchAssistance(false);
|
SetNoSearchAssistance(false);
|
||||||
|
|
||||||
//Dismiss group if is leader
|
//Dismiss group if is leader
|
||||||
if (m_formation != null && m_formation.GetLeader() == this)
|
if (m_formation != null)
|
||||||
m_formation.FormationReset(true);
|
{
|
||||||
|
if (m_formation.GetLeader() == this)
|
||||||
|
m_formation.FormationReset(true);
|
||||||
|
|
||||||
|
ZoneScript script = GetZoneScript();
|
||||||
|
if (script != null && !m_formation.HasAliveMembers())
|
||||||
|
script.OnCreatureGroupDepleted(m_formation);
|
||||||
|
}
|
||||||
|
|
||||||
bool needsFalling = (IsFlying() || IsHovering()) && !IsUnderWater() && !HasUnitState(UnitState.Root);
|
bool needsFalling = (IsFlying() || IsHovering()) && !IsUnderWater() && !HasUnitState(UnitState.Root);
|
||||||
SetHover(false, false);
|
SetHover(false, false);
|
||||||
|
|||||||
@@ -55,6 +55,12 @@ namespace Game.Entities
|
|||||||
Log.outDebug(LogFilter.Unit, $"Deleting member GUID: {leaderSpawnId} from group {member.GetSpawnId()}");
|
Log.outDebug(LogFilter.Unit, $"Deleting member GUID: {leaderSpawnId} from group {member.GetSpawnId()}");
|
||||||
group.RemoveMember(member);
|
group.RemoveMember(member);
|
||||||
|
|
||||||
|
// If removed member was alive we need to check if we have any other alive members
|
||||||
|
// if not - fire OnCreatureGroupDepleted
|
||||||
|
ZoneScript script = member.GetZoneScript();
|
||||||
|
if (script != null && member.IsAlive() && !group.HasAliveMembers())
|
||||||
|
script.OnCreatureGroupDepleted(group);
|
||||||
|
|
||||||
if (group.IsEmpty())
|
if (group.IsEmpty())
|
||||||
{
|
{
|
||||||
if (leaderSpawnId != 0)
|
if (leaderSpawnId != 0)
|
||||||
@@ -299,6 +305,29 @@ namespace Game.Entities
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool HasAliveMembers()
|
||||||
|
{
|
||||||
|
return _members.Any(pair => pair.Key.IsAlive());
|
||||||
|
}
|
||||||
|
|
||||||
|
public bool LeaderHasStringId(string id)
|
||||||
|
{
|
||||||
|
if (_leader != null)
|
||||||
|
return _leader.HasStringId(id);
|
||||||
|
|
||||||
|
CreatureData leaderCreatureData = Global.ObjectMgr.GetCreatureData(_leaderSpawnId);
|
||||||
|
if (leaderCreatureData != null)
|
||||||
|
{
|
||||||
|
if (leaderCreatureData.StringId == id)
|
||||||
|
return true;
|
||||||
|
|
||||||
|
if (Global.ObjectMgr.GetCreatureTemplate(leaderCreatureData.Id).StringId == id)
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public Creature GetLeader() { return _leader; }
|
public Creature GetLeader() { return _leader; }
|
||||||
public ulong GetLeaderSpawnId() { return _leaderSpawnId; }
|
public ulong GetLeaderSpawnId() { return _leaderSpawnId; }
|
||||||
public bool IsEmpty() { return _members.Empty(); }
|
public bool IsEmpty() { return _members.Empty(); }
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ namespace Game.Maps
|
|||||||
|
|
||||||
public virtual void OnUnitDeath(Unit unit) { }
|
public virtual void OnUnitDeath(Unit unit) { }
|
||||||
|
|
||||||
|
// Triggers when the CreatureGroup no longer has any alive members (either last alive member dies or is removed from the group)
|
||||||
|
public virtual void OnCreatureGroupDepleted(CreatureGroup creatureGroup) { }
|
||||||
|
|
||||||
//All-purpose data storage 64 bit
|
//All-purpose data storage 64 bit
|
||||||
public virtual ObjectGuid GetGuidData(uint DataId) { return ObjectGuid.Empty; }
|
public virtual ObjectGuid GetGuidData(uint DataId) { return ObjectGuid.Empty; }
|
||||||
public virtual void SetGuidData(uint DataId, ObjectGuid Value) { }
|
public virtual void SetGuidData(uint DataId, ObjectGuid Value) { }
|
||||||
|
|||||||
Reference in New Issue
Block a user