Add weeb sights to mechanic

Created Diff never expires
0 removals
207 lines
52 additions
259 lines
"use strict";
"use strict";


let mydb;
let mydb;


const mbus_sights = [
const mbus_sights = [
"sight_rear_all_magpul_mbus_anti",
"sight_rear_all_magpul_mbus_anti",
"sight_rear_all_magpul_mbus_gen2_anime",
"sight_rear_all_magpul_mbus_gen2_anime",
"sight_rear_all_magpul_mbus_gen2_anime2",
"sight_rear_all_magpul_mbus_gen2_anime2",
"sight_rear_all_magpul_mbus_gen2_anime3",
"sight_rear_all_magpul_mbus_gen2_anime3",
"sight_rear_all_magpul_mbus_gen2_anime3v2",
"sight_rear_all_magpul_mbus_gen2_anime3v2",
"sight_rear_all_magpul_mbus_gen2_anti2",
"sight_rear_all_magpul_mbus_gen2_anti2",
"sight_rear_all_magpul_mbus_gen2_ramrem",
"sight_rear_all_magpul_mbus_gen2_ramrem",
"sight_rear_all_magpul_mbus_gen2_fde_anime",
"sight_rear_all_magpul_mbus_gen2_fde_anime",
"sight_rear_all_magpul_mbus_gen2_fde_anime2",
"sight_rear_all_magpul_mbus_gen2_fde_anime2",
"sight_rear_all_magpul_mbus_gen2_fde_anime3",
"sight_rear_all_magpul_mbus_gen2_fde_anime3",
"sight_rear_all_magpul_mbus_gen2_fde_anime3v2",
"sight_rear_all_magpul_mbus_gen2_fde_anime3v2",
"sight_rear_all_magpul_mbus_gen2_fde_anti",
"sight_rear_all_magpul_mbus_gen2_fde_anti",
"sight_rear_all_magpul_mbus_gen2_fde_anti2",
"sight_rear_all_magpul_mbus_gen2_fde_anti2",
"sight_rear_all_magpul_mbus_gen2_fde_ramrem"
"sight_rear_all_magpul_mbus_gen2_fde_ramrem"
];
];


const sig_sights = [
const sig_sights = [
"sight_rear_all_sig_flip_up_anime",
"sight_rear_all_sig_flip_up_anime",
"sight_rear_all_sig_flip_up_anime2",
"sight_rear_all_sig_flip_up_anime2",
"sight_rear_all_sig_flip_up_anime3",
"sight_rear_all_sig_flip_up_anime3",
"sight_rear_all_sig_flip_up_anime3v2",
"sight_rear_all_sig_flip_up_anime3v2",
"sight_rear_all_sig_flip_up_anti",
"sight_rear_all_sig_flip_up_anti",
"sight_rear_all_sig_flip_up_anti2",
"sight_rear_all_sig_flip_up_anti2",
"sight_rear_all_sig_flip_up_ramrem"
"sight_rear_all_sig_flip_up_ramrem"
];
];


