[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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
15 changed files with 252 additions and 125 deletions

View File

@ -28,6 +28,9 @@ public:
std::string ls_id;
int lsaccount_id;
int gmspeed;
int invulnerable;
int flymode;
int ignore_tells;
int revoked;
int karma;
std::string minilogin_ip;
@ -60,6 +63,9 @@ public:
"ls_id",
"lsaccount_id",
"gmspeed",
"invulnerable",
"flymode",
"ignore_tells",
"revoked",
"karma",
"minilogin_ip",
@ -88,6 +94,9 @@ public:
"ls_id",
"lsaccount_id",
"gmspeed",
"invulnerable",
"flymode",
"ignore_tells",
"revoked",
"karma",
"minilogin_ip",
@ -150,6 +159,9 @@ public:
entry.ls_id = "eqemu";
entry.lsaccount_id = 0;
entry.gmspeed = 0;
entry.invulnerable = 0;
entry.flymode = 0;
entry.ignore_tells = 0;
entry.revoked = 0;
entry.karma = 0;
entry.minilogin_ip = "";
@ -207,19 +219,22 @@ public:
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
entry.crc_eqgame = row[19] ? row[19] : "";
entry.crc_skillcaps = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : "";
entry.invulnerable = atoi(row[9]);
entry.flymode = atoi(row[10]);
entry.ignore_tells = atoi(row[11]);
entry.revoked = atoi(row[12]);
entry.karma = atoi(row[13]);
entry.minilogin_ip = row[14] ? row[14] : "";
entry.hideme = atoi(row[15]);
entry.rulesflag = atoi(row[16]);
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.time_creation = atoi(row[18]);
entry.expansion = atoi(row[19]);
entry.ban_reason = row[20] ? row[20] : "";
entry.suspend_reason = row[21] ? row[21] : "";
entry.crc_eqgame = row[22] ? row[22] : "";
entry.crc_skillcaps = row[23] ? row[23] : "";
entry.crc_basedata = row[24] ? row[24] : "";
return entry;
}
@ -261,19 +276,22 @@ public:
update_values.push_back(columns[6] + " = '" + Strings::Escape(account_entry.ls_id) + "'");
update_values.push_back(columns[7] + " = " + std::to_string(account_entry.lsaccount_id));
update_values.push_back(columns[8] + " = " + std::to_string(account_entry.gmspeed));
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.revoked));
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.karma));
update_values.push_back(columns[11] + " = '" + Strings::Escape(account_entry.minilogin_ip) + "'");
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.hideme));
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.rulesflag));
update_values.push_back(columns[14] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.time_creation));
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.expansion));
update_values.push_back(columns[17] + " = '" + Strings::Escape(account_entry.ban_reason) + "'");
update_values.push_back(columns[18] + " = '" + Strings::Escape(account_entry.suspend_reason) + "'");
update_values.push_back(columns[19] + " = '" + Strings::Escape(account_entry.crc_eqgame) + "'");
update_values.push_back(columns[20] + " = '" + Strings::Escape(account_entry.crc_skillcaps) + "'");
update_values.push_back(columns[21] + " = '" + Strings::Escape(account_entry.crc_basedata) + "'");
update_values.push_back(columns[9] + " = " + std::to_string(account_entry.invulnerable));
update_values.push_back(columns[10] + " = " + std::to_string(account_entry.flymode));
update_values.push_back(columns[11] + " = " + std::to_string(account_entry.ignore_tells));
update_values.push_back(columns[12] + " = " + std::to_string(account_entry.revoked));
update_values.push_back(columns[13] + " = " + std::to_string(account_entry.karma));
update_values.push_back(columns[14] + " = '" + Strings::Escape(account_entry.minilogin_ip) + "'");
update_values.push_back(columns[15] + " = " + std::to_string(account_entry.hideme));
update_values.push_back(columns[16] + " = " + std::to_string(account_entry.rulesflag));
update_values.push_back(columns[17] + " = FROM_UNIXTIME(" + (account_entry.suspendeduntil > 0 ? std::to_string(account_entry.suspendeduntil) : "null") + ")");
update_values.push_back(columns[18] + " = " + std::to_string(account_entry.time_creation));
update_values.push_back(columns[19] + " = " + std::to_string(account_entry.expansion));
update_values.push_back(columns[20] + " = '" + Strings::Escape(account_entry.ban_reason) + "'");
update_values.push_back(columns[21] + " = '" + Strings::Escape(account_entry.suspend_reason) + "'");
update_values.push_back(columns[22] + " = '" + Strings::Escape(account_entry.crc_eqgame) + "'");
update_values.push_back(columns[23] + " = '" + Strings::Escape(account_entry.crc_skillcaps) + "'");
update_values.push_back(columns[24] + " = '" + Strings::Escape(account_entry.crc_basedata) + "'");
auto results = db.QueryDatabase(
fmt::format(
@ -304,6 +322,9 @@ public:
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.invulnerable));
insert_values.push_back(std::to_string(account_entry.flymode));
insert_values.push_back(std::to_string(account_entry.ignore_tells));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
@ -355,6 +376,9 @@ public:
insert_values.push_back("'" + Strings::Escape(account_entry.ls_id) + "'");
insert_values.push_back(std::to_string(account_entry.lsaccount_id));
insert_values.push_back(std::to_string(account_entry.gmspeed));
insert_values.push_back(std::to_string(account_entry.invulnerable));
insert_values.push_back(std::to_string(account_entry.flymode));
insert_values.push_back(std::to_string(account_entry.ignore_tells));
insert_values.push_back(std::to_string(account_entry.revoked));
insert_values.push_back(std::to_string(account_entry.karma));
insert_values.push_back("'" + Strings::Escape(account_entry.minilogin_ip) + "'");
@ -410,19 +434,22 @@ public:
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
entry.crc_eqgame = row[19] ? row[19] : "";
entry.crc_skillcaps = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : "";
entry.invulnerable = atoi(row[9]);
entry.flymode = atoi(row[10]);
entry.ignore_tells = atoi(row[11]);
entry.revoked = atoi(row[12]);
entry.karma = atoi(row[13]);
entry.minilogin_ip = row[14] ? row[14] : "";
entry.hideme = atoi(row[15]);
entry.rulesflag = atoi(row[16]);
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.time_creation = atoi(row[18]);
entry.expansion = atoi(row[19]);
entry.ban_reason = row[20] ? row[20] : "";
entry.suspend_reason = row[21] ? row[21] : "";
entry.crc_eqgame = row[22] ? row[22] : "";
entry.crc_skillcaps = row[23] ? row[23] : "";
entry.crc_basedata = row[24] ? row[24] : "";
all_entries.push_back(entry);
}
@ -456,19 +483,22 @@ public:
entry.ls_id = row[6] ? row[6] : "";
entry.lsaccount_id = atoi(row[7]);
entry.gmspeed = atoi(row[8]);
entry.revoked = atoi(row[9]);
entry.karma = atoi(row[10]);
entry.minilogin_ip = row[11] ? row[11] : "";
entry.hideme = atoi(row[12]);
entry.rulesflag = atoi(row[13]);
entry.suspendeduntil = strtoll(row[14] ? row[14] : "-1", nullptr, 10);
entry.time_creation = atoi(row[15]);
entry.expansion = atoi(row[16]);
entry.ban_reason = row[17] ? row[17] : "";
entry.suspend_reason = row[18] ? row[18] : "";
entry.crc_eqgame = row[19] ? row[19] : "";
entry.crc_skillcaps = row[20] ? row[20] : "";
entry.crc_basedata = row[21] ? row[21] : "";
entry.invulnerable = atoi(row[9]);
entry.flymode = atoi(row[10]);
entry.ignore_tells = atoi(row[11]);
entry.revoked = atoi(row[12]);
entry.karma = atoi(row[13]);
entry.minilogin_ip = row[14] ? row[14] : "";
entry.hideme = atoi(row[15]);
entry.rulesflag = atoi(row[16]);
entry.suspendeduntil = strtoll(row[17] ? row[17] : "-1", nullptr, 10);
entry.time_creation = atoi(row[18]);
entry.expansion = atoi(row[19]);
entry.ban_reason = row[20] ? row[20] : "";
entry.suspend_reason = row[21] ? row[21] : "";
entry.crc_eqgame = row[22] ? row[22] : "";
entry.crc_skillcaps = row[23] ? row[23] : "";
entry.crc_basedata = row[24] ? row[24] : "";
all_entries.push_back(entry);
}

