Core/Map: Implement several difficulty getters

Port From (https://github.com/TrinityCore/TrinityCore/commit/9eceff2bc243946998c006418229dbb639e898d6)
This commit is contained in:
hondacrx
2024-02-01 18:02:16 -05:00
parent a57a2d948d
commit 4c66c90f94
3 changed files with 89 additions and 20 deletions
+3 -3
View File
@@ -933,11 +933,11 @@ namespace Framework.Constants
public enum DifficultyFlags : ushort public enum DifficultyFlags : ushort
{ {
Heroic = 0x01, HeroicStyleLockouts = 0x01,
Default = 0x02, Default = 0x02,
CanSelect = 0x04, // Player can select this difficulty in dropdown menu CanSelect = 0x04, // Player can select this difficulty in dropdown menu
ChallengeMode = 0x08, //ChallengeMode = 0x08, // deprecated since Legion expansion
LfgOnly = 0x10,
Legacy = 0x20, Legacy = 0x20,
DisplayHeroic = 0x40, // Controls icon displayed on minimap when inside the instance DisplayHeroic = 0x40, // Controls icon displayed on minimap when inside the instance
DisplayMythic = 0x80 // Controls icon displayed on minimap when inside the instance DisplayMythic = 0x80 // Controls icon displayed on minimap when inside the instance
+36 -9
View File
@@ -16,12 +16,10 @@ namespace Game.AI
{ {
Difficulty _difficulty; Difficulty _difficulty;
bool _isCombatMovementAllowed; bool _isCombatMovementAllowed;
bool _isHeroic;
public ScriptedAI(Creature creature) : base(creature) public ScriptedAI(Creature creature) : base(creature)
{ {
_isCombatMovementAllowed = true; _isCombatMovementAllowed = true;
_isHeroic = me.GetMap().IsHeroic();
_difficulty = me.GetMap().GetDifficultyID(); _difficulty = me.GetMap().GetDifficultyID();
} }
@@ -456,16 +454,45 @@ namespace Game.AI
} }
public bool HealthBelowPct(int pct) { return me.HealthBelowPct(pct); } public bool HealthBelowPct(int pct) { return me.HealthBelowPct(pct); }
public bool HealthAbovePct(int pct) { return me.HealthAbovePct(pct); } public bool HealthAbovePct(int pct) { return me.HealthAbovePct(pct); }
public bool IsCombatMovementAllowed() { return _isCombatMovementAllowed; } public bool IsLFR()
{
return me.GetMap().IsLFR();
}
// return true for heroic mode. i.e. public bool IsNormal()
// - for dungeon in mode 10-heroic, {
// - for raid in mode 10-Heroic return me.GetMap().IsNormal();
// - for raid in mode 25-heroic }
// DO NOT USE to check raid in mode 25-normal.
public bool IsHeroic() { return _isHeroic; } public bool IsHeroic()
{
return me.GetMap().IsHeroic();
}
public bool IsMythic()
{
return me.GetMap().IsMythic();
}
public bool IsMythicPlus()
{
return me.GetMap().IsMythicPlus();
}
public bool IsHeroicOrHigher()
{
return me.GetMap().IsHeroicOrHigher();
}
public bool IsTimewalking()
{
return me.GetMap().IsTimewalking();
}
public bool IsCombatMovementAllowed() { return _isCombatMovementAllowed; }
// return the dungeon or raid difficulty // return the dungeon or raid difficulty
public Difficulty GetDifficulty() { return _difficulty; } public Difficulty GetDifficulty() { return _difficulty; }
+43 -1
View File
@@ -3264,20 +3264,62 @@ namespace Game.Maps
return i_mapRecord != null && i_mapRecord.IsRaid(); return i_mapRecord != null && i_mapRecord.IsRaid();
} }
public bool IsLFR() => i_spawnMode switch
{
Difficulty.LFR or Difficulty.LFRNew or Difficulty.LFR15thAnniversary => true,
_ => false
};
public bool IsNormal() => i_spawnMode switch
{
Difficulty.Normal or Difficulty.Raid10N or Difficulty.Raid25N or Difficulty.NormalRaid or Difficulty.NormalIsland or Difficulty.NormalWarfront => true,
_ => false
};
public bool IsHeroic() public bool IsHeroic()
{ {
DifficultyRecord difficulty = CliDB.DifficultyStorage.LookupByKey(i_spawnMode); DifficultyRecord difficulty = CliDB.DifficultyStorage.LookupByKey(i_spawnMode);
if (difficulty != null && difficulty.Flags.HasFlag(DifficultyFlags.DisplayHeroic))
return true;
// compatibility purposes of old difficulties
return i_spawnMode switch
{
Difficulty.Raid10HC or Difficulty.Raid25HC or Difficulty.Heroic or Difficulty.Scenario3ManHC => true,
_ => false
};
}
public bool IsMythic()
{
var difficulty = CliDB.DifficultyStorage.LookupByKey(i_spawnMode);
if (difficulty != null) if (difficulty != null)
return difficulty.Flags.HasAnyFlag(DifficultyFlags.Heroic); return difficulty.Flags.HasFlag(DifficultyFlags.DisplayMythic);
return false; return false;
} }
public bool IsMythicPlus()
{
return IsDungeon() && i_spawnMode == Difficulty.MythicKeystone;
}
public bool IsHeroicOrHigher()
{
return IsHeroic() || IsMythic() || IsMythicPlus();
}
public bool Is25ManRaid() public bool Is25ManRaid()
{ {
// since 25man difficulties are 1 and 3, we can check them like that // since 25man difficulties are 1 and 3, we can check them like that
return IsRaid() && (i_spawnMode == Difficulty.Raid25N || i_spawnMode == Difficulty.Raid25HC); return IsRaid() && (i_spawnMode == Difficulty.Raid25N || i_spawnMode == Difficulty.Raid25HC);
} }
public bool IsTimewalking()
{
return (IsDungeon() && i_spawnMode == Difficulty.Timewalking) || (IsRaid() && i_spawnMode == Difficulty.TimewalkingRaid);
}
public bool IsBattleground() public bool IsBattleground()
{ {
return i_mapRecord != null && i_mapRecord.IsBattleground(); return i_mapRecord != null && i_mapRecord.IsBattleground();