Tutorial
Contents |
Level 0 - Adding Basic Cards
What is a level 0 card?
A "level 0" card is a card that can be added without writing any code at all!
Generally, these cards have an identical ability of an existing card. For example, 'Nantuko Shade' is a level 0 card because it has an identical ability as 'Frozen Shade', even though its casting cost, creature type, and power are different.
Card type does not even need to be the same, just ability. In this way, 'Magus of the Library, and Disk' are all level 0, since they have the same ability as an existing land and artifact, respectively.
Finally, a small set of basic abilities can be added to other cards without any code changes. Those are basic landwalk, flying, banding, trample, first strike, protection, reach, rampage, and shroud. Therefore you can add Spectral Lynx (regen + pro green), but not Bull Cerodon (haste + vigilence).
Prerequisites
Before you add any card, make sure you have the most up-to-date version of the Magic software. That can generally be found in the stickied post Manalink Update Date.
Next, download the most recent version of the SkyMagic Editor. That can be found here.
Creating a Card
For this exercise, we will be creating the card Skyknight Legionnaire. (yes, this card does already exist, so we'll actually create it with a new name)
- Open up SkyMagic Editor. It should look something like this:
- Use the binoculars icon to search for the card that has the same ability as the card you want to create. Remember that in this case, the ability is "haste", since we get flying for free. Raging Goblin has "haste", so we'll search for that.
Remember this card's id. - This is a new card, so we need to enter a new ID. Scroll all the way to the bottom of the list of cards to see what the highest ID currently is. Set your ID to the next highest number.
- Fill in 'Name' and 'Full Name' with the name of your card. Call it 'Test Card', so that we don't interfere with the real Skyknight Legionnaire.
- 'CODED CARD' indicates the card is done, and ready to show up in the deck editor. Leave this as '1' unless you do not plan on finishing your card now.
- The next few fields, 'Expansion', 'Color', and 'Card Type' all have dropdowns of values to choose from. Select the appropriate values. For Expansion, choose whichever one feels like a best fit.
- Leave 'DB Card Type 2' alone, and fill in the the rarity for the card. Choices show at the bottom of the editor.
- The 'Req ...' fields set up the casting cost for the card. Our card costs 1WR, so Req Colorless, Red, and White should all be 1. If this cost 2RW, then Req Colorless would be 2 instead, etc.
- Set 'Num Pics' to 1, since we only plan on adding 1 picture for this card.
- The next several fields give hints to the computer about how to use the card. Assuming we selected a card similar to the one we are building, these values can be left alone.
- 'AI Power/Toughness' should be set to a creature's power and toughness.
- Go all the way down to 'Exp Rarity'. If you want your card to show up in multiple sets for Sealed play, enter the appropriate sets here. Otherwise enter '0h'.
- Enter the 'Power' and 'Toughness' again for your creature.
- Skip down to the 'Subtype' and 'Subtype 2' fields. Use the dropdowns to enter your creature's tyes. Only 2 types are allowed, and if your creature is lenegdary, you must select that as one of your types. To blank a type out, chose '211'.
- Fill in your card's 'Type Text', 'Rules Text', and 'Flavor Text'. You can find the exact wording for these by looking them up on Gatherer.
- If your card has mana symbols in them, you need to use special syntax. 8 colorless mana is represented by |8, blue mana by |U, tap by |T, etc.
Add blank lines by adding \n.
If a basic land type appears in the text, precede it with |H1.
If a color word appears in the text, precede it with |S. - If necessary, update the rest of the text fields as necessary.
- Click 'Save Record'. You should be prompted 'Append Test Card'? Choose yes to save.
- Click the 'Save' icon in the upper left to save your changes to disk. Congratulations, you're half way there.
- Click on the 'Magic.exe' tab. Use the binoculars icon to search for the original card (Raging Goblin) by id.
- Doubleclick on Raging Goblin to update the right pane.
- Replace the name and ID with the information for your card.
- Update the 'Card Type', 'Card SubType', and 'Card Color' as appropriate. Remember that this card is white AND red.
- The card CC slots help the computer know when a card is available to cast. Generally, put the total colorless cost into 'Card CC 1', and the total colored cost into 'Card CC 2'. So we'd enter 1, and 2.
- Enter your card's power and toughness yet again.
- 'Code Pointer' tells the program where to find the code for your card's ability. Since we did not write any code, leave this alone.
- Use the dropdowns for the 'Static Abilities' to add on any of the "free" abilities to your creature. If you have done this correctly, you will see '20' (for flying) in static abilities 1.
- Leave 'Reserved information alone.
- Now for the odd part. Search for the card with the ID one less than your card's ID. Scroll down one more spot on the left and you should see 'Dummy'. Singleclick 'Dummy'.
- Click 'Save Record'. You should be prompted 'Overwrite Dummy'? Choose yes to save. After you do, your card's information should still be in the right pane.
- Click the 'Save' icon in the upper left to save your changes to disk.
- You are done with SkyMagic Editor. You can close it now if you want.
- In your Magic directory, run csv2dat.exe. A blank screen should flicker. As long as there was no error text on it, it worked.
- The last thing we need is an image for the card. You can get this from many sources, including Gatherer.
You can crop the image using MS Paint or another program.
Save the image in Magic/CardArtNew/ID.jpg, where ID the your card's ID. - Your card is created! Test it by running the magic program. To make testing easier, you can turn on debug mode in duels. Just fit F12, and then right-click for a whole bunch of great options.
- The last thing you'll want to do is share your card with the world. To do this, zip up the following files: Magic.exe, Manalink.csv, Cards.dat, and the image you created. Voila, you are a productive member of the slightymagic community.
Level 1 - Very Easy Mods
What is a level 1 card?
A "level 1" card is a card that can be added without really understanding anything about coding, other than a couple basics explained here.
To create level 1 cards, we will take existing cards and make very tiny tweaks. It is not always obvious when a card can be made with only level 1 tweaks. It really depends on how the original card was coded.
Prerequisites
- Be a master at creating Level 0 cards.
- Download the Olly debugger.
- Download the ExtraCopy Plugin for Olly.
Creating a Card
For this exercise, we will be creating the card Tidings. (yes, this card does already exist, so we'll actually create it with a new name)
- Follow all the steps you learned from the Level 0 Tutorial to create a card identical to Counsel of the Soratami, but with all the information for Tidings.
Your new card should be called Test Card, but behave exactly like Counsel. - In SkyMagic Editor, go to the Magic.exe tab and search for your card. Find the 'Code Pointer' section and click the '...'.
You are now in the (somewhat) scary View Assembler tab. -
Hilight all the code for the card you are copying. The code will always start at the top of the screen with the command
55 push ebp
It will end with
C3 retIn this case, the code takes up almost exactly one screen.
- With the code hilighted, click the leftmost icon, export patch. Save the patch as Counsel.skp.
- Next we need to find an empty space to put our new code. The easiest way of doing this is search for the last card created, and click its code pointer.
Scroll down to the end of that proc, and it should be followed by a bunch of
2020 and [eax], ah
- The first one of those is where we can put our code, so remember the address for that line. In the image below, the address we want is 004E0B7.
- Go back to your card in the Magic.exe tab and update you card's Code Pointer with this new value.
- Click 'Save Record'. You should be prompted 'Overwrite Test Card'? Choose yes to save.
- Click the 'Save' icon in the upper left to save your changes to disk.
- Click the '...' in the 'Code Pointer' section.
- Click the first line, and then click the 2nd icon, 'Import Patch'.
- Import Counsel.skp
- Click File -> Magic -> Save.
- Now is a good time to test your card in Magic.exe. Is should still only draw 2 cards.
Finally, it is time to update our card. We can do this either in Olly or in SkyMagic Editor. I'll explain both ways, starting with Olly.
Editing using Olly
- Start Olly and open Magic.exe. Ignore the warnings.
- Control-G to search by address. Find your card by the address you put in the 'Code Pointer' section of SkyMagic editor.
- Even if you don't know anything about the code, you know that Counsel had the word '2' in it. So scour the code for an isolated 2.
If you look carefully, you'll see this line:
6A02 push 2
- Double click that line, and change push 2 to push 4 (for 4 cards).
- You can test your changes by starting Debug Mode. Just press F9.
- Test out your card and voila! Tidings now draws you 4 cards.
You'll notice that if you use F12 to open debug mode in magic.exe, the screen will flip back to Olly. Just hit F9 again, and switch back to magic. Debug mode will be on. - To save your changes, hilight and sections of code you have changed. Right-click and choose Copy to Executable -> Selection.
- Close the new window, and choose 'Yes', and then save. You are done!
Note: You can only save your file as Magic.exe once. To save again, you'll need to either close and re-open Olly, or rename your file.
Editing using SkyMagic Editor
This is recommended for only the most trivial changes.
- Go back to viewing your code in the 'View Assembly' tab.
- Even if you don't know anything about the code, you know that Counsel had the word '2' in it. So scour the code for an isolated 2.
If you look carefully, you'll see this line:
6A02 push 0x00000002
- This editor will only let you update the ugly hex code (6A02), not the actual instruction. In this case, we can guess how to change the hex code.
Double click on that line and change 6A02 to 6A04.
The code should now be updated to
6A04 push 0x00000004
- Click File -> Magic -> Save.
- Test your changes by running the Magic.exe game. It works, you are done.
One more note about editing in SkyMagic. Open up the 'View Assembly' tab and click the funnel icon (Disasm). Type in 4DEB70 to jump to that line. You should see:
68A4050000 push 0x000005A4
Notice that the argument to push is 000005A4, but in the HEX code the numbers are jumbled. The first 2 digits are the instruction (in this case, push). After that, the number gets re-ordered, so 12345678 becomes 78563412. In this example, 000005A4 becomes A4050000.
