fix(Core/Creatures): Implemented `SUMMON_PROP_FLAG_ONLY_VISIBLE_TO_SU… (#14054)

* fix(Core/Creatures): Implemented `SUMMON_PROP_FLAG_ONLY_VISIBLE_TO_SUMMONER` summon flag.

Fixes #6674

* Update.
This commit is contained in:
UltraNix
2023-01-06 00:52:05 +01:00
committed by GitHub
parent 0e1e8f27de
commit 14f3b444ae
12 changed files with 96 additions and 44 deletions

View File

@@ -2354,6 +2354,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
if (!m_originalCaster)
return;
bool personalSpawn = (properties->Flags & SUMMON_PROP_FLAG_ONLY_VISIBLE_TO_SUMMONER) != 0;
int32 duration = m_spellInfo->GetDuration();
if (Player* modOwner = m_originalCaster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
@@ -2398,7 +2399,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
case SUMMON_CATEGORY_UNK:
if (properties->Flags & 512)
{
SummonGuardian(effIndex, entry, properties, numSummons);
SummonGuardian(effIndex, entry, properties, numSummons, personalSpawn);
break;
}
switch (properties->Type)
@@ -2407,18 +2408,18 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
case SUMMON_TYPE_GUARDIAN:
case SUMMON_TYPE_GUARDIAN2:
case SUMMON_TYPE_MINION:
SummonGuardian(effIndex, entry, properties, numSummons);
SummonGuardian(effIndex, entry, properties, numSummons, personalSpawn);
break;
// Summons a vehicle, but doesn't force anyone to enter it (see SUMMON_CATEGORY_VEHICLE)
case SUMMON_TYPE_VEHICLE:
case SUMMON_TYPE_VEHICLE2:
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn);
break;
case SUMMON_TYPE_LIGHTWELL:
case SUMMON_TYPE_TOTEM:
{
// protection code
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn);
if (!summon || !summon->IsTotem())
return;
@@ -2436,7 +2437,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
case SUMMON_TYPE_JEEVES:
case SUMMON_TYPE_MINIPET:
{
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn);
if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
return;
@@ -2470,7 +2471,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
// randomize position for multiple summons
pos = m_caster->GetRandomPoint(*destTarget, radius);
summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration);
summon = m_originalCaster->SummonCreature(entry, pos, summonType, duration, 0, nullptr, personalSpawn);
if (!summon)
continue;
@@ -2492,10 +2493,10 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
// Xinef: SummonGuardian function can summon a few npcs of same type, remove old summons with same entry here
if (m_originalCaster)
m_originalCaster->RemoveAllMinionsByEntry(entry);
SummonGuardian(effIndex, entry, properties, numSummons);
SummonGuardian(effIndex, entry, properties, numSummons, personalSpawn);
break;
case SUMMON_CATEGORY_PUPPET:
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id);
summon = m_caster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_originalCaster, m_spellInfo->Id, 0, personalSpawn);
break;
case SUMMON_CATEGORY_VEHICLE:
// Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker
@@ -2506,7 +2507,7 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
if (std::fabs(m_caster->GetPositionZ() - destTarget->GetPositionZ()) > 6.0f)
destTarget->m_positionZ = m_caster->GetPositionZ();
summon = m_originalCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_caster, m_spellInfo->Id);
summon = m_originalCaster->GetMap()->SummonCreature(entry, *destTarget, properties, duration, m_caster, m_spellInfo->Id, 0, personalSpawn);
if (!summon || !summon->IsVehicle())
return;
@@ -3176,7 +3177,7 @@ void Spell::EffectSummonPet(SpellEffIndex effIndex)
// Xinef: unsummon old guardian
if (Guardian* oldPet = m_originalCaster->GetGuardianPet())
oldPet->UnSummon();
SummonGuardian(effIndex, petentry, properties, 1);
SummonGuardian(effIndex, petentry, properties, 1, false);
}
return;
}
@@ -6005,7 +6006,7 @@ void Spell::EffectGameObjectSetDestructionState(SpellEffIndex effIndex)
gameObjTarget->SetDestructibleState(GameObjectDestructibleState(m_spellInfo->Effects[effIndex].MiscValue), player, true);
}
void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numGuardians)
void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const* properties, uint32 numGuardians, bool personalSpawn)
{
Unit* caster = m_originalCaster;
if (!caster)
@@ -6105,7 +6106,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const*
pos = m_caster->GetRandomPoint(*destTarget, radius);
}
summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id);
summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id, 0, personalSpawn);
if (!summon)
return;