[9934] Skinning related fixes

* Show skinning tooltip only after creature loot
  (when creature can be explcitly skinned).
* Allow reopen skinning loot if still have not looted items.
This commit is contained in:
VladimirMangos 2010-05-19 14:40:20 +04:00
parent cad8693819
commit d4f1b510ae
7 changed files with 52 additions and 19 deletions

View file

@ -370,6 +370,7 @@ void Creature::Update(uint32 diff)
m_respawnTime = 0; m_respawnTime = 0;
lootForPickPocketed = false; lootForPickPocketed = false;
lootForBody = false; lootForBody = false;
lootForSkin = false;
if(m_originalEntry != GetEntry()) if(m_originalEntry != GetEntry())
UpdateEntry(m_originalEntry); UpdateEntry(m_originalEntry);
@ -810,6 +811,38 @@ void Creature::AI_SendMoveToPacket(float x, float y, float z, uint32 time, Splin
SendMonsterMove(x, y, z, type, flags, time); SendMonsterMove(x, y, z, type, flags, time);
} }
void Creature::PrepareBodyLootState()
{
loot.clear();
// if have normal loot then prepare it access
if (!isAlive() && GetCreatureInfo()->lootid && !lootForBody)
{
SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
return;
}
// if not have normal loot allow skinning if need
if (!isAlive() && !lootForSkin)
{
lootForBody = true; // pass this loot mode
if (GetCreatureInfo()->SkinLootId)
{
if (LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId))
{
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
return;
}
}
}
RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
}
/** /**
* Return original player who tap creature, it can be different from player/group allowed to loot so not use it for loot code * Return original player who tap creature, it can be different from player/group allowed to loot so not use it for loot code
*/ */
@ -1330,10 +1363,6 @@ void Creature::setDeathState(DeathState s)
SetTargetGUID(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState) SetTargetGUID(0); // remove target selection in any cases (can be set at aura remove in Unit::setDeathState)
SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE); SetUInt32Value(UNIT_NPC_FLAGS, UNIT_NPC_FLAG_NONE);
if (!isPet() && GetCreatureInfo()->SkinLootId)
if (LootTemplates_Skinning.HaveLootFor(GetCreatureInfo()->SkinLootId))
SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_SKINNABLE);
if (canFly() && FallGround()) if (canFly() && FallGround())
return; return;

View file

@ -531,7 +531,9 @@ class MANGOS_DLL_SPEC Creature : public Unit
Loot loot; Loot loot;
bool lootForPickPocketed; bool lootForPickPocketed;
bool lootForBody; bool lootForBody;
bool lootForSkin;
void PrepareBodyLootState();
ObjectGuid GetLootRecipientGuid() const { return m_lootRecipientGuid; } ObjectGuid GetLootRecipientGuid() const { return m_lootRecipientGuid; }
uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; } uint32 GetLootGroupRecipientId() const { return m_lootGroupRecipientId; }
Player* GetLootRecipient() const; // use group cases as prefered Player* GetLootRecipient() const; // use group cases as prefered

View file

@ -442,12 +442,11 @@ void WorldSession::DoLootRelease(ObjectGuid lguid)
if (loot->isLooted()) if (loot->isLooted())
{ {
// skip pickpocketing loot for speed, skinning timer redunction is no-op in fact // for example skinning after normal loot
pCreature->PrepareBodyLootState();
if(!pCreature->isAlive()) if(!pCreature->isAlive())
pCreature->AllLootRemovedFromCorpse(); pCreature->AllLootRemovedFromCorpse();
pCreature->RemoveFlag(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
loot->clear();
} }
break; break;
} }

View file

@ -7886,8 +7886,16 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
// possible only if creature->lootForBody && loot->empty() at spell cast check // possible only if creature->lootForBody && loot->empty() at spell cast check
if (loot_type == LOOT_SKINNING) if (loot_type == LOOT_SKINNING)
{ {
loot->clear(); if (!creature->lootForSkin)
loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, this, false); {
creature->lootForSkin = true;
loot->clear();
loot->FillLoot(creature->GetCreatureInfo()->SkinLootId, LootTemplates_Skinning, this, false);
// let reopen skinning loot if will closed.
if (!loot->empty())
creature->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
}
} }
// set group rights only for loot_type != LOOT_SKINNING // set group rights only for loot_type != LOOT_SKINNING
else else

View file

@ -4805,7 +4805,7 @@ SpellCastResult Spell::CheckCast(bool strict)
return SPELL_FAILED_TARGET_UNSKINNABLE; return SPELL_FAILED_TARGET_UNSKINNABLE;
Creature* creature = (Creature*)m_targets.getUnitTarget(); Creature* creature = (Creature*)m_targets.getUnitTarget();
if ( creature->GetCreatureType() != CREATURE_TYPE_CRITTER && ( !creature->lootForBody || !creature->loot.empty() ) ) if ( creature->GetCreatureType() != CREATURE_TYPE_CRITTER && ( !creature->lootForBody || creature->lootForSkin || !creature->loot.empty() ) )
{ {
return SPELL_FAILED_TARGET_NOT_LOOTED; return SPELL_FAILED_TARGET_NOT_LOOTED;
} }

View file

@ -566,9 +566,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
pVictim->SetHealth(0); pVictim->SetHealth(0);
// allow loot only if has loot_id in creature_template // allow loot only if has loot_id in creature_template
CreatureInfo const* cInfo = ((Creature*)pVictim)->GetCreatureInfo(); ((Creature*)pVictim)->PrepareBodyLootState();
if(cInfo && cInfo->lootid)
pVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
// some critters required for quests (need normal entry instead possible heroic in any cases) // some critters required for quests (need normal entry instead possible heroic in any cases)
if(GetTypeId() == TYPEID_PLAYER) if(GetTypeId() == TYPEID_PLAYER)
@ -809,10 +807,7 @@ uint32 Unit::DealDamage(Unit *pVictim, uint32 damage, CleanDamage const* cleanDa
{ {
cVictim->DeleteThreatList(); cVictim->DeleteThreatList();
// only lootable if it has loot or can drop gold // only lootable if it has loot or can drop gold
if(cVictim->GetCreatureInfo()->lootid || cVictim->GetCreatureInfo()->maxgold > 0) cVictim->PrepareBodyLootState();
cVictim->SetUInt32Value(UNIT_DYNAMIC_FLAGS, UNIT_DYNFLAG_LOOTABLE);
else
cVictim->lootForBody = true; // needed for skinning
} }
// Call creature just died function // Call creature just died function
if (cVictim->AI()) if (cVictim->AI())

View file

@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__ #ifndef __REVISION_NR_H__
#define __REVISION_NR_H__ #define __REVISION_NR_H__
#define REVISION_NR "9933" #define REVISION_NR "9934"
#endif // __REVISION_NR_H__ #endif // __REVISION_NR_H__