GithubHelp home page GithubHelp logo

milanmaldini / sc-tools Goto Github PK

View Code? Open in Web Editor NEW

This project forked from jeanbmar/sc-tools

0.0 0.0 0.0 129 KB

A tool to unpack, repack, edit and play 2d animations from Supercell games

License: MIT License

JavaScript 99.56% GLSL 0.44%

sc-tools's Introduction

SC Tools

This module is intended to unpack, edit and repack .sc files from Supercell games.

SC files are unpacked to disk as projects. Projects contain textures and readable configuration files. These files can be edited, and a new SC file can be repacked from a project at anytime.

For a better understanding of SC file structures, look at the files in the lib/supercell-sc directory.

This tool has been successfully tested on Brawl Stars assets from Q1 2022.

Todo:

  • Add engine web example
  • Check sc compression perf

Recipes

Unpack SC File(s) to Project(s)

import { basename, join } from 'path';
import glob from 'glob';
import { unpack } from '@ultrapowa/sc-tools';

const sourcePattern = 'path/to/apk/assets/e30a1e4a93c76bea755877299ebebf535e1b3d73/sc/*.sc';
const projectDir = 'path/to/local/workspace/brawl-stars-33.127';

const files = glob.sync(sourcePattern)
  .filter((filePath) => !filePath.includes('_tex.sc')); // those will be processed within the regular .sc files

for (const filePath of files) {
  const projectName = basename(filePath, '.sc');
  await unpack(filePath, join(projectDir, projectName), {
    shapeOuterColor: { // remove this options for total transparency
      red: 0, green: 255, blue: 0, alpha: 255,
    },
  });
}

Pack Project to SC File

import { pack } from '@ultrapowa/sc-tools';

await pack('path/to/local/workspace/clash-royale/spell_goblin_barrel');

Extract SC File Shapes as PNG Images

import { basename, join } from 'path';
import glob from 'glob';
import { unpack, buildPngShapes } from '@ultrapowa/sc-tools';

const sourcePattern = 'path/to/apk/**/*.sc';
const projectDir = 'path/to/local/workspace/brawl-stars-38.111';

const files = glob.sync(sourcePattern)
  .filter((filePath) => !filePath.includes('_tex.sc')); // those will be processed within the regular .sc files

for (const filePath of files) {
  const projectName = basename(filePath, '.sc');
  const projectDirectory = join(projectDir, projectName);
  await unpack(filePath, projectDirectory, { flattenShapes: true });
  await buildPngShapes(projectDirectory); // still sync
}

Export Movie Clips to Render in a Browser

This part of the code is not migrated yet.

import path from 'path';
import { exportMovieClips } from '@ultrapowa/sc-tools';

const filePath = 'path/to/apk/assets/e30a1e4a93c76bea755877299ebebf535e1b3d73/sc/level.sc'; 
const outputDir = 'path/to/workspace/rendering';

await exportMovieClips(filePath, outputDir);

sc-tools's People

Contributors

jeanbmar avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.