Skip to content

Commit

Permalink
Core/Spells: Removed old combo point code leftovers
Browse files Browse the repository at this point in the history
  • Loading branch information
Shauren committed Jul 31, 2023
1 parent 4c29e45 commit 197d436
Show file tree
Hide file tree
Showing 10 changed files with 10 additions and 105 deletions.
9 changes: 4 additions & 5 deletions src/server/game/Entities/Player/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1232,8 +1232,7 @@ void Player::setDeathState(DeathState s)

// drunken state is cleared on death
SetDrunkValue(0);
// lost combo points at any target (targeted combo points clear in Unit::setDeathState)
ClearComboPoints();
SetPower(POWER_COMBO_POINTS, 0);

ClearResurrectRequestData();

Expand Down Expand Up @@ -1615,7 +1614,7 @@ void Player::RemoveFromWorld()
StopCastingCharm();
StopCastingBindSight();
UnsummonPetTemporaryIfAny();
ClearComboPoints();
SetPower(POWER_COMBO_POINTS, 0);
m_session->DoLootReleaseAll();
m_lootRolls.clear();
sOutdoorPvPMgr->HandlePlayerLeaveZone(this, m_zoneUpdateId);
Expand Down Expand Up @@ -7764,8 +7763,8 @@ void Player::DuelComplete(DuelCompleteType type)
opponent->RemoveAurasWithInterruptFlags(SpellAuraInterruptFlags2::DuelEnd);

// cleanup combo points
ClearComboPoints();
opponent->ClearComboPoints();
SetPower(POWER_COMBO_POINTS, 0);
opponent->SetPower(POWER_COMBO_POINTS, 0);

