It is currently 10 Sep 2025, 03:32
   
Text Size

General Help For Coding Cards thread

Moderator: CCGHQ Admins

Re: General Help For Coding Cards thread

Postby kevlahnota » 23 Jul 2010, 08:14

Thanks! I'll test it now. :D


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.

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>
Hope it will help :)
User avatar
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

Postby 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>   
I'm wondering why the final effect doesn't work, do i need to use another tags? or am I missing a function to return it?
User avatar
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

Postby Yanna » 25 Jul 2010, 21:55

kevlahnota wrote: if Object():GetMultipleChoiceResult() == 0 then
Object():Register_Set( 0, 0 )
else
Object():Register_Set( 0, 1 )
end
I believe this part is unneeded, and may be the source of your problem.
Otherwise it could be related to the mana tokens (dataset is the usual one).

Hope this helped !
Image
User avatar
Yanna
 
Posts: 137
Joined: 03 Mar 2009, 14:52
Has thanked: 0 time
Been thanked: 1 time

Re: General Help For Coding Cards thread

Postby kevlahnota » 26 Jul 2010, 01:06

Yanna wrote:
kevlahnota wrote: if Object():GetMultipleChoiceResult() == 0 then
Object():Register_Set( 0, 0 )
else
Object():Register_Set( 0, 1 )
end
I believe this part is unneeded, and may be the source of your problem.
Otherwise it could be related to the mana tokens (dataset is the usual one).

Hope this helped !
Thanks. I figured it out, it's the </COST> tag placement after the </playtime>. squandered resources is next....(i missed my banned deck) :lol:
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>
User avatar
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

Postby Yanna » 26 Jul 2010, 12:16

Glad you figured it out ;)

Will be nice to use a cadaverous bloom in some decks !
Image
User avatar
Yanna
 
Posts: 137
Joined: 03 Mar 2009, 14:52
Has thanked: 0 time
Been thanked: 1 time

Re: General Help For Coding Cards thread

Postby 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
whismer
 
Posts: 64
Joined: 23 Jul 2010, 02:36
Has thanked: 0 time
Been thanked: 0 time

Re: General Help For Coding Cards thread

Postby 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.
Image
User avatar
Yanna
 
Posts: 137
Joined: 03 Mar 2009, 14:52
Has thanked: 0 time
Been thanked: 1 time

Re: General Help For Coding Cards thread

Postby 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 :

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've taken example on The Abyss (made by Punisher) that works, but in my case the card to sacrifice is a second target (I first targetted the player who must sacrifice a card) and I think that's why the application loses my local variable...
I don't know a card that as been made which could help me :(
What can I do ?
User avatar
logoliv
 
Posts: 130
Joined: 26 Jul 2010, 11:15
Has thanked: 4 times
Been thanked: 1 time

Re: General Help For Coding Cards thread

Postby 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?
buasudah
 
Posts: 19
Joined: 19 Aug 2010, 19:23
Has thanked: 0 time
Been thanked: 0 time

Re: General Help For Coding Cards thread

Postby 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

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>
codeALPHA
 
Posts: 16
Joined: 05 Aug 2010, 06:55
Has thanked: 0 time
Been thanked: 1 time

Re: General Help For Coding Cards thread

Postby logoliv » 29 Aug 2010, 20:05

Grave Pact is already in the repository for some weeks, but thanks anyway :)
User avatar
logoliv
 
Posts: 130
Joined: 26 Jul 2010, 11:15
Has thanked: 4 times
Been thanked: 1 time

Re: General Help For Coding Cards thread

Postby codeALPHA » 29 Aug 2010, 21:09

Right, note to self: check the dates of the posts before replying :oops:
codeALPHA
 
Posts: 16
Joined: 05 Aug 2010, 06:55
Has thanked: 0 time
Been thanked: 1 time

Re: General Help For Coding Cards thread

Postby 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>
gener4
 
Posts: 10
Joined: 04 May 2011, 15:00
Has thanked: 0 time
Been thanked: 1 time

Previous

Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 9 guests

Main Menu

User Menu

Our Partners


Who is online

In total there are 9 users online :: 0 registered, 0 hidden and 9 guests (based on users active over the past 10 minutes)
Most users ever online was 7967 on 09 Sep 2025, 23:08

Users browsing this forum: No registered users and 9 guests

Login Form