[10834] Cleanup shapeshift form code.

This commit is contained in:
VladimirMangos 2010-12-07 14:01:12 +03:00
parent c3254c88ca
commit 4c02094737
10 changed files with 56 additions and 53 deletions

View file

@ -1500,7 +1500,7 @@ void Player::SetDeathState(DeathState s)
clearResurrectRequestData();
// remove form before other mods to prevent incorrect stats calculation
RemoveAurasDueToSpell(m_ShapeShiftFormSpellId);
RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);
//FIXME: is pet dismissed at dying or releasing spirit? if second, add SetDeathState(DEAD) to HandleRepopRequestOpcode and define pet unsummon here with (s == DEAD)
RemovePet(PET_SAVE_REAGENTS);
@ -3351,8 +3351,9 @@ bool Player::IsNeedCastPassiveSpellAtLearn(SpellEntry const* spellInfo) const
{
// note: form passives activated with shapeshift spells be implemented by HandleShapeshiftBoosts instead of spell_learn_spell
// talent dependent passives activated at form apply have proper stance data
bool need_cast = (!spellInfo->Stances || (m_form != 0 && (spellInfo->Stances & (1<<(m_form-1)))) ||
(m_form == 0 && (spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT)));
ShapeshiftForm form = GetShapeshiftForm();
bool need_cast = (!spellInfo->Stances || (form && (spellInfo->Stances & (1 << (form - 1)))) ||
(!form && (spellInfo->AttributesEx2 & SPELL_ATTR_EX2_NOT_NEED_SHAPESHIFT)));
// Check CasterAuraStates
return need_cast && (!spellInfo->CasterAuraState || HasAuraState(AuraState(spellInfo->CasterAuraState)));
@ -5534,10 +5535,10 @@ void Player::UpdateWeaponSkill (WeaponAttackType attType)
if(pVictim && pVictim->IsCharmerOrOwnerPlayerOrPlayerItself())
return;
if(IsInFeralForm())
if (IsInFeralForm())
return; // always maximized SKILL_FERAL_COMBAT in fact
if(m_form == FORM_TREE)
if (GetShapeshiftForm() == FORM_TREE)
return; // use weapon but not skill up
uint32 weapon_skill_gain = sWorld.getConfig(CONFIG_UINT32_SKILL_GAIN_WEAPON);
@ -7371,10 +7372,10 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
if(apply)
{
// Cannot be used in this stance/form
if(GetErrorAtShapeshiftedCast(spellInfo, m_form) != SPELL_CAST_OK)
if (GetErrorAtShapeshiftedCast(spellInfo, GetShapeshiftForm()) != SPELL_CAST_OK)
return;
if(form_change) // check aura active state from other form
if (form_change) // check aura active state from other form
{
bool found = false;
for (int k=0; k < MAX_EFFECT_INDEX; ++k)
@ -7402,14 +7403,14 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
}
else
{
if(form_change) // check aura compatibility
if (form_change) // check aura compatibility
{
// Cannot be used in this stance/form
if(GetErrorAtShapeshiftedCast(spellInfo, m_form)==SPELL_CAST_OK)
if (GetErrorAtShapeshiftedCast(spellInfo, GetShapeshiftForm()) == SPELL_CAST_OK)
return; // and remove only not compatible at form change
}
if(item)
if (item)
RemoveAurasDueToItemSpell(item,spellInfo->Id); // un-apply all spells , not only at-equipped
else
RemoveAurasDueToSpell(spellInfo->Id); // un-apply spell (item set case)
@ -18311,10 +18312,10 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
return false;
// taximaster case
if(npc)
if (npc)
{
// not let cheating with start flight mounted
if(IsMounted())
if (IsMounted())
{
WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4);
data << uint32(ERR_TAXIPLAYERALREADYMOUNTED);
@ -18322,7 +18323,7 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
return false;
}
if( m_ShapeShiftFormSpellId && m_form != FORM_BATTLESTANCE && m_form != FORM_BERSERKERSTANCE && m_form != FORM_DEFENSIVESTANCE && m_form != FORM_SHADOW )
if (IsInDisallowedMountForm())
{
WorldPacket data(SMSG_ACTIVATETAXIREPLY, 4);
data << uint32(ERR_TAXIPLAYERSHAPESHIFTED);
@ -18344,8 +18345,8 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
{
RemoveSpellsCausingAura(SPELL_AURA_MOUNTED);
if( m_ShapeShiftFormSpellId && m_form != FORM_BATTLESTANCE && m_form != FORM_BERSERKERSTANCE && m_form != FORM_DEFENSIVESTANCE && m_form != FORM_SHADOW )
RemoveAurasDueToSpell(m_ShapeShiftFormSpellId);
if (IsInDisallowedMountForm())
RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT);
if (Spell* spell = GetCurrentSpell(CURRENT_GENERIC_SPELL))
if (spell->m_spellInfo->Id != spellid)
@ -18587,7 +18588,9 @@ void Player::ProhibitSpellSchool(SpellSchoolMask idSchoolMask, uint32 unTimeMs )
void Player::InitDataForForm(bool reapplyMods)
{
SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(m_form);
ShapeshiftForm form = GetShapeshiftForm();
SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(form);
if(ssEntry && ssEntry->attackSpeed)
{
SetAttackTime(BASE_ATTACK,ssEntry->attackSpeed);
@ -18597,7 +18600,7 @@ void Player::InitDataForForm(bool reapplyMods)
else
SetRegularAttackTime();
switch(m_form)
switch(form)
{
case FORM_CAT:
{