aboutsummaryrefslogtreecommitdiff
path: root/src/server/game
diff options
context:
space:
mode:
authorTeleqraph <nyrdeveloper@gmail.com>2023-10-22 11:24:48 +0200
committerGitHub <noreply@github.com>2023-10-22 11:24:48 +0200
commit9eceff2bc243946998c006418229dbb639e898d6 (patch)
treef800e44d9d2d7bb7caf388cb690194ed3bfac3e2 /src/server/game
parent3d3979f1cabf59321fbafcde1f0d1e600d29e974 (diff)
Core/Map: Implement several difficulty getters (#29370)
Co-authored-by: ModoX <moardox@gmail.com>
Diffstat (limited to 'src/server/game')
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.cpp36
-rw-r--r--src/server/game/AI/ScriptedAI/ScriptedCreature.h14
-rw-r--r--src/server/game/DataStores/DBCEnums.h16
-rw-r--r--src/server/game/Maps/Map.cpp67
-rw-r--r--src/server/game/Maps/Map.h6
5 files changed, 122 insertions, 17 deletions
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
index ad12f677884..00c15509f5a 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.cpp
@@ -126,7 +126,6 @@ ScriptedAI::ScriptedAI(Creature* creature) : ScriptedAI(creature, creature->GetS
ScriptedAI::ScriptedAI(Creature* creature, uint32 scriptId) : CreatureAI(creature, scriptId), IsFleeing(false), _isCombatMovementAllowed(true)
{
- _isHeroic = me->GetMap()->IsHeroic();
_difficulty = me->GetMap()->GetDifficultyID();
}
@@ -304,6 +303,41 @@ bool ScriptedAI::HealthAbovePct(uint32 pct) const
return me->HealthAbovePct(pct);
}
+bool ScriptedAI::IsLFR() const
+{
+ return me->GetMap()->IsLFR();
+}
+
+bool ScriptedAI::IsNormal() const
+{
+ return me->GetMap()->IsNormal();
+}
+
+bool ScriptedAI::IsHeroic() const
+{
+ return me->GetMap()->IsHeroic();
+}
+
+bool ScriptedAI::IsMythic() const
+{
+ return me->GetMap()->IsMythic();
+}
+
+bool ScriptedAI::IsMythicPlus() const
+{
+ return me->GetMap()->IsMythicPlus();
+}
+
+bool ScriptedAI::IsHeroicOrHigher() const
+{
+ return me->GetMap()->IsHeroicOrHigher();
+}
+
+bool ScriptedAI::IsTimewalking() const
+{
+ return me->GetMap()->IsTimewalking();
+}
+
SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mechanic, SelectTargetType targets, float rangeMin, float rangeMax, SelectEffect effect)
{
// No target so we can't cast
diff --git a/src/server/game/AI/ScriptedAI/ScriptedCreature.h b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
index bcb0496ec36..a52b33b0dcc 100644
--- a/src/server/game/AI/ScriptedAI/ScriptedCreature.h
+++ b/src/server/game/AI/ScriptedAI/ScriptedCreature.h
@@ -237,12 +237,13 @@ struct TC_GAME_API ScriptedAI : public CreatureAI
void SetCombatMovement(bool allowMovement);
bool IsCombatMovementAllowed() const { return _isCombatMovementAllowed; }
- // return true for heroic mode. i.e.
- // - for dungeon in mode 10-heroic,
- // - for raid in mode 10-Heroic
- // - for raid in mode 25-heroic
- // DO NOT USE to check raid in mode 25-normal.
- bool IsHeroic() const { return _isHeroic; }
+ bool IsLFR() const;
+ bool IsNormal() const;
+ bool IsHeroic() const;
+ bool IsMythic() const;
+ bool IsMythicPlus() const;
+ bool IsHeroicOrHigher() const;
+ bool IsTimewalking() const;
// return the dungeon or raid difficulty
Difficulty GetDifficulty() const { return _difficulty; }
@@ -305,7 +306,6 @@ struct TC_GAME_API ScriptedAI : public CreatureAI
private:
Difficulty _difficulty;
bool _isCombatMovementAllowed;
- bool _isHeroic;
};
class TC_GAME_API BossAI : public ScriptedAI
diff --git a/src/server/game/DataStores/DBCEnums.h b/src/server/game/DataStores/DBCEnums.h
index 6a1a7dec181..15fff9739a6 100644
--- a/src/server/game/DataStores/DBCEnums.h
+++ b/src/server/game/DataStores/DBCEnums.h
@@ -909,14 +909,14 @@ enum Difficulty : uint8
enum DifficultyFlags
{
- DIFFICULTY_FLAG_HEROIC = 0x01,
- DIFFICULTY_FLAG_DEFAULT = 0x02,
- DIFFICULTY_FLAG_CAN_SELECT = 0x04, // Player can select this difficulty in dropdown menu
- DIFFICULTY_FLAG_CHALLENGE_MODE = 0x08,
-
- DIFFICULTY_FLAG_LEGACY = 0x20,
- DIFFICULTY_FLAG_DISPLAY_HEROIC = 0x40, // Controls icon displayed on minimap when inside the instance
- DIFFICULTY_FLAG_DISPLAY_MYTHIC = 0x80 // Controls icon displayed on minimap when inside the instance
+ DIFFICULTY_FLAG_HEROIC_STYLE_LOCKOUTS = 0x01,
+ DIFFICULTY_FLAG_DEFAULT = 0x02,
+ DIFFICULTY_FLAG_CAN_SELECT = 0x04, // Player can select this difficulty in dropdown menu
+ //DIFFICULTY_FLAG_CHALLENGE_MODE = 0x08, // deprecated since Legion expansion
+ DIFFICULTY_FLAG_LFG_ONLY = 0x10,
+ DIFFICULTY_FLAG_LEGACY = 0x20,
+ DIFFICULTY_FLAG_DISPLAY_HEROIC = 0x40, // Controls icon displayed on minimap when inside the instance
+ DIFFICULTY_FLAG_DISPLAY_MYTHIC = 0x80 // Controls icon displayed on minimap when inside the instance
};
enum class ExpectedStatType : uint8
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp
index 57af9eb75c0..c778396dd88 100644
--- a/src/server/game/Maps/Map.cpp
+++ b/src/server/game/Maps/Map.cpp
@@ -3193,18 +3193,83 @@ bool Map::IsRaid() const
return i_mapEntry && i_mapEntry->IsRaid();
}
+bool Map::IsLFR() const
+{
+ switch (i_spawnMode)
+ {
+ case DIFFICULTY_LFR:
+ case DIFFICULTY_LFR_NEW:
+ case DIFFICULTY_LFR_15TH_ANNIVERSARY:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool Map::IsNormal() const
+{
+ switch (i_spawnMode)
+ {
+ case DIFFICULTY_NORMAL:
+ case DIFFICULTY_10_N:
+ case DIFFICULTY_25_N:
+ case DIFFICULTY_NORMAL_RAID:
+ case DIFFICULTY_NORMAL_ISLAND:
+ case DIFFICULTY_NORMAL_WARFRONT:
+ return true;
+ default:
+ return false;
+ }
+}
+
bool Map::IsHeroic() const
{
if (DifficultyEntry const* difficulty = sDifficultyStore.LookupEntry(i_spawnMode))
- return difficulty->Flags & DIFFICULTY_FLAG_HEROIC;
+ {
+ if (difficulty->Flags & DIFFICULTY_FLAG_DISPLAY_HEROIC)
+ return true;
+ }
+
+ // compatibility purposes of old difficulties
+ switch (i_spawnMode)
+ {
+ case DIFFICULTY_10_HC:
+ case DIFFICULTY_25_HC:
+ case DIFFICULTY_HEROIC:
+ case DIFFICULTY_3_MAN_SCENARIO_HC:
+ return true;
+ default:
+ return false;
+ }
+}
+
+bool Map::IsMythic() const
+{
+ if (DifficultyEntry const* difficulty = sDifficultyStore.LookupEntry(i_spawnMode))
+ return difficulty->Flags & DIFFICULTY_FLAG_DISPLAY_MYTHIC;
return false;
}
+bool Map::IsMythicPlus() const
+{
+ return IsDungeon() && i_spawnMode == DIFFICULTY_MYTHIC_KEYSTONE;
+}
+
+bool Map::IsHeroicOrHigher() const
+{
+ return IsHeroic() || IsMythic() || IsMythicPlus();
+}
+
bool Map::Is25ManRaid() const
{
return IsRaid() && (i_spawnMode == DIFFICULTY_25_N || i_spawnMode == DIFFICULTY_25_HC);
}
+bool Map::IsTimewalking() const
+{
+ return (IsDungeon() && i_spawnMode == DIFFICULTY_TIMEWALKING) || (IsRaid() && i_spawnMode == DIFFICULTY_TIMEWALKING_RAID);
+}
+
bool Map::IsBattleground() const
{
return i_mapEntry && i_mapEntry->IsBattleground();
diff --git a/src/server/game/Maps/Map.h b/src/server/game/Maps/Map.h
index f41716ea4d3..6cd97bb5d4b 100644
--- a/src/server/game/Maps/Map.h
+++ b/src/server/game/Maps/Map.h
@@ -325,8 +325,14 @@ class TC_GAME_API Map : public GridRefManager<NGridType>
bool IsDungeon() const;
bool IsNonRaidDungeon() const;
bool IsRaid() const;
+ bool IsLFR() const;
+ bool IsNormal() const;
bool IsHeroic() const;
+ bool IsMythic() const;
+ bool IsMythicPlus() const;
+ bool IsHeroicOrHigher() const;
bool Is25ManRaid() const;
+ bool IsTimewalking() const;
bool IsBattleground() const;
bool IsBattleArena() const;
bool IsBattlegroundOrArena() const;