Scripts/Commands: Create a new group of commands, .cheat, and add new and move old commands to it:

Changes:
- .explorecheat is now .cheat explore
- .waterwalk is now .cheat waterwalk
- .taxicheat is now .cheat taxi

New commands:
- .cheat god
- .cheat casttime
- .cheat cooldown
- .cheat power

(Descriptions available in the SQL file / in-game)

Inspiration on ArcEmu commands
Closes #7569
This commit is contained in:
Myran2
2012-08-31 14:48:02 -05:00
committed by Subv
parent a5d977c90e
commit db7b750e0c
8 changed files with 340 additions and 118 deletions
@@ -0,0 +1,14 @@
DELETE FROM `command` WHERE `name`='explorecheat';
DELETE FROM `command` WHERE `name`='taxicheat';
DELETE FROM `command` WHERE `name`='waterwalk';
DELETE FROM `command` WHERE `name`='cheat' OR `name` LIKE 'cheat%';
INSERT INTO `command` (`name`, `security`, `help`) VALUES
('cheat', 2, 'Syntax: .cheat $subcommand\r\nType .cheat to see the list of possible subcommands or .help cheat $subcommand to see info on subcommands'),
('cheat god', 2, 'Syntax: .cheat god [on/off]\r\nEnables or disables your character''s ability to take damage.'),
('cheat casttime', 2, 'Syntax: .cheat casttime [on/off]\r\nEnables or disables your character''s spell cast times.'),
('cheat cooldown', 2, 'Syntax: .cheat cooldown [on/off]\r\nEnables or disables your character''s spell cooldowns.'),
('cheat power', 2, 'Syntax: .cheat power [on/off]\r\nEnables or disables your character''s spell cost (e.g mana).'),
('cheat waterwalk', 2, 'Syntax: .cheat waterwalk on/off\r\nSet on/off waterwalk state for selected player or self if no player selected.'),
('cheat explore', 2, 'Syntax: .cheat explore #flag\r\nReveal or hide all maps for the selected player. If no player is selected, hide or reveal maps to you.\r\nUse a #flag of value 1 to reveal, use a #flag value of 0 to hide all maps.'),
('cheat taxi', 2, 'Syntax: .cheat taxi on/off\r\nTemporary grant access or remove to all taxi routes for the selected character.\r\n If no character is selected, hide or reveal all routes to you.Visited taxi nodes sill accessible after removing access.');
@@ -861,6 +861,8 @@ Player::Player(WorldSession* session): Unit(true), m_achievementMgr(this), m_rep
m_SeasonalQuestChanged = false;
SetPendingBind(0, 0);
_activeCheats = CHEAT_NONE;
}
Player::~Player()
+17
View File
@@ -896,6 +896,16 @@ enum PlayerRestState
REST_STATE_RAF_LINKED = 0x06
};
enum PlayerCommandStates
{
CHEAT_NONE = 0x00,
CHEAT_GOD = 0x01,
CHEAT_CASTTIME = 0x02,
CHEAT_COOLDOWN = 0x04,
CHEAT_POWER = 0x08,
CHEAT_WATERWALK = 0x10
};
class PlayerTaxi
{
public:
@@ -1148,6 +1158,11 @@ class Player : public Unit, public GridObject<Player>
void InitStatsForLevel(bool reapplyMods = false);
// .cheat command related
bool GetCommandStatus(uint32 command) const { return _activeCheats & command; }
void SetCommandStatusOn(uint32 command) { _activeCheats |= command; }
void SetCommandStatusOff(uint32 command) { _activeCheats &= ~command; }
// Played Time Stuff
time_t m_logintime;
time_t m_Last_tick;
@@ -2854,6 +2869,8 @@ class Player : public Unit, public GridObject<Player>
InstanceTimeMap _instanceResetTimes;
uint32 _pendingBindId;
uint32 _pendingBindTimer;
uint32 _activeCheats;
};
void AddItemsSetItem(Player*player, Item* item);
@@ -50,6 +50,7 @@ void AddSC_ban_commandscript();
void AddSC_bf_commandscript();
void AddSC_cast_commandscript();
void AddSC_character_commandscript();
void AddSC_cheat_commandscript();
void AddSC_debug_commandscript();
void AddSC_disable_commandscript();
void AddSC_event_commandscript();
@@ -666,6 +667,7 @@ void AddCommandScripts()
AddSC_bf_commandscript();
AddSC_cast_commandscript();
AddSC_character_commandscript();
AddSC_cheat_commandscript();
AddSC_debug_commandscript();
AddSC_disable_commandscript();
AddSC_event_commandscript();
+23
View File
@@ -3023,7 +3023,13 @@ void Spell::prepare(SpellCastTargets const* targets, AuraEffect const* triggered
// calculate cast time (calculated after first CheckCast check to prevent charge counting for first CheckCast fail)
m_casttime = m_spellInfo->CalcCastTime(m_caster, this);
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
// Set casttime to 0 if .cheat casttime is enabled.
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_CASTTIME))
m_casttime = 0;
}
// don't allow channeled spells / spells with cast time to be casted while moving
// (even if they are interrupted on moving, spells with almost immediate effect get to have their effect processed before movement interrupter kicks in)
@@ -3315,7 +3321,13 @@ void Spell::cast(bool skipCheck)
}
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
m_caster->ToPlayer()->SetSpellModTakingSpell(this, false);
//Clear spell cooldowns after every spell is cast if .cheat cooldown is enabled.
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
m_caster->ToPlayer()->RemoveSpellCooldown(m_spellInfo->Id, true);
}
SetExecutedCurrently(false);
}
@@ -4358,6 +4370,13 @@ void Spell::TakePower()
if (m_CastItem || m_triggeredByAuraSpell)
return;
//Don't take power if the spell is cast while .cheat power is enabled.
if (m_caster->GetTypeId() == TYPEID_PLAYER)
{
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_POWER))
return;
}
Powers powerType = Powers(m_spellInfo->PowerType);
bool hit = true;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
@@ -7193,6 +7212,10 @@ void Spell::TriggerGlobalCooldown()
if (!gcd)
return;
if (m_caster->GetTypeId() == TYPEID_PLAYER)
if (m_caster->ToPlayer()->GetCommandStatus(CHEAT_COOLDOWN))
return;
// Global cooldown can't leave range 1..1.5 secs
// There are some spells (mostly not casted directly by player) that have < 1 sec and > 1.5 sec global cooldowns
// but as tests show are not affected by any spell mods.
@@ -16,6 +16,7 @@ set(scripts_STAT_SRCS
Commands/cs_bf.cpp
Commands/cs_cast.cpp
Commands/cs_character.cpp
Commands/cs_cheat.cpp
Commands/cs_debug.cpp
Commands/cs_disable.cpp
Commands/cs_event.cpp
+281
View File
@@ -0,0 +1,281 @@
/*
* Copyright (C) 2008-2012 TrinityCore <http://www.trinitycore.org/>
*
* This program is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License as published by the
* Free Software Foundation; either version 2 of the License, or (at your
* option) any later version.
*
* This program is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
* more details.
*
* You should have received a copy of the GNU General Public License along
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
/* ScriptData
Name: cheat_commandscript
%Complete: 100
Comment: All cheat related commands
Category: commandscripts
EndScriptData */
#include "ScriptMgr.h"
#include "ObjectMgr.h"
#include "Chat.h"
class cheat_commandscript : public CommandScript
{
public:
cheat_commandscript() : CommandScript("cheat_commandscript") { }
ChatCommand* GetCommands() const
{
static ChatCommand cheatCommandTable[] =
{
{ "god", SEC_GAMEMASTER, false, &HandleGodModeCheatCommand, "", NULL },
{ "casttime", SEC_GAMEMASTER, false, &HandleCasttimeCheatCommand, "", NULL },
{ "cooldown", SEC_GAMEMASTER, false, &HandleCoolDownCheatCommand, "", NULL },
{ "power", SEC_GAMEMASTER, false, &HandlePowerCheatCommand, "", NULL },
{ "waterwalk", SEC_GAMEMASTER, false, &HandleWaterWalkCheatCommand, "", NULL },
{ "taxi", SEC_GAMEMASTER, false, &HandleTaxiCheatCommand, "", NULL },
{ "explore", SEC_GAMEMASTER, false, &HandleExploreCheatCommand, "", NULL },
{ NULL, 0, false, NULL, "", NULL }
};
static ChatCommand commandTable[] =
{
{ "cheat", SEC_GAMEMASTER, false, NULL, "", cheatCommandTable },
{ NULL, 0, false, NULL, "", NULL }
};
return commandTable;
}
static bool HandleGodModeCheatCommand(ChatHandler* handler, const char* args)
{
if (!handler->GetSession() && !handler->GetSession()->GetPlayer())
return false;
std::string argstr = (char*)args;
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")
{
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_GOD);
handler->SendSysMessage("Godmode is ON. You won't take damage.");
return true;
}
return false;
}
static bool HandleCasttimeCheatCommand(ChatHandler* handler, const char* args)
{
if (!handler->GetSession() && !handler->GetSession()->GetPlayer())
return false;
std::string argstr = (char*)args;
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")
{
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_CASTTIME);
handler->SendSysMessage("CastTime Cheat is ON. Your spells won't have a casttime.");
return true;
}
return false;
}
static bool HandleCoolDownCheatCommand(ChatHandler* handler, const char* args)
{
if (!handler->GetSession() && !handler->GetSession()->GetPlayer())
return false;
std::string argstr = (char*)args;
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")
{
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_COOLDOWN);
handler->SendSysMessage("Cooldown Cheat is ON. You are not on the global cooldown.");
return true;
}
return false;
}
static bool HandlePowerCheatCommand(ChatHandler* handler, const char* args)
{
if (!handler->GetSession() && !handler->GetSession()->GetPlayer())
return false;
std::string argstr = (char*)args;
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")
{
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_POWER);
handler->SendSysMessage("Power Cheat is ON. You don't need mana/rage/energy to use spells.");
return true;
}
return false;
}
static bool HandleWaterWalkCheatCommand(ChatHandler* handler, const char* args)
{
if (!handler->GetSession() && !handler->GetSession()->GetPlayer())
return false;
std::string argstr = (char*)args;
if (!*args)
{
argstr = (handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_WATERWALK)) ? "off" : "on";
if (handler->GetSession()->GetPlayer()->GetCommandStatus(CHEAT_WATERWALK))
argstr = "off";
else
argstr = "on";
}
if (argstr == "off")
{
handler->GetSession()->GetPlayer()->SetCommandStatusOff(CHEAT_WATERWALK);
handler->GetSession()->GetPlayer()->SetMovement(MOVE_LAND_WALK); // OFF
handler->SendSysMessage("Waterwalking is OFF. You can't walk on water.");
return true;
}
else if (argstr == "on")
{
handler->GetSession()->GetPlayer()->SetCommandStatusOn(CHEAT_WATERWALK);
handler->GetSession()->GetPlayer()->SetMovement(MOVE_WATER_WALK); // ON
handler->SendSysMessage("Waterwalking is ON. You can walk on water.");
return true;
}
return false;
}
static bool HandleTaxiCheatCommand(ChatHandler* handler, const char* args)
{
if (!*args)
{
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
std::string argstr = (char*)args;
Player* chr = handler->getSelectedPlayer();
if (!chr)
chr = handler->GetSession()->GetPlayer();
else if (handler->HasLowerSecurity(chr, 0)) // check online security
return false;
if (argstr == "on")
{
chr->SetTaxiCheater(true);
handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str());
if (handler->needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str());
return true;
}
if (argstr == "off")
{
chr->SetTaxiCheater(false);
handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str());
if (handler->needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str());
return true;
}
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
static bool HandleExploreCheatCommand(ChatHandler* handler, const char *args)
{
if (!*args)
return false;
int flag = atoi((char*)args);
Player* chr = handler->getSelectedPlayer();
if (chr == NULL)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
if (flag != 0)
{
handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(chr).c_str());
if (handler->needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink().c_str());
}
else
{
handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(chr).c_str());
if (handler->needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink().c_str());
}
for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
{
if (flag != 0)
handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0xFFFFFFFF);
else
handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0);
}
return true;
}
};
void AddSC_cheat_commandscript()
{
new cheat_commandscript();
}
-118
View File
@@ -82,10 +82,8 @@ public:
{ "saveall", SEC_MODERATOR, true, &HandleSaveAllCommand, "", NULL },
{ "kick", SEC_GAMEMASTER, true, &HandleKickPlayerCommand, "", NULL },
{ "start", SEC_PLAYER, false, &HandleStartCommand, "", NULL },
{ "taxicheat", SEC_MODERATOR, false, &HandleTaxiCheatCommand, "", NULL },
{ "linkgrave", SEC_ADMINISTRATOR, false, &HandleLinkGraveCommand, "", NULL },
{ "neargrave", SEC_ADMINISTRATOR, false, &HandleNearGraveCommand, "", NULL },
{ "explorecheat", SEC_ADMINISTRATOR, false, &HandleExploreCheatCommand, "", NULL },
{ "showarea", SEC_ADMINISTRATOR, false, &HandleShowAreaCommand, "", NULL },
{ "hidearea", SEC_ADMINISTRATOR, false, &HandleHideAreaCommand, "", NULL },
{ "additem", SEC_ADMINISTRATOR, false, &HandleAddItemCommand, "", NULL },
@@ -106,7 +104,6 @@ public:
{ "combatstop", SEC_GAMEMASTER, true, &HandleCombatStopCommand, "", NULL },
{ "flusharenapoints", SEC_ADMINISTRATOR, false, &HandleFlushArenaPointsCommand, "", NULL },
{ "repairitems", SEC_GAMEMASTER, true, &HandleRepairitemsCommand, "", NULL },
{ "waterwalk", SEC_GAMEMASTER, false, &HandleWaterwalkCommand, "", NULL },
{ "freeze", SEC_MODERATOR, false, &HandleFreezeCommand, "", NULL },
{ "unfreeze", SEC_MODERATOR, false, &HandleUnFreezeCommand, "", NULL },
{ "listfreeze", SEC_MODERATOR, false, &HandleListFreezeCommand, "", NULL },
@@ -960,49 +957,6 @@ public:
player->CastSpell(player, 7355, false);
return true;
}
// Enable on\off all taxi paths
static bool HandleTaxiCheatCommand(ChatHandler* handler, char const* args)
{
if (!*args)
{
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
std::string argStr = (char*)args;
Player* chr = handler->getSelectedPlayer();
if (!chr)
chr = handler->GetSession()->GetPlayer();
else if (handler->HasLowerSecurity(chr, 0)) // check online security
return false;
if (argStr == "on")
{
chr->SetTaxiCheater(true);
handler->PSendSysMessage(LANG_YOU_GIVE_TAXIS, handler->GetNameLink(chr).c_str());
if (handler->needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_ADDED, handler->GetNameLink().c_str());
return true;
}
if (argStr == "off")
{
chr->SetTaxiCheater(false);
handler->PSendSysMessage(LANG_YOU_REMOVE_TAXIS, handler->GetNameLink(chr).c_str());
if (handler->needReportToTarget(chr))
ChatHandler(chr).PSendSysMessage(LANG_YOURS_TAXIS_REMOVED, handler->GetNameLink().c_str());
return true;
}
handler->SendSysMessage(LANG_USE_BOL);
handler->SetSentErrorMessage(true);
return false;
}
static bool HandleLinkGraveCommand(ChatHandler* handler, char const* args)
{
@@ -1123,45 +1077,6 @@ public:
return true;
}
static bool HandleExploreCheatCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
int32 flag = int32(atoi((char*)args));
Player* playerTarget = handler->getSelectedPlayer();
if (!playerTarget)
{
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
if (flag != 0)
{
handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_ALL, handler->GetNameLink(playerTarget).c_str());
if (handler->needReportToTarget(playerTarget))
ChatHandler(playerTarget).PSendSysMessage(LANG_YOURS_EXPLORE_SET_ALL, handler->GetNameLink().c_str());
}
else
{
handler->PSendSysMessage(LANG_YOU_SET_EXPLORE_NOTHING, handler->GetNameLink(playerTarget).c_str());
if (handler->needReportToTarget(playerTarget))
ChatHandler(playerTarget).PSendSysMessage(LANG_YOURS_EXPLORE_SET_NOTHING, handler->GetNameLink().c_str());
}
for (uint8 i = 0; i < PLAYER_EXPLORED_ZONES_SIZE; ++i)
{
if (flag != 0)
handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0xFFFFFFFF);
else
handler->GetSession()->GetPlayer()->SetFlag(PLAYER_EXPLORED_ZONES_1+i, 0);
}
return true;
}
static bool HandleShowAreaCommand(ChatHandler* handler, char const* args)
{
if (!*args)
@@ -2194,39 +2109,6 @@ public:
return true;
}
static bool HandleWaterwalkCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
Player* player = handler->getSelectedPlayer();
if (!player)
{
handler->PSendSysMessage(LANG_NO_CHAR_SELECTED);
handler->SetSentErrorMessage(true);
return false;
}
// check online security
if (handler->HasLowerSecurity(player, 0))
return false;
if (strncmp(args, "on", 3) == 0)
player->SetMovement(MOVE_WATER_WALK); // ON
else if (strncmp(args, "off", 4) == 0)
player->SetMovement(MOVE_LAND_WALK); // OFF
else
{
handler->SendSysMessage(LANG_USE_BOL);
return false;
}
handler->PSendSysMessage(LANG_YOU_SET_WATERWALK, args, handler->GetNameLink(player).c_str());
if (handler->needReportToTarget(player))
ChatHandler(player).PSendSysMessage(LANG_YOUR_WATERWALK_SET, args, handler->GetNameLink().c_str());
return true;
}
// Send mail by command
static bool HandleSendMailCommand(ChatHandler* handler, char const* args)
{