Misc updates/fixes

This commit is contained in:
hondacrx
2022-01-27 12:36:56 -05:00
parent 169abc1531
commit 6c0e21b4de
36 changed files with 415 additions and 354 deletions
+19 -5
View File
@@ -108,7 +108,7 @@ namespace Game.AI
if (!CliDB.SoundKitStorage.ContainsKey(soundId))
{
Log.outError(LogFilter.Scripts, "Invalid soundId {0} used in DoPlaySoundToSet (Source: TypeId {1}, GUID {2})", soundId, source.GetTypeId(), source.GetGUID().ToString());
Log.outError(LogFilter.ScriptsAi, $"ScriptedAI::DoPlaySoundToSet: Invalid soundId {soundId} used in DoPlaySoundToSet (Source: {source.GetGUID()})");
return;
}
@@ -307,9 +307,24 @@ namespace Game.AI
if (mechanic != 0 && tempSpell.Mechanic != mechanic)
continue;
// Continue if we don't have the mana to actually cast this spell
bool hasPower = true;
foreach (SpellPowerCost cost in tempSpell.CalcPowerCost(me, tempSpell.GetSchoolMask()))
{
if (cost.Amount > me.GetPower(cost.Power))
{
hasPower = false;
break;
}
}
if (!hasPower)
continue;
//Check if the spell meets our range requirements
if (rangeMin != 0 && me.GetSpellMinRangeForTarget(target, tempSpell) < rangeMin)
continue;
if (rangeMax != 0 && me.GetSpellMaxRangeForTarget(target, tempSpell) > rangeMax)
continue;
@@ -350,8 +365,7 @@ namespace Game.AI
if (player != null)
player.TeleportTo(unit.GetMapId(), x, y, z, o, TeleportToOptions.NotLeaveCombat);
else
Log.outError(LogFilter.Scripts, "Creature {0} (Entry: {1}) Tried to teleport non-player unit (Type: {2} GUID: {3}) to X: {4} Y: {5} Z: {6} O: {7}. Aborted.",
me.GetGUID(), me.GetEntry(), unit.GetTypeId(), unit.GetGUID(), x, y, z, o);
Log.outError(LogFilter.ScriptsAi, $"ScriptedAI::DoTeleportPlayer: Creature {me.GetGUID()} Tried to teleport non-player unit ({unit.GetGUID()}) to X: {x} Y: {y} Z: {z} O: {o}. Aborted.");
}
public void DoTeleportAll(float x, float y, float z, float o)
@@ -631,7 +645,7 @@ namespace Game.AI
{
if (delayToRespawn < TimeSpan.FromSeconds(2))
{
Log.outError(LogFilter.Scripts, "_DespawnAtEvade called with delay of {0} seconds, defaulting to 2.", delayToRespawn);
Log.outError(LogFilter.ScriptsAi, $"BossAI::_DespawnAtEvade: called with delay of {delayToRespawn} seconds, defaulting to 2 (me: {me.GetGUID()})");
delayToRespawn = TimeSpan.FromSeconds(2);
}
@@ -641,7 +655,7 @@ namespace Game.AI
TempSummon whoSummon = who.ToTempSummon();
if (whoSummon)
{
Log.outWarn(LogFilter.ScriptsAi, "_DespawnAtEvade called on a temporary summon.");
Log.outWarn(LogFilter.ScriptsAi, $"BossAI::_DespawnAtEvade: called on a temporary summon (who: {who.GetGUID()})");
whoSummon.UnSummon();
return;
}
+15 -15
View File
@@ -143,7 +143,7 @@ namespace Game.AI
{
AddEscortState(EscortState.Returning);
ReturnToLastPoint();
Log.outDebug(LogFilter.Scripts, "EscortAI.EnterEvadeMode has left combat and is now returning to last point");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI.EnterEvadeMode has left combat and is now returning to last point {me.GetGUID()}");
}
else
{
@@ -195,7 +195,7 @@ namespace Game.AI
if (_despawnAtEnd)
{
Log.outDebug(LogFilter.Scripts, "EscortAI.UpdateAI: reached end of waypoints, despawning at end");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::UpdateAI: reached end of waypoints, despawning at end ({me.GetGUID()})");
if (_returnToStart)
{
Position respawnPosition = new();
@@ -203,7 +203,7 @@ namespace Game.AI
me.GetRespawnPosition(out respawnPosition.posX, out respawnPosition.posY, out respawnPosition.posZ, out orientation);
respawnPosition.SetOrientation(orientation);
me.GetMotionMaster().MovePoint(EscortPointIds.Home, respawnPosition);
Log.outDebug(LogFilter.Scripts, $"EscortAI.UpdateAI: returning to spawn location: {respawnPosition}");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::UpdateAI: returning to spawn location: {respawnPosition} ({me.GetGUID()})");
}
else if (_instantRespawn)
me.Respawn();
@@ -211,7 +211,7 @@ namespace Game.AI
me.DespawnOrUnsummon();
}
Log.outDebug(LogFilter.Scripts, "EscortAI.UpdateAI: reached end of waypoints");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::UpdateAI: reached end of waypoints ({me.GetGUID()})");
RemoveEscortState(EscortState.Escorting);
return;
}
@@ -242,7 +242,7 @@ namespace Game.AI
{
if (!IsPlayerOrGroupInRange())
{
Log.outDebug(LogFilter.Scripts, "EscortAI failed because player/group was to far away or not found");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::UpdateAI: failed because player/group was to far away or not found ({me.GetGUID()})");
bool isEscort = false;
CreatureData creatureData = me.GetCreatureData();
@@ -293,7 +293,7 @@ namespace Game.AI
if (Id == EscortPointIds.LastPoint)
{
Log.outDebug(LogFilter.Scripts, "EscortAI.MovementInform has returned to original position before combat");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::MovementInform has returned to original position before combat ({me.GetGUID()})");
me.SetWalk(!_running);
RemoveEscortState(EscortState.Returning);
@@ -301,16 +301,16 @@ namespace Game.AI
}
else if (Id == EscortPointIds.Home)
{
Log.outDebug(LogFilter.Scripts, "EscortAI.MovementInform: returned to home location and restarting waypoint path");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::MovementInform: returned to home location and restarting waypoint path ({me.GetGUID()})");
_started = false;
}
}
else if (moveType == MovementGeneratorType.Waypoint)
{
Cypher.Assert(Id < _path.nodes.Count, $"EscortAI.MovementInform: referenced movement id ({Id}) points to non-existing node in loaded path");
Cypher.Assert(Id < _path.nodes.Count, $"EscortAI::MovementInform: referenced movement id ({Id}) points to non-existing node in loaded path ({me.GetGUID()})");
WaypointNode waypoint = _path.nodes[(int)Id];
Log.outDebug(LogFilter.Scripts, $"EscortAI.MovementInform: waypoint node {waypoint.id} reached");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::MovementInform: waypoint node {waypoint.id} reached ({me.GetGUID()})");
// last point
if (Id == _path.nodes.Count - 1)
@@ -387,15 +387,15 @@ namespace Game.AI
}
}
if (me.GetVictim())
if (me.IsEngaged())
{
Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) attempts to Start while in combat");
Log.outError(LogFilter.ScriptsAi, $"EscortAI::Start: (script: {me.GetScriptName()} attempts to Start while in combat ({me.GetGUID()})");
return;
}
if (HasEscortState(EscortState.Escorting))
{
Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) attempts to Start while already escorting");
Log.outError(LogFilter.ScriptsAi, $"EscortAI::Start: (script: {me.GetScriptName()} attempts to Start while already escorting ({me.GetGUID()})");
return;
}
@@ -406,7 +406,7 @@ namespace Game.AI
if (_path.nodes.Empty())
{
Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) starts with 0 waypoints (possible missing entry in script_waypoint. Quest: {(quest != null ? quest.Id : 0)}).");
Log.outError(LogFilter.ScriptsAi, $"EscortAI::Start: (script: {me.GetScriptName()} starts with 0 waypoints (possible missing entry in script_waypoint. Quest: {(quest != null ? quest.Id : 0)} ({me.GetGUID()})");
return;
}
@@ -418,7 +418,7 @@ namespace Game.AI
_returnToStart = canLoopPath;
if (_returnToStart && _instantRespawn)
Log.outError(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn.");
Log.outError(LogFilter.ScriptsAi, $"EscortAI::Start: (script: {me.GetScriptName()} is set to return home after waypoint end and instant respawn at waypoint end. Creature will never despawn ({me.GetGUID()})");
me.GetMotionMaster().MoveIdle();
me.GetMotionMaster().Clear(MovementGeneratorPriority.Normal);
@@ -432,7 +432,7 @@ namespace Game.AI
me.SetImmuneToNPC(false);
}
Log.outDebug(LogFilter.Scripts, $"EscortAI.Start: (script: {me.GetScriptName()}, creature entry: {me.GetEntry()}) started with {_path.nodes.Count} waypoints. ActiveAttacker = {_activeAttacker}, Run = {_running}, Player = {_playerGUID}");
Log.outDebug(LogFilter.ScriptsAi, $"EscortAI::Start: (script: {me.GetScriptName()}, started with {_path.nodes.Count} waypoints. ActiveAttacker = {_activeAttacker}, Run = {_running}, Player = {_playerGUID} ({me.GetGUID()})");
// set initial speed
me.SetWalk(!_running);
@@ -109,7 +109,7 @@ namespace Game.AI
{
if (HasFollowState(FollowState.Complete) && !HasFollowState(FollowState.PostEvent))
{
Log.outDebug(LogFilter.Scripts, "FollowerAI is set completed, despawns.");
Log.outDebug(LogFilter.ScriptsAi, $"FollowerAI::UpdateAI: is set completed, despawns. ({me.GetGUID()})");
me.DespawnOrUnsummon();
return;
}
@@ -156,7 +156,7 @@ namespace Game.AI
if (maxRangeExceeded || questAbandoned)
{
Log.outDebug(LogFilter.Scripts, $"FollowerAI::UpdateAI: failed because player/group was to far away or not found ({me.GetGUID()})");
Log.outDebug(LogFilter.ScriptsAi, $"FollowerAI::UpdateAI: failed because player/group was to far away or not found ({me.GetGUID()})");
me.DespawnOrUnsummon();
return;
}