[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
+46
View File
@@ -533,3 +533,49 @@ std::string EQ::constants::GetWeatherTypeName(uint8 weather_type)
return std::string(); return std::string();
} }
const std::map<uint8, std::string> &EQ::constants::GetEmoteEventTypeMap()
{
static const std::map<uint8, std::string> emote_event_type_map = {
{ EmoteEventTypes::LeaveCombat, "Leave Combat" },
{ EmoteEventTypes::EnterCombat, "Enter Combat" },
{ EmoteEventTypes::OnDeath, "On Death" },
{ EmoteEventTypes::AfterDeath, "After Death" },
{ EmoteEventTypes::Hailed, "Hailed" },
{ EmoteEventTypes::KilledPC, "Killed PC" },
{ EmoteEventTypes::KilledNPC, "Killed NPC" },
{ EmoteEventTypes::OnSpawn, "On Spawn" },
{ EmoteEventTypes::OnDespawn, "On Despawn" }
};
return emote_event_type_map;
}
std::string EQ::constants::GetEmoteEventTypeName(uint8 emote_event_type)
{
if (EQ::ValueWithin(emote_event_type, EmoteEventTypes::LeaveCombat, EmoteEventTypes::OnDespawn)) {
return EQ::constants::GetEmoteEventTypeMap().find(emote_event_type)->second;
}
return std::string();
}
const std::map<uint8, std::string> &EQ::constants::GetEmoteTypeMap()
{
static const std::map<uint8, std::string> emote_type_map = {
{ EmoteTypes::Emote, "Emote" },
{ EmoteTypes::Shout, "Shout" },
{ EmoteTypes::Proximity, "Proximity" }
};
return emote_type_map;
}
std::string EQ::constants::GetEmoteTypeName(uint8 emote_type)
{
if (EQ::ValueWithin(emote_type, EmoteTypes::Emote, EmoteTypes::Proximity)) {
return EQ::constants::GetEmoteTypeMap().find(emote_type)->second;
}
return std::string();
}
+24
View File
@@ -337,6 +337,24 @@ namespace EQ
Snowing Snowing
}; };
enum EmoteEventTypes : uint8 {
LeaveCombat,
EnterCombat,
OnDeath,
AfterDeath,
Hailed,
KilledPC,
KilledNPC,
OnSpawn,
OnDespawn
};
enum EmoteTypes : uint8 {
Emote,
Shout,
Proximity
};
const char *GetStanceName(StanceType stance_type); const char *GetStanceName(StanceType stance_type);
int ConvertStanceTypeToIndex(StanceType stance_type); int ConvertStanceTypeToIndex(StanceType stance_type);
@@ -373,6 +391,12 @@ namespace EQ
extern const std::map<uint8, std::string>& GetWeatherTypeMap(); extern const std::map<uint8, std::string>& GetWeatherTypeMap();
std::string GetWeatherTypeName(uint8 weather_type); std::string GetWeatherTypeName(uint8 weather_type);
extern const std::map<uint8, std::string>& GetEmoteEventTypeMap();
std::string GetEmoteEventTypeName(uint8 emote_event_type);
extern const std::map<uint8, std::string>& GetEmoteTypeMap();
std::string GetEmoteTypeName(uint8 emote_type);
const int STANCE_TYPE_FIRST = stancePassive; const int STANCE_TYPE_FIRST = stancePassive;
const int STANCE_TYPE_LAST = stanceBurnAE; const int STANCE_TYPE_LAST = stanceBurnAE;
const int STANCE_TYPE_COUNT = stanceBurnAE; const int STANCE_TYPE_COUNT = stanceBurnAE;
+4 -4
View File
@@ -1802,7 +1802,7 @@ bool Client::Death(Mob* killerMob, int64 damage, uint16 spell, EQ::skills::Skill
uint32 emoteid = killerMob->GetEmoteID(); uint32 emoteid = killerMob->GetEmoteID();
if (emoteid != 0) if (emoteid != 0)
killerMob->CastToNPC()->DoNPCEmote(KILLEDPC, emoteid); killerMob->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::KilledPC, emoteid);
killerMob->TrySpellOnKill(killed_level, spell); killerMob->TrySpellOnKill(killed_level, spell);
} }
@@ -2650,7 +2650,7 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
ApplyIllusionToCorpse(illusion_spell_id, corpse); ApplyIllusionToCorpse(illusion_spell_id, corpse);
if (killer != 0 && emoteid != 0) if (killer != 0 && emoteid != 0)
corpse->CastToNPC()->DoNPCEmote(AFTERDEATH, emoteid); corpse->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::AfterDeath, emoteid);
if (killer != 0 && killer->IsClient()) { if (killer != 0 && killer->IsClient()) {
corpse->AllowPlayerLoot(killer, 0); corpse->AllowPlayerLoot(killer, 0);
if (killer->IsGrouped()) { if (killer->IsGrouped()) {
@@ -2734,12 +2734,12 @@ bool NPC::Death(Mob* killer_mob, int64 damage, uint16 spell, EQ::skills::SkillTy
uint32 emoteid = GetEmoteID(); uint32 emoteid = GetEmoteID();
if (emoteid != 0) if (emoteid != 0)
DoNPCEmote(ONDEATH, emoteid); DoNPCEmote(EQ::constants::EmoteEventTypes::OnDeath, emoteid);
if (oos->IsNPC()) { if (oos->IsNPC()) {
parse->EventNPC(EVENT_NPC_SLAY, oos->CastToNPC(), this, "", 0); parse->EventNPC(EVENT_NPC_SLAY, oos->CastToNPC(), this, "", 0);
uint32 emoteid = oos->GetEmoteID(); uint32 emoteid = oos->GetEmoteID();
if (emoteid != 0) if (emoteid != 0)
oos->CastToNPC()->DoNPCEmote(KILLEDNPC, emoteid); oos->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::KilledNPC, emoteid);
killer_mob->TrySpellOnKill(killed_level, spell); killer_mob->TrySpellOnKill(killed_level, spell);
} }
} }
+1 -1
View File
@@ -6249,7 +6249,7 @@ void Client::CheckEmoteHail(Mob *target, const char* message)
} }
uint32 emoteid = target->GetEmoteID(); uint32 emoteid = target->GetEmoteID();
if(emoteid != 0) if(emoteid != 0)
target->CastToNPC()->DoNPCEmote(HAILED,emoteid); target->CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::Hailed, emoteid);
} }
void Client::MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count) void Client::MarkSingleCompassLoc(float in_x, float in_y, float in_z, uint8 count)
+1 -1
View File
@@ -133,7 +133,7 @@ int command_init(void)
command_add("dzkickplayers", "Removes all players from current expedition. (/kickplayers alternative for pre-RoF clients)", AccountStatus::Player, command_dzkickplayers) || command_add("dzkickplayers", "Removes all players from current expedition. (/kickplayers alternative for pre-RoF clients)", AccountStatus::Player, command_dzkickplayers) ||
command_add("editmassrespawn", "[name-search] [second-value] - Mass (Zone wide) NPC respawn timer editing command", AccountStatus::GMAdmin, command_editmassrespawn) || command_add("editmassrespawn", "[name-search] [second-value] - Mass (Zone wide) NPC respawn timer editing command", AccountStatus::GMAdmin, command_editmassrespawn) ||
command_add("emote", "['name'/'world'/'zone'] [type] [message] - Send an emote message", AccountStatus::QuestTroupe, command_emote) || command_add("emote", "['name'/'world'/'zone'] [type] [message] - Send an emote message", AccountStatus::QuestTroupe, command_emote) ||
command_add("emotesearch", "Searches NPC Emotes", AccountStatus::QuestTroupe, command_emotesearch) || command_add("emotesearch", "[Search Criteria] - Search for NPC Emotes", AccountStatus::QuestTroupe, command_emotesearch) ||
command_add("emoteview", "Lists all NPC Emotes", AccountStatus::QuestTroupe, command_emoteview) || command_add("emoteview", "Lists all NPC Emotes", AccountStatus::QuestTroupe, command_emoteview) ||
command_add("emptyinventory", "Clears your or your target's entire inventory (Equipment, General, Bank, and Shared Bank)", AccountStatus::GMImpossible, command_emptyinventory) || command_add("emptyinventory", "Clears your or your target's entire inventory (Equipment, General, Bank, and Shared Bank)", AccountStatus::GMImpossible, command_emptyinventory) ||
command_add("enablerecipe", "[Recipe ID] - Enables a Recipe", AccountStatus::QuestTroupe, command_enablerecipe) || command_add("enablerecipe", "[Recipe ID] - Enables a Recipe", AccountStatus::QuestTroupe, command_enablerecipe) ||
+1 -1
View File
@@ -700,7 +700,7 @@ void EntityList::AddNPC(NPC *npc, bool SendSpawnPacket, bool dontqueue)
uint32 emoteid = npc->GetEmoteID(); uint32 emoteid = npc->GetEmoteID();
if (emoteid != 0) if (emoteid != 0)
npc->DoNPCEmote(ONSPAWN, emoteid); npc->DoNPCEmote(EQ::constants::EmoteEventTypes::OnSpawn, emoteid);
npc->SetSpawned(); npc->SetSpawned();
if (SendSpawnPacket) { if (SendSpawnPacket) {
if (dontqueue) { // aka, SEND IT NOW BITCH! if (dontqueue) { // aka, SEND IT NOW BITCH!
+126 -62
View File
@@ -2,77 +2,141 @@
void command_emotesearch(Client *c, const Seperator *sep) void command_emotesearch(Client *c, const Seperator *sep)
{ {
if (sep->arg[1][0] == 0) { auto arguments = sep->argnum;
c->Message(Chat::White, "Usage: #emotesearch [search string or emoteid]"); if (!arguments) {
c->Message(Chat::White, "Usage: #emotesearch [Emote ID]");
c->Message(Chat::White, "Usage: #emotesearch [Search Crteria]");
return;
} }
else {
const char *search_criteria = sep->argplus[1];
int count = 0;
if (Seperator::IsNumber(search_criteria)) { auto emote_count = 0;
uint32 emoteid = atoi(search_criteria); auto emote_number = 1;
LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList);
iterator.Reset(); std::string search_criteria = sep->argplus[1];
while (iterator.MoreElements()) { bool found_by_id = false;
NPC_Emote_Struct *nes = iterator.GetData();
if (emoteid == nes->emoteid) { if (!sep->IsNumber(1)) {
c->Message( LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList);
Chat::White, iterator.Reset();
"EmoteID: %i Event: %i Type: %i Text: %s", while (iterator.MoreElements()) {
nes->emoteid, auto &e = iterator.GetData();
nes->event_, auto current_text = Strings::ToLower(e->text);
nes->type,
nes->text if (Strings::Contains(current_text, Strings::ToLower(search_criteria))) {
); c->Message(
count++; Chat::White,
} fmt::format(
iterator.Advance(); "Emote {} | Emote ID: {}",
emote_number,
e->emoteid
).c_str()
);
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++;
} }
if (count == 0) {
c->Message(Chat::White, "No emotes found."); if (emote_count == 50) {
} break;
else {
c->Message(Chat::White, "%i emote(s) found", count);
} }
iterator.Advance();
} }
else { } else {
char sText[64]; auto emote_id = std::stoul(search_criteria);
char sCriteria[515];
strn0cpy(sCriteria, search_criteria, sizeof(sCriteria));
strupr(sCriteria);
char *pdest;
LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList); LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList);
iterator.Reset(); iterator.Reset();
while (iterator.MoreElements()) { while (iterator.MoreElements()) {
NPC_Emote_Struct *nes = iterator.GetData(); auto &e = iterator.GetData();
strn0cpy(sText, nes->text, sizeof(sText)); if (emote_id == e->emoteid) {
strupr(sText); found_by_id = true;
pdest = strstr(sText, sCriteria);
if (pdest != nullptr) {
c->Message(
Chat::White,
"EmoteID: %i Event: %i Type: %i Text: %s",
nes->emoteid,
nes->event_,
nes->type,
nes->text
);
count++;
}
if (count == 50) {
break;
}
iterator.Advance(); 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++;
} }
if (count == 50) {
c->Message(Chat::White, "50 emotes shown...too many results."); if (emote_count == 50) {
} break;
else {
c->Message(Chat::White, "%i emote(s) found", count);
} }
iterator.Advance();
} }
} }
auto found_string = (
found_by_id ?
fmt::format("ID {}", search_criteria) :
search_criteria
);
if (!emote_count) {
c->Message(
Chat::White,
fmt::format(
"No Emotes found matching {}.",
found_string
).c_str()
);
} else if (emote_count == 50) {
c->Message(
Chat::White,
fmt::format(
"50 Emotes shown matching {}, too many results.",
found_string
).c_str()
);
} else {
c->Message(
Chat::White,
fmt::format(
"{} Emote{} found matching {}.",
emote_count,
emote_count != 1 ? "s" : "",
found_string
).c_str()
);
}
} }
+60 -27
View File
@@ -3,37 +3,70 @@
void command_emoteview(Client *c, const Seperator *sep) void command_emoteview(Client *c, const Seperator *sep)
{ {
if (!c->GetTarget() || !c->GetTarget()->IsNPC()) { 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; return;
} }
if (c->GetTarget() && c->GetTarget()->IsNPC()) { auto target = c->GetTarget()->CastToNPC();
int count = 0;
int emoteid = c->GetTarget()->CastToNPC()->GetEmoteID();
LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList); auto emote_count = 0;
iterator.Reset(); auto emote_id = target->GetEmoteID();
while (iterator.MoreElements()) {
NPC_Emote_Struct *nes = iterator.GetData(); auto emote_number = 1;
if (emoteid == nes->emoteid) {
c->Message( LinkedListIterator<NPC_Emote_Struct *> iterator(zone->NPCEmoteList);
Chat::White, iterator.Reset();
"EmoteID: %i Event: %i Type: %i Text: %s", while (iterator.MoreElements()) {
nes->emoteid, auto &e = iterator.GetData();
nes->event_, if (emote_id == e->emoteid) {
nes->type, c->Message(
nes->text Chat::White,
); fmt::format(
count++; "Emote {} | Event: {} ({}) Type: {} ({})",
} emote_number,
iterator.Advance(); EQ::constants::GetEmoteEventTypeName(e->event_),
} e->event_,
if (count == 0) { EQ::constants::GetEmoteTypeName(e->type),
c->Message(Chat::White, "No emotes found."); e->type
} ).c_str()
else { );
c->Message(Chat::White, "%i emote(s) found", count);
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()
);
}
+2 -2
View File
@@ -1925,7 +1925,7 @@ void Mob::AI_Event_Engaged(Mob *attacker, bool yell_for_help)
parse->EventNPC(EVENT_COMBAT, CastToNPC(), attacker, "1", 0); parse->EventNPC(EVENT_COMBAT, CastToNPC(), attacker, "1", 0);
uint32 emoteid = GetEmoteID(); uint32 emoteid = GetEmoteID();
if (emoteid != 0) { if (emoteid != 0) {
CastToNPC()->DoNPCEmote(ENTERCOMBAT, emoteid); CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::EnterCombat, emoteid);
} }
std::string mob_name = GetCleanName(); std::string mob_name = GetCleanName();
combat_record.Start(mob_name); combat_record.Start(mob_name);
@@ -1958,7 +1958,7 @@ void Mob::AI_Event_NoLongerEngaged() {
uint32 emoteid = CastToNPC()->GetEmoteID(); uint32 emoteid = CastToNPC()->GetEmoteID();
parse->EventNPC(EVENT_COMBAT, CastToNPC(), nullptr, "0", 0); parse->EventNPC(EVENT_COMBAT, CastToNPC(), nullptr, "0", 0);
if (emoteid != 0) { if (emoteid != 0) {
CastToNPC()->DoNPCEmote(LEAVECOMBAT, emoteid); CastToNPC()->DoNPCEmote(EQ::constants::EmoteEventTypes::LeaveCombat, emoteid);
} }
combat_record.Stop(); combat_record.Stop();
CastToNPC()->SetCombatEvent(false); CastToNPC()->SetCombatEvent(false);
+1 -1
View File
@@ -1112,7 +1112,7 @@ void NPC::UpdateEquipmentLight()
void NPC::Depop(bool StartSpawnTimer) { void NPC::Depop(bool StartSpawnTimer) {
uint32 emoteid = GetEmoteID(); uint32 emoteid = GetEmoteID();
if(emoteid != 0) if(emoteid != 0)
DoNPCEmote(ONDESPAWN,emoteid); DoNPCEmote(EQ::constants::EmoteEventTypes::OnDespawn,emoteid);
p_depop = true; p_depop = true;
if (respawn2) if (respawn2)
{ {
-10
View File
@@ -35,16 +35,6 @@
#define M_PI 3.141592 #define M_PI 3.141592
#endif #endif
#define LEAVECOMBAT 0
#define ENTERCOMBAT 1
#define ONDEATH 2
#define AFTERDEATH 3
#define HAILED 4
#define KILLEDPC 5
#define KILLEDNPC 6
#define ONSPAWN 7
#define ONDESPAWN 8
typedef struct { typedef struct {
float min_x; float min_x;
float max_x; float max_x;