Below is the working script that corresponds to the example I posted about the spell that triggers the cast of either a
lower/higher rank pet summon spell depending upon the level of the caster.
Code:
function event_spell_effect(e)
local P_LVL = e.target:GetLevel();
e.target:Message(15, "My CASTER_ID is: "..e.caster_id);
e.target:Message(15, "My LEVEL IS: "..P_LVL);
if(P_LVL <=50) then
e.target:CastSpell(12001, e.caster_id); -- Summons lower level Pet
elseif(P_LVL >50) then
e.target:CastSpell(12002, e.caster_id); -- Summons higher level Pet
end
end
This only works when casting the main spell via the #cast command.
From what I can figure out, when casting the main spell from a spell gem it must begin the cast and then process the script.
However, when using the #cast command it must process the script before the cast of the main spell actually takes place
because the appropriate second spell immediately begins its cast sequence when the command is activated.
I'm moving on to using the global_player.lua file for what I need until I can find another way, but I felt like sharing this information - maybe it will help someone.