[Commands] Cleanup #emotesearch and #emoteview Command. (#2494)

* [Commands] Cleanup #emoteview Command.

Cleanup command messages and logic.

Add constants for Emote Events and Emote Types and replace all the old constants with the new constants.

* Update emoteview.cpp

* Cleanup #emotesearch Command.
This commit is contained in:
Kinglykrab
2022-10-29 21:22:17 -04:00
committed by GitHub
parent dcbc9a358f
commit 53dcd14534
11 changed files with 266 additions and 109 deletions
+60 -27
View File
@@ -3,37 +3,70 @@
void command_emoteview(Client *c, const Seperator *sep)
{
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) {
c->Message(Chat::White, "You must target a NPC to view their emotes.");
c->Message(Chat::White, "You must target an NPC to view their emotes.");
return;
}
if (c->GetTarget() && c->GetTarget()->IsNPC()) {
int count = 0;
int emoteid = c->GetTarget()->CastToNPC()->GetEmoteID();
auto target = c->GetTarget()->CastToNPC();
LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList);
iterator.Reset();
while (iterator.MoreElements()) {
NPC_Emote_Struct *nes = iterator.GetData();
if (emoteid == nes->emoteid) {
c->Message(
Chat::White,
"EmoteID: %i Event: %i Type: %i Text: %s",
nes->emoteid,
nes->event_,
nes->type,
nes->text
);
count++;
}
iterator.Advance();
}
if (count == 0) {
c->Message(Chat::White, "No emotes found.");
}
else {
c->Message(Chat::White, "%i emote(s) found", count);
auto emote_count = 0;
auto emote_id = target->GetEmoteID();
auto emote_number = 1;
LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList);
iterator.Reset();
while (iterator.MoreElements()) {
auto &e = iterator.GetData();
if (emote_id == e->emoteid) {
c->Message(
Chat::White,
fmt::format(
"Emote {} | Event: {} ({}) Type: {} ({})",
emote_number,
EQ::constants::GetEmoteEventTypeName(e->event_),
e->event_,
EQ::constants::GetEmoteTypeName(e->type),
e->type
).c_str()
);
c->Message(
Chat::White,
fmt::format(
"Emote {} | Text: {}",
emote_number,
e->text
).c_str()
);
emote_count++;
emote_number++;
}
iterator.Advance();
}
}
if (!emote_count) {
c->Message(
Chat::White,
fmt::format(
"{} has no emotes on Emote ID {}.",
c->GetTargetDescription(target),
emote_id
).c_str()
);
return;
}
c->Message(
Chat::White,
fmt::format(
"{} has {} emote{} on Emote ID {}.",
c->GetTargetDescription(target),
emote_count,
emote_count != 1 ? "s" : "",
emote_id
).c_str()
);
}