View File

@ -39,6 +39,7 @@
#include "eqemu_config.h"
#include "data_verification.h"
#include "repositories/criteria/content_filter_criteria.h"
#include "repositories/account_repository.h"
namespace ItemField
{
@ -65,40 +66,56 @@ SharedDatabase::~SharedDatabase() = default;
bool SharedDatabase::SetHideMe(uint32 account_id, uint8 hideme)
{
const std::string query = StringFormat("UPDATE account SET hideme = %i WHERE id = %i", hideme, account_id);
const auto results = QueryDatabase(query);
if (!results.Success()) {
return false;
auto a = AccountRepository::FindOne(*this, account_id);
if (a.id > 0) {
a.hideme = hideme ? 1 : 0;
AccountRepository::UpdateOne(*this, a);
}
return true;
return a.id > 0;
}
uint8 SharedDatabase::GetGMSpeed(uint32 account_id)
{
const std::string query = StringFormat("SELECT gmspeed FROM account WHERE id = '%i'", account_id);
auto results = QueryDatabase(query);
if (!results.Success()) {
return 0;
auto a = AccountRepository::FindOne(*this, account_id);
if (a.id > 0) {
return a.gmspeed;
}
if (results.RowCount() != 1)
return 0;
auto& row = results.begin();
return atoi(row[0]);
return 0;
}
bool SharedDatabase::SetGMSpeed(uint32 account_id, uint8 gmspeed)
{
const std::string query = StringFormat("UPDATE account SET gmspeed = %i WHERE id = %i", gmspeed, account_id);
const auto results = QueryDatabase(query);
if (!results.Success()) {
return false;
auto a = AccountRepository::FindOne(*this, account_id);
if (a.id > 0) {
a.gmspeed = gmspeed ? 1 : 0;
AccountRepository::UpdateOne(*this, a);
}
return true;
return a.id > 0;
}
bool SharedDatabase::SetGMInvul(uint32 account_id, bool gminvul)
{
auto a = AccountRepository::FindOne(*this, account_id);
if (a.id > 0) {
a.invulnerable = gminvul ? 1 : 0;
AccountRepository::UpdateOne(*this, a);
}
return a.id > 0;
}
bool SharedDatabase::SetGMFlymode(uint32 account_id, uint8 flymode)
{
auto a = AccountRepository::FindOne(*this, account_id);
if (a.id > 0) {
a.flymode = flymode;
AccountRepository::UpdateOne(*this, a);
}
return a.id > 0;
}
uint32 SharedDatabase::GetTotalTimeEntitledOnAccount(uint32 AccountID) {

View File

@ -79,6 +79,8 @@ public:
bool UpdateInjectedCommandSettings(const std::vector<std::pair<std::string, uint8>> &injected);
bool UpdateOrphanedCommandSettings(const std::vector<std::string> &orphaned);
uint32 GetTotalTimeEntitledOnAccount(uint32 AccountID);
bool SetGMInvul(uint32 account_id, bool gminvul);
bool SetGMFlymode(uint32 account_id, uint8 flymode);
void SetMailKey(int CharID, int IPAddress, int MailKey);
std::string GetMailKey(int CharID, bool key_only = false);
bool SaveCursor(

View File

@ -444,6 +444,7 @@
9188|2022_07_14_zone_expansion_revert.sql|SHOW COLUMNS FROM `zone` LIKE 'expansion'|empty|
9189|2022_07_10_character_task_rewarded.sql|SHOW COLUMNS FROM `character_tasks` LIKE 'was_rewarded'|empty|
9190|2022_07_13_task_reward_points.sql|SHOW COLUMNS FROM `tasks` LIKE 'reward_points'|empty|
9191|2022_07_28_gm_state_changes.sql|SHOW COLUMNS FROM `account` LIKE 'invulnerable'|empty|
# Upgrade conditions:
# This won't be needed after this system is implemented, but it is used database that are not

View File

@ -0,0 +1,4 @@
ALTER TABLE `account`
ADD COLUMN `invulnerable` TINYINT(4) NULL DEFAULT '0' AFTER `gmspeed`,
ADD COLUMN `flymode` TINYINT(4) NULL DEFAULT '0' AFTER `invulnerable`,
ADD COLUMN `ignore_tells` TINYINT(4) NULL DEFAULT '0' AFTER `flymode`;

View File

@ -457,27 +457,25 @@ void ZoneServer::HandleMessage(uint16 opcode, const EQ::Net::Packet &p) {
(
cle->TellsOff() &&
(
(
cle->Anon() == 1 &&
scm->fromadmin < cle->Admin()
) ||
scm->fromadmin < AccountStatus::QuestTroupe
scm->fromadmin < cle->Admin()
|| scm->fromadmin < AccountStatus::QuestTroupe
)
)
) {
) {
if (!scm->noreply) {
auto sender = client_list.FindCharacter(scm->from);
if (!sender || !sender->Server()) {
break;
}
scm->noreply = true;
scm->queued = 3; // offline
scm->noreply = true;
scm->queued = 3; // offline
scm->chan_num = ChatChannel_TellEcho;
strcpy(scm->deliverto, scm->from);
sender->Server()->SendPacket(pack);
}
} else if (cle->Online() == CLE_Status::Zoning) {
}
else if (cle->Online() == CLE_Status::Zoning) {
if (!scm->noreply) {
auto sender = client_list.FindCharacter(scm->from);
if (cle->TellQueueFull()) {

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());

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;

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;

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"

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);

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(

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]");
}
}

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()
);
}

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()) {