fix(Core/Spells): Remove all hardcoded restrictions for pick pocket sp… (#14788)

Co-authored-by: Shauren <shauren.trinity@gmail.com>
This commit is contained in:
Skjalf
2023-01-29 12:12:21 -03:00
committed by GitHub
parent b3d4d36398
commit 2aeeee9c83
7 changed files with 34 additions and 14 deletions

View File

@@ -7878,7 +7878,7 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
if (loot_type == LOOT_PICKPOCKETING)
{
if (loot->loot_type != LOOT_PICKPOCKETING)
if (!loot || loot->loot_type != LOOT_PICKPOCKETING)
{
if (creature->CanGeneratePickPocketLoot())
{

View File

@@ -13778,9 +13778,9 @@ bool Unit::isTargetableForAttack(bool checkFakeDeath, Unit const* byWho) const
return !HasUnitState(UNIT_STATE_UNATTACKABLE) && (!checkFakeDeath || !HasUnitState(UNIT_STATE_DIED));
}
bool Unit::IsValidAttackTarget(Unit const* target) const
bool Unit::IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell) const
{
return _IsValidAttackTarget(target, nullptr);
return _IsValidAttackTarget(target, bySpell);
}
// function based on function Unit::CanAttack from 13850 client

View File

@@ -1713,7 +1713,7 @@ public:
bool isTargetableForAttack(bool checkFakeDeath = true, Unit const* byWho = nullptr) const;
bool IsValidAttackTarget(Unit const* target) const;
bool IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell = nullptr) const;
bool _IsValidAttackTarget(Unit const* target, SpellInfo const* bySpell, WorldObject const* obj = nullptr) const;
bool IsValidAssistTarget(Unit const* target) const;

View File

@@ -2719,13 +2719,7 @@ void Spell::EffectPickPocket(SpellEffIndex /*effIndex*/)
if (m_caster->GetTypeId() != TYPEID_PLAYER)
return;
// victim must be creature and attackable
if (!unitTarget || unitTarget->GetTypeId() != TYPEID_UNIT || m_caster->IsFriendlyTo(unitTarget))
return;
// victim have to be alive and humanoid or undead
if (unitTarget->IsAlive() && (unitTarget->GetCreatureTypeMask() &CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) != 0)
m_caster->ToPlayer()->SendLoot(unitTarget->GetGUID(), LOOT_PICKPOCKETING);
m_caster->ToPlayer()->SendLoot(unitTarget->GetGUID(), LOOT_PICKPOCKETING);
}
void Spell::EffectAddFarsight(SpellEffIndex effIndex)

View File

@@ -19,6 +19,7 @@
#include "Chat.h"
#include "ConditionMgr.h"
#include "DBCStores.h"
#include "LootMgr.h"
#include "Player.h"
#include "ScriptMgr.h"
#include "Spell.h"
@@ -1777,11 +1778,13 @@ SpellCastResult SpellInfo::CheckTarget(Unit const* caster, WorldObject const* ta
if (targetCreature->hasLootRecipient() && !targetCreature->isTappedBy(caster->ToPlayer()))
return SPELL_FAILED_CANT_CAST_ON_TAPPED;
if (AttributesCu & SPELL_ATTR0_CU_PICKPOCKET)
if (HasAttribute(SPELL_ATTR0_CU_PICKPOCKET))
{
if (unitTarget->GetTypeId() == TYPEID_PLAYER)
Creature const* targetCreature = unitTarget->ToCreature();
if (!targetCreature)
return SPELL_FAILED_BAD_TARGETS;
else if ((unitTarget->GetCreatureTypeMask() & CREATURE_TYPEMASK_HUMANOID_OR_UNDEAD) == 0)
if (!LootTemplates_Pickpocketing.HaveLootFor(targetCreature->GetCreatureTemplate()->pickpocketLootId))
return SPELL_FAILED_TARGET_NO_POCKETS;
}