aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Spells/SpellEffects.cpp
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2022-12-04 15:13:20 +0100
committerShauren <shauren.trinity@gmail.com>2022-12-04 15:13:20 +0100
commite98e1283ea0034baf6be9aa2ffb386eb5582801b (patch)
treeb1dd854d88e6e049d26b208bb259cdc7d31f29f8 /src/server/game/Spells/SpellEffects.cpp
parentde7c03c8385780f05530c2b3cf952a712d5f8f00 (diff)
Core: Updated to 10.0.2
Diffstat (limited to 'src/server/game/Spells/SpellEffects.cpp')
-rw-r--r--src/server/game/Spells/SpellEffects.cpp134
1 files changed, 96 insertions, 38 deletions
diff --git a/src/server/game/Spells/SpellEffects.cpp b/src/server/game/Spells/SpellEffects.cpp
index 6aefb6c38d9..2bde0329e6f 100644
--- a/src/server/game/Spells/SpellEffects.cpp
+++ b/src/server/game/Spells/SpellEffects.cpp
@@ -371,8 +371,23 @@ NonDefaultConstructible<SpellEffectHandlerFn> SpellEffectHandlers[TOTAL_SPELL_EF
&Spell::EffectNULL, //285 SPELL_EFFECT_MODIFY_KEYSTONE_2
&Spell::EffectGrantBattlePetExperience, //286 SPELL_EFFECT_GRANT_BATTLEPET_EXPERIENCE
&Spell::EffectNULL, //287 SPELL_EFFECT_SET_GARRISON_FOLLOWER_LEVEL
- &Spell::EffectUnused, //288 SPELL_EFFECT_288
- &Spell::EffectNULL, //289 SPELL_EFFECT_289
+ &Spell::EffectNULL, //288 SPELL_EFFECT_CRAFT_ITEM
+ &Spell::EffectModifyAuraStacks, //289 SPELL_EFFECT_MODIFY_AURA_STACKS
+ &Spell::EffectModifyCooldown, //290 SPELL_EFFECT_MODIFY_COOLDOWN
+ &Spell::EffectModifyCooldowns, //291 SPELL_EFFECT_MODIFY_COOLDOWNS
+ &Spell::EffectModifyCooldownsByCategory, //292 SPELL_EFFECT_MODIFY_COOLDOWNS_BY_CATEGORY
+ &Spell::EffectModifySpellCharges, //293 SPELL_EFFECT_MODIFY_CHARGES
+ &Spell::EffectNULL, //294 SPELL_EFFECT_CRAFT_LOOT
+ &Spell::EffectNULL, //295 SPELL_EFFECT_SALVAGE_ITEM
+ &Spell::EffectNULL, //296 SPELL_EFFECT_CRAFT_SALVAGE_ITEM
+ &Spell::EffectNULL, //297 SPELL_EFFECT_RECRAFT_ITEM
+ &Spell::EffectNULL, //298 SPELL_EFFECT_CANCEL_ALL_PRIVATE_CONVERSATIONS
+ &Spell::EffectNULL, //299 SPELL_EFFECT_299
+ &Spell::EffectUnused, //300 SPELL_EFFECT_300
+ &Spell::EffectNULL, //301 SPELL_EFFECT_CRAFT_ENCHANT
+ &Spell::EffectNULL, //302 SPELL_EFFECT_GATHERING
+ &Spell::EffectNULL, //303 SPELL_EFFECT_CREATE_TRAIT_TREE_CONFIG
+ &Spell::EffectNULL, //304 SPELL_EFFECT_CHANGE_ACTIVE_COMBAT_TRAIT_CONFIG
};
void Spell::EffectNULL()
@@ -2439,30 +2454,7 @@ void Spell::EffectEnchantItemTmp()
}
// select enchantment duration
- uint32 duration;
-
- // rogue family enchantments exception by duration
- if (m_spellInfo->Id == 38615)
- duration = 1800; // 30 mins
- // other rogue family enchantments always 1 hour (some have spell damage=0, but some have wrong data in EffBasePoints)
- else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_ROGUE)
- duration = 3600; // 1 hour
- // shaman family enchantments
- else if (m_spellInfo->SpellFamilyName == SPELLFAMILY_SHAMAN)
- duration = 3600; // 30 mins
- // other cases with this SpellVisual already selected
- else if (m_spellInfo->GetSpellVisual() == 215)
- duration = 1800; // 30 mins
- // some fishing pole bonuses except Glow Worm which lasts full hour
- else if (m_spellInfo->GetSpellVisual() == 563 && m_spellInfo->Id != 64401)
- duration = 600; // 10 mins
- else if (m_spellInfo->Id == 29702)
- duration = 300; // 5 mins
- else if (m_spellInfo->Id == 37360)
- duration = 300; // 5 mins
- // default case
- else
- duration = 3600; // 1 hour
+ uint32 duration = pEnchant->Duration;
// item can be in trade slot and have owner diff. from caster
Player* item_owner = itemTarget->GetOwner();
@@ -5385,19 +5377,14 @@ void Spell::EffectChangeBattlePetQuality()
if (!unitTarget || !unitTarget->IsCreature())
return;
- BattlePets::BattlePetBreedQuality quality = BattlePets::BattlePetBreedQuality::Poor;
- switch (damage)
+ auto qualityItr = std::lower_bound(sBattlePetBreedQualityStore.begin(), sBattlePetBreedQualityStore.end(), damage, [](BattlePetBreedQualityEntry const* a1, int32 selector)
{
- case 85:
- quality = BattlePets::BattlePetBreedQuality::Rare;
- break;
- case 75:
- quality = BattlePets::BattlePetBreedQuality::Uncommon;
- break;
- default:
- // Ignore Epic Battle-Stones
- break;
- }
+ return a1->MaxQualityRoll < selector;
+ });
+
+ BattlePets::BattlePetBreedQuality quality = BattlePets::BattlePetBreedQuality::Poor;
+ if (qualityItr != sBattlePetBreedQualityStore.end())
+ quality = BattlePets::BattlePetBreedQuality(qualityItr->QualityEnum);
playerCaster->GetSession()->GetBattlePetMgr()->ChangeBattlePetQuality(unitTarget->GetBattlePetCompanionGUID(), quality);
}
@@ -5815,3 +5802,74 @@ void Spell::EffectLearnTransmogIllusion()
player->GetSession()->GetCollectionMgr()->AddTransmogIllusion(illusionId);
}
+
+void Spell::EffectModifyAuraStacks()
+{
+ if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
+ return;
+
+ Aura* targetAura = unitTarget->GetAura(effectInfo->TriggerSpell);
+ if (!targetAura)
+ return;
+
+ switch (effectInfo->MiscValue)
+ {
+ case 0:
+ targetAura->ModStackAmount(damage);
+ break;
+ case 1:
+ targetAura->SetStackAmount(damage);
+ break;
+ default:
+ break;
+ }
+}
+
+void Spell::EffectModifyCooldown()
+{
+ if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
+ return;
+
+ unitTarget->GetSpellHistory()->ModifyCooldown(effectInfo->TriggerSpell, Milliseconds(damage));
+}
+
+void Spell::EffectModifyCooldowns()
+{
+ if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
+ return;
+
+ unitTarget->GetSpellHistory()->ModifyCoooldowns([this](SpellHistory::CooldownStorageType::iterator itr)
+ {
+ SpellInfo const* spellOnCooldown = sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE);
+ if (spellOnCooldown->SpellFamilyName != uint32(effectInfo->MiscValue))
+ return false;
+
+ int32 bitIndex = effectInfo->MiscValueB - 1;
+ if (bitIndex < 0 || uint32(bitIndex) >= sizeof(flag128) * 8)
+ return false;
+
+ flag128 reqFlag;
+ reqFlag[bitIndex / 32] = 1u << (bitIndex % 32);
+ return bool(spellOnCooldown->SpellFamilyFlags & reqFlag);
+ }, Milliseconds(damage));
+}
+
+void Spell::EffectModifyCooldownsByCategory()
+{
+ if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
+ return;
+
+ unitTarget->GetSpellHistory()->ModifyCoooldowns([this](SpellHistory::CooldownStorageType::iterator itr)
+ {
+ return sSpellMgr->AssertSpellInfo(itr->first, DIFFICULTY_NONE)->CategoryId == uint32(effectInfo->MiscValue);
+ }, Milliseconds(damage));
+}
+
+void Spell::EffectModifySpellCharges()
+{
+ if (effectHandleMode != SPELL_EFFECT_HANDLE_HIT_TARGET)
+ return;
+
+ for (int32 i = 0; i < damage; ++i)
+ unitTarget->GetSpellHistory()->RestoreCharge(effectInfo->MiscValue);
+}