resolve the precast not stopping spell cast

This commit is contained in:
Emagi 2024-04-10 20:10:44 -04:00
parent c98a2997d7
commit 92ca3bac38

View file

@ -1534,11 +1534,16 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
if (lua_interface) { if (lua_interface) {
bool result = false; bool result = false;
std::string outCall = lua_interface->AddSpawnPointers(lua_spell, false, true); std::string outCall = lua_interface->AddSpawnPointers(lua_spell, false, true);
if (outCall.length() > 0 && lua_pcall(lua_spell->state, 2, 2, 0) == 0) { if (outCall.length() > 0 && lua_pcall(lua_spell->state, 2, LUA_MULTRET, 0) == 0) {
result = lua_interface->GetBooleanValue(lua_spell->state, 1); int8 error = SPELL_ERROR_CANNOT_PREPARE;
int8 error = lua_interface->GetInt8Value(lua_spell->state, 2) == 0 ? SPELL_ERROR_CANNOT_PREPARE : lua_interface->GetInt8Value(lua_spell->state, 2); if (lua_toboolean(lua_spell->state, -1))
{
result = lua_toboolean(lua_spell->state, -1);
lua_pop(lua_spell->state, 1);
}
lua_interface->ResetFunctionStack(lua_spell->state); lua_interface->ResetFunctionStack(lua_spell->state);
// need to add back support for error to be modified
if (!result) { if (!result) {
zone->SendSpellFailedPacket(client, error); zone->SendSpellFailedPacket(client, error);
lua_spell->caster->GetZone()->GetSpellProcess()->RemoveSpellScriptTimerBySpell(lua_spell); lua_spell->caster->GetZone()->GetSpellProcess()->RemoveSpellScriptTimerBySpell(lua_spell);