mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-16 22:58:34 +00:00
[Logs] Add NPC Trades to Player Events (#4505)
* [Logs] Add NPC Trades to Player Events * Update player_event_discord_formatter.cpp * Push * Fix money and add NPC info * [Logs] Add NPC Trades to Player Events * Update player_event_discord_formatter.cpp * Push * Minor logic fix * Push * Update perl_client.cpp --------- Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
+1
-173
@@ -4611,179 +4611,7 @@ int8 QuestManager::DoesAugmentFit(EQ::ItemInstance* inst, uint32 augment_id, uin
|
||||
}
|
||||
|
||||
void QuestManager::SendPlayerHandinEvent() {
|
||||
QuestManagerCurrentQuestVars();
|
||||
if (!owner || !owner->IsNPC() || !initiator) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (
|
||||
!initiator->EntityVariableExists("HANDIN_ITEMS") &&
|
||||
!initiator->EntityVariableExists("HANDIN_MONEY") &&
|
||||
!initiator->EntityVariableExists("RETURN_ITEMS") &&
|
||||
!initiator->EntityVariableExists("RETURN_MONEY")
|
||||
) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto handin_items = initiator->GetEntityVariable("HANDIN_ITEMS");
|
||||
auto return_items = initiator->GetEntityVariable("RETURN_ITEMS");
|
||||
auto handin_money = initiator->GetEntityVariable("HANDIN_MONEY");
|
||||
auto return_money = initiator->GetEntityVariable("RETURN_MONEY");
|
||||
|
||||
std::vector<PlayerEvent::HandinEntry> hi = {};
|
||||
std::vector<PlayerEvent::HandinEntry> ri = {};
|
||||
PlayerEvent::HandinMoney hm{};
|
||||
PlayerEvent::HandinMoney rm{};
|
||||
|
||||
// Handin Items
|
||||
if (!handin_items.empty()) {
|
||||
if (Strings::Contains(handin_items, ",")) {
|
||||
const auto handin_data = Strings::Split(handin_items, ",");
|
||||
for (const auto &h: handin_data) {
|
||||
const auto item_data = Strings::Split(h, "|");
|
||||
if (
|
||||
item_data.size() == 3 &&
|
||||
Strings::IsNumber(item_data[0]) &&
|
||||
Strings::IsNumber(item_data[1]) &&
|
||||
Strings::IsNumber(item_data[2])
|
||||
) {
|
||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
||||
if (item_id != 0) {
|
||||
const auto *item = database.GetItem(item_id);
|
||||
|
||||
if (item) {
|
||||
hi.emplace_back(
|
||||
PlayerEvent::HandinEntry{
|
||||
.item_id = item_id,
|
||||
.item_name = item->Name,
|
||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Strings::Contains(handin_items, "|")) {
|
||||
const auto item_data = Strings::Split(handin_items, "|");
|
||||
if (
|
||||
item_data.size() == 3 &&
|
||||
Strings::IsNumber(item_data[0]) &&
|
||||
Strings::IsNumber(item_data[1]) &&
|
||||
Strings::IsNumber(item_data[2])
|
||||
) {
|
||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
||||
const auto *item = database.GetItem(item_id);
|
||||
|
||||
if (item) {
|
||||
hi.emplace_back(
|
||||
PlayerEvent::HandinEntry{
|
||||
.item_id = item_id,
|
||||
.item_name = item->Name,
|
||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Handin Money
|
||||
if (!handin_money.empty()) {
|
||||
const auto hms = Strings::Split(handin_money, "|");
|
||||
hm.copper = static_cast<uint32>(Strings::ToUnsignedInt(hms[0]));
|
||||
hm.silver = static_cast<uint32>(Strings::ToUnsignedInt(hms[1]));
|
||||
hm.gold = static_cast<uint32>(Strings::ToUnsignedInt(hms[2]));
|
||||
hm.platinum = static_cast<uint32>(Strings::ToUnsignedInt(hms[3]));
|
||||
}
|
||||
|
||||
// Return Items
|
||||
if (!return_items.empty()) {
|
||||
if (Strings::Contains(return_items, ",")) {
|
||||
const auto return_data = Strings::Split(return_items, ",");
|
||||
for (const auto &r: return_data) {
|
||||
const auto item_data = Strings::Split(r, "|");
|
||||
if (
|
||||
item_data.size() == 3 &&
|
||||
Strings::IsNumber(item_data[0]) &&
|
||||
Strings::IsNumber(item_data[1]) &&
|
||||
Strings::IsNumber(item_data[2])
|
||||
) {
|
||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
||||
const auto *item = database.GetItem(item_id);
|
||||
|
||||
if (item) {
|
||||
ri.emplace_back(
|
||||
PlayerEvent::HandinEntry{
|
||||
.item_id = item_id,
|
||||
.item_name = item->Name,
|
||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (Strings::Contains(return_items, "|")) {
|
||||
const auto item_data = Strings::Split(return_items, "|");
|
||||
if (
|
||||
item_data.size() == 3 &&
|
||||
Strings::IsNumber(item_data[0]) &&
|
||||
Strings::IsNumber(item_data[1]) &&
|
||||
Strings::IsNumber(item_data[2])
|
||||
) {
|
||||
const auto item_id = static_cast<uint32>(Strings::ToUnsignedInt(item_data[0]));
|
||||
const auto *item = database.GetItem(item_id);
|
||||
|
||||
if (item) {
|
||||
ri.emplace_back(
|
||||
PlayerEvent::HandinEntry{
|
||||
.item_id = item_id,
|
||||
.item_name = item->Name,
|
||||
.charges = static_cast<uint16>(Strings::ToUnsignedInt(item_data[1])),
|
||||
.attuned = Strings::ToInt(item_data[2]) ? true : false
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Return Money
|
||||
if (!return_money.empty()) {
|
||||
const auto rms = Strings::Split(return_money, "|");
|
||||
rm.copper = static_cast<uint32>(Strings::ToUnsignedInt(rms[0]));
|
||||
rm.silver = static_cast<uint32>(Strings::ToUnsignedInt(rms[1]));
|
||||
rm.gold = static_cast<uint32>(Strings::ToUnsignedInt(rms[2]));
|
||||
rm.platinum = static_cast<uint32>(Strings::ToUnsignedInt(rms[3]));
|
||||
}
|
||||
|
||||
initiator->DeleteEntityVariable("HANDIN_ITEMS");
|
||||
initiator->DeleteEntityVariable("HANDIN_MONEY");
|
||||
initiator->DeleteEntityVariable("RETURN_ITEMS");
|
||||
initiator->DeleteEntityVariable("RETURN_MONEY");
|
||||
|
||||
bool handed_in_money = hm.platinum > 0 || hm.gold > 0 || hm.silver > 0 || hm.copper > 0;
|
||||
|
||||
bool event_has_data_to_record = (
|
||||
!hi.empty() || handed_in_money
|
||||
);
|
||||
|
||||
if (player_event_logs.IsEventEnabled(PlayerEvent::NPC_HANDIN) && event_has_data_to_record) {
|
||||
auto e = PlayerEvent::HandinEvent{
|
||||
.npc_id = owner->CastToNPC()->GetNPCTypeID(),
|
||||
.npc_name = owner->GetCleanName(),
|
||||
.handin_items = hi,
|
||||
.handin_money = hm,
|
||||
.return_items = ri,
|
||||
.return_money = rm
|
||||
};
|
||||
|
||||
RecordPlayerEventLogWithClient(initiator, PlayerEvent::NPC_HANDIN, e);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
std::string QuestManager::GetAutoLoginCharacterNameByAccountID(uint32 account_id)
|
||||
|
||||
Reference in New Issue
Block a user