Allow exclusion to work as a whitelist as well
That way only the models listed in it will be replaced with other models (e.g. only Kiryu)
This commit is contained in:
parent
32156b09bb
commit
3993a25e4f
@ -42,7 +42,14 @@ const randomModels = [
|
|||||||
//
|
//
|
||||||
// Example: If Kiryu's base model is found it will never be changed
|
// 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
|
// That means Kiryu can't be set to Daigo, but Daigo can still be set to Kiryu
|
||||||
const excludedModels = [];
|
// Can also work as a whitelist so only the models listed here will be replaced
|
||||||
|
const exclusions = {
|
||||||
|
isWhitelist: false,
|
||||||
|
models: [
|
||||||
|
[0x71, 0x08],
|
||||||
|
[0x72, 0x08],
|
||||||
|
],
|
||||||
|
};
|
||||||
|
|
||||||
// Blacklist to prevent models from appearing
|
// Blacklist to prevent models from appearing
|
||||||
// Can also act as a whitelist so *only* those models will appear
|
// Can also act as a whitelist so *only* those models will appear
|
||||||
@ -59,6 +66,6 @@ module.exports = {
|
|||||||
sameType,
|
sameType,
|
||||||
singleModel,
|
singleModel,
|
||||||
randomModels,
|
randomModels,
|
||||||
excludedModels,
|
exclusions,
|
||||||
blacklist,
|
blacklist,
|
||||||
};
|
};
|
||||||
|
70
index.js
70
index.js
@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
const fs = require("fs");
|
const fs = require("fs");
|
||||||
const _ = require("underscore");
|
const _ = require("underscore");
|
||||||
const { allTypes, shuffledModels } = require("./models");
|
const { _models, allTypes, shuffledModels } = require("./models");
|
||||||
|
|
||||||
if (!fs.existsSync("config.js")) {
|
if (!fs.existsSync("config.js")) {
|
||||||
fs.writeFileSync("config.js", fs.readFileSync("config.default.js"));
|
fs.writeFileSync("config.js", fs.readFileSync("config.default.js"));
|
||||||
@ -17,25 +17,25 @@ const {
|
|||||||
sameType,
|
sameType,
|
||||||
singleModel,
|
singleModel,
|
||||||
randomModels,
|
randomModels,
|
||||||
excludedModels,
|
exclusions,
|
||||||
blacklist,
|
blacklist,
|
||||||
} = require("./config");
|
} = require("./config");
|
||||||
|
|
||||||
// Check if a model is excluded from modification
|
// Check if a model is excluded from modification
|
||||||
function isModelExcluded(fb, sb) {
|
function isModelExcluded(fb, sb) {
|
||||||
for (let i = 0; i < excludedModels.length; i++) {
|
for (let i = 0; i < exclusions.models.length; i++) {
|
||||||
const model = excludedModels[i];
|
const model = exclusions.models[i];
|
||||||
|
|
||||||
if (
|
if (
|
||||||
(model[0] === fb && model[1] === -1) ||
|
(model[0] === fb && model[1] === -1) ||
|
||||||
(model[0] === -1 && model[1] === sb)
|
(model[0] === -1 && model[1] === sb)
|
||||||
) {
|
) {
|
||||||
return true;
|
return !exclusions.isWhitelist;
|
||||||
} else if (model[0] === fb && model[1] === sb) {
|
} else if (model[0] === fb && model[1] === sb) {
|
||||||
return true;
|
return !exclusions.isWhitelist;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return exclusions.isWhitelist;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if a model is blacklisted
|
// Check if a model is blacklisted
|
||||||
@ -58,49 +58,75 @@ function isModelBlacklisted(fb, sb) {
|
|||||||
function replaceModels(doReplace = true) {
|
function replaceModels(doReplace = true) {
|
||||||
const data = fs.readFileSync("original/character_character_data.bin.orig");
|
const data = fs.readFileSync("original/character_character_data.bin.orig");
|
||||||
|
|
||||||
|
let replaced = 0;
|
||||||
|
let excluded = 0;
|
||||||
|
|
||||||
if (doReplace) {
|
if (doReplace) {
|
||||||
// Magic
|
// Magic
|
||||||
if (mode === 0) {
|
if (mode === 0) {
|
||||||
for (let i = 0x16194; i < 0x18ea8; i += 4) {
|
for (let i = 0x16194; i < 0x18ea8; i += 4) {
|
||||||
if (isModelExcluded(data[i], data[i + 1])) continue;
|
if (isModelExcluded(data[i], data[i + 1])) {
|
||||||
|
excluded++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
data[i] = singleModel[0];
|
data[i] = singleModel[0];
|
||||||
data[i + 1] = singleModel[1];
|
data[i + 1] = singleModel[1];
|
||||||
|
replaced++;
|
||||||
}
|
}
|
||||||
} else if (mode === 1) {
|
} else if (mode === 1) {
|
||||||
for (let i = 0x16194; i < 0x18ea8; i += 4) {
|
for (let i = 0x16194; i < 0x18ea8; i += 4) {
|
||||||
if (isModelExcluded(data[i], data[i + 1])) continue;
|
if (isModelExcluded(data[i], data[i + 1])) {
|
||||||
|
excluded++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
const model = randomModels[_.random(randomModels.length - 1)];
|
const model = randomModels[_.random(randomModels.length - 1)];
|
||||||
|
|
||||||
data[i] = model[0];
|
data[i] = model[0];
|
||||||
data[i + 1] = model[1];
|
data[i + 1] = model[1];
|
||||||
|
replaced++;
|
||||||
}
|
}
|
||||||
} else if (mode === 2) {
|
} else if (mode === 2) {
|
||||||
for (let i = 0x16194; i < 0x18ea8; i += 4) {
|
for (let i = 0x16194; i < 0x18ea8; i += 4) {
|
||||||
const id = data[i];
|
const id = data[i];
|
||||||
const type = data[i + 1];
|
const type = data[i + 1];
|
||||||
|
|
||||||
if (isModelExcluded(id, type)) continue;
|
if (isModelExcluded(id, type)) {
|
||||||
|
excluded++;
|
||||||
const modelType = sameType
|
continue;
|
||||||
? 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;
|
if (sameType) {
|
||||||
data[i + 1] = type;
|
const models = shuffledModels[type];
|
||||||
|
|
||||||
|
let modelId = models[_.random(models.length - 1)];
|
||||||
|
|
||||||
|
while (isModelBlacklisted(modelId, type)) {
|
||||||
|
modelId = models[_.random(models.length - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
data[i] = modelId;
|
||||||
|
data[i + 1] = type;
|
||||||
|
} else {
|
||||||
|
let [modelId, modelType] = _models[_.random(_models.length - 1)];
|
||||||
|
|
||||||
|
while (isModelBlacklisted(modelId, modelType)) {
|
||||||
|
[modelId, modelType] = _models[_.random(_models.length - 1)];
|
||||||
|
}
|
||||||
|
|
||||||
|
data[i] = modelId;
|
||||||
|
data[i + 1] = modelType;
|
||||||
|
}
|
||||||
|
|
||||||
|
replaced++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// -----
|
// -----
|
||||||
}
|
}
|
||||||
|
|
||||||
|
console.log(`Replaced ${replaced} models - Excluded ${excluded}`);
|
||||||
|
|
||||||
fs.writeFileSync("output/character_character_data.bin", data);
|
fs.writeFileSync("output/character_character_data.bin", data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user