New LUA Function: Interrupt
Just getting the new function into the LUA system seems to take 3 parts - LuaInterface.cpp (registering), and the function/declaration in LuaFunctions.cpp/h.
Register the LUA Function (LuaInterface.cpp):
Code: Select all
lua_register(state, "Interrupt", EQ2Emu_lua_Interrupt);Code: Select all
int EQ2Emu_lua_Interrupt(lua_State* state);Code: Select all
int EQ2Emu_lua_Interrupt(lua_State* state)
{
if (!lua_interface)
return 0;
Spawn* caster = lua_interface->GetSpawn(state); // Second param in lua_interface->get functions defaults to 1
Spawn* target = lua_interface->GetSpawn(state, 2);
if (!caster) {
lua_interface->LogError("LUA Interrupt command error: caster is not a valid spawn");
return 0;
}
if(!target) {
lua_interface->LogError("LUA Interrupt command error: target is not a valid spawn");
return 0;
}
if (!target->IsEntity()) {
lua_interface->LogError("LUA Interrupt command error: Target is not an entity");
return 0;
}
caster->GetZone()->GetSpellProcess()->Interrupted((Entity*)target, caster, SPELL_ERROR_INTERRUPTED);
return 0;
}UPDATED! With the guidance below, I have updated this OP to show the full build out of this function. Thanks guys!
FYI, this is for my first CoE+ spell "Provoke", and already ran into something I need help with
Thanks in advance