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
|
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
|
||||||
|
|||||||
@@ -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();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -109,7 +107,7 @@ namespace Game.AI
|
|||||||
/// <param name="who"></param>
|
/// <param name="who"></param>
|
||||||
public void AddThreat(Unit victim, float amount, Unit who = null)
|
public void AddThreat(Unit victim, float amount, Unit who = null)
|
||||||
{
|
{
|
||||||
if (victim == null)
|
if (victim == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (who == null)
|
if (who == null)
|
||||||
@@ -126,7 +124,7 @@ namespace Game.AI
|
|||||||
/// <param name="who"></param>
|
/// <param name="who"></param>
|
||||||
public void ModifyThreatByPercent(Unit victim, int pct, Unit who = null)
|
public void ModifyThreatByPercent(Unit victim, int pct, Unit who = null)
|
||||||
{
|
{
|
||||||
if (victim == null)
|
if (victim == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (who == null)
|
if (who == null)
|
||||||
@@ -142,7 +140,7 @@ namespace Game.AI
|
|||||||
/// <param name="who"></param>
|
/// <param name="who"></param>
|
||||||
public void ResetThreat(Unit victim, Unit who)
|
public void ResetThreat(Unit victim, Unit who)
|
||||||
{
|
{
|
||||||
if (victim == null)
|
if (victim == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (who == null)
|
if (who == null)
|
||||||
@@ -171,7 +169,7 @@ namespace Game.AI
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
public float GetThreat(Unit victim, Unit who = null)
|
public float GetThreat(Unit victim, Unit who = null)
|
||||||
{
|
{
|
||||||
if (victim == null)
|
if (victim == null)
|
||||||
return 0.0f;
|
return 0.0f;
|
||||||
|
|
||||||
if (who == null)
|
if (who == null)
|
||||||
@@ -306,10 +304,10 @@ namespace Game.AI
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!hasPower)
|
if (!hasPower)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Check if the spell meets our range requirements
|
//Check if the spell meets our range requirements
|
||||||
if (rangeMin != 0 && me.GetSpellMinRangeForTarget(target, tempSpell) < rangeMin)
|
if (rangeMin != 0 && me.GetSpellMinRangeForTarget(target, tempSpell) < rangeMin)
|
||||||
continue;
|
continue;
|
||||||
@@ -449,23 +447,52 @@ namespace Game.AI
|
|||||||
{
|
{
|
||||||
return source.FindNearestCreatureWithOptions(maxSearchRange, options);
|
return source.FindNearestCreatureWithOptions(maxSearchRange, options);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static GameObject GetClosestGameObjectWithEntry(WorldObject source, uint entry, float maxSearchRange, bool spawnedOnly = true)
|
public static GameObject GetClosestGameObjectWithEntry(WorldObject source, uint entry, float maxSearchRange, bool spawnedOnly = true)
|
||||||
{
|
{
|
||||||
return source.FindNearestGameObject(entry, maxSearchRange, spawnedOnly);
|
return source.FindNearestGameObject(entry, maxSearchRange, spawnedOnly);
|
||||||
}
|
}
|
||||||
|
|
||||||
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
@@ -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();
|
||||||
|
|||||||
Reference in New Issue
Block a user