Advertisement
EmperorRubidium

blackthor

Aug 1st, 2022
1,316
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import { container, DependencyContainer } from "tsyringe";
  2. import { IPostDBLoadMod } from "@spt-aki/models/external/IPostDBLoadMod";
  3. import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
  4. import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
  5. import { JsonUtil } from "@spt-aki/utils/JsonUtil";
  6.  
  7. class BlackThor implements IPostDBLoadMod {
  8.     public postDBLoad(container: DependencyContainer): void {
  9.         const modName = "LukewarmPudding-BlackTHOR";
  10.         const modVersion = "v1.0.0"
  11.         const logger = container.resolve<ILogger>("WinstonLogger");
  12.        
  13.         logger.log("Loading: " + modName + " - " + modVersion, "red");
  14.  
  15.         //Get THOR from gamedb
  16.         const databaseServer = container.resolve<DatabaseServer>("DatabaseServer");
  17.         const itemID = "THORblack";
  18.         const itemClone = "60a283193cb70855c43a381d";
  19.  
  20.         //get in mem /assets/database
  21.         const database = databaseServer.getTables();
  22.         const items = database.templates.items;
  23.         const handbook = database.templates.handbook.Items;
  24.         const global = database.locales.global;
  25.         const traders = database.traders;
  26.  
  27.         //handbook
  28.         const itemCategory = "5448e54d4bdc2dcc718b4568";
  29.         const itemFleaPrice = 10000;
  30.  
  31.         //item
  32.         const itemPrefabPath = "thor_carrier_full.bundle"
  33.         const itemLongName = "NFM THOR Integrated Carrier body armor - Black"
  34.         const itemShortName = "THOR ICB"
  35.         const itemDescription = "The THOR full protection assault body armor equipped with soft and hard armor elements to protect against shrapnel and bullets of pistol and rifle calibers. Now in Black. Manufactured by NFM."
  36.        
  37.         //offer
  38.         const itemTrader = "5ac3b934156ae10c4430e83c"; //Ragman
  39.         const itemTraderPrice = 120;
  40.         const itemTraderCurrency = "5449016a4bdc2d6f028b456f"; //Roubles
  41.         const itemTraderLV = 1;
  42.  
  43.         //process info
  44.         this.createItemHandbookEntry(itemID, itemCategory, itemFleaPrice, handbook);
  45.         this.createItem(itemID, itemClone, itemPrefabPath, itemLongName, itemShortName, itemDescription, items, global);
  46.         this.createItemOffer(itemID, itemTrader, itemTraderPrice, itemTraderCurrency, itemTraderLV, traders);
  47.  
  48.     }
  49.  
  50.     createItemHandbookEntry(i_id, i_category, i_fprice, i_handbook)    {
  51.         //add item to handbook
  52.         i_handbook.push(
  53.             {
  54.                 "Id": i_id,
  55.                 "ParentId": i_category,
  56.                 "Price": i_fprice
  57.             }
  58.         );
  59.     }
  60.  
  61.     createItem(i_id, i_clone, i_path, i_lname, i_sname, i_desc, i_items, i_global)    {
  62.         const JsonUtil = container.resolve<JsonUtil>("JsonUtil");
  63.         let item = JsonUtil.clone(i_items[i_clone]);
  64.         //new item props (not include not changed props)
  65.         item._id = i_id;
  66.         item._props.Durability = 80000;
  67.         item._props.MaxDurability = 80000;
  68.         item._props.armorClass = 10;
  69.         item._props.BackgroundColor = "red";
  70.         item._props.RepairCost = 2;
  71.         item._props.RepairSpeed = 0;
  72.         item._props.Indestructibility = 0.09;
  73.         item._props.Prefab.path = "thor_carrier_full.bundle";
  74.  
  75.         //add item back to database
  76.         i_items[i_id] = item;
  77.         //add custom item names to all languages/locales
  78.         for (const localeID in i_global)
  79.         {
  80.             i_global[localeID].templates[i_id] =
  81.             {
  82.                 "Name": i_lname,
  83.                 "ShortName": i_sname,
  84.                 "Description": i_desc
  85.             };
  86.         }
  87.     }
  88.  
  89.     createItemOffer(i_id, i_trader, i_price, i_currency, i_loyalty, i_traders)    {
  90.         i_traders[i_trader].assort.items.push(
  91.             {
  92.                 "_id": i_id,
  93.                 "_tpl": i_id,
  94.                 "parentId": "hideout",
  95.                 "slotId": "hideout",
  96.                 "upd":
  97.                 {
  98.                     "UnlimitedCount": true,
  99.                     "StackObjectsCount": 50
  100.                 }
  101.             }
  102.         );
  103.         //add trader cost to item
  104.         i_traders[i_trader].assort.barter_scheme[i_id] = [
  105.             [
  106.                 {
  107.                     "count": i_price,
  108.                     "_tpl": i_currency
  109.                 }
  110.             ]
  111.         ];
  112.         //add trader loyalty level to item
  113.         i_traders[i_trader].assort.loyal_level_items[i_id] = i_loyalty;
  114.  
  115.     }
  116. }
  117.  
  118. module.exports = { mod: new BlackThor }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement