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



General Help For Coding Cards thread
Moderator: CCGHQ Admins
28 posts
• Page 2 of 2 • 1, 2
Re: General Help For Coding Cards thread
by kevlahnota » 23 Jul 2010, 08:14
Thanks! I'll test it now.

pun1sher666 wrote:Hi,
To get the current player upkeep turn in your code, you don't need to ask for a target.
You can use TriggerPlayer().
Here an example of what you could write.Hope it will help
- Code: Select all
<TRIGGERED_ABILITY tag="BRAIDS_CABAL_MINION_RULE_1" auto_skip="1" layer="0">
<TRIGGER value="BEGINNING_OF_STEP">
return ( MTG():GetStep() == STEP_UPKEEP and TriggerPlayer():MyTurn() ~= 0 )
</TRIGGER>
<PRE_EFFECT>
local PSacrificeLCA = TriggerPlayer()
Object():Register_Player_Set( 0, PSacrificeLCA )
Object():GetFilter():Clear()
Object():GetFilter():SetPlayer( PSacrificeLCA )
Object():GetFilter():SetZone( ZONE_IN_PLAY )
Object():GetFilter():SetController( PSacrificeLCA )
Object():GetFilter():AddCardType( CARD_TYPE_LAND )
Object():GetFilter():AddCardType( CARD_TYPE_CREATURE )
Object():GetFilter():AddCardType( CARD_TYPE_ARTIFACT )
PSacrificeLCA:ChooseTarget( "ChooseTarget" )
</PRE_EFFECT>
<EFFECT>
SacrificeTargetCard()
</EFFECT>
</TRIGGERED_ABILITY>
-
kevlahnota - Programmer
- Posts: 825
- Joined: 19 Jul 2010, 17:45
- Location: Philippines
- Has thanked: 14 times
- Been thanked: 264 times
Re: General Help For Coding Cards thread
by kevlahnota » 25 Jul 2010, 21:11
thanks the code works! is there any precedence/priority tags in coding the xml? I already have made a deck and like to learn more on coding. just like the example below. cadaverous bloom:
- Code: Select all
<TOKEN_REGISTRATION type="_BLACK_MANA_Token" reservation="2" />
<TOKEN_REGISTRATION type="_GREEN_MANA_Token" reservation="2" />
<ACTIVATED_ABILITY tag="CADAVEROUS_BLOOM_RULE_1" auto_skip="1" layer="0">
<COST type="DISCARD" />
<TARGET_DETERMINATION>
Object():GetFilter():Clear()
Object():GetFilter():May()
Object():GetFilter():SetPlayer( Object():GetPlayer() )
Object():GetFilter():SetZone( ZONE_HAND )
return TargetGoodF()
</TARGET_DETERMINATION>
<PLAYTIME>
ChooseTarget( "ChooseCardToDiscard")
</PLAYTIME>
<PRE_EFFECT>
if (Object():GetTargetCard() ~= nil) then
Object():GetTargetCard():RemoveFromGame()
Object():GetFilter():Clear()
Object():GetPlayer():BeginNewMultipleChoice( true )
Object():GetPlayer():AddMultipleChoiceAnswer( "CADAV_BLACK_MANA" )
Object():GetPlayer():AddMultipleChoiceAnswer( "CADAV_GREEN_MANA" )
Object():GetPlayer():AskMultipleChoiceQuestion( "CADAV_CHOOSE_TITLE" )
if Object():GetMultipleChoiceResult() == 0 then
Object():Register_Set( 0, 0 )
else
Object():Register_Set( 0, 1 )
end
end
</PRE_EFFECT>
<EFFECT>
if (Object():GetMultipleChoiceResult() == 0) then
PutTokensIntoPlay( "_BLACK_MANA_Token", 2 )
else
PutTokensIntoPlay( "_GREEN_MANA_Token", 2 )
end
</EFFECT>
</ACTIVATED_ABILITY>
-
kevlahnota - Programmer
- Posts: 825
- Joined: 19 Jul 2010, 17:45
- Location: Philippines
- Has thanked: 14 times
- Been thanked: 264 times
Re: General Help For Coding Cards thread
by Yanna » 25 Jul 2010, 21:55
I believe this part is unneeded, and may be the source of your problem.kevlahnota wrote: if Object():GetMultipleChoiceResult() == 0 then
Object():Register_Set( 0, 0 )
else
Object():Register_Set( 0, 1 )
end
Otherwise it could be related to the mana tokens (dataset is the usual one).
Hope this helped !

Re: General Help For Coding Cards thread
by kevlahnota » 26 Jul 2010, 01:06
Thanks. I figured it out, it's the </COST> tag placement after the </playtime>. squandered resources is next....(i missed my banned deck)Yanna wrote:I believe this part is unneeded, and may be the source of your problem.kevlahnota wrote: if Object():GetMultipleChoiceResult() == 0 then
Object():Register_Set( 0, 0 )
else
Object():Register_Set( 0, 1 )
end
Otherwise it could be related to the mana tokens (dataset is the usual one).
Hope this helped !

