• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

C++ spell script

Status
Not open for further replies.

AlexeWarr

Epic Member
If someone of you guys can write a spell script example in C++? Where:

1. Give a message when just started to cast the spell
2. When the spell casted successfully
3. When the spell failed, interrupted
 

Tommy

Founder
I didn't know how to do the interrupt correctly, but I'm assuming you check OnCast considering the player/creature will be casting the spell. You could play with it a bit though. :D

Code:
class spell_script : public SpellScriptLoader
{
public:
    spell_script() : SpellScriptLoader("spell_script") { }

    class spell_script_SpellScript : public SpellScript
    {
        PrepareSpellScript(spell_script_SpellScript);

        void SayAfterCast()
        {
            GetCaster()->MonsterYell("RAWRWARWA", LANG_UNIVERSAL, 0);
        }

        void SayOnCast()
        {
            GetCaster()->MonsterYell("RAWRWAXAWIUD", LANG_UNIVERSAL, 0);
        }

        void Register()
        {
            OnCast += SpellCastFn(spell_script_SpellScript::SayOnCast);
            AfterCast += SpellCastFn(spell_script_SpellScript::SayAfterCast);
        }
    };

    SpellScript* GetSpellScript() const
    {
        return new spell_script_SpellScript();
    }
};

void AddSC_tutorial_aura()
{
    new spell_script;
}
 
Status
Not open for further replies.
Top