feat(Core/Commands): Deserter command (BG/Instance) (#1786)
* feat(Core/Commands): Deserter command (BG/Instance) - Adding .deserter command - Subcommands ; * instance add * instance remove * bg add * bg remove Time is in seconds, example usage: .deserter instance add 3600 (One hour) .deserter bg add 3600 (One hour) * Update cs_deserter.cpp * Update cs_deserter.cpp another try * Update cs_deserter.cpp again * Update cs_deserter.cpp sick of this * Update cs_deserter.cpp * Update cs_deserter.cpp Remove some lines
This commit is contained in:
@@ -0,0 +1,13 @@
|
|||||||
|
INSERT INTO `version_db_world` (`sql_rev`) VALUES ('1556618006402506300');
|
||||||
|
|
||||||
|
DELETE FROM `command` WHERE `name` IN
|
||||||
|
("deserter instance add",
|
||||||
|
"deserter instance remove",
|
||||||
|
"deserter bg add",
|
||||||
|
"deserter bg remove");
|
||||||
|
|
||||||
|
INSERT INTO `command` (`name`, `security`, `help`) VALUES
|
||||||
|
("deserter instance add", 3, "Syntax: .deserter instance add $time \n\n Adds the instance deserter debuff to your target with $time duration."),
|
||||||
|
("deserter instance remove", 3, "Syntax: .deserter instance remove \n\n Removes the instance deserter debuff from your target."),
|
||||||
|
("deserter bg add", 3, "Syntax: .deserter bg add $time \n\n Adds the bg deserter debuff to your target with $time duration."),
|
||||||
|
("deserter bg remove", 3, "Syntax: .deserter bg remove \n\n Removes the bg deserter debuff from your target.");
|
||||||
@@ -18,6 +18,7 @@ set(scripts_STAT_SRCS
|
|||||||
Commands/cs_character.cpp
|
Commands/cs_character.cpp
|
||||||
Commands/cs_cheat.cpp
|
Commands/cs_cheat.cpp
|
||||||
Commands/cs_debug.cpp
|
Commands/cs_debug.cpp
|
||||||
|
Commands/cs_deserter.cpp
|
||||||
Commands/cs_disable.cpp
|
Commands/cs_disable.cpp
|
||||||
Commands/cs_event.cpp
|
Commands/cs_event.cpp
|
||||||
Commands/cs_gm.cpp
|
Commands/cs_gm.cpp
|
||||||
|
|||||||
@@ -0,0 +1,133 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU GPL v2 license: https://github.com/azerothcore/azerothcore-wotlk/blob/master/LICENSE-GPL2
|
||||||
|
* Copyright (C) 2008-2016 TrinityCore <http://www.trinitycore.org/>
|
||||||
|
* Copyright (C) 2005-2009 MaNGOS <http://getmangos.com/>
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "Chat.h"
|
||||||
|
#include "Player.h"
|
||||||
|
#include "Language.h"
|
||||||
|
#include "ScriptMgr.h"
|
||||||
|
#include "SpellAuras.h"
|
||||||
|
#include "SpellAuraEffects.h"
|
||||||
|
|
||||||
|
enum Spells
|
||||||
|
{
|
||||||
|
LFG_SPELL_DUNGEON_DESERTER = 71041,
|
||||||
|
BG_SPELL_DESERTER = 26013
|
||||||
|
};
|
||||||
|
|
||||||
|
class deserter_commandscript : public CommandScript
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
deserter_commandscript() : CommandScript("deserter_commandscript") { }
|
||||||
|
|
||||||
|
std::vector<ChatCommand> GetCommands() const override
|
||||||
|
{
|
||||||
|
static std::vector<ChatCommand> deserterinstanceCommandTable =
|
||||||
|
{
|
||||||
|
{ "add", SEC_ADMINISTRATOR, false, &HandleDeserterInstanceAdd, "" },
|
||||||
|
{ "remove", SEC_ADMINISTRATOR, false, &HandleDeserterInstanceRemove, "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::vector<ChatCommand> deserterBGCommandTable =
|
||||||
|
{
|
||||||
|
{ "add", SEC_ADMINISTRATOR, false, &HandleDeserterBGAdd, "" },
|
||||||
|
{ "remove", SEC_ADMINISTRATOR, false, &HandleDeserterBGRemove, "" }
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::vector<ChatCommand> deserterCommandTable =
|
||||||
|
{
|
||||||
|
{ "instance", SEC_ADMINISTRATOR, false, nullptr, "", deserterinstanceCommandTable },
|
||||||
|
{ "bg", SEC_ADMINISTRATOR, false, nullptr, "", deserterBGCommandTable }
|
||||||
|
};
|
||||||
|
|
||||||
|
static std::vector<ChatCommand> commandTable =
|
||||||
|
{
|
||||||
|
{ "deserter", SEC_ADMINISTRATOR, false, nullptr, "", deserterCommandTable }
|
||||||
|
};
|
||||||
|
|
||||||
|
return commandTable;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleDeserterAdd(ChatHandler* handler, char const* args, bool isInstance)
|
||||||
|
{
|
||||||
|
if (!*args)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
Player* targetPlayer = handler->getSelectedPlayer();
|
||||||
|
if (!targetPlayer)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
char* timeStr = strtok((char*)args, " ");
|
||||||
|
if (!timeStr)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
uint32 time = atoi(timeStr);
|
||||||
|
|
||||||
|
if (!time)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Aura* aura = targetPlayer->AddAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER, targetPlayer);
|
||||||
|
|
||||||
|
if (!aura)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_BAD_VALUE);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
aura->SetDuration(time * IN_MILLISECONDS);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleDeserterRemove(ChatHandler* handler, char const* /*args*/, bool isInstance)
|
||||||
|
{
|
||||||
|
Player* targetPlayer = handler->getSelectedPlayer();
|
||||||
|
if (!targetPlayer)
|
||||||
|
{
|
||||||
|
handler->SendSysMessage(LANG_NO_CHAR_SELECTED);
|
||||||
|
handler->SetSentErrorMessage(true);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
targetPlayer->RemoveAura(isInstance ? LFG_SPELL_DUNGEON_DESERTER : BG_SPELL_DESERTER);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleDeserterInstanceAdd(ChatHandler* handler, char const* args)
|
||||||
|
{
|
||||||
|
return HandleDeserterAdd(handler, args, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleDeserterBGAdd(ChatHandler* handler, char const* args)
|
||||||
|
{
|
||||||
|
return HandleDeserterAdd(handler, args, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleDeserterInstanceRemove(ChatHandler* handler, char const* args)
|
||||||
|
{
|
||||||
|
return HandleDeserterRemove(handler, args, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool HandleDeserterBGRemove(ChatHandler* handler, char const* args)
|
||||||
|
{
|
||||||
|
return HandleDeserterRemove(handler, args, false);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
void AddSC_deserter_commandscript()
|
||||||
|
{
|
||||||
|
new deserter_commandscript();
|
||||||
|
}
|
||||||
@@ -34,6 +34,7 @@ void AddSC_cast_commandscript();
|
|||||||
void AddSC_character_commandscript();
|
void AddSC_character_commandscript();
|
||||||
void AddSC_cheat_commandscript();
|
void AddSC_cheat_commandscript();
|
||||||
void AddSC_debug_commandscript();
|
void AddSC_debug_commandscript();
|
||||||
|
void AddSC_deserter_commandscript();
|
||||||
void AddSC_disable_commandscript();
|
void AddSC_disable_commandscript();
|
||||||
void AddSC_event_commandscript();
|
void AddSC_event_commandscript();
|
||||||
void AddSC_gm_commandscript();
|
void AddSC_gm_commandscript();
|
||||||
@@ -611,6 +612,7 @@ void AddCommandScripts()
|
|||||||
AddSC_character_commandscript();
|
AddSC_character_commandscript();
|
||||||
AddSC_cheat_commandscript();
|
AddSC_cheat_commandscript();
|
||||||
AddSC_debug_commandscript();
|
AddSC_debug_commandscript();
|
||||||
|
AddSC_deserter_commandscript();
|
||||||
AddSC_disable_commandscript();
|
AddSC_disable_commandscript();
|
||||||
AddSC_event_commandscript();
|
AddSC_event_commandscript();
|
||||||
AddSC_gm_commandscript();
|
AddSC_gm_commandscript();
|
||||||
|
|||||||
Reference in New Issue
Block a user