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

Public Member Functions

 modify_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

template<typename... Args>
static void NotifyModification (ChatHandler *handler, Unit *target, AcoreStrings resourceMessage, AcoreStrings resourceReportMessage, Args &&... args)
 
static bool CheckModifyInt32 (ChatHandler *handler, Player *target, int32 modifyValue)
 
static bool HandleModifyHPCommand (ChatHandler *handler, int32 healthPoints)
 
static bool HandleModifyManaCommand (ChatHandler *handler, int32 manaPoints)
 
static bool HandleModifyEnergyCommand (ChatHandler *handler, int32 energyPoints)
 
static bool HandleModifyRageCommand (ChatHandler *handler, int32 ragePoints)
 
static bool HandleModifyRunicPowerCommand (ChatHandler *handler, int32 runePoints)
 
static bool HandleModifyFactionCommand (ChatHandler *handler, Optional< uint32 > factionID, Optional< uint32 > flagID, Optional< uint32 > npcFlagID, Optional< uint32 > dynamicFlagID)
 
static bool HandleModifySpellCommand (ChatHandler *handler, uint8 spellFlatID, uint8 op, uint16 val, Optional< uint16 > mark)
 
static bool HandleModifyTalentCommand (ChatHandler *handler, uint32 talentPoints)
 
static bool CheckModifySpeed (ChatHandler *handler, Unit *target, float speed, float minimumBound, float maximumBound, bool checkInFlight=true)
 
static bool HandleModifyASpeedCommand (ChatHandler *handler, float allSpeed)
 
static bool HandleModifySpeedCommand (ChatHandler *handler, float speed)
 
static bool HandleModifySwimCommand (ChatHandler *handler, float swimSpeed)
 
static bool HandleModifyBWalkCommand (ChatHandler *handler, float backSpeed)
 
static bool HandleModifyFlyCommand (ChatHandler *handler, float flySpeed)
 
static bool HandleModifyScaleCommand (ChatHandler *handler, float scale)
 
static bool HandleModifyMountCommand (ChatHandler *handler, uint32 creatureDisplayID, Optional< float > speed)
 
static bool HandleModifyMoneyCommand (ChatHandler *handler, Tail money)
 
static bool HandleModifyBitCommand (ChatHandler *handler, uint16 field, uint32 bit)
 
static bool HandleModifyHonorCommand (ChatHandler *handler, int32 amount)
 
static bool HandleModifyDrunkCommand (ChatHandler *handler, uint8 drunklevel)
 
static bool HandleModifyRepCommand (ChatHandler *handler, uint32 factionId, Variant< int32, std::string > rank, Optional< int32 > delta)
 
static bool HandleMorphTargetCommand (ChatHandler *handler, uint32 displayID)
 
static bool HandleMorphResetCommand (ChatHandler *handler)
 
static bool HandleMorphMountCommand (ChatHandler *handler, uint32 displayID)
 
static bool HandleModifyPhaseCommand (ChatHandler *handler, uint32 phaseMask)
 
static bool HandleModifyStandStateCommand (ChatHandler *handler, uint32 anim)
 
static bool HandleModifyArenaCommand (ChatHandler *handler, int32 amount)
 
static bool HandleModifyGenderCommand (ChatHandler *handler, Tail genderString)
 

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

◆ modify_commandscript()

modify_commandscript::modify_commandscript ( )
inline
39: CommandScript("modify_commandscript") { }
Definition: CommandScript.h:25

Member Function Documentation

◆ CheckModifyInt32()

static bool modify_commandscript::CheckModifyInt32 ( ChatHandler handler,
Player target,
int32  modifyValue 
)
inlinestatic
108 {
109 if (modifyValue < 1)
110 {
112 return false;
113 }
114
115 if (!target)
116 {
118 return false;
119 }
120
121 if (handler->HasLowerSecurity(target))
122 {
123 return false;
124 }
125
126 return true;
127 }
@ LANG_NO_CHAR_SELECTED
Definition: Language.h:148
@ LANG_BAD_VALUE
Definition: Language.h:147
void SendErrorMessage(uint32 entry)
Definition: Chat.cpp:218
bool HasLowerSecurity(Player *target, ObjectGuid guid=ObjectGuid::Empty, bool strong=false)
Definition: Chat.cpp:59

References ChatHandler::HasLowerSecurity(), LANG_BAD_VALUE, LANG_NO_CHAR_SELECTED, and ChatHandler::SendErrorMessage().

Referenced by HandleModifyEnergyCommand(), HandleModifyHPCommand(), HandleModifyManaCommand(), HandleModifyRageCommand(), and HandleModifyRunicPowerCommand().

◆ CheckModifySpeed()

static bool modify_commandscript::CheckModifySpeed ( ChatHandler handler,
Unit target,
float  speed,
float  minimumBound,
float  maximumBound,
bool  checkInFlight = true 
)
inlinestatic
389 {
390 if (speed > maximumBound || speed < minimumBound)
391 {
393 return false;
394 }
395
396 if (!target)
397 {
399 return false;
400 }
401
402 if (Player* player = target->ToPlayer())
403 {
404 // check online security
405 if (handler->HasLowerSecurity(player))
406 {
407 return false;
408 }
409
410 if (player->IsInFlight() && checkInFlight)
411 {
412 handler->SendErrorMessage(LANG_CHAR_IN_FLIGHT, handler->GetNameLink(player).c_str());
413 return false;
414 }
415 }
416
417 return true;
418 }
@ LANG_CHAR_IN_FLIGHT
Definition: Language.h:53
virtual std::string GetNameLink() const
Definition: Chat.h:200
Player * ToPlayer()
Definition: Object.h:198
Definition: Player.h:1064

References ChatHandler::GetNameLink(), ChatHandler::HasLowerSecurity(), LANG_BAD_VALUE, LANG_CHAR_IN_FLIGHT, LANG_NO_CHAR_SELECTED, ChatHandler::SendErrorMessage(), and Object::ToPlayer().

Referenced by HandleModifyASpeedCommand(), HandleModifyBWalkCommand(), HandleModifyFlyCommand(), HandleModifyMountCommand(), HandleModifySpeedCommand(), and HandleModifySwimCommand().

◆ GetCommands()

ChatCommandTable modify_commandscript::GetCommands ( ) const
inlineoverridevirtual

Implements CommandScript.

