Skip to content

Commit 1ec8f65

Browse files
committed
Add map weopon weighting to all bots
1 parent 982bca8 commit 1ec8f65

File tree

5 files changed

+76
-52
lines changed

5 files changed

+76
-52
lines changed
366 KB
Binary file not shown.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "AlgorithmicLevelProgression",
3-
"version": "5.4.1",
3+
"version": "5.4.2",
44
"main": "src/mod.js",
55
"license": "MIT",
66
"author": "DewardianDev",

src/LoadoutChanges/GlobalValues.ts

Lines changed: 74 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -41,77 +41,103 @@ export class globalValues {
4141
currentLevel: number,
4242
location: keyof typeof advancedConfig.locations
4343
) {
44-
// const items = this.tables.templates.items;
44+
const items = this.tables.templates.items;
4545
const nameList = Object.keys(this.storedEquipmentValues);
4646
if (!nameList.length || !currentLevel) return;
4747
const botConfig = this.configServer.getConfig<IBotConfig>(ConfigTypes.BOT);
48+
const firstPrimaryWeaponMultiplier =
49+
advancedConfig.locations[location].weightingAdjustments
50+
.FirstPrimaryWeapon;
4851

49-
// const firstPrimaryWeaponTypes =
50-
// advancedConfig.locations[location].weightingAdjustments
51-
// .FirstPrimaryWeapon;
52+
nameList.forEach((botName) => {
53+
const copiedInventory = cloneDeep(
54+
this.originalBotTypes[botName].inventory
55+
);
5256

53-
nameList.forEach((name) => {
54-
const currentLevelIndex = this.storedEquipmentValues[name].findIndex(
57+
const currentLevelIndex = this.storedEquipmentValues[botName].findIndex(
5558
({ levelRange: { min, max } }) =>
5659
currentLevel <= max && currentLevel >= min
5760
);
61+
5862
const weightingToUpdate =
59-
this.storedEquipmentValues[name][currentLevelIndex];
63+
this.storedEquipmentValues[botName][currentLevelIndex];
6064

61-
const botInventory = this.tables.bots.types[name].inventory;
6265
if (!weightingToUpdate) return;
6366
if (weightingToUpdate?.ammo) {
6467
for (const caliber in weightingToUpdate.ammo) {
65-
mergeDeep(
66-
botInventory.Ammo[caliber],
67-
weightingToUpdate.ammo[caliber]
68-
);
68+
copiedInventory.Ammo[caliber] = {
69+
...copiedInventory.Ammo[caliber],
70+
...weightingToUpdate.ammo[caliber],
71+
};
6972
}
7073
}
7174

7275
if (weightingToUpdate?.equipment) {
7376
for (const equipmentType in weightingToUpdate.equipment) {
74-
//update weapons here
75-
// if (equipmentType === "FirstPrimaryWeapon") {
76-
// const copiedWeapons: Record<string, number> = cloneDeep(
77-
// weightingToUpdate.equipment[equipmentType]
78-
// );
79-
// // console.log(name, copiedWeapons);
80-
// for (const key in firstPrimaryWeaponTypes) {
81-
// const value = firstPrimaryWeaponTypes[key];
82-
// // console.log(, value);
83-
// copiedWeapons[key] = value;
84-
// }
85-
// firstPrimaryKeys?.forEach((weaponId) => {
86-
// const parentId = items[weaponId]?._parent;
87-
// const parent = items?.[parentId]?._name;
88-
// if (parent && firstPrimaryWeaponTypes[parent]) {
89-
// const multiplier = firstPrimaryWeaponTypes[parent];
90-
// pmcWeighting[index].equipment.edit.FirstPrimaryWeapon[
91-
// weaponId
92-
// ] = Math.round(multiplier * firstPrimary[weaponId]);
93-
// // console.log(firstPrimary[weaponId], " to ", pmcWeighting[index].equipment.edit.FirstPrimaryWeapon[weaponId], parent, items[weaponId]._name)
94-
// } else {
95-
mergeDeep(
96-
botInventory.equipment[equipmentType],
97-
weightingToUpdate.equipment[equipmentType]
98-
);
99-
// }
77+
copiedInventory.equipment[equipmentType] = {
78+
...copiedInventory.equipment[equipmentType],
79+
...weightingToUpdate.equipment[equipmentType],
80+
};
81+
try {
82+
//update weapons here
83+
if (equipmentType === "FirstPrimaryWeapon") {
84+
// console.log("Updating", botName, " weapons for map", location);
85+
const firstPrimary: Record<string, number> = cloneDeep(
86+
copiedInventory.equipment[equipmentType]
87+
);
88+
89+
const firstPrimaryKeys = Object.keys(firstPrimary);
90+
firstPrimaryKeys?.forEach((weaponId) => {
91+
const parentId = items[weaponId]?._parent;
92+
const parent = items?.[parentId]?._name;
93+
if (parent && firstPrimaryWeaponMultiplier[parent]) {
94+
const multiplier =
95+
(firstPrimaryWeaponMultiplier[parent] - 1) / 2 + 1;
96+
97+
copiedInventory.equipment[equipmentType][weaponId] =
98+
Math.round(multiplier * firstPrimary[weaponId]);
99+
100+
// if (botName === "assault") {
101+
// console.log(
102+
// multiplier,
103+
// location,
104+
// botName,
105+
// firstPrimary[weaponId],
106+
// " to ",
107+
// copiedInventory.equipment[equipmentType][weaponId],
108+
// parent,
109+
// items[weaponId]._name
110+
// );
111+
// }
112+
} else {
113+
console.log(
114+
`[AlgorithmicLevelProgression]: Unable to set map settings for bot ${botName}'s item ${items[weaponId]._name} - ${weaponId} `
115+
);
116+
}
117+
});
118+
}
119+
} catch (error) {
120+
`[AlgorithmicLevelProgression]: Failed to update bot ${botName}'s ${equipmentType}`;
121+
}
100122
}
101-
if (name === "assault") {
102-
buffScavGearAsLevel(botConfig.equipment[name], currentLevelIndex);
123+
124+
if (botName === "assault") {
125+
//adjust randomization
126+
buffScavGearAsLevel(botConfig.equipment[botName], currentLevelIndex);
103127
}
128+
104129
setPlateWeightings(
105-
name,
106-
botConfig.equipment[name],
107-
currentLevelIndex,
108-
botInventory,
109-
this.tables.templates.items
130+
botName,
131+
botConfig.equipment[botName],
132+
currentLevelIndex
110133
);
111-
// if (name === "assault") {
112-
// saveToFile(this.tables.bots.types[name], `refDBS/assault.json`);
113-
// }
134+
135+
if (botName === "assault") {
136+
saveToFile(this.tables.bots.types[botName], `refDBS/assault.json`);
137+
}
114138
}
139+
140+
this.tables.bots.types[botName].inventory = copiedInventory;
115141
});
116142
}
117143

src/NonPmcBotChanges/NonPmcUtils.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -386,8 +386,6 @@ export const setPlateWeightings = (
386386
name: string,
387387
equipmentFilters: EquipmentFilters,
388388
index: number,
389-
equipment: IInventory,
390-
items: Record<string, ITemplateItem>
391389
) => {
392390
equipmentFilters.armorPlateWeighting = [
393391
{

src/mod.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class AlgorithmicLevelProgression
6363
const botConfig = configServer.getConfig<IBotConfig>(ConfigTypes.BOT);
6464
globalValues.originalBotTypes = cloneDeep(tables.bots.types);
6565
globalValues.originalWeighting = cloneDeep(botConfig.equipment.pmc);
66-
// globalValues.updateInventory(50, "factory4_day");
66+
// globalValues.updateInventory(1, "woods"); // REMOVE
6767
}
6868

6969
postSptLoad(container: DependencyContainer): void {

0 commit comments

Comments
 (0)