Core/SAI: Add support to friendly+hostile to SMART_EVENT_OOC_LOS and SMART_EVENT_IC_LOS (#26579)

Change SMART_EVENT_OOC_LOS and SMART_EVENT_IC_LOS first parameter to have 3 values:
- 0 : Hostile
- 1 : Not hostile (not that Friendly and Not hostile have different meanings)
- 2 : Any, as in both Hostile and Not hostile

Close #24789

* Add validation on startup for allowed values.
Code cleanup.

* Fix errors

(cherry picked from commit 9e7cdb02d2)
This commit is contained in:
Giacomo Pozzoni
2021-06-08 17:59:46 +02:00
committed by Shauren
parent bea0528436
commit 76c470fb32
4 changed files with 33 additions and 7 deletions
@@ -3434,9 +3434,11 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
//if range is ok and we are actually in LOS
if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
{
SmartEvent::LOSHostilityMode hostilityMode = static_cast<SmartEvent::LOSHostilityMode>(e.event.los.hostilityMode);
//if friendly event&&who is not hostile OR hostile event&&who is hostile
if ((e.event.los.noHostile && !me->IsHostileTo(unit)) ||
(!e.event.los.noHostile && me->IsHostileTo(unit)))
if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
(hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
(hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
{
if (e.event.los.playerOnly && unit->GetTypeId() != TYPEID_PLAYER)
return;
@@ -3456,9 +3458,11 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
//if range is ok and we are actually in LOS
if (me->IsWithinDistInMap(unit, range) && me->IsWithinLOSInMap(unit))
{
SmartEvent::LOSHostilityMode hostilityMode = static_cast<SmartEvent::LOSHostilityMode>(e.event.los.hostilityMode);
//if friendly event&&who is not hostile OR hostile event&&who is hostile
if ((e.event.los.noHostile && !me->IsHostileTo(unit)) ||
(!e.event.los.noHostile && me->IsHostileTo(unit)))
if ((hostilityMode == SmartEvent::LOSHostilityMode::Any) ||
(hostilityMode == SmartEvent::LOSHostilityMode::NotHostile && !me->IsHostileTo(unit)) ||
(hostilityMode == SmartEvent::LOSHostilityMode::Hostile && me->IsHostileTo(unit)))
{
if (e.event.los.playerOnly && unit->GetTypeId() != TYPEID_PLAYER)
return;