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
 

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)
 
virtual ~ScriptObject ()=default
 

Detailed Description

Constructor & Destructor Documentation

◆ honor_commandscript()

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

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:68
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:50
static bool HandleHonorAddCommand(ChatHandler *handler, uint32 amount)
Definition: cs_honor.cpp:59
static bool HandleHonorUpdateCommand(ChatHandler *handler)
Definition: cs_honor.cpp:96
static bool HandleHonorAddKillCommand(ChatHandler *handler)
Definition: cs_honor.cpp:77

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 handler->SetSentErrorMessage(true);
66 return false;
67 }
68
69 // check online security
70 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
71 return false;
72
73 target->RewardHonor(nullptr, 1, amount);
74 return true;
75 }
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:522
void SetSentErrorMessage(bool val)
Definition: Chat.h:118
virtual void SendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:103
Player * getSelectedPlayer() const
Definition: Chat.cpp:301
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:53
static ObjectGuid const Empty
Definition: ObjectGuid.h:122
Definition: Player.h:1046
bool RewardHonor(Unit *victim, uint32 groupsize, int32 honor=-1, bool awardXP=true)
Definition: Player.cpp:5967

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

Referenced by GetCommands().

◆ HandleHonorAddKillCommand()

static bool honor_commandscript::HandleHonorAddKillCommand ( ChatHandler handler)
inlinestatic
78 {
79 Unit* target = handler->getSelectedUnit();
80 if (!target)
81 {
83 handler->SetSentErrorMessage(true);
84 return false;
85 }
86
87 // check online security
88 if (Player* player = target->ToPlayer())
89 if (handler->HasLowerSecurity(player, ObjectGuid::Empty))
90 return false;
91
92 handler->GetSession()->GetPlayer()->RewardHonor(target, 1);
93 return true;
94 }
WorldSession * GetSession()
Definition: Chat.h:122
Unit * getSelectedUnit() const
Definition: Chat.cpp:313
Player * ToPlayer()
Definition: Object.h:195
Definition: Unit.h:1290
Player * GetPlayer() const
Definition: WorldSession.h:361

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

Referenced by GetCommands().

◆ HandleHonorUpdateCommand()

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

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

Referenced by GetCommands().