mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-13 11:43:18 -04:00
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:
@@ -192,7 +192,7 @@ void SmartScript::ProcessEventsFor(SMART_EVENT e, Unit* unit, uint32 var0, uint3
|
||||
if (eventType == SMART_EVENT_LINK)//special handling
|
||||
continue;
|
||||
|
||||
if (eventType == e /*&& (!i->event.event_phase_mask || IsInPhase(i->event.event_phase_mask)) && !(i->event.event_flags & SMART_EVENT_FLAG_NOT_REPEATABLE && i->runOnce)*/)
|
||||
if (eventType == e)
|
||||
if (sConditionMgr->IsObjectMeetingSmartEventConditions(i->entryOrGuid, i->event_id, i->source_type, unit, GetBaseObject()))
|
||||
ProcessEvent(*i, unit, var0, var1, bvar, spell, gob, varString);
|
||||
}
|
||||
@@ -3165,6 +3165,14 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
ProcessAction(e, unit, var0, var1);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_EVENT_PHASE_CHANGE:
|
||||
{
|
||||
if (!IsInPhase(e.event.eventPhaseChange.phasemask))
|
||||
return;
|
||||
|
||||
ProcessAction(e, GetLastInvoker());
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_GAME_EVENT_START:
|
||||
case SMART_EVENT_GAME_EVENT_END:
|
||||
{
|
||||
@@ -3804,5 +3812,30 @@ Unit* SmartScript::GetLastInvoker(Unit* invoker) const
|
||||
void SmartScript::IncPhase(uint32 p)
|
||||
{
|
||||
// protect phase from overflowing
|
||||
mEventPhase = std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p);
|
||||
SetPhase(std::min<uint32>(SMART_EVENT_PHASE_12, mEventPhase + p));
|
||||
}
|
||||
|
||||
void SmartScript::DecPhase(uint32 p)
|
||||
{
|
||||
if (p >= mEventPhase)
|
||||
SetPhase(0);
|
||||
else
|
||||
SetPhase(mEventPhase - p);
|
||||
}
|
||||
|
||||
void SmartScript::SetPhase(uint32 p)
|
||||
{
|
||||
uint32 oldPhase = mEventPhase;
|
||||
|
||||
mEventPhase = p;
|
||||
|
||||
if (oldPhase != mEventPhase)
|
||||
ProcessEventsFor(SMART_EVENT_EVENT_PHASE_CHANGE);
|
||||
}
|
||||
|
||||
bool SmartScript::IsInPhase(uint32 p) const
|
||||
{
|
||||
if (mEventPhase == 0)
|
||||
return false;
|
||||
return ((1 << (mEventPhase - 1)) & p) != 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user