From e0717daa996af8647c5e7ba9358c6d1b109625b0 Mon Sep 17 00:00:00 2001 From: Scuvy Date: Thu, 6 Jun 2024 11:14:38 +0000 Subject: [PATCH] Send pity gift codes to player when player dies to other PMC's (!359) * This is to address [Issue 652](https://dev.sp-tarkov.com/SPT/Issues/issues/652). * Added messages with gift codes inside project/assets/database/locales/server/en.json * Update pmcchatresponse.json to include new pity message type. * Update logic in project/src/services/PmcChatResponseService.ts to now account for pity messages that are sent. The message's %giftcode% will now be replaced with a random gift code from assets\configs\gifts.json * Example: - ![image](/attachments/ade2686a-8dcb-4c11-9457-88e003a47416) Co-authored-by: Scuvy Co-authored-by: chomp Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/359 Co-authored-by: Scuvy Co-committed-by: Scuvy --- project/assets/configs/pmcchatresponse.json | 5 +++-- .../assets/database/locales/server/en.json | 16 +++++++++++++++ .../src/services/PmcChatResponseService.ts | 20 ++++++++++++++----- 3 files changed, 34 insertions(+), 7 deletions(-) diff --git a/project/assets/configs/pmcchatresponse.json b/project/assets/configs/pmcchatresponse.json index 5a73f2b7..527a90a4 100644 --- a/project/assets/configs/pmcchatresponse.json +++ b/project/assets/configs/pmcchatresponse.json @@ -15,10 +15,11 @@ "responseTypeWeights": { "positive": 5, "negative": 2, - "plead": 2 + "plead": 2, + "pity": 1 }, "stripCapitalisationChancePercent": 20, "allCapsChancePercent": 15, "appendBroToMessageEndChancePercent": 15 } -} \ No newline at end of file +} diff --git a/project/assets/database/locales/server/en.json b/project/assets/database/locales/server/en.json index 1b70db69..f1e52713 100644 --- a/project/assets/database/locales/server/en.json +++ b/project/assets/database/locales/server/en.json @@ -310,6 +310,22 @@ "pmcresponse-killer_negative_7": "No wonder you play SPT with your aim", "pmcresponse-killer_negative_8": "It is what it is", "pmcresponse-killer_negative_9": "Thanks for looting for me", + "pmcresponse-killer_pity_1": "Wow, those Scavs must have a personal vendetta against you. Here's a gift code: '%giftcode%'. Maybe they'll mistake you for a friend next time.", + "pmcresponse-killer_pity_2": "You died faster than I could say 'Friendly PMC!' Take this gift code: '%giftcode%' and maybe you'll last a little longer next time.", + "pmcresponse-killer_pity_3": "You're starting to make Scavs look like elite soldiers. Use this gift code: '%giftcode%' and show them who's boss.", + "pmcresponse-killer_pity_4": "If dying was an art, you'd be Picasso. Here's a gift code: '%giftcode%' to keep your masterpiece alive a bit longer.", + "pmcresponse-killer_pity_5": "Looks like those Scavs got the better of you again. Here, take this gift code: '%giftcode%'. Maybe it will help you survive next time.", + "pmcresponse-killer_pity_6": "That raid was brutal. I feel bad watching you struggle. Use this gift code: '%giftcode%' and maybe you'll have better luck.", + "pmcresponse-killer_pity_7": "Ouch, another failed extraction. Don't worry, take this gift code: '%giftcode%' and gear up for your next try.", + "pmcresponse-killer_pity_8": "It hurts to watch you get ambushed like that. Maybe this gift code: '%giftcode%' will turn things around for you.", + "pmcresponse-killer_pity_9": "Those PMC runs aren't going well, huh? Take this gift code: '%giftcode%' and give it another shot.", + "pmcresponse-killer_pity_10": "Another wipe and you're still struggling. This gift code: '%giftcode%' might give you the edge you need.", + "pmcresponse-killer_pity_11": "You keep getting Tarkov'd hard. Hopefully, this gift code: '%giftcode%' can help you catch a break.", + "pmcresponse-killer_pity_12": "Damn, looks like you need this gift code more than I do: '%giftcode%'. I've heard you can message SPT that code, and they will help you out. They're pretty friendly; they might even be on your friends list already.", + "pmcresponse-killer_pity_13": "You should probably turn your headphones back on. I feel bad I killed you like that, so here, have this gift code: '%giftcode%'.", + "pmcresponse-killer_pity_14": "I'll keep it real with you... You're trash, but don't despair. I did find this gift code I can give to you: '%giftcode%'.", + "pmcresponse-killer_pity_15": "Did your gun jam? I can't imagine any other reason you would have died back there. Oh well, I found this scribbled on a dead scav's notebook: '%giftcode%'. Not sure what it means, but maybe it will be useful to you.", + "pmcresponse-killer_pity_16": "You seem to be having a hard day. Maybe this gift code: '%giftcode%' will make it better.", "pmcresponse-killer_plead_1": "I was trying to extract a quest item and you were in my path", "pmcresponse-killer_plead_10": "Typical {{playerSide}} behaviour", "pmcresponse-killer_plead_11": "I need to kill {{playerSide}}, i hope you understand", diff --git a/project/src/services/PmcChatResponseService.ts b/project/src/services/PmcChatResponseService.ts index 135ed411..3eaab83a 100644 --- a/project/src/services/PmcChatResponseService.ts +++ b/project/src/services/PmcChatResponseService.ts @@ -7,6 +7,7 @@ import { IUserDialogInfo } from "@spt/models/eft/profile/ISptProfile"; import { ConfigTypes } from "@spt/models/enums/ConfigTypes"; import { MemberCategory } from "@spt/models/enums/MemberCategory"; import { MessageType } from "@spt/models/enums/MessageType"; +import { IGiftsConfig } from "@spt/models/spt/config/IGiftsConfig"; import { IPmcChatResponse } from "@spt/models/spt/config/IPmChatResponse"; import { ILogger } from "@spt/models/spt/utils/ILogger"; import { ConfigServer } from "@spt/servers/ConfigServer"; @@ -19,6 +20,7 @@ import { RandomUtil } from "@spt/utils/RandomUtil"; export class PmcChatResponseService { protected pmcResponsesConfig: IPmcChatResponse; + protected giftConfig: IGiftsConfig; constructor( @inject("PrimaryLogger") protected logger: ILogger, @@ -32,6 +34,7 @@ export class PmcChatResponseService ) { this.pmcResponsesConfig = this.configServer.getConfig(ConfigTypes.PMC_CHAT_RESPONSE); + this.giftConfig = this.configServer.getConfig(ConfigTypes.GIFTS); } /** @@ -82,10 +85,7 @@ export class PmcChatResponseService } // find bot by name in cache - const killerDetailsInCache = this.matchBotDetailsCacheService.getBotByNameAndSide( - killer.Name, - killer.Side, - ); + const killerDetailsInCache = this.matchBotDetailsCacheService.getBotByNameAndSide(killer.Name, killer.Side); if (!killerDetailsInCache) { return; @@ -108,12 +108,22 @@ export class PmcChatResponseService }, }; - const message = this.chooseMessage(false, pmcData); + let message = this.chooseMessage(false, pmcData); if (!message) { return; } + // Give the player a gift code if they were killed. + const regex: RegExp = /(%giftcode%)/gi; + if (regex.test(message)) + { + const giftKeys = Object.keys(this.giftConfig.gifts); + const randomGiftKey = this.randomUtil.getStringArrayValue(giftKeys); + + message = message.replace(regex, randomGiftKey); + } + this.notificationSendHelper.sendMessageToPlayer(sessionId, killerDetails, message, MessageType.USER_MESSAGE); }