feat: rewards for overriden enemy caches

Closes #2913
This commit is contained in:
AMelonInsideLemon 2025-10-20 13:28:39 +02:00
parent 8e502ebe0b
commit 593407e3c4
2 changed files with 70 additions and 1 deletions

View File

@ -8,6 +8,7 @@ import {
ExportAnimals,
ExportEnemies,
ExportFusionBundles,
ExportKeys,
ExportRegions,
ExportRelics,
ExportRewards
@ -1141,6 +1142,7 @@ export const addMissionRewards = async (
const MissionRewards: IMissionReward[] = getRandomMissionDrops(
inventory,
rewardInfo,
levelKeyName,
missions,
wagerTier,
firstCompletion
@ -1756,6 +1758,7 @@ function getLevelCreditRewards(node: IRegion): number {
function getRandomMissionDrops(
inventory: TInventoryDatabaseDocument,
RewardInfo: IRewardInfo,
levelKeyName: string | undefined,
mission: IMission | undefined,
tierOverride: number | undefined,
firstCompletion: boolean
@ -2193,7 +2196,7 @@ function getRandomMissionDrops(
}
}
if (region.cacheRewardManifest && RewardInfo.EnemyCachesFound) {
if (region.cacheRewardManifest && RewardInfo.EnemyCachesFound && !RewardInfo.goalId) {
const deck = ExportRewards[region.cacheRewardManifest];
for (let rotation = 0; rotation != RewardInfo.EnemyCachesFound; ++rotation) {
const drop = getRandomRewardByChance(deck[rotation]);
@ -2259,6 +2262,71 @@ function getRandomMissionDrops(
}
}
if (RewardInfo.EnemyCachesFound) {
if (RewardInfo.goalId) {
const goal = getWorldState().Goals.find(x => x._id.$oid == RewardInfo.goalId);
if (goal) {
let currentMissionKey: string | undefined;
if (RewardInfo.node == goal.Node) {
currentMissionKey = goal.MissionKeyName;
} else if (goal.ConcurrentNodes && goal.ConcurrentMissionKeyNames) {
for (let i = 0; i < goal.ConcurrentNodes.length; i++) {
if (RewardInfo.node == goal.ConcurrentNodes[i]) {
currentMissionKey = goal.ConcurrentMissionKeyNames[i];
break;
}
}
}
if (currentMissionKey) {
const keyMeta = ExportKeys[currentMissionKey];
if (keyMeta.cacheRewardManifest) {
const deck = ExportRewards[keyMeta.cacheRewardManifest];
for (let rotation = 0; rotation != RewardInfo.EnemyCachesFound; ++rotation) {
const drop = getRandomRewardByChance(deck[rotation]);
if (drop) {
drops.push({
StoreItem: drop.type,
ItemCount: drop.itemCount,
FromEnemyCache: true
});
}
}
}
}
}
} else if (RewardInfo.alertId) {
const alert = getWorldState().Alerts.find(x => x._id.$oid == RewardInfo.alertId);
if (alert && alert.MissionInfo.enemyCacheOverride) {
const deck = ExportRewards[alert.MissionInfo.enemyCacheOverride];
for (let rotation = 0; rotation != RewardInfo.EnemyCachesFound; ++rotation) {
const drop = getRandomRewardByChance(deck[rotation]);
if (drop) {
drops.push({
StoreItem: drop.type,
ItemCount: drop.itemCount,
FromEnemyCache: true
});
}
}
}
} else if (levelKeyName) {
const keyMeta = ExportKeys[levelKeyName];
if (keyMeta.cacheRewardManifest) {
const deck = ExportRewards[keyMeta.cacheRewardManifest];
for (let rotation = 0; rotation != RewardInfo.EnemyCachesFound; ++rotation) {
const drop = getRandomRewardByChance(deck[rotation]);
if (drop) {
drops.push({
StoreItem: drop.type,
ItemCount: drop.itemCount,
FromEnemyCache: true
});
}
}
}
}
}
if (inventory.missionsCanGiveAllRelics) {
for (const drop of drops) {
const itemType = fromStoreItem(drop.StoreItem);

View File

@ -58,6 +58,7 @@ export interface IAlertMissionInfo {
maxEnemyLevel?: number;
maxWaveNum?: number;
descText?: string;
enemyCacheOverride?: string;
maxRotations?: number; // SNS specific field
}