1
0

RemoveSpellBonus should only remove the target if specified, otherwise it can remove the entire target set/group accidentally

This commit is contained in:
Emagi 2025-01-19 09:59:42 -05:00
parent e9936f1c80
commit b985613791

View File

@ -2578,7 +2578,12 @@ int EQ2Emu_lua_RemoveSpellBonus(lua_State* state) {
Spawn* spawn = lua_interface->GetSpawn(state); Spawn* spawn = lua_interface->GetSpawn(state);
LuaSpell* luaspell = lua_interface->GetCurrentSpell(state); LuaSpell* luaspell = lua_interface->GetCurrentSpell(state);
lua_interface->ResetFunctionStack(state); lua_interface->ResetFunctionStack(state);
if (luaspell && luaspell->spell) { if (spawn && spawn->IsEntity()) {
((Entity*)spawn)->RemoveSpellBonus(luaspell);
if (spawn->IsPlayer())
((Player*)spawn)->SetCharSheetChanged(true);
}
else if (luaspell && luaspell->spell) {
ZoneServer* zone = nullptr; ZoneServer* zone = nullptr;
if (luaspell->caster != nullptr) if (luaspell->caster != nullptr)
zone = luaspell->caster->GetZone(); zone = luaspell->caster->GetZone();
@ -2602,11 +2607,6 @@ int EQ2Emu_lua_RemoveSpellBonus(lua_State* state) {
LogWrite(LUA__ERROR, 0, "LUA", "Error removing spell bonus buff %s called by %s, zone is not available.", luaspell->spell ? luaspell->spell->GetName() : "NotSet", spawn ? spawn->GetName() : "N/A"); LogWrite(LUA__ERROR, 0, "LUA", "Error removing spell bonus buff %s called by %s, zone is not available.", luaspell->spell ? luaspell->spell->GetName() : "NotSet", spawn ? spawn->GetName() : "N/A");
} }
} }
else if (spawn && spawn->IsEntity()) {
((Entity*)spawn)->RemoveSpellBonus(luaspell);
if (spawn->IsPlayer())
((Player*)spawn)->SetCharSheetChanged(true);
}
return 0; return 0;
} }