Skip to content

Commit cb99adb

Browse files
authored
Merge branch '3.10.2-dev' into CultistCircleImprovements.3.10.2-dev
2 parents 12332dc + c071702 commit cb99adb

File tree

5 files changed

+930
-111
lines changed

5 files changed

+930
-111
lines changed

project/biome.jsonc

+13-1
Original file line numberDiff line numberDiff line change
@@ -69,5 +69,17 @@
6969
"formatter": {
7070
"trailingCommas": "none"
7171
}
72-
}
72+
},
73+
"overrides": [
74+
{
75+
"include": ["tests/*"],
76+
"linter": {
77+
"rules": {
78+
"suspicious": {
79+
"noExplicitAny": "off"
80+
}
81+
}
82+
}
83+
}
84+
]
7385
}

project/src/generators/BotEquipmentModGenerator.ts

+58-37
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ export class BotEquipmentModGenerator {
374374
const randomisationSettings = this.botHelper.getBotRandomizationDetails(request.botData.level, botEquipConfig);
375375

376376
// Iterate over mod pool and choose mods to attach
377-
const sortedModKeys = this.sortModKeys(Object.keys(compatibleModsPool));
377+
const sortedModKeys = this.sortModKeys(Object.keys(compatibleModsPool), request.parentTemplate._id);
378378
for (const modSlot of sortedModKeys) {
379379
// Check weapon has slot for mod to fit in
380380
const modsParentSlot = this.getModItemSlotFromDb(modSlot, request.parentTemplate);
@@ -665,13 +665,15 @@ export class BotEquipmentModGenerator {
665665
/**
666666
* Sort mod slots into an ordering that maximises chance of a successful weapon generation
667667
* @param unsortedSlotKeys Array of mod slot strings to sort
668+
* @param itemTplWithKeysToSort The Tpl of the item with mod keys being sorted
668669
* @returns Sorted array
669670
*/
670-
protected sortModKeys(unsortedSlotKeys: string[]): string[] {
671+
protected sortModKeys(unsortedSlotKeys: string[], itemTplWithKeysToSort: string): string[] {
671672
// No need to sort with only 1 item in array
672673
if (unsortedSlotKeys.length <= 1) {
673674
return unsortedSlotKeys;
674675
}
676+
const isMount = this.itemHelper.isOfBaseclass(itemTplWithKeysToSort, BaseClasses.MOUNT);
675677

676678
const sortedKeys: string[] = [];
677679
const modRecieverKey = "mod_reciever";
@@ -683,50 +685,69 @@ export class BotEquipmentModGenerator {
683685
const modHandguardKey = "mod_handguard";
684686
const modMountKey = "mod_mount";
685687
const modScopeKey = "mod_scope";
688+
const modScope000Key = "mod_scope_000";
686689

687-
if (unsortedSlotKeys.includes(modHandguardKey)) {
688-
sortedKeys.push(modHandguardKey);
689-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modHandguardKey), 1);
690-
}
690+
// Mounts are a special case, they need scopes first before more mounts
691+
if (isMount) {
692+
if (unsortedSlotKeys.includes(modScope000Key)) {
693+
sortedKeys.push(modScope000Key);
694+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modScope000Key), 1);
695+
}
691696

692-
if (unsortedSlotKeys.includes(modBarrelKey)) {
693-
sortedKeys.push(modBarrelKey);
694-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modBarrelKey), 1);
695-
}
697+
if (unsortedSlotKeys.includes(modScopeKey)) {
698+
sortedKeys.push(modScopeKey);
699+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modScopeKey), 1);
700+
}
696701

697-
if (unsortedSlotKeys.includes(modMount001Key)) {
698-
sortedKeys.push(modMount001Key);
699-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modMount001Key), 1);
700-
}
702+
if (unsortedSlotKeys.includes(modMountKey)) {
703+
sortedKeys.push(modMountKey);
704+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modMountKey), 1);
705+
}
706+
} else {
707+
if (unsortedSlotKeys.includes(modHandguardKey)) {
708+
sortedKeys.push(modHandguardKey);
709+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modHandguardKey), 1);
710+
}
701711

702-
if (unsortedSlotKeys.includes(modRecieverKey)) {
703-
sortedKeys.push(modRecieverKey);
704-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modRecieverKey), 1);
705-
}
712+
if (unsortedSlotKeys.includes(modBarrelKey)) {
713+
sortedKeys.push(modBarrelKey);
714+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modBarrelKey), 1);
715+
}
706716

707-
if (unsortedSlotKeys.includes(modPistolGrip)) {
708-
sortedKeys.push(modPistolGrip);
709-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modPistolGrip), 1);
710-
}
717+
if (unsortedSlotKeys.includes(modMount001Key)) {
718+
sortedKeys.push(modMount001Key);
719+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modMount001Key), 1);
720+
}
711721

