mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-23 13:46:24 +00:00
fix(Core/Entities): extend combo point system to all Units (#9816)
- Closes #1140
This commit is contained in:
@@ -4995,9 +4995,8 @@ void AuraEffect::HandleAuraRetainComboPoints(AuraApplication const* aurApp, uint
|
||||
|
||||
// combo points was added in SPELL_EFFECT_ADD_COMBO_POINTS handler
|
||||
// remove only if aura expire by time (in case combo points amount change aura removed without combo points lost)
|
||||
if (!(apply) && GetBase()->GetDuration() == 0 && target->ToPlayer()->GetComboTarget())
|
||||
if (Unit* unit = ObjectAccessor::GetUnit(*target, target->ToPlayer()->GetComboTarget()))
|
||||
target->ToPlayer()->AddComboPoints(unit, -GetAmount());
|
||||
if (!(apply) && GetBase()->GetDuration() == 0)
|
||||
target->AddComboPoints(-GetAmount());
|
||||
}
|
||||
|
||||
/*********************************************************/
|
||||
|
||||
@@ -572,6 +572,8 @@ Spell::Spell(Unit* caster, SpellInfo const* info, TriggerCastFlags triggerFlags,
|
||||
m_referencedFromCurrentSpell = false;
|
||||
m_executedCurrently = false;
|
||||
m_needComboPoints = m_spellInfo->NeedsComboPoints();
|
||||
m_comboPointGain = 0;
|
||||
m_comboTarget = nullptr;
|
||||
m_delayStart = 0;
|
||||
m_delayAtDamageCount = 0;
|
||||
|
||||
@@ -3315,7 +3317,7 @@ SpellCastResult Spell::prepare(SpellCastTargets const* targets, AuraEffect const
|
||||
m_powerCost = m_CastItem ? 0 : m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask, this);
|
||||
|
||||
// Set combo point requirement
|
||||
if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem || !m_caster->m_movedByPlayer)
|
||||
if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem)
|
||||
m_needComboPoints = false;
|
||||
|
||||
SpellCastResult result = CheckCast(true);
|
||||
@@ -3946,16 +3948,16 @@ void Spell::_handle_immediate_phase()
|
||||
|
||||
void Spell::_handle_finish_phase()
|
||||
{
|
||||
if (m_caster->m_movedByPlayer && m_needComboPoints)
|
||||
// Take for real after all targets are processed
|
||||
if (m_needComboPoints)
|
||||
{
|
||||
// Take for real after all targets are processed
|
||||
m_caster->m_movedByPlayer->ToPlayer()->ClearComboPoints();
|
||||
m_caster->ClearComboPoints();
|
||||
}
|
||||
|
||||
// Real add combo points from effects
|
||||
if( m_targets.GetUnitTarget() && m_targets.GetUnitTarget()->IsInWorld() && m_targets.GetUnitTarget()->IsAlive() )
|
||||
m_caster->m_movedByPlayer->ToPlayer()->AddComboPoints(m_targets.GetUnitTarget(), m_caster->m_movedByPlayer->ToPlayer()->GetComboPointGain());
|
||||
|
||||
m_caster->m_movedByPlayer->ToPlayer()->SetComboPointGain(0);
|
||||
// Real add combo points from effects
|
||||
if (m_comboTarget && m_comboPointGain)
|
||||
{
|
||||
m_caster->AddComboPoints(m_comboTarget, m_comboPointGain);
|
||||
}
|
||||
|
||||
if (m_caster->m_extraAttacks && GetSpellInfo()->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
|
||||
@@ -6322,11 +6324,24 @@ SpellCastResult Spell::CheckCast(bool strict)
|
||||
return SPELL_FAILED_ITEM_ALREADY_ENCHANTED;
|
||||
}
|
||||
|
||||
// check if caster has at least 1 combo point for spells that require combo points
|
||||
// check if caster has at least 1 combo point on target for spells that require combo points
|
||||
if (m_needComboPoints)
|
||||
if (Player* plrCaster = m_caster->ToPlayer())
|
||||
if (!plrCaster->GetComboPoints())
|
||||
{
|
||||
if (m_spellInfo->NeedsExplicitUnitTarget())
|
||||
{
|
||||
if (!m_caster->GetComboPoints(m_targets.GetUnitTarget()))
|
||||
{
|
||||
return SPELL_FAILED_NO_COMBO_POINTS;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!m_caster->GetComboPoints())
|
||||
{
|
||||
return SPELL_FAILED_NO_COMBO_POINTS;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// xinef: check relic cooldown
|
||||
if (m_CastItem && m_CastItem->GetTemplate()->InventoryType == INVTYPE_RELIC && m_triggeredByAuraSpell)
|
||||
|
||||
@@ -527,6 +527,21 @@ public:
|
||||
SpellCastTargets m_targets;
|
||||
SpellCustomErrors m_customError;
|
||||
|
||||
void AddComboPointGain(Unit* target, int8 amount)
|
||||
{
|
||||
if (target != m_comboTarget)
|
||||
{
|
||||
m_comboTarget = target;
|
||||
m_comboPointGain = amount;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_comboPointGain += amount;
|
||||
}
|
||||
}
|
||||
Unit* m_comboTarget;
|
||||
int8 m_comboPointGain;
|
||||
|
||||
UsedSpellMods m_appliedMods;
|
||||
|
||||
PathGenerator* m_pathFinder; // pussywizard: for precomputing path for charge
|
||||
|
||||
@@ -481,7 +481,7 @@ void Spell::EffectSchoolDMG(SpellEffIndex effIndex)
|
||||
float multiple = ap / 410 + m_spellInfo->Effects[effIndex].DamageMultiplier;
|
||||
int32 energy = -(m_caster->ModifyPower(POWER_ENERGY, -30));
|
||||
damage += int32(energy * multiple);
|
||||
damage += int32(CalculatePct(m_caster->ToPlayer()->GetComboPoints() * ap, 7));
|
||||
damage += int32(CalculatePct(m_caster->GetComboPoints() * ap, 7));
|
||||
}
|
||||
// Wrath
|
||||
else if (m_spellInfo->SpellFamilyFlags[0] & 0x00000001)
|
||||
@@ -3399,8 +3399,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
|
||||
// Hemorrhage
|
||||
if (m_spellInfo->SpellFamilyFlags[0] & 0x2000000)
|
||||
{
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->AddComboPoints(unitTarget, 1);
|
||||
AddComboPointGain(unitTarget, 1);
|
||||
}
|
||||
// 50% more damage with daggers
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
@@ -3460,8 +3459,7 @@ void Spell::EffectWeaponDmg(SpellEffIndex effIndex)
|
||||
// Mangle (Cat): CP
|
||||
if (m_spellInfo->SpellFamilyFlags[1] & 0x400)
|
||||
{
|
||||
if (m_caster->GetTypeId() == TYPEID_PLAYER)
|
||||
m_caster->ToPlayer()->AddComboPoints(unitTarget, 1);
|
||||
AddComboPointGain(unitTarget, 1);
|
||||
}
|
||||
// Shred, Maul - Rend and Tear
|
||||
else if (m_spellInfo->SpellFamilyFlags[0] & 0x00008800 && unitTarget->HasAuraState(AURA_STATE_BLEEDING))
|
||||
@@ -4325,19 +4323,16 @@ void Spell::EffectSanctuary(SpellEffIndex /*effIndex*/)
|
||||
void Spell::EffectAddComboPoints(SpellEffIndex /*effIndex*/)
|
||||
{
|
||||
if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
|
||||
return;
|
||||
|
||||
if (!m_caster->m_movedByPlayer || !unitTarget || damage <= 0)
|
||||
return;
|
||||
|
||||
if (m_spellInfo->Id == 14157 || // Ruthlessness and Netherblade set
|
||||
m_spellInfo->Id == 70802) // xinef: mayhem, rogue t10p4
|
||||
{
|
||||
m_caster->m_movedByPlayer->ToPlayer()->SetComboPointGain(m_caster->m_movedByPlayer->ToPlayer()->GetComboPointGain() + damage);
|
||||
return;
|
||||
}
|
||||
|
||||
m_caster->m_movedByPlayer->ToPlayer()->AddComboPoints(unitTarget, damage);
|
||||
if (!unitTarget || damage <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
AddComboPointGain(unitTarget, damage);
|
||||
}
|
||||
|
||||
void Spell::EffectDuel(SpellEffIndex effIndex)
|
||||
|
||||
@@ -449,10 +449,10 @@ int32 SpellEffectInfo::CalcValue(Unit const* caster, int32 const* bp, Unit const
|
||||
if (caster)
|
||||
{
|
||||
// bonus amount from combo points
|
||||
if (caster->m_movedByPlayer)
|
||||
if (uint8 comboPoints = caster->m_movedByPlayer->ToPlayer()->GetComboPoints())
|
||||
if (float comboDamage = PointsPerComboPoint)
|
||||
value += comboDamage * comboPoints;
|
||||
if (uint8 comboPoints = caster->GetComboPoints())
|
||||
{
|
||||
value += PointsPerComboPoint * comboPoints;
|
||||
}
|
||||
|
||||
value = caster->ApplyEffectModifiers(_spellInfo, _effIndex, value);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user