Core/Units: Fixed totem timer UI

Closes #298
Closes #1595
This commit is contained in:
Shauren
2011-05-19 18:50:57 +02:00
parent 69376d0e1c
commit 49a81557fa
4 changed files with 43 additions and 78 deletions
+2 -1
View File
@@ -2067,7 +2067,7 @@ void WorldObject::AddObjectToRemoveList()
map->AddObjectToRemoveList(this); 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; uint32 mask = UNIT_MASK_SUMMON;
if (properties) if (properties)
@@ -2128,6 +2128,7 @@ TempSummon *Map::SummonCreature(uint32 entry, const Position &pos, SummonPropert
summon->SetHomePosition(pos); summon->SetHomePosition(pos);
summon->InitStats(duration); summon->InitStats(duration);
if (addToWorld)
Add(summon->ToCreature()); Add(summon->ToCreature());
summon->InitSummon(); summon->InitSummon();
+13 -48
View File
@@ -54,45 +54,9 @@ void Totem::InitStats(uint32 duration)
{ {
Minion::InitStats(duration); Minion::InitStats(duration);
CreatureTemplate const *cinfo = GetCreatureInfo(); if (m_owner->GetTypeId() == TYPEID_PLAYER)
if (m_owner->GetTypeId() == TYPEID_PLAYER && cinfo) // set display id depending on race
{ SetDisplayId(m_owner->GetModelForTotem(PlayerTotemType(m_Properties->Id)));
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);
}
// Get spell casted by totem // Get spell casted by totem
SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell()); SpellEntry const * totemSpell = sSpellStore.LookupEntry(GetSpell());
@@ -139,19 +103,20 @@ void Totem::UnSummon()
m_owner->RemoveAurasDueToSpell(GetSpell()); m_owner->RemoveAurasDueToSpell(GetSpell());
//remove aura all party members too //remove aura all party members too
Group *pGroup = NULL; if (Player* owner = m_owner->ToPlayer())
if (m_owner->GetTypeId() == TYPEID_PLAYER)
{ {
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) // Not only the player can summon the totem (scripted AI)
pGroup = m_owner->ToPlayer()->GetGroup(); Group* group = owner->GetGroup();
if (pGroup) 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(); Player* target = itr->getSource();
if (Target && pGroup->SameSubGroup((Player*)m_owner, Target)) if (target && group->SameSubGroup(owner, target))
Target->RemoveAurasDueToSpell(GetSpell()); target->RemoveAurasDueToSpell(GetSpell());
} }
} }
} }
+1 -1
View File
@@ -428,7 +428,7 @@ class Map : public GridRefManager<NGridType>
void UpdateIteratorBack(Player *player); 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); Creature* GetCreature(uint64 guid);
GameObject* GetGameObject(uint64 guid); GameObject* GetGameObject(uint64 guid);
DynamicObject* GetDynamicObject(uint64 guid); DynamicObject* GetDynamicObject(uint64 guid);
+9 -10
View File
@@ -3018,9 +3018,9 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
break; break;
case SUMMON_TYPE_TOTEM: case SUMMON_TYPE_TOTEM:
{ {
summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster); summon = m_caster->GetMap()->SummonCreature(entry, pos, properties, duration, m_originalCaster, 0, false);
if (!summon || !summon->isTotem()) if (summon && summon->isTotem())
return; {
// Mana Tide Totem // Mana Tide Totem
if (m_spellInfo->Id == 16190) if (m_spellInfo->Id == 16190)
@@ -3036,19 +3036,18 @@ void Spell::EffectSummonType(SpellEffIndex effIndex)
&& properties->Slot >= SUMMON_SLOT_TOTEM && properties->Slot >= SUMMON_SLOT_TOTEM
&& properties->Slot < MAX_TOTEM_SLOT) && 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); WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
data << uint8(properties->Slot - 1); data << uint8(properties->Slot - 1);
data << uint64(m_originalCaster->GetGUID()); data << uint64(summon->GetGUID());
data << uint32(duration); data << uint32(duration);
data << uint32(m_spellInfo->Id); data << uint32(m_spellInfo->Id);
m_originalCaster->ToPlayer()->SendDirectMessage(&data); 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; break;
} }
case SUMMON_TYPE_MINIPET: case SUMMON_TYPE_MINIPET: