mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-13 18:51:29 +00:00
[Commands] Cleanup #gearup Command. (#2589)
# Notes - Cleanup messages and logic. - Add support for gearing up target client (with #gm on) and/or target bots.
This commit is contained in:
parent
d0e7e8c4c4
commit
d6db35b84e
@ -162,7 +162,7 @@ int command_init(void)
|
|||||||
command_add("fov", "Check wether you're behind or in your target's field of view", AccountStatus::QuestTroupe, command_fov) ||
|
command_add("fov", "Check wether you're behind or in your target's field of view", AccountStatus::QuestTroupe, command_fov) ||
|
||||||
command_add("freeze", "Freeze your target", AccountStatus::QuestTroupe, command_freeze) ||
|
command_add("freeze", "Freeze your target", AccountStatus::QuestTroupe, command_freeze) ||
|
||||||
command_add("gassign", "[Grid ID] - Assign targetted NPC to predefined wandering grid id", AccountStatus::GMAdmin, command_gassign) ||
|
command_add("gassign", "[Grid ID] - Assign targetted NPC to predefined wandering grid id", AccountStatus::GMAdmin, command_gassign) ||
|
||||||
command_add("gearup", "Developer tool to quickly equip a character", AccountStatus::GMMgmt, command_gearup) ||
|
command_add("gearup", "Developer tool to quickly equip yourself or your target", AccountStatus::GMMgmt, command_gearup) ||
|
||||||
command_add("gender", "[0/1/2] - Change your or your target's gender to male/female/neuter", AccountStatus::Guide, command_gender) ||
|
command_add("gender", "[0/1/2] - Change your or your target's gender to male/female/neuter", AccountStatus::Guide, command_gender) ||
|
||||||
command_add("getplayerburiedcorpsecount", "Get your or your target's total number of buried player corpses.", AccountStatus::GMAdmin, command_getplayerburiedcorpsecount) ||
|
command_add("getplayerburiedcorpsecount", "Get your or your target's total number of buried player corpses.", AccountStatus::GMAdmin, command_getplayerburiedcorpsecount) ||
|
||||||
command_add("getvariable", "[Variable Name] - Get the value of a variable from the database", AccountStatus::GMMgmt, command_getvariable) ||
|
command_add("getvariable", "[Variable Name] - Get the value of a variable from the database", AccountStatus::GMMgmt, command_getvariable) ||
|
||||||
|
|||||||
@ -2,9 +2,26 @@
|
|||||||
#include "../../common/http/httplib.h"
|
#include "../../common/http/httplib.h"
|
||||||
#include "../../common/content/world_content_service.h"
|
#include "../../common/content/world_content_service.h"
|
||||||
|
|
||||||
|
#ifdef BOTS
|
||||||
|
#include "../bot.h"
|
||||||
|
#endif
|
||||||
|
|
||||||
void command_gearup(Client *c, const Seperator *sep)
|
void command_gearup(Client *c, const Seperator *sep)
|
||||||
{
|
{
|
||||||
std::string tool_table_name = "tool_gearup_armor_sets";
|
Mob* t = c;
|
||||||
|
if (
|
||||||
|
c->GetTarget() &&
|
||||||
|
(
|
||||||
|
(c->GetTarget()->IsClient() && c->GetGM())
|
||||||
|
#ifdef BOTS
|
||||||
|
|| c->GetTarget()->IsBot()
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
) {
|
||||||
|
t = c->GetTarget();
|
||||||
|
}
|
||||||
|
|
||||||
|
const std::string tool_table_name = "tool_gearup_armor_sets";
|
||||||
if (!database.DoesTableExist(tool_table_name)) {
|
if (!database.DoesTableExist(tool_table_name)) {
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::Yellow,
|
Chat::Yellow,
|
||||||
@ -41,8 +58,7 @@ void command_gearup(Client *c, const Seperator *sep)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
c->Message(
|
c->Message(
|
||||||
Chat::Yellow,
|
Chat::Yellow,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
@ -55,74 +71,97 @@ void command_gearup(Client *c, const Seperator *sep)
|
|||||||
c->Message(
|
c->Message(
|
||||||
Chat::Yellow,
|
Chat::Yellow,
|
||||||
fmt::format(
|
fmt::format(
|
||||||
"Table [{}] installed. Sourced [{}] queries",
|
"Table [{}] installed. Sourced [{}] quer{}",
|
||||||
tool_table_name, sourced_queries
|
tool_table_name,
|
||||||
|
sourced_queries,
|
||||||
|
sourced_queries != 1 ? "ies" : "y"
|
||||||
).c_str()
|
).c_str()
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string expansion_arg = sep->arg[1];
|
const std::string expansion_arg = sep->arg[1];
|
||||||
std::string expansion_filter;
|
std::string expansion_filter;
|
||||||
if (expansion_arg.length() > 0) {
|
if (!expansion_arg.empty()) {
|
||||||
expansion_filter = fmt::format("and `expansion` = {}", expansion_arg);
|
expansion_filter = fmt::format(" AND `expansion` = {}", expansion_arg);
|
||||||
}
|
}
|
||||||
|
|
||||||
auto results = database.QueryDatabase(
|
auto query = fmt::format(
|
||||||
fmt::format(
|
"SELECT item_id, slot FROM {} WHERE "
|
||||||
SQL (
|
"`class` = {} AND `level` = {}{} "
|
||||||
select
|
"ORDER BY score DESC, expansion DESC",
|
||||||
item_id,
|
|
||||||
slot
|
|
||||||
from
|
|
||||||
{}
|
|
||||||
where
|
|
||||||
`class` = {}
|
|
||||||
and `level` = {}
|
|
||||||
{}
|
|
||||||
order by score desc, expansion desc
|
|
||||||
),
|
|
||||||
tool_table_name,
|
tool_table_name,
|
||||||
c->GetClass(),
|
t->GetClass(),
|
||||||
c->GetLevel(),
|
t->GetLevel(),
|
||||||
expansion_filter
|
expansion_filter
|
||||||
)
|
|
||||||
);
|
);
|
||||||
|
auto results = database.QueryDatabase(query);
|
||||||
|
|
||||||
int items_equipped = 0;
|
int items_equipped = 0;
|
||||||
int items_already_have = 0;
|
int items_already_have = 0;
|
||||||
std::set<int> equipped;
|
std::set<int> equipped;
|
||||||
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
for (auto row : results) {
|
||||||
int item_id = atoi(row[0]);
|
auto item_id = std::stoul(row[0]);
|
||||||
int slot_id = atoi(row[1]);
|
auto slot_id = static_cast<uint16>(std::stoul(row[1]));
|
||||||
|
|
||||||
if (equipped.find(slot_id) != equipped.end()) {
|
if (equipped.find(slot_id) != equipped.end()) {
|
||||||
if (slot_id == EQ::invslot::slotEar1) {
|
if (slot_id == EQ::invslot::slotEar1) {
|
||||||
slot_id = EQ::invslot::slotEar2;
|
slot_id = EQ::invslot::slotEar2;
|
||||||
}
|
} else if (slot_id == EQ::invslot::slotFinger1) {
|
||||||
if (slot_id == EQ::invslot::slotFinger1) {
|
|
||||||
slot_id = EQ::invslot::slotFinger2;
|
slot_id = EQ::invslot::slotFinger2;
|
||||||
}
|
} else if (slot_id == EQ::invslot::slotWrist1) {
|
||||||
if (slot_id == EQ::invslot::slotWrist1) {
|
|
||||||
slot_id = EQ::invslot::slotWrist2;
|
slot_id = EQ::invslot::slotWrist2;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (equipped.find(slot_id) == equipped.end()) {
|
if (equipped.find(slot_id) == equipped.end()) {
|
||||||
const EQ::ItemData *item = database.GetItem(item_id);
|
const auto *item = database.GetItem(item_id);
|
||||||
bool has_item = (c->GetInv().HasItem(item_id, 1, invWhereWorn) != INVALID_INDEX);
|
bool has_item = false;
|
||||||
bool can_wear_item = !c->CheckLoreConflict(item) && !has_item;
|
if (t->IsClient()) {
|
||||||
|
has_item = t->CastToClient()->GetInv().HasItem(item_id, 1, invWhereWorn) != INVALID_INDEX;
|
||||||
|
#ifdef BOTS
|
||||||
|
} else if (t->IsBot()) {
|
||||||
|
has_item = t->CastToBot()->HasBotItem(item_id);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
|
bool can_wear_item = false;
|
||||||
|
if (t->IsClient()) {
|
||||||
|
can_wear_item = !t->CastToClient()->CheckLoreConflict(item) && !has_item;
|
||||||
|
#ifdef BOTS
|
||||||
|
} else if (t->IsBot()) {
|
||||||
|
can_wear_item = !t->CastToBot()->CheckLoreConflict(item) && !has_item;
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
if (!can_wear_item) {
|
if (!can_wear_item) {
|
||||||
items_already_have++;
|
items_already_have++;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (c->CastToMob()->CanClassEquipItem(item_id) && can_wear_item) {
|
if (
|
||||||
|
can_wear_item &&
|
||||||
|
t->CanClassEquipItem(item_id) &&
|
||||||
|
(
|
||||||
|
t->CanRaceEquipItem(item_id)
|
||||||
|
#ifdef BOTS
|
||||||
|
|| (t->IsBot() && !t->CanRaceEquipItem(item_id) && RuleB(Bots, AllowBotEquipAnyRaceGear))
|
||||||
|
#endif
|
||||||
|
)
|
||||||
|
) {
|
||||||
equipped.insert(slot_id);
|
equipped.insert(slot_id);
|
||||||
c->SummonItem(
|
|
||||||
|
if (t->IsClient()) {
|
||||||
|
t->CastToClient()->SummonItem(
|
||||||
item_id,
|
item_id,
|
||||||
0, 0, 0, 0, 0, 0, 0, 0,
|
0, 0, 0, 0, 0, 0, 0, 0,
|
||||||
slot_id
|
slot_id
|
||||||
);
|
);
|
||||||
|
#ifdef BOTS
|
||||||
|
} else if (t->IsBot()) {
|
||||||
|
t->CastToBot()->AddBotItem(slot_id, item_id);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
|
||||||
items_equipped++;
|
items_equipped++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -138,43 +177,36 @@ void command_gearup(Client *c, const Seperator *sep)
|
|||||||
);
|
);
|
||||||
|
|
||||||
if (expansion_arg.empty()) {
|
if (expansion_arg.empty()) {
|
||||||
results = database.QueryDatabase(
|
query = fmt::format(
|
||||||
fmt::format(
|
"SELECT expansion FROM {} WHERE "
|
||||||
SQL (
|
"class = {} AND level = {} "
|
||||||
select
|
"GROUP BY expansion",
|
||||||
expansion
|
|
||||||
from
|
|
||||||
{}
|
|
||||||
where
|
|
||||||
class = {}
|
|
||||||
and level = {}
|
|
||||||
group by
|
|
||||||
expansion;
|
|
||||||
),
|
|
||||||
tool_table_name,
|
tool_table_name,
|
||||||
c->GetClass(),
|
t->GetClass(),
|
||||||
c->GetLevel()
|
t->GetLevel()
|
||||||
|
);
|
||||||
|
results = database.QueryDatabase(query);
|
||||||
|
|
||||||
|
c->Message(Chat::White, "Choose Armor by Expansion:");
|
||||||
|
std::string message;
|
||||||
|
for (auto row : results) {
|
||||||
|
const auto expansion = std::stoi(row[0]);
|
||||||
|
message += fmt::format(
|
||||||
|
"[{}] ",
|
||||||
|
Saylink::Silent(
|
||||||
|
fmt::format("#gearup {}", expansion),
|
||||||
|
Expansion::ExpansionName[expansion]
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
c->Message(Chat::White, "Choose armor from a specific era");
|
|
||||||
std::string message;
|
|
||||||
for (auto row = results.begin(); row != results.end(); ++row) {
|
|
||||||
int expansion = atoi(row[0]);
|
|
||||||
message += "[" + Saylink::Silent(
|
|
||||||
fmt::format("#gearup {}", expansion),
|
|
||||||
Expansion::ExpansionName[expansion]
|
|
||||||
) + "] ";
|
|
||||||
|
|
||||||
if (message.length() > 2000) {
|
if (message.length() > 2000) {
|
||||||
c->Message(Chat::White, message.c_str());
|
c->Message(Chat::White, message.c_str());
|
||||||
message = "";
|
message = std::string();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (message.length() > 0) {
|
|
||||||
|
if (!message.empty()) {
|
||||||
c->Message(Chat::White, message.c_str());
|
c->Message(Chat::White, message.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user