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
This commit is contained in:
Dev 2023-07-22 23:23:42 +01:00
parent b235bba374
commit 618a41fcd9
5 changed files with 125 additions and 11 deletions

View File

@ -694,7 +694,7 @@
"randomisedArmorSlots": ["Headwear"], "randomisedArmorSlots": ["Headwear"],
"randomisedWeaponModSlots": ["mod_scope", "mod_scope_000", "mod_scope_001", "mod_scope_002", "mod_scope_003", "randomisedWeaponModSlots": ["mod_scope", "mod_scope_000", "mod_scope_001", "mod_scope_002", "mod_scope_003",
"mod_handguard", "mod_magazine", "mod_muzzle", "mod_bipod", "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_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_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", "mod_mount_000", "mod_mount_001", "mod_mount_002", "mod_mount_003", "mod_mount_004", "mod_mount_005", "mod_mount_006",

View File

@ -63,7 +63,7 @@
"upd": { "upd": {
"StackObjectsCount": 1 "StackObjectsCount": 1
} }
}, }
], ],
"sender": "System", "sender": "System",
"messageText": "Merry christmas!", "messageText": "Merry christmas!",
@ -501,6 +501,60 @@
"messageText": "HESOYAM", "messageText": "HESOYAM",
"collectionTimeHours": 48, "collectionTimeHours": 48,
"associatedEvent": "Promo" "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
} }
} }
} }

View File

@ -25,6 +25,7 @@ import { ILogger } from "../models/spt/utils/ILogger";
import { ConfigServer } from "../servers/ConfigServer"; import { ConfigServer } from "../servers/ConfigServer";
import { DatabaseServer } from "../servers/DatabaseServer"; import { DatabaseServer } from "../servers/DatabaseServer";
import { CustomLocationWaveService } from "../services/CustomLocationWaveService"; import { CustomLocationWaveService } from "../services/CustomLocationWaveService";
import { GiftService } from "../services/GiftService";
import { LocalisationService } from "../services/LocalisationService"; import { LocalisationService } from "../services/LocalisationService";
import { OpenZoneService } from "../services/OpenZoneService"; import { OpenZoneService } from "../services/OpenZoneService";
import { ProfileFixerService } from "../services/ProfileFixerService"; import { ProfileFixerService } from "../services/ProfileFixerService";
@ -57,6 +58,7 @@ export class GameController
@inject("CustomLocationWaveService") protected customLocationWaveService: CustomLocationWaveService, @inject("CustomLocationWaveService") protected customLocationWaveService: CustomLocationWaveService,
@inject("OpenZoneService") protected openZoneService: OpenZoneService, @inject("OpenZoneService") protected openZoneService: OpenZoneService,
@inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService, @inject("SeasonalEventService") protected seasonalEventService: SeasonalEventService,
@inject("GiftService") protected giftService: GiftService,
@inject("ApplicationContext") protected applicationContext: ApplicationContext, @inject("ApplicationContext") protected applicationContext: ApplicationContext,
@inject("ConfigServer") protected configServer: ConfigServer @inject("ConfigServer") protected configServer: ConfigServer
) )
@ -124,6 +126,8 @@ export class GameController
this.splitBotWavesIntoSingleWaves(); this.splitBotWavesIntoSingleWaves();
} }
this.sendPraporGiftsToNewProfiles(pmcProfile);
this.profileFixerService.removeLegacyScavCaseProductionCrafts(pmcProfile); this.profileFixerService.removeLegacyScavCaseProductionCrafts(pmcProfile);
this.profileFixerService.addMissingHideoutAreasToProfile(fullProfile); 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 * 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
*/ */

View File

@ -23,6 +23,8 @@ export interface Gift
/** Optional - supply a trader type to send from, not necessary when sending from SYSTEM or USER */ /** Optional - supply a trader type to send from, not necessary when sending from SYSTEM or USER */
trader?: Traders trader?: Traders
messageText: string messageText: string
/** Optional - if sending text from the client locale file */
localeTextId?: string
/** Optional - Used by Seasonal events to send on specific day */ /** Optional - Used by Seasonal events to send on specific day */
timestampToSend?: number timestampToSend?: number
associatedEvent: SeasonalEventType associatedEvent: SeasonalEventType

View File

@ -4,6 +4,7 @@ import { ConfigTypes } from "../models/enums/ConfigTypes";
import { GiftSenderType } from "../models/enums/GiftSenderType"; import { GiftSenderType } from "../models/enums/GiftSenderType";
import { GiftSentResult } from "../models/enums/GiftSentResult"; import { GiftSentResult } from "../models/enums/GiftSentResult";
import { MessageType } from "../models/enums/MessageType"; import { MessageType } from "../models/enums/MessageType";
import { Traders } from "../models/enums/Traders";
import { Gift, IGiftsConfig } from "../models/spt/config/IGiftsConfig"; import { Gift, IGiftsConfig } from "../models/spt/config/IGiftsConfig";
import { ISendMessageDetails } from "../models/spt/dialog/ISendMessageDetails"; import { ISendMessageDetails } from "../models/spt/dialog/ISendMessageDetails";
import { ILogger } from "../models/spt/utils/ILogger"; import { ILogger } from "../models/spt/utils/ILogger";
@ -80,6 +81,18 @@ export class GiftService
this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours)); this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours));
} }
else if (giftData.sender === GiftSenderType.TRADER) else if (giftData.sender === GiftSenderType.TRADER)
{
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( this.mailSendService.sendDirectNpcMessageToPlayer(
playerId, playerId,
@ -89,6 +102,9 @@ export class GiftService
giftData.items, giftData.items,
this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours)); this.timeUtil.getHoursAsSeconds(giftData.collectionTimeHours));
} }
}
else else
{ {
// TODO: further split out into different message systems like above SYSTEM method // TODO: further split out into different message systems like above SYSTEM method
@ -124,7 +140,7 @@ export class GiftService
{ {
if (giftData.sender === GiftSenderType.TRADER) if (giftData.sender === GiftSenderType.TRADER)
{ {
return giftData.trader; return Traders[giftData.trader];
} }
if (giftData.sender === GiftSenderType.USER) if (giftData.sender === GiftSenderType.USER)
@ -153,4 +169,23 @@ export class GiftService
break; 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;
}
}
} }