42 {
43 static ChatCommandTable modifyspeedCommandTable =
44 {
45 { "fly", HandleModifyFlyCommand, SEC_GAMEMASTER, Console::No },
46 { "all", HandleModifyASpeedCommand, SEC_GAMEMASTER, Console::No },
47 { "walk", HandleModifySpeedCommand, SEC_GAMEMASTER, Console::No },
48 { "backwalk", HandleModifyBWalkCommand, SEC_GAMEMASTER, Console::No },
49 { "swim", HandleModifySwimCommand, SEC_GAMEMASTER, Console::No },
50 { "", HandleModifyASpeedCommand, SEC_GAMEMASTER, Console::No }
51 };
52
53 static ChatCommandTable modifyCommandTable =
54 {
55 { "hp", HandleModifyHPCommand, SEC_GAMEMASTER, Console::No },
56 { "mana", HandleModifyManaCommand, SEC_GAMEMASTER, Console::No },
57 { "rage", HandleModifyRageCommand, SEC_GAMEMASTER, Console::No },
58 { "runicpower", HandleModifyRunicPowerCommand, SEC_GAMEMASTER, Console::No },
59 { "energy", HandleModifyEnergyCommand, SEC_GAMEMASTER, Console::No },
60 { "money", HandleModifyMoneyCommand, SEC_GAMEMASTER, Console::No },
61 { "scale", HandleModifyScaleCommand, SEC_GAMEMASTER, Console::No },
62 { "bit", HandleModifyBitCommand, SEC_GAMEMASTER, Console::No },
63 { "faction", HandleModifyFactionCommand, SEC_ADMINISTRATOR, Console::No },
64 { "spell", HandleModifySpellCommand, SEC_CONSOLE, Console::No },
65 { "talentpoints", HandleModifyTalentCommand, SEC_GAMEMASTER, Console::No },
66 { "mount", HandleModifyMountCommand, SEC_GAMEMASTER, Console::No },
67 { "honor", HandleModifyHonorCommand, SEC_GAMEMASTER, Console::No },
68 { "reputation", HandleModifyRepCommand, SEC_GAMEMASTER, Console::No },
69 { "arenapoints", HandleModifyArenaCommand, SEC_GAMEMASTER, Console::No },
70 { "drunk", HandleModifyDrunkCommand, SEC_GAMEMASTER, Console::No },
71 { "standstate", HandleModifyStandStateCommand, SEC_GAMEMASTER, Console::No },
72 { "phase", HandleModifyPhaseCommand, SEC_GAMEMASTER, Console::No },
73 { "gender", HandleModifyGenderCommand, SEC_GAMEMASTER, Console::No },
74 { "speed", modifyspeedCommandTable }
75 };
76
77 static ChatCommandTable morphCommandTable =
78 {
79 { "reset", HandleMorphResetCommand, SEC_MODERATOR, Console::No },
80 { "target", HandleMorphTargetCommand, SEC_MODERATOR, Console::No },
81 { "mount", HandleMorphMountCommand, SEC_MODERATOR, Console::No }
82 };
83
84 static ChatCommandTable commandTable =
85 {
86 { "morph", morphCommandTable },
87 { "modify", modifyCommandTable }
88 };
89
90 return commandTable;
91 }
@ SEC_ADMINISTRATOR
Definition: Common.h:60
@ SEC_GAMEMASTER
Definition: Common.h:59
@ SEC_MODERATOR
Definition: Common.h:58
@ SEC_CONSOLE
Definition: Common.h:61
std::vector< ChatCommandBuilder > ChatCommandTable
Definition: ChatCommand.h:49
static bool HandleModifyScaleCommand(ChatHandler *handler, float scale)
Definition: cs_modify.cpp:494
static bool HandleModifyEnergyCommand(ChatHandler *handler, int32 energyPoints)
Definition: cs_modify.cpp:176
static bool HandleModifyBWalkCommand(ChatHandler *handler, float backSpeed)
Definition: cs_modify.cpp:466
static bool HandleModifyFlyCommand(ChatHandler *handler, float flySpeed)
Definition: cs_modify.cpp:480
static bool HandleModifyPhaseCommand(ChatHandler *handler, uint32 phaseMask)
Definition: cs_modify.cpp:888
static bool HandleModifyHPCommand(ChatHandler *handler, int32 healthPoints)
Definition: cs_modify.cpp:130
static bool HandleMorphTargetCommand(ChatHandler *handler, uint32 displayID)
Definition: cs_modify.cpp:838
static bool HandleModifySpeedCommand(ChatHandler *handler, float speed)
Definition: cs_modify.cpp:438
static bool HandleModifyASpeedCommand(ChatHandler *handler, float allSpeed)
Definition: cs_modify.cpp:421
static bool HandleMorphMountCommand(ChatHandler *handler, uint32 displayID)
Definition: cs_modify.cpp:872
static bool HandleModifyMountCommand(ChatHandler *handler, uint32 creatureDisplayID, Optional< float > speed)
Definition: cs_modify.cpp:526
static bool HandleModifyBitCommand(ChatHandler *handler, uint16 field, uint32 bit)
Definition: cs_modify.cpp:659
static bool HandleMorphResetCommand(ChatHandler *handler)
Definition: cs_modify.cpp:856
static bool HandleModifyMoneyCommand(ChatHandler *handler, Tail money)
Definition: cs_modify.cpp:563
static bool HandleModifySpellCommand(ChatHandler *handler, uint8 spellFlatID, uint8 op, uint16 val, Optional< uint16 > mark)
Definition: cs_modify.cpp:312
static bool HandleModifyStandStateCommand(ChatHandler *handler, uint32 anim)
Definition: cs_modify.cpp:905
static bool HandleModifyRepCommand(ChatHandler *handler, uint32 factionId, Variant< int32, std::string > rank, Optional< int32 > delta)
Definition: cs_modify.cpp:737
static bool HandleModifyDrunkCommand(ChatHandler *handler, uint8 drunklevel)
Definition: cs_modify.cpp:722
static bool HandleModifySwimCommand(ChatHandler *handler, float swimSpeed)
Definition: cs_modify.cpp:452
static bool HandleModifyRageCommand(ChatHandler *handler, int32 ragePoints)
Definition: cs_modify.cpp:203
static bool HandleModifyFactionCommand(ChatHandler *handler, Optional< uint32 > factionID, Optional< uint32 > flagID, Optional< uint32 > npcFlagID, Optional< uint32 > dynamicFlagID)
Definition: cs_modify.cpp:253
static bool HandleModifyRunicPowerCommand(ChatHandler *handler, int32 runePoints)
Definition: cs_modify.cpp:228
static bool HandleModifyHonorCommand(ChatHandler *handler, int32 amount)
Definition: cs_modify.cpp:700
static bool HandleModifyManaCommand(ChatHandler *handler, int32 manaPoints)
Definition: cs_modify.cpp:153
static bool HandleModifyGenderCommand(ChatHandler *handler, Tail genderString)
Definition: cs_modify.cpp:927
static bool HandleModifyTalentCommand(ChatHandler *handler, uint32 talentPoints)
Definition: cs_modify.cpp:344
static bool HandleModifyArenaCommand(ChatHandler *handler, int32 amount)
Definition: cs_modify.cpp:911

References HandleModifyArenaCommand(), HandleModifyASpeedCommand(), HandleModifyBitCommand(), HandleModifyBWalkCommand(), HandleModifyDrunkCommand(), HandleModifyEnergyCommand(), HandleModifyFactionCommand(), HandleModifyFlyCommand(), HandleModifyGenderCommand(), HandleModifyHonorCommand(), HandleModifyHPCommand(), HandleModifyManaCommand(), HandleModifyMoneyCommand(), HandleModifyMountCommand(), HandleModifyPhaseCommand(), HandleModifyRageCommand(), HandleModifyRepCommand(), HandleModifyRunicPowerCommand(), HandleModifyScaleCommand(), HandleModifySpeedCommand(), HandleModifySpellCommand(), HandleModifyStandStateCommand(), HandleModifySwimCommand(), HandleModifyTalentCommand(), HandleMorphMountCommand(), HandleMorphResetCommand(), HandleMorphTargetCommand(), SEC_ADMINISTRATOR, SEC_CONSOLE, SEC_GAMEMASTER, and SEC_MODERATOR.

◆ HandleModifyArenaCommand()

static bool modify_commandscript::HandleModifyArenaCommand ( ChatHandler handler,
int32  amount 
)
inlinestatic
912 {
913 Player* target = handler->getSelectedPlayer();
914 if (!target)
915 {
917 return false;
918 }
919
920 target->ModifyArenaPoints(amount);
921
922 handler->PSendSysMessage(LANG_COMMAND_MODIFY_ARENA, handler->GetNameLink(target), target->GetArenaPoints());
923
924 return true;
925 }
@ LANG_COMMAND_MODIFY_ARENA
Definition: Language.h:347
@ LANG_PLAYER_NOT_FOUND
Definition: Language.h:539
void PSendSysMessage(std::string_view str, bool escapeCharacters=false)
Definition: Chat.cpp:213
Player * getSelectedPlayer() const
Definition: Chat.cpp:376
uint32 GetArenaPoints() const
Definition: Player.h:2133
void ModifyArenaPoints(int32 value, CharacterDatabaseTransaction trans=CharacterDatabaseTransaction(nullptr))
If trans is specified, honor save query will be added to trans.
Definition: Player.cpp:6287