712-
if (unsortedSlotKeys.includes(modGasBlockKey)) {
713-
sortedKeys.push(modGasBlockKey);
714-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modGasBlockKey), 1);
715-
}
722+
if (unsortedSlotKeys.includes(modRecieverKey)) {
723+
sortedKeys.push(modRecieverKey);
724+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modRecieverKey), 1);
725+
}
716726

717-
if (unsortedSlotKeys.includes(modStockKey)) {
718-
sortedKeys.push(modStockKey);
719-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modStockKey), 1);
720-
}
727+
if (unsortedSlotKeys.includes(modPistolGrip)) {
728+
sortedKeys.push(modPistolGrip);
729+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modPistolGrip), 1);
730+
}
721731

722-
if (unsortedSlotKeys.includes(modMountKey)) {
723-
sortedKeys.push(modMountKey);
724-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modMountKey), 1);
725-
}
732+
if (unsortedSlotKeys.includes(modGasBlockKey)) {
733+
sortedKeys.push(modGasBlockKey);
734+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modGasBlockKey), 1);
735+
}
726736

727-
if (unsortedSlotKeys.includes(modScopeKey)) {
728-
sortedKeys.push(modScopeKey);
729-
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modScopeKey), 1);
737+
if (unsortedSlotKeys.includes(modStockKey)) {
738+
sortedKeys.push(modStockKey);
739+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modStockKey), 1);
740+
}
741+
742+
if (unsortedSlotKeys.includes(modMountKey)) {
743+
sortedKeys.push(modMountKey);
744+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modMountKey), 1);
745+
}
746+
747+
if (unsortedSlotKeys.includes(modScopeKey)) {
748+
sortedKeys.push(modScopeKey);
749+
unsortedSlotKeys.splice(unsortedSlotKeys.indexOf(modScopeKey), 1);
750+
}
730751
}
731752

732753
sortedKeys.push(...unsortedSlotKeys);

project/src/services/BotWeaponModLimitService.ts

+14-9
Original file line numberDiff line numberDiff line change
@@ -100,23 +100,28 @@ export class BotWeaponModLimitService {
100100
return true;
101101
}
102102

103-
// mods parent is scope and mod is scope, allow it (adds those mini-sights to the tops of sights)
103+
// Mods parent is scope and mod is scope, allow it (adds those mini-sights to the tops of sights)
104104
const modIsScope = this.itemHelper.isOfBaseclasses(modTemplate._id, modLimits.scopeBaseTypes);
105105
if (this.itemHelper.isOfBaseclasses(modsParent._id, modLimits.scopeBaseTypes) && modIsScope) {
106106
return false;
107107
}
108108

109-
// If mod is a scope, return if limit reached
109+
// If mod is a scope , Exit early
110110
if (modIsScope) {
111111
return this.weaponModLimitReached(modTemplate._id, modLimits.scope, modLimits.scopeMax, botRole);
112112
}
113113

114-
// Mod is a mount that can hold only scopes and limit is reached (dont want to add empty mounts if limit is reached)
114+
// Don't allow multple mounts on a weapon (except when mount is on another mount)
115+
// Fail when:
116+
// Over or at scope limit on weapon
117+
// Item being added is a mount but the parent item is NOT a mount (Allows red dot sub-mounts on mounts)
118+
// Mount has one slot and its for a mod_scope
115119
if (
120+
modLimits.scope.count >= modLimits.scopeMax &&
121+
modTemplate._props.Slots?.length === 1 &&
116122
this.itemHelper.isOfBaseclass(modTemplate._id, BaseClasses.MOUNT) &&
117-
modTemplate._props.Slots.some((x) => x._name === "mod_scope") &&
118-
modTemplate._props.Slots.length === 1 &&
119-
modLimits.scope.count >= modLimits.scopeMax
123+
!this.itemHelper.isOfBaseclass(modsParent._id, BaseClasses.MOUNT) &&
124+
modTemplate._props.Slots.some((slot) => slot._name === "mod_scope")
120125
) {
121126
return true;
122127
}
@@ -134,10 +139,10 @@ export class BotWeaponModLimitService {
134139

135140
// Mod is a mount that can hold only flashlights ad limit is reached (dont want to add empty mounts if limit is reached)
136141
if (
142+
modLimits.scope.count >= modLimits.scopeMax &&
143+
modTemplate._props.Slots?.length === 1 &&
137144
this.itemHelper.isOfBaseclass(modTemplate._id, BaseClasses.MOUNT) &&
138-
modTemplate._props.Slots.some((x) => x._name === "mod_flashlight") &&
139-
modTemplate._props.Slots.length === 1 &&
140-
modLimits.scope.count >= modLimits.scopeMax
145+
modTemplate._props.Slots.some((slot) => slot._name === "mod_flashlight")
141146
) {
142147
return true;
143148
}

0 commit comments

Comments
 (0)