Log in

DotP 2014: Modding Tutorial

Modding Duels of the Planeswalkers 2014 is largely the process of coding a new card, finding the art for the card, and then packing all of the new cards and art into a .wad file. However, there are a few things you should have set up before you begin to make things go a bit more smoothly, and there are some advanced things you can try.

Before we go any further, you need to decide whether you're modding for the Community Wad or if you'll be releasing the wad yourself. Making the cards is mostly the same process either way, but if you're working with the Community Wad, you won't be packing or unpacking any .wad files, you won't be collecting or converting the art, and you won't be making a thread for it (although, you could, and you may still want to make a thread for you decks, that's up to you).


Contents

Tools

A quick overview of the tools used. Installing these is discussed in the next section.

To get started, you'll need a few tools.

For the first three tools, custom files can be found in the Public CW Tools folder. The custom files will be explained below.

Gibbed Tools allows you to pack and unpack .wad files. .Wad files are archive files (like .zip or .7z files). They are a folder and its contents packaged together as a single file which the game knows how to read. The .wad files contain the cards, their images, text helper files, and LUA function files. This set of tools also allows you to convert JPGs and PNGs to and from TDX files, which is the format the game requires. The custom files Gibbed Tools basically consist of an exe that you can drop any file onto. If one of the Gibbed Tools exes could handle it, then it's run through the appropriate one. Drop a wad file, and it'll be unpacked. Drop an image, and it'll be converted to or from tdx. It can also handle folders if the headers are set up right (which gibbed tools requires). The entire Gibbed Tools package can be downloaded from the Public Tools folder.

A card generator produces the template for a card. A card is made up of many sections of code, most of which can be directly read from Gatherer. thefiremind has made two different tools which do exactly this, collecting any information it can from the card's page and converting it to an XML template the game can read. The sections of code that will often be missing or incorrect, needing fixed by a modder, are the sections of code that explain what the card's abilities do. The text for the abilities is usually successfully parsed and included, but the actual code is often missing or wrong. The custom files for this are more advanced parsing scripts for the output plugins and a local input plugin that allows you to make custom cards just as easily as official ones. Just download the "DotPUniGen.zip" file.

RiiakShiNal's Deck Builder allows you not only to make decks but also to set up a custom data folder and check for many different kinds of errors in the cards you make. The custom files for this one allow you to filter by underscore (allowing you to exclude most of the cards in the CW that aren't meant to go into a deck), edit an existing deck without having to make a new one or mess with the ID the deck is given, and helps ensure the AI Personality (the art that shows up when selecting the deck or playing against it) are always present (it has a habit of disappearing, but the custom files fix that). It may have other features not mentioned here because it's actively updated, albeit slowly. Unlike the two above, you'll need to download the original, and then replace some of its files with ones from the PUblic Tools folder. You only need the exe and the xml file. The zip file (if it still exists) in just the source code for the exe. The xml file goes into your Deck Builder's "Lang" folder.

