mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Merge pull request #8978 from Naios/sai_timed_cond
Core/SmartScripts: Check Conditions also for timed Events
This commit is contained in:
@@ -2011,6 +2011,17 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
||||
}
|
||||
}
|
||||
|
||||
void SmartScript::ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit, uint32 var0, uint32 var1, bool bvar, const SpellInfo* spell, GameObject* gob)
|
||||
{
|
||||
ConditionList const conds = sConditionMgr->GetConditionsForSmartEvent(e.entryOrGuid, e.event_id, e.source_type);
|
||||
ConditionSourceInfo info = ConditionSourceInfo(unit, GetBaseObject());
|
||||
|
||||
if (sConditionMgr->IsObjectMeetToConditions(info, conds))
|
||||
ProcessAction(e, unit, var0, var1, bvar, spell, gob);
|
||||
|
||||
RecalcTimer(e, min, max);
|
||||
}
|
||||
|
||||
void SmartScript::InstallTemplate(SmartScriptHolder const& e)
|
||||
{
|
||||
if (!GetBaseObject())
|
||||
@@ -2409,20 +2420,17 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
break;
|
||||
//called from Update tick
|
||||
case SMART_EVENT_UPDATE:
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
ProcessAction(e);
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
break;
|
||||
case SMART_EVENT_UPDATE_OOC:
|
||||
if (me && me->isInCombat())
|
||||
return;
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
ProcessAction(e);
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
break;
|
||||
case SMART_EVENT_UPDATE_IC:
|
||||
if (!me || !me->isInCombat())
|
||||
return;
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
ProcessAction(e);
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
break;
|
||||
case SMART_EVENT_HEALT_PCT:
|
||||
{
|
||||
@@ -2431,8 +2439,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
uint32 perc = (uint32)me->GetHealthPct();
|
||||
if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
|
||||
return;
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
ProcessAction(e);
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_TARGET_HEALTH_PCT:
|
||||
@@ -2442,8 +2449,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
uint32 perc = (uint32)me->getVictim()->GetHealthPct();
|
||||
if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
|
||||
return;
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
ProcessAction(e, me->getVictim());
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->getVictim());
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_MANA_PCT:
|
||||
@@ -2453,8 +2459,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
uint32 perc = uint32(100.0f * me->GetPower(POWER_MANA) / me->GetMaxPower(POWER_MANA));
|
||||
if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
|
||||
return;
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
ProcessAction(e);
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_TARGET_MANA_PCT:
|
||||
@@ -2464,8 +2469,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
uint32 perc = uint32(100.0f * me->getVictim()->GetPower(POWER_MANA) / me->getVictim()->GetMaxPower(POWER_MANA));
|
||||
if (perc > e.event.minMaxRepeat.max || perc < e.event.minMaxRepeat.min)
|
||||
return;
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
ProcessAction(e, me->getVictim());
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->getVictim());
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_RANGE:
|
||||
@@ -2474,18 +2478,15 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
return;
|
||||
|
||||
if (me->IsInRange(me->getVictim(), (float)e.event.minMaxRepeat.min, (float)e.event.minMaxRepeat.max))
|
||||
{
|
||||
ProcessAction(e, me->getVictim());
|
||||
RecalcTimer(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax);
|
||||
}
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->getVictim());
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_TARGET_CASTING:
|
||||
{
|
||||
if (!me || !me->isInCombat() || !me->getVictim() || !me->getVictim()->IsNonMeleeSpellCasted(false, false, true))
|
||||
return;
|
||||
ProcessAction(e, me->getVictim());
|
||||
RecalcTimer(e, e.event.minMax.repeatMin, e.event.minMax.repeatMax);
|
||||
|
||||
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->getVictim());
|
||||
}
|
||||
case SMART_EVENT_FRIENDLY_HEALTH:
|
||||
{
|
||||
@@ -2495,8 +2496,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
Unit* target = DoSelectLowestHpFriendly((float)e.event.friendlyHealt.radius, e.event.friendlyHealt.hpDeficit);
|
||||
if (!target)
|
||||
return;
|
||||
ProcessAction(e, target);
|
||||
RecalcTimer(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax);
|
||||
ProcessTimedAction(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax, target);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_FRIENDLY_IS_CC:
|
||||
@@ -2508,8 +2508,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
DoFindFriendlyCC(pList, (float)e.event.friendlyCC.radius);
|
||||
if (pList.empty())
|
||||
return;
|
||||
ProcessAction(e, *(pList.begin()));
|
||||
RecalcTimer(e, e.event.friendlyCC.repeatMin, e.event.friendlyCC.repeatMax);
|
||||
ProcessTimedAction(e, e.event.friendlyCC.repeatMin, e.event.friendlyCC.repeatMax, *pList.begin());
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_FRIENDLY_MISSING_BUFF:
|
||||
@@ -2519,8 +2518,8 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
|
||||
if (pList.empty())
|
||||
return;
|
||||
ProcessAction(e, *(pList.begin()));
|
||||
RecalcTimer(e, e.event.missingBuff.repeatMin, e.event.missingBuff.repeatMax);
|
||||
|
||||
ProcessTimedAction(e, e.event.missingBuff.repeatMin, e.event.missingBuff.repeatMax, *pList.begin());
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_HAS_AURA:
|
||||
@@ -2529,10 +2528,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
return;
|
||||
uint32 count = me->GetAuraCount(e.event.aura.spell);
|
||||
if ((!e.event.aura.count && !count) || (e.event.aura.count && count >= e.event.aura.count))
|
||||
{
|
||||
ProcessAction(e);
|
||||
RecalcTimer(e, e.event.aura.repeatMin, e.event.aura.repeatMax);
|
||||
}
|
||||
ProcessTimedAction(e, e.event.aura.repeatMin, e.event.aura.repeatMax);
|
||||
break;
|
||||
}
|
||||
case SMART_EVENT_TARGET_BUFFED:
|
||||
@@ -2542,8 +2538,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
uint32 count = me->getVictim()->GetAuraCount(e.event.aura.spell);
|
||||
if (count < e.event.aura.count)
|
||||
return;
|
||||
ProcessAction(e);
|
||||
RecalcTimer(e, e.event.aura.repeatMin, e.event.aura.repeatMax);
|
||||
ProcessTimedAction(e, e.event.aura.repeatMin, e.event.aura.repeatMax);
|
||||
break;
|
||||
}
|
||||
//no params
|
||||
@@ -2578,10 +2573,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
|
||||
if (Unit* victim = me->getVictim())
|
||||
{
|
||||
if (!victim->HasInArc(static_cast<float>(M_PI), me))
|
||||
{
|
||||
ProcessAction(e, victim);
|
||||
RecalcTimer(e, e.event.behindTarget.cooldownMin, e.event.behindTarget.cooldownMax);
|
||||
}
|
||||
ProcessTimedAction(e, e.event.behindTarget.cooldownMin, e.event.behindTarget.cooldownMax, victim);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -45,6 +45,7 @@ class SmartScript
|
||||
void UpdateTimer(SmartScriptHolder& e, uint32 const diff);
|
||||
void InitTimer(SmartScriptHolder& e);
|
||||
void ProcessAction(SmartScriptHolder& e, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
void ProcessTimedAction(SmartScriptHolder& e, uint32 const& min, uint32 const& max, Unit* unit = NULL, uint32 var0 = 0, uint32 var1 = 0, bool bvar = false, const SpellInfo* spell = NULL, GameObject* gob = NULL);
|
||||
ObjectList* GetTargets(SmartScriptHolder const& e, Unit* invoker = NULL);
|
||||
ObjectList* GetWorldObjectsInDist(float dist);
|
||||
void InstallTemplate(SmartScriptHolder const& e);
|
||||
|
||||
Reference in New Issue
Block a user