From ad782e59067b414db3835e5c82d8482ac6a2ded8 Mon Sep 17 00:00:00 2001 From: Chomp Date: Sun, 19 Jan 2025 19:16:23 +0000 Subject: [PATCH] Replicated Mechanic sending player a measuring tape on profile creation --- project/assets/configs/gifts.json | 18 ++++++++++++++++++ project/src/controllers/GameController.ts | 10 ++++++++++ project/src/services/GiftService.ts | 13 ++++++++++++- 3 files changed, 40 insertions(+), 1 deletion(-) diff --git a/project/assets/configs/gifts.json b/project/assets/configs/gifts.json index 6d4600522..69c97b305 100644 --- a/project/assets/configs/gifts.json +++ b/project/assets/configs/gifts.json @@ -1300,6 +1300,24 @@ "collectionTimeHours": 48, "maxToSendPlayer": 5 }, + "MechanicGiftDay1": { + "items": [ + { + "_id": "678d4d81189b5f2a7538f14d", + "_tpl": "590c2c9c86f774245b1f03f2", + "slotId": "main", + "upd": { + "StackObjectsCount": 1 + }, + "parentId": "678d4d90fc70718b8c4067ad" + } + ], + "sender": "Trader", + "trader": "MECHANIC", + "localeTextId": "6776e324810eb26b880fb4a5 0", + "collectionTimeHours": 72, + "maxToSendPlayer": 1 + }, "KAPPA4U": { "items": [ { diff --git a/project/src/controllers/GameController.ts b/project/src/controllers/GameController.ts index 773152698..820201a09 100644 --- a/project/src/controllers/GameController.ts +++ b/project/src/controllers/GameController.ts @@ -186,6 +186,8 @@ export class GameController { if (pmcProfile.Inventory) { this.sendPraporGiftsToNewProfiles(pmcProfile); + this.sendMechanicGiftsToNewProfile(pmcProfile); + this.profileFixerService.checkForOrphanedModdedItems(sessionID, fullProfile); } @@ -632,6 +634,14 @@ export class GameController { } } + /** + * Mechanic sends players a measuring tape on profile start for some reason + * @param pmcProfile + */ + protected sendMechanicGiftsToNewProfile(pmcProfile: IPmcData) { + this.giftService.sendGiftWithSilentReceivedCheck("MechanicGiftDay1", pmcProfile.sessionId, 1); + } + /** * Get a list of installed mods and save their details to the profile being used * @param fullProfile Profile to add mod details to diff --git a/project/src/services/GiftService.ts b/project/src/services/GiftService.ts index a349feaa4..5c967d0fe 100644 --- a/project/src/services/GiftService.ts +++ b/project/src/services/GiftService.ts @@ -216,11 +216,22 @@ export class GiftService { } if (giftId) { - const giftData = this.getGiftById(giftId); if (!this.profileHelper.playerHasRecievedMaxNumberOfGift(sessionId, giftId, 1)) { // Hard-coded to send only one this.sendGiftToPlayer(sessionId, giftId); } } } + + /** + * Send player a gift with silent recieved check + * @param giftId Id of gift to send + * @param sessionId Session id of player to send to + * @param giftCount OPTIONAL How many to send + */ + public sendGiftWithSilentReceivedCheck(giftId: string, sessionId: string, giftCount = 1) { + if (!this.profileHelper.playerHasRecievedMaxNumberOfGift(sessionId, giftId, giftCount)) { + this.sendGiftToPlayer(sessionId, giftId); + } + } }