References Player::GetArenaPoints(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), LANG_COMMAND_MODIFY_ARENA, LANG_PLAYER_NOT_FOUND, Player::ModifyArenaPoints(), ChatHandler::PSendSysMessage(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleModifyASpeedCommand()

static bool modify_commandscript::HandleModifyASpeedCommand ( ChatHandler handler,
float  allSpeed 
)
inlinestatic
422 {
423 Player* target = handler->getSelectedPlayerOrSelf();
424 if (CheckModifySpeed(handler, target, allSpeed, 0.1f, 50.0f))
425 {
427 target->SetSpeed(MOVE_WALK, allSpeed);
428 target->SetSpeed(MOVE_RUN, allSpeed);
429 target->SetSpeed(MOVE_SWIM, allSpeed);
430 target->SetSpeed(MOVE_FLIGHT, allSpeed);
431 return true;
432 }
433
434 return false;
435 }
@ LANG_YOURS_ASPEED_CHANGED
Definition: Language.h:173
@ LANG_YOU_CHANGE_ASPEED
Definition: Language.h:172
@ MOVE_FLIGHT
Definition: UnitDefines.h:334
@ MOVE_SWIM
Definition: UnitDefines.h:331
@ MOVE_RUN
Definition: UnitDefines.h:329
@ MOVE_WALK
Definition: UnitDefines.h:328
Player * getSelectedPlayerOrSelf() const
Definition: Chat.cpp:420
void SetSpeed(UnitMoveType mtype, float rate, bool forced=false)
Definition: Unit.cpp:14383
static bool CheckModifySpeed(ChatHandler *handler, Unit *target, float speed, float minimumBound, float maximumBound, bool checkInFlight=true)
Definition: cs_modify.cpp:388
static void NotifyModification(ChatHandler *handler, Unit *target, AcoreStrings resourceMessage, AcoreStrings resourceReportMessage, Args &&... args)
Definition: cs_modify.cpp:94

References CheckModifySpeed(), ChatHandler::getSelectedPlayerOrSelf(), LANG_YOU_CHANGE_ASPEED, LANG_YOURS_ASPEED_CHANGED, MOVE_FLIGHT, MOVE_RUN, MOVE_SWIM, MOVE_WALK, NotifyModification(), and Unit::SetSpeed().

Referenced by GetCommands().

◆ HandleModifyBitCommand()

static bool modify_commandscript::HandleModifyBitCommand ( ChatHandler handler,
uint16  field,
uint32  bit 
)
inlinestatic
660 {
661 Unit* target = handler->getSelectedUnit();
662 if (!target)
663 {
665 return false;
666 }
667
668 // check online security
669 if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer()))
670 {
671 return false;
672 }
673
674 if (field < OBJECT_END || field >= target->GetValuesCount())
675 {
677 return false;
678 }
679
680 if (bit < 1 || bit > 32)
681 {
683 return false;
684 }
685
686 if (target->HasFlag(field, (1 << (bit - 1))))
687 {
688 target->RemoveFlag(field, (1 << (bit - 1)));
689 handler->PSendSysMessage(LANG_REMOVE_BIT, bit, field);
690 }
691 else
692 {
693 target->SetFlag(field, (1 << (bit - 1)));
694 handler->PSendSysMessage(LANG_SET_BIT, bit, field);
695 }
696
697 return true;
698 }
@ LANG_REMOVE_BIT
Definition: Language.h:200
@ LANG_SET_BIT
Definition: Language.h:201
Unit * getSelectedUnit() const
Definition: Chat.cpp:388
bool IsPlayer() const
Definition: Object.h:197
void SetFlag(uint16 index, uint32 newFlag)
Definition: Object.cpp:845
void RemoveFlag(uint16 index, uint32 oldFlag)
Definition: Object.cpp:860
bool HasFlag(uint16 index, uint32 flag) const
Definition: Object.cpp:889
uint16 GetValuesCount() const
Definition: Object.h:184
Definition: Unit.h:630

References ChatHandler::getSelectedUnit(), Object::GetValuesCount(), Object::HasFlag(), ChatHandler::HasLowerSecurity(), Object::IsPlayer(), LANG_BAD_VALUE, LANG_NO_CHAR_SELECTED, LANG_REMOVE_BIT, LANG_SET_BIT, ChatHandler::PSendSysMessage(), Object::RemoveFlag(), ChatHandler::SendErrorMessage(), Object::SetFlag(), and Object::ToPlayer().

Referenced by GetCommands().

◆ HandleModifyBWalkCommand()

static bool modify_commandscript::HandleModifyBWalkCommand ( ChatHandler handler,
float  backSpeed 
)
inlinestatic
467 {
468 Player* target = handler->getSelectedPlayerOrSelf();
469 if (CheckModifySpeed(handler, target, backSpeed, 0.1f, 50.0f))
470 {
472 target->SetSpeedRate(MOVE_RUN_BACK, backSpeed);
473 return true;
474 }
475
476 return false;
477 }
@ LANG_YOU_CHANGE_BACK_SPEED
Definition: Language.h:178
@ LANG_YOURS_BACK_SPEED_CHANGED
Definition: Language.h:179
@ MOVE_RUN_BACK
Definition: UnitDefines.h:330
void SetSpeedRate(UnitMoveType mtype, float rate)
Definition: Unit.h:1589

References CheckModifySpeed(), ChatHandler::getSelectedPlayerOrSelf(), LANG_YOU_CHANGE_BACK_SPEED, LANG_YOURS_BACK_SPEED_CHANGED, MOVE_RUN_BACK, NotifyModification(), and Unit::SetSpeedRate().

Referenced by GetCommands().

◆ HandleModifyDrunkCommand()

static bool modify_commandscript::HandleModifyDrunkCommand ( ChatHandler handler,
uint8  drunklevel 
)
inlinestatic
723 {
724 if (drunklevel > 100)
725 {
726 drunklevel = 100;
727 }
728
729 if (Player* target = handler->getSelectedPlayer())
730 {
731 target->SetDrunkValue(drunklevel);
732 }
733
734 return true;
735 }

References ChatHandler::getSelectedPlayer().

Referenced by GetCommands().

◆ HandleModifyEnergyCommand()

static bool modify_commandscript::HandleModifyEnergyCommand ( ChatHandler handler,
int32  energyPoints 
)
inlinestatic
177 {
178 Player* target = handler->getSelectedPlayer();
179
180 if (!CheckModifyInt32(handler, target, energyPoints))
181 {
182 return false;
183 }
184
185 energyPoints *= 10;
186
187 handler->PSendSysMessage(LANG_YOU_CHANGE_ENERGY, handler->GetNameLink(target), energyPoints / 10, energyPoints / 10);
188
189 if (handler->needReportToTarget(target))
190 {
191 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_ENERGY_CHANGED, handler->GetNameLink(), energyPoints / 10, energyPoints / 10);
192 }
193
194 target->SetMaxPower(POWER_ENERGY, energyPoints);
195 target->SetPower(POWER_ENERGY, energyPoints);
196
198
199 return true;
200 }
#define LOG_DEBUG(filterType__,...)
Definition: Log.h:168
@ LANG_YOU_CHANGE_ENERGY
Definition: Language.h:155
@ LANG_CURRENT_ENERGY
Definition: Language.h:158
@ LANG_YOURS_ENERGY_CHANGED
Definition: Language.h:156
@ POWER_ENERGY
Definition: SharedDefines.h:272
Definition: Chat.h:39
virtual char const * GetAcoreString(uint32 entry) const
Definition: Chat.cpp:43
virtual bool needReportToTarget(Player *chr) const
Definition: Chat.cpp:866
WorldSession * GetSession() const
Definition: Player.h:1978
void SetPower(Powers power, uint32 val, bool withPowerUpdate=true, bool fromRegenerate=false)
Definition: Unit.cpp:15521
void SetMaxPower(Powers power, uint32 val)
Definition: Unit.cpp:15586
uint32 GetMaxPower(Powers power) const
Definition: Unit.h:892
static bool CheckModifyInt32(ChatHandler *handler, Player *target, int32 modifyValue)
Definition: cs_modify.cpp:107

References CheckModifyInt32(), ChatHandler::GetAcoreString(), Unit::GetMaxPower(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), LANG_CURRENT_ENERGY, LANG_YOU_CHANGE_ENERGY, LANG_YOURS_ENERGY_CHANGED, LOG_DEBUG, ChatHandler::needReportToTarget(), POWER_ENERGY, ChatHandler::PSendSysMessage(), Unit::SetMaxPower(), and Unit::SetPower().

Referenced by GetCommands().

◆ HandleModifyFactionCommand()

