diff options
-rwxr-xr-x | src/server/game/Entities/Object/Object.cpp | 5 | ||||
-rwxr-xr-x | src/server/game/Entities/Totem/Totem.cpp | 61 | ||||
-rwxr-xr-x | src/server/game/Maps/Map.h | 2 | ||||
-rwxr-xr-x | src/server/game/Spells/SpellEffects.cpp | 53 |
4 files changed, 43 insertions, 78 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 907d62ad5e8..8b4efe51de7 100755 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -2067,7 +2067,7 @@ void WorldObject::AddObjectToRemoveList() map->AddObjectToRemoveList(this); } -TempSummon *Map::SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties, uint32 duration, Unit *summoner, uint32 vehId) +TempSummon* Map::SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties /*= NULL*/, uint32 duration /*= 0*/, Unit *summoner /*= NULL*/, uint32 vehId /*= 0*/, bool addToWorld /*= false*/) { uint32 mask = UNIT_MASK_SUMMON; if (properties) @@ -2128,7 +2128,8 @@ TempSummon *Map::SummonCreature(uint32 entry, const Position &pos, SummonPropert summon->SetHomePosition(pos); summon->InitStats(duration); - Add(summon->ToCreature()); + if (addToWorld) + Add(summon->ToCreature()); summon->InitSummon(); //ObjectAccessor::UpdateObjectVisibility(summon); diff --git a/src/server/game/Entities/Totem/Totem.cpp b/src/server/game/Entities/Totem/Totem.cpp index b216d3e344c..63ae2dd9bda 100755 --- a/src/server/game/Entities/Totem/Totem.cpp +++ b/src/server/game/Entities/Totem/Totem.cpp @@ -54,45 +54,9 @@ void Totem::InitStats(uint32 duration) { Minion::InitStats(duration); - CreatureTemplate const *cinfo = GetCreatureInfo(); - if (m_owner->GetTypeId() == TYPEID_PLAYER && cinfo) - { - uint32 displayID = sObjectMgr->ChooseDisplayId(m_owner->ToPlayer()->GetTeam(), cinfo); - sObjectMgr->GetCreatureModelRandomGender(&displayID); - switch (m_owner->ToPlayer()->GetTeam()) - { - case ALLIANCE: - displayID = cinfo->Modelid1; - break; - case HORDE: - if (cinfo->Modelid3) - displayID = cinfo->Modelid3; - else - displayID = cinfo->Modelid1; - - switch (((Player*)m_owner)->getRace()) - { - case RACE_ORC: - if (cinfo->Modelid2) - displayID = cinfo->Modelid2; - else - displayID = cinfo->Modelid1; - break; - case RACE_TROLL: - if (cinfo->Modelid4) - displayID = cinfo->Modelid4; - else - displayID = cinfo->Modelid1; - break; - default: - break; - } - break; - default: - break; - } - SetDisplayId(displayID); - } + 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()); @@ -139,19 +103,20 @@ void Totem::UnSummon() m_owner->RemoveAurasDueToSpell(GetSpell()); //remove aura all party members too - Group *pGroup = NULL; - if (m_owner->GetTypeId() == TYPEID_PLAYER) + if (Player* owner = m_owner->ToPlayer()) { - m_owner->ToPlayer()->SendAutoRepeatCancel(this); + 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) - pGroup = m_owner->ToPlayer()->GetGroup(); - if (pGroup) + Group* group = owner->GetGroup(); + if (group) { - for (GroupReference *itr = pGroup->GetFirstMember(); itr != NULL; itr = itr->next()) + for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next()) { - Player* Target = itr->getSource(); - if (Target && pGroup->SameSubGroup((Player*)m_owner, Target)) - Target->RemoveAurasDueToSpell(GetSpell()); + Player* target = itr->getSource(); + if (target && group->SameSubGroup(owner, target)) + target->RemoveAurasDueToSpell(GetSpell()); } } } diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h index bf4ba4aade9..27ef86ac2a3 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); + TempSummon *SummonCreature(uint32 entry, const Position &pos, SummonPropertiesEntry const *properties = NULL, uint32 duration = 0, Unit *summoner = NULL, uint32 vehId = 0, bool addToWorld = true); 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 3b96476878c..70fbd92849c 100755 --- a/src/server/game/Spells/SpellEffects.cpp +++ b/src/server/game/Spells/SpellEffects.cpp @@ -3018,37 +3018,36 @@ void Spell::EffectSummonType(SpellEffIndex effIndex) break; case SUMMON_TYPE_TOTEM: { - summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster); - if (!summon || !summon->isTotem()) - return; + 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); + // 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 (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) - { - // set display id depending on race - uint32 displayId = m_originalCaster->GetModelForTotem(PlayerTotemType(properties->Id)); - summon->SetNativeDisplayId(displayId); - summon->SetDisplayId(displayId); - - //summon->SendUpdateToPlayerm_originalCaster->ToPlayer(); - WorldPacket data(SMSG_TOTEM_CREATED, 1+8+4+4); - data << uint8(properties->Slot-1); - data << uint64(m_originalCaster->GetGUID()); - data << uint32(duration); - data << uint32(m_spellInfo->Id); - m_originalCaster->ToPlayer()->SendDirectMessage(&data); + 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); + } } + // 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: |