TrinityCore
Loading...
Searching...
No Matches
cs_bf.cpp
Go to the documentation of this file.
1/*
2 * This file is part of the TrinityCore Project. See AUTHORS file for Copyright information
3 *
4 * This program is free software; you can redistribute it and/or modify it
5 * under the terms of the GNU General Public License as published by the
6 * Free Software Foundation; either version 2 of the License, or (at your
7 * option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
12 * more details.
13 *
14 * You should have received a copy of the GNU General Public License along
15 * with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18/* ScriptData
19Name: bf_commandscript
20%Complete: 100
21Comment: All bf related commands
22Category: commandscripts
23EndScriptData */
24
25#include "ScriptMgr.h"
26#include "BattlefieldMgr.h"
27#include "Chat.h"
28#include "RBAC.h"
29
30using namespace Trinity::ChatCommands;
31
33{
34public:
35 bf_commandscript() : CommandScript("bf_commandscript") { }
36
38 {
39 static ChatCommandTable battlefieldcommandTable =
40 {
46 };
47 static ChatCommandTable commandTable =
48 {
49 { "bf", battlefieldcommandTable },
50 };
51 return commandTable;
52 }
53
54 static bool HandleBattlefieldStart(ChatHandler* handler, uint32 battleId)
55 {
56 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
57
58 if (!bf)
59 return false;
60
61 bf->StartBattle();
62
63 if (battleId == 1)
64 handler->SendGlobalGMSysMessage("Wintergrasp (Command start used)");
65
66 return true;
67 }
68
69 static bool HandleBattlefieldEnd(ChatHandler* handler, uint32 battleId)
70 {
71 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
72
73 if (!bf)
74 return false;
75
76 bf->EndBattle(true);
77
78 if (battleId == 1)
79 handler->SendGlobalGMSysMessage("Wintergrasp (Command stop used)");
80
81 return true;
82 }
83
84 static bool HandleBattlefieldEnable(ChatHandler* handler, uint32 battleId)
85 {
86 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
87
88 if (!bf)
89 return false;
90
91 if (bf->IsEnabled())
92 {
93 bf->ToggleBattlefield(false);
94 if (battleId == 1)
95 handler->SendGlobalGMSysMessage("Wintergrasp is disabled");
96 }
97 else
98 {
99 bf->ToggleBattlefield(true);
100 if (battleId == 1)
101 handler->SendGlobalGMSysMessage("Wintergrasp is enabled");
102 }
103
104 return true;
105 }
106
107 static bool HandleBattlefieldSwitch(ChatHandler* handler, uint32 battleId)
108 {
109 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
110
111 if (!bf)
112 return false;
113
114 bf->EndBattle(false);
115 if (battleId == 1)
116 handler->SendGlobalGMSysMessage("Wintergrasp (Command switch used)");
117
118 return true;
119 }
120
121 static bool HandleBattlefieldTimer(ChatHandler* handler, uint32 battleId, uint32 time)
122 {
123 Battlefield* bf = sBattlefieldMgr->GetBattlefieldByBattleId(battleId);
124
125 if (!bf)
126 return false;
127
128 bf->SetTimer(time * IN_MILLISECONDS);
130 if (battleId == 1)
131 handler->SendGlobalGMSysMessage("Wintergrasp (Command timer used)");
132
133 return true;
134 }
135};
136
138{
139 new bf_commandscript();
140}
#define sBattlefieldMgr
@ IN_MILLISECONDS
Definition Common.h:35
uint32_t uint32
Definition Define.h:133
Role Based Access Control related classes definition.
void SetTimer(uint32 timer)
virtual void SendInitWorldStatesToAll()=0
Send all worldstate data to all player in zone.
void EndBattle(bool endByTimer)
void StartBattle()
void ToggleBattlefield(bool enable)
Enable or Disable battlefield.
bool IsEnabled() const
Return if battlefield is enable.
void SendGlobalGMSysMessage(const char *str)
Definition Chat.cpp:135
static bool HandleBattlefieldEnable(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:84
static bool HandleBattlefieldStart(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:54
ChatCommandTable GetCommands() const override
Definition cs_bf.cpp:37
static bool HandleBattlefieldSwitch(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:107
static bool HandleBattlefieldTimer(ChatHandler *handler, uint32 battleId, uint32 time)
Definition cs_bf.cpp:121
static bool HandleBattlefieldEnd(ChatHandler *handler, uint32 battleId)
Definition cs_bf.cpp:69
void AddSC_bf_commandscript()
Definition cs_bf.cpp:137
std::vector< ChatCommandBuilder > ChatCommandTable
Definition ChatCommand.h:50
@ RBAC_PERM_COMMAND_BF_TIMER
Definition RBAC.h:177
@ RBAC_PERM_COMMAND_BF_ENABLE
Definition RBAC.h:178
@ RBAC_PERM_COMMAND_BF_SWITCH
Definition RBAC.h:176
@ RBAC_PERM_COMMAND_BF_START
Definition RBAC.h:174
@ RBAC_PERM_COMMAND_BF_STOP
Definition RBAC.h:175