#binary-file #command-line-tool #sc #supercell #brawlstars #file-format #clashofclans

bin+lib sc_extract

A command-line tool to extract graphics and csv files from Supercell games

8 releases (4 stable)

1.1.0 May 8, 2021
1.0.2 Sep 4, 2020
1.0.1 Aug 25, 2020
0.2.0 Jul 27, 2020
0.1.1 Jun 6, 2020

#1820 in Command line utilities

MIT license

68KB
1K SLoC

sc_extract

build badge release badge crates.io badge license badge rust 2018 badge

sc_extract is a very fast tool to extract graphics and decode csv files from Supercell's game files.

This tool is simply intended to get high quality graphics and data from the files. It is in no way an attempt to:

  • modify the game in any way
  • create a clone or any other game based on any of Supercell's games
  • make profit

Features

Some of sc_extract's features include:

  • very fast speed (upto 10 times faster than Python tools)
  • precompiled binaries for multiple operating systems (Linux, macOS, Windows)
  • multiple file formats support
  • very extensive command line support

sc_extract can extract/process the following files found in Supercell's games:

  • _tex.sc
  • .csv
  • .sc files extracted from QuickBMS

sc_extract is a standalone tool (binary name sce ) but provides a simple Rust crate with a clean API allowing developers to implement their own tools with minimal work.

About The Tool

This tool is a Rust implementation of these scripts:

  • cr-sc-dump: tex_sc and csv extraction
  • sc_decode: extraction of individual images from tex_sc sprites

The Python implementations take a long time to extract images from huge files. sc_extract can extract data very quickly. Some comparisons are as below:

  • To extract all _tex.sc sprites from Brawl Stars' version 27.269, sc_extract takes less than 20 seconds whereas cr-sc-dump takes over 4 minutes

  • To extract all individual images from ui file of Brawl Stars' version 27.269, sc_extract takes about 2.5 minutes whereas sc_decode takes over 10 minutes.

Note: The times were tested on a MacBook Air with 1.8 GHz Dual-Core Intel Core i5 processor and 8 GB of RAM. They may wary on your machine.

The time sc_extract takes can be further reduced by using the parallelize flag.

Installation

sc_extract can be installed in three ways. The first method is the fastest and does not require you to install Rust. Second and third methods require you to install Rust's 2018 version. Rust is available for a large number of operating systems. Clicking on the above link above will take you to Rust's installation page.

You can find precompiled binaries for multiple operating systems and architectures here.

Download the binary which is appropriate for your machine. After downloading, unzip the folder. You should see the following three files inside:

  • sce (or sce.exe on Windows)
  • README.md
  • LICENSE

Now, cd into this directory and follow steps described here to use it!

Using cargo install

sc_extract is available on crates.io. You can install and build this tool by simply using cargo install sc_extract command from the terminal. The installation process will take a few minutes to build all dependencies, but once that's done, the tool will work very, very fast.

It will also add this tool to the shell path automatically, allowing you to use the tool from any directory.

Building From Source

You can download this tool's source code and build it yourself by using cargo build --release command. You need to cd into this tool's directory before executing that command. Do not forgot the --release flag or your tool will work very slowly.

Note: In the below example commands, it will be assumed that you have installed the tool using first or second method. If you installed from the source, you will have to replace sce with cargo run --release in all commands. The binary name of previous versions of sc_extract was sc_extract , so if you have an old version, you'd have to use sc_extract as the name.

Usage

Note 1: You may need to replace sce by ./sce , sce.exe , sc_extract or cargo run --release in the commands below.

Note 2: Extracted sc will be used to denote .sc files extracted using QuickBMS in the following section(s). Extracted sc files have no extension, they appear as ui , loading , etc.

You will need the _tex.sc , extracted sc or .csv files of the Supercell game you wish to extract. You can get the files by downloading the APK of the game, changing the extension to .zip , unzipping it and navigating to /assets/sc (_tex.sc files), /assets/csv_logic (csv files) or csv_client (csv files) folder inside the unzipped folder. To get extracted sc files, see this section.

