mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-20 01:15:35 +01:00
Scripts/Commands: Convert argument parsing of cheat commands to new system (PR #25277)
(cherry picked from commit 4707e05938)
This commit is contained in:
committed by
Shauren
parent
0fcce6ed99
commit
4aa1c74232
@@ -56,103 +56,91 @@ public:
|
||||
return commandTable;
|
||||
}
|
||||
|
||||
static bool HandleGodModeCheatCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleGodModeCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||
{
|
||||
std::string argstr = (char*)args;
|
||||
bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_GOD);
|
||||
if (enableArg)
|
||||
enable = *enableArg;
|
||||
|
||||
if (!*args)
|
||||
argstr = (handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_GOD)) ? "off" : "on";
|
||||
|
||||
if (argstr == "off")
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_GOD);
|
||||
handler->SendSysMessage("Godmode is OFF. You can take damage.");
|
||||
return true;
|
||||
}
|
||||
else if (argstr == "on")
|
||||
if (enable)
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_GOD);
|
||||
handler->SendSysMessage("Godmode is ON. You won't take damage.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_GOD);
|
||||
handler->SendSysMessage("Godmode is OFF. You can take damage.");
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleCasttimeCheatCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleCasttimeCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||
{
|
||||
std::string argstr = (char*)args;
|
||||
bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_CASTTIME);
|
||||
if (enableArg)
|
||||
enable = *enableArg;
|
||||
|
||||
if (!*args)
|
||||
argstr = (handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_CASTTIME)) ? "off" : "on";
|
||||
|
||||
if (argstr == "off")
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_CASTTIME);
|
||||
handler->SendSysMessage("CastTime Cheat is OFF. Your spells will have a casttime.");
|
||||
return true;
|
||||
}
|
||||
else if (argstr == "on")
|
||||
if (enable)
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_CASTTIME);
|
||||
handler->SendSysMessage("CastTime Cheat is ON. Your spells won't have a casttime.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_CASTTIME);
|
||||
handler->SendSysMessage("CastTime Cheat is OFF. Your spells will have a casttime.");
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleCoolDownCheatCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleCoolDownCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||
{
|
||||
std::string argstr = (char*)args;
|
||||
bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_COOLDOWN);
|
||||
if (enableArg)
|
||||
enable = *enableArg;
|
||||
|
||||
if (!*args)
|
||||
argstr = (handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_COOLDOWN)) ? "off" : "on";
|
||||
|
||||
if (argstr == "off")
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_COOLDOWN);
|
||||
handler->SendSysMessage("Cooldown Cheat is OFF. You are on the global cooldown.");
|
||||
return true;
|
||||
}
|
||||
else if (argstr == "on")
|
||||
if (enable)
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_COOLDOWN);
|
||||
handler->SendSysMessage("Cooldown Cheat is ON. You are not on the global cooldown.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_COOLDOWN);
|
||||
handler->SendSysMessage("Cooldown Cheat is OFF. You are on the global cooldown.");
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandlePowerCheatCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandlePowerCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||
{
|
||||
std::string argstr = (char*)args;
|
||||
bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_POWER);
|
||||
if (enableArg)
|
||||
enable = *enableArg;
|
||||
|
||||
if (!*args)
|
||||
argstr = (handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_POWER)) ? "off" : "on";
|
||||
|
||||
if (argstr == "off")
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_POWER);
|
||||
handler->SendSysMessage("Power Cheat is OFF. You need mana/rage/energy to use spells.");
|
||||
return true;
|
||||
}
|
||||
else if (argstr == "on")
|
||||
if (enable)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
// Set max power to all powers
|
||||
for (uint32 i = 0; i < MAX_POWERS; ++i)
|
||||
player->SetPower(Powers(i), player->GetMaxPower(Powers(i)));
|
||||
player->SetFullPower(Powers(i));
|
||||
player->SetCommandStatusOn(CHEAT_POWER);
|
||||
handler->SendSysMessage("Power Cheat is ON. You don't need mana/rage/energy to use spells.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_POWER);
|
||||
handler->SendSysMessage("Power Cheat is OFF. You need mana/rage/energy to use spells.");
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleCheatStatusCommand(ChatHandler* handler, char const* /*args*/)
|
||||
static bool HandleCheatStatusCommand(ChatHandler* handler)
|
||||
{
|
||||
Player* player = handler->GetSession()->GetPlayer();
|
||||
|
||||
@@ -169,36 +157,30 @@ public:
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleWaterWalkCheatCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleWaterWalkCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||
{
|
||||
std::string argstr = (char*)args;
|
||||
bool enable = !handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_WATERWALK);
|
||||
if (enableArg)
|
||||
enable = *enableArg;
|
||||
|
||||
Player* target = handler->GetSession()->GetPlayer();
|
||||
if (!*args)
|
||||
argstr = (target->GetCommandStatus(CHEAT_WATERWALK)) ? "off" : "on";
|
||||
|
||||
if (argstr == "off")
|
||||
if (enable)
|
||||
{
|
||||
target->SetCommandStatusOff(CHEAT_WATERWALK);
|
||||
target->SetWaterWalking(false);
|
||||
handler->SendSysMessage("Waterwalking is OFF. You can't walk on water.");
|
||||
return true;
|
||||
}
|
||||
else if (argstr == "on")
|
||||
{
|
||||
target->SetCommandStatusOn(CHEAT_WATERWALK);
|
||||
target->SetWaterWalking(true);
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_WATERWALK);
|
||||
handler->GetSession()->GetPlayer()->SetWaterWalking(true); // ON
|
||||
handler->SendSysMessage("Waterwalking is ON. You can walk on water.");
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_WATERWALK);
|
||||
handler->GetSession()->GetPlayer()->SetWaterWalking(false); // OFF
|
||||
handler->SendSysMessage("Waterwalking is OFF. You can't walk on water.");
|
||||
}
|
||||
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleTaxiCheatCommand(ChatHandler* handler, char const* args)
|
||||
static bool HandleTaxiCheatCommand(ChatHandler* handler, Optional<bool> enableArg)
|
||||
{
|
||||
|
||||
std::string argstr = (char*)args;
|
||||
Player* chr = handler->getSelectedPlayer();
|
||||
|
||||
if (!chr)
|
||||
@@ -206,41 +188,30 @@ public:
|
||||
else if (handler->HasLowerSecurity(chr, ObjectGuid::Empty)) // check online security
|
||||
return false;
|
||||
|
||||
if (!*args)
|
||||
argstr = (chr->isTaxiCheater()) ? "off" : "on";
|
||||
bool enable = !chr->isTaxiCheater();
|
||||
if (enableArg)
|
||||
enable = *enableArg;
|
||||
|
||||
|
||||
if (argstr == "off")
|
||||
|
||||
{
|
||||
chr->SetTaxiCheater(false);
|
||||
handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str());
|
||||
if (handler->needReportToTarget(chr))
|
||||
ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str());
|
||||
return true;
|
||||
}
|
||||
else if (argstr == "on")
|
||||
if (enable)
|
||||
{
|
||||
chr->SetTaxiCheater(true);
|
||||
handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str());
|
||||
if (handler->needReportToTarget(chr))
|
||||
ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str());
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
chr->SetTaxiCheater(false);
|
||||
handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str());
|
||||
if (handler->needReportToTarget(chr))
|
||||
ChatHandler(chr->GetSession()).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str());
|
||||
}
|
||||
|
||||
|
||||
handler->SendSysMessage(LANG_USE_BOL);
|
||||
handler->SetSentErrorMessage(true);
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool HandleExploreCheatCommand(ChatHandler* handler, const char *args)
|
||||
static bool HandleExploreCheatCommand(ChatHandler* handler, bool reveal)
|
||||
{
|
||||
if (!*args)
|
||||
return false;
|
||||
|
||||
int flag = atoi((char*)args);
|
||||
|
||||
Player* chr = handler->getSelectedPlayer();
|
||||
if (!chr)
|
||||
{
|
||||
@@ -249,7 +220,7 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flag != 0)
|
||||
if (reveal)
|
||||
{
|
||||
handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(chr).c_str());
|
||||
if (handler->needReportToTarget(chr))
|
||||
@@ -264,7 +235,7 @@ public:
|
||||
|
||||
for (uint16 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
|
||||
{
|
||||
if (flag != 0)
|
||||
if (reveal)
|
||||
handler->GetSession()->GetPlayer()->AddExploredZones(i, 0xFFFFFFFFFFFFFFFF);
|
||||
else
|
||||
handler->GetSession()->GetPlayer()->RemoveExploredZones(i, 0xFFFFFFFFFFFFFFFF);
|
||||
|
||||
Reference in New Issue
Block a user