[Quest API] Add EVENT_LOOT_ADDED to Perl/Lua (#3739)

* [Quest API] Add EVENT_ADDED_LOOT to Perl/Lua

# Perl
- Add `EVENT_ADDED_LOOT`.
- Exports `$item`, `$item_id`, `$item_name`, `$item_charges`, `$augment_one`, `$augment_two`, `$augment_three`, `$augment_four`, `$augment_five`, and `$augment_six`.

# Lua
- Add `event_added_loot`.
- Exports `e.item`, `e.item_id`, `e.item_name`, `e.item_charges`, `e.augment_one`, `e.augment_two`, `e.augment_three`, `e.augment_four`, `e.augment_five`, and `e.augment_six`.

# Notes
- Allows operators to perform events when loot is added to an NPC, such as removing the loot or keeping track of it.

* Update lua_parser_events.cpp

* Rename event.

* loot_added

* AddItem changese
This commit is contained in:
Alex King
2023-12-16 23:25:09 -05:00
committed by GitHub
parent 9c238cd08d
commit c1b07afae9
8 changed files with 347 additions and 226 deletions
+57
View File
@@ -492,6 +492,63 @@ void handle_npc_damage(
lua_setfield(L, -2, "other");
}
void handle_npc_loot_added(
QuestInterface *parse,
lua_State* L,
NPC* npc,
Mob* init,
std::string data,
uint32 extra_data,
std::vector<std::any> *extra_pointers
) {
if (extra_pointers && extra_pointers->size() == 1) {
auto *inst = std::any_cast<EQ::ItemInstance *>(extra_pointers->at(0));
auto *item = database.GetItem(inst->GetID());
if (item) {
Lua_Item l_item(item);
luabind::adl::object l_item_o = luabind::adl::object(L, l_item);
l_item_o.push(L);
lua_setfield(L, -2, "item");
} else {
Lua_Item l_item(nullptr);
luabind::adl::object l_item_o = luabind::adl::object(L, l_item);
l_item_o.push(L);
lua_setfield(L, -2, "item");
}
if (inst) {
lua_pushinteger(L, inst->GetID());
lua_setfield(L, -2, "item_id");
lua_pushstring(L, inst->GetItem()->Name);
lua_setfield(L, -2, "item_name");
lua_pushinteger(L, inst->GetCharges());
lua_setfield(L, -2, "item_charges");
lua_pushinteger(L, inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN));
lua_setfield(L, -2, "augment_one");
lua_pushinteger(L, inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 1));
lua_setfield(L, -2, "augment_two");
lua_pushinteger(L, inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 2));
lua_setfield(L, -2, "augment_three");
lua_pushinteger(L, inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 3));
lua_setfield(L, -2, "augment_four");
lua_pushinteger(L, inst->GetAugmentItemID(EQ::invaug::SOCKET_BEGIN + 4));
lua_setfield(L, -2, "augment_five");
lua_pushinteger(L, inst->GetAugmentItemID(EQ::invaug::SOCKET_END));
lua_setfield(L, -2, "augment_six");
}
}
}
// Player
void handle_player_say(
QuestInterface *parse,