mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-02 02:23:49 +00:00
feat(Core/Unit): New helper IsClass and script hook OnPlayerIsClass (#18243)
* Class Comparison Logic Encapsulation - Parity * Add Context to IsClass * Add Unit IsClass script hook * Replace additional getClass with IsClass * Update CanUseItem to replace getClass with IsClass * Add separate context for pet vs ability * Change Create to Init since not all referenced contexts are creation * Align spacing in ClassContext * Drop context on LFGManager max power * Update IsClass context that wraps around Missle Barrage * Rename context for swapping weapons * Be more specific than CLASS_CONTEXT_TALENT * Remove duplicate context * Moved IsClass Hook to Player * Removed unused parameter in virtual base function * Added maybe_unused to IsClass virtual in order to compile To match the override signature, the virtual base needs to include the parameter in question, so using [maybe_unused] to signal to the compiler to allow it * Remove extra blank line * Add ABILITY_REACTIVE context * Add context for PET_CHARM * Remove explicit nullopt check per review * Code Readability - Change if to if else in pet Due to the return pattern, this doesn't change functionality in any way * Add OnPlayer to disambiguate --------- Co-authored-by: NathanHandley <nathanhandley@protonmail.com>
This commit is contained in:
@@ -184,7 +184,7 @@ void WorldSession::HandleBattlemasterJoinOpcode(WorldPacket& recvData)
|
||||
err = ERR_BATTLEGROUND_QUEUED_FOR_RATED;
|
||||
}
|
||||
// don't let Death Knights join BG queues when they are not allowed to be teleported yet
|
||||
else if (_player->getClass() == CLASS_DEATH_KNIGHT && _player->GetMapId() == 609 && !_player->IsGameMaster() && !_player->HasSpell(50977))
|
||||
else if (_player->IsClass(CLASS_DEATH_KNIGHT, CLASS_CONTEXT_TELEPORT) && _player->GetMapId() == 609 && !_player->IsGameMaster() && !_player->HasSpell(50977))
|
||||
{
|
||||
err = ERR_BATTLEGROUND_NONE;
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recvData)
|
||||
{
|
||||
Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
|
||||
|
||||
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
|
||||
bool lootAllowed = creature && creature->IsAlive() == (player->IsClass(CLASS_ROGUE, CLASS_CONTEXT_ABILITY) && creature->loot.loot_type == LOOT_PICKPOCKETING);
|
||||
if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
|
||||
{
|
||||
player->SendLootError(lguid, lootAllowed ? LOOT_ERROR_TOO_FAR : LOOT_ERROR_DIDNT_KILL);
|
||||
@@ -162,7 +162,7 @@ void WorldSession::HandleLootMoneyOpcode(WorldPacket& /*recvData*/)
|
||||
case HighGuid::Vehicle:
|
||||
{
|
||||
Creature* creature = player->GetMap()->GetCreature(guid);
|
||||
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
|
||||
bool lootAllowed = creature && creature->IsAlive() == (player->IsClass(CLASS_ROGUE, CLASS_CONTEXT_ABILITY) && creature->loot.loot_type == LOOT_PICKPOCKETING);
|
||||
if (lootAllowed && creature->IsWithinDistInMap(player, INTERACTION_DISTANCE))
|
||||
{
|
||||
loot = &creature->loot;
|
||||
@@ -382,7 +382,7 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
|
||||
{
|
||||
Creature* creature = GetPlayer()->GetMap()->GetCreature(lguid);
|
||||
|
||||
bool lootAllowed = creature && creature->IsAlive() == (player->getClass() == CLASS_ROGUE && creature->loot.loot_type == LOOT_PICKPOCKETING);
|
||||
bool lootAllowed = creature && creature->IsAlive() == (player->IsClass(CLASS_ROGUE, CLASS_CONTEXT_ABILITY) && creature->loot.loot_type == LOOT_PICKPOCKETING);
|
||||
if (!lootAllowed || !creature->IsWithinDistInMap(_player, INTERACTION_DISTANCE))
|
||||
return;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user