Skip to content

Commit

Permalink
Replicated Mechanic sending player a measuring tape on profile creation
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomp committed Jan 19, 2025
1 parent bef38fd commit ad782e5
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 1 deletion.
18 changes: 18 additions & 0 deletions project/assets/configs/gifts.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": [
{
Expand Down
10 changes: 10 additions & 0 deletions project/src/controllers/GameController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,6 +186,8 @@ export class GameController {
if (pmcProfile.Inventory) {
this.sendPraporGiftsToNewProfiles(pmcProfile);

this.sendMechanicGiftsToNewProfile(pmcProfile);

this.profileFixerService.checkForOrphanedModdedItems(sessionID, fullProfile);
}

Expand Down Expand Up @@ -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
Expand Down
13 changes: 12 additions & 1 deletion project/src/services/GiftService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}

0 comments on commit ad782e5

Please sign in to comment.