AzerothCore 3.3.5a
OpenSource WoW Emulator
Loading...
Searching...
No Matches
honor_commandscript Class Reference
Inheritance diagram for honor_commandscript:
CommandScript ScriptObject

Public Member Functions

 honor_commandscript ()
 
ChatCommandTable GetCommands () const override
 
virtual std::vector< Acore::ChatCommands::ChatCommandBuilderGetCommands () const =0
 
- Public Member Functions inherited from ScriptObject
virtual bool IsDatabaseBound () const
 
virtual bool isAfterLoadScript () const
 
virtual void checkValidity ()
 
const std::string & GetName () const
 
uint16 GetTotalAvailableHooks ()
 

Static Public Member Functions

static bool HandleHonorAddCommand (ChatHandler *handler, uint32 amount)
 
static bool HandleHonorAddKillCommand (ChatHandler *handler)
 
static bool HandleHonorUpdateCommand (ChatHandler *handler)
 

Additional Inherited Members

- Protected Member Functions inherited from CommandScript
 CommandScript (const char *name)
 
- Protected Member Functions inherited from ScriptObject
 ScriptObject (const char *name, uint16 totalAvailableHooks=0)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ honor_commandscript()

honor_commandscript::honor_commandscript ( )
inline
36: CommandScript("honor_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable honor_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

39 {
40 static ChatCommandTable honorAddCommandTable =
41 {
42 { "kill", HandleHonorAddKillCommand, SEC_GAMEMASTER, Console::No },
43 { "", HandleHonorAddCommand, SEC_GAMEMASTER, Console::No }
44 };
45
46 static ChatCommandTable honorCommandTable =
47 {
48 { "add", honorAddCommandTable },
49 { "update", HandleHonorUpdateCommand, SEC_GAMEMASTER, Console::No }
50 };
51
52 static ChatCommandTable commandTable =
53 {
54 { "honor", honorCommandTable }
55 };
56 return commandTable;
57 }
@ SEC_GAMEMASTER
Definition: Common.h:59
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleHonorAddCommand(ChatHandler *handler, uint32 amount)
Definition: cs_honor.cpp:59
static bool HandleHonorUpdateCommand(ChatHandler *handler)
Definition: cs_honor.cpp:94
static bool HandleHonorAddKillCommand(ChatHandler *handler)
Definition: cs_honor.cpp:76

References HandleHonorAddCommand(), HandleHonorAddKillCommand(), HandleHonorUpdateCommand(), and SEC_GAMEMASTER.

◆ HandleHonorAddCommand()

static bool honor_commandscript::HandleHonorAddCommand ( ChatHandler handler,
uint32  amount 
)
inlinestatic
60 {
61 Player* target = handler->getSelectedPlayer();
62 if (!target)
63 {
65 return false;
66 }
67
68 // check online security
69 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
70 return false;
71
72 target->RewardHonor(nullptr, 1, amount);
73 return true;
74 }
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:215
Player * getSelectedPlayer() const
Definition: Chat.cpp:373
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:56
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
Definition: Player.h:1064
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool awardXP=true)
Definition: Player.cpp:6073

References ObjectGuid::Empty, ChatHandler::getSelectedPlayer(), ChatHandler::HasLowerSecurity(), LANG_PLAYER_NOT_FOUND, Player::RewardHonor(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleHonorAddKillCommand()

static bool honor_commandscript::HandleHonorAddKillCommand ( ChatHandler handler)
inlinestatic
77 {
78 Unit* target = handler->getSelectedUnit();
79 if (!target)
80 {
82 return false;
83 }
84
85 // check online security
86 if (Player* player = target->ToPlayer())
87 if (handler->HasLowerSecurity(player, ObjectGuid::Empty))
88 return false;
89
90 handler->GetSession()->GetPlayer()->RewardHonor(target, 1);
91 return true;
92 }
WorldSession * GetSession()
Definition: Chat.h:242
Unit * getSelectedUnit() const
Definition: Chat.cpp:385
Player * ToPlayer()
Definition: Object.h:198
Definition: Unit.h:630
Player * GetPlayer() const
Definition: WorldSession.h:362

References ObjectGuid::Empty, WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), ChatHandler::HasLowerSecurity(), LANG_PLAYER_NOT_FOUND, Player::RewardHonor(), ChatHandler::SendErrorMessage(), and Object::ToPlayer().

Referenced by GetCommands().

◆ HandleHonorUpdateCommand()

static bool honor_commandscript::HandleHonorUpdateCommand ( ChatHandler handler)
inlinestatic
95 {
96 Player* target = handler->getSelectedPlayer();
97 if (!target)
98 {
100 return false;
101 }
102
103 // check online security
104 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
105 return false;
106
107 target->UpdateHonorFields();
108 return true;
109 }
void UpdateHonorFields()
Definition: PlayerUpdates.cpp:1138

References ObjectGuid::Empty, ChatHandler::getSelectedPlayer(), ChatHandler::HasLowerSecurity(), LANG_PLAYER_NOT_FOUND, ChatHandler::SendErrorMessage(), and Player::UpdateHonorFields().

Referenced by GetCommands().