- Code: Select all
<TOKEN_REGISTRATION type="_BLACK_MANA_Token" reservation="2" />
<TOKEN_REGISTRATION type="_GREEN_MANA_Token" reservation="2" />
<ACTIVATED_ABILITY tag="CADAVEROUS_BLOOM_RULE_1" auto_skip="1" layer="0">
<COST type="DISCARD" >
<TARGET_DETERMINATION>
Object():GetFilter():Clear()
Object():GetFilter():May()
Object():GetFilter():SetPlayer( Object():GetPlayer() )
Object():GetFilter():SetZone( ZONE_HAND )
return TargetGoodF()
</TARGET_DETERMINATION>
<PLAYTIME>
ChooseTarget( "ChooseCardToRemoveFromGame")
</PLAYTIME>
</COST>
<PRE_EFFECT>
Object():GetPlayer():BeginNewMultipleChoice( true )
Object():GetPlayer():AddMultipleChoiceAnswer( "CADAV_BLACK_MANA" )
Object():GetPlayer():AddMultipleChoiceAnswer( "CADAV_GREEN_MANA" )
Object():GetPlayer():AskMultipleChoiceQuestion( "CADAV_CHOOSE_TITLE" )
if Object():GetMultipleChoiceResult() == 0 then
Object():Register_Set( 0, 0 )
else
Object():Register_Set( 0, 1 )
end
</PRE_EFFECT>
<EFFECT>
if (Object():GetTargetCard() ~= nil) then
Object():GetTargetCard():RemoveFromGame()
end
if (Object():GetMultipleChoiceResult() == 0) then
PutTokensIntoPlay( "_BLACK_MANA_Token", 2 )
else
PutTokensIntoPlay( "_GREEN_MANA_Token", 2 )
end
</EFFECT>
</ACTIVATED_ABILITY>
-
kevlahnota - Programmer
- Posts: 825
- Joined: 19 Jul 2010, 17:45
- Location: Philippines
- Has thanked: 14 times
- Been thanked: 264 times
Re: General Help For Coding Cards thread
by Yanna » 26 Jul 2010, 12:16
Glad you figured it out 
Will be nice to use a cadaverous bloom in some decks !

Will be nice to use a cadaverous bloom in some decks !

Re: General Help For Coding Cards thread
by whismer » 26 Jul 2010, 18:09
Is there a place to find a list of the token in the game...
If I look at Raise the alarm, it's said Soldier11_Token
(11 for 1/1 ?)
but in Zombie Infestation it's Zombie22ALA
why ALA?
and Can we give an ability like first strike to the token?
Thx
Whismer
If I look at Raise the alarm, it's said Soldier11_Token
(11 for 1/1 ?)
but in Zombie Infestation it's Zombie22ALA
why ALA?
and Can we give an ability like first strike to the token?
Thx
Whismer
- whismer
- Posts: 64
- Joined: 23 Jul 2010, 02:36
- Has thanked: 0 time
- Been thanked: 0 time
Re: General Help For Coding Cards thread
by Yanna » 26 Jul 2010, 20:38
There is no list per se, but you can do (in the card folder) :
dir *_token.xml /A /B which gives :
BEAST88RGW_TOKEN.XML
DRAGON44F_TOKEN.XML
DRAGON55F_TOKEN.XML
ELEMENTALSHAMAN31H_TOKEN.XML
ELEMENTALSHAMAN31_TOKEN.XML
ELFWARRIOR11_TOKEN.XML
GOBLIN11ALA_TOKEN.XML
GOBLIN11_TOKEN.XML
GREENELEMENTAL44_TOKEN.XML
SAPROLING11ALA_TOKEN.XML
SAPROLING11_TOKEN.XML
SKELETON11R_TOKEN.XML
SOLDIER11_TOKEN.XML
SPIDER12R_TOKEN.XML
THOPTER11F_TOKEN.XML
WASP11F_TOKEN.XML
WOLF22_TOKEN.XML
ZOMBIE22ALA_TOKEN.XML
ZOMBIE22_TOKEN.XML
The 'ALA' part is just a different presentation than the other token.
And yes you can give abilities to tokens, edit SKELETON11R_TOKEN.XML this token has regeneration abilities. Take into account the 'Frameborder' used, that has a box part to display text.
dir *_token.xml /A /B which gives :
BEAST88RGW_TOKEN.XML
DRAGON44F_TOKEN.XML
DRAGON55F_TOKEN.XML
ELEMENTALSHAMAN31H_TOKEN.XML
ELEMENTALSHAMAN31_TOKEN.XML
ELFWARRIOR11_TOKEN.XML
GOBLIN11ALA_TOKEN.XML
GOBLIN11_TOKEN.XML
GREENELEMENTAL44_TOKEN.XML
SAPROLING11ALA_TOKEN.XML
SAPROLING11_TOKEN.XML
SKELETON11R_TOKEN.XML
SOLDIER11_TOKEN.XML
SPIDER12R_TOKEN.XML
THOPTER11F_TOKEN.XML
WASP11F_TOKEN.XML
WOLF22_TOKEN.XML
ZOMBIE22ALA_TOKEN.XML
ZOMBIE22_TOKEN.XML
The 'ALA' part is just a different presentation than the other token.
And yes you can give abilities to tokens, edit SKELETON11R_TOKEN.XML this token has regeneration abilities. Take into account the 'Frameborder' used, that has a box part to display text.

