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,
|
||||
Ranged = 0x02,
|
||||
Melee = 0x04,
|
||||
Unknown = 0x08,
|
||||
DualWieldTwoHanded = 0x10, // Used For Cunitdisplay::Setsheatheinvertedfordualwield
|
||||
PetOverrideSpec = 0x20,
|
||||
Recommended = 0x40,
|
||||
}
|
||||
|
||||
public enum ChrSpecializationRole
|
||||
{
|
||||
Tank = 0,
|
||||
Healer = 1,
|
||||
Dps = 2
|
||||
}
|
||||
|
||||
public enum ContentTuningCalcType
|
||||
{
|
||||
Base = 0,
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
// Licensed under the GNU GENERAL PUBLIC LICENSE. See LICENSE file in the project root for full license information.
|
||||
|
||||
using Framework.Constants;
|
||||
using Game.DataStorage;
|
||||
using Game.Entities;
|
||||
using Game.Spells;
|
||||
using System;
|
||||
@@ -393,15 +394,8 @@ namespace Game.AI
|
||||
if (!who)
|
||||
return false;
|
||||
|
||||
return who.GetClass() switch
|
||||
{
|
||||
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,
|
||||
};
|
||||
return who.GetPrimarySpecialization() != 0
|
||||
&& CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Healer;
|
||||
}
|
||||
|
||||
bool IsPlayerRangedAttacker(Player who)
|
||||
@@ -409,36 +403,8 @@ namespace Game.AI
|
||||
if (!who)
|
||||
return false;
|
||||
|
||||
switch (who.GetClass())
|
||||
{
|
||||
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;
|
||||
}
|
||||
return who.GetPrimarySpecialization() != 0
|
||||
&& CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetFlags() == ChrSpecializationFlag.Ranged;
|
||||
}
|
||||
|
||||
Tuple<Spell, Unit> VerifySpellCast(uint spellId, Unit target)
|
||||
|
||||
@@ -2742,13 +2742,13 @@ namespace Game
|
||||
case UnitConditionVariable.IsEnemy:
|
||||
return (otherUnit && unit.GetReactionTo(otherUnit) <= ReputationRank.Hostile) ? 1 : 0;
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
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:
|
||||
return unit.IsCreature() && unit.HasUnitFlag(UnitFlags.PlayerControlled) ? 1 : 0;
|
||||
case UnitConditionVariable.IsDying:
|
||||
|
||||
@@ -216,7 +216,7 @@ namespace Game.DataStorage
|
||||
//ASSERT(chrSpec.OrderIndex < MAX_SPECIALIZATIONS);
|
||||
|
||||
uint storageIndex = chrSpec.ClassID;
|
||||
if (chrSpec.Flags.HasAnyFlag(ChrSpecializationFlag.PetOverrideSpec))
|
||||
if (chrSpec.GetFlags().HasFlag(ChrSpecializationFlag.PetOverrideSpec))
|
||||
{
|
||||
//ASSERT(!chrSpec.ClassID);
|
||||
storageIndex = (int)Class.Max;
|
||||
|
||||
@@ -301,12 +301,15 @@ namespace Game.DataStorage
|
||||
public byte OrderIndex;
|
||||
public sbyte PetTalentType;
|
||||
public sbyte Role;
|
||||
public ChrSpecializationFlag Flags;
|
||||
public uint Flags;
|
||||
public int SpellIconFileID;
|
||||
public sbyte PrimaryStatPriority;
|
||||
public int AnimReplacements;
|
||||
public uint[] MasterySpellID = new uint[PlayerConst.MaxMasterySpells];
|
||||
|
||||
public ChrSpecializationFlag GetFlags() { return (ChrSpecializationFlag)Flags; }
|
||||
public ChrSpecializationRole GetRole() { return (ChrSpecializationRole)Role; }
|
||||
|
||||
public bool IsPetSpecialization()
|
||||
{
|
||||
return ClassID == 0;
|
||||
|
||||
@@ -676,7 +676,7 @@ namespace Scripts.Spells.Druid
|
||||
return SpellCastResult.BadTargets;
|
||||
|
||||
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.SpellCastOk;
|
||||
|
||||
Reference in New Issue
Block a user