fix(Core/SmartScripts): Add Triggered Flags for CAST & INVOKER_CAST (#16045)
* cast/invoker_cast
* Update SmartScript.cpp
* {}
This commit is contained in:
@@ -581,7 +581,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
if (e.GetScriptType() == SMART_SCRIPT_TYPE_AREATRIGGER)
|
if (e.GetScriptType() == SMART_SCRIPT_TYPE_AREATRIGGER)
|
||||||
caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000);
|
caster = unit->SummonTrigger(unit->GetPositionX(), unit->GetPositionY(), unit->GetPositionZ(), unit->GetOrientation(), 5000);
|
||||||
|
|
||||||
if (e.action.cast.targetsLimit > 0 && targets.size() > e.action.cast.targetsLimit)
|
if (e.action.cast.targetsLimit)
|
||||||
Acore::Containers::RandomResize(targets, e.action.cast.targetsLimit);
|
Acore::Containers::RandomResize(targets, e.action.cast.targetsLimit);
|
||||||
|
|
||||||
for (WorldObject* target : targets)
|
for (WorldObject* target : targets)
|
||||||
@@ -602,12 +602,27 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
else if (me && (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell)))
|
else if (me && (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell)))
|
||||||
{
|
{
|
||||||
if (e.action.cast.castFlags & SMARTCAST_INTERRUPT_PREVIOUS)
|
if (e.action.cast.castFlags & SMARTCAST_INTERRUPT_PREVIOUS)
|
||||||
|
{
|
||||||
me->InterruptNonMeleeSpells(false);
|
me->InterruptNonMeleeSpells(false);
|
||||||
|
}
|
||||||
|
|
||||||
// Xinef: flag usable only if caster has max dist set
|
TriggerCastFlags triggerFlags = TRIGGERED_NONE;
|
||||||
|
if (e.action.cast.castFlags & SMARTCAST_TRIGGERED)
|
||||||
|
{
|
||||||
|
if (e.action.cast.triggerFlags)
|
||||||
|
{
|
||||||
|
triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
triggerFlags = TRIGGERED_FULL_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Flag usable only if caster has max dist set.
|
||||||
if ((e.action.cast.castFlags & SMARTCAST_COMBAT_MOVE) && GetCasterMaxDist() > 0.0f && me->GetMaxPower(GetCasterPowerType()) > 0)
|
if ((e.action.cast.castFlags & SMARTCAST_COMBAT_MOVE) && GetCasterMaxDist() > 0.0f && me->GetMaxPower(GetCasterPowerType()) > 0)
|
||||||
{
|
{
|
||||||
// Xinef: check mana case only and operate movement accordingly, LoS and range is checked in targetet movement generator
|
// Check mana case only and operate movement accordingly, LoS and range is checked in targetet movement generator.
|
||||||
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell);
|
SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(e.action.cast.spell);
|
||||||
int32 currentPower = me->GetPower(GetCasterPowerType());
|
int32 currentPower = me->GetPower(GetCasterPowerType());
|
||||||
|
|
||||||
@@ -623,10 +638,16 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
me->CastSpell(target->ToUnit(), e.action.cast.spell, (e.action.cast.castFlags & SMARTCAST_TRIGGERED));
|
me->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
|
||||||
|
LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_CAST: Unit {} casts spell {} on target {} with castflags {}",
|
||||||
|
me->GetGUID().ToString().c_str(), e.action.cast.spell, target->GetGUID().ToString().c_str(), e.action.cast.castFlags);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
|
||||||
|
e.action.cast.spell, target->GetGUID().ToString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SMART_ACTION_SELF_CAST:
|
case SMART_ACTION_SELF_CAST:
|
||||||
@@ -641,9 +662,13 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
if (e.action.cast.castFlags & SMARTCAST_TRIGGERED)
|
if (e.action.cast.castFlags & SMARTCAST_TRIGGERED)
|
||||||
{
|
{
|
||||||
if (e.action.cast.triggerFlags)
|
if (e.action.cast.triggerFlags)
|
||||||
|
{
|
||||||
triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
|
triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
triggerFlags = TRIGGERED_FULL_MASK;
|
triggerFlags = TRIGGERED_FULL_MASK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (WorldObject* target : targets)
|
for (WorldObject* target : targets)
|
||||||
@@ -655,7 +680,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !uTarget->HasAura(e.action.cast.spell))
|
if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !uTarget->HasAura(e.action.cast.spell))
|
||||||
{
|
{
|
||||||
if (e.action.cast.castFlags & SMARTCAST_INTERRUPT_PREVIOUS)
|
if (e.action.cast.castFlags & SMARTCAST_INTERRUPT_PREVIOUS)
|
||||||
|
{
|
||||||
uTarget->InterruptNonMeleeSpells(false);
|
uTarget->InterruptNonMeleeSpells(false);
|
||||||
|
}
|
||||||
|
|
||||||
uTarget->CastSpell(uTarget, e.action.cast.spell, triggerFlags);
|
uTarget->CastSpell(uTarget, e.action.cast.spell, triggerFlags);
|
||||||
}
|
}
|
||||||
@@ -664,7 +691,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
}
|
}
|
||||||
case SMART_ACTION_INVOKER_CAST:
|
case SMART_ACTION_INVOKER_CAST:
|
||||||
{
|
{
|
||||||
Unit* tempLastInvoker = GetLastInvoker(unit); // xinef: can be used for area triggers cast
|
// Can be used for area trigger cast
|
||||||
|
Unit* tempLastInvoker = GetLastInvoker(unit);
|
||||||
if (!tempLastInvoker)
|
if (!tempLastInvoker)
|
||||||
break;
|
break;
|
||||||
|
|
||||||
@@ -682,12 +710,33 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell))
|
if (!(e.action.cast.castFlags & SMARTCAST_AURA_NOT_PRESENT) || !target->ToUnit()->HasAura(e.action.cast.spell))
|
||||||
{
|
{
|
||||||
if (e.action.cast.castFlags & SMARTCAST_INTERRUPT_PREVIOUS)
|
if (e.action.cast.castFlags & SMARTCAST_INTERRUPT_PREVIOUS)
|
||||||
|
{
|
||||||
tempLastInvoker->InterruptNonMeleeSpells(false);
|
tempLastInvoker->InterruptNonMeleeSpells(false);
|
||||||
|
}
|
||||||
|
|
||||||
tempLastInvoker->CastSpell(target->ToUnit(), e.action.cast.spell, (e.action.cast.castFlags & SMARTCAST_TRIGGERED));
|
TriggerCastFlags triggerFlags = TRIGGERED_NONE;
|
||||||
|
if (e.action.cast.castFlags & SMARTCAST_TRIGGERED)
|
||||||
|
{
|
||||||
|
if (e.action.cast.triggerFlags)
|
||||||
|
{
|
||||||
|
triggerFlags = TriggerCastFlags(e.action.cast.triggerFlags);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
triggerFlags = TRIGGERED_FULL_MASK;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
tempLastInvoker->CastSpell(target->ToUnit(), e.action.cast.spell, triggerFlags);
|
||||||
|
LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_INVOKER_CAST: Invoker {} casts spell {} on target {} with castflags {}",
|
||||||
|
tempLastInvoker->GetGUID().ToString().c_str(), e.action.cast.spell, target->GetGUID().ToString().c_str(), e.action.cast.castFlags);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
LOG_DEBUG("scripts.ai", "Spell {} not cast because it has flag SMARTCAST_AURA_NOT_PRESENT and the target {} already has the aura",
|
||||||
|
e.action.cast.spell, target->GetGUID().ToString().c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case SMART_ACTION_ADD_AURA:
|
case SMART_ACTION_ADD_AURA:
|
||||||
@@ -2494,7 +2543,9 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u
|
|||||||
if (IsUnit(target))
|
if (IsUnit(target))
|
||||||
{
|
{
|
||||||
if (e.action.castCustom.flags & SMARTCAST_INTERRUPT_PREVIOUS)
|
if (e.action.castCustom.flags & SMARTCAST_INTERRUPT_PREVIOUS)
|
||||||
|
{
|
||||||
me->InterruptNonMeleeSpells(false);
|
me->InterruptNonMeleeSpells(false);
|
||||||
|
}
|
||||||
|
|
||||||
if (e.action.castCustom.flags & SMARTCAST_COMBAT_MOVE)
|
if (e.action.castCustom.flags & SMARTCAST_COMBAT_MOVE)
|
||||||
{
|
{
|
||||||
@@ -4176,7 +4227,7 @@ void SmartScript::UpdateTimer(SmartScriptHolder& e, uint32 const diff)
|
|||||||
// delay spell cast event if another spell is being casted
|
// delay spell cast event if another spell is being casted
|
||||||
if (e.GetActionType() == SMART_ACTION_CAST)
|
if (e.GetActionType() == SMART_ACTION_CAST)
|
||||||
{
|
{
|
||||||
if (!(e.action.cast.castFlags & (SMARTCAST_INTERRUPT_PREVIOUS | SMARTCAST_TRIGGERED)))
|
if (!(e.action.cast.castFlags & SMARTCAST_INTERRUPT_PREVIOUS))
|
||||||
{
|
{
|
||||||
if (me && me->HasUnitState(UNIT_STATE_CASTING))
|
if (me && me->HasUnitState(UNIT_STATE_CASTING))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -533,7 +533,7 @@ enum SMART_ACTION
|
|||||||
SMART_ACTION_SET_REACT_STATE = 8, // state
|
SMART_ACTION_SET_REACT_STATE = 8, // state
|
||||||
SMART_ACTION_ACTIVATE_GOBJECT = 9, //
|
SMART_ACTION_ACTIVATE_GOBJECT = 9, //
|
||||||
SMART_ACTION_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3...
|
SMART_ACTION_RANDOM_EMOTE = 10, // EmoteId1, EmoteId2, EmoteId3...
|
||||||
SMART_ACTION_CAST = 11, // SpellId, CastFlags, LimitTargets
|
SMART_ACTION_CAST = 11, // spellID, castFlags, triggerFlags, targetsLimit
|
||||||
SMART_ACTION_SUMMON_CREATURE = 12, // CreatureID, summonType, duration in ms, attackInvoker, attackScriptOwner, flags(SmartActionSummonCreatureFlags)
|
SMART_ACTION_SUMMON_CREATURE = 12, // CreatureID, summonType, duration in ms, attackInvoker, attackScriptOwner, flags(SmartActionSummonCreatureFlags)
|
||||||
SMART_ACTION_THREAT_SINGLE_PCT = 13, // Threat%
|
SMART_ACTION_THREAT_SINGLE_PCT = 13, // Threat%
|
||||||
SMART_ACTION_THREAT_ALL_PCT = 14, // Threat%
|
SMART_ACTION_THREAT_ALL_PCT = 14, // Threat%
|
||||||
@@ -607,7 +607,7 @@ enum SMART_ACTION
|
|||||||
SMART_ACTION_ADD_NPC_FLAG = 82, // Flags
|
SMART_ACTION_ADD_NPC_FLAG = 82, // Flags
|
||||||
SMART_ACTION_REMOVE_NPC_FLAG = 83, // Flags
|
SMART_ACTION_REMOVE_NPC_FLAG = 83, // Flags
|
||||||
SMART_ACTION_SIMPLE_TALK = 84, // groupID, can be used to make players say groupID, Text_over event is not triggered, whisper can not be used (Target units will say the text)
|
SMART_ACTION_SIMPLE_TALK = 84, // groupID, can be used to make players say groupID, Text_over event is not triggered, whisper can not be used (Target units will say the text)
|
||||||
SMART_ACTION_SELF_CAST = 85, // spellID, castFlags
|
SMART_ACTION_SELF_CAST = 85, // spellID, castFlags, triggerFlags, targetsLimit
|
||||||
SMART_ACTION_CROSS_CAST = 86, // spellID, castFlags, CasterTargetType, CasterTarget param1, CasterTarget param2, CasterTarget param3, ( + the origonal target fields as Destination target), CasterTargets will cast spellID on all Targets (use with caution if targeting multiple * multiple units)
|
SMART_ACTION_CROSS_CAST = 86, // spellID, castFlags, CasterTargetType, CasterTarget param1, CasterTarget param2, CasterTarget param3, ( + the origonal target fields as Destination target), CasterTargets will cast spellID on all Targets (use with caution if targeting multiple * multiple units)
|
||||||
SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST = 87, // script9 ids 1-9
|
SMART_ACTION_CALL_RANDOM_TIMED_ACTIONLIST = 87, // script9 ids 1-9
|
||||||
SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST = 88, // script9 id min, max
|
SMART_ACTION_CALL_RANDOM_RANGE_TIMED_ACTIONLIST = 88, // script9 id min, max
|
||||||
@@ -656,8 +656,8 @@ enum SMART_ACTION
|
|||||||
SMART_ACTION_SPAWN_SPAWNGROUP = 131, /// @todo: NOT SUPPORTED YET
|
SMART_ACTION_SPAWN_SPAWNGROUP = 131, /// @todo: NOT SUPPORTED YET
|
||||||
SMART_ACTION_DESPAWN_SPAWNGROUP = 132, /// @todo: NOT SUPPORTED YET
|
SMART_ACTION_DESPAWN_SPAWNGROUP = 132, /// @todo: NOT SUPPORTED YET
|
||||||
SMART_ACTION_RESPAWN_BY_SPAWNID = 133, /// @todo: NOT SUPPORTED YET
|
SMART_ACTION_RESPAWN_BY_SPAWNID = 133, /// @todo: NOT SUPPORTED YET
|
||||||
SMART_ACTION_INVOKER_CAST = 134, // spellID, castFlags
|
SMART_ACTION_INVOKER_CAST = 134, // spellID, castFlags, triggerFlags, targetsLimit
|
||||||
SMART_ACTION_PLAY_CINEMATIC = 135, // entry, cinematic
|
SMART_ACTION_PLAY_CINEMATIC = 135, // entry
|
||||||
SMART_ACTION_SET_MOVEMENT_SPEED = 136, // movementType, speedInteger, speedFraction
|
SMART_ACTION_SET_MOVEMENT_SPEED = 136, // movementType, speedInteger, speedFraction
|
||||||
|
|
||||||
SMART_ACTION_SET_HEALTH_PCT = 142, // percent
|
SMART_ACTION_SET_HEALTH_PCT = 142, // percent
|
||||||
|
|||||||
Reference in New Issue
Block a user