Adding cards to Rance X

This tutorial will demonstrate how to add a new card to Rance X with a custom CG and skills.

Setting up the project

Start by downloading this .zip file which contains the code templates and directory structure for this mod project, plus a few scripts to automate the build process. Extract the .zip file somewhere, and then copy the files Rance10.ain and Rance10EX.ex from your game directory into the project directory (the same directory as the file extract.bat). Then double click extract.bat to dump the contents of the .ex file into the ex directory (on *nix, run the script extract.sh instead).

Card CGs

Inside of the png directory you’ll find an image file named カード/akuji.png which will be used for our card. You can add more images into this folder to use for additional cards, just make sure that the images have the same dimensions as カード/akuji.png and that the name begins with the カード/ prefix.

Adding a new card

Open the file ex/8_カードデータ.x in a text editor. The first line in the table gives the names and types of the columns (formatted vertically here for readability):

{
    indexed string Id,      // unique ID for the card, and the name that appears in game
    string 識別名,          // the character's name
    string CG名,          // name of the CG *without* the "カード/" prefix
    int 所属,               // the faction the card belongs to
    int 属性,               // attribute (fire, ice, etc.)
    int 性別,               // gender (1 = male, 2 = female)
    int スキル1,           // ID of the first skill
    int スキル2,           // ID of the second skill
    int HP,               // hit points
    int ATK,             // attack
    int 種別,               // ?
    string 詳細CG,        // CG to use for details page (when you first get the card)
    int イベント種別,       // ?
    int 大人子供,           // adult or child (adult = 0, child = 1)
    int 裸,                 // nude (0 = normal, 2 = nude)
    int SR,               // card rarity?
    int 削除,               // ?
    int 発生,               // ?
    int 情報時カード表示,   // ?
    int 割り込みバトル倍率, // ?
    int 必殺連撃効果        // ?
},

To add a new card, we need to add a new row to this table. In this tutorial, we’re going to add a card to the JAPAN faction with the same stats as the default Rance card and (superficially) different skills. So we copy the line beginning with “Lv42 ランス” and change it like so:

{ "Lv42 ランス",    "ランス", "ランス/基本", 1, 0, 1, 1004, 1008, 50, 42, 0, "立ち/ランス/基本", 0, 0, 0, 87, 0, 1, 0, 2, 0 },
{ "Yamamoto Akuji", "Akuji",  "akuji",        6, 0, 1, 2500, 2501, 50, 42, 0, "",                   0, 0, 0, 87, 0, 1, 0, 2, 0 },

Adding new skills

Open the file 11_スキルデータ.x. This file contains a table with the data for every skill in the game. We will be adding two new rows by copying the skills used by the default Rance card:

{ 1004, "突撃-零-",     1, 3, "", 0, 100, 1, 100, 0, 0, 0, 0, "", 0, 0, "攻撃(1倍)" },
{ 2500, "Akuji Kick",     1, 3, "", 0, 100, 1, 100, 0, 0, 0, 0, "", 0, 0, "攻撃(1倍)" },
{ 1008, "ランスアタック", 1, 3, "", 3, 100, 1, 300, 7, 0, 0, 0, "", 1, 0, "攻撃(3倍)r 必中" },
{ 2501, "Akuji Punch",    1, 3, "", 3, 100, 1, 300, 7, 0, 0, 0, "", 1, 0, "攻撃(3倍)r 必中" },

Note that the numbers 2500 and 2501 match the numbers that we used in the row for our new card above. Other than that nothing has been changed about these skills.

Giving the player the new card

In the file mod.jaf you’ll find the following code,

override void T初期化1(void)
{
    T味方カード生成("Yamamoto Akuji");
    super();
}

This gives our new card to the player at the start of the game. For testing purposes, this is useful but you’ll probably want to remove this in a real mod.

Adding the card to the gacha pool

Getting the card to show up in chests is a bit more complicated, but I’ve already done the hard part for you. If you open up the file mod.jam, towards the bottom you’ll find the following code,

;; MOD STARTS HERE
    PUSHLOCALPAGE
    PUSH 8
    .LOCALREF カードBOX
    .LOCALREF aa
    .LOCALREF fg
    CALLFUNC gacha_add_extra_cards
    ASSIGN
    POP
;; MOD ENDS HERE

This calls the function gacha_add_extra_cards (defined in mod.jaf), passing a reference to the array カードBOX (the gacha pool) so that we can write the code to add our card to the pool in a high level language. In mod.jaf you’ll find the following definition,

int gacha_add_extra_cards(ref array<string> cards, int nr_cards, int fg)
{
    string v;

    v = "Yamamoto Akuji";
    if (TA7(10, fg, v, "", "", 0) == 1) {
        nr_cards++;
        cards[nr_cards] = v;
    }

    return nr_cards;
}

The chunk of code in the middle of the function can be copy+pasted for each card you want to add to the pool. Just make sure to change the arguments to the TA7 function to suit the card.

TA7 arguments

The function TA7 has the following prototype:

int TA7(int ▲ランク, int ▲箱, string v, string 識別名, string 条件, int ▲フラグ)

Rebuilding the files

Double click the file build.bat to build the project (on *nix, run the script build.sh instead). This will create 3 files in the out directory,

out/Rance10.ain
out/Rance10CGmod.afa
out/Rance10EX.ex

Copy these files into your game directory to install the mod.

End

That’s it. If you launch the game and start a new game, you should find your Akuji card in the JAPAN faction.