static bool modify_commandscript::HandleModifyFactionCommand ( ChatHandler handler,
Optional< uint32 factionID,
Optional< uint32 flagID,
Optional< uint32 npcFlagID,
Optional< uint32 dynamicFlagID 
)
inlinestatic
254 {
255 Creature* target = handler->getSelectedCreature();
256 if (!target)
257 {
259 return false;
260 }
261
262 if (!factionID)
263 {
264 uint32 factionid = target->GetFaction();
265 uint32 flag = target->GetUnitFlags();
266 uint32 npcflag = target->GetNpcFlags();
267 uint32 dyflag = target->GetDynamicFlags();
268 handler->PSendSysMessage(LANG_CURRENT_FACTION, target->GetGUID().ToString(), factionid, flag, npcflag, dyflag);
269 return true;
270 }
271
272 uint32 factionid = factionID.value();
273 UnitFlags flag;
274 NPCFlags npcflag;
275 uint32 dyflag;
276
277 auto pflag = flagID;
278 if (!pflag)
279 flag = target->GetUnitFlags();
280 else
281 flag = UnitFlags(*pflag);
282
283 auto pnpcflag = npcFlagID;
284 if (!pnpcflag)
285 npcflag = target->GetNpcFlags();
286 else
287 npcflag = NPCFlags(*npcFlagID);
288
289 auto pdyflag = dynamicFlagID;
290 if (!pdyflag)
291 dyflag = target->GetDynamicFlags();
292 else
293 dyflag = *dynamicFlagID;
294
295 if (!sFactionTemplateStore.LookupEntry(factionid))
296 {
297 handler->SendErrorMessage(LANG_WRONG_FACTION, factionid);
298 return false;
299 }
300
301 handler->PSendSysMessage(LANG_YOU_CHANGE_FACTION, target->GetGUID().ToString(), factionid, flag, npcflag, dyflag);
302
303 target->SetFaction(factionid);
304 target->ReplaceAllUnitFlags(flag);
305 target->ReplaceAllNpcFlags(npcflag);
306 target->ReplaceAllDynamicFlags(dyflag);
307
308 return true;
309 }
std::uint32_t uint32
Definition: Define.h:107
DBCStorage< FactionTemplateEntry > sFactionTemplateStore(FactionTemplateEntryfmt)
@ LANG_SELECT_CREATURE
Definition: Language.h:32
@ LANG_WRONG_FACTION
Definition: Language.h:163
@ LANG_CURRENT_FACTION
Definition: Language.h:162
@ LANG_YOU_CHANGE_FACTION
Definition: Language.h:164
NPCFlags
Non Player Character flags.
Definition: UnitDefines.h:292
UnitFlags
Definition: UnitDefines.h:227
Creature * getSelectedCreature() const
Definition: Chat.cpp:412
Definition: Creature.h:46
static ObjectGuid GetGUID(Object const *o)
Definition: Object.h:109
std::string ToString() const
Definition: ObjectGuid.cpp:47
void ReplaceAllDynamicFlags(uint32 flag) override
Definition: Unit.h:700
void SetFaction(uint32 faction)
Definition: Unit.cpp:10018
NPCFlags GetNpcFlags() const
Definition: Unit.h:693
void ReplaceAllUnitFlags(UnitFlags flags)
Remove the Unit flag specify only.
Definition: Unit.h:685
UnitFlags GetUnitFlags() const
Definition: Unit.h:681
uint32 GetFaction() const
Definition: Unit.h:755
void ReplaceAllNpcFlags(NPCFlags flags)
Definition: Unit.h:697
uint32 GetDynamicFlags() const override
Definition: Unit.h:699

References Unit::GetDynamicFlags(), Unit::GetFaction(), Object::GetGUID(), Unit::GetNpcFlags(), ChatHandler::getSelectedCreature(), Unit::GetUnitFlags(), LANG_CURRENT_FACTION, LANG_SELECT_CREATURE, LANG_WRONG_FACTION, LANG_YOU_CHANGE_FACTION, ChatHandler::PSendSysMessage(), Unit::ReplaceAllDynamicFlags(), Unit::ReplaceAllNpcFlags(), Unit::ReplaceAllUnitFlags(), ChatHandler::SendErrorMessage(), Unit::SetFaction(), sFactionTemplateStore, and ObjectGuid::ToString().

Referenced by GetCommands().

◆ HandleModifyFlyCommand()

static bool modify_commandscript::HandleModifyFlyCommand ( ChatHandler handler,
float  flySpeed 
)
inlinestatic
481 {
482 Player* target = handler->getSelectedPlayerOrSelf();
483 if (CheckModifySpeed(handler, target, flySpeed, 0.1f, 50.0f, false))
484 {
486 target->SetSpeedRate(MOVE_FLIGHT, flySpeed);
487 return true;
488 }
489
490 return false;
491 }
@ LANG_YOURS_FLY_SPEED_CHANGED
Definition: Language.h:181
@ LANG_YOU_CHANGE_FLY_SPEED
Definition: Language.h:180

References CheckModifySpeed(), ChatHandler::getSelectedPlayerOrSelf(), LANG_YOU_CHANGE_FLY_SPEED, LANG_YOURS_FLY_SPEED_CHANGED, MOVE_FLIGHT, NotifyModification(), and Unit::SetSpeedRate().

Referenced by GetCommands().

◆ HandleModifyGenderCommand()

static bool modify_commandscript::HandleModifyGenderCommand ( ChatHandler handler,
Tail  genderString 
)
inlinestatic
928 {
929 if (genderString.empty())
930 {
931 return false;
932 }
933
934 Player* target = handler->getSelectedPlayer();
935 if (!target)
936 {
938 return false;
939 }
940
941 PlayerInfo const* info = sObjectMgr->GetPlayerInfo(target->getRace(), target->getClass());
942 if (!info)
943 {
944 return false;
945 }
946
947 Gender gender;
948
949 if (StringEqualI(genderString, "male")) // MALE
950 {
951 if (target->getGender() == GENDER_MALE)
952 return true;
953
954 gender = GENDER_MALE;
955 }
956 else if (StringEqualI(genderString, "female")) // FEMALE
957 {
958 if (target->getGender() == GENDER_FEMALE)
959 return true;
960
961 gender = GENDER_FEMALE;
962 }
963 else
964 {
966 return false;
967 }
968
969 // Set gender
970 target->SetByteValue(UNIT_FIELD_BYTES_0, 2, gender);
971 target->SetByteValue(PLAYER_BYTES_3, 0, gender);
972
973 // Change display ID
974 target->InitDisplayIds();
975
976 char const* gender_full = gender ? "female" : "male";
977
978 handler->PSendSysMessage(LANG_YOU_CHANGE_GENDER, handler->GetNameLink(target), gender_full);
979
980 if (handler->needReportToTarget(target))
981 {
983 }
984
985 return true;
986 }
bool StringEqualI(std::string_view a, std::string_view b)
Definition: Util.cpp:592
#define sObjectMgr
Definition: ObjectMgr.h:1623
@ LANG_MUST_MALE_OR_FEMALE
Definition: Language.h:908
@ LANG_YOU_CHANGE_GENDER
Definition: Language.h:909
@ LANG_YOUR_GENDER_CHANGED
Definition: Language.h:910
@ PLAYER_BYTES_3
Definition: UpdateFields.h:183
@ UNIT_FIELD_BYTES_0
Definition: UpdateFields.h:95
Gender
Definition: SharedDefines.h:60
@ GENDER_MALE
Definition: SharedDefines.h:61
@ GENDER_FEMALE
Definition: SharedDefines.h:62
void SetByteValue(uint16 index, uint8 offset, uint8 value)
Definition: Object.cpp:750
Definition: Player.h:335
void InitDisplayIds()
Definition: Player.cpp:10616
uint8 getGender() const
Definition: Unit.h:752
uint8 getClass() const
Definition: Unit.h:747
uint8 getRace(bool original=false) const
Definition: Unit.cpp:20962

References GENDER_FEMALE, GENDER_MALE, Unit::getClass(), Unit::getGender(), ChatHandler::GetNameLink(), Unit::getRace(), ChatHandler::getSelectedPlayer(), Player::GetSession(), Player::InitDisplayIds(), LANG_MUST_MALE_OR_FEMALE, LANG_PLAYER_NOT_FOUND, LANG_YOU_CHANGE_GENDER, LANG_YOUR_GENDER_CHANGED, ChatHandler::needReportToTarget(), PLAYER_BYTES_3, ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), Object::SetByteValue(), sObjectMgr, StringEqualI(), and UNIT_FIELD_BYTES_0.

Referenced by GetCommands().

◆ HandleModifyHonorCommand()

