mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 21:30:43 -05:00
Better handle cultist rewards not fitting the container (#979)
Better handle rewards not fitting (they shouldn't just poof) by instead trimming the rewards amount until they fit. (cherry picked from commit 8d05bf0069b22968d7e4fcdc4901ae0babd948c3)
This commit is contained in:
parent
2abf216a07
commit
b4061b3e41
@ -124,7 +124,7 @@ export class CircleOfCultistService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const rewards = hasDirectReward
|
let rewards = hasDirectReward
|
||||||
? this.getDirectRewards(sessionId, directRewardSettings, cultistCircleStashId)
|
? this.getDirectRewards(sessionId, directRewardSettings, cultistCircleStashId)
|
||||||
: this.getRewardsWithinBudget(
|
: this.getRewardsWithinBudget(
|
||||||
this.getCultistCircleRewardPool(sessionId, pmcData, craftingInfo, this.hideoutConfig.cultistCircle),
|
this.getCultistCircleRewardPool(sessionId, pmcData, craftingInfo, this.hideoutConfig.cultistCircle),
|
||||||
@ -138,27 +138,28 @@ export class CircleOfCultistService {
|
|||||||
|
|
||||||
// Ensure rewards fit into container
|
// Ensure rewards fit into container
|
||||||
const containerGrid = this.inventoryHelper.getContainerSlotMap(cultistStashDbItem[1]._id);
|
const containerGrid = this.inventoryHelper.getContainerSlotMap(cultistStashDbItem[1]._id);
|
||||||
const canAddToContainer = this.inventoryHelper.canPlaceItemsInContainer(
|
let canAddToContainer = false;
|
||||||
this.cloner.clone(containerGrid), // MUST clone grid before passing in as function modifies grid
|
while (!canAddToContainer && rewards.length > 0) {
|
||||||
rewards,
|
canAddToContainer = this.inventoryHelper.canPlaceItemsInContainer(
|
||||||
);
|
this.cloner.clone(containerGrid), // MUST clone grid before passing in as function modifies grid
|
||||||
|
rewards,
|
||||||
if (canAddToContainer) {
|
|
||||||
for (const itemToAdd of rewards) {
|
|
||||||
this.inventoryHelper.placeItemInContainer(
|
|
||||||
containerGrid,
|
|
||||||
itemToAdd,
|
|
||||||
cultistCircleStashId,
|
|
||||||
CircleOfCultistService.circleOfCultistSlotId,
|
|
||||||
);
|
|
||||||
// Add item + mods to output and profile inventory
|
|
||||||
output.profileChanges[sessionId].items.new.push(...itemToAdd);
|
|
||||||
pmcData.Inventory.items.push(...itemToAdd);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
this.logger.error(
|
|
||||||
`Unable to fit all: ${rewards.length} reward items into sacrifice grid, nothing will be returned (rewards so valuable cultists stole it)`,
|
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if (canAddToContainer) {
|
||||||
|
for (const itemToAdd of rewards) {
|
||||||
|
this.inventoryHelper.placeItemInContainer(
|
||||||
|
containerGrid,
|
||||||
|
itemToAdd,
|
||||||
|
cultistCircleStashId,
|
||||||
|
CircleOfCultistService.circleOfCultistSlotId,
|
||||||
|
);
|
||||||
|
// Add item + mods to output and profile inventory
|
||||||
|
output.profileChanges[sessionId].items.new.push(...itemToAdd);
|
||||||
|
pmcData.Inventory.items.push(...itemToAdd);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
rewards.pop();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user