[Quest API] Add EVENT_DESTROY_ITEM_CLIENT to Perl/Lua. (#2871)

* [Quest API] Add EVENT_DESTROY_ITEM_CLIENT to Perl/Lua.

- Add `EVENT_DESTROY_ITEM_CLIENT`, exports `$item_id`, `$item_name`, `$quantity`, and `$item`.

- Add `event_destroy_item_client`, exports `e.item_id`, `e.item_name`, `e.quantity`, and `e.item`.

- Allows operators to use player scripts for item destroys.

* Update lua_parser_events.h

* Update inventory.cpp
This commit is contained in:
Alex King
2023-02-13 00:58:27 -05:00
committed by GitHub
parent 24de1d948a
commit d4afc78982
7 changed files with 83 additions and 6 deletions
+31 -4
View File
@@ -1130,7 +1130,16 @@ void Client::SendCursorBuffer()
LogInventory("([{}]) Duplicate lore items are not allowed - destroying item [{}](id:[{}]) on cursor",
GetName(), test_item->Name, test_item->ID);
MessageString(Chat::Loot, 290);
parse->EventItem(EVENT_DESTROY_ITEM, this, test_inst, nullptr, "", 0);
if (parse->ItemHasQuestSub(test_inst, EVENT_DESTROY_ITEM)) {
parse->EventItem(EVENT_DESTROY_ITEM, this, test_inst, nullptr, "", 0);
}
if (parse->PlayerHasQuestSub(EVENT_DESTROY_ITEM_CLIENT)) {
std::vector<std::any> args = { test_inst };
parse->EventPlayer(EVENT_DESTROY_ITEM_CLIENT, this, "", 0, &args);
}
DeleteItemInInventory(EQ::invslot::slotCursor);
SendCursorBuffer();
}
@@ -1861,7 +1870,16 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
LogInventory("([{}]) Duplicate lore items are not allowed - destroying item [{}](id:[{}]) on cursor",
GetName(), test_item->Name, test_item->ID);
MessageString(Chat::Loot, 290);
parse->EventItem(EVENT_DESTROY_ITEM, this, test_inst, nullptr, "", 0);
if (parse->ItemHasQuestSub(test_inst, EVENT_DESTROY_ITEM)) {
parse->EventItem(EVENT_DESTROY_ITEM, this, test_inst, nullptr, "", 0);
}
if (parse->PlayerHasQuestSub(EVENT_DESTROY_ITEM_CLIENT)) {
std::vector<std::any> args = { test_inst };
parse->EventPlayer(EVENT_DESTROY_ITEM_CLIENT, this, "", 0, &args);
}
DeleteItemInInventory(EQ::invslot::slotCursor, 0, true);
if (player_event_logs.IsEventEnabled(PlayerEvent::ITEM_DESTROY)) {
@@ -1886,8 +1904,8 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
if(RuleB(QueryServ, PlayerLogMoves)) { QSSwapItemAuditor(move_in); } // QS Audit
EQ::ItemInstance *inst = m_inv.GetItem(EQ::invslot::slotCursor);
if(inst) {
parse->EventItem(EVENT_DESTROY_ITEM, this, inst, nullptr, "", 0);
if (inst) {
if (player_event_logs.IsEventEnabled(PlayerEvent::ITEM_DESTROY)) {
auto e = PlayerEvent::DestroyItemEvent{
.item_id = inst->GetItem()->ID,
@@ -1898,6 +1916,15 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
RecordPlayerEventLog(PlayerEvent::ITEM_DESTROY, e);
}
if (parse->ItemHasQuestSub(inst, EVENT_DESTROY_ITEM)) {
parse->EventItem(EVENT_DESTROY_ITEM, this, inst, nullptr, "", 0);
}
if (parse->PlayerHasQuestSub(EVENT_DESTROY_ITEM_CLIENT)) {
std::vector<std::any> args = { inst };
parse->EventPlayer(EVENT_DESTROY_ITEM_CLIENT, this, "", 0, &args);
}
}
DeleteItemInInventory(move_in->from_slot);