[Commands] Cleanup #appearance Command (#3827)

* [Commands] Cleanup #appearance Command

# Notes
- Cleanup messages and logic.
- Cleanup appearance type constants to use a namespace with constexpr instead.
- Cleanup animation constants to use a namespace with constexpr instead.

* Update emu_constants.cpp

* Cleanup
This commit is contained in:
Alex King
2024-01-06 23:24:32 -05:00
committed by GitHub
parent d2f5dc43a6
commit 259add68f5
33 changed files with 330 additions and 237 deletions
+39 -39
View File
@@ -547,8 +547,8 @@ void Client::CompleteConnect()
default: { break; } // GUILD_NONE
}
}
SendAppearancePacket(AT_GuildID, GuildID(), false);
SendAppearancePacket(AT_GuildRank, rank, false);
SendAppearancePacket(AppearanceType::GuildID, GuildID(), false);
SendAppearancePacket(AppearanceType::GuildRank, rank, false);
}
// moved to dbload and translators since we iterate there also .. keep m_pp values whatever they are when they get here
@@ -703,7 +703,7 @@ void Client::CompleteConnect()
case SE_Invisibility2:
case SE_Invisibility:
{
SendAppearancePacket(AT_Invis, Invisibility::Invisible);
SendAppearancePacket(AppearanceType::Invisibility, Invisibility::Invisible);
break;
}
case SE_Levitate:
@@ -712,17 +712,17 @@ void Client::CompleteConnect()
{
if (!GetGM())
{
SendAppearancePacket(AT_Levitate, 0);
SendAppearancePacket(AppearanceType::FlyMode, 0);
BuffFadeByEffect(SE_Levitate);
Message(Chat::Red, "You can't levitate in this zone.");
}
}
else {
if (spell.limit_value[x1] == 1) {
SendAppearancePacket(AT_Levitate, EQ::constants::GravityBehavior::LevitateWhileRunning, true, true);
SendAppearancePacket(AppearanceType::FlyMode, EQ::constants::GravityBehavior::LevitateWhileRunning, true, true);
}
else {
SendAppearancePacket(AT_Levitate, EQ::constants::GravityBehavior::Levitating, true, true);
SendAppearancePacket(AppearanceType::FlyMode, EQ::constants::GravityBehavior::Levitating, true, true);
}
}
break;
@@ -747,7 +747,7 @@ void Client::CompleteConnect()
}
}
/* Sends appearances for all mobs not doing anim_stand aka sitting, looting, playing dead */
/* Sends appearances for all mobs not doing Animation::Standing aka sitting, looting, playing dead */
entity_list.SendZoneAppearance(this);
/* Sends the Nimbus particle effects (up to 3) for any mob using them */
entity_list.SendNimbusEffects(this);
@@ -1316,7 +1316,7 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
/* If GM, not trackable */
if (gm_hide_me) { trackable = false; }
if (gminvul) { invulnerable = true; }
if (flymode > 0) { SendAppearancePacket(AT_Levitate, flymode); }
if (flymode > 0) { SendAppearancePacket(AppearanceType::FlyMode, flymode); }
/* Set Con State for Reporting */
conn_state = PlayerProfileLoaded;
@@ -6482,7 +6482,7 @@ void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app)
t->SetGM(false);
}
m->SendAppearancePacket(AT_NPCName, 1, true);
m->SendAppearancePacket(AppearanceType::NPCName, 1, true);
t->SetBecomeNPC(true);
t->SetBecomeNPCLevel(b->maxlevel);
m->MessageString(Chat::White, TOGGLE_OFF);
@@ -10852,7 +10852,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// Set Sit button to unpressed - send stand anim/end hpregen
mypet->SetFeigned(false);
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SendAppearancePacket(AT_Anim, ANIM_STAND);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
mypet->SayString(this, Chat::PetResponse, PET_GUARDINGLIFE);
mypet->SetPetOrder(SPO_Guard);
@@ -10877,7 +10877,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// fix GUI sit button to be unpressed - send stand anim/end hpregen
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SendAppearancePacket(AT_Anim, ANIM_STAND);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
if (mypet->IsPetStop()) {
mypet->SetPetStop(false);
@@ -10925,7 +10925,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
// Set Sit button to unpressed - send stand anim/end hpregen
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SendAppearancePacket(AT_Anim, ANIM_STAND);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
if (mypet->IsPetStop()) {
mypet->SetPetStop(false);
@@ -10943,7 +10943,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetFeigned(false);
mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING);
mypet->SetPetOrder(SPO_Follow);
mypet->SendAppearancePacket(AT_Anim, ANIM_STAND);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
}
else
{
@@ -10953,7 +10953,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetRunAnimSpeed(0);
if (!mypet->UseBardSpellLogic()) //maybe we can have a bard pet
mypet->InterruptSpell(); //No cast 4 u. //i guess the pet should start casting
mypet->SendAppearancePacket(AT_Anim, ANIM_SIT);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Sitting);
}
}
break;
@@ -10966,7 +10966,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SayString(this, Chat::PetResponse, PET_SIT_STRING);
SetPetCommandState(PET_BUTTON_SIT, 0);
mypet->SetPetOrder(SPO_Follow);
mypet->SendAppearancePacket(AT_Anim, ANIM_STAND);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Standing);
}
break;
}
@@ -10981,7 +10981,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetRunAnimSpeed(0);
if (!mypet->UseBardSpellLogic()) //maybe we can have a bard pet
mypet->InterruptSpell(); //No cast 4 u. //i guess the pet should start casting
mypet->SendAppearancePacket(AT_Anim, ANIM_SIT);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Sitting);
}
break;
}
@@ -11186,7 +11186,7 @@ void Client::Handle_OP_PetCommands(const EQApplicationPacket *app)
mypet->SetPetOrder(SPO_FeignDeath);
mypet->SetRunAnimSpeed(0);
mypet->StopNavigation();
mypet->SendAppearancePacket(AT_Anim, ANIM_DEATH);
mypet->SendAppearancePacket(AppearanceType::Animation, Animation::Lying);
mypet->SetFeigned(true);
mypet->SetTarget(nullptr);
if (!mypet->UseBardSpellLogic()) {
@@ -14264,14 +14264,14 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
if (sa->spawn_id != GetID())
return;
if (sa->type == AT_Invis) {
if (sa->type == AppearanceType::Invisibility) {
if (sa->parameter != 0)
{
if (!HasSkill(EQ::skills::SkillHide) && GetSkill(EQ::skills::SkillHide) == 0)
{
if (ClientVersion() < EQ::versions::ClientVersion::SoF)
{
auto message = fmt::format("Player sent OP_SpawnAppearance with AT_Invis [{}]", sa->parameter);
auto message = fmt::format("Player sent OP_SpawnAppearance with AppearanceType::Invisibility [{}]", sa->parameter);
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = message});
}
}
@@ -14283,18 +14283,18 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
entity_list.QueueClients(this, app, true);
return;
}
else if (sa->type == AT_Anim) {
else if (sa->type == AppearanceType::Animation) {
if (IsAIControlled())
return;
if (sa->parameter == ANIM_STAND) {
if (sa->parameter == Animation::Standing) {
SetAppearance(eaStanding);
playeraction = 0;
SetFeigned(false);
BindWound(this, false, true);
camp_timer.Disable();
}
else if (sa->parameter == ANIM_SIT) {
else if (sa->parameter == Animation::Sitting) {
SetAppearance(eaSitting);
playeraction = 1;
if (!UseBardSpellLogic())
@@ -14304,19 +14304,19 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
tmSitting = Timer::GetCurrentTime();
BuffFadeBySitModifier();
}
else if (sa->parameter == ANIM_CROUCH) {
else if (sa->parameter == Animation::Crouching) {
if (!UseBardSpellLogic())
InterruptSpell();
SetAppearance(eaCrouching);
playeraction = 2;
SetFeigned(false);
}
else if (sa->parameter == ANIM_DEATH) { // feign death too
else if (sa->parameter == Animation::Lying) { // feign death too
SetAppearance(eaDead);
playeraction = 3;
InterruptSpell();
}
else if (sa->parameter == ANIM_LOOT) {
else if (sa->parameter == Animation::Looting) {
SetAppearance(eaLooting);
playeraction = 4;
SetFeigned(false);
@@ -14329,7 +14329,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
entity_list.QueueClients(this, app, true);
}
else if (sa->type == AT_Anon) {
else if (sa->type == AppearanceType::Anonymous) {
if (!anon_toggle_timer.Check()) {
return;
}
@@ -14351,19 +14351,19 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
entity_list.QueueClients(this, app, true);
UpdateWho();
}
else if ((sa->type == AT_HP) && (dead == 0)) {
else if ((sa->type == AppearanceType::Health) && (dead == 0)) {
return;
}
else if (sa->type == AT_AFK) {
else if (sa->type == AppearanceType::AFK) {
if (afk_toggle_timer.Check()) {
AFK = (sa->parameter == 1);
entity_list.QueueClients(this, app, true);
}
}
else if (sa->type == AT_Split) {
else if (sa->type == AppearanceType::Split) {
m_pp.autosplit = (sa->parameter == 1);
}
else if (sa->type == AT_Sneak) {
else if (sa->type == AppearanceType::Sneak) {
if (sneaking == 0)
return;
@@ -14371,7 +14371,7 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
{
if (!HasSkill(EQ::skills::SkillSneak))
{
auto message = fmt::format("Player sent OP_SpawnAppearance with AT_Sneak [{}]", sa->parameter);
auto message = fmt::format("Player sent OP_SpawnAppearance with AppearanceType::Sneak [{}]", sa->parameter);
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = message});
}
return;
@@ -14379,38 +14379,38 @@ void Client::Handle_OP_SpawnAppearance(const EQApplicationPacket *app)
sneaking = 0;
entity_list.QueueClients(this, app, true);
}
else if (sa->type == AT_Size)
else if (sa->type == AppearanceType::Size)
{
auto message = fmt::format("Player sent OP_SpawnAppearance with AT_Size [{}]", sa->parameter);
auto message = fmt::format("Player sent OP_SpawnAppearance with AppearanceType::Size [{}]", sa->parameter);
RecordPlayerEventLog(PlayerEvent::POSSIBLE_HACK, PlayerEvent::PossibleHackEvent{.message = message});
}
else if (sa->type == AT_Light) // client emitting light (lightstone, shiny shield)
else if (sa->type == AppearanceType::Light) // client emitting light (lightstone, shiny shield)
{
//don't do anything with this
}
else if (sa->type == AT_Levitate)
else if (sa->type == AppearanceType::FlyMode)
{
// don't do anything with this, we tell the client when it's
// levitating, not the other way around
}
else if (sa->type == AT_ShowHelm)
else if (sa->type == AppearanceType::ShowHelm)
{
if (helm_toggle_timer.Check()) {
m_pp.showhelm = (sa->parameter == 1);
entity_list.QueueClients(this, app, true);
}
}
else if (sa->type == AT_GroupConsent)
else if (sa->type == AppearanceType::GroupAutoConsent)
{
m_pp.groupAutoconsent = (sa->parameter == 1);
ConsentCorpses("Group", (sa->parameter != 1));
}
else if (sa->type == AT_RaidConsent)
else if (sa->type == AppearanceType::RaidAutoConsent)
{
m_pp.raidAutoconsent = (sa->parameter == 1);
ConsentCorpses("Raid", (sa->parameter != 1));
}
else if (sa->type == AT_GuildConsent)
else if (sa->type == AppearanceType::GuildAutoConsent)
{
m_pp.guildAutoconsent = (sa->parameter == 1);
ConsentCorpses("Guild", (sa->parameter != 1));