Add Charisma points when insuring items
, points to reward is a total guess until data can be obtained
This commit is contained in:
parent
938e439c81
commit
206509359e
@ -10,10 +10,11 @@ import { IGetInsuranceCostRequestData } from "@spt-aki/models/eft/insurance/IGet
|
||||
import { IGetInsuranceCostResponseData } from "@spt-aki/models/eft/insurance/IGetInsuranceCostResponseData";
|
||||
import { IInsureRequestData } from "@spt-aki/models/eft/insurance/IInsureRequestData";
|
||||
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { Insurance, ISystemData } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||
import { ISystemData, Insurance } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { MessageType } from "@spt-aki/models/enums/MessageType";
|
||||
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
|
||||
import { IInsuranceConfig } from "@spt-aki/models/spt/config/IInsuranceConfig";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { EventOutputHolder } from "@spt-aki/routers/EventOutputHolder";
|
||||
@ -518,6 +519,7 @@ export class InsuranceController
|
||||
public insure(pmcData: IPmcData, body: IInsureRequestData, sessionID: string): IItemEventRouterResponse
|
||||
{
|
||||
let output = this.eventOutputHolder.getOutput(sessionID);
|
||||
const itemsToInsureCount = body.items.length;
|
||||
const itemsToPay = [];
|
||||
const inventoryItemsHash = {};
|
||||
|
||||
@ -564,6 +566,8 @@ export class InsuranceController
|
||||
});
|
||||
}
|
||||
|
||||
this.profileHelper.addSkillPointsToPlayer(pmcData, SkillTypes.CHARISMA, itemsToInsureCount * 0.01);
|
||||
|
||||
return output;
|
||||
}
|
||||
|
||||
|
@ -9,6 +9,7 @@ import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { SaveServer } from "@spt-aki/servers/SaveServer";
|
||||
import { LocalisationService } from "@spt-aki/services/LocalisationService";
|
||||
import { ProfileSnapshotService } from "@spt-aki/services/ProfileSnapshotService";
|
||||
import { JsonUtil } from "@spt-aki/utils/JsonUtil";
|
||||
import { TimeUtil } from "@spt-aki/utils/TimeUtil";
|
||||
@ -25,7 +26,8 @@ export class ProfileHelper
|
||||
@inject("SaveServer") protected saveServer: SaveServer,
|
||||
@inject("DatabaseServer") protected databaseServer: DatabaseServer,
|
||||
@inject("ItemHelper") protected itemHelper: ItemHelper,
|
||||
@inject("ProfileSnapshotService") protected profileSnapshotService: ProfileSnapshotService
|
||||
@inject("ProfileSnapshotService") protected profileSnapshotService: ProfileSnapshotService,
|
||||
@inject("LocalisationService") protected localisationService: LocalisationService
|
||||
)
|
||||
{ }
|
||||
|
||||
@ -366,4 +368,47 @@ export class ProfileHelper
|
||||
}
|
||||
return profileSkill.Progress >= 5100; // level 51
|
||||
}
|
||||
|
||||
/**
|
||||
* Add points to a specific skill in player profile
|
||||
* @param skill Skill to add points to
|
||||
* @param pointsToAdd Points to add
|
||||
* @param pmcProfile Player profile with skill
|
||||
* @param useSkillProgressRateMultipler Skills are multiplied by a value in globals, default is off to maintain compatibility with legacy code
|
||||
* @returns
|
||||
*/
|
||||
public addSkillPointsToPlayer(pmcProfile: IPmcData, skill: SkillTypes, pointsToAdd: number, useSkillProgressRateMultipler = false): void
|
||||
{
|
||||
if (!pointsToAdd || pointsToAdd < 0)
|
||||
{
|
||||
this.logger.error(this.localisationService.getText("player-attempt_to_increment_skill_with_negative_value", skill));
|
||||
return;
|
||||
}
|
||||
|
||||
const profileSkills = pmcProfile?.Skills?.Common;
|
||||
if (!profileSkills)
|
||||
{
|
||||
this.logger.warning(`Unable to add ${pointsToAdd} points to ${skill}, profile has no skills`);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
const profileSkill = profileSkills.find(x => x.Id === skill);
|
||||
if (!profileSkill)
|
||||
{
|
||||
this.logger.error(this.localisationService.getText("quest-no_skill_found", skill));
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (useSkillProgressRateMultipler)
|
||||
{
|
||||
const globals = this.databaseServer.getTables().globals;
|
||||
const skillProgressRate = globals.config.SkillsSettings.SkillProgressRate;
|
||||
pointsToAdd = skillProgressRate * pointsToAdd;
|
||||
}
|
||||
|
||||
profileSkill.Progress += pointsToAdd;
|
||||
profileSkill.LastAccess = this.timeUtil.getTimestamp();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user