0
0
mirror of https://github.com/sp-tarkov/server.git synced 2025-02-13 01:30:44 -05:00

Added system to insert items into bot storage areas during seasonal events - Used to add Christmas items to scavs

This commit is contained in:
Chomp 2024-12-18 23:51:25 +00:00
parent fae965797d
commit 7caec6efad
3 changed files with 70 additions and 3 deletions

View File

@ -231,6 +231,28 @@
} }
} }
}, },
"eventLoot": {
"christmas": {
"assault": {
"Pockets": {
"5df8a6a186f77412640e2e80": 3000,
"5df8a72c86f77412640e2e83": 3000,
"5df8a77486f77412672a1e3f": 3000
},
"Backpack": {
"5df8a6a186f77412640e2e80": 3000,
"5df8a72c86f77412640e2e83": 3000,
"5df8a77486f77412672a1e3f": 3000,
"63a8970d7108f713591149f5": 250
},
"TacticalVest": {
"5df8a6a186f77412640e2e80": 3000,
"5df8a72c86f77412640e2e83": 3000,
"5df8a77486f77412672a1e3f": 3000
}
}
}
},
"eventBotMapping": { "eventBotMapping": {
"peacefullZryachiyEvent": "bossZryachiy", "peacefullZryachiyEvent": "bossZryachiy",
"sectactPriestEvent": "sectantPriest", "sectactPriestEvent": "sectantPriest",

View File

@ -7,6 +7,8 @@ export interface ISeasonalEventConfig extends IBaseConfig {
enableSeasonalEventDetection: boolean; enableSeasonalEventDetection: boolean;
/** event / botType / equipSlot / itemid */ /** event / botType / equipSlot / itemid */
eventGear: Record<string, Record<string, Record<string, Record<string, number>>>>; eventGear: Record<string, Record<string, Record<string, Record<string, number>>>>;
/** event / bot type / equipSlot / itemid */
eventLoot: Record<string, Record<string, Record<string, Record<string, number>>>>;
events: ISeasonalEvent[]; events: ISeasonalEvent[];
eventBotMapping: Record<string, string>; eventBotMapping: Record<string, string>;
eventBossSpawns: Record<string, Record<string, IBossLocationSpawn[]>>; eventBossSpawns: Record<string, Record<string, IBossLocationSpawn[]>>;

View File

@ -178,6 +178,15 @@ export class SeasonalEventService {
return this.seasonalEventConfig.eventGear[eventType.toLowerCase()]; return this.seasonalEventConfig.eventGear[eventType.toLowerCase()];
} }
/**
* Get a dictionary of loot changes to apply to bots for a specific event e.g. Christmas/Halloween
* @param eventName Name of event to get gear changes for
* @returns bots with loot changes
*/
protected getEventBotLoot(eventType: SeasonalEventType): Record<string, Record<string, Record<string, number>>> {
return this.seasonalEventConfig.eventLoot[eventType.toLowerCase()];
}
/** /**
* Get the dates each seasonal event starts and ends at * Get the dates each seasonal event starts and ends at
* @returns Record with event name + start/end date * @returns Record with event name + start/end date
@ -385,6 +394,7 @@ export class SeasonalEventService {
globalConfig.EventType = globalConfig.EventType.filter((x) => x !== "None"); globalConfig.EventType = globalConfig.EventType.filter((x) => x !== "None");
globalConfig.EventType.push("Christmas"); globalConfig.EventType.push("Christmas");
this.addEventGearToBots(event.type); this.addEventGearToBots(event.type);
this.addEventLootToBots(event.type);
if (event.settings?.enableSanta) { if (event.settings?.enableSanta) {
this.addGifterBotToMaps(); this.addGifterBotToMaps();
this.addLootItemsToGifterDropItemsList(); this.addLootItemsToGifterDropItemsList();
@ -398,6 +408,7 @@ export class SeasonalEventService {
this.addLootItemsToGifterDropItemsList(); this.addLootItemsToGifterDropItemsList();
this.addEventGearToBots(SeasonalEventType.HALLOWEEN); this.addEventGearToBots(SeasonalEventType.HALLOWEEN);
this.addEventGearToBots(SeasonalEventType.CHRISTMAS); this.addEventGearToBots(SeasonalEventType.CHRISTMAS);
this.addEventLootToBots(SeasonalEventType.CHRISTMAS);
this.addEventBossesToMaps(SeasonalEventType.HALLOWEEN); this.addEventBossesToMaps(SeasonalEventType.HALLOWEEN);
this.enableHalloweenSummonEvent(); this.enableHalloweenSummonEvent();
this.addPumpkinsToScavBackpacks(); this.addPumpkinsToScavBackpacks();
@ -663,8 +674,8 @@ export class SeasonalEventService {
} }
// Iterate over each equipment slot change // Iterate over each equipment slot change
const gearAmendments = botGearChanges[bot]; const gearAmendmentsBySlot = botGearChanges[bot];
for (const equipmentSlot in gearAmendments) { for (const equipmentSlot in gearAmendmentsBySlot) {
// Adjust slots spawn chance to be at least 75% // Adjust slots spawn chance to be at least 75%
botToUpdate.chances.equipment[equipmentSlot] = Math.max( botToUpdate.chances.equipment[equipmentSlot] = Math.max(
botToUpdate.chances.equipment[equipmentSlot], botToUpdate.chances.equipment[equipmentSlot],
@ -672,7 +683,7 @@ export class SeasonalEventService {
); );
// Grab gear to add and loop over it // Grab gear to add and loop over it
const itemsToAdd = gearAmendments[equipmentSlot]; const itemsToAdd = gearAmendmentsBySlot[equipmentSlot];
for (const itemTplIdToAdd in itemsToAdd) { for (const itemTplIdToAdd in itemsToAdd) {
botToUpdate.inventory.equipment[equipmentSlot][itemTplIdToAdd] = itemsToAdd[itemTplIdToAdd]; botToUpdate.inventory.equipment[equipmentSlot][itemTplIdToAdd] = itemsToAdd[itemTplIdToAdd];
} }
@ -680,6 +691,38 @@ export class SeasonalEventService {
} }
} }
/**
* Read in data from seasonalEvents.json and add found loot items to bots
* @param eventName Name of the event to read loot in from config
*/
protected addEventLootToBots(eventType: SeasonalEventType): void {
const botLootChanges = this.getEventBotLoot(eventType);
if (!botLootChanges) {
this.logger.warning(this.localisationService.getText("gameevent-no_gear_data", eventType));
return;
}
// Iterate over bots with changes to apply
for (const bot in botLootChanges) {
const botToUpdate = this.databaseService.getBots().types[bot.toLowerCase()];
if (!botToUpdate) {
this.logger.warning(this.localisationService.getText("gameevent-bot_not_found", bot));
continue;
}
// Iterate over each loot slot change
const lootAmendmentsBySlot = botLootChanges[bot];
for (const slotKey in lootAmendmentsBySlot) {
// Grab loot to add and loop over it
const itemTplsToAdd = lootAmendmentsBySlot[slotKey];
for (const tpl in itemTplsToAdd) {
botToUpdate.inventory.items[slotKey][tpl] = itemTplsToAdd[tpl];
}
}
}
}
/** /**
* Add pumpkin loot boxes to scavs * Add pumpkin loot boxes to scavs
*/ */