Browse Source

restore ability to set custom spell errors on precast, return { cast_allowed_boolean, cast_error_num }, eg return { false, 1 } will not allow casting and return not enough knowledge

Emagi 2 weeks ago
parent
commit
5d80136092
1 changed files with 14 additions and 1 deletions
  1. 14 1
      EQ2/source/WorldServer/SpellProcess.cpp

+ 14 - 1
EQ2/source/WorldServer/SpellProcess.cpp

@@ -1536,7 +1536,20 @@ void SpellProcess::ProcessSpell(ZoneServer* zone, Spell* spell, Entity* caster,
 			std::string outCall = lua_interface->AddSpawnPointers(lua_spell, false, true);
 			if (outCall.length() > 0 && lua_pcall(lua_spell->state, 2, LUA_MULTRET, 0) == 0) {
 				int8 error = SPELL_ERROR_CANNOT_PREPARE;
-				if (lua_toboolean(lua_spell->state, -1))
+				if(lua_istable(lua_spell->state, -1)) {
+					lua_rawgeti(lua_spell->state, -1, 1);
+					if(lua_isboolean(lua_spell->state, -1)) {
+						result = lua_toboolean(lua_spell->state,-1);
+					}
+					lua_pop(lua_spell->state, 1);
+					
+					lua_rawgeti(lua_spell->state, -1, 2);
+					if(lua_isnumber(lua_spell->state, -1)) {
+						error = lua_tonumber(lua_spell->state,-1);
+					}
+					lua_pop(lua_spell->state, 1);
+				}
+				else if (lua_toboolean(lua_spell->state, -1))
 				{
 					result = lua_toboolean(lua_spell->state, -1);
 					lua_pop(lua_spell->state, 1);