Core/Map: Implement several difficulty getters
Port From (https://github.com/TrinityCore/TrinityCore/commit/9eceff2bc243946998c006418229dbb639e898d6)
This commit is contained in:
@@ -933,11 +933,11 @@ namespace Framework.Constants
|
||||
|
||||
public enum DifficultyFlags : ushort
|
||||
{
|
||||
Heroic = 0x01,
|
||||
HeroicStyleLockouts = 0x01,
|
||||
Default = 0x02,
|
||||
CanSelect = 0x04, // Player can select this difficulty in dropdown menu
|
||||
ChallengeMode = 0x08,
|
||||
|
||||
//ChallengeMode = 0x08, // deprecated since Legion expansion
|
||||
LfgOnly = 0x10,
|
||||
Legacy = 0x20,
|
||||
DisplayHeroic = 0x40, // Controls icon displayed on minimap when inside the instance
|
||||
DisplayMythic = 0x80 // Controls icon displayed on minimap when inside the instance
|
||||
|
||||
@@ -16,12 +16,10 @@ namespace Game.AI
|
||||
{
|
||||
Difficulty _difficulty;
|
||||
bool _isCombatMovementAllowed;
|
||||
bool _isHeroic;
|
||||
|
||||
public ScriptedAI(Creature creature) : base(creature)
|
||||
{
|
||||
_isCombatMovementAllowed = true;
|
||||
_isHeroic = me.GetMap().IsHeroic();
|
||||
_difficulty = me.GetMap().GetDifficultyID();
|
||||
}
|
||||
|
||||
@@ -456,16 +454,45 @@ namespace Game.AI
|
||||
}
|
||||
|
||||
public bool HealthBelowPct(int pct) { return me.HealthBelowPct(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.
|
||||
// - 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.
|
||||
public bool IsHeroic() { return _isHeroic; }
|
||||
public bool IsNormal()
|
||||
{
|
||||
return me.GetMap().IsNormal();
|
||||
}
|
||||
|
||||
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
|
||||
public Difficulty GetDifficulty() { return _difficulty; }
|
||||
|
||||
+43
-1
@@ -3264,20 +3264,62 @@ namespace Game.Maps
|
||||
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()
|
||||
{
|
||||
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)
|
||||
return difficulty.Flags.HasAnyFlag(DifficultyFlags.Heroic);
|
||||
return difficulty.Flags.HasFlag(DifficultyFlags.DisplayMythic);
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsMythicPlus()
|
||||
{
|
||||
return IsDungeon() && i_spawnMode == Difficulty.MythicKeystone;
|
||||
}
|
||||
|
||||
public bool IsHeroicOrHigher()
|
||||
{
|
||||
return IsHeroic() || IsMythic() || IsMythicPlus();
|
||||
}
|
||||
|
||||
public bool Is25ManRaid()
|
||||
{
|
||||
// since 25man difficulties are 1 and 3, we can check them like that
|
||||
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()
|
||||
{
|
||||
return i_mapRecord != null && i_mapRecord.IsBattleground();
|
||||
|
||||
Reference in New Issue
Block a user