aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Player
diff options
context:
space:
mode:
authorTreeston <treeston.mmoc@gmail.com>2017-12-30 20:28:41 +0100
committerGitHub <noreply@github.com>2017-12-30 20:28:41 +0100
commitd507a7e3388382960108b24143da48e5f912b4a7 (patch)
treeb4e3e62094e853cc8551126de438815779411cb7 /src/server/game/Entities/Player
parent671a34a966aefa409966f6eb86f88ce671be9b36 (diff)
[3.3.5] CastSpell unclusterfucking (that's a word now) (#21123)
Core/Spell: The giant CastSpell unclusterfucking (that's a word now) of this generation. - CastSpell now always takes three arguments - target, spellId, and a struct containing extra arguments - This struct (CastSpellExtraArgs, see SpellDefines.h) serves as a conglomerate of every previous combination of the 20 billion different CastSpell overloads, all merged into one - It has some great utility constructors - check them out! All of these can be used to implicitly construct the ExtraArgs object. - A gajillion refactors to make everything behave the way it always has
Diffstat (limited to 'src/server/game/Entities/Player')
-rw-r--r--src/server/game/Entities/Player/Player.cpp38
1 files changed, 20 insertions, 18 deletions
diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp
index 26ea8582f23..ab5f4618d7a 100644
--- a/src/server/game/Entities/Player/Player.cpp
+++ b/src/server/game/Entities/Player/Player.cpp
@@ -7679,7 +7679,7 @@ void Player::ApplyItemObtainSpells(Item* item, bool apply)
if (apply)
{
if (!HasAura(spellId))
- CastSpell(this, spellId, true, item);
+ CastSpell(this, spellId, item);
}
else
RemoveAurasDueToSpell(spellId);
@@ -7813,7 +7813,7 @@ void Player::ApplyEquipSpell(SpellInfo const* spellInfo, Item* item, bool apply,
TC_LOG_DEBUG("entities.player", "Player::ApplyEquipSpell: Player '%s' (%s) cast %s equip spell (ID: %i)",
GetName().c_str(), GetGUID().ToString().c_str(), (item ? "item" : "itemset"), spellInfo->Id);
- CastSpell(this, spellInfo, true, item);
+ CastSpell(this, spellInfo->Id, item);
}
else
{
@@ -7953,7 +7953,7 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
chance = GetWeaponProcChance();
if (roll_chance_f(chance) && sScriptMgr->OnCastItemCombatSpell(this, damageInfo.GetVictim(), spellInfo, item))
- CastSpell(damageInfo.GetVictim(), spellInfo->Id, true, item);
+ CastSpell(damageInfo.GetVictim(), spellInfo->Id, item);
}
}
@@ -8017,8 +8017,8 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
{
Unit* target = spellInfo->IsPositive() ? this : damageInfo.GetVictim();
+ CastSpellExtraArgs args(item);
// reduce effect values if enchant is limited
- CustomSpellValues values;
if (entry && (entry->AttributesMask & ENCHANT_PROC_ATTR_LIMIT_60) && target->getLevel() > 60)
{
int32 const lvlDifference = target->getLevel() - 60;
@@ -8029,11 +8029,10 @@ void Player::CastItemCombatSpell(DamageInfo const& damageInfo, Item* item, ItemT
for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
{
if (spellInfo->Effects[i].IsEffect())
- values.AddSpellMod(static_cast<SpellValueMod>(SPELLVALUE_BASE_POINT0 + i), CalculatePct(spellInfo->Effects[i].CalcValue(this), effectPct));
+ args.SpellValueOverrides.AddMod(static_cast<SpellValueMod>(SPELLVALUE_BASE_POINT0 + i), CalculatePct(spellInfo->Effects[i].CalcValue(this), effectPct));
}
}
-
- CastCustomSpell(spellInfo->Id, values, target, TRIGGERED_FULL_MASK, item);
+ CastSpell(target, spellInfo->Id, args);
}
}
}
@@ -8060,7 +8059,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8
spell->m_CastItem = item;
spell->m_cast_count = cast_count; //set count of casts
spell->SetSpellValue(SPELLVALUE_BASE_POINT0, learning_spell_id);
- spell->prepare(&targets);
+ spell->prepare(targets);
return;
}
@@ -8088,7 +8087,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8
spell->m_CastItem = item;
spell->m_cast_count = cast_count; // set count of casts
spell->m_glyphIndex = glyphIndex; // glyph index
- spell->prepare(&targets);
+ spell->prepare(targets);
return;
}
@@ -8115,7 +8114,7 @@ void Player::CastItemUseSpell(Item* item, SpellCastTargets const& targets, uint8
spell->m_CastItem = item;
spell->m_cast_count = cast_count; // set count of casts
spell->m_glyphIndex = glyphIndex; // glyph index
- spell->prepare(&targets);
+ spell->prepare(targets);
return;
}
}
@@ -13664,11 +13663,14 @@ void Player::ApplyEnchantment(Item* item, EnchantmentSlot slot, bool apply, bool
}
}
}
+
+ CastSpellExtraArgs args(item);
// Cast custom spell vs all equal basepoints got from enchant_amount
if (basepoints)
- CastCustomSpell(this, enchant_spell_id, &basepoints, &basepoints, &basepoints, true, item);
- else
- CastSpell(this, enchant_spell_id, true, item);
+ for (uint32 i = 0; i < MAX_SPELL_EFFECTS; ++i)
+ args.SpellValueOverrides.AddMod(SpellValueMod(SPELLVALUE_BASE_POINT0 + i), basepoints);
+
+ CastSpell(this, enchant_spell_id, args);
}
else
RemoveAurasDueToItemSpell(enchant_spell_id, item->GetGUID());
@@ -14291,7 +14293,7 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
break;
case GOSSIP_OPTION_SPIRITHEALER:
if (isDead())
- source->ToCreature()->CastSpell(source->ToCreature(), 17251, true, nullptr, nullptr, GetGUID());
+ source->ToCreature()->CastSpell(source->ToCreature(), 17251, GetGUID());
break;
case GOSSIP_OPTION_QUESTGIVER:
PrepareQuestMenu(guid);
@@ -14312,8 +14314,8 @@ void Player::OnGossipSelect(WorldObject* source, uint32 gossipListId, uint32 men
{
// Cast spells that teach dual spec
// Both are also ImplicitTarget self and must be cast by player
- CastSpell(this, 63680, true, nullptr, nullptr, GetGUID());
- CastSpell(this, 63624, true, nullptr, nullptr, GetGUID());
+ CastSpell(this, 63680, GetGUID());
+ CastSpell(this, 63624, GetGUID());
PrepareGossipMenu(source, menuItemData->GossipActionMenuId);
SendPreparedGossip(source);
@@ -23744,11 +23746,11 @@ void Player::ResurrectUsingRequestData()
if (uint32 aura = _resurrectionData->Aura)
{
- CastSpell(this, aura, true, nullptr, nullptr, _resurrectionData->GUID);
+ CastSpell(this, aura, _resurrectionData->GUID);
return;
}
- /// Teleport before resurrecting by player, otherwise the player might get attacked from creatures near his corpse
+ // Teleport before resurrecting by player, otherwise the player might get attacked from creatures near his corpse
TeleportTo(_resurrectionData->Location);
if (IsBeingTeleported())