Core/SAI: Add support to friendly+hostile to SMART_EVENT_OOC_LOS and SMART_EVENT_IC_LOS

Port From (https://github.com/TrinityCore/TrinityCore/commit/76c470fb3207c195804e789812a330394e81ecc3)
This commit is contained in:
hondacrx
2022-05-26 21:46:26 -04:00
parent 2703633af8
commit 3669df2708
3 changed files with 21 additions and 6 deletions
@@ -628,6 +628,11 @@ namespace Game.AI
case SmartEvents.IcLos:
if (!IsMinMaxValid(e, e.Event.los.cooldownMin, e.Event.los.cooldownMax))
return false;
if (e.Event.los.hostilityMode >= (uint)LOSHostilityMode.End)
{
Log.outError(LogFilter.Sql, $"SmartAIMgr: {e} uses hostilityMode with invalid value {e.Event.los.hostilityMode} (max allowed value {LOSHostilityMode.End - 1}), skipped.");
return false;
}
break;
case SmartEvents.Respawn:
if (e.Event.respawn.type == (uint)SmartRespawnCondition.Map && CliDB.MapStorage.LookupByKey(e.Event.respawn.map) == null)
@@ -912,7 +917,7 @@ namespace Game.AI
case SmartEvents.QuestObjCompletion:
if (Global.ObjectMgr.GetQuestObjective(e.Event.questObjective.id) == null)
{
Log.outError(LogFilter.Sql, $"SmartAIMgr: Event SMART_EVENT_QUEST_OBJ_COPLETETION using invalid objective id {e.Event.questObjective.id}, skipped.");
Log.outError(LogFilter.Sql, $"SmartAIMgr: Event SMART_EVENT_QUEST_OBJ_COMPLETION using invalid objective id {e.Event.questObjective.id}, skipped.");
return false;
}
break;
@@ -2165,7 +2170,7 @@ namespace Game.AI
}
public struct Los
{
public uint noHostile;
public uint hostilityMode;
public uint maxDist;
public uint cooldownMin;
public uint cooldownMax;
+4 -2
View File
@@ -3455,8 +3455,9 @@ namespace Game.AI
//if range is ok and we are actually in LOS
if (_me.IsWithinDistInMap(unit, range) && _me.IsWithinLOSInMap(unit))
{
LOSHostilityMode hostilityMode = (LOSHostilityMode)e.Event.los.hostilityMode;
//if friendly event&&who is not hostile OR hostile event&&who is hostile
if ((e.Event.los.noHostile != 0 && !_me.IsHostileTo(unit)) || (e.Event.los.noHostile == 0 && _me.IsHostileTo(unit)))
if ((hostilityMode == LOSHostilityMode.Any) || (hostilityMode == LOSHostilityMode.NotHostile && !_me.IsHostileTo(unit)) || (hostilityMode == LOSHostilityMode.Hostile && _me.IsHostileTo(unit)))
{
if (e.Event.los.playerOnly != 0 && !unit.IsTypeId(TypeId.Player))
return;
@@ -3477,8 +3478,9 @@ namespace Game.AI
//if range is ok and we are actually in LOS
if (_me.IsWithinDistInMap(unit, range) && _me.IsWithinLOSInMap(unit))
{
LOSHostilityMode hostilityMode = (LOSHostilityMode)e.Event.los.hostilityMode;
//if friendly event&&who is not hostile OR hostile event&&who is hostile
if ((e.Event.los.noHostile != 0 && !_me.IsHostileTo(unit)) || (e.Event.los.noHostile == 0 && _me.IsHostileTo(unit)))
if ((hostilityMode == LOSHostilityMode.Any) || (hostilityMode == LOSHostilityMode.NotHostile && !_me.IsHostileTo(unit)) || (hostilityMode == LOSHostilityMode.Hostile && _me.IsHostileTo(unit)))
{
if (e.Event.los.playerOnly != 0 && !unit.IsTypeId(TypeId.Player))
return;