Core/Spells: Moved setting UNIT_CREATED_BY_SPELL out of spell effect handlers and sending SMSG_TOTEM_CREATED into Totem class

This commit is contained in:
Shauren
2011-05-19 22:27:18 +02:00
parent f03bdceaff
commit ac4ed1efdf
7 changed files with 109 additions and 90 deletions

View File

@@ -3014,45 +3014,28 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
// 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, pos, properties, duration, m_originalCaster);
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id);
break;
case SUMMON_TYPE_TOTEM:
{
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, 0, false);
if (summon && summon->isTotem())
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id);
if (!summon || !summon->isTotem())
return;
// Mana Tide Totem
if (m_spellInfo->Id == 16190)
damage = m_caster->CountPctFromMaxHealth(10);
if (damage) // if not spell info, DB values used
{
// Mana Tide Totem
if (m_spellInfo->Id == 16190)
damage = m_caster->CountPctFromMaxHealth(10);
if (damage) // if not spell info, DB values used
{
summon->SetMaxHealth(damage);
summon->SetHealth(damage);
}
if (m_originalCaster->GetTypeId() == TYPEID_PLAYER
&& properties->Slot >= SUMMON_SLOT_TOTEM
&& properties->Slot < MAX_TOTEM_SLOT)
{
WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
data << uint8(properties->Slot - 1);
data << uint64(summon->GetGUID());
data << uint32(duration);
data << uint32(m_spellInfo->Id);
m_originalCaster->ToPlayer()->SendDirectMessage(&data);
}
summon->SetMaxHealth(damage);
summon->SetHealth(damage);
}
// client requires SMSG_TOTEM_CREATED to be sent before CreateObject and at the same time
// expects the summon's GUID so adding to world must be delayed
if (summon)
m_caster->GetMap()->Add(summon->ToCreature());
break;
}
case SUMMON_TYPE_MINIPET:
{
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id);
if (!summon || !summon->HasUnitTypeMask(UNIT_MASK_MINION))
return;
@@ -3105,14 +3088,14 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
SummonGuardian(effIndex, entry, properties);
break;
case SUMMON_CATEGORY_PUPPET:
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster);
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id);
break;
case SUMMON_CATEGORY_VEHICLE:
// Summoning spells (usually triggered by npc_spellclick) that spawn a vehicle and that cause the clicker
// to cast a ride vehicle spell on the summoned unit.
float x, y, z;
m_caster->GetClosePoint(x, y, z, DEFAULT_WORLD_OBJECT_SIZE);
summon = m_originalCaster->GetMap()->SummonCreature(entry, pos, properties, duration, m_caster);
summon = m_originalCaster->GetMap()->SummonCreature(entry, pos, properties, duration, m_caster, m_spellInfo->Id);
if (!summon || !summon->IsVehicle())
return;
@@ -3134,7 +3117,6 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
if (summon)
{
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
summon->SetCreatorGUID(m_originalCaster->GetGUID());
ExecuteLogEffectSummonObject(effIndex, summon);
}
@@ -6882,7 +6864,7 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *
Position pos;
GetSummonPosition(i, pos, radius, count);
TempSummon *summon = map->SummonCreature(entry, pos, properties, duration, caster);
TempSummon *summon = map->SummonCreature(entry, pos, properties, duration, caster, m_spellInfo->Id);
if (!summon)
return;
if (summon->HasUnitTypeMask(UNIT_MASK_GUARDIAN))
@@ -6891,7 +6873,6 @@ void Spell::SummonGuardian(uint32 i, uint32 entry, SummonPropertiesEntry const *
if (properties && properties->Category == SUMMON_CATEGORY_ALLY)
summon->setFaction(caster->getFaction());
summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, m_spellInfo->Id);
if (summon->HasUnitTypeMask(UNIT_MASK_MINION) && m_targets.HasDst())
((Minion*)summon)->SetFollowAngle(m_caster->GetAngle(summon));