Core/Mechanics: cleanup shapeshift form code (by VladimirMangos)
--HG-- branch : trunk
This commit is contained in:
@@ -1547,7 +1547,7 @@ void Player::setDeathState(DeathState s)
|
||||
clearResurrectRequestData();
|
||||
|
||||
// remove form before other mods to prevent incorrect stats calculation
|
||||
RemoveAurasDueToSpell(m_ShapeShiftFormSpellId);
|
||||
RemoveAurasByType(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(NULL, PET_SAVE_NOT_IN_SLOT, true);
|
||||
@@ -3589,7 +3589,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)))));
|
||||
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)));
|
||||
@@ -5906,7 +5908,7 @@ void Player::UpdateWeaponSkill (WeaponAttackType attType)
|
||||
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
|
||||
|
||||
if (pVictim && pVictim->GetTypeId() == TYPEID_UNIT && (pVictim->ToCreature()->GetCreatureInfo()->flags_extra & CREATURE_FLAG_EXTRA_NO_SKILLGAIN))
|
||||
@@ -7796,7 +7798,7 @@ 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
|
||||
@@ -7816,7 +7818,7 @@ void Player::ApplyEquipSpell(SpellEntry const* spellInfo, Item* item, bool apply
|
||||
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
|
||||
}
|
||||
|
||||
@@ -19401,7 +19403,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);
|
||||
@@ -19423,8 +19425,8 @@ bool Player::ActivateTaxiPathTo(std::vector<uint32> const& nodes, Creature* npc
|
||||
{
|
||||
RemoveAurasByType(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())
|
||||
RemoveAurasByType(SPELL_AURA_MOD_SHAPESHIFT);
|
||||
|
||||
if (Spell* spell = GetCurrentSpell(CURRENT_GENERIC_SPELL))
|
||||
if (spell->m_spellInfo->Id != spellid)
|
||||
@@ -19693,7 +19695,9 @@ void Player::ProhibitSpellScholl(SpellSchoolMask idSchoolMask, uint32 unTimeMs)
|
||||
|
||||
void Player::InitDataForForm(bool reapplyMods)
|
||||
{
|
||||
SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(m_form);
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
|
||||
SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(form);
|
||||
if (ssEntry && ssEntry->attackSpeed)
|
||||
{
|
||||
SetAttackTime(BASE_ATTACK,ssEntry->attackSpeed);
|
||||
@@ -19703,7 +19707,7 @@ void Player::InitDataForForm(bool reapplyMods)
|
||||
else
|
||||
SetRegularAttackTime();
|
||||
|
||||
switch(m_form)
|
||||
switch (form)
|
||||
{
|
||||
case FORM_GHOUL:
|
||||
case FORM_CAT:
|
||||
|
||||
@@ -296,13 +296,13 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
index_mod = UNIT_FIELD_RANGED_ATTACK_POWER_MODS;
|
||||
index_mult = UNIT_FIELD_RANGED_ATTACK_POWER_MULTIPLIER;
|
||||
|
||||
switch(getClass())
|
||||
switch (getClass())
|
||||
{
|
||||
case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_AGILITY) - 10.0f; break;
|
||||
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:
|
||||
@@ -317,19 +317,20 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
}
|
||||
else
|
||||
{
|
||||
switch(getClass())
|
||||
switch (getClass())
|
||||
{
|
||||
case CLASS_WARRIOR: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
|
||||
case CLASS_PALADIN: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
|
||||
case CLASS_DEATH_KNIGHT: val2 = level*3.0f + GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
|
||||
case CLASS_ROGUE: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
|
||||
case CLASS_HUNTER: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
|
||||
case CLASS_SHAMAN: val2 = level*2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
|
||||
case CLASS_WARRIOR: val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break;
|
||||
case CLASS_PALADIN: val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break;
|
||||
case CLASS_DEATH_KNIGHT: val2 = level * 3.0f + GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break;
|
||||
case CLASS_ROGUE: val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
|
||||
case CLASS_HUNTER: val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
|
||||
case CLASS_SHAMAN: val2 = level * 2.0f + GetStat(STAT_STRENGTH) + GetStat(STAT_AGILITY) - 20.0f; break;
|
||||
case CLASS_DRUID:
|
||||
{
|
||||
//Check if Predatory Strikes is skilled
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
// Check if Predatory Strikes is skilled
|
||||
float mLevelMult = 0.0;
|
||||
switch(m_form)
|
||||
switch (form)
|
||||
{
|
||||
case FORM_CAT:
|
||||
case FORM_BEAR:
|
||||
@@ -351,17 +352,17 @@ void Player::UpdateAttackPowerAndDamage(bool ranged)
|
||||
default: break;
|
||||
}
|
||||
|
||||
switch(m_form)
|
||||
switch (form)
|
||||
{
|
||||
case FORM_CAT:
|
||||
val2 = getLevel()*(mLevelMult+2.0f) + GetStat(STAT_STRENGTH)*2.0f + GetStat(STAT_AGILITY) - 20.0f + m_baseFeralAP; break;
|
||||
val2 = getLevel() * (mLevelMult + 2.0f) + GetStat(STAT_STRENGTH) * 2.0f + GetStat(STAT_AGILITY) - 20.0f + m_baseFeralAP; break;
|
||||
case FORM_BEAR:
|
||||
case FORM_DIREBEAR:
|
||||
val2 = getLevel()*(mLevelMult+3.0f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f + m_baseFeralAP; break;
|
||||
val2 = getLevel() * (mLevelMult + 3.0f) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP; break;
|
||||
case FORM_MOONKIN:
|
||||
val2 = getLevel()*(mLevelMult+1.5f) + GetStat(STAT_STRENGTH)*2.0f - 20.0f + m_baseFeralAP; break;
|
||||
val2 = getLevel() * (mLevelMult + 1.5f) + GetStat(STAT_STRENGTH) * 2.0f - 20.0f + m_baseFeralAP; break;
|
||||
default:
|
||||
val2 = GetStat(STAT_STRENGTH)*2.0f - 20.0f; break;
|
||||
val2 = GetStat(STAT_STRENGTH) * 2.0f - 20.0f; break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -123,7 +123,6 @@ m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this)
|
||||
m_rootTimes = 0;
|
||||
|
||||
m_state = 0;
|
||||
m_form = FORM_NONE;
|
||||
m_deathState = ALIVE;
|
||||
|
||||
for (uint8 i = 0; i < CURRENT_MAX_SPELL; ++i)
|
||||
@@ -140,7 +139,6 @@ m_vehicleKit(NULL), m_unitTypeMask(UNIT_MASK_NONE), m_HostileRefManager(this)
|
||||
|
||||
m_interruptMask = 0;
|
||||
m_transform = 0;
|
||||
m_ShapeShiftFormSpellId = 0;
|
||||
m_canModifyStats = false;
|
||||
|
||||
for (uint8 i = 0; i < MAX_SPELL_IMMUNITY; ++i)
|
||||
@@ -1701,7 +1699,7 @@ void Unit::CalcAbsorbResist(Unit *pVictim, SpellSchoolMask schoolMask, DamageEff
|
||||
if (spellProto->SpellIconID == 2253)
|
||||
{
|
||||
//reduces all damage taken while Stunned
|
||||
if (pVictim->m_form == FORM_CAT && (unitflag & UNIT_FLAG_STUNNED))
|
||||
if (pVictim->GetShapeshiftForm() == FORM_CAT && (unitflag & UNIT_FLAG_STUNNED))
|
||||
RemainingDamage -= RemainingDamage * currentAbsorb / 100;
|
||||
continue;
|
||||
}
|
||||
@@ -8290,7 +8288,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
|
||||
// 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;
|
||||
@@ -8305,7 +8303,7 @@ bool Unit::HandleProcTriggerSpell(Unit *pVictim, uint32 damage, AuraEffect* trig
|
||||
// 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:
|
||||
@@ -13091,7 +13089,8 @@ uint32 Unit::GetCreatureType() const
|
||||
{
|
||||
if (GetTypeId() == TYPEID_PLAYER)
|
||||
{
|
||||
SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(m_form);
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
SpellShapeshiftEntry const* ssEntry = sSpellShapeshiftStore.LookupEntry(form);
|
||||
if (ssEntry && ssEntry->creatureType > 0)
|
||||
return ssEntry->creatureType;
|
||||
else
|
||||
|
||||
@@ -1713,9 +1713,21 @@ class Unit : public WorldObject
|
||||
uint64 m_SummonSlot[MAX_SUMMON_SLOT];
|
||||
uint64 m_ObjectSlot[4];
|
||||
|
||||
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); }
|
||||
|
||||
inline bool IsInFeralForm() const
|
||||
{
|
||||
ShapeshiftForm form = GetShapeshiftForm();
|
||||
return form == FORM_CAT || form == FORM_BEAR || form == FORM_DIREBEAR;
|
||||
}
|
||||
|
||||
inline 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;
|
||||
|
||||
Reference in New Issue
Block a user