//cleanups
SetDuelArbiter(ObjectGuid::Empty);
Expand Down
39 changes: 0 additions & 39 deletions src/server/game/Entities/Unit/Unit.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10289,45 +10289,6 @@ void Unit::RestoreDisplayId(bool ignorePositiveAurasPreventingMounting /*= false
SetDisplayId(GetNativeDisplayId());
}

void Unit::AddComboPoints(int8 count, Spell* spell)
{
if (!count)
return;

int8 comboPoints = spell ? spell->m_comboPointGain : GetPower(POWER_COMBO_POINTS);

comboPoints += count;

if (comboPoints > 5)
comboPoints = 5;
else if (comboPoints < 0)
comboPoints = 0;

if (!spell)
SetPower(POWER_COMBO_POINTS, comboPoints);
else
spell->m_comboPointGain = comboPoints;
}

void Unit::GainSpellComboPoints(int8 count)
{
if (!count)
return;

int8 cp = GetPower(POWER_COMBO_POINTS);

cp += count;
if (cp > 5) cp = 5;
else if (cp < 0) cp = 0;

SetPower(POWER_COMBO_POINTS, cp);
}

void Unit::ClearComboPoints()
{
SetPower(POWER_COMBO_POINTS, 0);
}

void Unit::ClearAllReactives()
{
for (uint8 i = 0; i < MAX_REACTIVE; ++i)
Expand Down
6 changes: 0 additions & 6 deletions src/server/game/Entities/Unit/Unit.h
Original file line number Diff line number Diff line change
Expand Up @@ -1784,12 +1784,6 @@ class TC_GAME_API Unit : public WorldObject
void SetControlled(bool apply, UnitState state);
void ApplyControlStatesIfNeeded();

///-----------Combo point system-------------------
uint32 GetComboPoints() const { return uint32(GetPower(POWER_COMBO_POINTS)); }
void AddComboPoints(int8 count, Spell* spell = nullptr);
void GainSpellComboPoints(int8 count);
void ClearComboPoints();

///----------Pet responses methods-----------------
void SendPetActionFeedback(PetActionFeedback msg, uint32 spellId);
void SendPetTalk(uint32 pettalk);
Expand Down
43 changes: 1 addition & 42 deletions src/server/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,6 @@ m_spellValue(new SpellValue(m_spellInfo, caster)), _spellEvent(nullptr)
m_selfContainer = nullptr;
m_referencedFromCurrentSpell = false;
m_executedCurrently = false;
m_needComboPoints = m_spellInfo->NeedsComboPoints();
m_comboPointGain = 0;
m_delayStart = 0;
m_delayAtDamageCount = 0;

Expand Down Expand Up @@ -2946,10 +2944,6 @@ void Spell::TargetInfo::DoDamageAndTriggers(Spell* spell)
spell->m_hitMask |= hitMask;
spell->m_procSpellType |= procSpellType;

// Do not take combo points on dodge and miss
if (MissCondition != SPELL_MISS_NONE && spell->m_needComboPoints && spell->m_targets.GetUnitTargetGUID() == TargetGUID)
spell->m_needComboPoints = false;

// _spellHitTarget can be null if spell is missed in DoSpellHitOnUnit
if (MissCondition != SPELL_MISS_EVADE && _spellHitTarget && !spell->m_caster->IsFriendlyTo(unit) && (!spell->IsPositive() || spell->m_spellInfo->HasEffect(SPELL_EFFECT_DISPEL)))
{
Expand Down Expand Up @@ -3442,10 +3436,6 @@ SpellCastResult Spell::prepare(SpellCastTargets const& targets, AuraEffect const
if (!m_CastItem)
m_powerCost = m_spellInfo->CalcPowerCost(m_caster, m_spellSchoolMask, this);

// Set combo point requirement
if ((_triggeredCastFlags & TRIGGERED_IGNORE_COMBO_POINTS) || m_CastItem)
m_needComboPoints = false;

int32 param1 = 0, param2 = 0;
SpellCastResult result = CheckCast(true, &param1, &param2);
// target is checked in too many locations and with different results to handle each of them
Expand Down Expand Up @@ -4132,18 +4122,8 @@ void Spell::_handle_immediate_phase()
void Spell::_handle_finish_phase()
{
if (Unit* unitCaster = m_caster->ToUnit())
{
// Take for real after all targets are processed
if (m_needComboPoints)
unitCaster->ClearComboPoints();

// Real add combo points from effects
if (m_comboPointGain)
unitCaster->AddComboPoints(m_comboPointGain);

if (m_spellInfo->HasEffect(SPELL_EFFECT_ADD_EXTRA_ATTACKS))
unitCaster->SetLastExtraAttackSpell(m_spellInfo->Id);
}

// Handle procs on finish
if (!m_originalCaster)
Expand Down Expand Up @@ -5657,21 +5637,6 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
}
}

bool reqCombat = true;
Unit::AuraEffectList const& stateAuras = unitCaster->GetAuraEffectsByType(SPELL_AURA_ABILITY_IGNORE_AURASTATE);
for (Unit::AuraEffectList::const_iterator j = stateAuras.begin(); j != stateAuras.end(); ++j)
{
if ((*j)->IsAffectingSpell(m_spellInfo))
{
m_needComboPoints = false;
if ((*j)->GetMiscValue() == 1)
{
reqCombat = false;
break;
}
}
}

// caster state requirements
// not for triggered spells (needed by execute)
if (!(_triggeredCastFlags & TRIGGERED_IGNORE_CASTER_AURASTATE))
Expand All @@ -5692,7 +5657,7 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
if (m_spellInfo->ExcludeCasterAuraType && unitCaster->HasAuraType(m_spellInfo->ExcludeCasterAuraType))
return SPELL_FAILED_CASTER_AURASTATE;

if (reqCombat && unitCaster->IsInCombat() && !m_spellInfo->CanBeUsedInCombat(unitCaster))
if (unitCaster->IsInCombat() && !m_spellInfo->CanBeUsedInCombat(unitCaster))
return SPELL_FAILED_AFFECTING_COMBAT;
}

Expand Down Expand Up @@ -6685,12 +6650,6 @@ SpellCastResult Spell::CheckCast(bool strict, int32* param1 /*= nullptr*/, int32
return SPELL_FAILED_ITEM_ALREADY_ENCHANTED;
}

// check if caster has at least 1 combo point for spells that require combo points
if (m_needComboPoints)
if (Player* plrCaster = m_caster->ToPlayer())
if (!plrCaster->GetComboPoints())
return SPELL_FAILED_NO_COMBO_POINTS;

// all ok
return SPELL_CAST_OK;
}
Expand Down
2 changes: 0 additions & 2 deletions src/server/game/Spells/Spell.h
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,6 @@ class TC_GAME_API Spell
std::any m_customArg;
SpellCastVisual m_SpellVisual;
SpellCastTargets m_targets;
int8 m_comboPointGain;
SpellCustomErrors m_customError;

UsedSpellMods m_appliedMods;
Expand Down Expand Up @@ -705,7 +704,6 @@ class TC_GAME_API Spell
// These vars are used in both delayed spell system and modified immediate spell system
bool m_referencedFromCurrentSpell; // mark as references to prevent deleted and access by dead pointers
bool m_executedCurrently; // mark as executed to prevent deleted and access by dead pointers
bool m_needComboPoints;
uint32 m_applyMultiplierMask;
float m_damageMultipliers[MAX_SPELL_EFFECTS];

