Mod init
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"_id": "gunsmith",
|
||||
"working": true,
|
||||
"availableInRaid": false,
|
||||
"items_buy": {
|
||||
"id_list": [],
|
||||
"category": ["54009119af1c881c07000029"]
|
||||
},
|
||||
"items_buy_prohibited": {
|
||||
"id_list": [],
|
||||
"category": ["5795f317245977243854e041", "543be5dd4bdc2deb348b4569"]
|
||||
},
|
||||
"customization_seller": false,
|
||||
"name": "gunsmith",
|
||||
"surname": " ",
|
||||
"nickname": "gunsmith",
|
||||
"location": " ",
|
||||
"avatar": "/files/trader/avatar/gunsmith.jpg",
|
||||
"balance_rub": 50000000,
|
||||
"balance_dol": 0,
|
||||
"balance_eur": 0,
|
||||
"unlockedByDefault": true,
|
||||
"discount": 0,
|
||||
"discount_end": 0,
|
||||
"buyer_up": true,
|
||||
"currency": "RUB",
|
||||
"nextResupply": 1615141448,
|
||||
"repair": {
|
||||
"availability": false,
|
||||
"quality": "0",
|
||||
"excluded_id_list": [],
|
||||
"excluded_category": [],
|
||||
"currency": "5449016a4bdc2d6f028b456f",
|
||||
"currency_coefficient": 1,
|
||||
"price_rate": 1
|
||||
},
|
||||
"insurance": {
|
||||
"availability": false,
|
||||
"min_payment": 0,
|
||||
"min_return_hour": 0,
|
||||
"max_return_hour": 0,
|
||||
"max_storage_time": 99,
|
||||
"excluded_category": []
|
||||
},
|
||||
"gridHeight": 300,
|
||||
"loyaltyLevels": [
|
||||
{
|
||||
"minLevel": 1,
|
||||
"minSalesSum": 0,
|
||||
"minStanding": 0,
|
||||
"buy_price_coef": 50,
|
||||
"repair_price_coef": 150,
|
||||
"insurance_price_coef": 10,
|
||||
"exchange_price_coef": 0,
|
||||
"heal_price_coef": 0
|
||||
}
|
||||
],
|
||||
"sell_category": []
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
{
|
||||
"name": "gunsmith",
|
||||
"version": "2.0.7",
|
||||
"main": "src/mod.js",
|
||||
"license": "MIT",
|
||||
"author": "Alex",
|
||||
"akiVersion": "3.8.x",
|
||||
"isBundleMod": false,
|
||||
"loadBefore": [],
|
||||
"loadAfter": [],
|
||||
"incompatibilities": [],
|
||||
"contributors": [
|
||||
"CilginDalgic"
|
||||
],
|
||||
"scripts": {},
|
||||
"devDependencies": {}
|
||||
}
|
||||
Binary file not shown.
|
After Width: | Height: | Size: 166 KiB |
@@ -0,0 +1,149 @@
|
||||
"use strict";
|
||||
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
var desc = Object.getOwnPropertyDescriptor(m, k);
|
||||
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
||||
desc = { enumerable: true, get: function() { return m[k]; } };
|
||||
}
|
||||
Object.defineProperty(o, k2, desc);
|
||||
}) : (function(o, m, k, k2) {
|
||||
if (k2 === undefined) k2 = k;
|
||||
o[k2] = m[k];
|
||||
}));
|
||||
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
||||
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
||||
}) : function(o, v) {
|
||||
o["default"] = v;
|
||||
});
|
||||
var __importStar = (this && this.__importStar) || function (mod) {
|
||||
if (mod && mod.__esModule) return mod;
|
||||
var result = {};
|
||||
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
||||
__setModuleDefault(result, mod);
|
||||
return result;
|
||||
};
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
const ConfigTypes_1 = require("/snapshot/project/obj/models/enums/ConfigTypes");
|
||||
// New trader settings aamfac
|
||||
const baseJson = __importStar(require("../db/base.json"));
|
||||
const Traders_1 = require("/snapshot/project/obj/models/enums/Traders");
|
||||
const assortJson = __importStar(require("../db/assort.json"));
|
||||
class gunsmith {
|
||||
mod;
|
||||
logger;
|
||||
configServer;
|
||||
ragfairConfig;
|
||||
constructor() {
|
||||
this.mod = "gunsmith"; // Set name of mod so we can log it to console later
|
||||
}
|
||||
/**
|
||||
* Some work needs to be done prior to SPT code being loaded, registering the profile image + setting trader update time inside the trader config json
|
||||
* @param container Dependency container
|
||||
*/
|
||||
preAkiLoad(container) {
|
||||
this.logger = container.resolve("WinstonLogger");
|
||||
this.logger.debug(`[${this.mod}] preAki Loading... `);
|
||||
const preAkiModLoader = container.resolve("PreAkiModLoader");
|
||||
const imageRouter = container.resolve("ImageRouter");
|
||||
const configServer = container.resolve("ConfigServer");
|
||||
const traderConfig = configServer.getConfig(ConfigTypes_1.ConfigTypes.TRADER);
|
||||
this.registerProfileImage(preAkiModLoader, imageRouter);
|
||||
this.setupTraderUpdateTime(traderConfig);
|
||||
// Add trader to trader enum
|
||||
Traders_1.Traders["gunsmith"] = "gunsmith";
|
||||
this.logger.debug(`[${this.mod}] preAki Loaded`);
|
||||
}
|
||||
/**
|
||||
* Majority of trader-related work occurs after the aki database has been loaded but prior to SPT code being run
|
||||
* @param container Dependency container
|
||||
*/
|
||||
postDBLoad(container) {
|
||||
this.logger.debug(`[${this.mod}] postDb Loading... `);
|
||||
this.configServer = container.resolve("ConfigServer");
|
||||
this.ragfairConfig = this.configServer.getConfig(ConfigTypes_1.ConfigTypes.RAGFAIR);
|
||||
// Resolve SPT classes we'll use
|
||||
const databaseServer = container.resolve("DatabaseServer");
|
||||
const configServer = container.resolve("ConfigServer");
|
||||
const traderConfig = configServer.getConfig(ConfigTypes_1.ConfigTypes.TRADER);
|
||||
const jsonUtil = container.resolve("JsonUtil");
|
||||
// Get a reference to the database tables
|
||||
const tables = databaseServer.getTables();
|
||||
// Add new trader to the trader dictionary in DatabaseServer
|
||||
this.addTraderToDb(baseJson, tables, jsonUtil);
|
||||
this.addTraderToLocales(tables, baseJson.name, "gunsmith", baseJson.nickname, baseJson.location, "A distinguished gunsmith who smuggles some of the best weapons and equipment into Tarkov. Also he is excellent in repairing weapons and armor.");
|
||||
// Add item purchase threshold value (what % durability does trader stop buying items at)
|
||||
// traderConfig.durabilityPurchaseThreshhold[baseJson._id] = 60;
|
||||
this.ragfairConfig.traders[baseJson._id] = true;
|
||||
this.logger.debug(`[${this.mod}] postDb Loaded`);
|
||||
}
|
||||
/**
|
||||
* Add profile picture to our trader
|
||||
* @param preAkiModLoader mod loader class - used to get the mods file path
|
||||
* @param imageRouter image router class - used to register the trader image path so we see their image on trader page
|
||||
*/
|
||||
registerProfileImage(preAkiModLoader, imageRouter) {
|
||||
// Reference the mod "res" folder
|
||||
const imageFilepath = `./${preAkiModLoader.getModPath(this.mod)}res`;
|
||||
// Register a route to point to the profile picture
|
||||
imageRouter.addRoute(baseJson.avatar.replace(".jpg", ""), `${imageFilepath}/gunsmith.jpg`);
|
||||
}
|
||||
/**
|
||||
* Add record to trader config to set the refresh time of trader in seconds (default is 60 minutes)
|
||||
* @param traderConfig trader config to add our trader to
|
||||
*/
|
||||
setupTraderUpdateTime(traderConfig) {
|
||||
// Add refresh time in seconds to config
|
||||
const traderRefreshRecord = { traderId: baseJson._id, seconds: { min: 1000, max: 6000 } };
|
||||
traderConfig.updateTime.push(traderRefreshRecord);
|
||||
}
|
||||
/**
|
||||
* Add our new trader to the database
|
||||
* @param traderDetailsToAdd trader details
|
||||
* @param tables database
|
||||
* @param jsonUtil json utility class
|
||||
*/
|
||||
// rome-ignore lint/suspicious/noExplicitAny: traderDetailsToAdd comes from base.json, so no type
|
||||
addTraderToDb(traderDetailsToAdd, tables, jsonUtil) {
|
||||
// Add trader to trader table, key is the traders id
|
||||
tables.traders[traderDetailsToAdd._id] = {
|
||||
assort: jsonUtil.deserialize(jsonUtil.serialize(assortJson)), // assorts are the 'offers' trader sells, can be a single item (e.g. carton of milk) or multiple items as a collection (e.g. a gun)
|
||||
base: jsonUtil.deserialize(jsonUtil.serialize(traderDetailsToAdd)),
|
||||
questassort: {
|
||||
started: {},
|
||||
success: {},
|
||||
fail: {}
|
||||
} // Empty object as trader has no assorts unlocked by quests
|
||||
};
|
||||
}
|
||||
/**
|
||||
* Add traders name/location/description to the locale table
|
||||
* @param tables database tables
|
||||
* @param fullName fullname of trader
|
||||
* @param firstName first name of trader
|
||||
* @param nickName nickname of trader
|
||||
* @param location location of trader
|
||||
* @param description description of trader
|
||||
*/
|
||||
addTraderToLocales(tables, fullName, firstName, nickName, location, description) {
|
||||
// For each language, add locale for the new trader
|
||||
const locales = Object.values(tables.locales.global);
|
||||
for (const locale of locales) {
|
||||
locale[`${baseJson._id} FullName`] = fullName;
|
||||
locale[`${baseJson._id} FirstName`] = firstName;
|
||||
locale[`${baseJson._id} Nickname`] = nickName;
|
||||
locale[`${baseJson._id} Location`] = location;
|
||||
locale[`${baseJson._id} Description`] = description;
|
||||
}
|
||||
}
|
||||
addItemToLocales(tables, itemTpl, name, shortName, Description) {
|
||||
// For each language, add locale for the new trader
|
||||
const locales = Object.values(tables.locales.global);
|
||||
for (const locale of locales) {
|
||||
locale[`${itemTpl} Name`] = name;
|
||||
locale[`${itemTpl} ShortName`] = shortName;
|
||||
locale[`${itemTpl} Description`] = Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
module.exports = { mod: new gunsmith() };
|
||||
//# sourceMappingURL=mod.js.map
|
||||
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"mod.js","sourceRoot":"","sources":["mod.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAUA,gFAA6E;AAO7E,6BAA6B;AAC7B,0DAA4C;AAC5C,wEAAqE;AACrE,8DAAgD;AAEhD,MAAM,QAAQ;IACV,GAAG,CAAQ;IACX,MAAM,CAAS;IACP,YAAY,CAAe;IAC3B,aAAa,CAAiB;IAEtC;QACI,IAAI,CAAC,GAAG,GAAG,UAAU,CAAC,CAAC,oDAAoD;IAC/E,CAAC;IAED;;;OAGG;IACI,UAAU,CAAC,SAA8B;QAC5C,IAAI,CAAC,MAAM,GAAG,SAAS,CAAC,OAAO,CAAU,eAAe,CAAC,CAAC;QAC1D,IAAI,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,CAA6B,CAAC;QACjF,KAAK,MAAM,MAAM,IAAI,OAAO,EAAE,CAAC;YAC3B,MAAM,CAAC,GAAG,OAAO,OAAO,CAAC,GAAG,IAAI,CAAC;YACjC,MAAM,CAAC,GAAG,OAAO,YAAY,CAAC,GAAG,SAAS,CAAC;YAC3C,MAAM,CAAC,GAAG,OAAO,cAAc,CAAC,GAAG,WAAW,CAAC;QACnD,CAAC;IACL,CAAC;CACJ;AAED,MAAM,CAAC,OAAO,GAAG,EAAE,GAAG,EAAE,IAAI,QAAQ,EAAE,EAAE,CAAA"}
|
||||
@@ -0,0 +1,168 @@
|
||||
import { DependencyContainer } from "tsyringe";
|
||||
|
||||
// SPT types
|
||||
import { IPreAkiLoadMod } from "@spt-aki/models/external/IPreAkiLoadMod";
|
||||
import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { PreAkiModLoader } from "@spt-aki/loaders/PreAkiModLoader";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { ImageRouter } from "@spt-aki/routers/ImageRouter";
|
||||
import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { ITraderAssort, ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader";
|
||||
import { ITraderConfig, UpdateTime } from "@spt-aki/models/spt/config/ITraderConfig";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { IDatabaseTables } from "@spt-aki/models/spt/server/IDatabaseTables";
|
||||
|
||||
|
||||
// New trader settings aamfac
|
||||
import * as baseJson from "../db/base.json";
|
||||
import { Traders } from "@spt-aki/models/enums/Traders";
|
||||
import * as assortJson from "../db/assort.json";
|
||||
|
||||
class gunsmith implements IPreAkiLoadMod, IPostDBLoadMod {
|
||||
mod: string
|
||||
logger: ILogger
|
||||
private configServer: ConfigServer;
|
||||
private ragfairConfig: IRagfairConfig;
|
||||
|
||||
constructor() {
|
||||
this.mod = "gunsmith"; // Set name of mod so we can log it to console later
|
||||
}
|
||||
|
||||
/**
|
||||
* Some work needs to be done prior to SPT code being loaded, registering the profile image + setting trader update time inside the trader config json
|
||||
* @param container Dependency container
|
||||
*/
|
||||
public preAkiLoad(container: DependencyContainer): void {
|
||||
this.logger = container.resolve<ILogger>("WinstonLogger");
|
||||
this.logger.debug(`[${this.mod}] preAki Loading... `);
|
||||
|
||||
const preAkiModLoader: PreAkiModLoader = container.resolve<PreAkiModLoader>("PreAkiModLoader");
|
||||
const imageRouter: ImageRouter = container.resolve<ImageRouter>("ImageRouter");
|
||||
const configServer = container.resolve<ConfigServer>("ConfigServer");
|
||||
const traderConfig: ITraderConfig = configServer.getConfig<ITraderConfig>(ConfigTypes.TRADER);
|
||||
|
||||
this.registerProfileImage(preAkiModLoader, imageRouter);
|
||||
|
||||
this.setupTraderUpdateTime(traderConfig);
|
||||
|
||||
|
||||
// Add trader to trader enum
|
||||
Traders["gunsmith"] = "gunsmith";
|
||||
this.logger.debug(`[${this.mod}] preAki Loaded`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Majority of trader-related work occurs after the aki database has been loaded but prior to SPT code being run
|
||||
* @param container Dependency container
|
||||
*/
|
||||
public postDBLoad(container: DependencyContainer): void {
|
||||
this.logger.debug(`[${this.mod}] postDb Loading... `);
|
||||
|
||||
this.configServer = container.resolve("ConfigServer");
|
||||
this.ragfairConfig = this.configServer.getConfig(ConfigTypes.RAGFAIR);
|
||||
|
||||
// Resolve SPT classes we'll use
|
||||
const databaseServer: DatabaseServer = container.resolve<DatabaseServer>("DatabaseServer");
|
||||
const configServer: ConfigServer = container.resolve<ConfigServer>("ConfigServer");
|
||||
const traderConfig: ITraderConfig = configServer.getConfig(ConfigTypes.TRADER);
|
||||
const jsonUtil: JsonUtil = container.resolve<JsonUtil>("JsonUtil");
|
||||
|
||||
// Get a reference to the database tables
|
||||
const tables = databaseServer.getTables();
|
||||
|
||||
// Add new trader to the trader dictionary in DatabaseServer
|
||||
this.addTraderToDb(baseJson, tables, jsonUtil);
|
||||
|
||||
this.addTraderToLocales(tables, baseJson.name, "gunsmith", baseJson.nickname, baseJson.location, "A distinguished gunsmith who smuggles some of the best weapons and equipment into Tarkov. Also he is excellent in repairing weapons and armor.");
|
||||
|
||||
// Add item purchase threshold value (what % durability does trader stop buying items at)
|
||||
// traderConfig.durabilityPurchaseThreshhold[baseJson._id] = 60;
|
||||
this.ragfairConfig.traders[baseJson._id] = true;
|
||||
|
||||
this.logger.debug(`[${this.mod}] postDb Loaded`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add profile picture to our trader
|
||||
* @param preAkiModLoader mod loader class - used to get the mods file path
|
||||
* @param imageRouter image router class - used to register the trader image path so we see their image on trader page
|
||||
*/
|
||||
private registerProfileImage(preAkiModLoader: PreAkiModLoader, imageRouter: ImageRouter): void
|
||||
{
|
||||
// Reference the mod "res" folder
|
||||
const imageFilepath = `./${preAkiModLoader.getModPath(this.mod)}res`;
|
||||
|
||||
// Register a route to point to the profile picture
|
||||
imageRouter.addRoute(baseJson.avatar.replace(".jpg", ""), `${imageFilepath}/gunsmith.jpg`);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add record to trader config to set the refresh time of trader in seconds (default is 60 minutes)
|
||||
* @param traderConfig trader config to add our trader to
|
||||
*/
|
||||
private setupTraderUpdateTime(traderConfig: ITraderConfig): void
|
||||
{
|
||||
// Add refresh time in seconds to config
|
||||
const traderRefreshRecord: UpdateTime = { traderId: baseJson._id, seconds: { min: 1000, max: 6000 } }
|
||||
traderConfig.updateTime.push(traderRefreshRecord);
|
||||
}
|
||||
|
||||
/**
|
||||
* Add our new trader to the database
|
||||
* @param traderDetailsToAdd trader details
|
||||
* @param tables database
|
||||
* @param jsonUtil json utility class
|
||||
*/
|
||||
|
||||
// rome-ignore lint/suspicious/noExplicitAny: traderDetailsToAdd comes from base.json, so no type
|
||||
private addTraderToDb(traderDetailsToAdd: any, tables: IDatabaseTables, jsonUtil: JsonUtil): void
|
||||
{
|
||||
// Add trader to trader table, key is the traders id
|
||||
tables.traders[traderDetailsToAdd._id] = {
|
||||
assort: jsonUtil.deserialize(jsonUtil.serialize(assortJson)) as ITraderAssort, // assorts are the 'offers' trader sells, can be a single item (e.g. carton of milk) or multiple items as a collection (e.g. a gun)
|
||||
base: jsonUtil.deserialize(jsonUtil.serialize(traderDetailsToAdd)) as ITraderBase,
|
||||
questassort: {
|
||||
started: {},
|
||||
success: {},
|
||||
fail: {}
|
||||
} // Empty object as trader has no assorts unlocked by quests
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Add traders name/location/description to the locale table
|
||||
* @param tables database tables
|
||||
* @param fullName fullname of trader
|
||||
* @param firstName first name of trader
|
||||
* @param nickName nickname of trader
|
||||
* @param location location of trader
|
||||
* @param description description of trader
|
||||
*/
|
||||
private addTraderToLocales(tables: IDatabaseTables, fullName: string, firstName: string, nickName: string, location: string, description: string)
|
||||
{
|
||||
// For each language, add locale for the new trader
|
||||
const locales = Object.values(tables.locales.global) as Record<string, string>[];
|
||||
for (const locale of locales) {
|
||||
locale[`${baseJson._id} FullName`] = fullName;
|
||||
locale[`${baseJson._id} FirstName`] = firstName;
|
||||
locale[`${baseJson._id} Nickname`] = nickName;
|
||||
locale[`${baseJson._id} Location`] = location;
|
||||
locale[`${baseJson._id} Description`] = description;
|
||||
}
|
||||
}
|
||||
|
||||
private addItemToLocales(tables: IDatabaseTables, itemTpl: string, name: string, shortName: string, Description: string)
|
||||
{
|
||||
// For each language, add locale for the new trader
|
||||
const locales = Object.values(tables.locales.global) as Record<string, string>[];
|
||||
for (const locale of locales) {
|
||||
locale[`${itemTpl} Name`] = name;
|
||||
locale[`${itemTpl} ShortName`] = shortName;
|
||||
locale[`${itemTpl} Description`] = Description;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = { mod: new gunsmith() }
|
||||
Reference in New Issue
Block a user