Core/SmartAI: Add a spellid to SMART_EVENT_TARGET_CASTING. If left on 0, it checks for all spells (like it did without these changes)

This commit is contained in:
Discover-
2013-09-01 10:49:29 +02:00
parent ec837b1d7d
commit 016dac995e
3 changed files with 39 additions and 13 deletions

View File

@@ -2643,10 +2643,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:
@@ -2654,10 +2664,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:
@@ -3005,7 +3015,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();
@@ -3018,7 +3028,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:

View File

@@ -407,10 +407,10 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
}
break;
case SMART_EVENT_FRIENDLY_HEALTH:
if (!NotNULL(e, e.event.friendlyHealt.radius))
if (!NotNULL(e, e.event.friendlyHealth.radius))
return false;
if (!IsMinMaxValid(e, e.event.friendlyHealt.repeatMin, e.event.friendlyHealt.repeatMax))
if (!IsMinMaxValid(e, e.event.friendlyHealth.repeatMin, e.event.friendlyHealth.repeatMax))
return false;
break;
case SMART_EVENT_FRIENDLY_IS_CC:
@@ -437,6 +437,15 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
return false;
break;
case SMART_EVENT_TARGET_CASTING:
if (e.event.targetCasting.spellId > 0 && !sSpellMgr->GetSpellInfo(e.event.targetCasting.spellId))
{
sLog->outError(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u uses non-existent Spell entry %u, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType(), e.event.spellHit.spell);
return false;
}
if (!IsMinMaxValid(e, e.event.targetCasting.repeatMin, e.event.targetCasting.repeatMax))
return false;
break;
case SMART_EVENT_PASSENGER_BOARDED:
case SMART_EVENT_PASSENGER_REMOVED:
if (!IsMinMaxValid(e, e.event.minMax.repeatMin, e.event.minMax.repeatMax))
@@ -546,10 +555,10 @@ bool SmartAIMgr::IsEventValid(SmartScriptHolder& e)
break;
}
case SMART_EVENT_FRIENDLY_HEALTH_PCT:
if (!IsMinMaxValid(e, e.event.friendlyHealtPct.repeatMin, e.event.friendlyHealtPct.repeatMax))
if (!IsMinMaxValid(e, e.event.friendlyHealthPct.repeatMin, e.event.friendlyHealthPct.repeatMax))
return false;
if (e.event.friendlyHealtPct.maxHpPct > 100 || e.event.friendlyHealtPct.minHpPct > 100)
if (e.event.friendlyHealthPct.maxHpPct > 100 || e.event.friendlyHealthPct.minHpPct > 100)
{
TC_LOG_ERROR(LOG_FILTER_SQL, "SmartAIMgr: Entry %d SourceType %u Event %u Action %u has pct value above 100, skipped.", e.entryOrGuid, e.GetScriptType(), e.event_id, e.GetActionType());
return false;

View File

@@ -94,7 +94,7 @@ enum SMART_EVENT
SMART_EVENT_OOC_LOS = 10, // NoHostile, MaxRnage, CooldownMin, CooldownMax
SMART_EVENT_RESPAWN = 11, // type, MapId, ZoneId
SMART_EVENT_TARGET_HEALTH_PCT = 12, // HPMin%, HPMax%, RepeatMin, RepeatMax
SMART_EVENT_TARGET_CASTING = 13, // RepeatMin, RepeatMax
SMART_EVENT_TARGET_CASTING = 13, // RepeatMin, RepeatMax, spellid
SMART_EVENT_FRIENDLY_HEALTH = 14, // HPDeficit, Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_IS_CC = 15, // Radius, RepeatMin, RepeatMax
SMART_EVENT_FRIENDLY_MISSING_BUFF = 16, // SpellId, Radius, RepeatMin, RepeatMax
@@ -213,13 +213,20 @@ struct SmartEvent
uint32 repeatMax;
} minMax;
struct
{
uint32 repeatMin;
uint32 repeatMax;
uint32 spellId;
} targetCasting;
struct
{
uint32 hpDeficit;
uint32 radius;
uint32 repeatMin;
uint32 repeatMax;
} friendlyHealt;
} friendlyHealth;
struct
{
@@ -368,7 +375,7 @@ struct SmartEvent
uint32 maxHpPct;
uint32 repeatMin;
uint32 repeatMax;
} friendlyHealtPct;
} friendlyHealthPct;
struct
{