It is currently 12 Nov 2025, 23:13
   
Text Size

DOTP 2013 Need help for Counter target spell unless {X}.

Moderator: CCGHQ Admins

DOTP 2013 Need help for Counter target spell unless {X}.

Postby Ikaru69 » 07 Nov 2012, 20:32

Hi ! :wink:

Actually I'm trying to code Syncopate but I think this is just a bit more complicated for my little knowledge of modding.

I tried to start from the code of Mana Leak but in game the spell is automatically countered if the opponent doesn't control any untapped land, even if 0 is spend for the X of Syncopate.
And if the opponent has one untapped land, he just have to tap it for his spell goes well, although normally he should not be able to pay the cost...

So here the code I tried :
Code: Select all
<SPELL_ABILITY filter_zone="ZONE_IN_PLAY">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Contrecarrez le sort ciblé à moins que son contrôleur ne paie {X}. Si ce sort est contrecarré de cette manière, exilez-le à la place de le mettre dans le cimetière de son propriétaire.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[NCounter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner's graveyard.]]></LOCALISED_TEXT>
    <TARGET_DEFINITION id="0">
    local filter = Object():GetFilter()
    filter:Clear()
    filter:SetZone( ZONE_STACK )
    filter:SetStackObjectType( STACK_OBJECT_CARD )
    filter:SetHint( HINT_ENEMY_ONLY, EffectController() )
    </TARGET_DEFINITION>
    <TARGET_DETERMINATION>
    return AtLeastOneTargetFromDefinition(0)
    </TARGET_DETERMINATION>
    <PLAY_TIME_ACTION target_choosing="1">
    EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_SPELL_TO_COUNTER", EffectDC():Make_Targets(0) )
    </PLAY_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local target_spell = EffectDC():Get_Targets(0):Get_CardPtr(0)
    local player = target_spell:GetPlayer()
    if player ~= nil then
       if player:CanAfford("{GetObjectX()}") == 1 then
          player:BeginNewMultipleChoice()   
          player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_PAY_X" )   
          player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_IS_COUNTERED" )   
          player:AskMultipleChoiceQuestion( "CARD_QUERY_MC_MANA_LEAK" )
       end
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local target_spell = EffectDC():Get_Targets(0):Get_CardPtr(0)
    local player = target_spell:GetPlayer()
    local decision = Object():GetMultipleChoiceResult()
    if player ~= nil then
    if player:CanAfford("{GetObjectX()}") == 1 then
      if decision ~= 1 then
        player:TapLand("{GetObjectX()}")
      else
       target_spell:CounterSpell()
      end
     
    else
      target_spell:CounterSpell()
    end
    end
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
Perhaps a good modder of the site could give me a hand and show me where I'm wrong, it would be really nice.
Thank you in advance and excuse my bad english speaking. :oops:
Ikaru69
 
Posts: 6
Joined: 04 Jan 2012, 11:35
Has thanked: 9 times
Been thanked: 0 time

Re: DOTP 2013 Need help for Counter target spell unless {X}.

Postby pcastellazzi » 08 Nov 2012, 08:59

There is small error in your code, all instances of:

Code: Select all
if player:CanAfford("{GetObjectX()}") then
Should be:

Code: Select all
if player:CanAfford("{" .. GetObjectX() .. "}") then
The lights then came up and the crowd erupted in applause, because that's what the crowd does after it watches destruction on a large screen.
— Ben Kuchera, Mordern Warfare 3 review.
User avatar
pcastellazzi
 
Posts: 184
Joined: 25 Apr 2012, 00:40
Location: Montevideo, Uruguay
Has thanked: 11 times
Been thanked: 30 times

Re: DOTP 2013 Need help for Counter target spell unless {X}.

Postby Ikaru69 » 08 Nov 2012, 09:24

And it works ! Great !
Thanks a lot, now it remains for me to deal with second ability.
Ikaru69
 
Posts: 6
Joined: 04 Jan 2012, 11:35
Has thanked: 9 times
Been thanked: 0 time

Re: DOTP 2013 Need help for Counter target spell unless {X}.

Postby thefiremind » 08 Nov 2012, 10:12

The second ability is very similar to what Red Sun's Zenith does, but it's more difficult because it has a pre-condition to meet: the spell must have been countered, not just gone in the graveyard for other reasons. I would make a delayed SPELL_BEING_COUNTERED trigger that sets a delayed ZONECHANGE_CONSIDERED trigger, but I don't know if the SPELL_BEING_COUNTERED trigger fires when the spell is still on the stack or not: we have to anticipate the zone change, otherwise it's useless. That's not something I can discover without testing: I'll let you know if I get it right.

EDIT: This is what I came up with:
Code: Select all
  <SPELL_ABILITY filter_zone="ZONE_IN_PLAY">
    <LOCALISED_TEXT LanguageCode="en-US"><![CDATA[Counter target spell unless its controller pays {X}. If that spell is countered this way, exile it instead of putting it into its owner’s graveyard.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[Neutralizza una magia bersaglio a meno che il suo controllore non paghi {X}. Se quella magia è neutralizzata in questo modo, esiliala invece di metterla nel cimitero del suo proprietario.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[Neutralisiere einen Zauberspruch deiner Wahl, falls sein Beherrscher nicht {X} bezahlt. Wird der Zauberspruch auf diese Weise neutralisiert, schicke ihn ins Exil, anstatt ihn auf den Friedhof seines Besitzers zu legen.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[Contrecarrez le sort ciblé à moins que son contrôleur ne paie {X}. Si ce sort est contrecarré de cette manière, exilez-le à la place de le mettre dans le cimetière de son propriétaire.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[Contrarresta el hechizo objetivo a menos que su controlador pague {X}. Si ese hechizo es contrarrestado de esta manera, exílialo en vez de ponerlo en el cementerio de su propietario.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[呪文1つを対象とする。それのコントローラーが{X}を支払わないかぎり、それを打ち消す。その呪文がこれにより打ち消された場合、それをオーナーの墓地に置く代わりに追放する。]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[주문 한 개를 목표로 정한다. 그 주문의 조종자가 {X}를 지불하지 않으면 그 주문을 무효화한다. 이렇게 그 주문이 무효화되면 그 카드를 소유자의 무덤에 넣는 대신 추방한다.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Отмените целевое заклинание, если только контролирующий его игрок не заплатит {X}. Если то заклинание отменяется таким способом, изгоните его вместо того, чтобы положить его на кладбище его владельца.]]></LOCALISED_TEXT>
    <LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[Anule a mágica alvo, a menos que seu controlador pague {X}. Se aquela mágica for anulada dessa maneira, exile-a em vez de colocá-la no cemitério de seu dono.]]></LOCALISED_TEXT>
    <TARGET_DEFINITION id="0">
    local filter = Object():GetFilter()
    filter:Clear()
    filter:SetZone( ZONE_STACK )
    filter:SetStackObjectType( STACK_OBJECT_CARD )
    filter:SetHint( HINT_ENEMY_ONLY, EffectController() )
    </TARGET_DEFINITION>
    <TARGET_DETERMINATION>
    return AtLeastOneTargetFromDefinition(0)
    </TARGET_DETERMINATION>
    <PLAY_TIME_ACTION target_choosing="1">
    EffectController():ChooseTarget( 0, "CARD_QUERY_CHOOSE_SPELL_TO_COUNTER", EffectDC():Make_Targets(0) )
    </PLAY_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local target_spell = EffectDC():Get_Targets(0):Get_CardPtr(0)
    local player = target_spell:GetPlayer()
    if player ~= nil then
       local x = GetObjectX()
       if player:CanAfford("{"..x.."}") == 1 then
          player:SetCustomQueryInstructionValue( x )
          player:BeginNewMultipleChoice()
          player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_YES" )
          player:AddMultipleChoiceAnswer( "CARD_QUERY_OPTION_NO" )
          player:AskMultipleChoiceQuestion( "CARD_QUERY_MC_PAY_MANA_AMOUNT" )
       end
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local target_spell = EffectDC():Get_Targets(0):Get_CardPtr(0)
    local player = target_spell:GetPlayer()
    local decision = Object():GetMultipleChoiceResult()
    if player ~= nil then
       local x = GetObjectX()
       if player:CanAfford("{"..x.."}") == 1 and decision ~= 1 then
          player:TapLand("{"..x.."}")
       else
          local delayDC = EffectDC():Make_Chest(1)
          delayDC:Set_CardPtr(0, target_spell)
          MTG():CreateDelayedTrigger(1, delayDC)
          target_spell:CounterSpell()
       end
    end
    </RESOLUTION_TIME_ACTION>
  </SPELL_ABILITY>
  <TRIGGERED_ABILITY internal="1" pre_trigger="1" resource_id="1">
    <CLEANUP simple_cleanup="EndOfTurn" />
    <TRIGGER value="SPELL_BEING_COUNTERED">
    if TriggerObject() == EffectDC():Get_CardPtr(0) then
       local delayDC = EffectDC():Make_Chest(2)
       delayDC:Set_CardPtr(0, TriggerObject())
       MTG():CreateDelayedTrigger(2, delayDC)
    end
    return false
    </TRIGGER>
  </TRIGGERED_ABILITY>
  <TRIGGERED_ABILITY internal="1" pre_trigger="1" resource_id="2">
    <CLEANUP fire_once="1" />
    <TRIGGER value="ZONECHANGE_CONSIDERED" to_zone="ZONE_GRAVEYARD" from_zone="ZONE_STACK">
    if TriggerObject() == EffectDC():Get_CardPtr(0) then
       override = 1
       TriggerObject():RemoveFromGame()
       return true
    end
    return false
    </TRIGGER>
  </TRIGGERED_ABILITY>
Before the spell is countered, I set a delayed trigger that waits for the spell to be countered. It has pre_trigger="1" so it happens before the spell goes to the graveyard. That trigger actually never fires (it always returns false, that's why I set the cleanup to EndOfTurn, so that it doesn't stay around forever), but it sets another delayed trigger, which intercepts the spell going to the graveyard and exiles it.

I used my personal query that is customized with SetCustomQueryInstructionValue, so that it always displays the right cost. If you want it to work you have to add the following row to your custom TEXT_PERMANENT Excel XML file (if you already have one, otherwise I'd recommend to make one, or just use CARD_UI_TEXT1999 from my mod, this row is already included in it):
Code: Select all
   <Row>
    <Cell><Data ss:Type="String">CARD_QUERY_MC_PAY_MANA_AMOUNT</Data></Cell>
    <Cell ss:Index="3"><Data ss:Type="String">Do you want to pay {%d}?</Data></Cell>
    <Cell><Data ss:Type="String">Voulez-vous payer {%d}&#160;?</Data></Cell>
    <Cell><Data ss:Type="String">¿Quieres pagar {%d}?</Data></Cell>
    <Cell><Data ss:Type="String">Willst du {%d} bezahlen?</Data></Cell>
    <Cell><Data ss:Type="String">Vuoi pagare {%d}?</Data></Cell>
    <Cell ss:Index="9"><Data ss:Type="String">{%d}を支払いますか?</Data></Cell>
    <Cell><Data ss:Type="String">{%d}을 지불하시겠습니까?</Data></Cell>
    <Cell><Data ss:Type="String">Вы хотите заплатить {%d}?</Data></Cell>
    <Cell><Data ss:Type="String">Deseja pagar {%d}?</Data></Cell>
   </Row>
That %d will be substituted by the argument passed to SetCustomQueryInstructionValue.

I attached the card (with hi-res illustration) here.
Attachments
SYNCOPATE_270369.zip
(114.59 KiB) Downloaded 273 times
< 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: 722 times

Re: DOTP 2013 Need help for Counter target spell unless {X}.

Postby Ikaru69 » 08 Nov 2012, 11:23

Thank you very much ! :D
Ikaru69
 
Posts: 6
Joined: 04 Jan 2012, 11:35
Has thanked: 9 times
Been thanked: 0 time


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 10 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 10 users online :: 0 registered, 0 hidden and 10 guests (based on users active over the past 10 minutes)
Most users ever online was 9824 on 10 Nov 2025, 04:33

Users browsing this forum: No registered users and 10 guests

Login Form