It is currently 28 Apr 2024, 06:23
   
Text Size

Creating Tokens

Moderator: CCGHQ Admins

Creating Tokens

Postby irie009 » 09 Jul 2013, 06:55

I am currently creating my very first card, and while I probably should have stuck with something extremely simple, like a Savannah Lion, I am trying to program Thopter Foundry

Now I have the card fleshed out with basic xml, and the tdx crop ready, it looks great ingame

In looking at Master of the Wild Hunt for some help in the token area, obviously this is the piece of code that is important
| Open
MTG():PutTokensOntoBattlefield( "TOKEN_WOLF_2_2_G_350765", 1, EffectController() )


I am assuming that the id on the end there, 350765, is for the actual token card with the wolf on it. Now, how do I go about adding a Thopter token into the game?
irie009
 
Posts: 9
Joined: 09 Jul 2013, 06:38
Has thanked: 1 time
Been thanked: 0 time

Re: Creating Tokens

Postby irie009 » 09 Jul 2013, 07:05

I found this through a search
| Open
<?xml version='1.0'?>
<CARD_V2>
<FILENAME text="TOKEN_OOZE_S_S_19990127" />
<CARDNAME text="OOZE" />
<TITLE>
<LOCALISED_TEXT LanguageCode="en-US"><![CDATA[OOZE]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="fr-FR"><![CDATA[LIMON]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="es-ES"><![CDATA[CIENO]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="de-DE"><![CDATA[SCHLAMMWESEN]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="it-IT"><![CDATA[MELMA]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="jp-JA"><![CDATA[ウーズ]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ko-KR"><![CDATA[점액괴물]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="ru-RU"><![CDATA[Тина]]></LOCALISED_TEXT>
<LOCALISED_TEXT LanguageCode="pt-BR"><![CDATA[LODO]]></LOCALISED_TEXT>
</TITLE>
<MULTIVERSEID value="19990127" />
<ARTID value="A19990127" />
<COLOUR value="G" />
<ARTIST name="Marco Nelor" />
<CASTING_COST cost="" />
<TYPE metaname="Creature" />
<SUB_TYPE metaname="Ooze" />
<EXPANSION value="DPG" />
<RARITY metaname="T" />
<POWER value="*" />
<TOUGHNESS value="*" />
<TOKEN />
<STATIC_ABILITY filter_zone="ZONE_IN_PLAY">
<CONTINUOUS_ACTION layer="7A">
local index = ObjectDC():Get_Int(COMPARTMENT_ID_STAR_TOKEN_INDEX)
local stm = StarTokensManager()
local power = stm.GetPower(index)
local toughness = stm.GetToughness(index)
local characteristics = Object():GetCurrentCharacteristics()
characteristics:Power_Set(power)
characteristics:Toughness_Set(toughness)
</CONTINUOUS_ACTION>
</STATIC_ABILITY>
<SFX text="COMBAT_BLUNT_LARGE_ATTACK" power_boundary_min="4" power_boundary_max="-1" />
<SFX text="COMBAT_BLUNT_SMALL_ATTACK" power_boundary_min="1" power_boundary_max="3" />
</CARD_V2>

Can I just go off this, and make a thopter version of it?
irie009
 
Posts: 9
Joined: 09 Jul 2013, 06:38
Has thanked: 1 time
Been thanked: 0 time

Re: Creating Tokens

Postby irie009 » 09 Jul 2013, 07:16

I am also searching through the current cards for a card that requires you to sac an artifact, specifically, but I am need help on that part of the code as well. I know this seems like a card request thread but I am really just trying to learn my way through this
irie009
 
Posts: 9
Joined: 09 Jul 2013, 06:38
Has thanked: 1 time
Been thanked: 0 time

Re: Creating Tokens

Postby gorem2k » 09 Jul 2013, 07:36

irie009 wrote:I found this through a search

"TOKEN_OOZE_S_S_19990127"

Can I just go off this, and make a thopter version of it?
it would be less complicated to use TOKEN_GRIFFIN_2_2_W_F_350754,

1 - copy and rename this file to TOKEN_THOPTER_1_1_F.xml

2 - change <FILENAME text="TOKEN_GRIFFIN_2_2_W_F_350754" /> to
<FILENAME text="TOKEN_THOPTER_1_1_F" />

3 - change every word GRIFFIN/Griffin to THOPTER/Thopter

4 - change <COLOUR value="W" /> to <COLOUR value="U" />

4 - change both power and toughness values "2" to "1"

5 - the rest is details, the thopter token image will be a griffin image. if you want to change it, <ARTID value="98951" /> 98951 (.TDX) is the filename image.
gorem2k
 
Posts: 464
Joined: 01 Apr 2013, 04:21
Has thanked: 48 times
Been thanked: 33 times

Re: Creating Tokens

Postby irie009 » 09 Jul 2013, 07:47

The issue is that Riiak's deck builder does not show me the token cards that are in the wads, so I can't view the code for them, or mayb e it does and I am just not seeing them for some reason? Anyway to view all of the available tokens so I can get the code? Also, if I want to create my own tdx image for a token, do I go about it the same way as for a normal card, or is there another process?
irie009
 
Posts: 9
Joined: 09 Jul 2013, 06:38
Has thanked: 1 time
Been thanked: 0 time

Re: Creating Tokens

Postby irie009 » 09 Jul 2013, 07:49

I figured it out, I guess some filters come pre selected, after hitting clear filters I can see the tokens
irie009
 
Posts: 9
Joined: 09 Jul 2013, 06:38
Has thanked: 1 time
Been thanked: 0 time

Re: Creating Tokens

Postby thefiremind » 09 Jul 2013, 08:13

irie009 wrote:Anyway to view all of the available tokens so I can get the code?
Either you unpack the official decks WAD, or you download "cards2014.zip" from here:
viewtopic.php?f=62&t=10872
You'll find the code for all the official cards, tokens included.

irie009 wrote:Also, if I want to create my own tdx image for a token, do I go about it the same way as for a normal card, or is there another process?
The difference is that the token TDX covers the whole card, so you need to position the picture in the right place to make it viewable from the token's "picture window". This is not very difficult if you start from an existing token image and paste your image onto the original with Paint.NET. Note that tokens with written abilities will need a smaller picture because their "picture window" is smaller. The standard size for token TDXs is 356x512.

gorem2k wrote correct steps but forgot a couple:
  1. The Thopter is an artifact creature so you would need to add the artifact type to the griffin.
  2. Changing just the art ID isn't enough: you need to change the Multiverse ID so that each card has a different one.

Now, I already made the Thopter token you need because I coded Sharding Sphinx which uses the same one, so here it is, with your prefix:
TOKEN_THOPTER_1_1_U_F_313900001.zip
(60.33 KiB) Downloaded 271 times

We can't find the Multiverse IDs for tokens anywhere so we have to invent our own. Since we won't reach Multiverse ID 900,000 anytime soon, I suggest to start from 900,001 and go on from there for all the tokens you make in the future.

About the ability, I'd suggest to start from Jade Mage, which already has an activated ability that produces tokens.
Jade Mage ability (untouched) | Open
Code: Select all
  <ACTIVATED_ABILITY>
    -- Localised text omitted
    <COST mana_cost="{2}{G}" type="Mana" />
    <RESOLUTION_TIME_ACTION>
    MTG():PutTokensOntoBattlefield( "TOKEN_SAPROLING_1_1_G_350772", 1, EffectController() )
    </RESOLUTION_TIME_ACTION>
    <AI_AVAILABILITY window_step="declare_blockers" type="window" />
    <AI_AVAILABILITY type="in_response" response_source="1" />
    <AI_AVAILABILITY window_step="end_of_turn" window_turn="their_turn" type="window" />
    <AI_AVAILABILITY window_step="declare_attackers" window_turn="their_turn" type="window" />
    <AI_AVAILABILITY window_step="main_2" window_turn="my_turn" type="window" />
    <AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
  </ACTIVATED_ABILITY>
  <TOKEN_REGISTRATION reservation="1" type="TOKEN_SAPROLING_1_1_G_350772" />
What do we notice here? First thing: the TOKEN_REGISTRATION block. Each kind of token produced by a card needs its TOKEN_REGISTRATION block. The tag reservation="1" is always the same, no need to change it. The type must be changed, of course, to match your token.

Let's start by substituting the Saproling with the Thopter:
Jade Mage ability that produces Thopters | Open
Code: Select all
  <ACTIVATED_ABILITY>
    -- Localised text omitted
    <COST mana_cost="{2}{G}" type="Mana" />
    <RESOLUTION_TIME_ACTION>
    MTG():PutTokensOntoBattlefield( "TOKEN_THOPTER_1_1_U_F_313900001", 1, EffectController() )
    </RESOLUTION_TIME_ACTION>
    <AI_AVAILABILITY window_step="declare_blockers" type="window" />
    <AI_AVAILABILITY type="in_response" response_source="1" />
    <AI_AVAILABILITY window_step="end_of_turn" window_turn="their_turn" type="window" />
    <AI_AVAILABILITY window_step="declare_attackers" window_turn="their_turn" type="window" />
    <AI_AVAILABILITY window_step="main_2" window_turn="my_turn" type="window" />
    <AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
  </ACTIVATED_ABILITY>
  <TOKEN_REGISTRATION reservation="1" type="TOKEN_THOPTER_1_1_U_F_313900001" />
Now we need to change the cost for Thopter Foundry, it isn't {2} {G} but {1} plus sacrifice a nontoken artifact. The {1} cost can be written in place of {2} {G}, that's easy. The other cost still needs to be added. Let's look at the official cards again. There are cards that need to sacrifice a creature as a cost, for example Jinxed Idol. Let's copy its sacrifice cost:
Jinxed Idol sacrifice cost (untouched) | Open
Code: Select all
    <COST type="Sacrifice" definition="0" compartment="1" query_tag="CARD_QUERY_CHOOSE_CREATURE_TO_SACRIFICE" item_count="1" />
    <COST_DEFINITION id="0">
    local filter = ClearFilter()
    filter:Add( FE_TYPE, OP_IS, CARD_TYPE_CREATURE )
    </COST_DEFINITION>
First let's make it so that it needs artifacts instead of creatures:
Jinxed Idol sacrifice cost that wants artifacts | Open
Code: Select all
    <COST type="Sacrifice" definition="0" compartment="1" query_tag="CARD_QUERY_CHOOSE_ARTIFACT_TO_SACRIFICE" item_count="1" />
    <COST_DEFINITION id="0">
    local filter = ClearFilter()
    filter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
    </COST_DEFINITION>
I changed the query_tag as well but it's not important for the code, that's a string that will be substituted with the right query in your game's language, for example "Choose an artifact to sacrifice." which will be displayed while you choose the artifact. This is still not enough, Thopter Foundry wants a nontoken artifact. Let's search for "nontoken" in the official cards. I found Bifurcate, where you can see what kind of filter you need to add for "nontoken". Let's add it:
Jinxed Idol sacrifice cost that wants nontoken artifacts | Open
Code: Select all
    <COST type="Sacrifice" definition="0" compartment="1" query_tag="CARD_QUERY_CHOOSE_ARTIFACT_TO_SACRIFICE" item_count="1" />
    <COST_DEFINITION id="0">
    local filter = ClearFilter()
    filter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
    filter:Add( FE_IS_TOKEN, false )
    </COST_DEFINITION>
Our cost is ready, let's add it to our token-producing ability:
Thopter Foundry ability | Open
Code: Select all
  <ACTIVATED_ABILITY>
    -- Localised text omitted
    <COST mana_cost="{1}" type="Mana" />
    <COST type="Sacrifice" definition="0" compartment="1" query_tag="CARD_QUERY_CHOOSE_ARTIFACT_TO_SACRIFICE" item_count="1" />
    <COST_DEFINITION id="0">
    local filter = ClearFilter()
    filter:Add( FE_TYPE, OP_IS, CARD_TYPE_ARTIFACT )
    filter:Add( FE_IS_TOKEN, false )
    </COST_DEFINITION>
    <RESOLUTION_TIME_ACTION>
    MTG():PutTokensOntoBattlefield( "TOKEN_THOPTER_1_1_U_F_313900001", 1, EffectController() )
    </RESOLUTION_TIME_ACTION>
    <RESOLUTION_TIME_ACTION>
    EffectController():GainLife(1)
    </RESOLUTION_TIME_ACTION>
    <AI_AVAILABILITY window_step="declare_blockers" type="window" />
    <AI_AVAILABILITY type="in_response" response_source="1" />
    <AI_AVAILABILITY window_step="end_of_turn" window_turn="their_turn" type="window" />
    <AI_AVAILABILITY window_step="declare_attackers" window_turn="their_turn" type="window" />
    <AI_AVAILABILITY window_step="main_2" window_turn="my_turn" type="window" />
    <AI_AVAILABILITY window_step="main_1" window_turn="my_turn" type="window" />
  </ACTIVATED_ABILITY>
  <TOKEN_REGISTRATION reservation="1" type="TOKEN_THOPTER_1_1_U_F_313900001" />
Done. :D (I didn't write the localised text for the ability but you have it in your pre-made XML, just position it in place of "-- Localised text omitted".)

EDIT: Added the life gain, I totally overlooked that. #-o
Last edited by thefiremind on 09 Jul 2013, 09:11, edited 1 time in total.
< 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

Re: Creating Tokens

Postby irie009 » 09 Jul 2013, 08:23

Ok, I have my thopter token fleshed out now, does anyone know how to fit the TDX image into these properly? I just used the same image I have for thopter foundry as a test, and it looks like the standard for cards at 512/376 gets stretched into the frame of the token cards
irie009
 
Posts: 9
Joined: 09 Jul 2013, 06:38
Has thanked: 1 time
Been thanked: 0 time

Re: Creating Tokens

Postby irie009 » 09 Jul 2013, 08:28

Holy crap Fire, tyvm, I actually was already on track with some of the info, I knew the thopter token was colorless and had looked at the sliver token to determine how to do that, the positioning of the tdx is going to take some getting used to if i do this in the future but with your card as a guide im sure i wont have an issue with other tokens if i need them. Thanks for all this wonderful info, now to see if I can apply it, and get the card working ingame, hope I can post some screens with hundreds of thopter's fllying around my board =P, oh and of course, Sword of the Meek is my next card I will be trying to add =P
irie009
 
Posts: 9
Joined: 09 Jul 2013, 06:38
Has thanked: 1 time
Been thanked: 0 time

Re: Creating Tokens

Postby RiiakShiNal » 09 Jul 2013, 12:51

irie009 wrote:I figured it out, I guess some filters come pre selected, after hitting clear filters I can see the tokens
That is correct because lets face it how often is someone going to add a token to a deck, or a scheme or a plane for that matter as well. Planeswalkers aren't supported, Vanguards aren't in the game, and the game will automatically add basic lands so there is no reason to add those. So yeah, the default is to have some things filtered out.

Though it should be noted that if you use the basic filters then you can't un-filter things like invisible tokens (they have no types so under the basic filters there isn't really any way to prevent them from being filtered out). So if you want to show invisible tokens you'll either need to clear the filters or use advanced filters. Though there is really no point in adding invisible tokens to a deck either so for regular users this is a non-issue.
RiiakShiNal
Programmer
 
Posts: 2185
Joined: 16 May 2011, 21:37
Has thanked: 75 times
Been thanked: 497 times


Return to Programming Talk

Who is online

Users browsing this forum: No registered users and 23 guests


Who is online

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

Login Form