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

Public Member Functions

 gear_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 HandleGearRepairCommand (ChatHandler *handler, Optional< PlayerIdentifier > target)
 
static bool HandleGearStatsCommand (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

◆ gear_commandscript()

gear_commandscript::gear_commandscript ( )
inline
29: CommandScript("gear_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ GetCommands()

ChatCommandTable gear_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

32 {
33 static ChatCommandTable gearCommandTable =
34 {
35 { "repair", HandleGearRepairCommand, SEC_GAMEMASTER, Console::No },
36 { "stats", HandleGearStatsCommand, SEC_PLAYER, Console::No }
37 };
38
39 static ChatCommandTable commandTable =
40 {
41 { "gear", gearCommandTable }
42 };
43
44 return commandTable;
45 }
@ SEC_PLAYER
Definition: Common.h:57
@ SEC_GAMEMASTER
Definition: Common.h:59
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:46
static bool HandleGearRepairCommand(ChatHandler *handler, Optional< PlayerIdentifier > target)
Definition: cs_gear.cpp:47
static bool HandleGearStatsCommand(ChatHandler *handler)
Definition: cs_gear.cpp:80

References HandleGearRepairCommand(), HandleGearStatsCommand(), SEC_GAMEMASTER, and SEC_PLAYER.

◆ HandleGearRepairCommand()

static bool gear_commandscript::HandleGearRepairCommand ( ChatHandler handler,
Optional< PlayerIdentifier target 
)
inlinestatic
48 {
49 if (!target)
50 {
51 target = PlayerIdentifier::FromTargetOrSelf(handler);
52 }
53
54 if (!target || !target->IsConnected())
55 {
56 return false;
57 }
58
59 // check online security
60 if (handler->HasLowerSecurity(target->GetConnectedPlayer()))
61 {
62 return false;
63 }
64
65 // Repair items
66 target->GetConnectedPlayer()->DurabilityRepairAll(false, 0, false);
67
68 std::string nameLink = handler->playerLink(target->GetName());
69
70 handler->PSendSysMessage(LANG_YOU_REPAIR_ITEMS, nameLink);
71
72 if (handler->needReportToTarget(target->GetConnectedPlayer()))
73 {
74 ChatHandler(target->GetConnectedPlayer()->GetSession()).PSendSysMessage(LANG_YOUR_ITEMS_REPAIRED, nameLink);
75 }
76
77 return true;
78 }
@ LANG_YOU_REPAIR_ITEMS
Definition: Language.h:377
@ LANG_YOUR_ITEMS_REPAIRED
Definition: Language.h:378
Definition: Chat.h:37
std::string playerLink(std::string const &name) const
Definition: Chat.h:231
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:210
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:863
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:56
static Optional< PlayerIdentifier > FromTargetOrSelf(ChatHandler *handler)
Definition: ChatCommandTags.h:184

References Acore::ChatCommands::PlayerIdentifier::FromTargetOrSelf(), ChatHandler::HasLowerSecurity(), LANG_YOU_REPAIR_ITEMS, LANG_YOUR_ITEMS_REPAIRED, ChatHandler::needReportToTarget(), ChatHandler::playerLink(), and ChatHandler::PSendSysMessage().

Referenced by GetCommands().

◆ HandleGearStatsCommand()

static bool gear_commandscript::HandleGearStatsCommand ( ChatHandler handler)
inlinestatic
81 {
82 Player* player = handler->getSelectedPlayerOrSelf();
83
84 if (!player)
85 {
86 return false;
87 }
88
89 handler->PSendSysMessage("Character: {}", player->GetPlayerName());
90 handler->PSendSysMessage("Current equipment average item level: |cff00ffff{}|r", (int16)player->GetAverageItemLevel());
91
92 if (sWorld->getIntConfig(CONFIG_MIN_LEVEL_STAT_SAVE))
93 {
95 stmt->SetData(0, player->GetGUID().GetCounter());
96 PreparedQueryResult result = CharacterDatabase.Query(stmt);
97
98 if (result)
99 {
100 Field* fields = result->Fetch();
101 uint32 MaxHealth = fields[0].Get<uint32>();
102 uint32 Strength = fields[1].Get<uint32>();
103 uint32 Agility = fields[2].Get<uint32>();
104 uint32 Stamina = fields[3].Get<uint32>();
105 uint32 Intellect = fields[4].Get<uint32>();
106 uint32 Spirit = fields[5].Get<uint32>();
107 uint32 Armor = fields[6].Get<uint32>();
108 uint32 AttackPower = fields[7].Get<uint32>();
109 uint32 SpellPower = fields[8].Get<uint32>();
110 uint32 Resilience = fields[9].Get<uint32>();
111
112 handler->PSendSysMessage("Health: |cff00ffff{}|r - Stamina: |cff00ffff{}|r", MaxHealth, Stamina);
113 handler->PSendSysMessage("Strength: |cff00ffff{}|r - Agility: |cff00ffff{}|r", Strength, Agility);
114 handler->PSendSysMessage("Intellect: |cff00ffff{}|r - Spirit: |cff00ffff{}|r", Intellect, Spirit);
115 handler->PSendSysMessage("AttackPower: |cff00ffff{}|r - SpellPower: |cff00ffff{}|r", AttackPower, SpellPower);
116 handler->PSendSysMessage("Armor: |cff00ffff{}|r - Resilience: |cff00ffff{}|r", Armor, Resilience);
117 }
118 }
119
120 return true;
121 }
std::uint32_t uint32
Definition: Define.h:107
std::int16_t int16
Definition: Define.h:104
@ CONFIG_MIN_LEVEL_STAT_SAVE
Definition: IWorld.h:349
@ CHAR_SEL_CHAR_STATS
Definition: CharacterDatabase.h:449
std::shared_ptr< PreparedResultSet > PreparedQueryResult
Definition: DatabaseEnvFwd.h:45
DatabaseWorkerPool< CharacterDatabaseConnection > CharacterDatabase
Accessor to the character database.
Definition: DatabaseEnv.cpp:21
#define sWorld
Definition: World.h:443
Definition: PreparedStatement.h:157
Class used to access individual fields of database query result.
Definition: Field.h:98
std::enable_if_t< std::is_arithmetic_v< T >, T > Get() const
Definition: Field.h:112
Acore::Types::is_default< T > SetData(const uint8 index, T value)
Definition: PreparedStatement.h:77
Player * getSelectedPlayerOrSelf() const
Definition: Chat.cpp:417
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:112
LowType GetCounter() const
Definition: ObjectGuid.h:145
Definition: Player.h:1081
std::string GetPlayerName()
Definition: Player.cpp:16327
float GetAverageItemLevel()
Definition: Player.cpp:15754

References CHAR_SEL_CHAR_STATS, CharacterDatabase, CONFIG_MIN_LEVEL_STAT_SAVE, Field::Get(), Player::GetAverageItemLevel(), ObjectGuid::GetCounter(), Object::GetGUID(), Player::GetPlayerName(), ChatHandler::getSelectedPlayerOrSelf(), ChatHandler::PSendSysMessage(), PreparedStatementBase::SetData(), and sWorld.

Referenced by GetCommands().