Core/SmartAI: implemented SMART_EVENT_EVENT_PHASE_CHANGE

- Use instead of Update + event_phase_mask when action needs to be synchronized

(cherry picked from commit 619a5534c5)
This commit is contained in:
ariel-
2017-06-10 19:17:41 -03:00
committed by Shauren
parent 7a5d331f11
commit 593d3243d4
4 changed files with 68 additions and 20 deletions

View File

@@ -857,6 +857,27 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
if (!IsTextValid(e, e.event.textOver.textGroupID))
return false;
break;
case SMART_EVENT_EVENT_PHASE_CHANGE:
{
if (!e.event.eventPhaseChange.phasemask)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u has no param set, event won't be executed!.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
return false;
}
if (e.event.eventPhaseChange.phasemask > SMART_EVENT_PHASE_ALL)
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses invalid phasemask %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.eventPhaseChange.phasemask);
return false;
}
if (e.event.event_phase_mask && !(e.event.event_phase_mask & e.event.eventPhaseChange.phasemask))
{
TC_LOG_ERROR("sql.sql", "SmartAIMgr: Entry " SI64FMTD " SourceType %u Event %u Action %u uses event phasemask %u and incompatible event_param1 %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.event_phase_mask, e.event.eventPhaseChange.phasemask);
return false;
}
break;
}
case SMART_EVENT_IS_BEHIND_TARGET:
{
if (!IsMinMaxValid(e, e.event.behindTarget.cooldownMin, e.event.behindTarget.cooldownMax))
@@ -1731,4 +1752,4 @@ void ObjectGuidVector::UpdateObjects(WorldObject const& ref) const
for (ObjectGuid const& guid : _guidVector)
if (WorldObject* obj = ObjectAccessor::GetWorldObject(ref, guid))
_objectVector.push_back(obj);
}
}