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