It is currently 16 Apr 2024, 09:51
   
Text Size

Adding already existing cards to Magic

MicroProse's Shandalar Campaign Game, now with new cards & a new look!

Moderators: BAgate, drool66, Aswan jaguar, gmzombie, stassy, CCGHQ Admins

Adding already existing cards to Magic

Postby Alatar » 25 Nov 2017, 15:49

Hi everyone,

I have the normal version of Microprose's Magic the Gathering (with Planeswalkers & Ancients).
I do not have Manalink 3.0 or 2.0 (and don't desire them). The problem I am describing is true on Windows XP, 7 and 10 (and most likely has nothing to do with the windows version at all).

I only want to add old cards like e.g. Stone Throwing Devils (I'll stick to this example from now on, simply calling them Devils). When I check e.g. the "Rarity" file in the games folder I can see that these old cards are actually listed with an ID, power, toughness etc. When I go to the "Playdeck" folder and edit one of the decks so that they have the Devils (by adding their ID), I can see in the Deck Editor that this card now appears in the deck, it has the right picture, card name, ability and everything. However, the deck from that moment on is no longer playable in a Duel mode (it doesn't show up in the deck selection).
When I edit the decks of all the creatures in the Shandalar World to have Devils (I edit them in the Folder "Decks", which normally works), the creatures don't appear anymore in the game. When I force them to appear by starting a quest to fight one of them, this enemy then appears, but when I approach him and the battle screen comes, the game just freezes.

So the old cards are basically present in the game and even show up in the Deck Editor when they are manually inserted into a deck. They are listed in the files, they have the artwork and abilities that they need (Devils just need first strike). But for some reason the game doesn't allow them to be present in a match.

I hope you guys can help me, because I really don't want any major changes to the game. I just want the cards that are already there to be included.

Thanks in advance for your help!
Alatar
 
Posts: 2
Joined: 25 Nov 2017, 15:29
Has thanked: 1 time
Been thanked: 0 time

Re: Adding already existing cards to Magic

Postby Korath » 25 Nov 2017, 20:44

Most of the values in that Rarity.csv file are only looked at when displaying cards and when building the AI deck in sealed-deck mode: even for game-relevant data like colors, power, and toughness, the real values that the game uses are stored somewhere else. The first column in Rarity.csv that's actually used is the set name - in particular, that tantalizing "Card Status" column, with "Yes"'s and "No"'s that almost exactly corresponds to cards in the game, is read but then ignored. The real values are stored directly in Shandalar.exe in an array we refer to as cards_data[]; there's a list of cards defined in cards_data[] here.

Simplifying a bit, cards need to be enabled in five places to be used in the game: file Cards1.dat; file Rarity.csv; a C function implementing the card in Shandalar.exe; cards_data[] in Shandalar.exe; and an array cards_coded[] containing a single bit for each card, also in Shandalar.exe. Each of these has somewhat fewer cards enabled than the previous.

cards_data[] was the main bottleneck that prevented expansion of Manalink past 2000 cards and Shandalar at all for so many years, since there isn't room to add any more data there. So if you don't want Manalink, the only option is to find cards that are in cards_data[] but aren't enabled in cards_coded[]. There's only two of them - Akron Legionnaire and, as you found, Stone-Throwing Devils.

In the version of Shandalar.exe that I've been working from, cards_coded[] starts at position 0x183d70 and looks like this:
Code: Select all
00183d70: ffe5 ef77 7fb5 bfce 7f3b feff 7ef7 3ffa  ...w.....;..~.?.
00183d80: ebd9 efff ffeb ffdf db37 ebf6 fbff fdaf  .........7......
00183d90: 79fa ffff ed90 0744 4200 9b0c 0031 08c1  y......DB....1..
00183da0: 109e 01b2 4a4a c230 4154 84c8 fbd5 d078  ....JJ.0AT.....x
00183db0: 8520 f10d ca00 0980 d021 0051 0055 1400  . .......!.Q.U..
00183dc0: 2402 6000 8000 000c 4080 0000 4122 1128  $.`.....@...A".(
00183dd0: 0160 000c 0824 0284 2802 d8f8 ff00 200c  .`...$..(..... .
00183de0: 1040 0000 8cca 0000 0000 0000 0000 0000  .@..............
00183df0: 001a 1000 804a 4031 8084 0100 8108 c004  .....J@1........
00183e00: 1426 1000 0014 0020 24c8 1409 0400 0250  .&..... $......P
00183e10: 8605 0000 0000 0000 0000 0000 0000 0000  ................
00183e20: 8061 fa4d b5b5 3dcd be89 7b37 042a 2787  .a.M..=...{7.*'.
00183e30: 5adf 0ef2 3500 0000 0000 0000 0000 0000  Z...5...........
00183e40: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00183e50: 0000 0000 0000 0000 0000 0000 0000 00d0  ................
00183e60: 0f00 0000 0000 0000 0000 0000 0000 0000  ................
00183e70: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00183e80: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00183e90: 0000 0000 104b 101a 1994 0442 0a00 c410  .....K.....B....
00183ea0: 2a00 0000 0000 0000 0000 0000 0000 0000  *...............
00183eb0: 0000 0000 0001 1220 0942 10a8 92a0 8008  ....... .B......
00183ec0: 8104 1428 2548 10e1 010a c005 8000 2880  ...(%H........(.
00183ed0: 4c00 0552 2000 0108 803c 0500 0000 8000  L..R ....<......
00183ee0: 0000 0000 0031 9900 0000 0000 0000 0000  .....1..........
00183ef0: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00183f00: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00183f10: 0000 0000 0004 8080 8403 0423 11c4 010a  ...........#....
00183f20: 0000 0000 0000 0000 0000 0000 0000 0000  ................
00183f30: 0000 0000 00b2 200b 0200 8802 090a 4072  ...... .......@r
00183f40: 5801 8293 1280 c702 9c00 0930 1a54 c003  X..........0.T..
00183f50: 008b f080 5753 7c02 0400 0205 0000 0000  ....WS|.........
00183f60: 0000 0000 1004 4401 0000 0000 0000 0000  ......D.........
00183f70: 4d55 4c54 4950 4c41 5945 5253 5452 494e  MULTIPLAYERSTRIN
00183f80: 4753 0000 4d50 5f55 4953 5452 494e 4753  GS..MP_UISTRINGS
The first 128 bytes - 8 lines above - are for cards enabled in the original release, the second 128 for cards in Spells of the Ancients, and the third 128 for cards in Duels of the Planeswalkers. The fourth 128 were apparently intended for a third expansion, and the last two lines aren't part of the array (obviously), but should be easier to search for if it's not at the same location in your executable.

Cards are stored in cards_data[] in the same order as in Cards1.dat/Rarity.csv (the order in cards_data[] is different). So, for example, the first two bytes, ffe5, set the status of the first sixteen cards in Rarity.csv in the original, unexpanded game:
Code: Select all
card name           bit    set
Air Elemental        1     yes
Ancestral Recall     2     yes
Animate Artifact     4     yes
Animate Dead         8     yes
Animate Wall        10     yes
Ankh of Mishra      20     yes
Armageddon          40     yes
Aspect of Wolf      80     yes
                    --
                    ff

Bad Moon             1     yes
Badlands             2     no
Balance              4     yes
Basalt Monolith      8     no
Bayou               10     no
Benalish Hero       20     yes
Berserk             40     yes
Birds of Paradise   80     yes
                    --
                    e5
(All three of those disabled cards are later enabled in the second expansion, which starts 001a.)

Stone-Throwing Devils is card number 461, and Akron Legionnaire is card number 558. That's bit 0x20 of cards_coded[57] (floor(461/8) = 57; 2^(461 mod 8 ) = 0x20) and bit 0x40 of cards_coded[69] (floor(558/8) = 69; 2^(558 mod 8 ) = 0x40).

It doesn't actually matter which expansion they're enabled in, so might as well do it in the original: assuming your executable stores cards_coded in the same place as mine, change the value at 0x183da9 (= 0x183d70 + 57) from 0x54 to 0x74, and the value at 0x183db5 (= 0x183d70 + 69) from 0x00 to 0x40. And then the Legionnaire and Devils should work.
User avatar
Korath
DEVELOPER
 
Posts: 3707
Joined: 02 Jun 2013, 05:57
Has thanked: 496 times
Been thanked: 1106 times

Re: Adding already existing cards to Magic

Postby Alatar » 25 Nov 2017, 22:54

Thanks a lot for the quick reply :)
If these two cards are all I would get, I guess I rather go for Manalink then.
By the way, I think you guys are doing a great job reviving this game. Thanks a lot for all your time investment.
Alatar
 
Posts: 2
Joined: 25 Nov 2017, 15:29
Has thanked: 1 time
Been thanked: 0 time

Re: Adding already existing cards to Magic

Postby lorfanti » 29 Jun 2020, 12:10

Hi guys,

thanks for the info. I have a question: How can I access to the file cards_data? Where can I find it?
Thank you.
lorfanti
 
Posts: 2
Joined: 29 Jun 2020, 11:58
Has thanked: 1 time
Been thanked: 0 time


Return to Shandalar

Who is online

Users browsing this forum: No registered users and 22 guests


Who is online

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

Login Form