mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Loot: Set loot dungeon encounter id before generating
This commit is contained in:
@@ -521,13 +521,7 @@ void BossAI::_JustDied()
|
||||
summons.DespawnAll();
|
||||
scheduler.CancelAll();
|
||||
if (instance)
|
||||
{
|
||||
if (me->m_loot)
|
||||
if (DungeonEncounterEntry const* dungeonEncounter = instance->GetBossDungeonEncounter(_bossId))
|
||||
me->m_loot->SetDungeonEncounterId(dungeonEncounter->ID);
|
||||
|
||||
instance->SetBossState(_bossId, DONE);
|
||||
}
|
||||
}
|
||||
|
||||
void BossAI::_JustReachedHome()
|
||||
|
||||
@@ -336,6 +336,8 @@ class TC_GAME_API BossAI : public ScriptedAI
|
||||
|
||||
bool CanAIAttack(Unit const* target) const override;
|
||||
|
||||
uint32 GetBossId() const { return _bossId; }
|
||||
|
||||
protected:
|
||||
void _Reset();
|
||||
void _JustEngagedWith(Unit* who);
|
||||
|
||||
@@ -10657,6 +10657,10 @@ void Unit::SetMeleeAnimKitId(uint16 animKitId)
|
||||
if (creature->GetMap()->Is25ManRaid())
|
||||
loot->maxDuplicates = 3;
|
||||
|
||||
if (InstanceScript const* instance = creature->GetInstanceScript())
|
||||
if (DungeonEncounterEntry const* dungeonEncounter = instance->GetBossDungeonEncounter(creature))
|
||||
loot->SetDungeonEncounterId(dungeonEncounter->ID);
|
||||
|
||||
if (uint32 lootid = creature->GetCreatureTemplate()->lootid)
|
||||
loot->FillLoot(lootid, LootTemplates_Creature, looter, false, false, creature->GetLootMode(), creature->GetMap()->GetDifficultyLootItemContext());
|
||||
|
||||
|
||||
@@ -35,6 +35,7 @@
|
||||
#include "PhasingHandler.h"
|
||||
#include "Player.h"
|
||||
#include "RBAC.h"
|
||||
#include "ScriptedCreature.h"
|
||||
#include "ScriptReloadMgr.h"
|
||||
#include "SmartEnum.h"
|
||||
#include "SpellMgr.h"
|
||||
@@ -729,6 +730,14 @@ DungeonEncounterEntry const* InstanceScript::GetBossDungeonEncounter(uint32 id)
|
||||
return id < bosses.size() ? bosses[id].GetDungeonEncounterForDifficulty(instance->GetDifficultyID()) : nullptr;
|
||||
}
|
||||
|
||||
DungeonEncounterEntry const* InstanceScript::GetBossDungeonEncounter(Creature const* creature) const
|
||||
{
|
||||
if (BossAI const* bossAi = dynamic_cast<BossAI const*>(creature->GetAI()))
|
||||
return GetBossDungeonEncounter(bossAi->GetBossId());
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
bool InstanceScript::CheckAchievementCriteriaMeet(uint32 criteria_id, Player const* /*source*/, Unit const* /*target*/ /*= nullptr*/, uint32 /*miscvalue1*/ /*= 0*/)
|
||||
{
|
||||
TC_LOG_ERROR("misc", "Achievement system call InstanceScript::CheckAchievementCriteriaMeet but instance script for map %u not have implementation for achievement criteria %u",
|
||||
|
||||
@@ -268,6 +268,7 @@ class TC_GAME_API InstanceScript : public ZoneScript
|
||||
static char const* GetBossStateName(uint8 state);
|
||||
CreatureBoundary const* GetBossBoundary(uint32 id) const { return id < bosses.size() ? &bosses[id].boundary : nullptr; }
|
||||
DungeonEncounterEntry const* GetBossDungeonEncounter(uint32 id) const;
|
||||
DungeonEncounterEntry const* GetBossDungeonEncounter(Creature const* creature) const;
|
||||
|
||||
// Achievement criteria additional requirements check
|
||||
// NOTE: not use this if same can be checked existed requirement types from AchievementCriteriaRequirementType
|
||||
|
||||
@@ -1570,13 +1570,13 @@ void Spell::SendLoot(ObjectGuid guid, LootType loottype)
|
||||
loot = new Loot(gameObjTarget->GetMap(), guid, loottype, groupRules ? group : nullptr);
|
||||
gameObjTarget->m_loot.reset(loot);
|
||||
|
||||
loot->SetDungeonEncounterId(gameObjTarget->GetGOInfo()->chest.DungeonEncounter);
|
||||
loot->FillLoot(lootId, LootTemplates_Gameobject, player, !groupRules, false, gameObjTarget->GetLootMode(), gameObjTarget->GetMap()->GetDifficultyLootItemContext());
|
||||
|
||||
if (gameObjTarget->GetLootMode() > 0)
|
||||
if (GameObjectTemplateAddon const* addon = gameObjTarget->GetTemplateAddon())
|
||||
loot->generateMoneyLoot(addon->Mingold, addon->Maxgold);
|
||||
|
||||
loot->SetDungeonEncounterId(gameObjTarget->GetGOInfo()->chest.DungeonEncounter);
|
||||
}
|
||||
|
||||
/// @todo possible must be moved to loot release (in different from linked triggering)
|
||||
|
||||
Reference in New Issue
Block a user