class Mod {
class Mod {
load(container) {
load(container) {
const Logger = container.resolve("WinstonLogger");
const Logger = container.resolve("WinstonLogger");
const jsonUtil = container.resolve("JsonUtil");
const jsonUtil = container.resolve("JsonUtil");
const modLoader = container.resolve("InitialModLoader");
const modLoader = container.resolve("InitialModLoader");
const customItemService = container.resolve("CustomItemService");
const customItemService = container.resolve("CustomItemService");
const customHandbookItemService = container.resolve("CustomHandbookItemService");
const customHandbookItemService = container.resolve("CustomHandbookItemService");
const databaseImporter = container.resolve("DatabaseImporter");
const databaseImporter = container.resolve("DatabaseImporter");
const customTraderAssortService = container.resolve("CustomTraderAssortService");


Logger.info("Loading: Weeb Sights");
Logger.info("Loading: Weeb Sights");


mydb = databaseImporter.loadRecursive(`${modLoader.getModPath("zSamSWAT-WeebSights")}database/`);
mydb = databaseImporter.loadRecursive(`${modLoader.getModPath("zSamSWAT-WeebSights")}database/`);
let newAssortList = {
"traderId": "5a7c2eca46aef81a7ca2145d",
"assorts": {
"items": [],
"barter_scheme": {},
"loyal_level_items": {}
}
};


for (const sight of mbus_sights) {
for (const sight of mbus_sights) {
let weebsight = jsonUtil.clone(mydb.templates.items["sight_rear_all_magpul_mbus_anti"]);
let weebsight = jsonUtil.clone(mydb.templates.items["sight_rear_all_magpul_mbus_anti"]);
weebsight._id = sight;
weebsight._id = sight;
weebsight._name = sight;
weebsight._name = sight;
weebsight._props.Prefab.path = "assets/content/items/mods/sights rear/".concat(sight, ".bundle");
weebsight._props.Prefab.path = "assets/content/items/mods/sights rear/".concat(sight, ".bundle");


let handbookItem = jsonUtil.clone(mydb.templates.handbook.Items[0]);
let handbookItem = jsonUtil.clone(mydb.templates.handbook.Items[0]);
handbookItem.Id = sight;
handbookItem.Id = sight;
newAssortList["assorts"]["items"].push({
"_id": sight,
"_tpl": sight,
"parentId": "hideout",
"slotId": "hideout",
"upd": {
"UnlimitedCount": true,
"StackObjectsCount": 999999999
}
});
newAssortList["assorts"]["barter_scheme"][sight] = [
[
{
"count": 4000,
"_tpl": "5449016a4bdc2d6f028b456f"
}
]
];
newAssortList["assorts"]["loyal_level_items"][sight] = 1;


customItemService.add(weebsight);
customItemService.add(weebsight);
customHandbookItemService.add(handbookItem);
customHandbookItemService.add(handbookItem);
}
}


for (const sigsight of sig_sights) {
for (const sigsight of sig_sights) {
let weebsight = jsonUtil.clone(mydb.templates.items["sight_rear_all_sig_flip_up_anime"]);
let weebsight = jsonUtil.clone(mydb.templates.items["sight_rear_all_sig_flip_up_anime"]);
weebsight._id = sigsight;
weebsight._id = sigsight;
weebsight._name = sigsight;
weebsight._name = sigsight;
weebsight._props.Prefab.path = "assets/content/items/mods/sights rear/".concat(sigsight, ".bundle");
weebsight._props.Prefab.path = "assets/content/items/mods/sights rear/".concat(sigsight, ".bundle");


let handbookItem = jsonUtil.clone(mydb.templates.handbook.Items[1]);
let handbookItem = jsonUtil.clone(mydb.templates.handbook.Items[1]);
handbookItem.Id = sigsight;
handbookItem.Id = sigsight;
newAssortList["assorts"]["items"].push({
"_id": sigsight,
"_tpl": sigsight,
"parentId": "hideout",
"slotId": "hideout",
"upd": {
"UnlimitedCount": true,
"StackObjectsCount": 999999999
}
});
newAssortList["assorts"]["barter_scheme"][sigsight] = [
[
{
"count": 2500,
"_tpl": "5449016a4bdc2d6f028b456f"
}
]
];
newAssortList["assorts"]["loyal_level_items"][sigsight] = 1;


customItemService.add(weebsight);
customItemService.add(weebsight);
customHandbookItemService.add(handbookItem);
customHandbookItemService.add(handbookItem);
}
}
customTraderAssortService.add(newAssortList);
}
}


delayedLoad(container) {
delayedLoad(container) {


const db = container.resolve("DatabaseServer").getTables();
const db = container.resolve("DatabaseServer").getTables();
const locales = db.locales.global;
const locales = db.locales.global;


Mod.addToFilters(db);
Mod.addToFilters(db);


for (const localeID in locales) {
for (const localeID in locales) {
locales[localeID].templates["sight_rear_all_magpul_mbus_anti"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_anti"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight [Anti]",
"Name": "Magpul MBUS Gen2 rear flip-up sight [Anti]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Your personal waifu giving her neko love to support you in combat."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Your personal waifu giving her neko love to support you in combat."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight [Ai Fuyuumi]",
"Name": "Magpul MBUS Gen2 rear flip-up sight [Ai Fuyuumi]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime2"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime2"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight [GF M4 SOPMOD II]",
"Name": "Magpul MBUS Gen2 rear flip-up sight [GF M4 SOPMOD II]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime3"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime3"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight [Animu 3]",
"Name": "Magpul MBUS Gen2 rear flip-up sight [Animu 3]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime3v2"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anime3v2"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight [Animu 3 v2]",
"Name": "Magpul MBUS Gen2 rear flip-up sight [Animu 3 v2]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anti2"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_anti2"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight [Anti 2]",
"Name": "Magpul MBUS Gen2 rear flip-up sight [Anti 2]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. The personal sight used by Anti, the war Neko! Nya!!"
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. The personal sight used by Anti, the war Neko! Nya!!"
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_ramrem"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_ramrem"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight [Ram & Rem]",
"Name": "Magpul MBUS Gen2 rear flip-up sight [Ram & Rem]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Ai Fuyuumi]",
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Ai Fuyuumi]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime2"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime2"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [GF M4 SOPMOD II]",
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [GF M4 SOPMOD II]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime3"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime3"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Animu 3]",
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Animu 3]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime3v2"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anime3v2"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Animu 3 v2]",
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Animu 3 v2]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anti"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anti"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Anti]",
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Anti]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color. Your personal waifu giving her neko love to support you in combat."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color. Your personal waifu giving her neko love to support you in combat."
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anti2"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_anti2"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Anti 2]",
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Anti 2]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color. The personal sight used by Anti, the war Neko! Nya!!"
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color. The personal sight used by Anti, the war Neko! Nya!!"
};
};
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_ramrem"] = {
locales[localeID].templates["sight_rear_all_magpul_mbus_gen2_fde_ramrem"] = {
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Ram & Rem]",
"Name": "Magpul MBUS Gen2 rear flip-up sight (FDE) [Ram & Rem]",
"ShortName": "MBUS RS",
"ShortName": "MBUS RS",
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
"Description": "Removable flip-up rear sight MBUS Gen2, installed on the mount. Manufactured by Magpul. Flat Dark Earth color."
};
};


