Core/Creatures: Create a CreatureGroup for every SummonCreatureGroup
Port From (https://github.com/TrinityCore/TrinityCore/commit/9a7a83ef3074faaad037cfb4c098784695f49d30)
This commit is contained in:
@@ -1685,21 +1685,13 @@ namespace Game.Entities
|
|||||||
|
|
||||||
public void SummonCreatureGroup(byte group, out List<TempSummon> list)
|
public void SummonCreatureGroup(byte group, out List<TempSummon> list)
|
||||||
{
|
{
|
||||||
Cypher.Assert((IsTypeId(TypeId.GameObject) || IsTypeId(TypeId.Unit)), "Only GOs and creatures can summon npc groups!");
|
list = new();
|
||||||
list = new List<TempSummon>();
|
|
||||||
var data = Global.ObjectMgr.GetSummonGroup(GetEntry(), IsTypeId(TypeId.GameObject) ? SummonerType.GameObject : SummonerType.Creature, group);
|
|
||||||
if (data.Empty())
|
|
||||||
{
|
|
||||||
Log.outWarn(LogFilter.Scripts, "{0} ({1}) tried to summon non-existing summon group {2}.", GetName(), GetGUID().ToString(), group);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
foreach (var tempSummonData in data)
|
Cypher.Assert(IsTypeId(TypeId.GameObject) || IsTypeId(TypeId.Unit), "Only GOs and creatures can summon npc groups!");
|
||||||
|
Map.SummonCreatureGroup(GetEntry(), GetTypeId() == TypeId.GameObject ? SummonerType.GameObject : SummonerType.Creature, group, list, tempSummonData =>
|
||||||
{
|
{
|
||||||
TempSummon summon = SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, tempSummonData.time);
|
return SummonCreature(tempSummonData.entry, tempSummonData.pos, tempSummonData.type, tempSummonData.time);
|
||||||
if (summon != null)
|
});
|
||||||
list.Add(summon);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Creature FindNearestCreature(uint entry, float range, bool alive = true)
|
public Creature FindNearestCreature(uint entry, float range, bool alive = true)
|
||||||
|
|||||||
@@ -3823,6 +3823,44 @@ namespace Game.Maps
|
|||||||
return summon;
|
return summon;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void SummonCreatureGroup(uint summonerId, SummonerType summonerType, byte group, List<TempSummon> summoned, Func<TempSummonData, TempSummon> summonCreature)
|
||||||
|
{
|
||||||
|
var data = Global.ObjectMgr.GetSummonGroup(summonerId, summonerType, group);
|
||||||
|
if (data == null)
|
||||||
|
{
|
||||||
|
Log.outWarn(LogFilter.Scripts, $"Summoner {summonerId} type {summonerType} tried to summon non-existing summon group {group}.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
List<TempSummon> summons = new();
|
||||||
|
|
||||||
|
foreach (TempSummonData tempSummonData in data)
|
||||||
|
{
|
||||||
|
TempSummon summon = summonCreature(tempSummonData);
|
||||||
|
if (summon != null)
|
||||||
|
summons.Add(summon);
|
||||||
|
}
|
||||||
|
|
||||||
|
CreatureGroup creatureGroup = new CreatureGroup(0);
|
||||||
|
foreach (TempSummon summon in summons)
|
||||||
|
{
|
||||||
|
if (!summon.IsInWorld) // evil script might despawn a summon
|
||||||
|
continue;
|
||||||
|
|
||||||
|
creatureGroup.AddMember(summon);
|
||||||
|
if (summoned != null)
|
||||||
|
summoned.Add(summon);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void SummonCreatureGroup(byte group, List<TempSummon> list = null)
|
||||||
|
{
|
||||||
|
SummonCreatureGroup(GetId(), SummonerType.Map, group, list, tempSummonData =>
|
||||||
|
{
|
||||||
|
return SummonCreature(tempSummonData.entry, tempSummonData.pos, null, tempSummonData.time);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
public ulong GenerateLowGuid(HighGuid high)
|
public ulong GenerateLowGuid(HighGuid high)
|
||||||
{
|
{
|
||||||
return GetGuidSequenceGenerator(high).Generate();
|
return GetGuidSequenceGenerator(high).Generate();
|
||||||
|
|||||||
Reference in New Issue
Block a user