diff --git a/zone/embparser.cpp b/zone/embparser.cpp index c74b7de42..2747dd6f1 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -125,7 +125,9 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_COMBINE", "EVENT_CONSIDER", "EVENT_CONSIDER_CORPSE", - "EVENT_LOOT_ZONE" + "EVENT_LOOT_ZONE", + "EVENT_EQUIP_ITEM_CLIENT", + "EVENT_UNEQUIP_ITEM_CLIENT" }; PerlembParser::PerlembParser() : perl(nullptr) @@ -1689,6 +1691,15 @@ void PerlembParser::ExportEventVariables( break; } + case EVENT_EQUIP_ITEM_CLIENT: + case EVENT_UNEQUIP_ITEM_CLIENT: { + Seperator sep(data); + ExportVar(package_name.c_str(), "item_id", extradata); + ExportVar(package_name.c_str(), "item_quantity", sep.arg[0]); + ExportVar(package_name.c_str(), "slot_id", sep.arg[1]); + break; + } + default: { break; } diff --git a/zone/event_codes.h b/zone/event_codes.h index 8aebee1a7..e808091ff 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -94,6 +94,8 @@ typedef enum { EVENT_CONSIDER, EVENT_CONSIDER_CORPSE, EVENT_LOOT_ZONE, + EVENT_EQUIP_ITEM_CLIENT, + EVENT_UNEQUIP_ITEM_CLIENT, _LargestEventID } QuestEventID; diff --git a/zone/inventory.cpp b/zone/inventory.cpp index 41e67e7b9..93742db1e 100644 --- a/zone/inventory.cpp +++ b/zone/inventory.cpp @@ -2205,20 +2205,52 @@ bool Client::SwapItem(MoveItem_Struct* move_in) { if (src_slot_id <= EQ::invslot::EQUIPMENT_END) { if(src_inst) { parse->EventItem(EVENT_UNEQUIP_ITEM, this, src_inst, nullptr, "", src_slot_id); + + std::string export_string = fmt::format( + "{} {}", + src_inst->IsStackable() ? src_inst->GetCharges() : 1, + src_slot_id + ); + + parse->EventPlayer(EVENT_UNEQUIP_ITEM_CLIENT, this, export_string, src_inst->GetItem()->ID); } if(dst_inst) { parse->EventItem(EVENT_EQUIP_ITEM, this, dst_inst, nullptr, "", src_slot_id); + + std::string export_string = fmt::format( + "{} {}", + dst_inst->IsStackable() ? dst_inst->GetCharges() : 1, + src_slot_id + ); + + parse->EventPlayer(EVENT_EQUIP_ITEM_CLIENT, this, export_string, dst_inst->GetItem()->ID); } } if (dst_slot_id <= EQ::invslot::EQUIPMENT_END) { if(dst_inst) { parse->EventItem(EVENT_UNEQUIP_ITEM, this, dst_inst, nullptr, "", dst_slot_id); + + std::string export_string = fmt::format( + "{} {}", + dst_inst->IsStackable() ? dst_inst->GetCharges() : 1, + dst_slot_id + ); + + parse->EventPlayer(EVENT_UNEQUIP_ITEM_CLIENT, this, export_string, dst_inst->GetItem()->ID); } if(src_inst) { parse->EventItem(EVENT_EQUIP_ITEM, this, src_inst, nullptr, "", dst_slot_id); + + std::string export_string = fmt::format( + "{} {}", + src_inst->IsStackable() ? src_inst->GetCharges() : 1, + dst_slot_id + ); + + parse->EventPlayer(EVENT_EQUIP_ITEM_CLIENT, this, export_string, src_inst->GetItem()->ID); } } } diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index db4394b0f..b6d1d93b8 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -4212,7 +4212,9 @@ luabind::scope lua_register_events() { luabind::value("test_buff", static_cast(EVENT_TEST_BUFF)), luabind::value("consider", static_cast(EVENT_CONSIDER)), luabind::value("consider_corpse", static_cast(EVENT_CONSIDER_CORPSE)), - luabind::value("loot_zone", static_cast(EVENT_LOOT_ZONE)) + luabind::value("loot_zone", static_cast(EVENT_LOOT_ZONE)), + luabind::value("equip_item_client", static_cast(EVENT_EQUIP_ITEM_CLIENT)), + luabind::value("unequip_item_client", static_cast(EVENT_UNEQUIP_ITEM_CLIENT)) ]; } diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index 2b1f89574..5183f5aaa 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -136,7 +136,9 @@ const char *LuaEvents[_LargestEventID] = { "event_combine", "event_consider", "event_consider_corpse", - "event_loot_zone" + "event_loot_zone", + "event_equip_item_client", + "event_unequip_item_client" }; extern Zone *zone; @@ -227,7 +229,8 @@ LuaParser::LuaParser() { PlayerArgumentDispatch[EVENT_WARP] = handle_player_warp; PlayerArgumentDispatch[EVENT_COMBINE] = handle_player_quest_combine; PlayerArgumentDispatch[EVENT_CONSIDER] = handle_player_consider; - PlayerArgumentDispatch[EVENT_CONSIDER_CORPSE] = handle_player_consider_corpse; + PlayerArgumentDispatch[EVENT_EQUIP_ITEM_CLIENT] = handle_player_equip_item; + PlayerArgumentDispatch[EVENT_UNEQUIP_ITEM_CLIENT] = handle_player_equip_item; ItemArgumentDispatch[EVENT_ITEM_CLICK] = handle_item_click; ItemArgumentDispatch[EVENT_ITEM_CLICK_CAST] = handle_item_click; diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index 9adc0981e..d0421c86d 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -760,6 +760,24 @@ void handle_translocate_finish(QuestInterface *parse, lua_State* L, NPC* npc, Cl lua_setfield(L, -2, "target"); } +void handle_player_equip_item(QuestInterface *parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector *extra_pointers) { + lua_pushnumber(L, extra_data); + lua_setfield(L, -2, "item_id"); + + Seperator sep(data.c_str()); + + lua_pushnumber(L, std::stoi(sep.arg[0])); + lua_setfield(L, -2, "item_quantity"); + + lua_pushnumber(L, std::stoi(sep.arg[1])); + lua_setfield(L, -2, "slot_id"); + + Lua_ItemInst l_item(extra_data); + luabind::adl::object l_item_o = luabind::adl::object(L, l_item); + l_item_o.push(L); + lua_setfield(L, -2, "item"); +} + void handle_spell_null(QuestInterface *parse, lua_State* L, NPC* npc, Client* client, uint32 spell_id, std::string data, uint32 extra_data, std::vector *extra_pointers) { } void handle_encounter_timer(QuestInterface *parse, lua_State* L, Encounter* encounter, std::string data, uint32 extra_data, diff --git a/zone/lua_parser_events.h b/zone/lua_parser_events.h index 5eced1243..bae1b11b8 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -113,6 +113,8 @@ void handle_player_consider(QuestInterface* parse, lua_State* L, Client* client, std::vector* extra_pointers); void handle_player_consider_corpse(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, std::vector* extra_pointers); +void handle_player_equip_item(QuestInterface* parse, lua_State* L, Client* client, std::string data, uint32 extra_data, + std::vector* extra_pointers); //Item void handle_item_click(QuestInterface *parse, lua_State* L, Client* client, EQ::ItemInstance* item, Mob *mob, std::string data, uint32 extra_data,