Re: General Help For Coding Cards thread
by logoliv » 01 Aug 2010, 13:10
Need help please !
I'm trying desperately to code Grave Pact for 3 days and always have the same error saying :
[lua] [string "GRAVE_PACT_TITLE (PRE_EFFECT)"]:10: attempt to index local 'TheChosenPlayer' (a nil value)
Here's my code :
I don't know a card that as been made which could help me
What can I do ?
I'm trying desperately to code Grave Pact for 3 days and always have the same error saying :
[lua] [string "GRAVE_PACT_TITLE (PRE_EFFECT)"]:10: attempt to index local 'TheChosenPlayer' (a nil value)
Here's my code :
- Code: Select all
<TRIGGERED_ABILITY tag="GRAVE_PACT_RULE_1" zone="IN_PLAY" layer="0">
<TRIGGER value="HIT_GRAVEYARD">
return ( (TriggerObject():GetCardType():Test( CARD_TYPE_CREATURE ) ~= 0) and YouControl() )
</TRIGGER>
<TARGET_DETERMINATION>
return TargetOpponent( Object():GetPlayer() )
</TARGET_DETERMINATION>
<PLAYTIME>
ChooseTargetOpponent()
</PLAYTIME>
<PRE_EFFECT>
local TheChosenPlayer = Object():GetTargetPlayer()
Object():Register_Player_Set( 0, TheChosenPlayer )
Object():GetFilter():Clear()
Object():GetFilter():SetPlayer( TheChosenPlayer )
Object():GetFilter():SetController( TheChosenPlayer )
Object():GetFilter():SetZone( ZONE_IN_PLAY )
Object():GetFilter():AddCardType( CARD_TYPE_CREATURE )
Object():GetFilter():NotTargetted()
TheChosenPlayer:ChooseTarget( "TargetCreatureNeutralBadF" )
</PRE_EFFECT>
<EFFECT>
SacrificeTargetCard()
</EFFECT>
</TRIGGERED_ABILITY>
I don't know a card that as been made which could help me

What can I do ?
Re: General Help For Coding Cards thread
by buasudah » 29 Aug 2010, 13:01
Hello good people!
Can anyone please help me with this card - it produces 5 mana but if 1 mana spell is cast - it spends them all. I tried to put diferent numbers for reservations but it doesnt work.
<TOKEN_REGISTRATION type="_BLACK_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_WHITE_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_BLUE_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_RED_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_GREEN_MANA_Token" reservation="1" />
<SPELL_ABILITY tag="{W}{U}{G}{R}{B}" layer="0" forced_skip="1" >
<EFFECT>
ProduceBlackMana( 1 )
ProduceRedMana( 1 )
ProduceGreenMana( 1 )
ProduceBlueMana( 1 )
ProduceWhiteMana( 1 )
</EFFECT>
</SPELL_ABILITY>
Also, is there anything related to reservation numbers that i should watch out for when making token-spawn cards?
Can anyone please help me with this card - it produces 5 mana but if 1 mana spell is cast - it spends them all. I tried to put diferent numbers for reservations but it doesnt work.
<TOKEN_REGISTRATION type="_BLACK_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_WHITE_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_BLUE_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_RED_MANA_Token" reservation="1" />
<TOKEN_REGISTRATION type="_GREEN_MANA_Token" reservation="1" />
<SPELL_ABILITY tag="{W}{U}{G}{R}{B}" layer="0" forced_skip="1" >
<EFFECT>
ProduceBlackMana( 1 )
ProduceRedMana( 1 )
ProduceGreenMana( 1 )
ProduceBlueMana( 1 )
ProduceWhiteMana( 1 )
</EFFECT>
</SPELL_ABILITY>
Also, is there anything related to reservation numbers that i should watch out for when making token-spawn cards?
- buasudah
- Posts: 19
- Joined: 19 Aug 2010, 19:23
- Has thanked: 0 time
- Been thanked: 0 time
Re: General Help For Coding Cards thread
by codeALPHA » 29 Aug 2010, 18:49
@ logoliv
I have not test it, but if I had to code that card I would have tried something like that
I have not test it, but if I had to code that card I would have tried something like that
- Code: Select all
<TRIGGERED_ABILITY tag="GRAVE_PACT_RULE_1" zone="IN_PLAY" layer="0">
<TRIGGER value="HIT_GRAVEYARD">
return ( (TriggerObject():GetCardType():Test( CARD_TYPE_CREATURE ) ~= 0) and YouControl() )
</TRIGGER>
<FILTER>
return Opponents()
</FILTER>
<EFFECT>
Object():GetFilter():Clear()
Object():GetFilter():SetPlayer( Subject())
Object():GetFilter():SetController( Subject())
Object():GetFilter():SetZone( ZONE_IN_PLAY )
Object():GetFilter():AddCardType( CARD_TYPE_CREATURE )
Subject():ChooseTarget( "TargetCreatureNeutralBadF" )
SacrificeTargetCard()
</EFFECT>
</TRIGGERED_ABILITY>
Re: General Help For Coding Cards thread
by logoliv » 29 Aug 2010, 20:05
Grave Pact is already in the repository for some weeks, but thanks anyway 

