[Feature] GM State Change Persistance (#2328)

* [Feature] GM State Change Persistance

- Flymode and Invulnerable will now persist over zoning.

- Appended GMSpeed, Flymode and Invulnerable to the hideme message GMs see when they first login.

- Added #godmode [on/off] command to turn on or off hideme, flymode, gmspeed and invulnerable all in one shot.

- /becomenpc will now disable tells to the target player. It will also automatically disable GM States that interfere with its functionality.

- GM Command /toggle will not properly turn tells on/off

- GMs will now be notified if they are ignoring tells when they first zone-in, provided their GM flag is up.

- Added TellsOff variable to the output to #showstats

* [Bug] Fix tells when gmhideme is turned off.

* [Cleanup] Cleanup function and rename for consistancy.

Remove un-needed this->

* Tweaks

* Tweaks

* Update db_update_manifest.txt

* Move string building logic to a vector and use strings join

* Update client_packet.cpp

* Update 2022_07_28_gm_state_changes.sql

* PR comment tweaks

Co-authored-by: Akkadius <akkadius1@gmail.com>
This commit is contained in:
Michael
2022-07-30 20:29:24 -04:00
committed by GitHub
parent 793d4bc3a4
commit ea878ed27f
15 changed files with 252 additions and 125 deletions
+11 -10
View File
@@ -220,6 +220,7 @@ Client::Client(EQStreamInterface* ieqs)
LFGComments[0] = '\0';
LFP = false;
gmspeed = 0;
gminvul = false;
playeraction = 0;
SetTarget(0);
auto_attack = false;
@@ -3378,27 +3379,26 @@ void Client::SetTint(int16 in_slot, EQ::textures::Tint_Struct& color) {
}
void Client::SetHideMe(bool flag)
void Client::SetHideMe(bool gm_hide_me)
{
EQApplicationPacket app;
gm_hide_me = flag;
if(gm_hide_me)
{
database.SetHideMe(AccountID(),true);
if (gm_hide_me) {
database.SetHideMe(AccountID(), true);
CreateDespawnPacket(&app, false);
entity_list.RemoveFromTargets(this);
trackable = false;
tellsoff = true;
}
else
{
database.SetHideMe(AccountID(),false);
else {
database.SetHideMe(AccountID(), false);
CreateSpawnPacket(&app);
trackable = true;
tellsoff = false;
}
entity_list.QueueClientsStatus(this, &app, true, 0, Admin()-1);
entity_list.QueueClientsStatus(this, &app, true, 0, Admin() - 1);
UpdateWho();
}
void Client::SetLanguageSkill(int langid, int value)
@@ -7092,6 +7092,7 @@ void Client::SendStatsWindow(Client* client, bool use_window)
client->Message(Chat::White, " compute_tohit: %i TotalToHit: %i", compute_tohit(skill), GetTotalToHit(skill, 0));
client->Message(Chat::White, " compute_defense: %i TotalDefense: %i", compute_defense(), GetTotalDefense());
client->Message(Chat::White, " offense: %i mitigation ac: %i", offense(skill), GetMitigationAC());
client->Message(Chat::White, " AFK: %i LFG: %i Anon: %i PVP: %i GM: %i Flymode: %i GMSpeed: %i Hideme: %i GMInvul: %d LD: %i ClientVersion: %i TellsOff: %i", AFK, LFG, GetAnon(), GetPVP(), GetGM(), flymode, GetGMSpeed(), GetHideMe(), GetGMInvul(), IsLD(), ClientVersionBit(), tellsoff);
if(CalcMaxMana() > 0)
client->Message(Chat::White, " Mana: %i/%i Mana Regen: %i/%i", GetMana(), GetMaxMana(), CalcManaRegen(), CalcManaRegenCap());
client->Message(Chat::White, " End.: %i/%i End. Regen: %i/%i",GetEndurance(), GetMaxEndurance(), CalcEnduranceRegen(), CalcEnduranceRegenCap());
+2
View File
@@ -1040,6 +1040,7 @@ public:
void SendRules();
const bool GetGMSpeed() const { return (gmspeed > 0); }
const bool GetGMInvul() const { return gminvul; }
bool CanUseReport;
//This is used to later set the buff duration of the spell, in slot to duration.
@@ -1786,6 +1787,7 @@ private:
bool auto_fire;
bool runmode;
uint8 gmspeed;
bool gminvul;
bool medding;
uint16 horseId;
bool revoked;
+64 -30
View File
@@ -68,6 +68,7 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#include "../common/shared_tasks.h"
#include "gm_commands/door_manipulation.h"
#include "client.h"
#include "../common/repositories/account_repository.h"
#ifdef BOTS
@@ -569,7 +570,31 @@ void Client::CompleteConnect()
//SendAATable();
if (GetHideMe()) Message(Chat::Red, "[GM] You are currently hidden to all clients");
if (GetGM() && (GetHideMe() || GetGMSpeed() || GetGMInvul() || flymode != 0 || tellsoff)) {
std::vector<std::string> state;
if (GetHideMe()) {
state.emplace_back("hidden to all clients");
}
if (GetGMSpeed()) {
state.emplace_back("running at GM speed");
}
if (GetGMInvul()) {
state.emplace_back("invulnerable to all damage");
}
if (flymode == GravityBehavior::Flying) {
state.emplace_back("flying");
}
else if (flymode == GravityBehavior::Levitating) {
state.emplace_back("levitating");
}
if (tellsoff) {
state.emplace_back("ignoring tells");
}
if (!state.empty()) {
Message(Chat::Red, "[GM] You are currently %s.", Strings::Join(state, ", ").c_str());
}
}
uint32 raidid = database.GetRaidID(GetName());
Raid *raid = nullptr;
@@ -1184,23 +1209,25 @@ void Client::Handle_Connect_OP_ZoneEntry(const EQApplicationPacket *app)
database.RemoveTempFactions(this);
database.LoadCharacterFactionValues(cid, factionvalues);
/* Load Character Account Data: Temp until I move */
query = StringFormat("SELECT `status`, `name`, `ls_id`, `lsaccount_id`, `gmspeed`, `revoked`, `hideme`, `time_creation` FROM `account` WHERE `id` = %u", AccountID());
auto results = database.QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
admin = atoi(row[0]);
strn0cpy(account_name, row[1], sizeof(account_name));
strn0cpy(loginserver, row[2], sizeof(loginserver));
lsaccountid = atoi(row[3]);
gmspeed = atoi(row[4]);
revoked = atoi(row[5]);
gm_hide_me = atoi(row[6]);
account_creation = atoul(row[7]);
auto a = AccountRepository::FindOne(database, AccountID());
if (a.id > 0) {
strn0cpy(account_name, a.name.c_str(), sizeof(account_name));
strn0cpy(loginserver, a.ls_id.c_str(), sizeof(loginserver));
admin = a.status;
lsaccountid = a.lsaccount_id;
gmspeed = a.gmspeed;
revoked = a.revoked;
gm_hide_me = a.hideme;
account_creation = a.time_creation;
gminvul = a.invulnerable;
flymode = static_cast<GravityBehavior>(a.flymode);
tellsoff = gm_hide_me;
}
/* Load Character Data */
query = StringFormat("SELECT `lfp`, `lfg`, `xtargets`, `firstlogon`, `guild_id`, `rank` FROM `character_data` LEFT JOIN `guild_members` ON `id` = `char_id` WHERE `id` = %i", cid);
results = database.QueryDatabase(query);
auto results = database.QueryDatabase(query);
for (auto row = results.begin(); row != results.end(); ++row) {
if (row[4] && atoi(row[4]) > 0) {
guild_id = atoi(row[4]);
@@ -1266,6 +1293,8 @@ 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); }
/* Set Con State for Reporting */
conn_state = PlayerProfileLoaded;
@@ -6117,17 +6146,26 @@ void Client::Handle_OP_GMBecomeNPC(const EQApplicationPacket *app)
BecomeNPC_Struct* bnpc = (BecomeNPC_Struct*)app->pBuffer;
Mob* cli = (Mob*)entity_list.GetMob(bnpc->id);
if (cli == 0)
if (cli == nullptr) {
return;
}
if (cli->IsClient())
cli->CastToClient()->QueuePacket(app);
cli->SendAppearancePacket(AT_NPCName, 1, true);
cli->CastToClient()->SetBecomeNPC(true);
cli->CastToClient()->SetBecomeNPCLevel(bnpc->maxlevel);
cli->MessageString(Chat::White, TOGGLE_OFF);
cli->CastToClient()->tellsoff = true;
//TODO: Make this toggle a BecomeNPC flag so that it gets updated when people zone in as well; Make combat work with this.
if (cli->IsClient()) {
Client* target = cli->CastToClient();
target->QueuePacket(app);
if(target->GetGM()) {
target->SetInvul(false);
target->SetHideMe(false);
target->SetGM(false);
}
cli->SendAppearancePacket(AT_NPCName, 1, true);
target->SetBecomeNPC(true);
target->SetBecomeNPCLevel(bnpc->maxlevel);
cli->MessageString(Chat::White, TOGGLE_OFF);
target->tellsoff = true;
target->UpdateWho();
}
return;
}
@@ -6532,16 +6570,12 @@ void Client::Handle_OP_GMToggle(const EQApplicationPacket *app)
GMToggle_Struct *ts = (GMToggle_Struct *)app->pBuffer;
if (ts->toggle == 0) {
MessageString(Chat::White, TOGGLE_OFF);
//Message(0, "Turning tells OFF");
tellsoff = true;
}
else if (ts->toggle == 1) {
//Message(0, "Turning tells ON");
} else if (ts->toggle == 1) {
MessageString(Chat::White, TOGGLE_ON);
tellsoff = false;
}
else {
Message(0, "Unkown value in /toggle packet");
} else {
Message(Chat::White, "Unkown value in /toggle packet");
}
UpdateWho();
return;
+2
View File
@@ -166,6 +166,7 @@ int command_init(void)
command_add("gm", "[On|Off] - Modify your or your target's GM Flag", AccountStatus::QuestTroupe, command_gm) ||
command_add("gmspeed", "[On|Off] - Turn GM Speed On or Off for you or your player target", AccountStatus::GMAdmin, command_gmspeed) ||
command_add("gmzone", "[Zone ID|Zone Short Name] [Version] [Instance Identifier] - Zones to a private GM instance (Version defaults to 0 and Instance Identifier defaults to 'gmzone' if not used)", AccountStatus::GMAdmin, command_gmzone) ||
command_add("godmode", "[on/off] - Turns on/off hideme, gmspeed, invul, and flymode.", AccountStatus::GMMgmt, command_godmode) ||
command_add("goto", "[playername] or [x y z] [h] - Teleport to the provided coordinates or to your target", AccountStatus::Steward, command_goto) ||
command_add("grid", "[add/delete] [grid_num] [wandertype] [pausetype] - Create/delete a wandering grid", AccountStatus::GMAreas, command_grid) ||
command_add("guild", "Guild manipulation commands. Use argument help for more info.", AccountStatus::Steward, command_guild) ||
@@ -1007,6 +1008,7 @@ void command_bot(Client *c, const Seperator *sep)
#include "gm_commands/gm.cpp"
#include "gm_commands/gmspeed.cpp"
#include "gm_commands/gmzone.cpp"
#include "gm_commands/godmode.cpp"
#include "gm_commands/goto.cpp"
#include "gm_commands/grid.cpp"
#include "gm_commands/guild.cpp"
+1
View File
@@ -105,6 +105,7 @@ void command_globalview(Client *c, const Seperator *sep);
void command_gm(Client *c, const Seperator *sep);
void command_gmspeed(Client *c, const Seperator *sep);
void command_gmzone(Client *c, const Seperator *sep);
void command_godmode(Client* c, const Seperator *sep);
void command_goto(Client *c, const Seperator *sep);
void command_grid(Client *c, const Seperator *sep);
void command_guild(Client *c, const Seperator *sep);
+2
View File
@@ -24,6 +24,8 @@ void command_flymode(Client *c, const Seperator *sep)
target->SetFlyMode(static_cast<GravityBehavior>(flymode_id));
target->SendAppearancePacket(AT_Levitate, flymode_id);
uint32 account = c->AccountID();
database.SetGMFlymode(account, flymode_id);
c->Message(
Chat::White,
fmt::format(
+33
View File
@@ -0,0 +1,33 @@
#include "../client.h"
#include "../../common/repositories/account_repository.h"
void command_godmode(Client *c, const Seperator *sep)
{
bool state = atobool(sep->arg[1]);
uint32 account_id = c->AccountID();
if (sep->arg[1][0] != 0) {
auto a = AccountRepository::FindOne(database, c->AccountID());
if (a.id > 0) {
a.flymode = state ? 1 : 0;
a.gmspeed = state ? 1 : 0;
a.invulnerable = state ? 1 : 0;
a.hideme = state ? 1 : 0;
}
c->SetInvul(state);
c->SendAppearancePacket(AT_Levitate, state);
c->SetHideMe(state);
c->Message(
Chat::White,
"Turning GodMode %s for %s (zone for gmspeed to take effect)",
state ? "On" : "Off",
c->GetName()
);
AccountRepository::UpdateOne(database, a);
}
else {
c->Message(Chat::White, "Usage: #godmode [on/off]");
}
}
+3 -3
View File
@@ -1,7 +1,6 @@
#include "../client.h"
void command_invul(Client *c, const Seperator *sep)
{
void command_invul(Client *c, const Seperator *sep) {
int arguments = sep->argnum;
if (!arguments) {
c->Message(Chat::White, "Usage: #invul [On|Off]");
@@ -15,6 +14,8 @@ void command_invul(Client *c, const Seperator *sep)
}
target->SetInvul(invul_flag);
uint32 account = target->AccountID();
database.SetGMInvul(account, invul_flag);
c->Message(
Chat::White,
fmt::format(
@@ -25,4 +26,3 @@ void command_invul(Client *c, const Seperator *sep)
).c_str()
);
}
+1 -1
View File
@@ -1959,7 +1959,7 @@ bool Client::SwapItem(MoveItem_Struct* move_in) {
// Check for No Drop Hacks
Mob* with = trade->With();
if (((with && with->IsClient() && dst_slot_id >= EQ::invslot::TRADE_BEGIN && dst_slot_id <= EQ::invslot::TRADE_END) ||
if (((with && with->IsClient() && !with->CastToClient()->IsBecomeNPC() && dst_slot_id >= EQ::invslot::TRADE_BEGIN && dst_slot_id <= EQ::invslot::TRADE_END) ||
(dst_slot_id >= EQ::invslot::SHARED_BANK_BEGIN && dst_slot_id <= EQ::invbag::SHARED_BANK_BAGS_END))
&& GetInv().CheckNoDrop(src_slot_id)
&& !CanTradeFVNoDropItem()) {