static bool modify_commandscript::HandleModifyHonorCommand ( ChatHandler handler,
int32  amount 
)
inlinestatic
701 {
702 Player* target = handler->getSelectedPlayer();
703 if (!target)
704 {
706 return false;
707 }
708
709 // check online security
710 if (handler->HasLowerSecurity(target))
711 {
712 return false;
713 }
714
715 target->ModifyHonorPoints(amount);
716
717 handler->PSendSysMessage(LANG_COMMAND_MODIFY_HONOR, handler->GetNameLink(target), target->GetHonorPoints());
718
719 return true;
720 }
@ LANG_COMMAND_MODIFY_HONOR
Definition: Language.h:338
uint32 GetHonorPoints() const
Definition: Player.h:2132
void ModifyHonorPoints(int32 value, CharacterDatabaseTransaction trans=CharacterDatabaseTransaction(nullptr))
Definition: Player.cpp:6271

References Player::GetHonorPoints(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), ChatHandler::HasLowerSecurity(), LANG_COMMAND_MODIFY_HONOR, LANG_PLAYER_NOT_FOUND, Player::ModifyHonorPoints(), ChatHandler::PSendSysMessage(), and ChatHandler::SendErrorMessage().

Referenced by GetCommands().

◆ HandleModifyHPCommand()

static bool modify_commandscript::HandleModifyHPCommand ( ChatHandler handler,
int32  healthPoints 
)
inlinestatic
131 {
132 Player* target = handler->getSelectedPlayer();
133
134 if (!CheckModifyInt32(handler, target, healthPoints))
135 {
136 return false;
137 }
138
139 handler->PSendSysMessage(LANG_YOU_CHANGE_HP, handler->GetNameLink(target), healthPoints, healthPoints);
140
141 if (handler->needReportToTarget(target))
142 {
143 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_HP_CHANGED, handler->GetNameLink(), healthPoints, healthPoints);
144 }
145
146 target->SetMaxHealth(healthPoints);
147 target->SetHealth(healthPoints);
148
149 return true;
150 }
@ LANG_YOURS_HP_CHANGED
Definition: Language.h:152
@ LANG_YOU_CHANGE_HP
Definition: Language.h:151
void SetHealth(uint32 val)
Definition: Unit.cpp:15433
void SetMaxHealth(uint32 val)
Definition: Unit.cpp:15483

References CheckModifyInt32(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), LANG_YOU_CHANGE_HP, LANG_YOURS_HP_CHANGED, ChatHandler::needReportToTarget(), ChatHandler::PSendSysMessage(), Unit::SetHealth(), and Unit::SetMaxHealth().

Referenced by GetCommands().

◆ HandleModifyManaCommand()

static bool modify_commandscript::HandleModifyManaCommand ( ChatHandler handler,
int32  manaPoints 
)
inlinestatic
154 {
155 Player* target = handler->getSelectedPlayer();
156
157 if (!CheckModifyInt32(handler, target, manaPoints))
158 {
159 return false;
160 }
161
162 handler->PSendSysMessage(LANG_YOU_CHANGE_MANA, handler->GetNameLink(target), manaPoints, manaPoints);
163
164 if (handler->needReportToTarget(target))
165 {
166 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MANA_CHANGED, handler->GetNameLink(), manaPoints, manaPoints);
167 }
168
169 target->SetMaxPower(POWER_MANA, manaPoints);
170 target->SetPower(POWER_MANA, manaPoints);
171
172 return true;
173 }
@ LANG_YOURS_MANA_CHANGED
Definition: Language.h:154
@ LANG_YOU_CHANGE_MANA
Definition: Language.h:153
@ POWER_MANA
Definition: SharedDefines.h:269

References CheckModifyInt32(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), LANG_YOU_CHANGE_MANA, LANG_YOURS_MANA_CHANGED, ChatHandler::needReportToTarget(), POWER_MANA, ChatHandler::PSendSysMessage(), Unit::SetMaxPower(), and Unit::SetPower().

Referenced by GetCommands().

◆ HandleModifyMoneyCommand()

static bool modify_commandscript::HandleModifyMoneyCommand ( ChatHandler handler,
Tail  money 
)
inlinestatic
564 {
565 if (money.empty())
566 {
567 return false;
568 }
569
570 Player* target = handler->getSelectedPlayer();
571 if (!target)
572 {
574 return false;
575 }
576
577 // check online security
578 if (handler->HasLowerSecurity(target))
579 {
580 return false;
581 }
582
583 auto IsExistWord = [](std::string_view line, std::initializer_list<std::string_view> words)
584 {
585 for (auto const& word : words)
586 {
587 if (line.find(word) != std::string_view::npos)
588 {
589 return true;
590 }
591 }
592
593 return false;
594 };
595
596 Optional<int32> moneyToAddO = 0;
597 if (IsExistWord(money, { "g", "s", "c" }))
598 {
599 moneyToAddO = MoneyStringToMoney(money);
600 }
601 else
602 {
603 moneyToAddO = Acore::StringTo<int32>(money);
604 }
605
606 if (!moneyToAddO)
607 {
608 return false;
609 }
610
611 int32 moneyToAdd = *moneyToAddO;
612 uint32 targetMoney = target->GetMoney();
613
614 if (moneyToAdd < 0)
615 {
616 int32 newmoney = int32(targetMoney) + moneyToAdd;
617
618 LOG_DEBUG("chat.system", handler->GetAcoreString(LANG_CURRENT_MONEY), targetMoney, moneyToAdd, newmoney);
619 if (newmoney <= 0)
620 {
621 handler->PSendSysMessage(LANG_YOU_TAKE_ALL_MONEY, handler->GetNameLink(target));
622 if (handler->needReportToTarget(target))
624
625 target->SetMoney(0);
626 }
627 else
628 {
629 if (newmoney > MAX_MONEY_AMOUNT)
630 newmoney = MAX_MONEY_AMOUNT;
631
632 handler->PSendSysMessage(LANG_YOU_TAKE_MONEY, std::abs(moneyToAdd), handler->GetNameLink(target));
633 if (handler->needReportToTarget(target))
634 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_TAKEN, handler->GetNameLink(), std::abs(moneyToAdd));
635 target->SetMoney(newmoney);
636 }
637 }
638 else
639 {
640 handler->PSendSysMessage(LANG_YOU_GIVE_MONEY, moneyToAdd, handler->GetNameLink(target));
641 if (handler->needReportToTarget(target))
642 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_MONEY_GIVEN, handler->GetNameLink(), moneyToAdd);
643
644 if (moneyToAdd >= MAX_MONEY_AMOUNT)
645 moneyToAdd = MAX_MONEY_AMOUNT;
646
647 if (targetMoney >= uint32(MAX_MONEY_AMOUNT) - moneyToAdd)
648 moneyToAdd -= targetMoney;
649
650 target->ModifyMoney(moneyToAdd);
651 }
652
653 LOG_DEBUG("chat.system", handler->GetAcoreString(LANG_NEW_MONEY), targetMoney, moneyToAdd, target->GetMoney());
654
655 return true;
656 }
std::optional< T > Optional
Optional helper class to wrap optional values within.
Definition: Optional.h:24
Optional< int32 > MoneyStringToMoney(std::string_view moneyString)
Definition: Util.cpp:108
std::int32_t int32
Definition: Define.h:103
@ LANG_CURRENT_MONEY
Definition: Language.h:189
@ LANG_YOU_TAKE_ALL_MONEY
Definition: Language.h:190
@ LANG_YOURS_MONEY_TAKEN
Definition: Language.h:193
@ LANG_YOURS_ALL_MONEY_GONE
Definition: Language.h:191
@ LANG_YOU_TAKE_MONEY
Definition: Language.h:192
@ LANG_YOURS_MONEY_GIVEN
Definition: Language.h:195
@ LANG_NEW_MONEY
Definition: Language.h:198
@ LANG_YOU_GIVE_MONEY
Definition: Language.h:194
#define MAX_MONEY_AMOUNT
Definition: Player.h:930
bool ModifyMoney(int32 amount, bool sendError=true)
Definition: Player.cpp:11511
uint32 GetMoney() const
Definition: Player.h:1596
void SetMoney(uint32 value)
Definition: Player.h:1606

