Core/Creatures: Flag dungeon bosses for quicker lookups for related encounters
This commit is contained in:
@@ -265,7 +265,6 @@ bool Creature::InitEntry(uint32 Entry, uint32 /*team*/, const CreatureData *data
|
||||
}
|
||||
|
||||
// get difficulty 1 mode entry
|
||||
uint32 actualEntry = Entry;
|
||||
CreatureInfo const *cinfo = normalInfo;
|
||||
for (uint8 diff = uint8(GetMap()->GetSpawnMode()); diff > 0;)
|
||||
{
|
||||
@@ -2409,3 +2408,9 @@ void Creature::FarTeleportTo(Map* map, float X, float Y, float Z, float O)
|
||||
|
||||
SetPosition(X, Y, Z, O, true);
|
||||
}
|
||||
|
||||
bool Creature::IsDungeonBoss() const
|
||||
{
|
||||
CreatureInfo const *cinfo = ObjectMgr::GetCreatureTemplate(GetEntry());
|
||||
return cinfo && (cinfo->flags_extra & CREATURE_FLAG_EXTRA_DUNGEON_BOSS);
|
||||
}
|
||||
|
||||
@@ -54,9 +54,15 @@ enum CreatureFlagsExtra
|
||||
CREATURE_FLAG_EXTRA_NO_SKILLGAIN = 0x00040000, // creature won't increase weapon skills
|
||||
CREATURE_FLAG_EXTRA_TAUNT_DIMINISH = 0x00080000, // Taunt is a subject to diminishing returns on this creautre
|
||||
CREATURE_FLAG_EXTRA_ALL_DIMINISH = 0x00100000, // Creature is subject to all diminishing returns as player are
|
||||
CREATURE_FLAG_EXTRA_DUNGEON_BOSS = 0x00200000, // creature is a dungeon boss
|
||||
CREATURE_FLAG_EXTRA_DUNGEON_BOSS = 0x10000000, // creature is a dungeon boss (SET DYNAMICALLY, DO NOT ADD IN DB)
|
||||
};
|
||||
|
||||
#define CREATURE_FLAG_EXTRA_DB_ALLOWED (CREATURE_FLAG_EXTRA_INSTANCE_BIND | CREATURE_FLAG_EXTRA_CIVILIAN | \
|
||||
CREATURE_FLAG_EXTRA_NO_PARRY | CREATURE_FLAG_EXTRA_NO_PARRY_HASTEN | CREATURE_FLAG_EXTRA_NO_BLOCK | \
|
||||
CREATURE_FLAG_EXTRA_NO_CRUSH | CREATURE_FLAG_EXTRA_NO_XP_AT_KILL | CREATURE_FLAG_EXTRA_TRIGGER | \
|
||||
CREATURE_FLAG_EXTRA_NO_TAUNT | CREATURE_FLAG_EXTRA_WORLDEVENT | CREATURE_FLAG_EXTRA_NO_CRIT | \
|
||||
CREATURE_FLAG_EXTRA_NO_SKILLGAIN | CREATURE_FLAG_EXTRA_TAUNT_DIMINISH | CREATURE_FLAG_EXTRA_ALL_DIMINISH)
|
||||
|
||||
// GCC have alternative #pragma pack(N) syntax and old gcc version not support pack(push,N), also any gcc version not support it at some platform
|
||||
#if defined(__GNUC__)
|
||||
#pragma pack(1)
|
||||
@@ -472,6 +478,8 @@ class Creature : public Unit, public GridObject<Creature>
|
||||
return GetCreatureInfo()->rank == CREATURE_ELITE_WORLDBOSS;
|
||||
}
|
||||
|
||||
bool IsDungeonBoss() const;
|
||||
|
||||
uint8 getLevelForTarget(WorldObject const* target) const; // overwrite Unit::getLevelForTarget for boss level support
|
||||
|
||||
bool IsInEvadeMode() const { return HasUnitState(UNIT_STAT_EVADE); }
|
||||
@@ -679,8 +687,6 @@ class Creature : public Unit, public GridObject<Creature>
|
||||
// vendor items
|
||||
VendorItemCounts m_vendorItemCounts;
|
||||
|
||||
void _RealtimeSetCreatureInfo();
|
||||
|
||||
static float _GetHealthMod(int32 Rank);
|
||||
|
||||
uint32 m_lootMoney;
|
||||
@@ -716,7 +722,7 @@ class Creature : public Unit, public GridObject<Creature>
|
||||
|
||||
bool DisableReputationGain;
|
||||
|
||||
CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from sObjectMgr->::GetCreatureTemplate(GetEntry())
|
||||
CreatureInfo const* m_creatureInfo; // in difficulty mode > 0 can different from ObjectMgr::GetCreatureTemplate(GetEntry())
|
||||
CreatureData const* m_creatureData;
|
||||
|
||||
uint16 m_LootMode; // bitmask, default LOOT_MODE_DEFAULT, determines what loot will be lootable
|
||||
|
||||
@@ -22123,7 +22123,8 @@ bool Player::RewardPlayerAndGroupAtKill(Unit* pVictim)
|
||||
}
|
||||
|
||||
// Credit encounter in instance
|
||||
if (pVictim->GetTypeId() == TYPEID_UNIT && GetMap()->IsDungeon())
|
||||
if (Creature* victim = pVictim->ToCreature())
|
||||
if (victim->IsDungeonBoss())
|
||||
if (InstanceScript* instance = pVictim->GetInstanceScript())
|
||||
instance->UpdateEncounterState(ENCOUNTER_CREDIT_KILL_CREATURE, pVictim->GetEntry(), pVictim);
|
||||
|
||||
|
||||
@@ -855,6 +855,12 @@ void ObjectMgr::CheckCreatureTemplate(CreatureInfo const* cInfo)
|
||||
const_cast<CreatureInfo*>(cInfo)->expansion = 0;
|
||||
}
|
||||
|
||||
if (uint32 badFlags = (cInfo->flags_extra & ~CREATURE_FLAG_EXTRA_DB_ALLOWED))
|
||||
{
|
||||
sLog->outErrorDb("Table `creature_template` lists creature (Entry: %u) with disallowed `flags_extra` %u, removing incorrect flag.", cInfo->Entry, badFlags);
|
||||
const_cast<CreatureInfo*>(cInfo)->flags_extra &= CREATURE_FLAG_EXTRA_DB_ALLOWED;
|
||||
}
|
||||
|
||||
const_cast<CreatureInfo*>(cInfo)->dmg_multiplier *= Creature::_GetDamageMod(cInfo->rank);
|
||||
}
|
||||
|
||||
@@ -5571,6 +5577,9 @@ void ObjectMgr::LoadInstanceEncounters()
|
||||
{
|
||||
Field* fields = result->Fetch();
|
||||
uint32 entry = fields[0].GetUInt32();
|
||||
uint8 creditType = fields[1].GetUInt8();
|
||||
uint32 creditEntry = fields[2].GetUInt32();
|
||||
uint32 lastEncounterDungeon = fields[3].GetUInt32();
|
||||
DungeonEncounterEntry const* dungeonEncounter = sDungeonEncounterStore.LookupEntry(entry);
|
||||
if (!dungeonEncounter)
|
||||
{
|
||||
@@ -5578,32 +5587,6 @@ void ObjectMgr::LoadInstanceEncounters()
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8 creditType = fields[1].GetUInt8();
|
||||
uint32 creditEntry = fields[2].GetUInt32();
|
||||
|
||||
switch (creditType)
|
||||
{
|
||||
case ENCOUNTER_CREDIT_KILL_CREATURE:
|
||||
if (!GetCreatureInfo(creditEntry))
|
||||
{
|
||||
sLog->outErrorDb("Table `instance_encounters` has an invalid creature (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
case ENCOUNTER_CREDIT_CAST_SPELL:
|
||||
if (!sSpellStore.LookupEntry(creditEntry))
|
||||
{
|
||||
sLog->outErrorDb("Table `instance_encounters` has an invalid spell (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sLog->outErrorDb("Table `instance_encounters` has an invalid credit type (%u) for encounter %u (%s), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
uint32 lastEncounterDungeon = fields[3].GetUInt32();
|
||||
|
||||
if (lastEncounterDungeon && !sLFGDungeonStore.LookupEntry(lastEncounterDungeon))
|
||||
{
|
||||
sLog->outErrorDb("Table `instance_encounters` has an encounter %u (%s) marked as final for invalid dungeon id %u, skipped!", entry, dungeonEncounter->encounterName[0], lastEncounterDungeon);
|
||||
@@ -5622,6 +5605,31 @@ void ObjectMgr::LoadInstanceEncounters()
|
||||
dungeonLastBosses[lastEncounterDungeon] = dungeonEncounter;
|
||||
}
|
||||
|
||||
switch (creditType)
|
||||
{
|
||||
case ENCOUNTER_CREDIT_KILL_CREATURE:
|
||||
{
|
||||
CreatureInfo const* creatureInfo = GetCreatureInfo(creditEntry);
|
||||
if (!creatureInfo)
|
||||
{
|
||||
sLog->outErrorDb("Table `instance_encounters` has an invalid creature (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
const_cast<CreatureInfo*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS;
|
||||
}
|
||||
case ENCOUNTER_CREDIT_CAST_SPELL:
|
||||
if (!sSpellStore.LookupEntry(creditEntry))
|
||||
{
|
||||
sLog->outErrorDb("Table `instance_encounters` has an invalid spell (entry %u) linked to the encounter %u (%s), skipped!", creditEntry, entry, dungeonEncounter->encounterName[0]);
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
sLog->outErrorDb("Table `instance_encounters` has an invalid credit type (%u) for encounter %u (%s), skipped!", creditType, entry, dungeonEncounter->encounterName[0]);
|
||||
continue;
|
||||
}
|
||||
|
||||
DungeonEncounterList& encounters = mDungeonEncounters[MAKE_PAIR32(dungeonEncounter->mapId, dungeonEncounter->difficulty)];
|
||||
encounters.push_back(new DungeonEncounter(dungeonEncounter, EncounterCreditType(creditType), creditEntry, lastEncounterDungeon));
|
||||
++count;
|
||||
|
||||
Reference in New Issue
Block a user