Correctly generate ammo boxes for dynamic/static/bot loot with one stack of cartridges. It seems the 0.14 client update now handles ammo boxes having a single stack and properly splits the ammo inside it
This commit is contained in:
parent
810cd8abd6
commit
7d97bc4945
@ -414,7 +414,7 @@ export class BotLootGenerator
|
|||||||
// Fill ammo box
|
// Fill ammo box
|
||||||
if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.AMMO_BOX))
|
if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.AMMO_BOX))
|
||||||
{
|
{
|
||||||
this.itemHelper.addCartridgesToAmmoBox(itemToAddChildrenTo, itemToAddTemplate);
|
this.itemHelper.addSingleStackCartridgesToAmmoBox(itemToAddChildrenTo, itemToAddTemplate);
|
||||||
}
|
}
|
||||||
// Make money a stack
|
// Make money a stack
|
||||||
else if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.MONEY))
|
else if (this.itemHelper.isOfBaseclass(itemToAddTemplate._id, BaseClasses.MONEY))
|
||||||
|
@ -3,7 +3,6 @@ import { inject, injectable } from "tsyringe";
|
|||||||
import { ContainerHelper } from "@spt-aki/helpers/ContainerHelper";
|
import { ContainerHelper } from "@spt-aki/helpers/ContainerHelper";
|
||||||
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
import { ItemHelper } from "@spt-aki/helpers/ItemHelper";
|
||||||
import { PresetHelper } from "@spt-aki/helpers/PresetHelper";
|
import { PresetHelper } from "@spt-aki/helpers/PresetHelper";
|
||||||
import { RagfairServerHelper } from "@spt-aki/helpers/RagfairServerHelper";
|
|
||||||
import { IContainerMinMax, IStaticContainer } from "@spt-aki/models/eft/common/ILocation";
|
import { IContainerMinMax, IStaticContainer } from "@spt-aki/models/eft/common/ILocation";
|
||||||
import { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
|
import { ILocationBase } from "@spt-aki/models/eft/common/ILocationBase";
|
||||||
import { ILooseLoot, Spawnpoint, SpawnpointTemplate, SpawnpointsForced } from "@spt-aki/models/eft/common/ILooseLoot";
|
import { ILooseLoot, Spawnpoint, SpawnpointTemplate, SpawnpointsForced } from "@spt-aki/models/eft/common/ILooseLoot";
|
||||||
@ -14,7 +13,6 @@ import {
|
|||||||
IStaticForcedProps,
|
IStaticForcedProps,
|
||||||
IStaticLootDetails,
|
IStaticLootDetails,
|
||||||
} from "@spt-aki/models/eft/common/tables/ILootBase";
|
} from "@spt-aki/models/eft/common/tables/ILootBase";
|
||||||
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
|
||||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||||
import { Money } from "@spt-aki/models/enums/Money";
|
import { Money } from "@spt-aki/models/enums/Money";
|
||||||
@ -24,7 +22,6 @@ import { ConfigServer } from "@spt-aki/servers/ConfigServer";
|
|||||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||||
import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService";
|
import { SeasonalEventService } from "@spt-aki/services/SeasonalEventService";
|
||||||
import { HashUtil } from "@spt-aki/utils/HashUtil";
|
|
||||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||||
import { MathUtil } from "@spt-aki/utils/MathUtil";
|
import { MathUtil } from "@spt-aki/utils/MathUtil";
|
||||||
import { ObjectId } from "@spt-aki/utils/ObjectId";
|
import { ObjectId } from "@spt-aki/utils/ObjectId";
|
||||||
@ -54,10 +51,8 @@ export class LocationGenerator
|
|||||||
@inject("WinstonLogger") protected logger: ILogger,
|
@inject("WinstonLogger") protected logger: ILogger,
|
||||||
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
||||||
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
@inject("JsonUtil") protected jsonUtil: JsonUtil,
|
||||||
@inject("HashUtil") protected hashUtil: HashUtil,
|
|
||||||
@inject("ObjectId") protected objectId: ObjectId,
|
@inject("ObjectId") protected objectId: ObjectId,
|
||||||
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
@inject("RandomUtil") protected randomUtil: RandomUtil,
|
||||||
@inject("RagfairServerHelper") protected ragfairServerHelper: RagfairServerHelper,
|
|
||||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||||
@inject("MathUtil") protected mathUtil: MathUtil,
|
@inject("MathUtil") protected mathUtil: MathUtil,
|
||||||
@inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService,
|
@inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService,
|
||||||
@ -852,7 +847,7 @@ export class LocationGenerator
|
|||||||
{
|
{
|
||||||
// Fill with cartridges
|
// Fill with cartridges
|
||||||
const ammoBoxItem: Item[] = [{ _id: this.objectId.generate(), _tpl: chosenTpl }];
|
const ammoBoxItem: Item[] = [{ _id: this.objectId.generate(), _tpl: chosenTpl }];
|
||||||
this.itemHelper.addCartridgesToAmmoBox(ammoBoxItem, itemTemplate); // ammo box template
|
this.itemHelper.addSingleStackCartridgesToAmmoBox(ammoBoxItem, itemTemplate);
|
||||||
itemWithMods.push(...ammoBoxItem);
|
itemWithMods.push(...ammoBoxItem);
|
||||||
}
|
}
|
||||||
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE))
|
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE))
|
||||||
@ -1062,7 +1057,7 @@ export class LocationGenerator
|
|||||||
// No spawnpoint to fall back on, generate manually
|
// No spawnpoint to fall back on, generate manually
|
||||||
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.AMMO_BOX))
|
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.AMMO_BOX))
|
||||||
{
|
{
|
||||||
this.itemHelper.addCartridgesToAmmoBox(items, itemTemplate);
|
this.itemHelper.addSingleStackCartridgesToAmmoBox(items, itemTemplate);
|
||||||
}
|
}
|
||||||
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE))
|
else if (this.itemHelper.isOfBaseclass(chosenTpl, BaseClasses.MAGAZINE))
|
||||||
{
|
{
|
||||||
|
@ -1034,6 +1034,26 @@ export class ItemHelper
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Add a single stack of cartridges to the ammo box
|
||||||
|
* @param ammoBox Box to add cartridges to
|
||||||
|
* @param ammoBoxDetails Item template from items db
|
||||||
|
*/
|
||||||
|
public addSingleStackCartridgesToAmmoBox(ammoBox: Item[], ammoBoxDetails: ITemplateItem): void
|
||||||
|
{
|
||||||
|
const ammoBoxMaxCartridgeCount = ammoBoxDetails._props.StackSlots[0]._max_count;
|
||||||
|
const cartridgeTpl = ammoBoxDetails._props.StackSlots[0]._props.filters[0].Filter[0];
|
||||||
|
ammoBox.push(
|
||||||
|
this.createCartridges(
|
||||||
|
ammoBox[0]._id,
|
||||||
|
cartridgeTpl,
|
||||||
|
ammoBoxMaxCartridgeCount,
|
||||||
|
0,
|
||||||
|
ammoBox[0].upd?.SpawnedInSession,
|
||||||
|
),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if item is stored inside of a container
|
* Check if item is stored inside of a container
|
||||||
* @param item Item to check is inside of container
|
* @param item Item to check is inside of container
|
||||||
|
Loading…
x
Reference in New Issue
Block a user