References ChatHandler::GetAcoreString(), Player::GetMoney(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), ChatHandler::HasLowerSecurity(), LANG_CURRENT_MONEY, LANG_NEW_MONEY, LANG_NO_CHAR_SELECTED, LANG_YOU_GIVE_MONEY, LANG_YOU_TAKE_ALL_MONEY, LANG_YOU_TAKE_MONEY, LANG_YOURS_ALL_MONEY_GONE, LANG_YOURS_MONEY_GIVEN, LANG_YOURS_MONEY_TAKEN, LOG_DEBUG, MAX_MONEY_AMOUNT, Player::ModifyMoney(), MoneyStringToMoney(), ChatHandler::needReportToTarget(), ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), and Player::SetMoney().

Referenced by GetCommands().

◆ HandleModifyMountCommand()

static bool modify_commandscript::HandleModifyMountCommand ( ChatHandler handler,
uint32  creatureDisplayID,
Optional< float >  speed 
)
inlinestatic
527 {
528 if (!sCreatureDisplayInfoStore.LookupEntry(creatureDisplayID))
529 {
531 return false;
532 }
533
534 Player* target = handler->getSelectedPlayerOrSelf();
535 if (!target)
536 {
538 return false;
539 }
540
541 // check online security
542 if (handler->HasLowerSecurity(target, ObjectGuid::Empty))
543 {
544 return false;
545 }
546
547 float _speed = speed ? *speed : 1.0f;
548
549 if (!CheckModifySpeed(handler, target, _speed, 0.1f, 50.0f))
550 {
551 return false;
552 }
553
555
556 target->Mount(creatureDisplayID);
557 target->SetSpeed(MOVE_RUN, _speed, true);
558 target->SetSpeed(MOVE_FLIGHT, _speed, true);
559 return true;
560 }
DBCStorage< CreatureDisplayInfoEntry > sCreatureDisplayInfoStore(CreatureDisplayInfofmt)
@ LANG_NO_MOUNT
Definition: Language.h:185
@ LANG_YOU_GIVE_MOUNT
Definition: Language.h:186
@ LANG_MOUNT_GIVED
Definition: Language.h:187
static ObjectGuid const Empty
Definition: ObjectGuid.h:120
void Mount(uint32 mount, uint32 vehicleId=0, uint32 creatureEntry=0)
Definition: Unit.cpp:13422

References CheckModifySpeed(), ObjectGuid::Empty, ChatHandler::getSelectedPlayerOrSelf(), ChatHandler::HasLowerSecurity(), LANG_MOUNT_GIVED, LANG_NO_CHAR_SELECTED, LANG_NO_MOUNT, LANG_YOU_GIVE_MOUNT, Unit::Mount(), MOVE_FLIGHT, MOVE_RUN, NotifyModification(), sCreatureDisplayInfoStore, ChatHandler::SendErrorMessage(), and Unit::SetSpeed().

Referenced by GetCommands().

◆ HandleModifyPhaseCommand()

static bool modify_commandscript::HandleModifyPhaseCommand ( ChatHandler handler,
uint32  phaseMask 
)
inlinestatic
889 {
890 Unit* target = handler->getSelectedUnit();
891 if (!target)
892 {
893 target = handler->GetSession()->GetPlayer();
894 }
895 else if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
896 {
897 return false;
898 }
899
900 target->SetPhaseMask(phaseMask, true);
901 return true;
902 }
WorldSession * GetSession()
Definition: Chat.h:244
void SetPhaseMask(uint32 newPhaseMask, bool update) override
Definition: Unit.cpp:19005
Player * GetPlayer() const
Definition: WorldSession.h:362

References WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), ChatHandler::HasLowerSecurity(), Object::IsPlayer(), Unit::SetPhaseMask(), and Object::ToPlayer().

Referenced by GetCommands().

◆ HandleModifyRageCommand()

static bool modify_commandscript::HandleModifyRageCommand ( ChatHandler handler,
int32  ragePoints 
)
inlinestatic
204 {
205 Player* target = handler->getSelectedPlayer();
206
207 if (!CheckModifyInt32(handler, target, ragePoints))
208 {
209 return false;
210 }
211
212 ragePoints *= 10;
213
214 handler->PSendSysMessage(LANG_YOU_CHANGE_RAGE, handler->GetNameLink(target), ragePoints / 10, ragePoints / 10);
215
216 if (handler->needReportToTarget(target))
217 {
218 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RAGE_CHANGED, handler->GetNameLink(), ragePoints / 10, ragePoints / 10);
219 }
220
221 target->SetMaxPower(POWER_RAGE, ragePoints);
222 target->SetPower(POWER_RAGE, ragePoints);
223
224 return true;
225 }
@ LANG_YOU_CHANGE_RAGE
Definition: Language.h:159
@ LANG_YOURS_RAGE_CHANGED
Definition: Language.h:160
@ POWER_RAGE
Definition: SharedDefines.h:270

References CheckModifyInt32(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), LANG_YOU_CHANGE_RAGE, LANG_YOURS_RAGE_CHANGED, ChatHandler::needReportToTarget(), POWER_RAGE, ChatHandler::PSendSysMessage(), Unit::SetMaxPower(), and Unit::SetPower().

Referenced by GetCommands().

◆ HandleModifyRepCommand()

static bool modify_commandscript::HandleModifyRepCommand ( ChatHandler handler,
uint32  factionId,
Variant< int32, std::string >  rank,
Optional< int32 delta 
)
inlinestatic
738 {
739 Player* target = handler->getSelectedPlayer();
740 if (!target)
741 {
743 return false;
744 }
745
746 // check online security
747 if (handler->HasLowerSecurity(target))
748 {
749 return false;
750 }
751
752 int32 amount = 0;
753
754 if (rank.holds_alternative<std::string>())
755 {
756 std::string rankStr = rank.get<std::string>();
757 std::wstring wrankStr;
758
759 if (!Utf8toWStr(rankStr, wrankStr))
760 {
761 return false;
762 }
763
764 wstrToLower(wrankStr);
765
766 int32 r = 0;
767 amount = -42000;
768
769 for (; r < MAX_REPUTATION_RANK; ++r)
770 {
771 std::string rank = handler->GetAcoreString(ReputationRankStrIndex[r]);
772 if (rank.empty())
773 continue;
774
775 std::wstring wrank;
776 if (!Utf8toWStr(rank, wrank))
777 continue;
778
779 wstrToLower(wrank);
780
781 if (wrank.substr(0, wrankStr.size()) == wrankStr)
782 {
783 if (delta)
784 {
785 if (*delta < 0 || (*delta > ReputationMgr::PointsInRank[r] - 1))
786 {
788 return false;
789 }
790
791 amount += *delta;
792 }
793
794 break;
795 }
796
797 amount += ReputationMgr::PointsInRank[r];
798 }
799
800 if (r >= MAX_REPUTATION_RANK)
801 {
802 handler->SendErrorMessage(LANG_COMMAND_FACTION_INVPARAM, rankStr.c_str());
803 return false;
804 }
805 }
806 else
807 {
808 amount = rank.get<int32>();
809 }
810
811 if (!amount)
812 {
813 return false;
814 }
815
816 FactionEntry const* factionEntry = sFactionStore.LookupEntry(factionId);
817
818 if (!factionEntry)
819 {
821 return false;
822 }
823
824 if (factionEntry->reputationListID < 0)
825 {
826 handler->SendErrorMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->name[handler->GetSessionDbcLocale()], factionId);
827 return false;
828 }
829
830 target->GetReputationMgr().SetOneFactionReputation(factionEntry, float(amount), false);
831 target->GetReputationMgr().SendState(target->GetReputationMgr().GetState(factionEntry));
832
833 handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->name[handler->GetSessionDbcLocale()], factionId,
834 handler->GetNameLink(target), target->GetReputationMgr().GetReputation(factionEntry));
835 return true;
836 }
bool Utf8toWStr(char const *utf8str, std::size_t csize, wchar_t *wstr, std::size_t &wsize)
Definition: Util.cpp:281
void wstrToLower(std::wstring &str)
Definition: Util.cpp:382
constexpr std::array< uint32, MAX_REPUTATION_RANK > ReputationRankStrIndex
Definition: ReputationMgr.h:28
DBCStorage< FactionEntry > sFactionStore(FactionEntryfmt)
@ LANG_COMMAND_FACTION_UNKNOWN
Definition: Language.h:349
@ LANG_COMMAND_FACTION_DELTA
Definition: Language.h:351
@ LANG_COMMAND_FACTION_NOREP_ERROR
Definition: Language.h:367
@ LANG_COMMAND_MODIFY_REP
Definition: Language.h:346
@ LANG_COMMAND_FACTION_INVPARAM
Definition: Language.h:350
#define MAX_REPUTATION_RANK
Definition: SharedDefines.h:245
virtual LocaleConstant GetSessionDbcLocale() const
Definition: Chat.cpp:872
constexpr decltype(auto) get()
Definition: ChatCommandTags.h:288
constexpr bool holds_alternative() const
Definition: ChatCommandTags.h:302
ReputationMgr & GetReputationMgr()
Definition: Player.h:2105
static const int32 PointsInRank[MAX_REPUTATION_RANK]
Definition: ReputationMgr.h:67
void SendState(FactionState const *faction)
Definition: ReputationMgr.cpp:178
int32 GetReputation(uint32 faction_id) const
Definition: ReputationMgr.cpp:78
bool SetOneFactionReputation(FactionEntry const *factionEntry, float standing, bool incremental, Optional< ReputationRank > repMaxCap={ })
Public for chat command needs.
Definition: ReputationMgr.cpp:378
FactionState const * GetState(FactionEntry const *factionEntry) const
Definition: ReputationMgr.h:82
Definition: DBCStructure.h:907
char const * name[16]
Definition: DBCStructure.h:919
int32 reputationListID
Definition: DBCStructure.h:909

