mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-13 09:50:43 -05:00
Remove FiR status from items on run through. Added toggle to always keep FiR status on items regardless of end raid status
This commit is contained in:
parent
386b93e7e6
commit
171fdfd6dd
@ -27,5 +27,6 @@
|
|||||||
"scavExtractGain": 0.01,
|
"scavExtractGain": 0.01,
|
||||||
"pmcKillProbabilityForScavGain": 0.2,
|
"pmcKillProbabilityForScavGain": 0.2,
|
||||||
"keepFiRSecureContainerOnDeath": false,
|
"keepFiRSecureContainerOnDeath": false,
|
||||||
|
"alwaysKeepFoundInRaidonRaidEnd": true,
|
||||||
"playerScavHostileChancePercent": 15
|
"playerScavHostileChancePercent": 15
|
||||||
}
|
}
|
||||||
|
@ -3,15 +3,18 @@ import { ItemHelper } from "@spt/helpers/ItemHelper";
|
|||||||
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
import { IPmcData } from "@spt/models/eft/common/IPmcData";
|
||||||
import { Item } from "@spt/models/eft/common/tables/IItem";
|
import { Item } from "@spt/models/eft/common/tables/IItem";
|
||||||
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
import { ConfigTypes } from "@spt/models/enums/ConfigTypes";
|
||||||
|
import { IInRaidConfig } from "@spt/models/spt/config/IInRaidConfig";
|
||||||
import { ILostOnDeathConfig } from "@spt/models/spt/config/ILostOnDeathConfig";
|
import { ILostOnDeathConfig } from "@spt/models/spt/config/ILostOnDeathConfig";
|
||||||
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
import { ILogger } from "@spt/models/spt/utils/ILogger";
|
||||||
import { ConfigServer } from "@spt/servers/ConfigServer";
|
import { ConfigServer } from "@spt/servers/ConfigServer";
|
||||||
|
import { DatabaseService } from "@spt/services/DatabaseService";
|
||||||
import { ICloner } from "@spt/utils/cloners/ICloner";
|
import { ICloner } from "@spt/utils/cloners/ICloner";
|
||||||
import { inject, injectable } from "tsyringe";
|
import { inject, injectable } from "tsyringe";
|
||||||
|
|
||||||
@injectable()
|
@injectable()
|
||||||
export class InRaidHelper {
|
export class InRaidHelper {
|
||||||
protected lostOnDeathConfig: ILostOnDeathConfig;
|
protected lostOnDeathConfig: ILostOnDeathConfig;
|
||||||
|
protected inRaidConfig: IInRaidConfig;
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
@inject("PrimaryLogger") protected logger: ILogger,
|
@inject("PrimaryLogger") protected logger: ILogger,
|
||||||
@ -19,8 +22,10 @@ export class InRaidHelper {
|
|||||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||||
@inject("ConfigServer") protected configServer: ConfigServer,
|
@inject("ConfigServer") protected configServer: ConfigServer,
|
||||||
@inject("PrimaryCloner") protected cloner: ICloner,
|
@inject("PrimaryCloner") protected cloner: ICloner,
|
||||||
|
@inject("DatabaseService") protected databaseService: DatabaseService,
|
||||||
) {
|
) {
|
||||||
this.lostOnDeathConfig = this.configServer.getConfig(ConfigTypes.LOST_ON_DEATH);
|
this.lostOnDeathConfig = this.configServer.getConfig(ConfigTypes.LOST_ON_DEATH);
|
||||||
|
this.inRaidConfig = this.configServer.getConfig(ConfigTypes.IN_RAID);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -43,7 +48,12 @@ export class InRaidHelper {
|
|||||||
* @param serverProfile Profile to update
|
* @param serverProfile Profile to update
|
||||||
* @param postRaidProfile Profile returned by client after a raid
|
* @param postRaidProfile Profile returned by client after a raid
|
||||||
*/
|
*/
|
||||||
public setInventory(sessionID: string, serverProfile: IPmcData, postRaidProfile: IPmcData): void {
|
public setInventory(
|
||||||
|
sessionID: string,
|
||||||
|
serverProfile: IPmcData,
|
||||||
|
postRaidProfile: IPmcData,
|
||||||
|
isSurvived: boolean,
|
||||||
|
): void {
|
||||||
// Store insurance (as removeItem() removes insurance also)
|
// Store insurance (as removeItem() removes insurance also)
|
||||||
const insured = this.cloner.clone(serverProfile.InsuredItems);
|
const insured = this.cloner.clone(serverProfile.InsuredItems);
|
||||||
|
|
||||||
@ -52,12 +62,46 @@ export class InRaidHelper {
|
|||||||
this.inventoryHelper.removeItem(serverProfile, serverProfile.Inventory.questRaidItems, sessionID);
|
this.inventoryHelper.removeItem(serverProfile, serverProfile.Inventory.questRaidItems, sessionID);
|
||||||
this.inventoryHelper.removeItem(serverProfile, serverProfile.Inventory.sortingTable, sessionID);
|
this.inventoryHelper.removeItem(serverProfile, serverProfile.Inventory.sortingTable, sessionID);
|
||||||
|
|
||||||
|
// Handle Removing of FIR status if did not survive.
|
||||||
|
if (!isSurvived && !this.inRaidConfig.alwaysKeepFoundInRaidonRaidEnd) {
|
||||||
|
this.removeSpawnedInSessionPropertyFromItems(postRaidProfile);
|
||||||
|
}
|
||||||
|
|
||||||
// Add the new items
|
// Add the new items
|
||||||
serverProfile.Inventory.items = [...postRaidProfile.Inventory.items, ...serverProfile.Inventory.items];
|
serverProfile.Inventory.items = [...postRaidProfile.Inventory.items, ...serverProfile.Inventory.items];
|
||||||
serverProfile.Inventory.fastPanel = postRaidProfile.Inventory.fastPanel; // Quick access items bar
|
serverProfile.Inventory.fastPanel = postRaidProfile.Inventory.fastPanel; // Quick access items bar
|
||||||
serverProfile.InsuredItems = insured;
|
serverProfile.InsuredItems = insured;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Iterate over inventory items and remove the property that defines an item as Found in Raid
|
||||||
|
* Only removes property if item had FiR when entering raid
|
||||||
|
* @param postRaidProfile profile to update items for
|
||||||
|
* @returns Updated profile with SpawnedInSession removed
|
||||||
|
*/
|
||||||
|
public removeSpawnedInSessionPropertyFromItems(postRaidProfile: IPmcData): IPmcData {
|
||||||
|
const dbItems = this.databaseService.getItems();
|
||||||
|
const itemsToRemovePropertyFrom = postRaidProfile.Inventory.items.filter((item) => {
|
||||||
|
// Has upd object + upd.SpawnedInSession property + not a quest item
|
||||||
|
return (
|
||||||
|
"upd" in item &&
|
||||||
|
"SpawnedInSession" in item.upd &&
|
||||||
|
!dbItems[item._tpl]._props.QuestItem &&
|
||||||
|
!(
|
||||||
|
this.inRaidConfig.keepFiRSecureContainerOnDeath &&
|
||||||
|
this.itemHelper.itemIsInsideContainer(item, "SecuredContainer", postRaidProfile.Inventory.items)
|
||||||
|
)
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
for (const item of itemsToRemovePropertyFrom) {
|
||||||
|
// biome-ignore lint/performance/noDelete: <explanation>
|
||||||
|
delete item.upd.SpawnedInSession;
|
||||||
|
}
|
||||||
|
|
||||||
|
return postRaidProfile;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Clear PMC inventory of all items except those that are exempt
|
* Clear PMC inventory of all items except those that are exempt
|
||||||
* Used post-raid to remove items after death
|
* Used post-raid to remove items after death
|
||||||
|
@ -20,6 +20,8 @@ export interface IInRaidConfig extends IBaseConfig {
|
|||||||
pmcKillProbabilityForScavGain: number;
|
pmcKillProbabilityForScavGain: number;
|
||||||
/** On death should items in your secure keep their Find in raid status regardless of how you finished the raid */
|
/** On death should items in your secure keep their Find in raid status regardless of how you finished the raid */
|
||||||
keepFiRSecureContainerOnDeath: boolean;
|
keepFiRSecureContainerOnDeath: boolean;
|
||||||
|
/** If enabled always keep found in raid status on items */
|
||||||
|
alwaysKeepFoundInRaidonRaidEnd: boolean;
|
||||||
/** Percentage chance a player scav hot is hostile to the player when scavving */
|
/** Percentage chance a player scav hot is hostile to the player when scavving */
|
||||||
playerScavHostileChancePercent: number;
|
playerScavHostileChancePercent: number;
|
||||||
}
|
}
|
||||||
|
@ -188,6 +188,7 @@ export class LocationLifecycleService {
|
|||||||
const isPmc = serverDetails[1].toLowerCase() === "pmc";
|
const isPmc = serverDetails[1].toLowerCase() === "pmc";
|
||||||
const mapBase = this.databaseService.getLocation(locationName).base;
|
const mapBase = this.databaseService.getLocation(locationName).base;
|
||||||
const isDead = this.isPlayerDead(request.results);
|
const isDead = this.isPlayerDead(request.results);
|
||||||
|
const isSurvived = this.isPlayerSurvived(request.results);
|
||||||
|
|
||||||
if (!isPmc) {
|
if (!isPmc) {
|
||||||
this.handlePostRaidPlayerScav(sessionId, pmcProfile, scavProfile, isDead, request);
|
this.handlePostRaidPlayerScav(sessionId, pmcProfile, scavProfile, isDead, request);
|
||||||
@ -195,7 +196,16 @@ export class LocationLifecycleService {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.handlePostRaidPmc(sessionId, pmcProfile, scavProfile, postRaidProfile, isDead, request, locationName);
|
this.handlePostRaidPmc(
|
||||||
|
sessionId,
|
||||||
|
pmcProfile,
|
||||||
|
scavProfile,
|
||||||
|
postRaidProfile,
|
||||||
|
isDead,
|
||||||
|
isSurvived,
|
||||||
|
request,
|
||||||
|
locationName,
|
||||||
|
);
|
||||||
|
|
||||||
// Handle car extracts
|
// Handle car extracts
|
||||||
if (this.extractWasViaCar(request.results.exitName)) {
|
if (this.extractWasViaCar(request.results.exitName)) {
|
||||||
@ -420,11 +430,12 @@ export class LocationLifecycleService {
|
|||||||
scavProfile: IPmcData,
|
scavProfile: IPmcData,
|
||||||
postRaidProfile: IPmcData,
|
postRaidProfile: IPmcData,
|
||||||
isDead: boolean,
|
isDead: boolean,
|
||||||
|
isSurvived: boolean,
|
||||||
request: IEndLocalRaidRequestData,
|
request: IEndLocalRaidRequestData,
|
||||||
locationName: string,
|
locationName: string,
|
||||||
): void {
|
): void {
|
||||||
// Update inventory
|
// Update inventory
|
||||||
this.inRaidHelper.setInventory(sessionId, pmcProfile, postRaidProfile);
|
this.inRaidHelper.setInventory(sessionId, pmcProfile, postRaidProfile, isSurvived);
|
||||||
|
|
||||||
pmcProfile.Info.Level = postRaidProfile.Info.Level;
|
pmcProfile.Info.Level = postRaidProfile.Info.Level;
|
||||||
pmcProfile.Skills = postRaidProfile.Skills;
|
pmcProfile.Skills = postRaidProfile.Skills;
|
||||||
@ -637,6 +648,15 @@ export class LocationLifecycleService {
|
|||||||
return inventoryItems;
|
return inventoryItems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Checks to see if player survives. run through will return false
|
||||||
|
* @param statusOnExit Exit value from offraidData object
|
||||||
|
* @returns true if Survived
|
||||||
|
*/
|
||||||
|
protected isPlayerSurvived(results: IEndRaidResult): boolean {
|
||||||
|
return results.result.toLowerCase() === "survived";
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is the player dead after a raid - dead = anything other than "survived" / "runner"
|
* Is the player dead after a raid - dead = anything other than "survived" / "runner"
|
||||||
* @param statusOnExit Exit value from offraidData object
|
* @param statusOnExit Exit value from offraidData object
|
||||||
|
Loading…
x
Reference in New Issue
Block a user