Page 1 of 1

Solution for copying a spell that left the stack

PostPosted: 07 Aug 2013, 12:13
by thefiremind
After a lot of tries, I finally found the solution to the problem that afflicted kevlahnota and sumomole: how to correctly copy a spell even if it leaves the stack (for example because it has been countered). The problem is that the copy of a spell that already left the stack loses its original targets, and the ChooseNewTargets function requires the spell to actually have targets in order to replace them with new ones.
So here's the idea: I checked the famous intricated code for Precursor Golem in DotP2013, and remembered that the CopySpell function has an optional second parameter that accepts a data chest. This allows us to save the targets of the original spell inside the trigger condition, and then pass them to the spell copy during resolution.

This is the fixed code for storm, you can easily adapt it to other cards.
Code: Select all
  <TRIGGERED_ABILITY active_zone="ZONE_STACK">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Storm]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Déluge]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Tormenta]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Sturm]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Tempesta]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[ストーム]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Storm]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Шторм]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Rajada]]></LOCALISED_TEXT>
    <TRIGGER value="SPELL_PLAYED" simple_qualifier="self">
    EffectDC():Make_Chest(0):CopyFrom( TriggerObject():GetDataChest() )
    return true
    </TRIGGER>
    <RESOLUTION_TIME_ACTION>
    local interrogation = MTG():ClearInterrogationQuery()
    local storm_count = interrogation:Count(INTERROGATE_SPELLS_CAST, INTERROGATE_THIS_TURN) - 1
    if storm_count &gt; 0 then
        for i=1,storm_count do
          local copy = EffectController():CopySpell( TriggerObjectLKI(), EffectDC():Get_Chest(0) )
          EffectController():ChooseNewTargets(copy)
        end
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
I'm feeling proud. :lol:

Re: Solution for copying a spell that left the stack

PostPosted: 07 Aug 2013, 12:15
by kevlahnota
Congrats =D> =D> =D>