Merge pull request #3162 from megamage/master
Fix incorrect logic in PetAI. Solve #3155.
This commit is contained in:
@@ -141,13 +141,8 @@ void PetAI::UpdateAI(const uint32 diff)
|
|||||||
if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
|
if (me->GetCharmInfo() && me->GetCharmInfo()->GetGlobalCooldownMgr().HasGlobalCooldown(spellInfo))
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
// ignore some combinations of combat state and combat/noncombat spells
|
if (spellInfo->IsPositive())
|
||||||
if (!me->getVictim())
|
|
||||||
{
|
{
|
||||||
// ignore attacking spells, and allow only self/around spells
|
|
||||||
if (!spellInfo->IsPositive())
|
|
||||||
continue;
|
|
||||||
|
|
||||||
// non combat spells allowed
|
// non combat spells allowed
|
||||||
// only pet spells have IsNonCombatSpell and not fit this reqs:
|
// only pet spells have IsNonCombatSpell and not fit this reqs:
|
||||||
// Consume Shadows, Lesser Invisibility, so ignore checks for its
|
// Consume Shadows, Lesser Invisibility, so ignore checks for its
|
||||||
@@ -163,36 +158,21 @@ void PetAI::UpdateAI(const uint32 diff)
|
|||||||
if (cooldown >= 0 && duration >= 0 && cooldown > duration)
|
if (cooldown >= 0 && duration >= 0 && cooldown > duration)
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// just ignore non-combat spells
|
|
||||||
if (!spellInfo->CanBeUsedInCombat())
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);
|
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);
|
||||||
|
|
||||||
// Fix to allow pets on STAY to autocast
|
|
||||||
if (me->getVictim() && _CanAttack(me->getVictim()) && spell->CanAutoCast(me->getVictim()))
|
|
||||||
{
|
|
||||||
targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
bool spellUsed = false;
|
bool spellUsed = false;
|
||||||
for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)
|
for (std::set<uint64>::const_iterator tar = m_AllySet.begin(); tar != m_AllySet.end(); ++tar)
|
||||||
{
|
{
|
||||||
Unit* Target = ObjectAccessor::GetUnit(*me, *tar);
|
Unit* target = ObjectAccessor::GetUnit(*me, *tar);
|
||||||
|
|
||||||
//only buff targets that are in combat, unless the spell can only be cast while out of combat
|
//only buff targets that are in combat, unless the spell can only be cast while out of combat
|
||||||
if (!Target)
|
if (!target)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (spell->CanAutoCast(Target))
|
if (spell->CanAutoCast(target))
|
||||||
{
|
{
|
||||||
targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(Target, spell));
|
targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(target, spell));
|
||||||
spellUsed = true;
|
spellUsed = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -200,6 +180,14 @@ void PetAI::UpdateAI(const uint32 diff)
|
|||||||
if (!spellUsed)
|
if (!spellUsed)
|
||||||
delete spell;
|
delete spell;
|
||||||
}
|
}
|
||||||
|
else if (me->getVictim() && _CanAttack(me->getVictim()) && spellInfo->CanBeUsedInCombat())
|
||||||
|
{
|
||||||
|
Spell* spell = new Spell(me, spellInfo, TRIGGERED_NONE, 0);
|
||||||
|
if (spell->CanAutoCast(me->getVictim()))
|
||||||
|
targetSpellStore.push_back(std::make_pair<Unit*, Spell*>(me->getVictim(), spell));
|
||||||
|
else
|
||||||
|
delete spell;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//found units to cast on to
|
//found units to cast on to
|
||||||
|
|||||||
@@ -237,11 +237,12 @@ class spell_intense_cold : public SpellScriptLoader
|
|||||||
|
|
||||||
void HandlePeriodicTick(AuraEffect const* aurEff)
|
void HandlePeriodicTick(AuraEffect const* aurEff)
|
||||||
{
|
{
|
||||||
Unit* caster = GetCaster();
|
if (aurEff->GetBase()->GetStackAmount() < 2)
|
||||||
if (!caster)
|
return;
|
||||||
|
Unit* caster = GetCaster();
|
||||||
|
//TODO: the caster should be boss but not the player
|
||||||
|
if (!caster || !caster->GetAI())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (aurEff->GetBase()->GetStackAmount() >= 2)
|
|
||||||
caster->GetAI()->SetGUID(GetTarget()->GetGUID(), DATA_INTENSE_COLD);
|
caster->GetAI()->SetGUID(GetTarget()->GetGUID(), DATA_INTENSE_COLD);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -167,9 +167,11 @@ class spell_dk_anti_magic_zone : public SpellScriptLoader
|
|||||||
{
|
{
|
||||||
SpellInfo const* talentSpell = sSpellMgr->GetSpellInfo(DK_SPELL_ANTI_MAGIC_SHELL_TALENT);
|
SpellInfo const* talentSpell = sSpellMgr->GetSpellInfo(DK_SPELL_ANTI_MAGIC_SHELL_TALENT);
|
||||||
amount = talentSpell->Effects[EFFECT_0].CalcValue(GetCaster());
|
amount = talentSpell->Effects[EFFECT_0].CalcValue(GetCaster());
|
||||||
// assume caster is a player here
|
Unit* caster = GetCaster();
|
||||||
if (Unit* caster = GetCaster())
|
if(!caster)
|
||||||
amount += int32(2 * caster->ToPlayer()->GetTotalAttackPowerValue(BASE_ATTACK));
|
return;
|
||||||
|
if(Player* player = caster->ToPlayer())
|
||||||
|
amount += int32(2 * player->GetTotalAttackPowerValue(BASE_ATTACK));
|
||||||
}
|
}
|
||||||
|
|
||||||
void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
void Absorb(AuraEffect* /*aurEff*/, DamageInfo & dmgInfo, uint32 & absorbAmount)
|
||||||
|
|||||||
Reference in New Issue
Block a user