mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-31 09:06:46 +00:00
[Quest API] Add EVENT_AA_BUY and EVENT_AA_GAIN to Perl/Lua. (#2504)
# Perl - Add EVENT_AA_BUY to Perl. - Exports `$aa_cost`, `$aa_id`, `$aa_previous_id`, and `$aa_next_id` - Add EVENT_AA_GAIN to Perl. - Exports `$aa_gained` - Add quest::getaaname(aa_id) to Perl. # Lua - Add event_aa_buy to Lua. - Exports `e.aa_cost`, `e.aa_id`, `e.aa_previous_id`, and `e.aa_next_id` - Add event_aa_gain to Lua. - Exports `e.aa_gained` - Add eq.get_aa_name(aa_id) to Lua.
This commit is contained in:
Executable
+100
@@ -0,0 +1,100 @@
|
||||
#include "../client.h"
|
||||
|
||||
void command_findaa(Client *c, const Seperator *sep)
|
||||
{
|
||||
auto arguments = sep->argnum;
|
||||
if (!arguments) {
|
||||
c->Message(Chat::White, "Command Syntax: #findaa [Search Criteria]");
|
||||
return;
|
||||
}
|
||||
|
||||
if (sep->IsNumber(1)) {
|
||||
int aa_id = std::stoi(sep->arg[1]);
|
||||
auto aa_name = zone->GetAAName(aa_id);
|
||||
if (!aa_name.empty()) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"AA {}: {}",
|
||||
aa_id,
|
||||
aa_name
|
||||
).c_str()
|
||||
);
|
||||
} else {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"AA ID {} was not found.",
|
||||
aa_id
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
} else {
|
||||
const auto search_criteria = Strings::ToLower(sep->argplus[1]);
|
||||
if (!search_criteria.empty()) {
|
||||
std::map<int, std::string> ordered_aas;
|
||||
|
||||
for (const auto& a : zone->aa_abilities) {
|
||||
ordered_aas[a.second.get()->id] = a.second.get()->name;
|
||||
}
|
||||
|
||||
int found_count = 0;
|
||||
for (const auto& a : ordered_aas) {
|
||||
auto aa_name = zone->GetAAName(a.first);
|
||||
if (!aa_name.empty()) {
|
||||
auto aa_name_lower = Strings::ToLower(aa_name);
|
||||
if (aa_name_lower.find(search_criteria) == std::string::npos) {
|
||||
continue;
|
||||
}
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"AA {}: {}",
|
||||
a.first,
|
||||
aa_name
|
||||
).c_str()
|
||||
);
|
||||
found_count++;
|
||||
|
||||
if (found_count == 50) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!found_count) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"No AAs were found matching '{}'.",
|
||||
search_criteria
|
||||
).c_str()
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (found_count == 50) {
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"50 AAs were found matching '{}', max reached.",
|
||||
search_criteria
|
||||
).c_str()
|
||||
);
|
||||
} else {
|
||||
auto skill_message = found_count == 1 ? "An AA was" : fmt::format("{} AAs were", found_count);
|
||||
|
||||
c->Message(
|
||||
Chat::White,
|
||||
fmt::format(
|
||||
"{} found matching '{}'.",
|
||||
skill_message,
|
||||
search_criteria
|
||||
).c_str()
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user