You can, of course, use any image editing program you want, but MS Paint is likely all you need (the main thing you'll need to do is crop and resize, both of which are very easy in MS Paint).

For the Text Editor, Notepad++ is a good candidate. It comes prepackaged with XML highlighting and LUA highlighting, both of which are used. It is possible to use Notepad, but it is not recommended.

Useful Links

Many links are very useful for modders that users are unlikely to need. As such, they don't get much attention because most modders are already aware of them, so they simply use them rather than asking about them.

Most of these links can be found on the main DotP 2014 wiki page.

Process

The actual process of modding involves three major phases, each with its own individual steps.

  1. Preparing the environment
    1. Register a prefix to use when coding
    2. Install all necessary tools
    3. Set up your folder which will contain the mod
  2. Creating cards
    1. Obtain the card template
    2. Code check/add/correct any code which is not correct
    3. Obtain art
    4. Modify and convert art
    5. Add any needed helper text to helper text files (TEXT_PERMANENT.XML files)
  3. Releasing the mod
    1. Pack the folder
    2. Upload the mod
    3. Create a topic


Phase 1: Preparing the Environment

Step 1: Register a prefix to use when coding

The DotP_2014:_Prefix/Id_Registry contains a list of registered prefixes and IDs. Choose yours and add it to the list. Make sure your Prefix is not the start of another prefix. Because 9009 is registered, you cannot use 9, 90, or 900. Also, make sure the prefix you choose is not an extension of another prefix. Because 909 is registered, do not use 9098 or 90935. Best practice: make sure it's 3 or 4 digits.

When you add it to the list, make sure they're in ascending order.

You may also reserve an ID, such as TFM, RSN, or X99. Make sure they're in alphabetical order.

When modding DotP, if different modders make a card with the same filename, or use a constant with the same name, or use a public chest with the same register, those mods will interfere with one another. In order to avoid this, you'll prefix any of these with your registered prefix. This way, the only person that can interfere with your functions, cards, constants, and decks is you.

Step 2: Install all necessary tools.

In order to install the needed tools, simply place most of them into a folder where they can be easily accessed. Personally, I use a folder named "Modding" inside of my game folder. This makes them easy to access and keeps them from interfering with anything else. Keeping each tool in its own separate subfolder is recommended.

Gibbed Tools Download the binaries, and then unzip the file into a subfolder of your modding folder.

As an alternative to this, you may want to use the copy from the Public Tools folder of the Community Wad. Simply choose the gibbed tools.zip file and download it. It contains an extra file which will handle all of the conversions rather than needing multiple different ones. If you set that Universal Gibbed Converter as the default for TDX and WAD files, you can double click them to convert them where they are so you can open them. This is not necessary but is an option.

A Card Generator thefiremind made two different card generators. The first one was run in the browser, but he has lost access to its source code and can't update it. However, he made a downloadable one which you can download and extract to your Modding folder and run on your computer. Xander9009 made plugins for it (see the linked thread) which expands its capabilities to include many more abilities. Either way, get the binaries and the DLLs. The DLLs must go in the same folder as the executable. If you get the optional plugin, it goes in the python folder, and when you run the generator, select the X99 plugin as the output plugin.

Once you have it where you want it, run it. Make sure Prefix is checked and that it contains your registered prefix. Please note that if you use a prefix of 4 digits, the generator will default to 999 because it adds that prefix before the MultiverseID. In that case, after creating any cards with it, the FILENAME, ARTID, and MULTIVERSEID tags will need to be altered.

RiiakShiNal's Deck Builder Download the version for your system and extract it to your game folder. Run it. It'll tell you to perform the initial set up. When you do, you'll point it to your game folder, and in the top red box, put in your registered prefix. This will ensure than any decks you export will automatically use this prefix.

This tutorial will assume you are using MS Paint. The steps are simple, so you should be able to replicate them in whatever image editor you're using.

If you decided the text editor you'll use is Notepad++, then download the latest version and install it. Otherwise, install whichever editor you prefer.

Step 3: Set up your folder which will contain the mod

In the Deck Builder, go to Tools>Setup Custom Data Folder. This will create a folder in your game folder named DATA_DLC_DECK_BUILDER_CUSTOM. A few subfolders in, you'll find CARDS, ART_ASSETS, TEXT_PERMANENT, and FUNCTIONS, along with a few others. Inside of ART_ASSETS you'll find ILLUSTRATIONS. These are the folders you need to add cards and art to in order to be loaded by the game.

Phase 2: Creating cards

Step 1: Obtain the card template

In the card generator, type in the name of the card you want to code and click run. If you're using a modified output plugin, make sure it's selected first. If you're making a custom card, then you'll need to use the LocalInput plugin (search the card generator's thread or get it from the Public Tools folder in the DotPUniGen.zip file). Save the card when it prompts you and you've got your template.

Step 2: Code check/add/correct any code which is not correct

How to Code Cards

Coding the card itself is the most time-consuming part of modding. It's the bulk of what we do, and as a result, it's been separated into its own page.

Once the card is coded, you'll need to place it in the CARDS folder you found in Phase 1>Step 3.

Step 3: Obtain art

For the art, you'll need to find a suitable image. The game's internal images for cards are 512x376 pixels, and this should be your goal. So, when finding an image, try to find one at least this large. If you need to shrink it, you can. But you can't make them larger without stretching them and making them look bad.

Google the card's name, possibly appending "art". If this fails, you may be able to find it on the artist's website. Many artists have either their website, a DeviantArt account, or both. Googling the artist may net you a gallery with their work, where you can find what you need.

Other sources of art include:

Art can also be found right here on Slightly Magic. The Pictures thread contains many topics related to the scanning of MTG images. You can download torrents with the images or check the Mega repository.

In your card's template, you'll find an XML tag which reads

<ARTID value="####" />

The value here is what your art file should be named. So, it could read

<ARTID value="123456" />

If it did, then that card would load the art named "123456.TDX". Name you jpg or png "123456.jpg" or "123456.png".

Step 4: Modify and convert art

Next up, you need to resize and then crop your art. The game displays the images only at a certain resolution. Any larger, and your file will be larger than it needs to be since the game will just scale it down anyway. As mentioned before, the optimum size is 512x376px. Open your art in MS Paint and click the Resize tool on the toolbar. Switch to pixel mode at the top. Now, set the Horizontal field to 512 and see what the Vertical field says. If it's smaller than 376, then set the Vertical field to 376. Click ok and it's resized.

Next step is to crop. Cropping can be simple or complicated. It's up to you. The simple method is just to drag the right side or the bottom inward to shrink the image until it's the correct size (the size in pixels can be seen in the status bar at the bottom of the window). If you don't want it to become too distorted as far as the center goes, click Rotate 180°. Now you can drag the other sides. Rotate 180° again to return it to its proper orientation. When you're pleased with its centering and it's 512x376px, save it. Please note that should you intend to really work on art, MS Paint has a tendency to create a bit of transformation weirdness. Whenever the image is transformed, such as rotating or flipping it, it'll lose some of its initial quality. If you want to transform it, it might be best to use a better program like Gimp.

Finally, you need to convert it to a TDX file. In your Gibbed Tools folder, you'll find two files related to converting images. Gibbed.Duels.TdxConvert.exe and Tdx Convert Compressed.bat. The first one does the work of actually converting the image, but you'll want to use the bat file. Just drop your image onto the bat file and you'll get a compressed TDX file ready for the game. If you have the Universal Gibbed Converter, you can drop it on that for the same result.

Now that you have the converted art, it needs to go in the ILLUSTRATIONS folder from Phase 1>Step 3.

If you're making art for certain types of cards, you'll need different dimensions. For tokens, you'll not only need different dimensions but also specific placement within those dimensions. Full art dimensions are 356x512. It's nearly a simple 90° rotation of the other, with only a 20px difference. Full art should be used for tokens and any colorless non-artifact, nonland card. This only applies to cards which are inherently colorless, not those made colorless through an ability such as devoid, which needs normal art.

For tokens, you'll need an image that is 356x512, but only a certain area within that image will actually show in-game. If the creature has an ability, then that area is (inclusive from the top left) 13x44 to 342x336. Without an ability, it's 16x46 to 339x424.

There are templates for these here.

Step 5: Add any needed helper text to helper text files (TEXT_PERMANENT XML files)

When making cards, sometimes you need to have text for multiple choice questions, target choices, ability tags, or various other things. That is covered in the guide to coding cards. To make sure the text actually appears, however, you'll need to make an entry in a TEXT_PERMANENT file. These files are XML files which can be opened with Excel.

Simply open a good one in Excel and delete everything after the first row. Then, add your tag in the first column, the English in the Master Translation column, and then any translations you have in the various other columns. Save it as a new file (it needs to be saved as XML Spreadsheet 2003) and place it in your TEXT_PERMANENT folder from Phase 1>Step 3.

If you can't find a good one to use, or you can't open them with excel, you can make one from scratch in excel. From cells A through L, row 1 should contain:

A: Ident

B: Comment

C: Master Translation

D: French

E: Spanish

F: German

G: Italian

H: (Blank)

I: Japanese

J: Korean

K: Russian

L: Portuguese (Brazil)

Rows 2 and down should contain your text. Ident is the identifier. If you use "CARD_QUERY_SOME_CARD_ANSWER_1" in a multiple choice question, then that's the identifier. Ignore Comment (it's not read by the game). Master Translation is where the English translation goes. If any of the fields are missing, the game will load this translation.

If you don't have Excel, Open Office may be able to modify these without breaking them. I don't know, I've never tried. Either way, you can modify them with Notepad++ if needed, although doing so without updating the "ExpandedRowCount" variable will cause it not to open in Excel anymore, so find and update that variable to keep it easy on others.

Here's a blank Blank Text Permanent file. Copy that and paste it into Notepad++. In order to add a new entry, copy and paste from <ROW> to </ROW> (including those tags). Replace the values (Ident, Comment, Master Translation, ...) with your identifier and translations. In order to make sure it can continue to be opened by Excel, find the <Table ss:ExpandedColumnCount="12" ss:ExpandedRowCount="1" x:FullColumns="1" x:FullRows="1" ss:DefaultRowHeight="15"> tag on line 36 and set ss:ExpandedRowCount="1" to the new number of rows. Using all caps is standard. They typically are named following one of two formats. CARD_UI_TEXT_(PREFIX/ID).XML or D14_(PREFIX/ID)_TEXT.XML.

Phase 3: Releasing the mod

Step 1: Pack the folder

In order to pack the folder, you can use either Gibbed Tools or RiiakShiNal's Deck Builder. The Deck Builder is preferred. To do so, go to Tools>Create Core WAD From Custom Data. It will ask for the name of the file. It should be fine as it is, so just click save.

If for some reason you want or must do it manually, you'll need to create a new folder with which will be named whatever you want the WAD named. We'll assume you want your mod to be named "DATA_DLC_(ID)_MY_MOD_CORE.WAD". It must begin with "DATA_DLC_" and adding your ID prevents any possible conflicts.

  1. Make a folder named "DATA_DLC_(ID)_MY_MOD_CORE"
  2. Move the "DATA_DLC_DECK_BUILDER_CUSTOM" folder into "DATA_DLC_(ID)_MY_MOD_CORE"
  3. Open "DATA_DLC_(ID)_MY_MOD_CORE"
  4. Rename "DATA_DLC_DECK_BUILDER_CUSTOM" to "DATA_DLC_(ID)_MY_MOD_CORE"
  5. Open "DATA_DLC_(ID)_MY_MOD_CORE\DATA_DLC_(ID)_MY_MOD_CORE".
  6. Open "HEADER.XML"
  7. Change "DATA_DLC_DECK_BUILDER_CUSTOM/DATA_ALL_PLATFORMS/" to "DATA_DLC_(ID)_MY_MOD_CORE/DATA_ALL_PLATFORMS/", save, and close.
  8. Copy "HEADER.XML"
  9. Go up a folder back into the folder named "DATA_DLC_(ID)_MY_MOD_CORE" which contains the subfolder of the same name.
  10. Paste "HEADER.XML"
  11. Rename "HEADER.XML" to "@header.xml"
  12. Drag and drop the uppermost "DATA_DLC_(ID)_MY_MOD_CORE" folder (unless you moved it, it'll be the one directly in your game folder) onto either "Gibbed.Duels.Pack.exe" or "Universal Gibbed Converter.exe"


Step 2: Upload the mod

In order for others to use the mod, they obviously need to be able to access it. Slightly Magic will allow you to upload the file directly to the site if it's small enough, but this isn't recommended because the site has limited storage. A better option is to use a free file hosting website.

Google Drive

Mega

Zippy Share

These are all good sites to use. Note that if you want to have a direct download link and you're using Google Drive, you can. Make sure the file is viewable by the public by sharing it. Right click the file and choose Share. Set it so anyone with the link can view the file.

Next copy the link and get just the ID. The ID of a Google Drive file is a long string of letters and numbers.

If https://drive.google.com/file/d/0B-cZn2P5m-lYYnpEX0NVVEJac28/view?usp=sharing is the URL you copied, you'd need 0B-cZn2P5m-lYYnpEX0NVVEJac28. Now, append that to this URL: https://docs.google.com/uc?export=download&id= so that you get https://docs.google.com/uc?export=download&id=0B-cZn2P5m-lYYnpEX0NVVEJac28. This URL will download the file without any user interaction (except asking where they want it saved).

Step 3: Create a topic

The final step is to make a topic and let everyone know about your new mod. If your mod is for custom cards, there's a forum specifically for that.

Note that once released, you're likely to get many people experiencing bugs and other problems. This is absolutely normal and there's no way around it. Fix them the best you can and ask for help (either in your own thread, in the General Coding Questions thread, or a new thread in the Programming section) when you need it.