[Quest API] Export $item and $augment to augment events in Perl (#2895)

* [Quest API] Export $item and $augment to augment events in Perl

# Notes
- Exports `$item` and `$augment` to `EVENT_AUGMENT_INSERT_CLIENT` in Perl.
- Exports `$item` and `$augment` to `EVENT_AUGMENT_REMOVE_CLIENT` in Perl.
- Allows operators to use item and augment reference instead of just item IDs.

* Cleanup
This commit is contained in:
Alex King 2023-02-12 23:42:27 -05:00 committed by GitHub
parent fd0764d4cb
commit e8f01fb6ac
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 192 additions and 59 deletions

View File

@ -3138,24 +3138,48 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
std::vector<std::any> args;
args.push_back(old_aug);
parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
if (parse->ItemHasQuestSub(tobe_auged, EVENT_UNAUGMENT_ITEM)) {
parse->EventItem(
EVENT_UNAUGMENT_ITEM,
this,
tobe_auged,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.assign(1, tobe_auged);
args.push_back(false);
parse->EventItem(EVENT_AUGMENT_REMOVE, this, old_aug, nullptr, "", in_augment->augment_index, &args);
const auto export_string = fmt::format(
"{} {} {} {} {}",
tobe_auged->GetID(),
item_slot,
old_aug->GetID(),
in_augment->augment_index,
false
);
if (parse->ItemHasQuestSub(old_aug, EVENT_AUGMENT_REMOVE)) {
parse->EventItem(
EVENT_AUGMENT_REMOVE,
this,
old_aug,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.push_back(old_aug);
if (parse->PlayerHasQuestSub(EVENT_AUGMENT_REMOVE_CLIENT)) {
const auto& export_string = fmt::format(
"{} {} {} {} {}",
tobe_auged->GetID(),
item_slot,
old_aug->GetID(),
in_augment->augment_index,
false
);
parse->EventPlayer(EVENT_AUGMENT_REMOVE_CLIENT, this, export_string, 0, &args);
args.push_back(old_aug);
parse->EventPlayer(EVENT_AUGMENT_REMOVE_CLIENT, this, export_string, 0, &args);
}
}
tobe_auged->PutAugment(in_augment->augment_index, *new_aug);
@ -3165,22 +3189,46 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
if (aug) {
std::vector<std::any> args;
args.push_back(aug);
parse->EventItem(EVENT_AUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
if (parse->ItemHasQuestSub(tobe_auged, EVENT_AUGMENT_ITEM)) {
parse->EventItem(
EVENT_AUGMENT_ITEM,
this,
tobe_auged,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.assign(1, tobe_auged);
parse->EventItem(EVENT_AUGMENT_INSERT, this, aug, nullptr, "", in_augment->augment_index, &args);
if (parse->ItemHasQuestSub(aug, EVENT_AUGMENT_INSERT)) {
parse->EventItem(
EVENT_AUGMENT_INSERT,
this,
aug,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.push_back(aug);
const auto export_string = fmt::format(
"{} {} {} {}",
tobe_auged->GetID(),
item_slot,
aug->GetID(),
in_augment->augment_index
);
if (parse->PlayerHasQuestSub(EVENT_AUGMENT_INSERT_CLIENT)) {
const auto& export_string = fmt::format(
"{} {} {} {}",
tobe_auged->GetID(),
item_slot,
aug->GetID(),
in_augment->augment_index
);
parse->EventPlayer(EVENT_AUGMENT_INSERT_CLIENT, this, export_string, 0, &args);
parse->EventPlayer(EVENT_AUGMENT_INSERT_CLIENT, this, export_string, 0, &args);
}
} else {
Message(
Chat::Red,
@ -3233,24 +3281,48 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
if (aug) {
std::vector<std::any> args;
args.push_back(aug);
parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
if (parse->ItemHasQuestSub(tobe_auged, EVENT_UNAUGMENT_ITEM)) {
parse->EventItem(
EVENT_UNAUGMENT_ITEM,
this,
tobe_auged,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.assign(1, tobe_auged);
args.push_back(false);
parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args);
if (parse->ItemHasQuestSub(aug, EVENT_AUGMENT_REMOVE)) {
parse->EventItem(
EVENT_AUGMENT_REMOVE,
this,
aug,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.push_back(aug);
const auto export_string = fmt::format(
"{} {} {} {} {}",
tobe_auged->GetID(),
item_slot,
aug->GetID(),
in_augment->augment_index,
false
);
if (parse->PlayerHasQuestSub(EVENT_AUGMENT_REMOVE_CLIENT)) {
const auto& export_string = fmt::format(
"{} {} {} {} {}",
tobe_auged->GetID(),
item_slot,
aug->GetID(),
in_augment->augment_index,
false
);
parse->EventPlayer(EVENT_AUGMENT_REMOVE_CLIENT, this, export_string, 0, &args);
parse->EventPlayer(EVENT_AUGMENT_REMOVE_CLIENT, this, export_string, 0, &args);
}
} else {
Message(Chat::Red, "Error: Could not find augmentation to remove at index %i. Aborting.", in_augment->augment_index);
return;
@ -3297,24 +3369,48 @@ void Client::Handle_OP_AugmentItem(const EQApplicationPacket *app)
if (aug) {
std::vector<std::any> args;
args.push_back(aug);
parse->EventItem(EVENT_UNAUGMENT_ITEM, this, tobe_auged, nullptr, "", in_augment->augment_index, &args);
if (parse->ItemHasQuestSub(tobe_auged, EVENT_UNAUGMENT_ITEM)) {
parse->EventItem(
EVENT_UNAUGMENT_ITEM,
this,
tobe_auged,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.assign(1, tobe_auged);
args.push_back(true);
parse->EventItem(EVENT_AUGMENT_REMOVE, this, aug, nullptr, "", in_augment->augment_index, &args);
if (parse->ItemHasQuestSub(aug, EVENT_AUGMENT_REMOVE)) {
parse->EventItem(
EVENT_AUGMENT_REMOVE,
this,
aug,
nullptr,
"",
in_augment->augment_index,
&args
);
}
args.push_back(aug);
const auto export_string = fmt::format(
"{} {} {} {} {}",
tobe_auged->GetID(),
item_slot,
aug->GetID(),
in_augment->augment_index,
true
);
if (parse->PlayerHasQuestSub(EVENT_AUGMENT_REMOVE_CLIENT)) {
const auto& export_string = fmt::format(
"{} {} {} {} {}",
tobe_auged->GetID(),
item_slot,
aug->GetID(),
in_augment->augment_index,
true
);
parse->EventPlayer(EVENT_AUGMENT_REMOVE_CLIENT, this, export_string, 0, &args);
parse->EventPlayer(EVENT_AUGMENT_REMOVE_CLIENT, this, export_string, 0, &args);
}
} else {
Message(
Chat::Red,

View File

@ -1951,16 +1951,40 @@ void PerlembParser::ExportEventVariables(
break;
}
case EVENT_AUGMENT_INSERT_CLIENT:
case EVENT_AUGMENT_INSERT_CLIENT: {
Seperator sep(data);
ExportVar(package_name.c_str(), "item_id", sep.arg[0]);
ExportVar(package_name.c_str(), "item_slot", sep.arg[1]);
ExportVar(package_name.c_str(), "augment_id", sep.arg[2]);
ExportVar(package_name.c_str(), "augment_slot", sep.arg[3]);
if (extra_pointers && extra_pointers->size() >= 1) {
ExportVar(package_name.c_str(), "item", "QuestItem", std::any_cast<EQ::ItemInstance*>(extra_pointers->at(0)));
}
if (extra_pointers && extra_pointers->size() >= 2) {
ExportVar(package_name.c_str(), "augment", "QuestItem", std::any_cast<EQ::ItemInstance*>(extra_pointers->at(1)));
}
break;
}
case EVENT_AUGMENT_REMOVE_CLIENT: {
Seperator sep(data);
ExportVar(package_name.c_str(), "item_id", sep.arg[0]);
ExportVar(package_name.c_str(), "item_slot", sep.arg[1]);
ExportVar(package_name.c_str(), "augment_id", sep.arg[2]);
ExportVar(package_name.c_str(), "augment_slot", sep.arg[3]);
if (sep.argnum >= 4) {
ExportVar(package_name.c_str(), "destroyed", sep.arg[4]);
ExportVar(package_name.c_str(), "destroyed", sep.arg[4]);
if (extra_pointers && extra_pointers->size() >= 1) {
ExportVar(package_name.c_str(), "item", "QuestItem", std::any_cast<EQ::ItemInstance*>(extra_pointers->at(0)));
}
if (extra_pointers && extra_pointers->size() >= 3) {
ExportVar(package_name.c_str(), "augment", "QuestItem", std::any_cast<EQ::ItemInstance*>(extra_pointers->at(2)));
}
break;
}

View File

@ -140,22 +140,30 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
if(aug) {
std::vector<std::any> args;
args.push_back(aug);
parse->EventItem(EVENT_AUGMENT_ITEM, user, tobe_auged, nullptr, "", slot, &args);
if (parse->ItemHasQuestSub(tobe_auged, EVENT_AUGMENT_ITEM)) {
parse->EventItem(EVENT_AUGMENT_ITEM, user, tobe_auged, nullptr, "", slot, &args);
}
args.assign(1, tobe_auged);
parse->EventItem(EVENT_AUGMENT_INSERT, user, aug, nullptr, "", slot, &args);
if (parse->ItemHasQuestSub(aug, EVENT_AUGMENT_INSERT)) {
parse->EventItem(EVENT_AUGMENT_INSERT, user, aug, nullptr, "", slot, &args);
}
args.push_back(aug);
const auto export_string = fmt::format(
"{} {} {} {}",
tobe_auged->GetID(),
-1,
aug->GetID(),
slot
);
if (parse->PlayerHasQuestSub(EVENT_AUGMENT_INSERT_CLIENT)) {
const auto& export_string = fmt::format(
"{} {} {} {}",
tobe_auged->GetID(),
-1,
aug->GetID(),
slot
);
parse->EventPlayer(EVENT_AUGMENT_INSERT_CLIENT, user, export_string, 0, &args);
parse->EventPlayer(EVENT_AUGMENT_INSERT_CLIENT, user, export_string, 0, &args);
}
}
item_one_to_push = tobe_auged->Clone();
@ -182,12 +190,17 @@ void Object::HandleAugmentation(Client* user, const AugmentItem_Struct* in_augme
}
std::vector<std::any> args;
args.push_back(aug);
parse->EventItem(EVENT_UNAUGMENT_ITEM, user, tobe_auged, nullptr, "", slot, &args);
if (parse->ItemHasQuestSub(tobe_auged, EVENT_UNAUGMENT_ITEM)) {
parse->EventItem(EVENT_UNAUGMENT_ITEM, user, tobe_auged, nullptr, "", slot, &args);
}
args.assign(1, tobe_auged);
args.push_back(&is_solvent);
parse->EventItem(EVENT_AUGMENT_REMOVE, user, aug, nullptr, "", slot, &args);
if (parse->ItemHasQuestSub(aug, EVENT_AUGMENT_REMOVE)) {
parse->EventItem(EVENT_AUGMENT_REMOVE, user, aug, nullptr, "", slot, &args);
}
}
if (is_solvent) {