mirror of
https://github.com/mangosfour/server.git
synced 2025-12-14 16:37:01 +00:00
[11871] Reorder caster/target selection for normal case in Aura::TriggerSpell
There is no reason to overwrite behaviour of custom code, also it is easier if caster/ target selection is done early to prevent unexpected changes after custom code
This commit is contained in:
parent
2a0a88c1e6
commit
4989b48ffd
2 changed files with 38 additions and 43 deletions
|
|
@ -1062,10 +1062,12 @@ void Aura::TriggerSpell()
|
|||
// generic casting code with custom spells and target/caster customs
|
||||
uint32 trigger_spell_id = GetSpellProto()->EffectTriggerSpell[m_effIndex];
|
||||
|
||||
SpellEntry const *triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
|
||||
SpellEntry const *auraSpellInfo = GetSpellProto();
|
||||
SpellEntry const* triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
|
||||
SpellEntry const* auraSpellInfo = GetSpellProto();
|
||||
uint32 auraId = auraSpellInfo->Id;
|
||||
Unit* target = GetTarget();
|
||||
Unit* triggerCaster = triggerTarget;
|
||||
WorldObject* triggerTargetObject = NULL;
|
||||
|
||||
// specific code for cases with no trigger spell provided in field
|
||||
if (triggeredSpellInfo == NULL)
|
||||
|
|
@ -1841,22 +1843,46 @@ void Aura::TriggerSpell()
|
|||
// Reget trigger spell proto
|
||||
triggeredSpellInfo = sSpellStore.LookupEntry(trigger_spell_id);
|
||||
}
|
||||
else
|
||||
else // initial triggeredSpellInfo != NULL
|
||||
{
|
||||
// for channeled spell cast applied from aura owner to channel target (persistent aura affects already applied to true target)
|
||||
// come periodic casts applied to targets, so need seelct proper caster (ex. 15790)
|
||||
if (IsChanneledSpell(GetSpellProto()) && GetSpellProto()->Effect[GetEffIndex()] != SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
{
|
||||
// interesting 2 cases: periodic aura at caster of channeled spell
|
||||
if (target->GetObjectGuid() == casterGUID)
|
||||
{
|
||||
triggerCaster = target;
|
||||
|
||||
if (WorldObject* channelTarget = target->GetMap()->GetWorldObject(target->GetChannelObjectGuid()))
|
||||
{
|
||||
if (channelTarget->isType(TYPEMASK_UNIT))
|
||||
triggerTarget = (Unit*)channelTarget;
|
||||
else
|
||||
triggerTargetObject = channelTarget;
|
||||
}
|
||||
}
|
||||
// or periodic aura at caster channel target
|
||||
else if (Unit* caster = GetCaster())
|
||||
{
|
||||
if (target->GetObjectGuid() == caster->GetChannelObjectGuid())
|
||||
{
|
||||
triggerCaster = caster;
|
||||
triggerTarget = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Spell exist but require custom code
|
||||
switch(auraId)
|
||||
{
|
||||
case 9347: // Mortal Strike
|
||||
{
|
||||
// expected selection current fight target
|
||||
triggerTarget = GetTarget()->getVictim();
|
||||
if (!triggerTarget)
|
||||
if (target->GetTypeId() != TYPEID_UNIT)
|
||||
return;
|
||||
|
||||
// avoid triggering for far target
|
||||
SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(triggeredSpellInfo->rangeIndex);
|
||||
float max_range = GetSpellMaxRange(srange);
|
||||
if (!triggerTarget->IsWithinDist(GetTarget(),max_range))
|
||||
// expected selection current fight target
|
||||
triggerTarget = ((Creature*)target)->SelectAttackingTarget(ATTACKING_TARGET_TOPAGGRO, 0, triggeredSpellInfo);
|
||||
if (!triggerTarget)
|
||||
return;
|
||||
|
||||
break;
|
||||
|
|
@ -1924,37 +1950,6 @@ void Aura::TriggerSpell()
|
|||
}
|
||||
}
|
||||
|
||||
Unit* triggerCaster = triggerTarget;
|
||||
WorldObject* triggerTargetObject = NULL;
|
||||
|
||||
// for channeled spell cast applied from aura owner to channel target (persistent aura affects already applied to true target)
|
||||
// come periodic casts applied to targets, so need seelct proper caster (ex. 15790)
|
||||
if (IsChanneledSpell(GetSpellProto()) && GetSpellProto()->Effect[GetEffIndex()] != SPELL_EFFECT_PERSISTENT_AREA_AURA)
|
||||
{
|
||||
// interesting 2 cases: periodic aura at caster of channeled spell
|
||||
if (target->GetObjectGuid() == casterGUID)
|
||||
{
|
||||
triggerCaster = target;
|
||||
|
||||
if (WorldObject* channelTarget = target->GetMap()->GetWorldObject(target->GetChannelObjectGuid()))
|
||||
{
|
||||
if (channelTarget->isType(TYPEMASK_UNIT))
|
||||
triggerTarget = (Unit*)channelTarget;
|
||||
else
|
||||
triggerTargetObject = channelTarget;
|
||||
}
|
||||
}
|
||||
// or periodic aura at caster channel target
|
||||
else if (Unit* caster = GetCaster())
|
||||
{
|
||||
if (target->GetObjectGuid() == caster->GetChannelObjectGuid())
|
||||
{
|
||||
triggerCaster = caster;
|
||||
triggerTarget = target;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// All ok cast by default case
|
||||
if (triggeredSpellInfo)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
#ifndef __REVISION_NR_H__
|
||||
#define __REVISION_NR_H__
|
||||
#define REVISION_NR "11870"
|
||||
#define REVISION_NR "11871"
|
||||
#endif // __REVISION_NR_H__
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue