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
+3 -2
View File
@@ -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);
+13 -48
View File
@@ -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());
}
}
}