@@ -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
0 commit comments