Core/Misc: Reduce number of player spec hardcoded checks
Port From (https://github.com/TrinityCore/TrinityCore/commit/054723241eaf1abe7d45a96460e84b9ff113ffb2)
This commit is contained in:
@@ -1114,12 +1114,18 @@ namespace Framework.Constants
|
|||||||
Caster = 0x01,
|
Caster = 0x01,
|
||||||
Ranged = 0x02,
|
Ranged = 0x02,
|
||||||
Melee = 0x04,
|
Melee = 0x04,
|
||||||
Unknown = 0x08,
|
|
||||||
DualWieldTwoHanded = 0x10, // Used For Cunitdisplay::Setsheatheinvertedfordualwield
|
DualWieldTwoHanded = 0x10, // Used For Cunitdisplay::Setsheatheinvertedfordualwield
|
||||||
PetOverrideSpec = 0x20,
|
PetOverrideSpec = 0x20,
|
||||||
Recommended = 0x40,
|
Recommended = 0x40,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum ChrSpecializationRole
|
||||||
|
{
|
||||||
|
Tank = 0,
|
||||||
|
Healer = 1,
|
||||||
|
Dps = 2
|
||||||
|
}
|
||||||
|
|
||||||
public enum ContentTuningCalcType
|
public enum ContentTuningCalcType
|
||||||
{
|
{
|
||||||
Base = 0,
|
Base = 0,
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||||
|
|
||||||
using Framework.Constants;
|
using Framework.Constants;
|
||||||
|
using Game.DataStorage;
|
||||||
using Game.Entities;
|
using Game.Entities;
|
||||||
using Game.Spells;
|
using Game.Spells;
|
||||||
using System;
|
using System;
|
||||||
@@ -393,15 +394,8 @@ namespace Game.AI
|
|||||||
if (!who)
|
if (!who)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
return who.GetClass() switch
|
return who.GetPrimarySpecialization() != 0
|
||||||
{
|
&& CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Healer;
|
||||||
Class.Paladin => who.GetPrimarySpecialization() == (uint)TalentSpecialization.PaladinHoly,
|
|
||||||
Class.Priest => who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestDiscipline || who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestHoly,
|
|
||||||
Class.Shaman => who.GetPrimarySpecialization() == (uint)TalentSpecialization.ShamanRestoration,
|
|
||||||
Class.Monk => who.GetPrimarySpecialization() == (uint)TalentSpecialization.MonkMistweaver,
|
|
||||||
Class.Druid => who.GetPrimarySpecialization() == (uint)TalentSpecialization.DruidRestoration,
|
|
||||||
_ => false,
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsPlayerRangedAttacker(Player who)
|
bool IsPlayerRangedAttacker(Player who)
|
||||||
@@ -409,36 +403,8 @@ namespace Game.AI
|
|||||||
if (!who)
|
if (!who)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
switch (who.GetClass())
|
return who.GetPrimarySpecialization() != 0
|
||||||
{
|
&& CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetFlags() == ChrSpecializationFlag.Ranged;
|
||||||
case Class.Warrior:
|
|
||||||
case Class.Paladin:
|
|
||||||
case Class.Rogue:
|
|
||||||
case Class.Deathknight:
|
|
||||||
default:
|
|
||||||
return false;
|
|
||||||
case Class.Mage:
|
|
||||||
case Class.Warlock:
|
|
||||||
return true;
|
|
||||||
case Class.Hunter:
|
|
||||||
{
|
|
||||||
// check if we have a ranged weapon equipped
|
|
||||||
Item rangedSlot = who.GetItemByPos(InventorySlots.Bag0, EquipmentSlot.Ranged);
|
|
||||||
|
|
||||||
ItemTemplate rangedTemplate = rangedSlot ? rangedSlot.GetTemplate() : null;
|
|
||||||
if (rangedTemplate != null)
|
|
||||||
if (Convert.ToBoolean((1 << (int)rangedTemplate.GetSubClass()) & (int)ItemSubClassWeapon.MaskRanged))
|
|
||||||
return true;
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
case Class.Priest:
|
|
||||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.PriestShadow;
|
|
||||||
case Class.Shaman:
|
|
||||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.ShamanElemental;
|
|
||||||
case Class.Druid:
|
|
||||||
return who.GetPrimarySpecialization() == (uint)TalentSpecialization.DruidBalance;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Tuple<Spell, Unit> VerifySpellCast(uint spellId, Unit target)
|
Tuple<Spell, Unit> VerifySpellCast(uint spellId, Unit target)
|
||||||
|
|||||||
@@ -2742,13 +2742,13 @@ namespace Game
|
|||||||
case UnitConditionVariable.IsEnemy:
|
case UnitConditionVariable.IsEnemy:
|
||||||
return (otherUnit && unit.GetReactionTo(otherUnit) <= ReputationRank.Hostile) ? 1 : 0;
|
return (otherUnit && unit.GetReactionTo(otherUnit) <= ReputationRank.Hostile) ? 1 : 0;
|
||||||
case UnitConditionVariable.IsSpecMelee:
|
case UnitConditionVariable.IsSpecMelee:
|
||||||
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).Flags.HasFlag(ChrSpecializationFlag.Melee)) ? 1 : 0;
|
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetFlags().HasFlag(ChrSpecializationFlag.Melee)) ? 1 : 0;
|
||||||
case UnitConditionVariable.IsSpecTank:
|
case UnitConditionVariable.IsSpecTank:
|
||||||
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).Role == 0) ? 1 : 0;
|
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Tank) ? 1 : 0;
|
||||||
case UnitConditionVariable.IsSpecRanged:
|
case UnitConditionVariable.IsSpecRanged:
|
||||||
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).Flags.HasFlag(ChrSpecializationFlag.Ranged)) ? 1 : 0;
|
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetFlags().HasFlag(ChrSpecializationFlag.Ranged)) ? 1 : 0;
|
||||||
case UnitConditionVariable.IsSpecHealer:
|
case UnitConditionVariable.IsSpecHealer:
|
||||||
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).Role == 1) ? 1 : 0;
|
return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Healer) ? 1 : 0;
|
||||||
case UnitConditionVariable.IsPlayerControlledNPC:
|
case UnitConditionVariable.IsPlayerControlledNPC:
|
||||||
return unit.IsCreature() && unit.HasUnitFlag(UnitFlags.PlayerControlled) ? 1 : 0;
|
return unit.IsCreature() && unit.HasUnitFlag(UnitFlags.PlayerControlled) ? 1 : 0;
|
||||||
case UnitConditionVariable.IsDying:
|
case UnitConditionVariable.IsDying:
|
||||||
|
|||||||
@@ -216,7 +216,7 @@ namespace Game.DataStorage
|
|||||||
//ASSERT(chrSpec.OrderIndex < MAX_SPECIALIZATIONS);
|
//ASSERT(chrSpec.OrderIndex < MAX_SPECIALIZATIONS);
|
||||||
|
|
||||||
uint storageIndex = chrSpec.ClassID;
|
uint storageIndex = chrSpec.ClassID;
|
||||||
if (chrSpec.Flags.HasAnyFlag(ChrSpecializationFlag.PetOverrideSpec))
|
if (chrSpec.GetFlags().HasFlag(ChrSpecializationFlag.PetOverrideSpec))
|
||||||
{
|
{
|
||||||
//ASSERT(!chrSpec.ClassID);
|
//ASSERT(!chrSpec.ClassID);
|
||||||
storageIndex = (int)Class.Max;
|
storageIndex = (int)Class.Max;
|
||||||
|
|||||||
@@ -301,12 +301,15 @@ namespace Game.DataStorage
|
|||||||
public byte OrderIndex;
|
public byte OrderIndex;
|
||||||
public sbyte PetTalentType;
|
public sbyte PetTalentType;
|
||||||
public sbyte Role;
|
public sbyte Role;
|
||||||
public ChrSpecializationFlag Flags;
|
public uint Flags;
|
||||||
public int SpellIconFileID;
|
public int SpellIconFileID;
|
||||||
public sbyte PrimaryStatPriority;
|
public sbyte PrimaryStatPriority;
|
||||||
public int AnimReplacements;
|
public int AnimReplacements;
|
||||||
public uint[] MasterySpellID = new uint[PlayerConst.MaxMasterySpells];
|
public uint[] MasterySpellID = new uint[PlayerConst.MaxMasterySpells];
|
||||||
|
|
||||||
|
public ChrSpecializationFlag GetFlags() { return (ChrSpecializationFlag)Flags; }
|
||||||
|
public ChrSpecializationRole GetRole() { return (ChrSpecializationRole)Role; }
|
||||||
|
|
||||||
public bool IsPetSpecialization()
|
public bool IsPetSpecialization()
|
||||||
{
|
{
|
||||||
return ClassID == 0;
|
return ClassID == 0;
|
||||||
|
|||||||
@@ -676,7 +676,7 @@ namespace Scripts.Spells.Druid
|
|||||||
return SpellCastResult.BadTargets;
|
return SpellCastResult.BadTargets;
|
||||||
|
|
||||||
ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(target.GetPrimarySpecialization());
|
ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(target.GetPrimarySpecialization());
|
||||||
if (spec == null || spec.Role != 1)
|
if (spec == null || spec.GetRole() != ChrSpecializationRole.Healer)
|
||||||
return SpellCastResult.BadTargets;
|
return SpellCastResult.BadTargets;
|
||||||
|
|
||||||
return SpellCastResult.SpellCastOk;
|
return SpellCastResult.SpellCastOk;
|
||||||
|
|||||||
Reference in New Issue
Block a user