mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-11 21:01:29 +00:00
[Bots] Add EVENT_UNEQUIP_ITEM_BOT & EVENT_EQUIP_ITEM_BOT (#2796)
* Initial Commit, need to test. * Add unequip events. * const auto
This commit is contained in:
parent
b71b3f5be0
commit
826550acac
16
zone/bot.cpp
16
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));
|
||||
|
||||
@ -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());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -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);
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -4625,7 +4625,9 @@ luabind::scope lua_register_events() {
|
||||
luabind::value("despawn_zone", static_cast<int>(EVENT_DESPAWN_ZONE)),
|
||||
luabind::value("bot_create", static_cast<int>(EVENT_BOT_CREATE)),
|
||||
luabind::value("augment_insert_client", static_cast<int>(EVENT_AUGMENT_INSERT_CLIENT)),
|
||||
luabind::value("augment_remove_client", static_cast<int>(EVENT_AUGMENT_REMOVE_CLIENT))
|
||||
luabind::value("augment_remove_client", static_cast<int>(EVENT_AUGMENT_REMOVE_CLIENT)),
|
||||
luabind::value("equip_item_bot", static_cast<int>(EVENT_EQUIP_ITEM_BOT)),
|
||||
luabind::value("unequip_item_bot", static_cast<int>(EVENT_UNEQUIP_ITEM_BOT))
|
||||
)];
|
||||
}
|
||||
|
||||
|
||||
@ -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;
|
||||
|
||||
@ -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<std::any> *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<std::any> *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
|
||||
|
||||
@ -955,5 +955,25 @@ void handle_bot_payload(
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
void handle_bot_equip_item(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
void handle_bot_unequip_item(
|
||||
QuestInterface *parse,
|
||||
lua_State* L,
|
||||
Bot* bot,
|
||||
Mob* init,
|
||||
std::string data,
|
||||
uint32 extra_data,
|
||||
std::vector<std::any> *extra_pointers
|
||||
);
|
||||
|
||||
#endif
|
||||
#endif
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user