Skip to content

Commit

Permalink
[9079] Less strict check related to TARGET_SCRIPT_COORDINATES
Browse files Browse the repository at this point in the history
Fixes and enables ~20 more summon related spells. Some minor cleanup in related code

Signed-off-by: NoFantasy <nofantasy@nf.no>
  • Loading branch information
NoFantasy committed Dec 28, 2009
1 parent 2d96534 commit 5472330
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 18 deletions.
43 changes: 26 additions & 17 deletions src/game/Spell.cpp
Expand Up @@ -4169,20 +4169,21 @@ SpellCastResult Spell::CheckCast(bool strict)
return castResult;
}

//ImpliciteTargetA-B = 38, If fact there is 0 Spell with ImpliciteTargetB=38
// Database based targets from spell_target_script
if (m_UniqueTargetInfo.empty()) // skip second CheckCast apply (for delayed spells for example)
{
for(uint8 j = 0; j < 3; ++j)
{
if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT ||
if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT ||
(m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT && m_spellInfo->EffectImplicitTargetA[j] != TARGET_SELF) ||
m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES ||
m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES ||
m_spellInfo->EffectImplicitTargetA[j] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT)
{

SpellScriptTargetBounds bounds = sSpellMgr.GetSpellScriptTargetBounds(m_spellInfo->Id);
if(bounds.first==bounds.second)

if (bounds.first==bounds.second)
sLog.outErrorDb("Spell (ID: %u) has effect EffectImplicitTargetA/EffectImplicitTargetB = TARGET_SCRIPT or TARGET_SCRIPT_COORDINATES, but does not have record in `spell_script_target`",m_spellInfo->Id);

SpellRangeEntry const* srange = sSpellRangeStore.LookupEntry(m_spellInfo->rangeIndex);
Expand All @@ -4205,8 +4206,8 @@ SpellCastResult Spell::CheckCast(bool strict)
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;

MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*m_caster,i_spellST->second.targetEntry,range);
MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(m_caster, p_GameObject,go_check);
MaNGOS::NearestGameObjectEntryInObjectRangeCheck go_check(*m_caster, i_spellST->second.targetEntry, range);
MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck> checker(m_caster, p_GameObject, go_check);

TypeContainerVisitor<MaNGOS::GameObjectLastSearcher<MaNGOS::NearestGameObjectEntryInObjectRangeCheck>, GridTypeMapContainer > object_checker(checker);
CellLock<GridReadGuard> cell_lock(cell, p);
Expand Down Expand Up @@ -4241,7 +4242,7 @@ SpellCastResult Spell::CheckCast(bool strict)
CellPair p(MaNGOS::ComputeCellPair(m_caster->GetPositionX(), m_caster->GetPositionY()));
Cell cell(p);
cell.data.Part.reserved = ALL_DISTRICT;
cell.SetNoCreate(); // Really don't know what is that???
cell.SetNoCreate();

MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck u_check(*m_caster,i_spellST->second.targetEntry,i_spellST->second.type!=SPELL_TARGET_TYPE_DEAD,range);
MaNGOS::CreatureLastSearcher<MaNGOS::NearestCreatureEntryWithLiveStateInObjectRangeCheck> searcher(m_caster, p_Creature, u_check);
Expand All @@ -4251,7 +4252,7 @@ SpellCastResult Spell::CheckCast(bool strict)
CellLock<GridReadGuard> cell_lock(cell, p);
cell_lock->Visit(cell_lock, grid_creature_searcher, *m_caster->GetMap(), *m_caster, range);

if(p_Creature )
if (p_Creature)
{
creatureScriptTarget = p_Creature;
goScriptTarget = NULL;
Expand All @@ -4262,35 +4263,43 @@ SpellCastResult Spell::CheckCast(bool strict)
}
}

if(creatureScriptTarget)
if (creatureScriptTarget)
{
// store coordinates for TARGET_SCRIPT_COORDINATES
if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES ||
m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES )
m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES)
{
m_targets.setDestination(creatureScriptTarget->GetPositionX(),creatureScriptTarget->GetPositionY(),creatureScriptTarget->GetPositionZ());

if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->EffectImplicitTargetB[j] == 0 && m_spellInfo->Effect[j]!=SPELL_EFFECT_PERSISTENT_AREA_AURA)
if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->Effect[j] != SPELL_EFFECT_PERSISTENT_AREA_AURA)
AddUnitTarget(creatureScriptTarget, j);
}
// store explicit target for TARGET_SCRIPT
else
AddUnitTarget(creatureScriptTarget, j);
{
if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT ||
m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT)
AddUnitTarget(creatureScriptTarget, j);
}
}
else if(goScriptTarget)
else if (goScriptTarget)
{
// store coordinates for TARGET_SCRIPT_COORDINATES
if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES ||
m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES )
m_spellInfo->EffectImplicitTargetB[j] == TARGET_SCRIPT_COORDINATES)
{
m_targets.setDestination(goScriptTarget->GetPositionX(),goScriptTarget->GetPositionY(),goScriptTarget->GetPositionZ());

if(m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->EffectImplicitTargetB[j] == 0 && m_spellInfo->Effect[j]!=SPELL_EFFECT_PERSISTENT_AREA_AURA)
if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_SCRIPT_COORDINATES && m_spellInfo->Effect[j] != SPELL_EFFECT_PERSISTENT_AREA_AURA)
AddGOTarget(goScriptTarget, j);
}
// store explicit target for TARGET_SCRIPT
// store explicit target for TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT
else
AddGOTarget(goScriptTarget, j);
{
if (m_spellInfo->EffectImplicitTargetA[j] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT ||
m_spellInfo->EffectImplicitTargetB[j] == TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT)
AddGOTarget(goScriptTarget, j);
}
}
//Missing DB Entry or targets for this spellEffect.
else
Expand All @@ -4301,7 +4310,7 @@ SpellCastResult Spell::CheckCast(bool strict)
if (m_spellInfo->EffectImplicitTargetA[j] != TARGET_FOCUS_OR_SCRIPTED_GAMEOBJECT)
{
// not report target not existence for triggered spells
if(m_triggeredByAuraSpell || m_IsTriggeredSpell)
if (m_triggeredByAuraSpell || m_IsTriggeredSpell)
return SPELL_FAILED_DONT_REPORT;
else
return SPELL_FAILED_BAD_TARGETS;
Expand Down
2 changes: 1 addition & 1 deletion src/shared/revision_nr.h
@@ -1,4 +1,4 @@
#ifndef __REVISION_NR_H__
#define __REVISION_NR_H__
#define REVISION_NR "9078"
#define REVISION_NR "9079"
#endif // __REVISION_NR_H__

0 comments on commit 5472330

Please sign in to comment.