It is currently 16 Jul 2019, 10:04
   
Text Size

Strange thing related to ignore_filter

Moderators: Xander9009, CCGHQ Admins

Strange thing related to ignore_filter

Postby thefiremind » 27 May 2013, 14:44

Try this implementation of Thundercloud Shaman:
Code: Select all
<?xml version='1.0' encoding='UTF-8'?>
<CARD_V2>
  <FILENAME text="THUNDERCLOUD_SHAMAN_139738" />
  <CARDNAME text="THUNDERCLOUD_SHAMAN" />
  <TITLE>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Thundercloud Shaman]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Shamane de nuée d’orage]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Chamán del nubarrón]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Donnerwolken-Schamane]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Sciamano del Temporale]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[雷雲のシャーマン]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Thundercloud Shaman]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Шаман Грозового Облака]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Xamã Cúmulo-Nimbo]]></LOCALISED_TEXT>
  </TITLE>
  <MULTIVERSEID value="139738" />
  <ARTID value="A139738" />
  <ARTIST name="Greg Staples" />
  <CASTING_COST cost="{3}{R}{R}" />
  <FLAVOURTEXT>
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[He cares not for the disasters his storm brings as long as his path ahead is clear.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Il se moque des conséquences de son orage tant qu’il déblaie les obstacles sur son chemin.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[No le importan los desastres que pueda acarrear su tormenta mientras su camino esté despejado.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Es ist ihm egal, was für Katastrophen sein Sturm mit sich bringt, solange dadurch sein Weg frei ist.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Non si preoccupa dei disastri causati dalla sua tempesta purché la strada che ha davanti sia sgombra.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[彼の目の前に道が開けるかぎり、彼は自分がもたらす嵐の被害など気にしはしない。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[He cares not for the disasters his storm brings as long as his path ahead is clear.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Его не беспокоят разрушения, которые приносит его буря, главное, чтобы дорога вперед была расчищена.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Ele não se importa com os desastres que suas tempestades causam desde que seu caminho fique limpo.]]></LOCALISED_TEXT>
  </FLAVOURTEXT>
  <TYPE metaname="Creature" />
  <SUB_TYPE metaname="Giant" order_fr-FR="0" order_es-ES="1" order_de-DE="0" order_it-IT="1" order_jp-JA="0" order_ko-KR="0" order_ru-RU="0" order_pt-BR="0" />
  <SUB_TYPE metaname="Shaman" order_fr-FR="1" order_es-ES="0" order_de-DE="1" order_it-IT="0" order_jp-JA="1" order_ko-KR="1" order_ru-RU="1" order_pt-BR="1" />
  <EXPANSION value="LRW" />
  <RARITY metaname="U" />
  <POWER value="4" />
  <TOUGHNESS value="4" />
  <TRIGGERED_ABILITY LKI_shield_effect_source="1" dangerous="1" filter_zone="ZONE_IN_PLAY">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[When Thundercloud Shaman enters the battlefield, it deals damage equal to the number of Giants you control to each non-Giant creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Quand le Shamane de nuée d’orage arrive en jeu, il inflige un nombre de blessures égal au nombre de géants que vous contrôlez à chaque créature non-géant.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Cuando el Chamán del nubarrón entre en juego, hace una cantidad de daño igual al número de Gigantes que controlas a cada criatura que no sea Gigante.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Wenn der Donnerwolken-Schamane ins Spiel kommt, fügt er allen Nichtriesen-Kreaturen so viele Schadenspunkte zu, wie du Riesen kontrollierst.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Quando lo Sciamano del Temporale entra nel campo di battaglia, infligge un ammontare di danni pari al numero di Giganti che controlli ad ogni creatura non Gigante.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[雷雲のシャーマンが場に出たとき、それは巨人でない各クリーチャーに、それぞれあなたがコントロールする巨人の総数に等しい点数のダメージを与える。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[When Thundercloud Shaman enters the battlefield, it deals damage equal to the number of Giants you control to each non-Giant creature.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Когда Шаман Грозового Облака входит в игру, он наносит каждому не являющемуся Гигантом существу повреждения, равные количеству Гигантов под вашим контролем.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Quando Xamã Cúmulo-Nimbo entra em jogo, ele causa dano igual ao número de Gigantes que você controla a cada criatura que não seja Gigante.]]></LOCALISED_TEXT>
    <TRIGGER value="ZONECHANGE_END" simple_qualifier="self" to_zone="ZONE_IN_PLAY" />
    <RESOLUTION_TIME_ACTION ignore_filter="1">
    -- How many Giants do you control?
    local filter = Object():GetFilter()
    filter:Clear()
    filter:NotTargetted()
    filter:SetZone( ZONE_IN_PLAY )
    filter:AddSubType( CREATURE_TYPE_GIANT )
    filter:SetController( EffectController() )
    EffectDC():Set_Int( 0, filter:Count() )
    -- Test
    MTG():MessageAllPlayers( "Test register 0 in 1st action: "..EffectDC():Get_Int(0) )
    </RESOLUTION_TIME_ACTION>
    <FILTER>
    -- Filter non-Giant creatures
    local fc = FilteredCard()
    return fc ~= nil and
    fc:GetZone() == ZONE_IN_PLAY and
    fc:GetCardType():Test( CARD_TYPE_CREATURE ) ~= 0 and
    fc:GetSubType():Test( CREATURE_TYPE_GIANT ) == 0
    </FILTER>
    <RESOLUTION_TIME_ACTION>
    -- Deal the damage
    if FilteredCard() ~= nil then
       local source = EffectSource()
       if source == nil then
          source = Object()
       end
       local damage = EffectDC():Get_Int(0)
       FilteredCard():DealDamage(damage, source)
       -- Test
       MTG():MessageAllPlayers( "Test register 0 in 2nd action: "..damage )
    end
    </RESOLUTION_TIME_ACTION>
    <SFX text="GLOBAL_CHAIN_PLAY" />
  </TRIGGERED_ABILITY>
  <SFX text="COMBAT_LIGHTNING_LARGE_ATTACK" power_boundary_min="4" power_boundary_max="-1" />
  <SFX text="COMBAT_LIGHTNING_SMALL_ATTACK" power_boundary_min="1" power_boundary_max="3" />
  <AI_BASE_SCORE score="450" zone="ZONE_HAND" />
</CARD_V2>
I added some messages that help testing. The code seems OK, doesn't it? Well it isn't: try and you'll see that while register 0 contains the right number in the first action, it resets in the second action.
But here's the thing: if you remove ignore_filter="1" from the first action, everything works as expected.

Does anyone have a good explanation for this? I thought about 2:
  1. Registers in actions with ignore_filter="1" are separated from registers in actions without it.
  2. Actions with ignore_filter="1" are actually executed for last, no matter what (this doesn't seem possible, since the messages are fired in the correct order and I think there are some official cards that wouldn't work if this was true).
Any other thoughts?
< 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: 717 times

Re: Strange thing related to ignore_filter

Postby sumomole » 27 May 2013, 15:29

thefiremind wrote:I added some messages that help testing. The code seems OK, doesn't it? Well it isn't: try and you'll see that while register 0 contains the right number in the first action, it resets in the second action.
But here's the thing: if you remove ignore_filter="1" from the first action, everything works as expected.

Does anyone have a good explanation for this? I thought about 2:
  1. Registers in actions with ignore_filter="1" are separated from registers in actions without it.
  2. Actions with ignore_filter="1" are actually executed for last, no matter what (this doesn't seem possible, since the messages are fired in the correct order and I think there are some official cards that wouldn't work if this was true).
Any other thoughts?
If don't use ignore_filter="1", <FILTER/> will cause <RESOLUTION_TIME_ACTION/> repeat as many times as the amount of the filtered card, but in this ability, no giant creature would leave the battlefield before effect resolved, so whether once or more, the results are the same. :lol:
User avatar
sumomole
Programmer
 
Posts: 611
Joined: 07 Jun 2011, 08:34
Has thanked: 51 times
Been thanked: 230 times

Re: Strange thing related to ignore_filter

Postby thefiremind » 27 May 2013, 15:41

sumomole wrote:If don't use ignore_filter="1", <FILTER/> will cause <RESOLUTION_TIME_ACTION/> repeat as many times as the amount of the filtered card, but in this ability, no giant creature would leave the battlefield before effect resolved, so whether once or more, the results are the same. :lol:
I know that, but it doesn't explain why it doesn't work with ignore_filter="1". Sometimes I'd like to go further than just finding how to code a working card, and I'd like to know why an apparently OK code doesn't work as expected.
< 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: 717 times

Re: Strange thing related to ignore_filter

Postby sumomole » 27 May 2013, 16:21

thefiremind wrote:
sumomole wrote:If don't use ignore_filter="1", <FILTER/> will cause <RESOLUTION_TIME_ACTION/> repeat as many times as the amount of the filtered card, but in this ability, no giant creature would leave the battlefield before effect resolved, so whether once or more, the results are the same. :lol:
I know that, but it doesn't explain why it doesn't work with ignore_filter="1". Sometimes I'd like to go further than just finding how to code a working card, and I'd like to know why an apparently OK code doesn't work as expected.
Oh, I know what you said and what's wrong, you can't use EffectDC in <FILTER/>, only ObjectDC can be used, I have met the same problem and I don't know why either.
User avatar
sumomole
Programmer
 
Posts: 611
Joined: 07 Jun 2011, 08:34
Has thanked: 51 times
Been thanked: 230 times

Re: Strange thing related to ignore_filter

Postby RiiakShiNal » 27 May 2013, 17:46

sumomole wrote:Oh, I know what you said and what's wrong, you can't use EffectDC in <FILTER/>, only ObjectDC can be used, I have met the same problem and I don't know why either.
He's not using EffectDC() in the FILTER, only in the RESOLUTION_TIME_ACTION that the FILTER controls. And what makes it stranger is that if neither action has ignore_filter="1" then it works fine. The problem is if only the first one has ignore_filter="1" set.

I have confirmed the provided code fails with ignore_filter="1" set on the first action, but have not yet tested with it removed.

Another possibility that you didn't list is that there could be a separate EffectDC() for each iteration for the FILTER.

Edit: It seems my hypothesis was correct in that you have a separate EffectDC() for each iteration of the filter. This code confirms:
Code: Select all
        <RESOLUTION_TIME_ACTION>
        -- How many Giants do you control?
        local filter = Object():GetFilter()
        filter:Clear()
        filter:NotTargetted()
        filter:SetZone( ZONE_IN_PLAY )
        filter:AddSubType( CREATURE_TYPE_GIANT )
        filter:SetController( EffectController() )
        EffectDC():Set_Int( 0, filter:Count() )
        -- We want to make sure that what is in each EffectDC() is different
        ObjectDC():Int_Inc( 0 )
        EffectDC():Set_Int( 1, ObjectDC():Int_Get( 0 ) )
        -- Test
        MTG():MessageAllPlayers( "Test register 0 in 1st action: "..EffectDC():Get_Int(0) )
        MTG():MessageAllPlayers( "Test register 1 in 1st action: "..EffectDC():Get_Int(1) )
        </RESOLUTION_TIME_ACTION>
        <FILTER>
        -- Filter non-Giant creatures
        local fc = FilteredCard()
        return fc ~= nil and
        fc:GetZone() == ZONE_IN_PLAY and
        fc:GetCardType():Test( CARD_TYPE_CREATURE ) ~= 0 and
        fc:GetSubType():Test( CREATURE_TYPE_GIANT ) == 0
        </FILTER>
        <RESOLUTION_TIME_ACTION>
        -- Deal the damage
        if FilteredCard() ~= nil then
           local source = EffectSource()
           if source == nil then
              source = Object()
           end
           local damage = EffectDC():Get_Int(0)
           FilteredCard():DealDamage(damage, source)
           -- Test
           MTG():MessageAllPlayers( "Test register 0 in 2nd action: "..damage )
           -- If we have the same EffectDC() for all iterations of the filter
           --  then this should be the same each time as it should only accept
           --  the last set.
           MTG():MessageAllPlayers( "Test register 1 in 2nd action: "..EffectDC():Get_Int(1) )
        end
        </RESOLUTION_TIME_ACTION>
Due to having a separate EffectDC() for each iteration of the FILTER, it would make sense to also have a separate EffectDC() for actions that ignore the filter.
Problems with base game cards: DotP 2014 Core Fixes
Need a deck builder: DotP 2014 Deck Builder
Problems Modding: DotP 2014 Frequent Modding Mistakes
RiiakShiNal
Programmer
 
Posts: 2119
Joined: 16 May 2011, 21:37
Has thanked: 73 times
Been thanked: 471 times

Re: Strange thing related to ignore_filter

Postby sumomole » 28 May 2013, 01:20

RiiakShiNal wrote:He's not using EffectDC() in the FILTER, only in the RESOLUTION_TIME_ACTION that the FILTER controls. And what makes it stranger is that if neither action has ignore_filter="1" then it works fine. The problem is if only the first one has ignore_filter="1" set.
Yes, that's what I mean, you can't use an EffectDC that from an action with ignore_filter="1" to any action withou ignore_filter="1", I guess when we use ignore_filter="1" in one of these, the two action are considered in two ability.

For example, if a spell let you destroy all lands and draw a card, you may code two effect in one spell ability with ignore_filter="1" in darw card action, also may code them in two spell ability without ignore_filter="1".

and why the code of Thundercloud Shaman can work fine without ignore_filter="1"? Because when you del it, the code as same as the following code:
Code: Select all
<FILTER>
    return not CreaturesInPlayOfType( CREATURE_TYPE_GIANT )
    </FILTER>
    <RESOLUTION_TIME_ACTION>
    if FilteredCard() ~= nil then
       local source = EffectSource()
       if source == nil then
          source = Object()
       end
       local damage = 0
        local filter = Object():GetFilter()
        filter:Clear()
        filter:NotTargetted()
        filter:SetZone( ZONE_IN_PLAY )
        filter:AddSubType( CREATURE_TYPE_GIANT )
        filter:SetController( EffectController() )
        EffectDC():Set_Int( 0, filter:Count() )
        damage = EffectDC():Get_Int(0)
       FilteredCard():DealDamage(damage, source)
    end
    </RESOLUTION_TIME_ACTION>
Of course it works fine! :lol:
User avatar
sumomole
Programmer
 
Posts: 611
Joined: 07 Jun 2011, 08:34
Has thanked: 51 times
Been thanked: 230 times

Re: Strange thing related to ignore_filter

Postby thefiremind » 28 May 2013, 21:57

Now that I look at my Azorius Charm again, which sets an EffectDC register in a PLAY_TIME_ACTION and retrieves its value successfully both in a RESOLUTION_TIME_ACTION with ignore_filter="1" and within the FILTER itself, I think that what happens with ignore_filter="1" is a sort of "ramification":
Code: Select all
    normal actions' flow
             |
             |
    -------------------
    |                 |
    |                 |
still normal      actions with
actions' flow     ignore_filter
So if you set a register before the ramification, any action after that will get its value, but once the flow gets divided, the values that you set in a branch can't be retrieved by the other branch.

Maybe I'm totally away from the real reason, but this explanation seems to be coherent with the facts.
< 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: 717 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 1 guest


Who is online

In total there is 1 user online :: 0 registered, 0 hidden and 1 guest (based on users active over the past 10 minutes)
Most users ever online was 287 on 31 Mar 2019, 04:11

Users browsing this forum: No registered users and 1 guest

Login Form