Jump to content

[10329] fix for Targettype TARGET_SCRIPT(38) for spells cast with suitable target


Schmoozerd

Recommended Posts

What bug does the patch fix? What features does the patch add?

Make it possible to use the casters target for spells with targettype TARGET_SCRIPT(38) which have multiple entries in the DB.

(atm the selected target is depending on order of DB entries and range rather than the caster's target)

For which repository revision was the patch created?

10064

Is there a thread in the bug report section or at lighthouse? If yes, please add a link to the thread.

no (przemratajczak emphasized the problem at http://www.scriptdev2.com/project.php?issueid=992)

Who has been writing this patch? Please include either forum user names or email addresses.

me

This is how it should work:

if the caster has a target valid to any of the DB-entries, this target shall be taken,

otherwise we take target depending on range

diff --git a/src/game/Spell.cpp b/src/game/Spell.cpp
index 6597d88..009b2de 100644
--- a/src/game/Spell.cpp
+++ b/src/game/Spell.cpp
@@ -4486,6 +4486,7 @@ SpellCastResult Spell::CheckCast(bool strict)

                Creature* creatureScriptTarget = NULL;
                GameObject* goScriptTarget = NULL;
+                bool isCastersTargetTarget = false;

                for(SpellScriptTarget::const_iterator i_spellST = bounds.first; i_spellST != bounds.second; ++i_spellST)
                {
@@ -4534,12 +4535,12 @@ SpellCastResult Spell::CheckCast(bool strict)
                                {
                                    if (i_spellST->second.type == SPELL_TARGET_TYPE_DEAD && pTarget->isDead())
                                    {
-                                        if (pTarget->IsWithinDistInMap(m_caster, range))
+                                        if (pTarget->IsWithinDistInMap(m_caster, GetSpellMaxRange(srange)))
                                            p_Creature = (Creature*)pTarget;
                                    }
                                    else if (i_spellST->second.type == SPELL_TARGET_TYPE_CREATURE && pTarget->isAlive())
                                    {
-                                        if (pTarget->IsWithinDistInMap(m_caster, range))
+                                        if (pTarget->IsWithinDistInMap(m_caster, GetSpellMaxRange(srange)))
                                            p_Creature = (Creature*)pTarget;
                                    }
                                }
@@ -4556,10 +4557,16 @@ SpellCastResult Spell::CheckCast(bool strict)

                                range = u_check.GetLastRange();
                            }
+                            else
+                            {   // our target was a valid target
+                                isCastersTargetTarget = true;
+                                creatureScriptTarget = p_Creature;
+                            }

                            if (p_Creature)
                            {
-                                creatureScriptTarget = p_Creature;
+                                if (!isCastersTargetTarget)
+                                    creatureScriptTarget = p_Creature;
                                goScriptTarget = NULL;
                            }

Link to comment
Share on other sites

  • 1 month later...
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use