Fix issue with weapon mod generation flagging mod as incompatible even though it passes compatibility checks
Stop trying to fit a mod to a weapon after 8 blocked attempts Created streamlined mod compatability checker function
This commit is contained in:
parent
58d620d424
commit
f3ec237674
@ -31,7 +31,7 @@
|
||||
"sectantWarrior": 10,
|
||||
"gifter": 5,
|
||||
"test": 30,
|
||||
"exUsec": 30,
|
||||
"exUsec": 25,
|
||||
"arenaFighterEvent": 15,
|
||||
"arenaFighter": 15,
|
||||
"crazyAssaultEvent": 15,
|
||||
@ -41,7 +41,7 @@
|
||||
"followerBoarClose2": 10,
|
||||
"followerKolontayAssault": 10,
|
||||
"followerKolontaySecurity": 10,
|
||||
"shooterBTR": 2,
|
||||
"shooterBTR": 1,
|
||||
"peacefullZryachiyEvent": 5,
|
||||
"ravangeZryachiyEvent": 5,
|
||||
"sectactPriestEvent": 10,
|
||||
@ -1728,7 +1728,6 @@
|
||||
"64abd93857958b4249003418": 10,
|
||||
"64be79c487d1510151095552": 1,
|
||||
"5648a7494bdc2d9d488b4583": 1,
|
||||
"572b7adb24597762ae139821": 1,
|
||||
"64be79e2bf8412471d0d9bcc": 1
|
||||
},
|
||||
"TacticalVest": {
|
||||
@ -1743,6 +1742,7 @@
|
||||
"5df8a42886f77412640e2e75": 60,
|
||||
"5648a69d4bdc2ded0b8b457b": 55,
|
||||
"5e4abc1f86f774069619fbaa": 1,
|
||||
"572b7adb24597762ae139821": 1,
|
||||
"6034d0230ca681766b6a0fb5": 1
|
||||
},
|
||||
"Headwear": {
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -3142,7 +3142,9 @@
|
||||
"64a536392d2c4e6e970f4121": 25,
|
||||
"64a5366719bab53bd203bf33": 25,
|
||||
"64be7095047e826eae02b0c1": 5,
|
||||
"64be7110bf597ba84a0a41ea": 15
|
||||
"64be7110bf597ba84a0a41ea": 15,
|
||||
"572b7adb24597762ae139821": 5,
|
||||
"6034d0230ca681766b6a0fb5": 2
|
||||
}
|
||||
},
|
||||
"items": {
|
||||
@ -9627,21 +9629,7 @@
|
||||
"5c07a8770db8340023300450",
|
||||
"63f5ed14534b2c3d5479a677"
|
||||
],
|
||||
"mod_stock": [
|
||||
"5a33ca0fc4a282000d72292f",
|
||||
"5c0faeddd174af02a962601f",
|
||||
"5649be884bdc2d79388b4577",
|
||||
"5d120a10d7ad1a4e1026ba85",
|
||||
"5b0800175acfc400153aebd4",
|
||||
"5947e98b86f774778f1448bc",
|
||||
"5947eab886f77475961d96c5",
|
||||
"602e3f1254072b51b239f713",
|
||||
"5c793fb92e221644f31bfb64",
|
||||
"5c793fc42e221600114ca25d",
|
||||
"591aef7986f774139d495f03",
|
||||
"591af10186f774139d495f0e",
|
||||
"627254cc9c563e6e442c398f"
|
||||
],
|
||||
"mod_stock": ["5a33ca0fc4a282000d72292f", "5c0faeddd174af02a962601f", "5649be884bdc2d79388b4577", "5d120a10d7ad1a4e1026ba85", "5b0800175acfc400153aebd4", "5947e98b86f774778f1448bc", "5947eab886f77475961d96c5", "602e3f1254072b51b239f713", "5c793fb92e221644f31bfb64", "5c793fc42e221600114ca25d", "591aef7986f774139d495f03", "591af10186f774139d495f0e", "627254cc9c563e6e442c398f", "638de3603a1a4031d8260b8c"],
|
||||
"patron_in_weapon": [
|
||||
"59e6920f86f77411d82aa167",
|
||||
"59e6927d86f77411da468256",
|
||||
|
@ -772,9 +772,8 @@ export class BotEquipmentModGenerator
|
||||
}
|
||||
|
||||
// Pick random mod that's compatible
|
||||
const chosenModResult = this.chooseRandomCompatibleModTpl(modPool, parentSlot, modSpawnResult, weapon, modSlot);
|
||||
|
||||
if (chosenModResult.slotBlocked)
|
||||
const chosenModResult = this.pickWeaponModTplForSlotFromPool(modPool, parentSlot, modSpawnResult, weapon, modSlot);
|
||||
if (chosenModResult.slotBlocked && !parentSlot._required)
|
||||
{
|
||||
// Don't bother trying to fit mod, slot is completely blocked
|
||||
return null;
|
||||
@ -817,7 +816,7 @@ export class BotEquipmentModGenerator
|
||||
return this.itemHelper.getItem(chosenModResult.chosenTpl);
|
||||
}
|
||||
|
||||
protected chooseRandomCompatibleModTpl(
|
||||
protected pickWeaponModTplForSlotFromPool(
|
||||
modPool: string[],
|
||||
parentSlot: Slot,
|
||||
modSpawnResult: ModSpawn,
|
||||
@ -833,6 +832,7 @@ export class BotEquipmentModGenerator
|
||||
};
|
||||
const modParentFilterList = parentSlot._props.filters[0].Filter;
|
||||
|
||||
let blockedAttemptCount = 0;
|
||||
while (exhaustableModPool.hasValues())
|
||||
{
|
||||
chosenTpl = exhaustableModPool.getRandomValue();
|
||||
@ -852,7 +852,7 @@ export class BotEquipmentModGenerator
|
||||
continue;
|
||||
}
|
||||
|
||||
chosenModResult = this.botGeneratorHelper.isItemIncompatibleWithCurrentItems(
|
||||
chosenModResult = this.botGeneratorHelper.isWeaponModIncompatibleWithCurrentMods(
|
||||
weapon,
|
||||
chosenTpl,
|
||||
modSlotname,
|
||||
@ -860,13 +860,25 @@ export class BotEquipmentModGenerator
|
||||
|
||||
if (chosenModResult.slotBlocked)
|
||||
{
|
||||
break;
|
||||
// Give max of 8 attempts of picking an item ifs blocked by another item
|
||||
if (blockedAttemptCount > 8)
|
||||
{
|
||||
this.logger.warning(`Attempted to find mod for slot: ${parentSlot._name} on weapon: ${weapon[0]._tpl} and blocked 8 times`);
|
||||
|
||||
blockedAttemptCount = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
blockedAttemptCount++;
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
// Some mod combos will never work, make sure its not happened
|
||||
if (!chosenModResult.incompatible && !this.weaponModComboIsIncompatible(weapon, chosenTpl))
|
||||
{
|
||||
chosenModResult.found = true;
|
||||
chosenModResult.incompatible = false;
|
||||
chosenModResult.chosenTpl = chosenTpl;
|
||||
|
||||
break;
|
||||
|
@ -276,6 +276,82 @@ export class BotGeneratorHelper
|
||||
return { Durability: currentDurability, MaxDurability: maxDurability };
|
||||
}
|
||||
|
||||
public isWeaponModIncompatibleWithCurrentMods(
|
||||
itemsEquipped: Item[],
|
||||
tplToCheck: string,
|
||||
modSlot: string,
|
||||
): IChooseRandomCompatibleModResult
|
||||
{
|
||||
// TODO: Can probably be optimized to cache itemTemplates as items are added to inventory
|
||||
const equippedItemsDb = itemsEquipped.map((item) => this.databaseServer.getTables().templates.items[item._tpl]);
|
||||
const itemToEquipDb = this.itemHelper.getItem(tplToCheck);
|
||||
const itemToEquip = itemToEquipDb[1];
|
||||
|
||||
if (!itemToEquipDb[0])
|
||||
{
|
||||
this.logger.warning(
|
||||
this.localisationService.getText("bot-invalid_item_compatibility_check", {
|
||||
itemTpl: tplToCheck,
|
||||
slot: modSlot,
|
||||
}),
|
||||
);
|
||||
|
||||
return {
|
||||
incompatible: true,
|
||||
found: false,
|
||||
reason: `item: ${tplToCheck} does not exist in the database`
|
||||
};
|
||||
}
|
||||
|
||||
// No props property
|
||||
if (!itemToEquip._props)
|
||||
{
|
||||
this.logger.warning(
|
||||
this.localisationService.getText("bot-compatibility_check_missing_props", {
|
||||
id: itemToEquip._id,
|
||||
name: itemToEquip._name,
|
||||
slot: modSlot,
|
||||
}),
|
||||
);
|
||||
|
||||
return {
|
||||
incompatible: true,
|
||||
found: false,
|
||||
reason: `item: ${tplToCheck} does not have a _props field`
|
||||
};
|
||||
}
|
||||
|
||||
// Check if any of the current weapon mod templates have the incoming item defined as incompatible
|
||||
const blockingItem = equippedItemsDb.find((x) => x._props.ConflictingItems?.includes(tplToCheck));
|
||||
if (blockingItem)
|
||||
{
|
||||
return {
|
||||
incompatible: true,
|
||||
found: false,
|
||||
reason:
|
||||
`Cannot add: ${tplToCheck} ${itemToEquip._name} to slot: ${modSlot}. Blocked by: ${blockingItem._id} ${blockingItem._name}`,
|
||||
slotBlocked: true,
|
||||
};
|
||||
}
|
||||
|
||||
// Check inverse to above, if the incoming item has any existing mods in its conflicting items array
|
||||
const blockingModItem = itemsEquipped.find((item) => itemToEquip._props.ConflictingItems?.includes(item._tpl));
|
||||
if (blockingModItem)
|
||||
{
|
||||
return {
|
||||
incompatible: true,
|
||||
found: false,
|
||||
reason:
|
||||
` Cannot add: ${tplToCheck} to slot: ${modSlot}. Would block existing item: ${blockingModItem._tpl} in slot: ${blockingModItem.slotId}`,
|
||||
};
|
||||
}
|
||||
|
||||
return {
|
||||
incompatible: false,
|
||||
reason: ""
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* Can item be added to another item without conflict
|
||||
* @param itemsEquipped Items to check compatibilities with
|
||||
|
Loading…
Reference in New Issue
Block a user