diff options
author | Shauren <shauren.trinity@gmail.com> | 2011-05-19 22:27:18 +0200 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2011-05-19 22:27:18 +0200 |
commit | ac4ed1efdf2d800ab2ea605fac982c9436cfba1b (patch) | |
tree | 93a7af028452062695f6ad09c29f1c1fb4cb299f /src | |
parent | f03bdceaff76d8488cb683a80ac3fd6149c6299b (diff) |
Core/Spells: Moved setting UNIT_CREATED_BY_SPELL out of spell effect handlers and sending SMSG_TOTEM_CREATED into Totem class
Diffstat (limited to 'src')
-rwxr-xr-x | src/server/game/Entities/Object/Object.cpp | 95 | ||||
-rwxr-xr-x | src/server/game/Entities/Player/Player.cpp | 3 | ||||
-rwxr-xr-x | src/server/game/Entities/Totem/Totem.cpp | 37 | ||||
-rwxr-xr-x | src/server/game/Entities/Totem/Totem.h | 6 | ||||
-rwxr-xr-x | src/server/game/Maps/Map.h | 2 | ||||
-rwxr-xr-x | src/server/game/Spells/SpellEffects.cpp | 49 | ||||
-rwxr-xr-x | src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp | 5 |
7 files changed, 108 insertions, 89 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 8b4efe51de7..58620cd9cd5 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2067,40 +2067,57 @@ void WorldObject::AddObjectToRemoveList() map->AddObjectToRemoveList(this); } -TempSummon* Map::SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties /*= NULL*/, uint32 duration /*= 0*/, Unit *summoner /*= NULL*/, uint32 vehId /*= 0*/, bool addToWorld /*= false*/) +TempSummon* Map::SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties /*= NULL*/, uint32 duration /*= 0*/, Unit* summoner /*= NULL*/, uint32 spellId /*= 0*/, uint32 vehId /*= 0*/) { uint32 mask = UNIT_MASK_SUMMON; if (properties) { - switch(properties->Category) + switch (properties->Category) { - case SUMMON_CATEGORY_PET: mask = UNIT_MASK_GUARDIAN; break; - case SUMMON_CATEGORY_PUPPET: mask = UNIT_MASK_PUPPET; break; - case SUMMON_CATEGORY_VEHICLE: mask = UNIT_MASK_MINION; break; - default: - switch(properties->Type) + case SUMMON_CATEGORY_PET: + mask = UNIT_MASK_GUARDIAN; + break; + case SUMMON_CATEGORY_PUPPET: + mask = UNIT_MASK_PUPPET; + break; + case SUMMON_CATEGORY_VEHICLE: + mask = UNIT_MASK_MINION; + break; + case SUMMON_CATEGORY_WILD: + case SUMMON_CATEGORY_ALLY: + case SUMMON_CATEGORY_UNK: + { + switch (properties->Type) { - case SUMMON_TYPE_MINION: - case SUMMON_TYPE_GUARDIAN: - case SUMMON_TYPE_GUARDIAN2: - mask = UNIT_MASK_GUARDIAN; break; - case SUMMON_TYPE_TOTEM: - mask = UNIT_MASK_TOTEM; break; - case SUMMON_TYPE_VEHICLE: - case SUMMON_TYPE_VEHICLE2: - mask = UNIT_MASK_SUMMON; break; - case SUMMON_TYPE_MINIPET: - mask = UNIT_MASK_MINION; break; - default: - if (properties->Flags & 512) // Mirror Image, Summon Gargoyle - mask = UNIT_MASK_GUARDIAN; - break; + case SUMMON_TYPE_MINION: + case SUMMON_TYPE_GUARDIAN: + case SUMMON_TYPE_GUARDIAN2: + mask = UNIT_MASK_GUARDIAN; + break; + case SUMMON_TYPE_TOTEM: + mask = UNIT_MASK_TOTEM; + break; + case SUMMON_TYPE_VEHICLE: + case SUMMON_TYPE_VEHICLE2: + mask = UNIT_MASK_SUMMON; + break; + case SUMMON_TYPE_MINIPET: + mask = UNIT_MASK_MINION; + break; + default: + if (properties->Flags & 512) // Mirror Image, Summon Gargoyle + mask = UNIT_MASK_GUARDIAN; + break; } break; + } + default: + return NULL; } } - uint32 phase = PHASEMASK_NORMAL, team = 0; + uint32 phase = PHASEMASK_NORMAL; + uint32 team = 0; if (summoner) { phase = summoner->GetPhaseMask(); @@ -2108,15 +2125,26 @@ TempSummon* Map::SummonCreature(uint32 entry, const Position &pos, SummonPropert team = summoner->ToPlayer()->GetTeam(); } - TempSummon *summon = NULL; - switch(mask) + TempSummon* summon = NULL; + switch (mask) { - case UNIT_MASK_SUMMON: summon = new TempSummon (properties, summoner); break; - case UNIT_MASK_GUARDIAN: summon = new Guardian (properties, summoner); break; - case UNIT_MASK_PUPPET: summon = new Puppet (properties, summoner); break; - case UNIT_MASK_TOTEM: summon = new Totem (properties, summoner); break; - case UNIT_MASK_MINION: summon = new Minion (properties, summoner); break; - default: return NULL; + case UNIT_MASK_SUMMON: + summon = new TempSummon(properties, summoner); + break; + case UNIT_MASK_GUARDIAN: + summon = new Guardian(properties, summoner); + break; + case UNIT_MASK_PUPPET: + summon = new Puppet(properties, summoner); + break; + case UNIT_MASK_TOTEM: + summon = new Totem(properties, summoner); + break; + case UNIT_MASK_MINION: + summon = new Minion(properties, summoner); + break; + default: + return NULL; } if (!summon->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), this, phase, entry, vehId, team, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), pos.GetOrientation())) @@ -2125,11 +2153,12 @@ TempSummon* Map::SummonCreature(uint32 entry, const Position &pos, SummonPropert return NULL; } + summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, spellId); + summon->SetHomePosition(pos); summon->InitStats(duration); - if (addToWorld) - Add(summon->ToCreature()); + Add(summon->ToCreature()); summon->InitSummon(); //ObjectAccessor::UpdateObjectVisibility(summon); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 0684e6a1e9b..25d808c7501 100755 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -6754,8 +6754,7 @@ void Player::SendMessageToSet(WorldPacket *data, Player const* skipped_rcvr) void Player::SendDirectMessage(WorldPacket *data) { - if (m_session) - m_session->SendPacket(data); + m_session->SendPacket(data); } void Player::SendCinematicStart(uint32 CinematicSequenceId) diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index 63ae2dd9bda..cc2b272625b 100755 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -24,7 +24,7 @@ #include "ObjectMgr.h" #include "SpellMgr.h" -Totem::Totem(SummonPropertiesEntry const *properties, Unit *owner) : Minion(properties, owner) +Totem::Totem(SummonPropertiesEntry const* properties, Unit* owner) : Minion(properties, owner) { m_unitTypeMask |= UNIT_MASK_TOTEM; m_duration = 0; @@ -54,18 +54,14 @@ void Totem::InitStats(uint32 duration) { Minion::InitStats(duration); + // set display id depending on caster's race if (m_owner->GetTypeId() == TYPEID_PLAYER) - // set display id depending on race SetDisplayId(m_owner->GetModelForTotem(PlayerTotemType(m_Properties->Id))); - // Get spell casted by totem - SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell()); - if (totemSpell) - { - // If spell have cast time -> so its active totem - if (GetSpellCastTime(totemSpell)) + // Get spell cast by totem + if (SpellEntry const* totemSpell = sSpellStore.LookupEntry(GetSpell())) + if (GetSpellCastTime(totemSpell)) // If spell has cast time -> its an active totem m_type = TOTEM_ACTIVE; - } if (GetEntry() == SENTRY_TOTEM_ENTRY) SetReactState(REACT_AGGRESSIVE); @@ -73,6 +69,19 @@ void Totem::InitStats(uint32 duration) m_duration = duration; SetLevel(m_owner->getLevel()); + + // client requires SMSG_TOTEM_CREATED to be sent before adding to world + if (m_owner->GetTypeId() == TYPEID_PLAYER + && m_Properties->Slot >= SUMMON_SLOT_TOTEM + && m_Properties->Slot < MAX_TOTEM_SLOT) + { + WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4); + data << uint8(m_Properties->Slot - 1); + data << uint64(GetGUID()); + data << uint32(duration); + data << uint32(GetUInt32Value(UNIT_CREATED_BY_SPELL)); + m_owner->ToPlayer()->SendDirectMessage(&data); + } } void Totem::InitSummon() @@ -106,11 +115,11 @@ void Totem::UnSummon() if (Player* owner = m_owner->ToPlayer()) { owner->SendAutoRepeatCancel(this); + if (SpellEntry const* spell = sSpellStore.LookupEntry(GetUInt32Value(UNIT_CREATED_BY_SPELL))) owner->SendCooldownEvent(spell); - // Not only the player can summon the totem (scripted AI) - Group* group = owner->GetGroup(); - if (group) + + if (Group* group = owner->GetGroup()) { for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { @@ -129,7 +138,8 @@ bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) co // TODO: possibly all negative auras immune? if (GetEntry() == 5925) return false; - switch(spellInfo->EffectApplyAuraName[index]) + + switch (spellInfo->EffectApplyAuraName[index]) { case SPELL_AURA_PERIODIC_DAMAGE: case SPELL_AURA_PERIODIC_LEECH: @@ -139,5 +149,6 @@ bool Totem::IsImmunedToSpellEffect(SpellEntry const* spellInfo, uint32 index) co default: break; } + return Creature::IsImmunedToSpellEffect(spellInfo, index); } diff --git a/src/server/game/Entities/Totem/Totem.h b/src/server/game/Entities/Totem/Totem.h index c8ee245d3fa..f1105f2a917 100755 --- a/src/server/game/Entities/Totem/Totem.h +++ b/src/server/game/Entities/Totem/Totem.h @@ -33,13 +33,13 @@ enum TotemType class Totem : public Minion { public: - explicit Totem(SummonPropertiesEntry const *properties, Unit *owner); - virtual ~Totem(){}; + Totem(SummonPropertiesEntry const* properties, Unit* owner); + virtual ~Totem() {} void Update(uint32 time); void InitStats(uint32 duration); void InitSummon(); void UnSummon(); - uint32 GetSpell(uint8 slot=0) const { return m_spells[slot]; } + uint32 GetSpell(uint8 slot = 0) const { return m_spells[slot]; } uint32 GetTotemDuration() const { return m_duration; } TotemType GetTotemType() const { return m_type; } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index 27ef86ac2a3..57372c0c259 100755 --- a/src/server/game/Maps/Map.h +++ b/src/server/game/Maps/Map.h @@ -428,7 +428,7 @@ class Map : public GridRefManager<NGridType> void UpdateIteratorBack(Player *player); - TempSummon *SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties = NULL, uint32 duration = 0, Unit *summoner = NULL, uint32 vehId = 0, bool addToWorld = true); + TempSummon* SummonCreature(uint32 entry, Position const& pos, SummonPropertiesEntry const* properties = NULL, uint32 duration = 0, Unit* summoner = NULL, uint32 spellId = 0, uint32 vehId = 0); Creature* GetCreature(uint64 guid); GameObject* GetGameObject(uint64 guid); DynamicObject* GetDynamicObject(uint64 guid); diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp index 70fbd92849c..45ba65252a6 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -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()) - { - - // Mana Tide Totem - if (m_spellInfo->Id == 16190) - damage = m_caster->CountPctFromMaxHealth(10); + summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, m_spellInfo->Id); + if (!summon || !summon->isTotem()) + return; - if (damage) // if not spell info, DB values used - { - summon->SetMaxHealth(damage); - summon->SetHealth(damage); - } + // Mana Tide Totem + if (m_spellInfo->Id == 16190) + damage = m_caster->CountPctFromMaxHealth(10); - 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); - } + if (damage) // if not spell info, DB values used + { + 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)); diff --git a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp index 9db92d10d6c..2844376fe21 100755 --- a/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp +++ b/src/server/scripts/Northrend/IcecrownCitadel/boss_professor_putricide.cpp @@ -1397,16 +1397,15 @@ class spell_putricide_mutated_transformation : public SpellScriptLoader Position pos; caster->GetPosition(&pos); - TempSummon* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster); + TempSummon* summon = caster->GetMap()->SummonCreature(entry, pos, properties, duration, caster, GetSpellInfo()->Id); if (!summon || !summon->IsVehicle()) return; caster->CastSpell(summon, SPELL_MUTATED_TRANSFORMATION_NAME, true); summon->CastSpell(summon, SPELL_ABOMINATION_VEHICLE_POWER_DRAIN, true); summon->CastSpell(summon, SPELL_MUTATED_TRANSFORMATION_DAMAGE, true); - caster->EnterVehicle(summon, 0); - summon->SetUInt32Value(UNIT_CREATED_BY_SPELL, GetSpellInfo()->Id); + caster->EnterVehicle(summon, 0); summon->SetCreatorGUID(caster->GetGUID()); putricide->AI()->JustSummoned(summon); } |