Fixed a crash with AISpellInfoType having cooldown default to 0 should be default 5000.
This commit is contained in:
@@ -45,7 +45,7 @@ namespace Framework.Constants
|
|||||||
Unknown = 5 // found in 2.2.3 for 2 mobs
|
Unknown = 5 // found in 2.2.3 for 2 mobs
|
||||||
}
|
}
|
||||||
|
|
||||||
[System.Flags]
|
[Flags]
|
||||||
public enum UnitFlags : uint
|
public enum UnitFlags : uint
|
||||||
{
|
{
|
||||||
ServerControlled = 0x01,
|
ServerControlled = 0x01,
|
||||||
|
|||||||
@@ -189,6 +189,7 @@ namespace Framework.Constants
|
|||||||
public const int BoundaryVisualizeStepSize = 1;
|
public const int BoundaryVisualizeStepSize = 1;
|
||||||
public const int BoundaryVisualizeFailsafeLimit = 750;
|
public const int BoundaryVisualizeFailsafeLimit = 750;
|
||||||
public const int BoundaryVisualizeSpawnHeight = 5;
|
public const int BoundaryVisualizeSpawnHeight = 5;
|
||||||
|
public const uint AIDefaultCooldown = 5000;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// GameObject Const
|
/// GameObject Const
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Game.AI
|
|||||||
foreach (var id in Spells)
|
foreach (var id in Spells)
|
||||||
{
|
{
|
||||||
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
||||||
if (info.condition == AICondition.Die)
|
if (info != null && info.condition == AICondition.Die)
|
||||||
me.CastSpell(killer, id, true);
|
me.CastSpell(killer, id, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -56,10 +56,13 @@ namespace Game.AI
|
|||||||
foreach (var id in Spells)
|
foreach (var id in Spells)
|
||||||
{
|
{
|
||||||
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
||||||
if (info.condition == AICondition.Aggro)
|
if (info != null)
|
||||||
me.CastSpell(victim, id, false);
|
{
|
||||||
else if (info.condition == AICondition.Combat)
|
if (info.condition == AICondition.Aggro)
|
||||||
_events.ScheduleEvent(id, info.cooldown + RandomHelper.Rand32() % info.cooldown);
|
me.CastSpell(victim, id, false);
|
||||||
|
else if (info.condition == AICondition.Combat)
|
||||||
|
_events.ScheduleEvent(id, info.cooldown + RandomHelper.Rand32() % info.cooldown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,7 +81,8 @@ namespace Game.AI
|
|||||||
{
|
{
|
||||||
DoCast(spellId);
|
DoCast(spellId);
|
||||||
AISpellInfoType info = GetAISpellInfo(spellId, me.GetMap().GetDifficultyID());
|
AISpellInfoType info = GetAISpellInfo(spellId, me.GetMap().GetDifficultyID());
|
||||||
_events.ScheduleEvent(spellId, info.cooldown + RandomHelper.Rand32() % info.cooldown);
|
if (info != null)
|
||||||
|
_events.ScheduleEvent(spellId, info.cooldown + RandomHelper.Rand32() % info.cooldown);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
DoMeleeAttackIfReady();
|
DoMeleeAttackIfReady();
|
||||||
@@ -121,7 +125,7 @@ namespace Game.AI
|
|||||||
foreach (var id in Spells)
|
foreach (var id in Spells)
|
||||||
{
|
{
|
||||||
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
||||||
if (info.condition == AICondition.Combat && _attackDist > info.maxRange)
|
if (info != null && info.condition == AICondition.Combat && _attackDist > info.maxRange)
|
||||||
_attackDist = info.maxRange;
|
_attackDist = info.maxRange;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,17 +148,20 @@ namespace Game.AI
|
|||||||
foreach (var id in Spells)
|
foreach (var id in Spells)
|
||||||
{
|
{
|
||||||
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
AISpellInfoType info = GetAISpellInfo(id, me.GetMap().GetDifficultyID());
|
||||||
if (info.condition == AICondition.Aggro)
|
if (info != null)
|
||||||
me.CastSpell(victim, id, false);
|
|
||||||
else if (info.condition == AICondition.Combat)
|
|
||||||
{
|
{
|
||||||
uint cooldown = info.realCooldown;
|
if (info.condition == AICondition.Aggro)
|
||||||
if (count == spell)
|
me.CastSpell(victim, id, false);
|
||||||
|
else if (info.condition == AICondition.Combat)
|
||||||
{
|
{
|
||||||
DoCast(Spells[spell]);
|
uint cooldown = info.realCooldown;
|
||||||
cooldown += (uint)me.GetCurrentSpellCastTime(id);
|
if (count == spell)
|
||||||
|
{
|
||||||
|
DoCast(Spells[spell]);
|
||||||
|
cooldown += (uint)me.GetCurrentSpellCastTime(id);
|
||||||
|
}
|
||||||
|
_events.ScheduleEvent(id, cooldown);
|
||||||
}
|
}
|
||||||
_events.ScheduleEvent(id, cooldown);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -181,7 +188,8 @@ namespace Game.AI
|
|||||||
DoCast(spellId);
|
DoCast(spellId);
|
||||||
uint casttime = (uint)me.GetCurrentSpellCastTime(spellId);
|
uint casttime = (uint)me.GetCurrentSpellCastTime(spellId);
|
||||||
AISpellInfoType info = GetAISpellInfo(spellId, me.GetMap().GetDifficultyID());
|
AISpellInfoType info = GetAISpellInfo(spellId, me.GetMap().GetDifficultyID());
|
||||||
_events.ScheduleEvent(spellId, (casttime != 0 ? casttime : 500) + info.realCooldown);
|
if (info != null)
|
||||||
|
_events.ScheduleEvent(spellId, (casttime != 0 ? casttime : 500) + info.realCooldown);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -491,8 +491,15 @@ namespace Game.AI
|
|||||||
public List<AreaBoundary> GetBoundary() { return _boundary; }
|
public List<AreaBoundary> GetBoundary() { return _boundary; }
|
||||||
}
|
}
|
||||||
|
|
||||||
public struct AISpellInfoType
|
public class AISpellInfoType
|
||||||
{
|
{
|
||||||
|
public AISpellInfoType()
|
||||||
|
{
|
||||||
|
target = AITarget.Self;
|
||||||
|
condition = AICondition.Combat;
|
||||||
|
cooldown = SharedConst.AIDefaultCooldown;
|
||||||
|
}
|
||||||
|
|
||||||
public AITarget target;
|
public AITarget target;
|
||||||
public AICondition condition;
|
public AICondition condition;
|
||||||
public uint cooldown;
|
public uint cooldown;
|
||||||
|
|||||||
@@ -252,9 +252,13 @@ namespace Game.AI
|
|||||||
public void DoCast(uint spellId)
|
public void DoCast(uint spellId)
|
||||||
{
|
{
|
||||||
Unit target = null;
|
Unit target = null;
|
||||||
|
AITarget aiTargetType = AITarget.Self;
|
||||||
|
|
||||||
AISpellInfoType info = GetAISpellInfo(spellId, me.GetMap().GetDifficultyID());
|
AISpellInfoType info = GetAISpellInfo(spellId, me.GetMap().GetDifficultyID());
|
||||||
switch (info.target)
|
if (info != null)
|
||||||
|
aiTargetType = info.target;
|
||||||
|
|
||||||
|
switch (aiTargetType)
|
||||||
{
|
{
|
||||||
default:
|
default:
|
||||||
case AITarget.Self:
|
case AITarget.Self:
|
||||||
@@ -321,8 +325,6 @@ namespace Game.AI
|
|||||||
|
|
||||||
public static void FillAISpellInfo()
|
public static void FillAISpellInfo()
|
||||||
{
|
{
|
||||||
//AISpellInfo = new AISpellInfoType[spellStorage.Keys.Max() + 1];
|
|
||||||
|
|
||||||
Global.SpellMgr.ForEachSpellInfo(spellInfo =>
|
Global.SpellMgr.ForEachSpellInfo(spellInfo =>
|
||||||
{
|
{
|
||||||
AISpellInfoType AIInfo = new();
|
AISpellInfoType AIInfo = new();
|
||||||
|
|||||||
@@ -223,7 +223,7 @@ namespace Game.AI
|
|||||||
AISpellInfoType aiSpell = GetAISpellInfo(me.m_spells[i], me.GetMap().GetDifficultyID());
|
AISpellInfoType aiSpell = GetAISpellInfo(me.m_spells[i], me.GetMap().GetDifficultyID());
|
||||||
|
|
||||||
//This spell doesn't exist
|
//This spell doesn't exist
|
||||||
if (tempSpell == null)
|
if (tempSpell == null || aiSpell == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// Targets and Effects checked first as most used restrictions
|
// Targets and Effects checked first as most used restrictions
|
||||||
|
|||||||
Reference in New Issue
Block a user