Add default config

It'll be copied to `config.js` if that file doesn't exist.
SHOULD NOT BE EDITED!
This commit is contained in:
Lordmau5 2020-05-21 15:16:28 +02:00
parent c6be5491d4
commit 25cde2a22e
4 changed files with 87 additions and 47 deletions

2
.gitignore vendored
View File

@ -1,5 +1,7 @@
# Custom
config.js
character_character_data.bin
character_model_model_data.bin
# ---> Node
# Logs

Binary file not shown.

View File

@ -3,7 +3,7 @@
// 0 = Everyone is one model (singleModel)
// 1 = Everyone has a random model from a list (randomModels)
// 2 = Everyone is a completely random model
const mode = 0;
const mode = 2;
// Should we try to make sure models are replaced
// with another one of the same "type"? (2nd byte)
@ -12,12 +12,29 @@ const sameType = false;
// Singular model to replace when mode is 0
//
// Example: [0x71, 0x08] for Kiryu
// const singleModel = [0x71, 0x08];
const singleModel = [0x71, 0x08];
// List of models to choose randomly from when mode is 1
const randomModels = [
[0x71, 0x08],
[0x72, 0x08],
[0x81, 0x08],
[0x75, 0x08],
[0x7d, 0x08],
[0x77, 0x08],
[0x7b, 0x08],
[0x7a, 0x08],
[0x78, 0x08],
[0x79, 0x08],
[0x73, 0x08],
[0x7f, 0x08],
[0x7e, 0x08],
[0x7c, 0x08],
[0x82, 0x08],
[0x76, 0x08],
[0x80, 0x08],
[0x83, 0x08],
];
// List of base models to exclude from modifications
@ -25,10 +42,7 @@ const randomModels = [
//
// Example: If Kiryu's base model is found it will never be changed
// That means Kiryu can't be set to Daigo, but Daigo can still be set to Kiryu
const excludedModels = [
[0xb6, 0x08],
[0xb3, 0x08],
];
const excludedModels = [];
// Blacklist to prevent models from appearing
// Can also act as a whitelist so *only* those models will appear

108
index.js
View File

@ -3,6 +3,11 @@
const fs = require("fs");
const _ = require("underscore");
const { allTypes, shuffledModels } = require("./models");
if (!fs.existsSync("config.js")) {
fs.writeFileSync("config.js", fs.readFileSync("config.default.js"));
}
const {
mode,
sameType,
@ -31,67 +36,86 @@ function isModelExcluded(fb, sb) {
// Check if a model is blacklisted
function isModelBlacklisted(fb, sb) {
for (let i = 0; i < blacklistedModels.length; i++) {
const model = blacklistedModels[i];
for (let i = 0; i < blacklist.models.length; i++) {
const model = blacklist.models[i];
if (
(model[0] === fb && model[1] === -1) ||
(model[0] === -1 && model[1] === sb)
) {
return blacklist.isWhitelist;
return !blacklist.isWhitelist;
} else if (model[0] === fb && model[1] === sb) {
return blacklist.isWhitelist;
return !blacklist.isWhitelist;
}
}
return !blacklist.isWhitelist;
return blacklist.isWhitelist;
}
function replaceModels() {
function replaceModels(doReplace = true) {
const data = fs.readFileSync("character_character_data.bin.orig");
// Magic
if (mode === 0) {
for (let i = 0x16194; i < 0x18ea8; i += 4) {
if (isModelExcluded(data[i], data[i + 1])) continue;
if (doReplace) {
// Magic
if (mode === 0) {
for (let i = 0x16194; i < 0x18ea8; i += 4) {
if (isModelExcluded(data[i], data[i + 1])) continue;
data[i] = singleModel[0];
data[i + 1] = singleModel[1];
}
} else if (mode === 1) {
for (let i = 0x16194; i < 0x18ea8; i += 4) {
if (isModelExcluded(data[i], data[i + 1])) continue;
const model = randomModels[_.random(randomModels.length - 1)];
data[i] = model[0];
data[i + 1] = model[1];
}
} else if (mode === 2) {
for (let i = 0x16194; i < 0x18ea8; i += 4) {
const id = data[i];
const type = data[i + 1];
if (isModelExcluded(id, type)) continue;
const modelType = sameType
? type
: allTypes[_.random(allTypes.length - 1)];
const models = shuffledModels[modelType];
let modelId = models[_.random(models.length - 1)];
while (isModelBlacklisted(modelId, type)) {
modelId = models[_.random(models.length - 1)];
data[i] = singleModel[0];
data[i + 1] = singleModel[1];
}
} else if (mode === 1) {
for (let i = 0x16194; i < 0x18ea8; i += 4) {
if (isModelExcluded(data[i], data[i + 1])) continue;
data[i] = modelId;
data[i + 1] = type;
const model = randomModels[_.random(randomModels.length - 1)];
data[i] = model[0];
data[i + 1] = model[1];
}
} else if (mode === 2) {
for (let i = 0x16194; i < 0x18ea8; i += 4) {
const id = data[i];
const type = data[i + 1];
if (isModelExcluded(id, type)) continue;
const modelType = sameType
? type
: allTypes[_.random(allTypes.length - 1)];
const models = shuffledModels[modelType];
let modelId = models[_.random(models.length - 1)];
while (isModelBlacklisted(modelId, type)) {
modelId = models[_.random(models.length - 1)];
}
data[i] = modelId;
data[i + 1] = type;
}
}
// -----
}
// -----
fs.writeFileSync("character_character_data.bin", data);
}
// TODO: Create a reverse-lookup map of some sort to fit the proper model height with other models?
// Only does scaling, so not that needed apparently...
function replaceHeights(doReplace = true) {
const data = fs.readFileSync("character_model_model_data.bin.orig");
if (doReplace) {
// Magic
for (let i = 0x23220; i < 0x24910; i += 2) {
data[i] = 0xb9;
data[i + 1] = 0x00;
}
// -----
}
fs.writeFileSync("character_model_model_data.bin", data);
}
replaceModels();
replaceHeights(false);