Implemented ConeAngle from DB2
This commit is contained in:
@@ -92,6 +92,11 @@ public static class MathFunctions
|
|||||||
return a + (b - a) * f;
|
return a + (b - a) * f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static float DegToRad(float degrees)
|
||||||
|
{
|
||||||
|
return degrees * (2.0f * PI / 360.0f);
|
||||||
|
}
|
||||||
|
|
||||||
#region Fuzzy
|
#region Fuzzy
|
||||||
public static bool fuzzyEq(double a, double b)
|
public static bool fuzzyEq(double a, double b)
|
||||||
{
|
{
|
||||||
@@ -109,13 +114,14 @@ public static class MathFunctions
|
|||||||
{
|
{
|
||||||
return !fuzzyEq(a, b);
|
return !fuzzyEq(a, b);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static bool fuzzyLe(double a, double b)
|
public static bool fuzzyLe(double a, double b)
|
||||||
{
|
{
|
||||||
return a < b + eps(a, b);
|
return a < b + eps(a, b);
|
||||||
}
|
}
|
||||||
|
public static bool fuzzyGe(double a, double b)
|
||||||
|
{
|
||||||
|
return a > b - eps(a, b);
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
public static int ApplyPct(ref int Base, float pct)
|
public static int ApplyPct(ref int Base, float pct)
|
||||||
|
|||||||
@@ -952,10 +952,6 @@ namespace Game.Spells
|
|||||||
if (GetSpellInfo().IsSingleTarget())
|
if (GetSpellInfo().IsSingleTarget())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Can't be saved - aura handler relies on calculated amount and changes it
|
|
||||||
if (HasEffectType(AuraType.ConvertRune))
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// No point in saving this, since the stable dialog can't be open on aura load anyway.
|
// No point in saving this, since the stable dialog can't be open on aura load anyway.
|
||||||
if (HasEffectType(AuraType.OpenStable))
|
if (HasEffectType(AuraType.OpenStable))
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -478,8 +478,9 @@ namespace Game.Spells
|
|||||||
WorldObject target = Global.ObjAccessor.GetUnit(m_caster, channelTarget);
|
WorldObject target = Global.ObjAccessor.GetUnit(m_caster, channelTarget);
|
||||||
CallScriptObjectTargetSelectHandlers(ref target, effIndex, targetType);
|
CallScriptObjectTargetSelectHandlers(ref target, effIndex, targetType);
|
||||||
// unit target may be no longer avalible - teleported out of map for example
|
// unit target may be no longer avalible - teleported out of map for example
|
||||||
if (target && target.IsTypeId(TypeId.Unit))
|
Unit unitTarget = target ? target.ToUnit() : null;
|
||||||
AddUnitTarget(target.ToUnit(), 1u << (int)effIndex);
|
if (unitTarget)
|
||||||
|
AddUnitTarget(unitTarget, 1u << (int)effIndex);
|
||||||
else
|
else
|
||||||
Log.outDebug(LogFilter.Spells, "SPELL: cannot find channel spell target for spell ID {0}, effect {1}", m_spellInfo.Id, effIndex);
|
Log.outDebug(LogFilter.Spells, "SPELL: cannot find channel spell target for spell ID {0}, effect {1}", m_spellInfo.Id, effIndex);
|
||||||
}
|
}
|
||||||
@@ -636,13 +637,12 @@ namespace Game.Spells
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
var condList = effect.ImplicitTargetConditions;
|
var condList = effect.ImplicitTargetConditions;
|
||||||
float coneAngle = MathFunctions.PiOver2;
|
|
||||||
float radius = effect.CalcRadius(m_caster) * m_spellValue.RadiusMod;
|
float radius = effect.CalcRadius(m_caster) * m_spellValue.RadiusMod;
|
||||||
|
|
||||||
GridMapTypeMask containerTypeMask = GetSearcherTypeMask(objectType, condList);
|
GridMapTypeMask containerTypeMask = GetSearcherTypeMask(objectType, condList);
|
||||||
if (containerTypeMask != 0)
|
if (containerTypeMask != 0)
|
||||||
{
|
{
|
||||||
var spellCone = new WorldObjectSpellConeTargetCheck(coneAngle, radius, m_caster, m_spellInfo, selectionType, condList);
|
var spellCone = new WorldObjectSpellConeTargetCheck(MathFunctions.DegToRad(m_spellInfo.ConeAngle), radius, m_caster, m_spellInfo, selectionType, condList);
|
||||||
var searcher = new WorldObjectListSearcher(m_caster, targets, spellCone, containerTypeMask);
|
var searcher = new WorldObjectListSearcher(m_caster, targets, spellCone, containerTypeMask);
|
||||||
SearchTargets(searcher, containerTypeMask, m_caster, m_caster.GetPosition(), radius);
|
SearchTargets(searcher, containerTypeMask, m_caster, m_caster.GetPosition(), radius);
|
||||||
|
|
||||||
@@ -7637,7 +7637,9 @@ namespace Game.Spells
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!_caster.IsWithinBoundaryRadius(target.ToUnit()))
|
if (!_caster.IsWithinBoundaryRadius(target.ToUnit()))
|
||||||
if (!_caster.isInFront(target, _coneAngle))
|
// ConeAngle > 0 -> select targets in front
|
||||||
|
// ConeAngle < 0 -> select targets in back
|
||||||
|
if (_caster.HasInArc(_coneAngle, target) != MathFunctions.fuzzyGe(_coneAngle, 0.0f))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
return base.Invoke(target);
|
return base.Invoke(target);
|
||||||
|
|||||||
@@ -228,6 +228,8 @@ namespace Game.Spells
|
|||||||
if (_target != null)
|
if (_target != null)
|
||||||
{
|
{
|
||||||
targets = (SpellCastTargetFlags)_target.Targets;
|
targets = (SpellCastTargetFlags)_target.Targets;
|
||||||
|
ConeAngle = _target.ConeAngle;
|
||||||
|
Width = _target.Width;
|
||||||
TargetCreatureType = _target.TargetCreatureType;
|
TargetCreatureType = _target.TargetCreatureType;
|
||||||
MaxAffectedTargets = _target.MaxAffectedTargets;
|
MaxAffectedTargets = _target.MaxAffectedTargets;
|
||||||
MaxTargetLevel = _target.MaxTargetLevel;
|
MaxTargetLevel = _target.MaxTargetLevel;
|
||||||
@@ -2629,6 +2631,8 @@ namespace Game.Spells
|
|||||||
public uint IconFileDataId { get; set; }
|
public uint IconFileDataId { get; set; }
|
||||||
public uint ActiveIconFileDataId { get; set; }
|
public uint ActiveIconFileDataId { get; set; }
|
||||||
public LocalizedString SpellName { get; set; }
|
public LocalizedString SpellName { get; set; }
|
||||||
|
public float ConeAngle { get; set; }
|
||||||
|
public float Width { get; set; }
|
||||||
public uint MaxTargetLevel { get; set; }
|
public uint MaxTargetLevel { get; set; }
|
||||||
public uint MaxAffectedTargets { get; set; }
|
public uint MaxAffectedTargets { get; set; }
|
||||||
public SpellFamilyNames SpellFamilyName { get; set; }
|
public SpellFamilyNames SpellFamilyName { get; set; }
|
||||||
@@ -3640,7 +3644,7 @@ namespace Game.Spells
|
|||||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.Dest, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 107 TARGET_UNK_DEST_AREA_UNK_107
|
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.Dest, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 107 TARGET_UNK_DEST_AREA_UNK_107
|
||||||
new StaticData(SpellTargetObjectTypes.Gobj, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Cone, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.Front), // 108 TARGET_GAMEOBJECT_CONE
|
new StaticData(SpellTargetObjectTypes.Gobj, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Cone, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.Front), // 108 TARGET_GAMEOBJECT_CONE
|
||||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 109
|
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 109
|
||||||
new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Cone, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.Front), // 110 TARGET_DEST_UNK_110
|
new StaticData(SpellTargetObjectTypes.Unit, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Cone, SpellTargetCheckTypes.Entry , SpellTargetDirectionTypes.Front), // 110 TARGET_DEST_UNK_110
|
||||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 111
|
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 111
|
||||||
new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 112
|
new StaticData(SpellTargetObjectTypes.Dest, SpellTargetReferenceTypes.Caster, SpellTargetSelectionCategories.Default, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 112
|
||||||
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 113
|
new StaticData(SpellTargetObjectTypes.None, SpellTargetReferenceTypes.None, SpellTargetSelectionCategories.Nyi, SpellTargetCheckTypes.Default, SpellTargetDirectionTypes.None), // 113
|
||||||
|
|||||||
@@ -2646,9 +2646,6 @@ namespace Game.Entities
|
|||||||
if (!spellInfo._IsPositiveEffect(2, false))
|
if (!spellInfo._IsPositiveEffect(2, false))
|
||||||
spellInfo.AttributesCu |= SpellCustomAttributes.NegativeEff2;
|
spellInfo.AttributesCu |= SpellCustomAttributes.NegativeEff2;
|
||||||
|
|
||||||
if (spellInfo.GetSpellVisual() == 3879)
|
|
||||||
spellInfo.AttributesCu |= SpellCustomAttributes.ConeBack;
|
|
||||||
|
|
||||||
if (talentSpells.Contains(spellInfo.Id))
|
if (talentSpells.Contains(spellInfo.Id))
|
||||||
spellInfo.AttributesCu |= SpellCustomAttributes.IsTalent;
|
spellInfo.AttributesCu |= SpellCustomAttributes.IsTalent;
|
||||||
|
|
||||||
@@ -2680,6 +2677,10 @@ namespace Game.Entities
|
|||||||
spellInfo.Speed = MotionMaster.SPEED_CHARGE;
|
spellInfo.Speed = MotionMaster.SPEED_CHARGE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (effect.TargetA.GetSelectionCategory() == SpellTargetSelectionCategories.Cone || effect.TargetB.GetSelectionCategory() == SpellTargetSelectionCategories.Cone)
|
||||||
|
if (MathFunctions.fuzzyEq(spellInfo.ConeAngle, 0.0f))
|
||||||
|
spellInfo.ConeAngle = 90.0f;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (spellInfo.ActiveIconFileDataId == 135754) // flight
|
if (spellInfo.ActiveIconFileDataId == 135754) // flight
|
||||||
|
|||||||
Reference in New Issue
Block a user