Merge pull request #10685 from Discover-/SmartAI-Target-Casting

Core/SmartAI: Add a spellid to SMART_EVENT_TARGET_CASTING. If left on 0,...
This commit is contained in:
Nay
2013-09-01 10:03:45 -07:00
3 changed files with 39 additions and 13 deletions
@@ -2645,10 +2645,20 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
}
case SMART_EVENT_TARGET_CASTING:
{
if (!me || !me->IsInCombat() || !me->GetVictim() || !me->GetVictim()->IsNonMeleeSpellCasted(false, false, true))
if (!me || !me->IsInCombat())
return;
ProcessTimedAction(e, e.event.minMaxRepeat.repeatMin, e.event.minMaxRepeat.repeatMax, me->GetVictim());
Unit* victim = me->GetVictim();
if (!victim || !victim->IsNonMeleeSpellCasted(false, false, true))
return;
if (e.event.targetCasting.spellId > 0)
if (Spell* currSpell = victim->GetCurrentSpell(CURRENT_GENERIC_SPELL))
if (currSpell->m_spellInfo->Id != e.event.targetCasting.spellId)
return;
ProcessTimedAction(e, e.event.targetCasting.repeatMin, e.event.targetCasting.repeatMax, me->GetVictim());
break;
}
case SMART_EVENT_FRIENDLY_HEALTH:
@@ -2656,10 +2666,10 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!me || !me->IsInCombat())
return;
Unit* target = DoSelectLowestHpFriendly((float)e.event.friendlyHealt.radius, e.event.friendlyHealt.hpDeficit);
Unit* target = DoSelectLowestHpFriendly((float)e.event.friendlyHealth.radius, e.event.friendlyHealth.hpDeficit);
if (!target || !target->IsInCombat())
return;
ProcessTimedAction(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax, target);
ProcessTimedAction(e, e.event.friendlyHealth.repeatMin, e.event.friendlyHealth.repeatMax, target);
break;
}
case SMART_EVENT_FRIENDLY_IS_CC:
@@ -3007,7 +3017,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
{
uint32 healthPct = uint32((*itr)->ToUnit()->GetHealthPct());
if (healthPct > e.event.friendlyHealtPct.maxHpPct || healthPct < e.event.friendlyHealtPct.minHpPct)
if (healthPct > e.event.friendlyHealthPct.maxHpPct || healthPct < e.event.friendlyHealthPct.minHpPct)
continue;
target = (*itr)->ToUnit();
@@ -3020,7 +3030,7 @@ void SmartScript::ProcessEvent(SmartScriptHolder& e, Unit* unit, uint32 var0, ui
if (!target)
return;
ProcessTimedAction(e, e.event.friendlyHealtPct.repeatMin, e.event.friendlyHealtPct.repeatMax, target);
ProcessTimedAction(e, e.event.friendlyHealthPct.repeatMin, e.event.friendlyHealthPct.repeatMax, target);
break;
}
default: