Log in

Coding FAQs

Q: Where would I find cards that are not in the /src/cards c files? I want to look at some other already exsisting cards in their raw c format. Take for instance Ancestrial recall where would I find it decompiled into raw c text? or how do I decompile it?

A: From the tutorial, you should know how to find the ASM code for any card. (look on the Magic.exe tab for the code pointer, and then click the '...' button to view the code.

There is also a version of Manalink 2.01 decompiled into C. It can be found here: http://www.savefile.com/files/2088274

To find the code for a specific card, search for the address of the code pointer. You'll find a sub with that name. That's the code. Of course, since decompiling saves no symbolic information, such as variable names, the code isn't always too helpful.

The .c file can be useful for figuring out where to inject code (injecting code). For example, there used to be a bug that the shock lands did not count as basic lands for Kird Ape, land walk, etc. This was strange, since the code for Template Garden was directly copied from the code for Savannah. So we suspected that there was some hard-coded id's of the dual lands somewhere else in the code. I searched the .c file for the ids of the dual lands, and found one sub that referred to the 10 id's, one after another. So I was able to look at the name of the sub that the code was in, and that name is the same as the address in Magic.exe. From there I was able to inject some code to also look for the ids of the shock lands.

Q: My C code is perfect, but the card doesn't work ! Why ?:
A: for some type of cards, the Reserved Infos field is vital, otherwise they will not work or crash the game. Check other similar cards and paste their Reserved Infos on your.
Also, for Regeneration and Indestructible, setting On "Instant Ability" from the "Extra Abilities" is required.

Plus, usually cards that employ the Rules Engine to work needs a specifical number to be putted on the "cc[2]" field of Magic.exe. Check Guide to Magic.exe editing fro more infos.