diff --git a/zone/bot.cpp b/zone/bot.cpp index fe8073e9d..7a0bf77b0 100644 --- a/zone/bot.cpp +++ b/zone/bot.cpp @@ -5074,6 +5074,13 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* BotRemoveEquipItem(return_iterator.from_bot_slot); + const auto export_string = fmt::format( + "{} {}", + return_iterator.return_item_instance->IsStackable() ? return_iterator.return_item_instance->GetCharges() : 1, + return_iterator.from_bot_slot + ); + + parse->EventBot(EVENT_UNEQUIP_ITEM_BOT, this, nullptr, export_string , return_iterator.return_item_instance->GetID()); if (return_instance) { EQ::SayLinkEngine linker; linker.SetLinkType(EQ::saylink::SayLinkItemInst); @@ -5122,6 +5129,15 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client* m_inv.PutItem(trade_iterator.to_bot_slot, *trade_iterator.trade_item_instance); BotAddEquipItem(trade_iterator.to_bot_slot, (trade_iterator.trade_item_instance ? trade_iterator.trade_item_instance->GetID() : 0)); + + const auto export_string = fmt::format( + "{} {}", + trade_iterator.trade_item_instance->IsStackable() ? trade_iterator.trade_item_instance->GetCharges() : 1, + trade_iterator.to_bot_slot + ); + + parse->EventBot(EVENT_EQUIP_ITEM_BOT, this, nullptr, export_string , trade_iterator.trade_item_instance->GetID()); + trade_iterator.trade_item_instance = nullptr; // actual deletion occurs in client delete below client->DeleteItemInInventory(trade_iterator.from_client_slot, 0, (trade_iterator.from_client_slot == EQ::invslot::slotCursor)); diff --git a/zone/bot_command.cpp b/zone/bot_command.cpp index 9c5251083..f41116949 100644 --- a/zone/bot_command.cpp +++ b/zone/bot_command.cpp @@ -9477,6 +9477,14 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep) slot_id ) ); + + const auto export_string = fmt::format( + "{} {}", + inst->IsStackable() ? inst->GetCharges() : 1, + slot_id + ); + + parse->EventBot(EVENT_UNEQUIP_ITEM_BOT, my_bot, nullptr, export_string, inst->GetID()); } } diff --git a/zone/embparser.cpp b/zone/embparser.cpp index 3b895a63c..2d8bf4bf4 100644 --- a/zone/embparser.cpp +++ b/zone/embparser.cpp @@ -169,6 +169,8 @@ const char *QuestEventSubroutines[_LargestEventID] = { "EVENT_BOT_CREATE", "EVENT_AUGMENT_INSERT_CLIENT", "EVENT_AUGMENT_REMOVE_CLIENT", + "EVENT_EQUIP_ITEM_BOT", + "EVENT_UNEQUIP_ITEM_BOT", // Add new events before these or Lua crashes "EVENT_SPELL_EFFECT_BOT", "EVENT_SPELL_EFFECT_BUFF_TIC_BOT" @@ -1901,6 +1903,15 @@ void PerlembParser::ExportEventVariables( break; } + case EVENT_EQUIP_ITEM_BOT: + case EVENT_UNEQUIP_ITEM_BOT: { + 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; + } + case EVENT_AUGMENT_INSERT_CLIENT: case EVENT_AUGMENT_REMOVE_CLIENT: { Seperator sep(data); diff --git a/zone/event_codes.h b/zone/event_codes.h index 2c56f42c6..b48838d19 100644 --- a/zone/event_codes.h +++ b/zone/event_codes.h @@ -114,6 +114,8 @@ typedef enum { EVENT_BOT_CREATE, EVENT_AUGMENT_INSERT_CLIENT, EVENT_AUGMENT_REMOVE_CLIENT, + EVENT_EQUIP_ITEM_BOT, + EVENT_UNEQUIP_ITEM_BOT, // Add new events before these or Lua crashes EVENT_SPELL_EFFECT_BOT, EVENT_SPELL_EFFECT_BUFF_TIC_BOT, diff --git a/zone/lua_general.cpp b/zone/lua_general.cpp index 086c5dc5e..2d9cc315b 100644 --- a/zone/lua_general.cpp +++ b/zone/lua_general.cpp @@ -4625,7 +4625,9 @@ luabind::scope lua_register_events() { luabind::value("despawn_zone", static_cast(EVENT_DESPAWN_ZONE)), luabind::value("bot_create", static_cast(EVENT_BOT_CREATE)), luabind::value("augment_insert_client", static_cast(EVENT_AUGMENT_INSERT_CLIENT)), - luabind::value("augment_remove_client", static_cast(EVENT_AUGMENT_REMOVE_CLIENT)) + luabind::value("augment_remove_client", static_cast(EVENT_AUGMENT_REMOVE_CLIENT)), + luabind::value("equip_item_bot", static_cast(EVENT_EQUIP_ITEM_BOT)), + luabind::value("unequip_item_bot", static_cast(EVENT_UNEQUIP_ITEM_BOT)) )]; } diff --git a/zone/lua_parser.cpp b/zone/lua_parser.cpp index bbd7aa33d..541996e56 100644 --- a/zone/lua_parser.cpp +++ b/zone/lua_parser.cpp @@ -156,6 +156,8 @@ const char *LuaEvents[_LargestEventID] = { "event_bot_create", "event_augment_insert_client", "event_augment_remove_client", + "event_equip_item_bot", + "event_unequip_item_bot", }; extern Zone *zone; @@ -308,6 +310,8 @@ LuaParser::LuaParser() { BotArgumentDispatch[EVENT_TRADE] = handle_bot_trade; BotArgumentDispatch[EVENT_USE_SKILL] = handle_bot_use_skill; BotArgumentDispatch[EVENT_PAYLOAD] = handle_bot_payload; + BotArgumentDispatch[EVENT_EQUIP_ITEM_BOT] = handle_bot_equip_item; + BotArgumentDispatch[EVENT_UNEQUIP_ITEM_BOT] = handle_bot_equip_item; #endif L = nullptr; diff --git a/zone/lua_parser_events.cpp b/zone/lua_parser_events.cpp index f12f11159..31bdc76dc 100644 --- a/zone/lua_parser_events.cpp +++ b/zone/lua_parser_events.cpp @@ -1951,4 +1951,57 @@ void handle_bot_use_skill( lua_setfield(L, -2, "skill_level"); } +void handle_bot_equip_item( + QuestInterface *parse, + lua_State* L, + Bot* bot, + Mob* init, + 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_bot_unequip_item( + QuestInterface *parse, + lua_State* L, + Bot* bot, + Mob* init, + 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"); +} + + #endif diff --git a/zone/lua_parser_events.h b/zone/lua_parser_events.h index b32683c7a..8decb37eb 100644 --- a/zone/lua_parser_events.h +++ b/zone/lua_parser_events.h @@ -955,5 +955,25 @@ void handle_bot_payload( std::vector *extra_pointers ); +void handle_bot_equip_item( + QuestInterface *parse, + lua_State* L, + Bot* bot, + Mob* init, + std::string data, + uint32 extra_data, + std::vector *extra_pointers +); + +void handle_bot_unequip_item( + QuestInterface *parse, + lua_State* L, + Bot* bot, + Mob* init, + std::string data, + uint32 extra_data, + std::vector *extra_pointers +); + #endif #endif