It is currently 21 May 2024, 12:47
   
Text Size

Way to return a spell from exile to the graveyard?

Moderator: CCGHQ Admins

Way to return a spell from exile to the graveyard?

Postby fallenangle » 16 Aug 2014, 22:47

I'm trying to code a card so that it is exiled when I play it, but is put into the graveyard at the beginning of my end step. I can get the card to exile, but what would the code look like to return it to my graveyard at the beginning of my end step? I don't really understand delayed triggers, so if anyone wise and kind could provide code that might do the trick along with annotations for my reference, I would be extremely grateful. Thanks in advance for all of your help.
fallenangle
 
Posts: 319
Joined: 20 Jul 2013, 02:31
Has thanked: 73 times
Been thanked: 41 times

Re: Way to return a spell from exile to the graveyard?

Postby thefiremind » 16 Aug 2014, 23:16

The following code will be somewhere inside an ability:
Code: Select all
    <RESOLUTION_TIME_ACTION>
    local card = EffectSource() -- if it's not the card itself that you want to move, change this
    if card ~= nil then
       EffectDC():Protect_CardPtr(COMPARTMENT_ID_EFFECT_SOURCE) -- protect the pointer before moving the card, or you won't find it anymore! EffectSource is a special pointer whose register number is accessible with the COMPARTMENT_ID_EFFECT_SOURCE constant so you need to protect it this way: if it's not the card itself that you want to move, change this as well
       card:Exile() -- you can move the card now
    end
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    local card = EffectSource() -- if it's not the card itself that you want to move, change this too
    if card ~= nil then
       local delayDC = EffectDC():Make_Chest(1) -- make a chest in a free register
       delayDC:Set_CardPtr(0, card) -- save the card (no need to protect the pointer here, the zone change has been already done)
       MTG():CreateDelayedTrigger(1, delayDC) -- start the delayed trigger with resource_id="1" and pass delayDC to it, which will become the trigger's EffectDC
    end
    </RESOLUTION_TIME_ACTION>
Then you have the delayed trigger as an additional ability on the card:
Code: Select all
  <TRIGGERED_ABILITY resource_id="1">
    <TRIGGER value="BEGINNING_OF_STEP">
    return MTG():GetStep() == STEP_END_OF_TURN
    </TRIGGER>
    <RESOLUTION_TIME_ACTION>
    local card = EffectDC():Get_CardPtr(0) -- because that's where you saved the card on delayDC
    if card ~= nil then
       card:PutInGraveyard() -- move the card again
    end
    </RESOLUTION_TIME_ACTION>
    <CLEANUP fire_once="1" />
  </TRIGGERED_ABILITY>
Note that I made a delayed trigger "at the beginning of the next end step", not necessarily your end step, because Magic cards usually work this way. If you really want your end step only, then add simple_qualifier="controller".
< 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 2014

Who is online

Users browsing this forum: No registered users and 38 guests


Who is online

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

Login Form