Improved handling of bot stock generation.
Moved code into own function Expanded force stock check to look for any child items instead of ones for slot `mod_stock` Expanded check to include additional slot names
This commit is contained in:
parent
08d66d9e42
commit
4582bb6fe2
@ -455,16 +455,11 @@ export class BotEquipmentModGenerator {
|
||||
}
|
||||
|
||||
// If stock mod can take a sub stock mod, force spawn chance to be 100% to ensure sub-stock gets added
|
||||
// Or if mod_stock is configured to be forced on
|
||||
if (
|
||||
modSlot === "mod_stock" &&
|
||||
modToAddTemplate._props.Slots.some(
|
||||
(slot) => slot._name.includes("mod_stock") || botEquipConfig.forceStock,
|
||||
)
|
||||
) {
|
||||
// Or if bot has stock force enabled
|
||||
if (this.shouldForceSubStockSlots(modSlot, botEquipConfig, modToAddTemplate)) {
|
||||
// Stock mod can take additional stocks, could be a locking device, force 100% chance
|
||||
const stockSlots = ["mod_stock", "mod_stock_000", "mod_stock_akms"];
|
||||
this.adjustSlotSpawnChances(request.modSpawnChances, stockSlots, 100);
|
||||
const subStockSlots = ["mod_stock", "mod_stock_000", "mod_stock_001", "mod_stock_akms"];
|
||||
this.adjustSlotSpawnChances(request.modSpawnChances, subStockSlots, 100);
|
||||
}
|
||||
|
||||
// Gather stats on mods being added to weapon
|
||||
@ -538,6 +533,27 @@ export class BotEquipmentModGenerator {
|
||||
return request.weapon;
|
||||
}
|
||||
|
||||
/**
|
||||
* Should the provided bot have its stock chance values altered to 100%
|
||||
* @param modSlot Slot to check
|
||||
* @param botEquipConfig Bots equipment config/chance values
|
||||
* @param modToAddTemplate Mod being added to bots weapon
|
||||
* @returns True if it should
|
||||
*/
|
||||
protected shouldForceSubStockSlots(
|
||||
modSlot: string,
|
||||
botEquipConfig: EquipmentFilters,
|
||||
modToAddTemplate: ITemplateItem,
|
||||
): boolean {
|
||||
// Slots a weapon can store its stock in
|
||||
const stockSlots = ["mod_stock", "mod_stock_000", "mod_stock_001", "mod_stock_akms"];
|
||||
|
||||
// Can the stock hold child items
|
||||
const hasSubSlots = modToAddTemplate._props.Slots?.length > 0;
|
||||
|
||||
return (stockSlots.includes(modSlot) && hasSubSlots) || botEquipConfig.forceStock;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this modslot a front or rear sight
|
||||
* @param modSlot Slot to check
|
||||
|
Loading…
x
Reference in New Issue
Block a user