Core/SmartAI: implement SMART_ACTION_OVERRIDE_LIGHT and SMART_ACTION_OVERRIDE_WEATHER
Port From (https://github.com/TrinityCore/TrinityCore/commit/1d08423725141de712290b18739dcc9b3ea3a7c6)
This commit is contained in:
@@ -1450,6 +1450,46 @@ namespace Game.AI
|
||||
|
||||
break;
|
||||
}
|
||||
case SmartActions.OverrideLight:
|
||||
{
|
||||
var areaEntry = CliDB.AreaTableStorage.LookupByKey(e.Action.overrideLight.zoneId);
|
||||
if (areaEntry == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent zoneId {e.Action.overrideLight.zoneId}, skipped.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areaEntry.ParentAreaID != 0)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses subzone (ID: {e.Action.overrideLight.zoneId}) instead of zone, skipped.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!CliDB.LightStorage.ContainsKey(e.Action.overrideLight.lightId))
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent lightId {e.Action.overrideLight.lightId}, skipped.");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SmartActions.OverrideWeather:
|
||||
{
|
||||
var areaEntry = CliDB.AreaTableStorage.LookupByKey(e.Action.overrideWeather.zoneId);
|
||||
if (areaEntry == null)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses non-existent zoneId {e.Action.overrideWeather.zoneId}, skipped.");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (areaEntry.ParentAreaID != 0)
|
||||
{
|
||||
Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses subzone (ID: {e.Action.overrideWeather.zoneId}) instead of zone, skipped.");
|
||||
return false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case SmartActions.CreateConversation:
|
||||
{
|
||||
if (Global.ConversationDataStorage.GetConversationTemplate(e.Action.conversation.id) == null)
|
||||
@@ -2562,6 +2602,12 @@ namespace Game.AI
|
||||
[FieldOffset(4)]
|
||||
public SpellVisualKit spellVisualKit;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public OverrideLight overrideLight;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public OverrideWeather overrideWeather;
|
||||
|
||||
[FieldOffset(4)]
|
||||
public Conversation conversation;
|
||||
|
||||
@@ -3091,6 +3137,18 @@ namespace Game.AI
|
||||
public uint kitType;
|
||||
public uint duration;
|
||||
}
|
||||
public struct OverrideLight
|
||||
{
|
||||
public uint zoneId;
|
||||
public uint lightId;
|
||||
public uint fadeInTime;
|
||||
}
|
||||
public struct OverrideWeather
|
||||
{
|
||||
public uint zoneId;
|
||||
public uint weatherId;
|
||||
public uint weatherGrade;
|
||||
}
|
||||
public struct Conversation
|
||||
{
|
||||
public uint id;
|
||||
|
||||
@@ -2414,6 +2414,28 @@ namespace Game.AI
|
||||
|
||||
break;
|
||||
}
|
||||
case SmartActions.OverrideLight:
|
||||
{
|
||||
WorldObject obj = GetBaseObject();
|
||||
if (obj != null)
|
||||
{
|
||||
obj.GetMap().SetZoneOverrideLight(e.Action.overrideLight.zoneId, e.Action.overrideLight.lightId, e.Action.overrideLight.fadeInTime);
|
||||
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_LIGHT: {obj.GetGUID()} sets zone override light (zoneId: {e.Action.overrideLight.zoneId}, " +
|
||||
$"lightId: {e.Action.overrideLight.lightId}, fadeInTime: {e.Action.overrideLight.fadeInTime})");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SmartActions.OverrideWeather:
|
||||
{
|
||||
WorldObject obj = GetBaseObject();
|
||||
if (obj != null)
|
||||
{
|
||||
obj.GetMap().SetZoneWeather(e.Action.overrideWeather.zoneId, (WeatherState)e.Action.overrideWeather.weatherId, e.Action.overrideWeather.weatherGrade);
|
||||
Log.outDebug(LogFilter.ScriptsAi, $"SmartScript::ProcessAction: SMART_ACTION_OVERRIDE_WEATHER: {obj.GetGUID()} sets zone weather (zoneId: {e.Action.overrideWeather.zoneId}, " +
|
||||
$"weatherId: {e.Action.overrideWeather.weatherId}, weatherGrade: {e.Action.overrideWeather.weatherGrade})");
|
||||
}
|
||||
break;
|
||||
}
|
||||
case SmartActions.PlaySpellVisualKit:
|
||||
{
|
||||
foreach (var target in targets)
|
||||
|
||||
Reference in New Issue
Block a user