Board index Programs with AI or Rules Enforcement Magic: The Gathering - Duels of the Planeswalkers New MTG Cards and Decks (2010, 2012, 2013, 2014, 2015, Magic Duels) 2014
Way to return a spell from exile to the graveyard?
Moderator: CCGHQ Admins
Way to return a spell from exile to the graveyard?
by 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?
by 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>
- 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>
< Former DotP 2012/2013/2014 modder >
Currently busy with life...
Currently busy with life...
-
thefiremind - Programmer
- Posts: 3515
- Joined: 07 Nov 2011, 10:55
- Has thanked: 118 times
- Been thanked: 721 times
2 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 38 guests