Expand Down
2 changes: 1 addition & 1 deletion src/server/game/Spells/SpellDefines.h
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ enum TriggerCastFlags : uint32
TRIGGERED_IGNORE_CAST_ITEM = 0x00000008, //! Will not take away cast item or update related achievement criteria
TRIGGERED_IGNORE_AURA_SCALING = 0x00000010, //! Will ignore aura scaling
TRIGGERED_IGNORE_CAST_IN_PROGRESS = 0x00000020, //! Will not check if a current cast is in progress
TRIGGERED_IGNORE_COMBO_POINTS = 0x00000040, //! Will ignore combo point requirement
// reuse = 0x00000040,
TRIGGERED_CAST_DIRECTLY = 0x00000080, //! In Spell::prepare, will be cast directly without setting containers for executed spell
TRIGGERED_IGNORE_AURA_INTERRUPT_FLAGS = 0x00000100, //! Will ignore interruptible aura's at cast
TRIGGERED_IGNORE_SET_FACING = 0x00000200, //! Will not adjust facing to target (if any)
Expand Down
9 changes: 2 additions & 7 deletions src/server/game/Spells/SpellInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -526,7 +526,7 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
}
else if (GetScalingExpectedStat() == ExpectedStatType::None)
{
if (casterUnit && basePointsPerLevel != 0.0f)
if (casterUnit && basePointsPerLevel != 0.0)
{
int32 level = int32(casterUnit->GetLevel());
if (level > int32(_spellInfo->MaxLevel) && _spellInfo->MaxLevel > 0)
Expand All @@ -545,7 +545,7 @@ int32 SpellEffectInfo::CalcValue(WorldObject const* caster /*= nullptr*/, int32
{
// bonus amount from combo points
if (comboDamage)
if (uint32 comboPoints = casterUnit->GetComboPoints())
if (int32 comboPoints = casterUnit->GetPower(POWER_COMBO_POINTS))
value += comboDamage * comboPoints;
}

Expand Down Expand Up @@ -1710,11 +1710,6 @@ bool SpellInfo::IsMoveAllowedChannel() const
return IsChanneled() && !ChannelInterruptFlags.HasFlag(SpellAuraInterruptFlags::Moving | SpellAuraInterruptFlags::Turning);
}

bool SpellInfo::NeedsComboPoints() const
{
return HasAttribute(SpellAttr1(SPELL_ATTR1_FINISHING_MOVE_DAMAGE | SPELL_ATTR1_FINISHING_MOVE_DURATION));
}

bool SpellInfo::IsNextMeleeSwingSpell() const
{
return HasAttribute(SpellAttr0(SPELL_ATTR0_ON_NEXT_SWING_NO_DAMAGE | SPELL_ATTR0_ON_NEXT_SWING));
Expand Down
1 change: 0 additions & 1 deletion src/server/game/Spells/SpellInfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -495,7 +495,6 @@ class TC_GAME_API SpellInfo
bool IsPositiveEffect(uint8 effIndex) const;
bool IsChanneled() const;
bool IsMoveAllowedChannel() const;
bool NeedsComboPoints() const;
bool IsNextMeleeSwingSpell() const;
bool IsRangedWeaponSpell() const;
bool IsAutoRepeatRangedSpell() const;
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Spells/spell_druid.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -961,7 +961,7 @@ class spell_dru_rip : public AuraScript
if (Unit* caster = GetCaster())
{
// 0.01 * $AP * cp
uint32 cp = caster->ToPlayer()->GetComboPoints();
int32 cp = caster->GetPower(POWER_COMBO_POINTS);

// Idol of Feral Shadows. Can't be handled as SpellMod due its dependency from CPs
if (AuraEffect const* auraEffIdolOfFeralShadows = caster->GetAuraEffect(SPELL_DRUID_IDOL_OF_FERAL_SHADOWS, EFFECT_0))
Expand Down
2 changes: 1 addition & 1 deletion src/server/scripts/Spells/spell_rogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,7 @@ class spell_rog_rupture : public AuraScript
0.0375f // 5 points: ${($m1 + $b1*5 + 0.0375 * $AP) * 8} damage over 16 secs
};

uint32 cp = caster->GetComboPoints();
int32 cp = caster->GetPower(POWER_COMBO_POINTS);
if (cp > 5)
cp = 5;

Expand Down

0 comments on commit 197d436

Please sign in to comment.