[Quest API] Export $item to Client/Bot Equip Events in Perl (#2860)

* [Quest API] Add $item Export to Client/Bot Equip Events

# Notes
- Adds `$item` export to `EVENT_ITEM_EQUIP_CLIENT`, `EVENT_ITEM_UNEQUIP_CLIENT`, `EVENT_ITEM_EQUIP_BOT`, and `EVENT_UNEQUIP_ITEM_BOT`.

* Update bot.cpp

* Update embparser.cpp
This commit is contained in:
Alex King 2023-02-10 23:56:36 -05:00 committed by GitHub
parent a1251bdda8
commit a3bb7e7741
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 32 additions and 5 deletions

View File

@ -5080,7 +5080,11 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client*
return_iterator.from_bot_slot
);
parse->EventBot(EVENT_UNEQUIP_ITEM_BOT, this, nullptr, export_string , return_iterator.return_item_instance->GetID());
std::vector<std::any> args;
args.emplace_back(return_iterator.return_item_instance);
parse->EventBot(EVENT_UNEQUIP_ITEM_BOT, this, nullptr, export_string , return_iterator.return_item_instance->GetID(), &args);
if (return_instance) {
EQ::SayLinkEngine linker;
linker.SetLinkType(EQ::saylink::SayLinkItemInst);
@ -5136,7 +5140,11 @@ void Bot::PerformTradeWithClient(int16 begin_slot_id, int16 end_slot_id, Client*
trade_iterator.to_bot_slot
);
parse->EventBot(EVENT_EQUIP_ITEM_BOT, this, nullptr, export_string , trade_iterator.trade_item_instance->GetID());
std::vector<std::any> args;
args.emplace_back(trade_iterator.trade_item_instance);
parse->EventBot(EVENT_EQUIP_ITEM_BOT, this, nullptr, export_string, trade_iterator.trade_item_instance->GetID(), &args);
trade_iterator.trade_item_instance = nullptr; // actual deletion occurs in client delete below

View File

@ -9484,7 +9484,11 @@ void bot_subcommand_inventory_remove(Client *c, const Seperator *sep)
slot_id
);
parse->EventBot(EVENT_UNEQUIP_ITEM_BOT, my_bot, nullptr, export_string, inst->GetID());
std::vector<std::any> args;
args.emplace_back(inst);
parse->EventBot(EVENT_UNEQUIP_ITEM_BOT, my_bot, nullptr, export_string, inst->GetID(), &args);
}
}

View File

@ -1727,6 +1727,7 @@ void PerlembParser::ExportEventVariables(
ExportVar(package_name.c_str(), "item_id", item->GetID());
ExportVar(package_name.c_str(), "item_name", item->GetItem()->Name);
ExportVar(package_name.c_str(), "spell_id", item->GetItem()->Click.Effect);
ExportVar(package_name.c_str(), "item", "QuestItem", item);
}
}
break;
@ -1924,6 +1925,9 @@ void PerlembParser::ExportEventVariables(
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]);
if (extra_pointers && extra_pointers->size() == 1) {
ExportVar(package_name.c_str(), "item", "QuestItem", std::any_cast<EQ::ItemInstance*>(extra_pointers->at(0)));
}
break;
}
@ -1933,6 +1937,9 @@ void PerlembParser::ExportEventVariables(
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]);
if (extra_pointers && extra_pointers->size() == 1) {
ExportVar(package_name.c_str(), "item", "QuestItem", std::any_cast<EQ::ItemInstance*>(extra_pointers->at(0)));
}
break;
}

View File

@ -2248,7 +2248,11 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
dst_slot_id
);
parse->EventPlayer(EVENT_UNEQUIP_ITEM_CLIENT, this, export_string, dst_inst->GetItem()->ID);
std::vector<std::any> args;
args.emplace_back(dst_inst);
parse->EventPlayer(EVENT_UNEQUIP_ITEM_CLIENT, this, export_string, dst_inst->GetItem()->ID, &args);
}
if(src_inst) {
@ -2260,7 +2264,11 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
dst_slot_id
);
parse->EventPlayer(EVENT_EQUIP_ITEM_CLIENT, this, export_string, src_inst->GetItem()->ID);
std::vector<std::any> args;
args.emplace_back(src_inst);
parse->EventPlayer(EVENT_EQUIP_ITEM_CLIENT, this, export_string, src_inst->GetItem()->ID, &args);
}
}
}