After installing this tool, cd into the directory with the tool (not required if you add it to your path or use the second method).

cd path_to_sce

Then, simply use the following command to extract the required files!

sce [FLAGS] [OPTIONS] [path]

path must be a valid path pointing to a single _tex.sc , extracted sc or .csv file or a directory containing those files. See Flags and Options section to know more about them.

If path is not given, the current directory is used as the path.

If you installed the tool using the source code, you may want to build the tool and all the dependencies prior to extracting the files. You can do so by run the cargo build --release command in the tool's directory. Building will take a couple of minutes, but running the tool in future will be very fast.

Flags and Options

The following optional flags and options can be specified to control the extraction. You might be required to specify the png option (see below) to extract images from extracted sc files.

Flags Short Description
--delete -d Deletes source files after extracting
--parallelize -p Extracts files in parallel, making the process faster
--disable-filter -F Disables filtering of common error-prone files like quickbms and .DS_Store
--help -h Prints help information
--version -V Prints version information
Options Short Description out_path
--out -o Specifies the output directory. If not specified, a directory named extracts is created in path . out-path must be a valid path-like string.
--png -P The path to directory where a _tex.sc file's extracted images are stored. It is required for cutting images using extracted .sc files. If the path is not specified, sc_extract will look for the png files in the directory where the source (extracted sc ) file(s) is/are present. png-dir must be a valid path-like string.
--type -t Specifies the type of files you want to extract. By default, all types are considered. kind can be one of "csv", "sc" and "tex" (without double quotes).

Example Commands:

sce ./sc -F

The above command uses ./sc as the source directory. It goes over all files in the directory one-by-one and extracts all valid files. The output is saved in ./sc/extracts directory. It does not ignore files like quickbms and .DS_Store because of the -F flag.

sce --delete -p ./sc --out ./extracts

The above command uses ./sc as the source directory. It goes over all files in the directory parallelly and extracts all valid files. The output is saved in ./extracts directory. png flag is not supplied, so it looks for sprites extracted from _tex.sc in ./sc . It will fail to cut images from extracted sc files if ./sc directory will not contain the sprites. The rest of extraction will not be affected. After extracting, all valid _tex.sc and .csv and extracted sc (with png images) files are deleted.

sce -p ./sc --out ./sc_out -t sc --png ./sc/extracts

The above command uses ./sc as the source directory. It goes over all files in the directory parallelly and cuts images using all valid extracted sc files. The output is saved in ./sc_out directory. The png files used for extraction as searched for in ./sc/extracts directory.

Using QuickBMS To Extract .sc Files

QuickBMS is required to extract .sc files. You will also need clash_royale.bms. QuickBMS can be downloaded for macOS here.

Copy QuickBMS and clash_royale.bms into the directory with .sc files (not _tex.sc ) and then run this command:

find . -not -name '*_tex.sc' -name '*.sc' -exec ./quickbms ./clash_royale.bms {} \;

You will have to adjust this command as appropriate if you are using Windows.

Running the command will create a new file for each .sc file in the folder. These files will have the same name as their corresponding .sc files but no extension. These are referred to as extracted sc files and are used to cut the sprites.

Updating

If you used a pre-compiled binary, you'll simply have to download a new binary for the newer version from the Releases page.

If you installed the tool using cargo install , you can update the tool by simply reusing the cargo install sc_extract command. If it fails to update the tool, you can force it by adding the --force flag, like so: cargo install sc_extract --force .

If you installed using the source code, you will have to repeat the process described in Building From Source section using the new source code.

License

sc_extract is available under the MIT license. See LICENSE for more details.

Credits

This tool wouldn't exist if the following didn't create the original Python scripts.

Dependencies

~16–27MB
~336K SLoC