locales[localeID].templates["sight_rear_all_sig_flip_up_anime"] = {
locales[localeID].templates["sight_rear_all_sig_flip_up_anime"] = {
"Name": "MCX flip-up rear sight [Ai Fuyuumi]",
"Name": "MCX flip-up rear sight [Ai Fuyuumi]",
"ShortName": "MCX RS",
"ShortName": "MCX RS",
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
};
};
locales[localeID].templates["sight_rear_all_sig_flip_up_anime2"] = {
locales[localeID].templates["sight_rear_all_sig_flip_up_anime2"] = {
"Name": "MCX flip-up rear sight [GF M4 SOPMOD II]",
"Name": "MCX flip-up rear sight [GF M4 SOPMOD II]",
"ShortName": "MCX RS",
"ShortName": "MCX RS",
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
};
};
locales[localeID].templates["sight_rear_all_sig_flip_up_anime3"] = {
locales[localeID].templates["sight_rear_all_sig_flip_up_anime3"] = {
"Name": "MCX flip-up rear sight [Animu 3]",
"Name": "MCX flip-up rear sight [Animu 3]",
"ShortName": "MCX RS",
"ShortName": "MCX RS",
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
};
};
locales[localeID].templates["sight_rear_all_sig_flip_up_anime3v2"] = {
locales[localeID].templates["sight_rear_all_sig_flip_up_anime3v2"] = {
"Name": "MCX flip-up rear sight [Animu 3 v2]",
"Name": "MCX flip-up rear sight [Animu 3 v2]",
"ShortName": "MCX RS",
"ShortName": "MCX RS",
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
};
};
locales[localeID].templates["sight_rear_all_sig_flip_up_anti"] = {
locales[localeID].templates["sight_rear_all_sig_flip_up_anti"] = {
"Name": "MCX flip-up rear sight [Anti]",
"Name": "MCX flip-up rear sight [Anti]",
"ShortName": "MCX RS",
"ShortName": "MCX RS",
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer. Your personal waifu giving her neko love to support you in combat."
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer. Your personal waifu giving her neko love to support you in combat."
};
};
locales[localeID].templates["sight_rear_all_sig_flip_up_anti2"] = {
locales[localeID].templates["sight_rear_all_sig_flip_up_anti2"] = {
"Name": "MCX flip-up rear sight [Anti 2]",
"Name": "MCX flip-up rear sight [Anti 2]",
"ShortName": "MCX RS",
"ShortName": "MCX RS",
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer. The personal sight used by Anti, the war Neko! Nya!!"
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer. The personal sight used by Anti, the war Neko! Nya!!"
};
};
locales[localeID].templates["sight_rear_all_sig_flip_up_ramrem"] = {
locales[localeID].templates["sight_rear_all_sig_flip_up_ramrem"] = {
"Name": "MCX flip-up rear sight [Ram & Rem]",
"Name": "MCX flip-up rear sight [Ram & Rem]",
"ShortName": "MCX RS",
"ShortName": "MCX RS",
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
"Description": "Removable flip-up rear sight for MCX assault rifles, manufactured by SIG Sauer."
};
};
}
}
}
}


static addToFilters(db) {
static addToFilters(db) {
const isModFilterExist = (slots) => slots.findIndex((slot) => slot._name === "mod_sight_rear");
const isModFilterExist = (slots) => slots.findIndex((slot) => slot._name === "mod_sight_rear");
const isItemSlotsExist = (item) => item._props.Slots && item._props.Slots.length > 0;
const isItemSlotsExist = (item) => item._props.Slots && item._props.Slots.length > 0;
const filtersIncludeAttachment = (filterArray) => filterArray.includes("5bc09a18d4351e003562b68e");
const filtersIncludeAttachment = (filterArray) => filterArray.includes("5bc09a18d4351e003562b68e");
const combinedarray = mbus_sights.concat(sig_sights);
const combinedarray = mbus_sights.concat(sig_sights);
for (const item of Object.values(db.templates.items)) {
for (const item of Object.values(db.templates.items)) {
if (isItemSlotsExist(item)) {
if (isItemSlotsExist(item)) {
const index = isModFilterExist(item._props.Slots);
const index = isModFilterExist(item._props.Slots);
if (index > -1 && filtersIncludeAttachment(item._props.Slots[index]._props.filters[0].Filter)) {
if (index > -1 && filtersIncludeAttachment(item._props.Slots[index]._props.filters[0].Filter)) {
for (const sight of combinedarray) {
for (const sight of combinedarray) {
item._props.Slots[index]._props.filters[0].Filter.push(sight);
item._props.Slots[index]._props.filters[0].Filter.push(sight);
}
}
}
}
}
}
}
}
}
}
}
}


module.exports = { mod: new Mod() }
module.exports = { mod: new Mod() }