Board index
Programs with AI or Rules Enforcement
Magic: The Gathering - Duels of the Planeswalkers
Programming Talk



Tradewind rider
Moderator: CCGHQ Admins
Tradewind rider
by keitofu » 17 Feb 2012, 08:17
Hello everybody,
It's my first post here, and I would like to thank everybody for the great job you have made on customising DOTP.
I've been using the tools you provided (Gibbed's tools and DeckEditorRev) and it helped me a lot for coding new cards.
I coded almost successfully the Tradewind Rider but I have a problem I can't resolve.
Here is the code :
Any idea ?
Thanks !
It's my first post here, and I would like to thank everybody for the great job you have made on customising DOTP.
I've been using the tools you provided (Gibbed's tools and DeckEditorRev) and it helped me a lot for coding new cards.
I coded almost successfully the Tradewind Rider but I have a problem I can't resolve.
Here is the code :
- Code: Select all
<ACTIVATED_ABILITY layer="2">
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[{T}: Tap two untapped creatures you control: Return target permanent to its owner's hand.]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[]]]]></LOCALISED_TEXT>
<AI_AVAILABILITY behaviour="InResponseOrDuringCombat" />
<TARGET_DETERMINATION>
local filter = Object():GetFilter()
filter:Clear()
filter:SetController( Object():GetPlayer() )
filter:SetZone( ZONE_IN_PLAY )
filter:AddExtra( FILTER_EXTRA_CREATURE_UNTAPPED )
filter:NotTargetted()
if Object():GetFilter():CountStopAt( 2 ) < 2 then
return TARGET_DETERMINATION_NONE
end
filter:Clear()
filter:AddCardType( CARD_TYPE_CREATURE )
filter:SetZone( ZONE_IN_PLAY )
return TargetBadF()
</TARGET_DETERMINATION>
<PLAY_TIME_ACTION>
local filter = Object():GetFilter()
filter:Clear()
filter:SetZone( ZONE_IN_PLAY )
filter:PlayerAntiHint( Object():GetPlayer() )
Object():GetPlayer():ChooseTargetDC( "CARD_QUERY_CHOOSE_PERMANENT_TO_PUT_INTO_HAND", MTG():EffectDataChest():Make_Targets( 1 ))
</PLAY_TIME_ACTION>
<RESOLUTION_TIME_ACTION>
local targetDC = MTG():EffectDataChest():Get_Targets(1)
if targetDC ~= nil then
local target = targetDC:Get_CardPtr(0)
if target ~= nil then
target:ReturnToOwnersHand()
end
end
</RESOLUTION_TIME_ACTION>
<COST type="TapSelf" />
<COST type="Tap" number="2">
<PLAYTIME>
local player = Object():GetPlayer()
player:ChooseTarget( "CARD_QUERY_TAP_AN_UNTAPPED_CREATURE_YOU_CONTROL" )
</PLAYTIME>
<TARGET_DETERMINATION>
local filter = Object():GetFilter()
filter:Clear()
filter:SetController( Object():GetPlayer() )
filter:AddCardType( CARD_TYPE_CREATURE )
filter:SetZone( ZONE_IN_PLAY )
filter:AddExtra( FILTER_EXTRA_CREATURE_UNTAPPED )
filter:NotTargetted()
if Object():GetFilter():CountStopAt( 1 ) == 1 then
return TARGET_DETERMINATION_ALL
else
return TARGET_DETERMINATION_NONE
end
</TARGET_DETERMINATION>
</COST>
<AI_BASE_SCORE score="600" zone="in_play" />
</ACTIVATED_ABILITY>
Any idea ?
Thanks !
Re: Tradewind rider
by thefiremind » 17 Feb 2012, 10:04
You see, the TARGET_DETERMINATION is split in 2 halves: the first checks if you have the untapped creatures, while the second should check the "real" target. But you wrote filter:AddCardType( CARD_TYPE_CREATURE ) on that, too, so an artifact isn't a valid target for this code. You can choose it because in the PLAY_TIME_ACTION you didn't include that filter, but the validity of the target is checked on TARGET_DETERMINATION before resolution (or at least, I think it works this way).
You have 2 options: either you add the other types of permanents (see Argentum Armor code), or you remove the filter for creatures since ZONE_IN_PLAY is usually enough to define a permanent. I prefer the first option but it's just because I'm a perfectionist...
You have 2 options: either you add the other types of permanents (see Argentum Armor code), or you remove the filter for creatures since ZONE_IN_PLAY is usually enough to define a permanent. I prefer the first option but it's just because I'm a perfectionist...

< 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: 722 times
Re: Tradewind rider
by keitofu » 17 Feb 2012, 11:02
Thanks for the response !
I'm really novice in coding card, I don't understand deeply how it works, so I fiddle with the code, trying to understand it, so your comments are really helpful !
I've tried you first option, which is just including all types and it works !!
But I'm wondering why I could return lands with my old code...
Anyway thanks a lot for the help and for giving me the opportunity to understand a little more how it works
I'm sure I'll have others questions later on
I'm really novice in coding card, I don't understand deeply how it works, so I fiddle with the code, trying to understand it, so your comments are really helpful !
I've tried you first option, which is just including all types and it works !!
But I'm wondering why I could return lands with my old code...
Anyway thanks a lot for the help and for giving me the opportunity to understand a little more how it works

I'm sure I'll have others questions later on

Re: Tradewind rider
by thefiremind » 17 Feb 2012, 15:20
That's strange, I really don't know...keitofu wrote:But I'm wondering why I could return lands with my old code...
Anyway I'm glad I have been helpful.

< 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: 722 times
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 16 guests