Improved bot generation comments
(cherry picked from commit e7f56edf0cfb9028e337056a78691a34beff5502)
This commit is contained in:
parent
d522e7d5a8
commit
adcd0194bf
@ -101,14 +101,18 @@ export class BotEquipmentModGenerator {
|
|||||||
botRole: settings.botRole,
|
botRole: settings.botRole,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const modSpawnResult = this.shouldModBeSpawned(
|
const modSpawnResult = this.shouldModBeSpawned(
|
||||||
itemSlotTemplate,
|
itemSlotTemplate,
|
||||||
modSlotName.toLowerCase(),
|
modSlotName.toLowerCase(),
|
||||||
settings.spawnChances.equipmentMods,
|
settings.spawnChances.equipmentMods,
|
||||||
settings.botEquipmentConfig,
|
settings.botEquipmentConfig,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
// Rolled to skip mod and it shouldnt be force-spawned
|
||||||
if (modSpawnResult === ModSpawn.SKIP && !forceSpawn) {
|
if (modSpawnResult === ModSpawn.SKIP && !forceSpawn) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -118,37 +122,41 @@ export class BotEquipmentModGenerator {
|
|||||||
forceSpawn = true;
|
forceSpawn = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get pool of items we can add for this slot
|
||||||
let modPoolToChooseFrom = compatibleModsPool[modSlotName];
|
let modPoolToChooseFrom = compatibleModsPool[modSlotName];
|
||||||
|
|
||||||
|
// Slot can hold armor plates + we are filtering possible items by bot level, handle
|
||||||
if (
|
if (
|
||||||
settings.botEquipmentConfig.filterPlatesByLevel &&
|
settings.botEquipmentConfig.filterPlatesByLevel &&
|
||||||
this.itemHelper.isRemovablePlateSlot(modSlotName.toLowerCase())
|
this.itemHelper.isRemovablePlateSlot(modSlotName.toLowerCase())
|
||||||
) {
|
) {
|
||||||
const outcome = this.filterPlateModsForSlotByLevel(
|
const plateSlotFilteringOutcome = this.filterPlateModsForSlotByLevel(
|
||||||
settings,
|
settings,
|
||||||
modSlotName.toLowerCase(),
|
modSlotName.toLowerCase(),
|
||||||
compatibleModsPool[modSlotName],
|
compatibleModsPool[modSlotName],
|
||||||
parentTemplate,
|
parentTemplate,
|
||||||
);
|
);
|
||||||
if ([Result.UNKNOWN_FAILURE, Result.NO_DEFAULT_FILTER].includes(outcome.result)) {
|
if ([Result.UNKNOWN_FAILURE, Result.NO_DEFAULT_FILTER].includes(plateSlotFilteringOutcome.result)) {
|
||||||
this.logger.debug(
|
this.logger.debug(
|
||||||
`Plate slot: ${modSlotName} selection for armor: ${parentTemplate._id} failed: ${
|
`Plate slot: ${modSlotName} selection for armor: ${parentTemplate._id} failed: ${
|
||||||
Result[outcome.result]
|
Result[plateSlotFilteringOutcome.result]
|
||||||
}, skipping`,
|
}, skipping`,
|
||||||
);
|
);
|
||||||
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ([Result.LACKS_PLATE_WEIGHTS].includes(outcome.result)) {
|
if ([Result.LACKS_PLATE_WEIGHTS].includes(plateSlotFilteringOutcome.result)) {
|
||||||
this.logger.warning(
|
this.logger.warning(
|
||||||
`Plate slot: ${modSlotName} lacks weights for armor: ${parentTemplate._id}, unable to adjust plate choice, using existing data`,
|
`Plate slot: ${modSlotName} lacks weights for armor: ${parentTemplate._id}, unable to adjust plate choice, using existing data`,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
modPoolToChooseFrom = outcome.plateModTpls;
|
// Replace mod pool with pool of chosen plate items
|
||||||
|
modPoolToChooseFrom = plateSlotFilteringOutcome.plateModTpls;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find random mod and check its compatible
|
// Choose random mod from pool and check its compatibility
|
||||||
let modTpl: string | undefined;
|
let modTpl: string | undefined;
|
||||||
let found = false;
|
let found = false;
|
||||||
const exhaustableModPool = new ExhaustableArray<string>(modPoolToChooseFrom, this.randomUtil, this.cloner);
|
const exhaustableModPool = new ExhaustableArray<string>(modPoolToChooseFrom, this.randomUtil, this.cloner);
|
||||||
@ -170,9 +178,8 @@ export class BotEquipmentModGenerator {
|
|||||||
found = !!modTpl;
|
found = !!modTpl;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compatible item not found + not required
|
// Compatible item not found + not required - skip
|
||||||
if (!(found || itemSlotTemplate._required)) {
|
if (!(found || itemSlotTemplate._required)) {
|
||||||
// Don't add item
|
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -185,9 +192,9 @@ export class BotEquipmentModGenerator {
|
|||||||
const modId = this.hashUtil.generate();
|
const modId = this.hashUtil.generate();
|
||||||
equipment.push(this.createModItem(modId, modTpl, parentId, modSlotName, modTemplate[1], settings.botRole));
|
equipment.push(this.createModItem(modId, modTpl, parentId, modSlotName, modTemplate[1], settings.botRole));
|
||||||
|
|
||||||
// Does the item being added have possible child mods?
|
// Does item being added exist in mod pool - has its own mod pool
|
||||||
if (Object.keys(settings.modPool).includes(modTpl)) {
|
if (Object.keys(settings.modPool).includes(modTpl)) {
|
||||||
// Call self recursively with item being checkced item we just added to bot
|
// Call self again with mod being added as item to add child mods to
|
||||||
this.generateModsForEquipment(equipment, modId, modTemplate[1], settings, forceSpawn);
|
this.generateModsForEquipment(equipment, modId, modTemplate[1], settings, forceSpawn);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -200,7 +207,7 @@ export class BotEquipmentModGenerator {
|
|||||||
* @param settings Bot equipment generation settings
|
* @param settings Bot equipment generation settings
|
||||||
* @param modSlot Armor slot being filtered
|
* @param modSlot Armor slot being filtered
|
||||||
* @param existingPlateTplPool Plates tpls to choose from
|
* @param existingPlateTplPool Plates tpls to choose from
|
||||||
* @param armorItem
|
* @param armorItem The armor items db template
|
||||||
* @returns Array of plate tpls to choose from
|
* @returns Array of plate tpls to choose from
|
||||||
*/
|
*/
|
||||||
protected filterPlateModsForSlotByLevel(
|
protected filterPlateModsForSlotByLevel(
|
||||||
|
@ -397,13 +397,13 @@ export class BotInventoryGenerator {
|
|||||||
|
|
||||||
// Item has slots, fill them
|
// Item has slots, fill them
|
||||||
if (pickedItemDb._props.Slots?.length > 0 && !settings.generateModsBlacklist?.includes(pickedItemDb._id)) {
|
if (pickedItemDb._props.Slots?.length > 0 && !settings.generateModsBlacklist?.includes(pickedItemDb._id)) {
|
||||||
const items = this.botEquipmentModGenerator.generateModsForEquipment(
|
const childItemsToAdd = this.botEquipmentModGenerator.generateModsForEquipment(
|
||||||
[item],
|
[item],
|
||||||
id,
|
id,
|
||||||
pickedItemDb,
|
pickedItemDb,
|
||||||
settings,
|
settings,
|
||||||
);
|
);
|
||||||
settings.inventory.items.push(...items);
|
settings.inventory.items.push(...childItemsToAdd);
|
||||||
} else {
|
} else {
|
||||||
// No slots, push root item only
|
// No slots, push root item only
|
||||||
settings.inventory.items.push(item);
|
settings.inventory.items.push(item);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user