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
+10 -2
View File
@@ -175,7 +175,7 @@ namespace Framework.Constants
Evade = 7, // None
SpellHit = 8, // Spellid, School, Cooldownmin, Cooldownmax
Range = 9, // Mindist, Maxdist, Repeatmin, Repeatmax
OocLos = 10, // Nohostile, Maxrnage, Cooldownmin, Cooldownmax
OocLos = 10, // HostilityMode, Maxrnage, Cooldownmin, Cooldownmax
Respawn = 11, // Type, Mapid, Zoneid
TargetHealthPct = 12, // Hpmin%, Hpmax%, Repeatmin, Repeatmax
VictimCasting = 13, // Repeatmin, Repeatmax
@@ -191,7 +191,7 @@ namespace Framework.Constants
HasAura = 23, // Param1 = Spellid, Param2 = Stack Amount, Param3/4 Repeatmin, Repeatmax
TargetBuffed = 24, // Param1 = Spellid, Param2 = Stack Amount, Param3/4 Repeatmin, Repeatmax
Reset = 25, // Called After Combat, When The Creature Respawn And Spawn.
IcLos = 26, // Nohostile, Maxrnage, Cooldownmin, Cooldownmax
IcLos = 26, // HostilityMode, Maxrnage, Cooldownmin, Cooldownmax
PassengerBoarded = 27, // Cooldownmin, Cooldownmax
PassengerRemoved = 28, // Cooldownmin, Cooldownmax
Charmed = 29, // onRemove (0 - on apply, 1 - on remove)
@@ -443,4 +443,12 @@ namespace Framework.Constants
End = 31
}
public enum LOSHostilityMode
{
Hostile = 0,
NotHostile = 1,
Any = 2,
End
}
}
@@ -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;