[9475] Add and use TotemSlot enum type

This commit is contained in:
VladimirMangos 2010-02-28 07:18:43 +03:00
parent 7e2d7d8324
commit ded1e3c263
10 changed files with 85 additions and 82 deletions

View file

@ -2214,10 +2214,7 @@ void Spell::EffectDummy(SpellEffectIndex eff_idx)
if (m_spellInfo->SpellIconID == 33)
{
// fire totems slot
if (!m_caster->m_TotemSlot[0])
return;
Creature* totem = m_caster->GetMap()->GetCreature(m_caster->m_TotemSlot[0]);
Totem* totem = m_caster->GetTotem(TOTEM_SLOT_FIRE);
if (!totem)
return;
@ -6267,20 +6264,15 @@ void Spell::EffectApplyGlyph(SpellEffectIndex eff_idx)
}
}
void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot)
void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot_dbc)
{
slot = slot ? (slot - 1): 255;
// DBC store slots starting from 1, with no slot 0 value)
int slot = slot_dbc ? slot_dbc - 1 : TOTEM_SLOT_NONE;
if(slot < MAX_TOTEM)
{
uint64 guid = m_caster->m_TotemSlot[slot];
if(guid != 0)
{
Creature *OldTotem = m_caster->GetMap()->GetCreature(guid);
if(OldTotem && OldTotem->isTotem())
((Totem*)OldTotem)->UnSummon();
}
}
// unsummon old totem
if(slot < MAX_TOTEM_SLOT)
if (Totem *OldTotem = m_caster->GetTotem(TotemSlot(slot)))
OldTotem->UnSummon();
uint32 team = 0;
if (m_caster->GetTypeId()==TYPEID_PLAYER)
@ -6295,7 +6287,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot)
return;
}
float angle = slot < MAX_TOTEM ? M_PI_F/MAX_TOTEM - (slot*2*M_PI_F/MAX_TOTEM) : 0;
float angle = slot < MAX_TOTEM_SLOT ? M_PI_F/MAX_TOTEM_SLOT - (slot*2*M_PI_F/MAX_TOTEM_SLOT) : 0;
float x, y, z;
m_caster->GetClosePoint(x, y, z, pTotem->GetObjectSize(), 2.0f, angle);
@ -6306,14 +6298,14 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot)
pTotem->Relocate(x, y, z, m_caster->GetOrientation());
if(slot < MAX_TOTEM)
m_caster->m_TotemSlot[slot] = pTotem->GetGUID();
if (slot < MAX_TOTEM_SLOT)
m_caster->_AddTotem(TotemSlot(slot),pTotem);
pTotem->SetOwner(m_caster->GetGUID());
pTotem->SetTypeBySummonSpell(m_spellInfo); // must be after Create call where m_spells initilized
int32 duration=GetSpellDuration(m_spellInfo);
if(Player* modOwner = m_caster->GetSpellModOwner())
if (Player* modOwner = m_caster->GetSpellModOwner())
modOwner->ApplySpellMod(m_spellInfo->Id, SPELLMOD_DURATION, duration);
pTotem->SetDuration(duration);
@ -6336,7 +6328,7 @@ void Spell::DoSummonTotem(SpellEffectIndex eff_idx, uint8 slot)
pTotem->Summon(m_caster);
if(slot < MAX_TOTEM && m_caster->GetTypeId() == TYPEID_PLAYER)
if (slot < MAX_TOTEM_SLOT && m_caster->GetTypeId() == TYPEID_PLAYER)
{
WorldPacket data(SMSG_TOTEM_CREATED, 1 + 8 + 4 + 4);
data << uint8(slot);
@ -6938,22 +6930,17 @@ void Spell::EffectSummonAllTotems(SpellEffectIndex eff_idx)
void Spell::EffectDestroyAllTotems(SpellEffectIndex /*eff_idx*/)
{
int32 mana = 0;
for(int slot = 0; slot < MAX_TOTEM; ++slot)
for(int slot = 0; slot < MAX_TOTEM_SLOT; ++slot)
{
if(!m_caster->m_TotemSlot[slot])
continue;
Creature* totem = m_caster->GetMap()->GetCreature(m_caster->m_TotemSlot[slot]);
if(totem && totem->isTotem())
if (Totem* totem = m_caster->GetTotem(TotemSlot(slot)))
{
uint32 spell_id = totem->GetUInt32Value(UNIT_CREATED_BY_SPELL);
SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id);
if(spellInfo)
if (SpellEntry const* spellInfo = sSpellStore.LookupEntry(spell_id))
{
uint32 manacost = m_caster->GetCreateMana() * spellInfo->ManaCostPercentage / 100;
mana += manacost * damage / 100;
}
((Totem*)totem)->UnSummon();
totem->UnSummon();
}
}