References Acore::ChatCommands::Variant< T1, Ts >::get(), ChatHandler::GetAcoreString(), ChatHandler::GetNameLink(), ReputationMgr::GetReputation(), Player::GetReputationMgr(), ChatHandler::getSelectedPlayer(), ChatHandler::GetSessionDbcLocale(), ReputationMgr::GetState(), ChatHandler::HasLowerSecurity(), Acore::ChatCommands::Variant< T1, Ts >::holds_alternative(), LANG_COMMAND_FACTION_DELTA, LANG_COMMAND_FACTION_INVPARAM, LANG_COMMAND_FACTION_NOREP_ERROR, LANG_COMMAND_FACTION_UNKNOWN, LANG_COMMAND_MODIFY_REP, LANG_PLAYER_NOT_FOUND, MAX_REPUTATION_RANK, FactionEntry::name, ReputationMgr::PointsInRank, ChatHandler::PSendSysMessage(), FactionEntry::reputationListID, ReputationRankStrIndex, ChatHandler::SendErrorMessage(), ReputationMgr::SendState(), ReputationMgr::SetOneFactionReputation(), sFactionStore, Utf8toWStr(), and wstrToLower().

Referenced by GetCommands().

◆ HandleModifyRunicPowerCommand()

static bool modify_commandscript::HandleModifyRunicPowerCommand ( ChatHandler handler,
int32  runePoints 
)
inlinestatic
229 {
230 Player* target = handler->getSelectedPlayer();
231
232 if (!CheckModifyInt32(handler, target, runePoints))
233 {
234 return false;
235 }
236
237 runePoints *= 10;
238
239 handler->PSendSysMessage(LANG_YOU_CHANGE_RUNIC_POWER, handler->GetNameLink(target), runePoints / 10, runePoints / 10);
240
241 if (handler->needReportToTarget(target))
242 {
243 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_RUNIC_POWER_CHANGED, handler->GetNameLink(), runePoints / 10, runePoints / 10);
244 }
245
246 target->SetMaxPower(POWER_RUNIC_POWER, runePoints);
247 target->SetPower(POWER_RUNIC_POWER, runePoints);
248
249 return true;
250 }
@ LANG_YOU_CHANGE_RUNIC_POWER
Definition: Language.h:213
@ LANG_YOURS_RUNIC_POWER_CHANGED
Definition: Language.h:214
@ POWER_RUNIC_POWER
Definition: SharedDefines.h:275

References CheckModifyInt32(), ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), LANG_YOU_CHANGE_RUNIC_POWER, LANG_YOURS_RUNIC_POWER_CHANGED, ChatHandler::needReportToTarget(), POWER_RUNIC_POWER, ChatHandler::PSendSysMessage(), Unit::SetMaxPower(), and Unit::SetPower().

Referenced by GetCommands().

◆ HandleModifyScaleCommand()

static bool modify_commandscript::HandleModifyScaleCommand ( ChatHandler handler,
float  scale 
)
inlinestatic
495 {
496 if (scale > 10.0f || scale < 0.1f)
497 {
499 return false;
500 }
501
502 Unit* target = handler->getSelectedUnit();
503 if (!target)
504 {
506 return false;
507 }
508
509 if (Player* player = target->ToPlayer())
510 {
511 // check online security
512 if (handler->HasLowerSecurity(player))
513 return false;
514
515 handler->PSendSysMessage(LANG_YOU_CHANGE_SIZE, scale, handler->GetNameLink(player));
516 if (handler->needReportToTarget(player))
517 ChatHandler(player->GetSession()).PSendSysMessage(LANG_YOURS_SIZE_CHANGED, handler->GetNameLink(), scale);
518 }
519
520 target->SetObjectScale(scale);
521
522 return true;
523 }
@ LANG_YOU_CHANGE_SIZE
Definition: Language.h:183
@ LANG_YOURS_SIZE_CHANGED
Definition: Language.h:184
@ LANG_SELECT_CHAR_OR_CREATURE
Definition: Language.h:31
virtual void SetObjectScale(float scale)
Definition: Object.h:116

References ChatHandler::GetNameLink(), ChatHandler::getSelectedUnit(), ChatHandler::HasLowerSecurity(), LANG_BAD_VALUE, LANG_SELECT_CHAR_OR_CREATURE, LANG_YOU_CHANGE_SIZE, LANG_YOURS_SIZE_CHANGED, ChatHandler::needReportToTarget(), ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), Object::SetObjectScale(), and Object::ToPlayer().

Referenced by GetCommands().

◆ HandleModifySpeedCommand()

static bool modify_commandscript::HandleModifySpeedCommand ( ChatHandler handler,
float  speed 
)
inlinestatic
439 {
440 Player* target = handler->getSelectedPlayerOrSelf();
441 if (CheckModifySpeed(handler, target, speed, 0.1f, 50.0f))
442 {
444 target->SetSpeedRate(MOVE_RUN, speed);
445 return true;
446 }
447
448 return false;
449 }
@ LANG_YOU_CHANGE_SPEED
Definition: Language.h:174
@ LANG_YOURS_SPEED_CHANGED
Definition: Language.h:175

References CheckModifySpeed(), ChatHandler::getSelectedPlayerOrSelf(), LANG_YOU_CHANGE_SPEED, LANG_YOURS_SPEED_CHANGED, MOVE_RUN, NotifyModification(), and Unit::SetSpeedRate().

Referenced by GetCommands().

◆ HandleModifySpellCommand()

static bool modify_commandscript::HandleModifySpellCommand ( ChatHandler handler,
uint8  spellFlatID,
uint8  op,
uint16  val,
Optional< uint16 mark 
)
inlinestatic
313 {
314 Player* target = handler->getSelectedPlayer();
315 if (!target)
316 {
318 return false;
319 }
320
321 // check online security
322 if (handler->HasLowerSecurity(target))
323 {
324 return false;
325 }
326
327 handler->PSendSysMessage(LANG_YOU_CHANGE_SPELLFLATID, spellFlatID, val, mark ? *mark : 65535, handler->GetNameLink(target));
328 if (handler->needReportToTarget(target))
329 {
330 ChatHandler(target->GetSession()).PSendSysMessage(LANG_YOURS_SPELLFLATID_CHANGED, handler->GetNameLink(), spellFlatID, val, mark ? *mark : 65535);
331 }
332
333 WorldPacket data(SMSG_SET_FLAT_SPELL_MODIFIER, (1 + 1 + 2 + 2));
334 data << uint8(spellFlatID);
335 data << uint8(op);
336 data << uint16(val);
337 data << uint16(mark ? *mark : 65535);
338 target->GetSession()->SendPacket(&data);
339
340 return true;
341 }
std::uint8_t uint8
Definition: Define.h:109
std::uint16_t uint16
Definition: Define.h:108
@ LANG_YOURS_SPELLFLATID_CHANGED
Definition: Language.h:166
@ LANG_YOU_CHANGE_SPELLFLATID
Definition: Language.h:165
@ SMSG_SET_FLAT_SPELL_MODIFIER
Definition: Opcodes.h:644
Definition: WorldPacket.h:27
void SendPacket(WorldPacket const *packet)
Send a packet to the client.
Definition: WorldSession.cpp:214

