[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

@ -4717,8 +4717,8 @@ static bool HandleResetStatsOrLevelHelper(Player* player)
uint8 powertype = cEntry->powerType;
// reset m_form if no aura
if(!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
player->m_form = FORM_NONE;
if (!player->HasAuraType(SPELL_AURA_MOD_SHAPESHIFT))
player->SetShapeshiftForm(FORM_NONE);
player->SetFloatValue(UNIT_FIELD_BOUNDINGRADIUS, DEFAULT_WORLD_OBJECT_SIZE );
player->SetFloatValue(UNIT_FIELD_COMBATREACH, 1.5f );
@ -4728,11 +4728,10 @@ static bool HandleResetStatsOrLevelHelper(Player* player)
player->SetByteValue(UNIT_FIELD_BYTES_0, 3, powertype);
// reset only if player not in some form;
if(player->m_form==FORM_NONE)
if (player->GetShapeshiftForm() == FORM_NONE)
player->InitDisplayIds();
player->SetByteValue(UNIT_FIELD_BYTES_2, 1, UNIT_BYTE2_FLAG_PVP );
player->SetByteValue(UNIT_FIELD_BYTES_2, 3, player->m_form);
player->SetUInt32Value(UNIT_FIELD_FLAGS, UNIT_FLAG_PVP_ATTACKABLE);

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:
{

View file

@ -2860,7 +2860,7 @@ void Spell::cast(bool skipCheck)
case SPELLFAMILY_DRUID:
{
// Faerie Fire (Feral)
if (m_spellInfo->Id == 16857 && m_caster->m_form != FORM_CAT)
if (m_spellInfo->Id == 16857 && m_caster->GetShapeshiftForm() != FORM_CAT)
AddTriggeredSpell(60089);
// Berserk (Bear Mangle part)
else if (m_spellInfo->Id == 50334)
@ -4276,7 +4276,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (checkForm)
{
// Cannot be used in this stance/form
SpellCastResult shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->m_form);
SpellCastResult shapeError = GetErrorAtShapeshiftedCast(m_spellInfo, m_caster->GetShapeshiftForm());
if(shapeError != SPELL_CAST_OK)
return shapeError;
@ -5264,11 +5264,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_caster->GetTypeId() == TYPEID_PLAYER && !sMapStore.LookupEntry(m_caster->GetMapId())->IsMountAllowed() && !m_IsTriggeredSpell && !m_spellInfo->AreaGroupId)
return SPELL_FAILED_NO_MOUNTS_ALLOWED;
ShapeshiftForm form = m_caster->m_form;
if( form == FORM_CAT || form == FORM_TREE || form == FORM_TRAVEL ||
form == FORM_AQUA || form == FORM_BEAR || form == FORM_DIREBEAR ||
form == FORM_CREATUREBEAR || form == FORM_GHOSTWOLF || form == FORM_FLIGHT ||
form == FORM_FLIGHT_EPIC || form == FORM_MOONKIN || form == FORM_METAMORPHOSIS )
if (m_caster->IsInDisallowedMountForm())
return SPELL_FAILED_NOT_SHAPESHIFT;
break;

View file

@ -2563,7 +2563,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
{
if (apply)
{
if (target->m_form != FORM_CAT)
if (target->GetShapeshiftForm() != FORM_CAT)
return;
target->CastSpell(target, 62071, true);
@ -2648,7 +2648,7 @@ void Aura::HandleAuraDummy(bool apply, bool Real)
if (apply)
{
if (target->m_form != FORM_MOONKIN)
if (target->GetShapeshiftForm() != FORM_MOONKIN)
return;
target->CastSpell(target, spell_id, true);
@ -2966,10 +2966,7 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
if(apply)
{
// remove other shapeshift before applying a new one
if(target->m_ShapeShiftFormSpellId)
target->RemoveAurasDueToSpell(target->m_ShapeShiftFormSpellId, GetHolder());
target->SetByteValue(UNIT_FIELD_BYTES_2, 3, form);
target->RemoveSpellsCausingAura(SPELL_AURA_MOD_SHAPESHIFT, GetHolder());
if(modelid > 0)
target->SetDisplayId(modelid);
@ -3043,8 +3040,7 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
}
}
target->m_ShapeShiftFormSpellId = GetId();
target->m_form = form;
target->SetShapeshiftForm(form);
// a form can give the player a new castbar with some spells.. this is a clientside process..
// serverside just needs to register the new spells so that player isn't kicked as cheater
@ -3058,11 +3054,9 @@ void Aura::HandleAuraModShapeshift(bool apply, bool Real)
{
if(modelid > 0)
target->SetDisplayId(target->GetNativeDisplayId());
target->SetByteValue(UNIT_FIELD_BYTES_2, 3, FORM_NONE);
if(target->getClass() == CLASS_DRUID)
target->setPowerType(POWER_MANA);
target->m_ShapeShiftFormSpellId = 0;
target->m_form = FORM_NONE;
target->SetShapeshiftForm(FORM_NONE);
switch(form)
{

View file

@ -518,7 +518,7 @@ void Spell::EffectSchoolDMG(SpellEffectIndex effect_idx)
if (m_spellInfo->SpellFamilyFlags & UI64LIT(0x0000000200000000))
m_caster->CastCustomSpell(m_caster, 32409, &damage, 0, 0, true);
// Improved Mind Blast (Mind Blast in shadow form bonus)
else if (m_caster->m_form == FORM_SHADOW && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x00002000)))
else if (m_caster->GetShapeshiftForm() == FORM_SHADOW && (m_spellInfo->SpellFamilyFlags & UI64LIT(0x00002000)))
{
Unit::AuraList const& ImprMindBlast = m_caster->GetAurasByType(SPELL_AURA_ADD_FLAT_MODIFIER);
for(Unit::AuraList::const_iterator i = ImprMindBlast.begin(); i != ImprMindBlast.end(); ++i)

View file

@ -267,7 +267,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
case CLASS_ROGUE: val2 = level + GetStat(STAT_AGILITY) - 10.0f; break;
case CLASS_WARRIOR:val2 = level + GetStat(STAT_AGILITY) - 10.0f; break;
case CLASS_DRUID:
switch(m_form)
switch(GetShapeshiftForm())
{
case FORM_CAT:
case FORM_BEAR:
@ -292,10 +292,11 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
case CLASS_SHAMAN: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
case CLASS_DRUID:
{
ShapeshiftForm form = GetShapeshiftForm();
//Check if Predatory Strikes is skilled
float mLevelBonus = 0.0f;
float mBonusWeaponAtt = 0.0f;
switch(m_form)
switch(form)
{
case FORM_CAT:
case FORM_BEAR:
@ -323,7 +324,7 @@ void Player::UpdateAttackPowerAndDamage(bool ranged )
default: break;
}
switch(m_form)
switch(form)
{
case FORM_CAT:
val2 = GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f + mLevelBonus + m_baseFeralAP + mBonusWeaponAtt; break;

View file

@ -198,7 +198,6 @@ Unit::Unit()
m_extraAttacks = 0;
m_state = 0;
m_form = FORM_NONE;
m_deathState = ALIVE;
for (uint32 i = 0; i < CURRENT_MAX_SPELL; ++i)
@ -223,7 +222,6 @@ Unit::Unit()
m_detectInvisibilityMask = 0;
m_invisibilityMask = 0;
m_transform = 0;
m_ShapeShiftFormSpellId = 0;
m_canModifyStats = false;
for (int i = 0; i < MAX_SPELL_IMMUNITY; ++i)
@ -2070,7 +2068,7 @@ void Unit::CalculateDamageAbsorbAndResist(Unit *pCaster, SpellSchoolMask schoolM
if (spellProto->SpellIconID == 2253)
{
//reduces all damage taken while Stunned and in Cat Form
if (m_form == FORM_CAT && (unitflag & UNIT_FLAG_STUNNED))
if (GetShapeshiftForm() == FORM_CAT && (unitflag & UNIT_FLAG_STUNNED))
RemainingDamage -= RemainingDamage * currentAbsorb / 100;
continue;
}
@ -8908,7 +8906,7 @@ uint32 Unit::GetCreatureType() const
{
if(GetTypeId() == TYPEID_PLAYER)
{
SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(m_form);
SpellShapeshiftFormEntry const* ssEntry = sSpellShapeshiftFormStore.LookupEntry(GetShapeshiftForm());
if(ssEntry && ssEntry->creatureType > 0)
return ssEntry->creatureType;
else

View file

@ -1668,9 +1668,21 @@ class MANGOS_DLL_SPEC Unit : public WorldObject
uint32 m_detectInvisibilityMask;
uint32 m_invisibilityMask;
uint32 m_ShapeShiftFormSpellId;
ShapeshiftForm m_form;
bool IsInFeralForm() const { return m_form == FORM_CAT || m_form == FORM_BEAR || m_form == FORM_DIREBEAR; }
ShapeshiftForm GetShapeshiftForm() const { return ShapeshiftForm(GetByteValue(UNIT_FIELD_BYTES_2, 3)); }
void SetShapeshiftForm(ShapeshiftForm form) { SetByteValue(UNIT_FIELD_BYTES_2, 3, form); }
bool IsInFeralForm() const
{
ShapeshiftForm form = GetShapeshiftForm();
return form == FORM_CAT || form == FORM_BEAR || form == FORM_DIREBEAR;
}
bool IsInDisallowedMountForm() const
{
ShapeshiftForm form = GetShapeshiftForm();
return form != FORM_NONE && form != FORM_BATTLESTANCE && form != FORM_BERSERKERSTANCE && form != FORM_DEFENSIVESTANCE &&
form != FORM_SHADOW;
}
float m_modMeleeHitChance;
float m_modRangedHitChance;

View file

@ -3014,7 +3014,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d
// Druid Forms Trinket
if (auraSpellInfo->Id==37336)
{
switch(m_form)
switch(GetShapeshiftForm())
{
case FORM_NONE: trigger_spell_id = 37344;break;
case FORM_CAT: trigger_spell_id = 37341;break;
@ -3029,7 +3029,7 @@ SpellAuraProcResult Unit::HandleProcTriggerSpellAuraProc(Unit *pVictim, uint32 d
// Druid T9 Feral Relic (Lacerate, Swipe, Mangle, and Shred)
else if (auraSpellInfo->Id==67353)
{
switch(m_form)
switch(GetShapeshiftForm())
{
case FORM_CAT: trigger_spell_id = 67355; break;
case FORM_BEAR:

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "10833"
#define REVISION_NR "10834"
#endif // __REVISION_NR_H__