function call fixes and resets for procs / call spell process
This commit is contained in:
parent
b7802d84db
commit
56e43288bf
@ -1721,54 +1721,58 @@ bool Entity::CastProc(Proc* proc, int8 type, Spawn* target) {
|
||||
else {
|
||||
lua_getglobal(state, "proc");
|
||||
}
|
||||
if (item_proc) {
|
||||
num_args++;
|
||||
lua_interface->SetItemValue(state, proc->item);
|
||||
}
|
||||
|
||||
lua_interface->SetSpawnValue(state, this);
|
||||
lua_interface->SetSpawnValue(state, target);
|
||||
lua_interface->SetInt32Value(state, type);
|
||||
lua_interface->SetInt32Value(state, proc->damage_type);
|
||||
|
||||
/*
|
||||
Add spell data from db in case of a spell proc here...
|
||||
*/
|
||||
if (!item_proc) {
|
||||
// Append spell data to the param list
|
||||
vector<LUAData*>* data = proc->spell->spell->GetLUAData();
|
||||
for(int32 i = 0; i < data->size(); i++) {
|
||||
switch(data->at(i)->type) {
|
||||
case 0:{
|
||||
lua_interface->SetSInt32Value(proc->spell->state, data->at(i)->int_value);
|
||||
break;
|
||||
}
|
||||
case 1:{
|
||||
lua_interface->SetFloatValue(proc->spell->state, data->at(i)->float_value);
|
||||
break;
|
||||
}
|
||||
case 2:{
|
||||
lua_interface->SetBooleanValue(proc->spell->state, data->at(i)->bool_value);
|
||||
break;
|
||||
}
|
||||
case 3:{
|
||||
lua_interface->SetStringValue(proc->spell->state, data->at(i)->string_value.c_str());
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
LogWrite(SPELL__ERROR, 0, "Spell", "Error: Unknown LUA Type '%i' in Entity::CastProc for Spell '%s'", (int)data->at(i)->type, proc->spell->spell->GetName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if (lua_isfunction(state, -1)) {
|
||||
if (item_proc) {
|
||||
num_args++;
|
||||
lua_interface->SetItemValue(state, proc->item);
|
||||
}
|
||||
|
||||
lua_interface->SetSpawnValue(state, this);
|
||||
lua_interface->SetSpawnValue(state, target);
|
||||
lua_interface->SetInt32Value(state, type);
|
||||
lua_interface->SetInt32Value(state, proc->damage_type);
|
||||
|
||||
/*
|
||||
Add spell data from db in case of a spell proc here...
|
||||
*/
|
||||
if (!item_proc) {
|
||||
// Append spell data to the param list
|
||||
vector<LUAData*>* data = proc->spell->spell->GetLUAData();
|
||||
for(int32 i = 0; i < data->size(); i++) {
|
||||
switch(data->at(i)->type) {
|
||||
case 0:{
|
||||
lua_interface->SetSInt32Value(proc->spell->state, data->at(i)->int_value);
|
||||
break;
|
||||
}
|
||||
case 1:{
|
||||
lua_interface->SetFloatValue(proc->spell->state, data->at(i)->float_value);
|
||||
break;
|
||||
}
|
||||
case 2:{
|
||||
lua_interface->SetBooleanValue(proc->spell->state, data->at(i)->bool_value);
|
||||
break;
|
||||
}
|
||||
case 3:{
|
||||
lua_interface->SetStringValue(proc->spell->state, data->at(i)->string_value.c_str());
|
||||
break;
|
||||
}
|
||||
default:{
|
||||
LogWrite(SPELL__ERROR, 0, "Spell", "Error: Unknown LUA Type '%i' in Entity::CastProc for Spell '%s'", (int)data->at(i)->type, proc->spell->spell->GetName());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
num_args++;
|
||||
}
|
||||
}
|
||||
|
||||
if (lua_pcall(state, num_args, 0, 0) != 0) {
|
||||
LogWrite(COMBAT__ERROR, 0, "Proc", "Unable to call the proc function for spell %i tier %i", proc->spell->spell->GetSpellID(), proc->spell->spell->GetSpellTier());
|
||||
lua_pop(state, 1);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (lua_pcall(state, num_args, 0, 0) != 0) {
|
||||
LogWrite(COMBAT__ERROR, 0, "Proc", "Unable to call the proc function for spell %i tier %i", proc->spell->spell->GetSpellID(), proc->spell->spell->GetSpellTier());
|
||||
lua_pop(state, 1);
|
||||
return false;
|
||||
}
|
||||
|
||||
lua_interface->ResetFunctionStack(state);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -674,9 +674,11 @@ bool LuaInterface::CallSpellProcess(LuaSpell* spell, int8 num_parameters, std::s
|
||||
if(lua_pcall(spell->state, num_parameters, 0, 0) != 0){
|
||||
LogError("Error running function '%s' in %s: %s", customFunction.c_str(), spell->spell->GetName(), lua_tostring(spell->state, -1));
|
||||
lua_pop(spell->state, 1);
|
||||
ResetFunctionStack(spell->state);
|
||||
RemoveSpell(spell, false); // may be in a lock
|
||||
return false;
|
||||
}
|
||||
ResetFunctionStack(spell->state);
|
||||
return true;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user