It is currently 27 Apr 2024, 17:57
   
Text Size

Solution for copying a spell that left the stack

Moderator: CCGHQ Admins

Solution for copying a spell that left the stack

Postby thefiremind » 07 Aug 2013, 12:13

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:
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
User avatar
thefiremind
Programmer
 
Posts: 3515
Joined: 07 Nov 2011, 10:55
Has thanked: 118 times
Been thanked: 721 times

Re: Solution for copying a spell that left the stack

Postby kevlahnota » 07 Aug 2013, 12:15

Congrats =D> =D> =D>
User avatar
kevlahnota
Programmer
 
Posts: 825
Joined: 19 Jul 2010, 17:45
Location: Philippines
Has thanked: 14 times
Been thanked: 264 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 27 guests


Who is online

In total there are 27 users online :: 0 registered, 0 hidden and 27 guests (based on users active over the past 10 minutes)
Most users ever online was 4143 on 23 Jan 2024, 08:21

Users browsing this forum: No registered users and 27 guests

Login Form