Project SkyFire Core
SkyFire 5.4.8 server core API documentation
Toggle main menu visibility
Loading...
Searching...
No Matches
cs_honor.cpp
Go to the documentation of this file.
1
/*
2
* This file is part of Project SkyFire https://www.projectskyfire.org.
3
* See LICENSE.md file for Copyright information
4
*/
5
6
/* ScriptData
7
Name: honor_commandscript
8
%Complete: 100
9
Comment: All honor related commands
10
Category: commandscripts
11
EndScriptData */
12
13
#include "
Chat.h
"
14
#include "
Language.h
"
15
#include "
ObjectMgr.h
"
16
#include "
Player.h
"
17
#include "
ScriptMgr.h
"
18
19
class
honor_commandscript
:
public
CommandScript
20
{
21
public
:
22
honor_commandscript
() :
CommandScript
(
"honor_commandscript"
) { }
23
24
std::vector<ChatCommand>
GetCommands
() const
OVERRIDE
25
{
26
static
std::vector<ChatCommand> honorAddCommandTable =
27
{
28
{
"kill"
,
rbac::RBAC_PERM_COMMAND_HONOR_ADD_KILL
,
false
, &
HandleHonorAddKillCommand
,
""
, },
29
{
""
,
rbac::RBAC_PERM_COMMAND_HONOR_ADD
,
false
, &
HandleHonorAddCommand
,
""
, },
30
};
31
32
static
std::vector<ChatCommand> honorCommandTable =
33
{
34
{
"add"
,
rbac::RBAC_PERM_COMMAND_HONOR_ADD
,
false
, NULL,
""
, honorAddCommandTable },
35
{
"update"
,
rbac::RBAC_PERM_COMMAND_HONOR_UPDATE
,
false
, &
HandleHonorUpdateCommand
,
""
, },
36
};
37
38
static
std::vector<ChatCommand> commandTable =
39
{
40
{
"honor"
,
rbac::RBAC_PERM_COMMAND_HONOR
,
false
, NULL,
""
, honorCommandTable },
41
};
42
return
commandTable;
43
}
44
45
static
bool
HandleHonorAddCommand
(
ChatHandler
* handler,
char
const
* args)
46
{
47
if
(!*args)
48
return
false
;
49
50
Player
* target = handler->
getSelectedPlayer
();
51
if
(!target)
52
{
53
handler->
SendSysMessage
(
LANG_PLAYER_NOT_FOUND
);
54
handler->
SetSentErrorMessage
(
true
);
55
return
false
;
56
}
57
58
// check online security
59
if
(handler->
HasLowerSecurity
(target, 0))
60
return
false
;
61
62
uint32
amount = (
uint32
)atoi(args);
63
target->
RewardHonor
(NULL, 1, amount);
64
return
true
;
65
}
66
67
static
bool
HandleHonorAddKillCommand
(
ChatHandler
* handler,
char
const
*
/*args*/
)
68
{
69
Unit
* target = handler->
getSelectedUnit
();
70
if
(!target)
71
{
72
handler->
SendSysMessage
(
LANG_PLAYER_NOT_FOUND
);
73
handler->
SetSentErrorMessage
(
true
);
74
return
false
;
75
}
76
77
// check online security
78
if
(
Player
* player = target->
ToPlayer
())
79
if
(handler->
HasLowerSecurity
(player, 0))
80
return
false
;
81
82
handler->
GetSession
()->
GetPlayer
()->
RewardHonor
(target, 1);
83
return
true
;
84
}
85
86
static
bool
HandleHonorUpdateCommand
(
ChatHandler
* handler,
char
const
*
/*args*/
)
87
{
88
Player
* target = handler->
getSelectedPlayer
();
89
if
(!target)
90
{
91
handler->
SendSysMessage
(
LANG_PLAYER_NOT_FOUND
);
92
handler->
SetSentErrorMessage
(
true
);
93
return
false
;
94
}
95
96
// check online security
97
if
(handler->
HasLowerSecurity
(target, 0))
98
return
false
;
99
100
target->
UpdateHonorFields
();
101
return
true
;
102
}
103
};
104
105
void
AddSC_honor_commandscript
()
106
{
107
new
honor_commandscript
();
108
}
Chat.h
uint32
std::uint32_t uint32
Definition
Define.h:77
OVERRIDE
#define OVERRIDE
Definition
Define.h:60
Language.h
LANG_PLAYER_NOT_FOUND
@ LANG_PLAYER_NOT_FOUND
Definition
Language.h:487
ObjectMgr.h
Player.h
ScriptMgr.h
ChatHandler
Definition
Chat.h:41
ChatHandler::HasLowerSecurity
bool HasLowerSecurity(Player *target, uint64 guid, bool strong=false)
Definition
Chat.cpp:78
ChatHandler::getSelectedUnit
Unit * getSelectedUnit()
Definition
Chat.cpp:841
ChatHandler::getSelectedPlayer
Player * getSelectedPlayer()
Definition
Chat.cpp:829
ChatHandler::GetSession
WorldSession * GetSession()
Definition
Chat.h:43
ChatHandler::SetSentErrorMessage
void SetSentErrorMessage(bool val)
Definition
Chat.h:114
ChatHandler::SendSysMessage
virtual void SendSysMessage(const char *str)
Definition
Chat.cpp:153
CommandScript::CommandScript
CommandScript(const char *name)
Definition
ScriptMgr.cpp:1466
Object::ToPlayer
Player * ToPlayer()
Definition
Object.h:204
Player
Definition
Player.h:1289
Player::RewardHonor
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool pvptoken=false)
Definition
Player.cpp:7316
Player::UpdateHonorFields
void UpdateHonorFields()
Definition
Player.cpp:7285
Unit
Definition
Unit.h:1367
WorldSession::GetPlayer
Player * GetPlayer() const
Definition
WorldSession.h:295
honor_commandscript
Definition
cs_honor.cpp:20
honor_commandscript::HandleHonorAddCommand
static bool HandleHonorAddCommand(ChatHandler *handler, char const *args)
Definition
cs_honor.cpp:45
honor_commandscript::honor_commandscript
honor_commandscript()
Definition
cs_honor.cpp:22
honor_commandscript::GetCommands
std::vector< ChatCommand > GetCommands() const OVERRIDE
Definition
cs_honor.cpp:24
honor_commandscript::HandleHonorAddKillCommand
static bool HandleHonorAddKillCommand(ChatHandler *handler, char const *)
Definition
cs_honor.cpp:67
honor_commandscript::HandleHonorUpdateCommand
static bool HandleHonorUpdateCommand(ChatHandler *handler, char const *)
Definition
cs_honor.cpp:86
AddSC_honor_commandscript
void AddSC_honor_commandscript()
Definition
cs_honor.cpp:105
rbac::RBAC_PERM_COMMAND_HONOR_UPDATE
@ RBAC_PERM_COMMAND_HONOR_UPDATE
Definition
RBAC.h:299
rbac::RBAC_PERM_COMMAND_HONOR
@ RBAC_PERM_COMMAND_HONOR
Definition
RBAC.h:296
rbac::RBAC_PERM_COMMAND_HONOR_ADD
@ RBAC_PERM_COMMAND_HONOR_ADD
Definition
RBAC.h:297
rbac::RBAC_PERM_COMMAND_HONOR_ADD_KILL
@ RBAC_PERM_COMMAND_HONOR_ADD_KILL
Definition
RBAC.h:298
src
server
scripts
Commands
cs_honor.cpp
Generated on
for Project SkyFire Core by
1.17.0