Core/Creatures: reworked tempoary summon creation

* all stats and values will now be set before summons are getting added to map
* cleaned up summon spell effect handler to reduce duplicade code
* summoner guids will no longer be set for every minion and correctly handle assigning creator guids instead. These values will serve as fallback guid if there is no summoner guid
* friendly tempsummons will now inherit the guild data of their player and pass them on to further allied summons. This fixes guild specific visuals for creatures such as Guild Battle Standards and Guild Heralds.

Todo: check for regressions
This commit is contained in:
Ovahlord committed 2020-04-22 00:20:18 +02:00
1 parent bc1a69caa3
commit d30c811d9e
19 files changed
+145 -276

No files matched your search

+21 -3
View File
@@ -739,7 +739,7 @@ uint32 Object::GetUpdateFieldData(Player const* target, uint32*& flags) const
{
Player* plr = ToUnit()->GetCharmerOrOwnerPlayerOrPlayerItself();
flags = UnitUpdateFieldFlags;
if (ToUnit()->GetOwnerGUID() == target->GetGUID())
if (ToUnit()->GetOwnerOrCreatorGUID() == target->GetGUID())
visibleFlag |= UF_FLAG_OWNER;
if (HasFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_SPECIALINFO))
@@ -2036,7 +2036,7 @@ void WorldObject::AddObjectToRemoveList()
map->AddObjectToRemoveList(this);
}
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= NULL*/, uint32 duration /*= 0*/, Unit* summoner /*= NULL*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/)
TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= nullptr*/, uint32 duration /*= 0*/, Unit* summoner /*= nullptr*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/, bool visibleBySummonerOnly /*= false*/, uint32 health /*= 0*/)
{
uint32 mask = UNIT_MASK_SUMMON;
if (properties)
@@ -2077,7 +2077,7 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
default:
if (properties->Flags & 512) // Mirror Image, Summon Gargoyle
mask = UNIT_MASK_GUARDIAN;
break;
break;
}
break;
}
@@ -2106,12 +2106,14 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
break;
}
// Create creature entity
if (!summon->Create(GenerateLowGuid<HighGuid::Unit>(), this, entry, pos, nullptr, vehId, true))
{
delete summon;
return nullptr;
}
// Add summon to transport if summoner is on a transport as well
if (summon->GetTransGUID().IsEmpty() && summoner)
{
if (Transport* transport = summoner->GetTransport())
@@ -2129,11 +2131,27 @@ TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropert
if (summoner)
PhasingHandler::InheritPhaseShift(summon, summoner);
// Initialize tempsummon fields
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId);
summon->SetHomePosition(pos);
summon->InitStats(duration);
summon->SetVisibleBySummonerOnly(visibleBySummonerOnly);
// Handle health argument (totem health via base points)
if (health)
{
summon->SetMaxHealth(health);
summon->SetHealth(health);
}
// Initialize guardian stats
if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN) && summoner)
{
((Guardian*)summon)->UpdateAllStats();
summon->SetPower(POWER_MANA, summon->GetMaxPower(POWER_MANA));
summon->SetFullHealth();
}
AddToMap(summon->ToCreature());
summon->InitSummon();