mirror of
https://github.com/EQEmu/Server.git
synced 2026-06-10 02:31:03 +00:00
[Quest API] Export corpse in EVENT_DEATH_COMPLETE (#2519)
It wasn't possible to easily obtain the corpse from post-death events because the killed entity id is assigned to the corpse and reset to 0 on the entity before the events are dispatched. This exposes the killed entity's corpse to EVENT_DEATH_COMPLETE and EVENT_DEATH_ZONE. Lua exports a Corpse object and perl exports a corpse entity id. The purpose of this is to make it easier to add items dynamically on death. Ideally this would be done in EVENT_DEATH before the corpse is made, but there's currently some combat system bugs that make that event unusable since it can be dispatched multiple times. A follow up will provide an api to reset corpse decay times since adding items after corpse creation will require quests to manually reset the decay timer in case the corpse had zero items.
This commit is contained in:
@@ -210,9 +210,17 @@ void handle_npc_death(QuestInterface *parse, lua_State* L, NPC* npc, Mob *init,
|
||||
lua_pushinteger(L, std::stoi(sep.arg[3]));
|
||||
lua_setfield(L, -2, "skill_id");
|
||||
|
||||
if (extra_pointers && !extra_pointers->empty())
|
||||
if (extra_pointers && extra_pointers->size() >= 1)
|
||||
{
|
||||
Lua_NPC l_npc(std::any_cast<NPC*>(extra_pointers->at(0)));
|
||||
Lua_Corpse l_corpse(std::any_cast<Corpse*>(extra_pointers->at(0)));
|
||||
luabind::adl::object l_corpse_o = luabind::adl::object(L, l_corpse);
|
||||
l_corpse_o.push(L);
|
||||
lua_setfield(L, -2, "corpse");
|
||||
}
|
||||
|
||||
if (extra_pointers && extra_pointers->size() >= 2)
|
||||
{
|
||||
Lua_NPC l_npc(std::any_cast<NPC*>(extra_pointers->at(1)));
|
||||
luabind::adl::object l_npc_o = luabind::adl::object(L, l_npc);
|
||||
l_npc_o.push(L);
|
||||
lua_setfield(L, -2, "killed");
|
||||
|
||||
Reference in New Issue
Block a user