Re: General Help For Coding Cards thread
by codeALPHA » 29 Aug 2010, 21:09
Right, note to self: check the dates of the posts before replying 

Re: General Help For Coding Cards thread
by gener4 » 09 May 2011, 16:35
Trying to code Khabal Ghoul. Started with the Sengir Vampire base then removes the self triggered, but its doesn't seem to catch.
<TRIGGERED_ABILITY internal="1" layer="0">
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_UNTAP
</TRIGGER>
<EFFECT>
Object():Register_Clear( 0 )
</EFFECT>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY internal="1" layer="0">
<TRIGGER value="ZONECHANGE">
return Triggered()
</TRIGGER>
<EFFECT>
Object():Register_Clear( 0 )
<EFFECT>
Object():Register_Object_Set( Object():Register_Get( 0 ), SecondaryObject() )
Object():Register_Inc( 0 )
</EFFECT>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY tag="KHABAL_GHOUL_RULE_1" auto_skip="1" layer="0">
<TRIGGER value="HIT_GRAVEYARD">
if TriggerObject():GetZone() ~= ZONE_GRAVEYARD or TriggerObject():GetErstwhileZone() ~= ZONE_IN_PLAY then
return false
end
for i = 0, Object():Register_Get( 0 ) - 1 do
if (TriggerObject() == Object():Register_Object_Get( i )) then
return true
end
end
return false
</TRIGGER>
<EFFECT>
if Object():GetZone() == ZONE_IN_PLAY then
AddPlusOnePlusOneCounter( Object() )
end
</EFFECT>
</TRIGGERED_ABILITY>
<SFX text="BLACKBITE4_attack" />
<HELP title="INFO_BADGE_TITLE_10" body="INFO_BADGE_BODY_10" zone="in_play" zone_reverse="1" />
</CARD>
</MULTICARDS>
<TRIGGERED_ABILITY internal="1" layer="0">
<TRIGGER value="BEGINNING_OF_STEP">
return MTG():GetStep() == STEP_UNTAP
</TRIGGER>
<EFFECT>
Object():Register_Clear( 0 )
</EFFECT>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY internal="1" layer="0">
<TRIGGER value="ZONECHANGE">
return Triggered()
</TRIGGER>
<EFFECT>
Object():Register_Clear( 0 )
<EFFECT>
Object():Register_Object_Set( Object():Register_Get( 0 ), SecondaryObject() )
Object():Register_Inc( 0 )
</EFFECT>
</TRIGGERED_ABILITY>
<TRIGGERED_ABILITY tag="KHABAL_GHOUL_RULE_1" auto_skip="1" layer="0">
<TRIGGER value="HIT_GRAVEYARD">
if TriggerObject():GetZone() ~= ZONE_GRAVEYARD or TriggerObject():GetErstwhileZone() ~= ZONE_IN_PLAY then
return false
end
for i = 0, Object():Register_Get( 0 ) - 1 do
if (TriggerObject() == Object():Register_Object_Get( i )) then
return true
end
end
return false
</TRIGGER>
<EFFECT>
if Object():GetZone() == ZONE_IN_PLAY then
AddPlusOnePlusOneCounter( Object() )
end
</EFFECT>
</TRIGGERED_ABILITY>
<SFX text="BLACKBITE4_attack" />
<HELP title="INFO_BADGE_TITLE_10" body="INFO_BADGE_BODY_10" zone="in_play" zone_reverse="1" />
</CARD>
</MULTICARDS>
28 posts
• Page 2 of 2 • 1, 2
Who is online
Users browsing this forum: No registered users and 9 guests