Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat(LuaEngine/SpellHooks): Add support for RegisterSpellEvent with initial events #224

Merged
merged 2 commits into from
Jan 23, 2025

Conversation

iThorgrim
Copy link

This pull request integrates the RegisterSpellEvent system from the TrinityCore version of Eluna into AzerothCore, allowing scripts to handle specific spell-related events.

Supported Events

  1. SPELL_EVENT_ON_PREPARE
    Triggered when a spell is prepared.
    Signature: (event, caster, spell)

  2. SPELL_EVENT_ON_CAST
    Triggered when a spell is cast.
    Signature: (event, caster, spell, skipCheck)

  3. SPELL_EVENT_ON_CAST_CANCEL
    Triggered when a spell cast is canceled.
    Signature: (event, caster, spell, bySelf)

Example Usage

lcoal SPELL_EVENT_ON_PREPARE = 1

local function OnSpellPrepare(event, caster, spell)
    print("RegisterSpellEvent :: OnPrepare")
end

RegisterSpellEvent(133, SPELL_EVENT_ON_PREPARE, OnSpellPrepare)

Test performed :

SPELL_EVENT_ON_PREPARE = 1
SPELL_EVENT_ON_CAST = 2
SPELL_EVENT_ON_CAST_CANCEL = 3

-- Test function for SPELL_EVENT_ON_PREPARE
local function OnSpellPrepare(event, caster, spell)
    print("Test: OnPrepare triggered for spell ID:", spell:GetEntry())
end

-- Test function for SPELL_EVENT_ON_CAST
local function OnSpellCast(event, caster, spell, skipCheck)
    print("Test: OnCast triggered for spell ID:", spell:GetEntry(), "SkipCheck:", skipCheck)
end

-- Test function for SPELL_EVENT_ON_CAST_CANCEL
local function OnSpellCastCancel(event, caster, spell, bySelf)
    print("Test: OnCastCancel triggered for spell ID:", spell:GetEntry(), "Cancelled by self:", bySelf)
end

-- Register events for Fireball (ID: 133)
RegisterSpellEvent(133, SPELL_EVENT_ON_PREPARE, OnSpellPrepare)
RegisterSpellEvent(133, SPELL_EVENT_ON_CAST, OnSpellCast)
RegisterSpellEvent(133, SPELL_EVENT_ON_CAST_CANCEL, OnSpellCastCancel)

Results:
image

Desktop.2025-01-22.17-11-52.1.mp4

@55Honey 55Honey merged commit 49fb60a into azerothcore:master Jan 23, 2025
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants