aboutsummaryrefslogtreecommitdiff
path: root/src/server/game/Entities/Creature
diff options
context:
space:
mode:
authorShauren <shauren.trinity@gmail.com>2015-01-10 01:35:47 +0100
committerShauren <shauren.trinity@gmail.com>2015-01-10 01:35:47 +0100
commitfaa583c7843af37d757bd46ca0bd226175dabc38 (patch)
tree5af657d84903b337bdb22c341bb01f4e6aab1392 /src/server/game/Entities/Creature
parentf6b30fdf616bd289dd668f98a0aed8dbfb14eba8 (diff)
Core/Maps: Updated map difficulties
Diffstat (limited to 'src/server/game/Entities/Creature')
-rw-r--r--src/server/game/Entities/Creature/Creature.cpp42
-rw-r--r--src/server/game/Entities/Creature/Creature.h39
-rw-r--r--src/server/game/Entities/Creature/TemporarySummon.h2
3 files changed, 59 insertions, 24 deletions
diff --git a/src/server/game/Entities/Creature/Creature.cpp b/src/server/game/Entities/Creature/Creature.cpp
index f4567fbc1b7..070263cd85e 100644
--- a/src/server/game/Entities/Creature/Creature.cpp
+++ b/src/server/game/Entities/Creature/Creature.cpp
@@ -269,27 +269,29 @@ bool Creature::InitEntry(uint32 entry, CreatureData const* data /*= nullptr*/)
}
// get difficulty 1 mode entry
- CreatureTemplate const* cinfo = normalInfo;
- for (uint8 diff = uint8(GetMap()->GetSpawnMode()); diff > 0;)
+ CreatureTemplate const* cinfo = nullptr;
+ DifficultyEntry const* difficultyEntry = sDifficultyStore.LookupEntry(GetMap()->GetSpawnMode());
+ while (!cinfo && difficultyEntry)
{
- // we already have valid Map pointer for current creature!
- if (normalInfo->DifficultyEntry[diff - 1])
- {
- cinfo = sObjectMgr->GetCreatureTemplate(normalInfo->DifficultyEntry[diff - 1]);
- if (cinfo)
- break; // template found
+ int32 idx = CreatureTemplate::DifficultyIDToDifficultyEntryIndex(difficultyEntry->ID);
+ if (idx == -1)
+ break;
- // check and reported at startup, so just ignore (restore normalInfo)
- cinfo = normalInfo;
+ if (normalInfo->DifficultyEntry[idx])
+ {
+ cinfo = sObjectMgr->GetCreatureTemplate(normalInfo->DifficultyEntry[idx]);
+ break;
}
- // for instances heroic to normal, other cases attempt to retrieve previous difficulty
- if (diff >= DIFFICULTY_10_HC && GetMap()->IsRaid())
- diff -= 2; // to normal raid difficulty cases
- else
- --diff;
+ if (!difficultyEntry->FallbackDifficultyID)
+ break;
+
+ difficultyEntry = sDifficultyStore.LookupEntry(difficultyEntry->FallbackDifficultyID);
}
+ if (!cinfo)
+ cinfo = normalInfo;
+
// Initialize loot duplicate count depending on raid difficulty
if (GetMap()->Is25ManRaid())
loot.maxDuplicates = 3;
@@ -946,7 +948,7 @@ void Creature::SaveToDB()
SaveToDB(mapId, data->spawnMask, GetPhaseMask());
}
-void Creature::SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask)
+void Creature::SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask)
{
// update in loaded data
if (!m_DBTableGuid)
@@ -1620,7 +1622,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
// This check must be done instead of 'if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (spellInfo->Mechanic - 1)))' for not break
// the check of mechanic immunity on DB (tested) because GetCreatureTemplate()->MechanicImmuneMask and m_spellImmune[IMMUNITY_MECHANIC] don't have same data.
bool immunedToAllEffects = true;
- for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficulty()))
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
{
if (!effect || !effect->IsEffect())
continue;
@@ -1638,7 +1640,7 @@ bool Creature::IsImmunedToSpell(SpellInfo const* spellInfo) const
bool Creature::IsImmunedToSpellEffect(SpellInfo const* spellInfo, uint32 index) const
{
- SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficulty());
+ SpellEffectInfo const* effect = spellInfo->GetEffect(GetMap()->GetDifficultyID());
if (!effect)
return true;
if (GetCreatureTemplate()->MechanicImmuneMask & (1 << (effect->Mechanic - 1)))
@@ -1684,7 +1686,7 @@ SpellInfo const* Creature::reachWithSpellAttack(Unit* victim)
}
bool bcontinue = true;
- for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficulty()))
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
{
if (effect && ((effect->Effect == SPELL_EFFECT_SCHOOL_DAMAGE) ||
(effect->Effect == SPELL_EFFECT_INSTAKILL) ||
@@ -1732,7 +1734,7 @@ SpellInfo const* Creature::reachWithSpellCure(Unit* victim)
}
bool bcontinue = true;
- for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficulty()))
+ for (SpellEffectInfo const* effect : spellInfo->GetEffectsForDifficulty(GetMap()->GetDifficultyID()))
{
if (effect && (effect->Effect == SPELL_EFFECT_HEAL))
{
diff --git a/src/server/game/Entities/Creature/Creature.h b/src/server/game/Entities/Creature/Creature.h
index ff43f73d1c6..842624e0c01 100644
--- a/src/server/game/Entities/Creature/Creature.h
+++ b/src/server/game/Entities/Creature/Creature.h
@@ -72,12 +72,13 @@ enum CreatureFlagsExtra
#define MAX_CREATURE_QUEST_ITEMS 6
#define MAX_CREATURE_NAMES 4
#define CREATURE_MAX_SPELLS 8
+#define MAX_CREATURE_DIFFICULTIES 3
// from `creature_template` table
struct CreatureTemplate
{
uint32 Entry;
- uint32 DifficultyEntry[MAX_DIFFICULTY - 1];
+ uint32 DifficultyEntry[MAX_CREATURE_DIFFICULTIES];
uint32 KillCredit[MAX_KILL_CREDIT];
uint32 Modelid1;
uint32 Modelid2;
@@ -170,6 +171,38 @@ struct CreatureTemplate
// if can tame exotic then can tame any tameable
return canTameExotic || !IsExotic();
}
+
+ static int32 DifficultyIDToDifficultyEntryIndex(uint32 difficulty)
+ {
+ switch (difficulty)
+ {
+ case DIFFICULTY_NONE:
+ case DIFFICULTY_NORMAL:
+ case DIFFICULTY_10_N:
+ case DIFFICULTY_40:
+ case DIFFICULTY_N_SCENARIO:
+ case DIFFICULTY_NORMAL_RAID:
+ return -1;
+ case DIFFICULTY_HEROIC:
+ case DIFFICULTY_25_N:
+ case DIFFICULTY_HC_SCENARIO:
+ case DIFFICULTY_HEROIC_RAID:
+ return 0;
+ case DIFFICULTY_10_HC:
+ case DIFFICULTY_CHALLENGE:
+ case DIFFICULTY_MYTHIC_RAID:
+ return 1;
+ case DIFFICULTY_25_HC:
+ return 2;
+ case DIFFICULTY_LFR:
+ case DIFFICULTY_LFR_NEW:
+ case DIFFICULTY_EVENT_RAID:
+ case DIFFICULTY_EVENT_DUNGEON:
+ case DIFFICULTY_EVENT_SCENARIO:
+ default:
+ return -1;
+ }
+ }
};
// Benchmarked: Faster than std::map (insert/find)
@@ -274,7 +307,7 @@ struct CreatureData
uint32 curhealth;
uint32 curmana;
uint8 movementType;
- uint8 spawnMask;
+ uint32 spawnMask;
uint32 npcflag;
uint32 unit_flags; // enum UnitFlags mask values
uint32 dynamicflags;
@@ -549,7 +582,7 @@ class Creature : public Unit, public GridObject<Creature>, public MapObject
bool LoadCreatureFromDB(ObjectGuid::LowType guid, Map* map, bool addToMap = true);
void SaveToDB();
// overriden in Pet
- virtual void SaveToDB(uint32 mapid, uint8 spawnMask, uint32 phaseMask);
+ virtual void SaveToDB(uint32 mapid, uint32 spawnMask, uint32 phaseMask);
virtual void DeleteFromDB(); // overriden in Pet
Loot loot;
diff --git a/src/server/game/Entities/Creature/TemporarySummon.h b/src/server/game/Entities/Creature/TemporarySummon.h
index 16fd7c11683..378061d2905 100644
--- a/src/server/game/Entities/Creature/TemporarySummon.h
+++ b/src/server/game/Entities/Creature/TemporarySummon.h
@@ -48,7 +48,7 @@ class TempSummon : public Creature
virtual void UnSummon(uint32 msTime = 0);
void RemoveFromWorld() override;
void SetTempSummonType(TempSummonType type);
- void SaveToDB(uint32 /*mapid*/, uint8 /*spawnMask*/, uint32 /*phaseMask*/) override { }
+ void SaveToDB(uint32 /*mapid*/, uint32 /*spawnMask*/, uint32 /*phaseMask*/) override { }
Unit* GetSummoner() const;
Creature* GetSummonerCreatureBase() const;
ObjectGuid GetSummonerGUID() const { return m_summonerGUID; }