Skip to content

Commit

Permalink
Fix skinning distance check.
Browse files Browse the repository at this point in the history
  • Loading branch information
ratkosrb committed Jun 5, 2024
1 parent b54215a commit 686fdad
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 9 deletions.
22 changes: 20 additions & 2 deletions src/game/Handlers/LootHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,30 @@ void WorldSession::HandleAutostoreLootItemOpcode(WorldPacket& recv_data)

bool ok_loot = pCreature && pCreature->IsAlive() == (player->GetClass() == CLASS_ROGUE && pCreature->lootForPickPocketed);

if (!ok_loot || !pCreature->IsWithinDistInMap(_player, _player->GetMaxLootDistance(pCreature), true, SizeFactor::None))
if (!ok_loot)
{
player->SendLootRelease(lguid);
player->SendLootError(lguid, LOOT_ERROR_DIDNT_KILL);
return;
}

// skinning uses the spell range which is 5 yards
if (pCreature->lootForSkin)
{
if (!pCreature->IsWithinCombatDistInMap(player, INTERACTION_DISTANCE + 1.25f))
{
player->SendLootError(lguid, LOOT_ERROR_TOO_FAR);
return;
}
}
else
{
if (!pCreature->IsWithinDistInMap(_player, _player->GetMaxLootDistance(pCreature), true, SizeFactor::None))
{
player->SendLootError(lguid, LOOT_ERROR_TOO_FAR);
return;
}
}

loot = &pCreature->loot;
break;
}
Expand Down
5 changes: 3 additions & 2 deletions src/game/Objects/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8317,11 +8317,12 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type, Player const* pVictim
// must be in range and creature must be alive for pickpocket and must be dead for another loot
if (!creature || creature->IsAlive() != (loot_type == LOOT_PICKPOCKETING))
{
SendLootRelease(guid);
SendLootError(guid, LOOT_ERROR_DIDNT_KILL);
return;
}

if (!creature->IsWithinDistInMap(this, GetMaxLootDistance(creature), true, SizeFactor::None))
// skinning range already checked during spell cast
if (loot_type != LOOT_SKINNING && !creature->IsWithinDistInMap(this, GetMaxLootDistance(creature), true, SizeFactor::None))
{
SendLootError(guid, LOOT_ERROR_TOO_FAR);
return;
Expand Down
5 changes: 0 additions & 5 deletions src/game/Spells/Spell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6567,11 +6567,6 @@ SpellCastResult Spell::CheckCast(bool strict)
if (!creature->IsSkinnableBy(m_caster->ToPlayer()))
return SPELL_FAILED_TARGET_NOT_LOOTED;

// If the player isn't in loot range, the skins are lost forever.
// This only happens on large mobs with disjointed models (i.e. Devilsaurs).
if (!creature->IsWithinDistInMap(m_caster, INTERACTION_DISTANCE))
return SPELL_FAILED_OUT_OF_RANGE;

int32 skillValue = ((Player*)m_caster)->GetSkillValue(SKILL_SKINNING);
int32 TargetLevel = m_targets.getUnitTarget()->GetLevel();
int32 ReqValue = (skillValue < 100 ? (TargetLevel - 10) * 10 : TargetLevel * 5);
Expand Down

0 comments on commit 686fdad

Please sign in to comment.