From 618a41fcd911921e5a90307648af5e2931781481 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 22 Jul 2023 23:23:42 +0100 Subject: [PATCH] Add system to make prapor give giffts the first and second day after starting a fresh character Add functionality to handle gift service to use locale ids instead of raw text --- project/assets/configs/bot.json | 2 +- project/assets/configs/gifts.json | 58 ++++++++++++++++++- project/src/controllers/GameController.ts | 23 ++++++++ project/src/models/spt/config/IGiftsConfig.ts | 2 + project/src/services/GiftService.ts | 51 +++++++++++++--- 5 files changed, 125 insertions(+), 11 deletions(-) diff --git a/project/assets/configs/bot.json b/project/assets/configs/bot.json index 5b5aee3a..e8dd75e9 100644 --- a/project/assets/configs/bot.json +++ b/project/assets/configs/bot.json @@ -694,7 +694,7 @@ "randomisedArmorSlots": ["Headwear"], "randomisedWeaponModSlots": ["mod_scope", "mod_scope_000", "mod_scope_001", "mod_scope_002", "mod_scope_003", "mod_handguard", "mod_magazine", "mod_muzzle", "mod_bipod", - "mod_muzzle_000", "mod_charge", "mod_reciever", + "mod_muzzle_000", "mod_charge", "mod_reciever", "mod_hammer", "mod_trigger", "mod_gas_block", "mod_pistol_grip", "mod_pistol_grip_akms", "mod_foregrip", "mod_stock", "mod_stock_000", "mod_stock_001", "mod_stock_akms", "mod_stock_axis", "mod_mount_000", "mod_mount_001", "mod_mount_002", "mod_mount_003", "mod_mount_004", "mod_mount_005", "mod_mount_006", diff --git a/project/assets/configs/gifts.json b/project/assets/configs/gifts.json index c5ba78c4..7c787491 100644 --- a/project/assets/configs/gifts.json +++ b/project/assets/configs/gifts.json @@ -63,7 +63,7 @@ "upd": { "StackObjectsCount": 1 } - }, + } ], "sender": "System", "messageText": "Merry christmas!", @@ -501,6 +501,60 @@ "messageText": "HESOYAM", "collectionTimeHours": 48, "associatedEvent": "Promo" - } + }, + "PraporGiftDay1": { + "items": [ + { + "_id": "a89275c1b18874ed6402a6d7", + "_tpl": "544fb45d4bdc2dee738b4568", + "upd": { + "StackObjectsCount": 1 + } + },{ + "_id": "a8927tryb15624ed6d02a6d7", + "_tpl": "5d02778e86f774203e7dedbe", + "upd": { + "StackObjectsCount": 1 + } + },{ + "_id": "a8927tgyg55674ed6d02a6d7", + "_tpl": "6034d0230ca681766b6a0fb5", + "upd": { + "StackObjectsCount": 1 + } + } + ], + "sender": "Trader", + "trader": "PRAPOR", + "localeTextId": "5fd4c8b59e4b2a58b34bbd28 0", + "collectionTimeHours": 48 + }, + "PraporGiftDay2": { + "items": [ + { + "_id": "a89275c1b18874ed7452a6d7", + "_tpl": "5751a25924597722c463c472", + "upd": { + "StackObjectsCount": 2 + } + },{ + "_id": "a8927tgyb15674ed6d02a6d7", + "_tpl": "5ca20d5986f774331e7c9602", + "upd": { + "StackObjectsCount": 1 + } + },{ + "_id": "a8927tgyb15674ed6d02oyj7", + "_tpl": "5755356824597772cb798962", + "upd": { + "StackObjectsCount": 3 + } + } + ], + "sender": "Trader", + "trader": "PRAPOR", + "localeTextId": "5fd4c8d49e4b2a58b34bbd29 0", + "collectionTimeHours": 48 + } } } diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 401a7848..cb0f61d5 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -25,6 +25,7 @@ import { ILogger } from "../models/spt/utils/ILogger"; import { ConfigServer } from "../servers/ConfigServer"; import { DatabaseServer } from "../servers/DatabaseServer"; import { CustomLocationWaveService } from "../services/CustomLocationWaveService"; +import { GiftService } from "../services/GiftService"; import { LocalisationService } from "../services/LocalisationService"; import { OpenZoneService } from "../services/OpenZoneService"; import { ProfileFixerService } from "../services/ProfileFixerService"; @@ -57,6 +58,7 @@ export class GameController @inject("CustomLocationWaveService") protected customLocationWaveService: CustomLocationWaveService, @inject("OpenZoneService") protected openZoneService: OpenZoneService, @inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService, + @inject("GiftService") protected giftService: GiftService, @inject("ApplicationContext") protected applicationContext: ApplicationContext, @inject("ConfigServer") protected configServer: ConfigServer ) @@ -124,6 +126,8 @@ export class GameController this.splitBotWavesIntoSingleWaves(); } + this.sendPraporGiftsToNewProfiles(pmcProfile); + this.profileFixerService.removeLegacyScavCaseProductionCrafts(pmcProfile); this.profileFixerService.addMissingHideoutAreasToProfile(fullProfile); @@ -459,6 +463,25 @@ export class GameController } } + protected sendPraporGiftsToNewProfiles(pmcProfile: IPmcData): void + { + const timeStampProfileCreated = pmcProfile.Info.RegistrationDate; + const oneDaySeconds = this.timeUtil.getHoursAsSeconds(24); + const currentTimeStamp = this.timeUtil.getTimestamp(); + + // One day post-profile creation + if ((timeStampProfileCreated + oneDaySeconds) > currentTimeStamp) + { + this.giftService.sendPraporStartingGift(pmcProfile.aid, 1); + } + + // Two day post-profile creation + if ((timeStampProfileCreated + (oneDaySeconds * 2)) > currentTimeStamp) + { + this.giftService.sendPraporStartingGift(pmcProfile.aid, 2); + } + } + /** * Find and split waves with large numbers of bots into smaller waves - BSG appears to reduce the size of these waves to one bot when they're waiting to spawn for too long */ diff --git a/project/src/models/spt/config/IGiftsConfig.ts b/project/src/models/spt/config/IGiftsConfig.ts index 21d33bf5..2e17439c 100644 --- a/project/src/models/spt/config/IGiftsConfig.ts +++ b/project/src/models/spt/config/IGiftsConfig.ts @@ -23,6 +23,8 @@ export interface Gift /** Optional - supply a trader type to send from, not necessary when sending from SYSTEM or USER */ trader?: Traders messageText: string + /** Optional - if sending text from the client locale file */ + localeTextId?: string /** Optional - Used by Seasonal events to send on specific day */ timestampToSend?: number associatedEvent: SeasonalEventType diff --git a/project/src/services/GiftService.ts b/project/src/services/GiftService.ts index 431d4ba0..020b1399 100644 --- a/project/src/services/GiftService.ts +++ b/project/src/services/GiftService.ts @@ -4,6 +4,7 @@ import { ConfigTypes } from "../models/enums/ConfigTypes"; import { GiftSenderType } from "../models/enums/GiftSenderType"; import { GiftSentResult } from "../models/enums/GiftSentResult"; import { MessageType } from "../models/enums/MessageType"; +import { Traders } from "../models/enums/Traders"; import { Gift, IGiftsConfig } from "../models/spt/config/IGiftsConfig"; import { ISendMessageDetails } from "../models/spt/dialog/ISendMessageDetails"; import { ILogger } from "../models/spt/utils/ILogger"; @@ -81,13 +82,28 @@ export class GiftService } else if (giftData.sender === GiftSenderType.TRADER) { - this.mailSendService.sendDirectNpcMessageToPlayer( - playerId, - giftData.trader, - MessageType.MESSAGE_WITH_ITEMS, - giftData.messageText, - giftData.items, - this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours)); + if (giftData.localeTextId) + { + this.mailSendService.sendLocalisedNpcMessageToPlayer( + playerId, + giftData.trader, + MessageType.MESSAGE_WITH_ITEMS, + giftData.localeTextId, + giftData.items, + this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours)); + } + else + { + this.mailSendService.sendDirectNpcMessageToPlayer( + playerId, + giftData.trader, + MessageType.MESSAGE_WITH_ITEMS, + giftData.messageText, + giftData.items, + this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours)); + } + + } else { @@ -124,7 +140,7 @@ export class GiftService { if (giftData.sender === GiftSenderType.TRADER) { - return giftData.trader; + return Traders[giftData.trader]; } if (giftData.sender === GiftSenderType.USER) @@ -153,4 +169,23 @@ export class GiftService break; } } + + /** + * Prapor sends gifts to player for first week after profile creation + * @param sessionId Player id + * @param day What day to give gift for + */ + public sendPraporStartingGift(sessionId: string, day: number): void + { + switch (day) + { + case 1: + this.sendGiftToPlayer(sessionId, "PraporGiftDay1"); + break; + case 2: + this.sendGiftToPlayer(sessionId, "PraporGiftDay2"); + break; + } + + } } \ No newline at end of file