Remove server calculation of scav rep post raid changes. awaiting Client Calculations

This commit is contained in:
Kaeno 2024-03-21 15:21:02 +00:00
parent 04aad787d3
commit d5517d7fdf
4 changed files with 3 additions and 129 deletions

View File

@ -92,11 +92,6 @@ export class InraidCallbacks
return this.httpResponse.noBody(this.inraidController.getBTRConfig()); return this.httpResponse.noBody(this.inraidController.getBTRConfig());
} }
public getPostRaidFenceRepDifference(sessionId: string): number
{
return this.httpResponse.noBody(this.inraidController.getPostRaidFenceRepDifference(sessionId));
}
/** /**
* Handle singleplayer/traderServices/getTraderServices * Handle singleplayer/traderServices/getTraderServices
*/ */

View File

@ -586,23 +586,16 @@ export class InraidController
{ {
const fenceId = Traders.FENCE; const fenceId = Traders.FENCE;
const fenceStanding = Number(pmcData.TradersInfo[fenceId].standing); let fenceStanding = Number(offraidData.profile.TradersInfo[fenceId].standing);
let adjustedFenceStanding = this.inRaidHelper.calculateFenceStandingChangeFromKillsAsScav(
fenceStanding,
offraidData.profile.Stats.Eft.Victims,
);
// Successful extract with scav adds 0.01 standing // Successful extract with scav adds 0.01 standing
if (offraidData.exit === PlayerRaidEndState.SURVIVED) if (offraidData.exit === PlayerRaidEndState.SURVIVED)
{ {
adjustedFenceStanding += this.inRaidConfig.scavExtractGain; fenceStanding += this.inRaidConfig.scavExtractGain;
} }
// Store diff in profile for later retreval by client end-of-raid screen
pmcData.Stats.Eft.sptLastRaidFenceRepChange = adjustedFenceStanding - fenceStanding;
// Make standing changes to pmc profile // Make standing changes to pmc profile
pmcData.TradersInfo[fenceId].standing = Math.min(Math.max(adjustedFenceStanding, -7), 15); // Ensure it stays between -7 and 15 pmcData.TradersInfo[fenceId].standing = Math.min(Math.max(fenceStanding, -7), 15); // Ensure it stays between -7 and 15
this.logger.debug(`New fence standing: ${pmcData.TradersInfo[fenceId].standing}`); this.logger.debug(`New fence standing: ${pmcData.TradersInfo[fenceId].standing}`);
this.traderHelper.lvlUp(fenceId, pmcData); this.traderHelper.lvlUp(fenceId, pmcData);
pmcData.TradersInfo[fenceId].loyaltyLevel = Math.max(pmcData.TradersInfo[fenceId].loyaltyLevel, 1); pmcData.TradersInfo[fenceId].loyaltyLevel = Math.max(pmcData.TradersInfo[fenceId].loyaltyLevel, 1);
@ -635,21 +628,6 @@ export class InraidController
return this.btrConfig; return this.btrConfig;
} }
/**
* Get the rep diff stored post-raid
* @param sessionId Player id
* @returns Fence rep difference
*/
public getPostRaidFenceRepDifference(sessionId: string): number
{
const profile = this.profileHelper.getPmcProfile(sessionId);
const valueToReturn = profile.Stats?.Eft?.sptLastRaidFenceRepChange ?? 0;
delete profile.Stats?.Eft?.sptLastRaidFenceRepChange;
return valueToReturn;
}
/** /**
* Handle singleplayer/traderServices/getTraderServices * Handle singleplayer/traderServices/getTraderServices
* @returns Trader services data * @returns Trader services data

View File

@ -79,98 +79,6 @@ export class InRaidHelper
} }
} }
/**
* Add karma changes up and return the new value
* @param existingFenceStanding Current fence standing level
* @param victims Array of kills player performed
* @returns adjusted karma level after kills are taken into account
*/
public calculateFenceStandingChangeFromKillsAsScav(existingFenceStanding: number, victims: Victim[]): number
{
// Run callback on every victim, adding up the standings gained/lossed, starting value is existing fence standing
let fenceStanding = existingFenceStanding;
for (const victim of victims)
{
let standingChangeForKill = this.getFenceStandingChangeForKillAsScav(victim);
if (standingChangeForKill === 0)
{
// Nothing to do, skip
continue;
}
if (victim.Name?.includes(")") && victim.Side === "Savage")
{
// Make value positive if traitor scav
standingChangeForKill = Math.abs(standingChangeForKill);
}
const additionalLossForKill = this.getAdditionalLossForKill(fenceStanding, standingChangeForKill);
this.logger.warning(`rep change: ${standingChangeForKill} - additional: ${additionalLossForKill}`);
fenceStanding += standingChangeForKill + additionalLossForKill;
}
return fenceStanding;
}
protected getAdditionalLossForKill(fenceStanding: number, repChangeForKill: number): number
{
// No loss for kill, skip
if (repChangeForKill >= 0)
{
return 0;
}
// Over 8, big penalty
if (fenceStanding > 8)
{
return -2.0;
}
// Fence rep is between 6 and 8, appy additional penalty
if (fenceStanding >= 6)
{
return -1;
}
// No additional penalty
return 0;
}
/**
* Get the standing gain/loss for killing an npc
* @param victim Who was killed by player
* @returns a numerical standing gain or loss
*/
protected getFenceStandingChangeForKillAsScav(victim: Victim): number
{
const botTypes = this.databaseServer.getTables().bots.types;
if (victim.Side.toLowerCase() === "savage")
{
let standing = botTypes[victim.Role.toLowerCase()]?.experience?.standingForKill;
if (standing === undefined)
{
this.logger.warning(
`Unable to find standing for kill for: ${victim.Role}, side: ${victim.Side}, setting to: 0`,
);
standing = 0;
}
// Scavs and bosses
return standing;
}
// PMCs - get by bear/usec
let pmcStandingForKill = botTypes[victim.Side.toLowerCase()]?.experience?.standingForKill;
const pmcKillProbabilityForScavGain = this.inRaidConfig.pmcKillProbabilityForScavGain;
if (this.randomUtil.rollForChanceProbability(pmcKillProbabilityForScavGain))
{
pmcStandingForKill += this.inRaidConfig.scavExtractGain;
}
return pmcStandingForKill;
}
/** /**
* Reset a profile to a baseline, used post-raid * Reset a profile to a baseline, used post-raid
* Reset points earned during session property * Reset points earned during session property

View File

@ -48,13 +48,6 @@ export class InraidStaticRouter extends StaticRouter
return this.inraidCallbacks.getBTRConfig(); return this.inraidCallbacks.getBTRConfig();
}, },
), ),
new RouteAction(
"/singleplayer/getfencerepdiff",
(url: string, info: any, sessionID: string, output: string): any =>
{
return this.inraidCallbacks.getPostRaidFenceRepDifference(sessionID);
},
),
new RouteAction( new RouteAction(
"/singleplayer/traderServices/itemDelivery", "/singleplayer/traderServices/itemDelivery",
(url: string, info: any, sessionID: string, output: string): any => (url: string, info: any, sessionID: string, output: string): any =>