[DiscordArchive] I see its returning true / false but is the purpose to validate whether the spell is available to th
[DiscordArchive] I see its returning true / false but is the purpose to validate whether the spell is available to th
Archived author: Drikish • Posted: 2025-01-11T18:46:53.102000+00:00
Original source
I see its returning true / false but is the purpose to validate whether the spell is available to the caster / off cooldown etc?
Archived author: Northstrider • Posted: 2025-01-11T18:46:58.340000+00:00
Original source
it makes sure the spell script only loads when there is a spell with that Id
Archived author: Drikish • Posted: 2025-01-11T18:47:04.462000+00:00
Original source
Ah ok
Archived author: Northstrider • Posted: 2025-01-11T18:47:06.908000+00:00
Original source
a protection to make sure outdated/broken spell scripts wont load
Archived author: Drikish • Posted: 2025-01-11T18:47:19.548000+00:00
Original source
makes sense
Archived author: Drikish • Posted: 2025-01-11T18:47:32.857000+00:00
Original source
So anything your working with within the script should be validated to check that it exists before trying to use it
Archived author: Northstrider • Posted: 2025-01-11T18:48:01.650000+00:00
Original source
whenever you want to use another spell or reference a spell effect, you always validate the spellInfo and the effect itself
Archived author: Drikish • Posted: 2025-01-11T18:48:11.724000+00:00
Original source
ok thanks
Archived author: Drikish • Posted: 2025-01-11T18:48:15.392000+00:00
Original source
```c++
class spell_mage_arcane_barrage : public SpellScript
{
PrepareSpellScript(spell_mage_arcane_barrage);
bool Validate(SpellInfo const* spellInfo) override
{
return ValidateSpellInfo({ SPELL_MAGE_ARCANE_BARRAGE });
}
void ConsumeArcaneCharges()
{
GetCaster()->SetPower(POWER_ARCANE_CHARGES, 0);
}
void HandleEffectHitTarget(SpellEffIndex /*effIndex*/)
{
Unit* caster = GetCaster();
// If its not the primary target it uses effect 1 which hits for 50% damage - set this first before next check
if (GetHitUnit()->GetGUID() != _primaryTarget)
SetHitDamage(CalculatePct(GetHitDamage(), GetEffectInfo(EFFECT_1)->CalcValue(GetCaster())));
// If Player has the talent Resonance add % value per target hit
if (AuraEffect const* auraEffect = caster->GetAuraEffect(TALENT_MAGE_RESONANCE, EFFECT_0, caster->GetGUID()))
SetHitDamage(GetHitDamage() + CalculatePct(GetHitDamage(), auraEffect->GetAmount() * 5));
//GetSpell()->m_targets
}
void CountTargets(std::list<WorldObject*>& targets)
{
_targets = targets.size();
}
void MarkPrimaryTarget(SpellEffIndex /*effIndex*/)
{
_primaryTarget = GetHitUnit()->GetGUID();
}
void Register() override
{
OnEffectHitTarget += SpellEffectFn(spell_mage_arcane_barrage::HandleEffectHitTarget, EFFECT_0, SPELL_EFFECT_SCHOOL_DAMAGE);
OnEffectLaunchTarget += SpellEffectFn(spell_mage_arcane_barrage::MarkPrimaryTarget, EFFECT_1, SPELL_EFFECT_DUMMY);
AfterCast += SpellCastFn(spell_mage_arcane_barrage::ConsumeArcaneCharges);
}
int32 _targets;
ObjectGuid _primaryTarget;
};
```
Archived author: Drikish • Posted: 2025-01-11T18:48:32.252000+00:00
Original source
This is what I have so far, (I replaced the bit I need to fix with * 5 right now just so i could compile and test)