References ChatHandler::GetNameLink(), ChatHandler::getSelectedPlayer(), Player::GetSession(), ChatHandler::HasLowerSecurity(), LANG_NO_CHAR_SELECTED, LANG_YOU_CHANGE_SPELLFLATID, LANG_YOURS_SPELLFLATID_CHANGED, ChatHandler::needReportToTarget(), ChatHandler::PSendSysMessage(), ChatHandler::SendErrorMessage(), WorldSession::SendPacket(), and SMSG_SET_FLAT_SPELL_MODIFIER.

Referenced by GetCommands().

◆ HandleModifyStandStateCommand()

static bool modify_commandscript::HandleModifyStandStateCommand ( ChatHandler handler,
uint32  anim 
)
inlinestatic
906 {
908 return true;
909 }
@ UNIT_NPC_EMOTESTATE
Definition: UpdateFields.h:140
void SetUInt32Value(uint16 index, uint32 value)
Definition: Unit.cpp:21256

References WorldSession::GetPlayer(), ChatHandler::GetSession(), Unit::SetUInt32Value(), and UNIT_NPC_EMOTESTATE.

Referenced by GetCommands().

◆ HandleModifySwimCommand()

static bool modify_commandscript::HandleModifySwimCommand ( ChatHandler handler,
float  swimSpeed 
)
inlinestatic
453 {
454 Player* target = handler->getSelectedPlayerOrSelf();
455 if (CheckModifySpeed(handler, target, swimSpeed, 0.1f, 50.0f))
456 {
458 target->SetSpeedRate(MOVE_SWIM, swimSpeed);
459 return true;
460 }
461
462 return false;
463 }
@ LANG_YOURS_SWIM_SPEED_CHANGED
Definition: Language.h:177
@ LANG_YOU_CHANGE_SWIM_SPEED
Definition: Language.h:176

References CheckModifySpeed(), ChatHandler::getSelectedPlayerOrSelf(), LANG_YOU_CHANGE_SWIM_SPEED, LANG_YOURS_SWIM_SPEED_CHANGED, MOVE_SWIM, NotifyModification(), and Unit::SetSpeedRate().

Referenced by GetCommands().

◆ HandleModifyTalentCommand()

static bool modify_commandscript::HandleModifyTalentCommand ( ChatHandler handler,
uint32  talentPoints 
)
inlinestatic
345 {
346 if (!talentPoints)
347 {
348 return false;
349 }
350
351 Unit* target = handler->getSelectedUnit();
352 if (!target)
353 {
355 return false;
356 }
357
358 if (target->IsPlayer())
359 {
360 // check online security
361 if (handler->HasLowerSecurity(target->ToPlayer()))
362 {
363 return false;
364 }
365
366 target->ToPlayer()->SetFreeTalentPoints(talentPoints);
367 target->ToPlayer()->SendTalentsInfoData(false);
368 return true;
369 }
370 else if (target->IsPet())
371 {
372 Unit* owner = target->GetOwner();
373 if (owner && owner->IsPlayer() && ((Pet*)target)->IsPermanentPetFor(owner->ToPlayer()))
374 {
375 // check online security
376 if (handler->HasLowerSecurity(owner->ToPlayer()))
377 return false;
378 ((Pet*)target)->SetFreeTalentPoints(talentPoints);
379 owner->ToPlayer()->SendTalentsInfoData(true);
380 return true;
381 }
382 }
383
385 return false;
386 }
Definition: Pet.h:41
void SendTalentsInfoData(bool pet)
Definition: Player.cpp:14421
void SetFreeTalentPoints(uint32 points)
Definition: Player.cpp:3779
Unit * GetOwner() const
Definition: Unit.cpp:10562
bool IsPet() const
Definition: Unit.h:710

References Unit::GetOwner(), ChatHandler::getSelectedUnit(), ChatHandler::HasLowerSecurity(), Unit::IsPet(), Object::IsPlayer(), LANG_NO_CHAR_SELECTED, ChatHandler::SendErrorMessage(), Player::SendTalentsInfoData(), Player::SetFreeTalentPoints(), and Object::ToPlayer().

Referenced by GetCommands().

◆ HandleMorphMountCommand()

static bool modify_commandscript::HandleMorphMountCommand ( ChatHandler handler,
uint32  displayID 
)
inlinestatic
873 {
874 Player* target = handler->getSelectedPlayerOrSelf();
875
876 if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
877 return false;
878
879 if (!target->GetAuraEffectsByType(SPELL_AURA_MOUNTED).empty())
880 target->SetUInt32Value(UNIT_FIELD_MOUNTDISPLAYID, displayID);
881 else
882 return false;
883
884 return true;
885 }
@ UNIT_FIELD_MOUNTDISPLAYID
Definition: UpdateFields.h:126
@ SPELL_AURA_MOUNTED
Definition: SpellAuraDefines.h:141
AuraEffectList const & GetAuraEffectsByType(AuraType type) const
Definition: Unit.h:1362

References Unit::GetAuraEffectsByType(), ChatHandler::getSelectedPlayerOrSelf(), ChatHandler::HasLowerSecurity(), Object::IsPlayer(), Unit::SetUInt32Value(), SPELL_AURA_MOUNTED, Object::ToPlayer(), and UNIT_FIELD_MOUNTDISPLAYID.

Referenced by GetCommands().

◆ HandleMorphResetCommand()

static bool modify_commandscript::HandleMorphResetCommand ( ChatHandler handler)
inlinestatic
857 {
858 Unit* target = handler->getSelectedUnit();
859 if (!target)
860 {
861 target = handler->GetSession()->GetPlayer();
862 }
863 else if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
864 {
865 return false;
866 }
867
868 target->DeMorph();
869 return true;
870 }
void DeMorph()
Definition: Unit.cpp:4331

References Unit::DeMorph(), WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), ChatHandler::HasLowerSecurity(), Object::IsPlayer(), and Object::ToPlayer().

Referenced by GetCommands().

◆ HandleMorphTargetCommand()

static bool modify_commandscript::HandleMorphTargetCommand ( ChatHandler handler,
uint32  displayID 
)
inlinestatic
839 {
840 Unit* target = handler->getSelectedUnit();
841
842 if (!target)
843 {
844 target = handler->GetSession()->GetPlayer();
845 }
846 else if (target->IsPlayer() && handler->HasLowerSecurity(target->ToPlayer())) // check online security
847 {
848 return false;
849 }
850
851 target->SetDisplayId(displayID);
852 return true;
853 }
virtual void SetDisplayId(uint32 modelId, float displayScale=1.f)
Definition: Unit.cpp:16718

References WorldSession::GetPlayer(), ChatHandler::getSelectedUnit(), ChatHandler::GetSession(), ChatHandler::HasLowerSecurity(), Object::IsPlayer(), Unit::SetDisplayId(), and Object::ToPlayer().

Referenced by GetCommands().

◆ NotifyModification()

template<typename... Args>
static void modify_commandscript::NotifyModification ( ChatHandler handler,
Unit target,
AcoreStrings  resourceMessage,
AcoreStrings  resourceReportMessage,
Args &&...  args 
)
inlinestatic
95 {
96 if (Player* player = target->ToPlayer())
97 {
98 handler->PSendSysMessage(resourceMessage, std::forward<Args>(args)..., handler->GetNameLink(player));
99
100 if (handler->needReportToTarget(player))
101 {
102 ChatHandler(player->GetSession()).PSendSysMessage(resourceReportMessage, handler->GetNameLink(), std::forward<Args>(args)...);
103 }
104 }
105 }

References ChatHandler::GetNameLink(), ChatHandler::needReportToTarget(), ChatHandler::PSendSysMessage(), and Object::ToPlayer().

Referenced by HandleModifyASpeedCommand(), HandleModifyBWalkCommand(), HandleModifyFlyCommand(), HandleModifyMountCommand(), HandleModifySpeedCommand(), and HandleModifySwimCommand().