Project SkyFire Core
SkyFire 5.4.8 server core API documentation
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
7Name: honor_commandscript
8%Complete: 100
9Comment: All honor related commands
10Category: commandscripts
11EndScriptData */
12
13#include "Chat.h"
14#include "Language.h"
15#include "ObjectMgr.h"
16#include "Player.h"
17#include "ScriptMgr.h"
18
20{
21public:
22 honor_commandscript() : CommandScript("honor_commandscript") { }
23
24 std::vector<ChatCommand> GetCommands() const OVERRIDE
25 {
26 static std::vector<ChatCommand> honorAddCommandTable =
27 {
30 };
31
32 static std::vector<ChatCommand> honorCommandTable =
33 {
34 { "add", rbac::RBAC_PERM_COMMAND_HONOR_ADD, false, NULL, "", honorAddCommandTable },
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 {
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 {
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 {
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
std::uint32_t uint32
Definition Define.h:77
#define OVERRIDE
Definition Define.h:60
@ LANG_PLAYER_NOT_FOUND
Definition Language.h:487
bool HasLowerSecurity(Player *target, uint64 guid, bool strong=false)
Definition Chat.cpp:78
Unit * getSelectedUnit()
Definition Chat.cpp:841
Player * getSelectedPlayer()
Definition Chat.cpp:829
WorldSession * GetSession()
Definition Chat.h:43
void SetSentErrorMessage(bool val)
Definition Chat.h:114
virtual void SendSysMessage(const char *str)
Definition Chat.cpp:153
CommandScript(const char *name)
Player * ToPlayer()
Definition Object.h:204
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool pvptoken=false)
Definition Player.cpp:7316
void UpdateHonorFields()
Definition Player.cpp:7285
Definition Unit.h:1367
Player * GetPlayer() const
static bool HandleHonorAddCommand(ChatHandler *handler, char const *args)
Definition cs_honor.cpp:45
std::vector< ChatCommand > GetCommands() const OVERRIDE
Definition cs_honor.cpp:24
static bool HandleHonorAddKillCommand(ChatHandler *handler, char const *)
Definition cs_honor.cpp:67
static bool HandleHonorUpdateCommand(ChatHandler *handler, char const *)
Definition cs_honor.cpp:86
void AddSC_honor_commandscript()
Definition cs_honor.cpp:105
@ RBAC_PERM_COMMAND_HONOR_UPDATE
Definition RBAC.h:299
@ RBAC_PERM_COMMAND_HONOR
Definition RBAC.h:296
@ RBAC_PERM_COMMAND_HONOR_ADD
Definition RBAC.h:297
@ RBAC_PERM_COMMAND_HONOR_ADD_KILL
Definition RBAC.h:298