It is currently 25 Apr 2024, 00:55
   
Text Size

Gaze of the Gorgon: solved!

Moderator: CCGHQ Admins

Gaze of the Gorgon: solved!

Postby thefiremind » 25 Oct 2013, 10:12

I finally had the right idea for Gaze of the Gorgon, and I wanted to post it here since the same idea might become useful for other cards.
Here's my code:
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2 ExportVersion="1">
  <FILENAME text="GAZE_OF_THE_GORGON_83933" />
  <CARDNAME text="GAZE_OF_THE_GORGON" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Gaze of the Gorgon]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Regard de la gorgone]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Mirada de la gorgona]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Blick der Gorgo]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Sguardo della Gorgone]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[ゴルゴンの凝視]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Gaze of the Gorgon]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Взор горгоны]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Olhar da Górgona]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="83933" />
  <ARTID value="83933" />
  <ARTIST name="Stephen Tappin" />
  <CASTING_COST cost="{3}{B/G}" />
  <FLAVOURTEXT>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Even the dead give way to the mineral gaze of the gorgon.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Même les morts ne résistent pas au regard minéral de la gorgone.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Incluso los muertos se rinden ante la mirada pétrea de la gorgona.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Selbst die Toten halten dem steinernen Blick der Gorgo nicht stand.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Anche i morti si fermano davanti allo sguardo pietrificante della gorgone.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[ゴルゴンの石化の視線の前では、死すらも道をあける。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Even the dead give way to the mineral gaze of the gorgon.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Даже мертвецы расступаются перед взором горгоны, обращающим в камень.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Até mesmo os mortos rendem-se ao olhar petrificante da górgona.]]></LOCALISED_TEXT>
  </FLAVOURTEXT>
  <TYPE metaname="Instant" />
  <EXPANSION value="RAV" />
  <RARITY metaname="C" />
  <TRIGGERED_ABILITY replacement_effect="1" priority="20" active_zone="ZONE_ANY">
    <TRIGGER value="BLOCKS_A_CREATURE" />
    <TRIGGER value="WAS_BLOCKED_BY_A_CREATURE" />
    <RESOLUTION_TIME_ACTION>
    local main_chest = MTG():DuelDataChest():Get_Chest(9876)
    local main_index = 1
    local main_location = -1
    if main_chest == nil then
       main_chest = MTG():DuelDataChest():Make_Chest(9876)
    else
       main_index = main_chest:Get_Int(0)
       for i=1,main_index-2,2 do
          -- Search for TriggerObject
          if main_chest:Get_CardPtr(i) == TriggerObject() then
             main_location = i
             break
          end
       end
    end
    if main_location == -1 then
       -- TriggerObject wasn't there, let's add it
       main_chest:Set_CardPtr( main_index, TriggerObject() )
       main_location = main_index
       main_chest:Set_Int(0, main_index+2)
    end
    local sub_chest = main_chest:Get_Chest(main_location+1)
    local sub_index = 1
    local sub_location = -1
    if sub_chest == nil then
       sub_chest = main_chest:Make_Chest(main_location+1)
    else
       sub_index = sub_chest:Get_Int(0)
       for i=1,sub_index-1 do
          -- Search for SecondaryObject
          if sub_chest:Get_CardPtr(i) == SecondaryObject() then
             sub_location = i
             break
          end
       end
    end
    if sub_location == -1 then
       -- SecondaryObject wasn't there, let's add it
       sub_chest:Set_CardPtr( sub_index, SecondaryObject() )
       sub_chest:Set_Int(0, sub_index+1)
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
  <TRIGGERED_ABILITY replacement_effect="1" priority="20" active_zone="ZONE_ANY">
    <TRIGGER value="BEGINNING_OF_STEP">
    return MTG():GetStep() == STEP_CLEANUP
    </TRIGGER>
    <RESOLUTION_TIME_ACTION>
    MTG():DuelDataChest():Free_Compartment(9876)
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
  <SPELL_ABILITY>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Regenerate target creature. At this turn’s next end of combat, destroy all creatures that blocked or were blocked by it this turn.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Régénérez la créature ciblée. À la fin du combat, détruisez toutes les créatures qui, ce tour-ci, ont bloqué ou ont été bloquées par cette créature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Regenera la criatura objetivo. Al final del combate, destruye todas las criaturas que bloquearon o fueron bloqueadas por esa criatura este turno.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Regeneriere eine Kreatur deiner Wahl. Zerstöre am Ende des Kampfes alle Kreaturen, die diese Kreatur in diesem Zug geblockt haben oder von ihr geblockt wurden.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Rigenera una creatura bersaglio. Alla prossima fine del combattimento di questo turno, distruggi tutte le creature che hanno bloccato o sono state bloccate da quella creatura in questo turno.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[クリーチャー1体を対象とし、それを再生する。 戦闘終了時に、このターンそのクリーチャーをブロックしたかそのクリーチャーにブロックされたすべてのクリーチャーを破壊する。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Regenerate target creature. At this turn’s next end of combat, destroy all creatures that blocked or were blocked by it this turn.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Регенерируйте целевое существо. В конце боя уничтожьте все существа, которые блокировали или были блокированы данным существом в этот ход.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Regenera a criatura alvo. No final do combate, destrua todas as criaturas que bloquearam ou foram bloqueadas por aquela criatura neste turno.]]></LOCALISED_TEXT>
    <TARGET tag="CARD_QUERY_CHOOSE_CREATURE_REGENERATE" definition="0" compartment="0" count="1" />
    <TARGET_DEFINITION id="0">
    local filter = ClearFilter()
    filter:Add(FE_TYPE, OP_IS, CARD_TYPE_CREATURE)
    </TARGET_DEFINITION>
    <RESOLUTION_TIME_ACTION>
    local target = EffectDC():Get_Targets(0):Get_CardPtr(0)
    if target ~= nil then
       -- The idea here is to save the position of target inside the chest in the delayed trigger, rather than the target pointer itself.
       -- In order to do this, we need to add the target to the chest in case it never battled before.
       local main_chest = MTG():DuelDataChest():Get_Chest(9876)
       local main_index = 1
       local main_location = -1
       if main_chest == nil then
          main_chest = MTG():DuelDataChest():Make_Chest(9876)
       else
          main_index = main_chest:Get_Int(0)
          for i=1,main_index-2,2 do
             -- Search for target
             if main_chest:Get_CardPtr(i) == target then
                main_location = i
                break
             end
          end
       end
       if main_location == -1 then
          -- target wasn't there, let's add it
          main_chest:Set_CardPtr(main_index, target)
          main_location = main_index
          main_chest:Set_Int(0, main_index+2)
       end
       local delayDC = EffectDC():Make_Chest(1)
       delayDC:Set_Int(0, main_location)
       MTG():CreateDelayedTrigger(1, delayDC)
       target:GiveRegeneration()
    end
    </RESOLUTION_TIME_ACTION>
    <AI_SIMPLIFIED_TARGETING compartment="0" hint="HINT_ALLIED_ONLY" />
  </SPELL_ABILITY>
  <TRIGGERED_ABILITY resource_id="1">
    <CLEANUP fire_once="1" simple_cleanup="EndOfTurn" />
    <TRIGGER value="BEGINNING_OF_STEP">
    return MTG():GetStep() == STEP_END_OF_COMBAT
    </TRIGGER>
    <RESOLUTION_TIME_ACTION>
    local main_chest = MTG():DuelDataChest():Get_Chest(9876)
    local main_location = EffectDC():Get_Int(0)
    local sub_chest = main_chest and main_chest:Get_Chest(main_location+1)
    if sub_chest ~= nil then
       local sub_index = sub_chest:Get_Int(0)
       for i=1,sub_index-1 do
          local creature = sub_chest:Get_CardPtr(i)
          if creature ~= nil then
             creature:Destroy()
          end
       end
    end
    </RESOLUTION_TIME_ACTION>
  </TRIGGERED_ABILITY>
  <AI_AVAILABILITY window_step="declare_blockers" type="window" />
  <AI_AVAILABILITY type="in_response" response_target="1" />
  <AI_AVAILABILITY type="in_response" response_source="1" />
  <AI_BASE_SCORE score="900" zone="ZONE_HAND" />
</CARD_V2>
Of course 9876 is just a random number, you can use any duel chest as long as it's not used by something else.

The idea is to save blocked and blocking creatures in a duel chest, then retrieve them for the creature targetted with the Gaze. The structure becomes something like this:
Code: Select all
Main duel chest --> [0]: 7 (last unused index)
                --> [1]: creature A
                --> [2]: sub-chest  --> [0]: 2 (last unused index)
                                    --> [1]: creature B
                --> [3]: creature B
                --> [4]: sub-chest  --> [0]: 3 (last unused index)
                                    --> [1]: creature A
                                    --> [2]: creature C
                --> [5]: creature C
                --> [6]: sub-chest  --> [0]: 2 (last unused index)
                                    --> [1]: creature B
Now, since Gaze of the Gorgon doesn't care whether the targetted creature is still on the battlefield or not when the delayed trigger does its thing, how can I remember that I'm interested in the creatures that battled creature B (referring to the above example)? Easy: rather than passing a pointer to creature B to the delayed trigger, I pass 3. This way I know where it was stored, even after the pointer gets wiped. :mrgreen:
< 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

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 19 guests


Who is online

In total there are 19 users online :: 0 registered, 0 hidden and 19 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 19 guests

Login Form