Convert hideout area bonus property + Bonus type property into an enum and update code that uses altered property
This commit is contained in:
parent
dbc6bd9a0b
commit
e88a661e7e
@ -19,6 +19,7 @@ import { IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeRespo
|
||||
import { IServerDetails } from "@spt-aki/models/eft/game/IServerDetails";
|
||||
import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||
import { AccountTypes } from "@spt-aki/models/enums/AccountTypes";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
|
||||
import { Traders } from "@spt-aki/models/enums/Traders";
|
||||
@ -569,15 +570,15 @@ export class GameController
|
||||
let hpRegenPerHour = 456.6;
|
||||
|
||||
// Set new values, whatever is smallest
|
||||
energyRegenPerHour += pmcProfile.Bonuses.filter((x) => x.type === "EnergyRegeneration").reduce(
|
||||
energyRegenPerHour += pmcProfile.Bonuses.filter((x) => x.type === BonusType.ENERGY_REGENERATION).reduce(
|
||||
(sum, curr) => sum + curr.value,
|
||||
0,
|
||||
);
|
||||
hydrationRegenPerHour += pmcProfile.Bonuses.filter((x) => x.type === "HydrationRegeneration").reduce(
|
||||
hydrationRegenPerHour += pmcProfile.Bonuses.filter((x) => x.type === BonusType.HYDRATION_REGENERATION).reduce(
|
||||
(sum, curr) => sum + curr.value,
|
||||
0,
|
||||
);
|
||||
hpRegenPerHour += pmcProfile.Bonuses.filter((x) => x.type === "HealthRegeneration").reduce(
|
||||
hpRegenPerHour += pmcProfile.Bonuses.filter((x) => x.type === BonusType.HEALTH_REGENERATION).reduce(
|
||||
(sum, curr) => sum + curr.value,
|
||||
0,
|
||||
);
|
||||
|
@ -11,6 +11,7 @@ import { Settings, Skills, Stats } from "@spt-aki/models/eft/common/tables/IBotB
|
||||
import { IBotType } from "@spt-aki/models/eft/common/tables/IBotType";
|
||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { AccountTypes } from "@spt-aki/models/enums/AccountTypes";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { ItemAddedResult } from "@spt-aki/models/enums/ItemAddedResult";
|
||||
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
|
||||
@ -313,7 +314,7 @@ export class PlayerScavGenerator
|
||||
|
||||
for (const bonus of pmcData.Bonuses)
|
||||
{
|
||||
if (bonus.type === "ScavCooldownTimer")
|
||||
if (bonus.type === BonusType.SCAV_COOLDOWN_TIMER)
|
||||
{
|
||||
// Value is negative, so add.
|
||||
// Also note that for scav cooldown, multiple bonuses stack additively.
|
||||
|
@ -11,8 +11,8 @@ import { IHideoutProduction } from "@spt-aki/models/eft/hideout/IHideoutProducti
|
||||
import { IHideoutSingleProductionStartRequestData } from "@spt-aki/models/eft/hideout/IHideoutSingleProductionStartRequestData";
|
||||
import { IHideoutTakeProductionRequestData } from "@spt-aki/models/eft/hideout/IHideoutTakeProductionRequestData";
|
||||
import { IAddItemDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemDirectRequest";
|
||||
import { IAddItemRequestData } from "@spt-aki/models/eft/inventory/IAddItemRequestData";
|
||||
import { IItemEventRouterResponse } from "@spt-aki/models/eft/itemEvent/IItemEventRouterResponse";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
|
||||
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
|
||||
@ -134,7 +134,7 @@ export class HideoutHelper
|
||||
// Handle additional changes some bonuses need before being added
|
||||
switch (bonus.type)
|
||||
{
|
||||
case "StashSize":
|
||||
case BonusType.STASH_SIZE:
|
||||
{
|
||||
// Find stash item and adjust tpl to new tpl from bonus
|
||||
const stashItem = pmcData.Inventory.items.find((x) => x._id === pmcData.Inventory.stash);
|
||||
@ -148,11 +148,11 @@ export class HideoutHelper
|
||||
stashItem._tpl = bonus.templateId;
|
||||
break;
|
||||
}
|
||||
case "MaximumEnergyReserve":
|
||||
case BonusType.MAXIMUM_ENERGY_RESERVE:
|
||||
// Amend max energy in profile
|
||||
pmcData.Health.Energy.Maximum += bonus.value;
|
||||
break;
|
||||
case "TextBonus":
|
||||
case BonusType.TEXT_BONUS:
|
||||
// Delete values before they're added to profile
|
||||
delete bonus.value;
|
||||
delete bonus.passive;
|
||||
@ -412,7 +412,7 @@ export class HideoutHelper
|
||||
let fuelDrainRate = this.databaseServer.getTables().hideout.settings.generatorFuelFlowRate
|
||||
* this.hideoutConfig.runIntervalSeconds;
|
||||
// implemented moddable bonus for fuel consumption bonus instead of using solar power variable as before
|
||||
const fuelBonus = pmcData.Bonuses.find((b) => b.type === "FuelConsumption");
|
||||
const fuelBonus = pmcData.Bonuses.find((bonus) => bonus.type === BonusType.FUEL_CONSUMPTION);
|
||||
const fuelBonusPercent = 1.0 - (fuelBonus ? Math.abs(fuelBonus.value) : 0) / 100;
|
||||
fuelDrainRate *= fuelBonusPercent;
|
||||
// Hideout management resource consumption bonus:
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { Item, Upd } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { IPmcDataRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests";
|
||||
import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
|
||||
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
|
||||
import { QuestStatus } from "@spt-aki/models/enums/QuestStatus";
|
||||
@ -493,7 +494,7 @@ export interface RagfairInfo
|
||||
export interface Bonus
|
||||
{
|
||||
id?: string;
|
||||
type: string;
|
||||
type: BonusType;
|
||||
templateId?: string;
|
||||
passive?: boolean;
|
||||
production?: boolean;
|
||||
|
@ -1,3 +1,5 @@
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
|
||||
export interface IHideoutArea
|
||||
{
|
||||
_id: string;
|
||||
@ -82,10 +84,10 @@ export interface StageBonus
|
||||
production: boolean;
|
||||
visible: boolean;
|
||||
skillType?: string;
|
||||
type: string;
|
||||
type: BonusType;
|
||||
filter?: string[];
|
||||
icon?: string;
|
||||
/** CHANGES PER DUMP */
|
||||
id?: string;
|
||||
templateId?: string;
|
||||
}
|
||||
}
|
33
project/src/models/enums/BonusType.ts
Normal file
33
project/src/models/enums/BonusType.ts
Normal file
@ -0,0 +1,33 @@
|
||||
export enum BonusType
|
||||
{
|
||||
ENERGY_REGENERATION = "EnergyRegeneration",
|
||||
HYDRATION_REGENERATION = "HydrationRegeneration",
|
||||
HEALTH_REGENERATION = "HealthRegeneration",
|
||||
EXPERIENCE_RATE = "ExperienceRate",
|
||||
QUEST_MONEY_REWARD = "QuestMoneyReward",
|
||||
SCAV_COOLDOWN_TIMER = "ScavCooldownTimer",
|
||||
UNLOCK_ITEM_CRAFT = "UnlockItemCraft",
|
||||
UNLOCK_ITEM_PASSIVE_CREATION = "UnlockItemPassiveCreation",
|
||||
UNLOCK_RANDOM_ITEM_CREATION = "UnlockRandomItemCreation",
|
||||
SKILL_LEVELING_BOOST = "SkillLevelingBoost",
|
||||
DEBUFF_END_DELAY = "DebuffEndDelay",
|
||||
RAGFAIR_COMMISSION = "RagfairCommission",
|
||||
INSURANCE_RETURN_TIME = "InsuranceReturnTime",
|
||||
UNLOCK_WEAPON_MODIFICATION = "UnlockWeaponModification",
|
||||
UNLOCK_SCAV_PLAY = "UnlockScavPlay",
|
||||
UNLOCK_ADD_OFFER = "UnlockAddOffer",
|
||||
UNLOCK_ITEM_CHARGE = "UnlockItemCharge",
|
||||
RECEIVE_ITEM_BONUS = "ReceiveItemBonus",
|
||||
UNLOCK_UNIQUE_ID = "UnlockUniqueId",
|
||||
INCREASE_CANISTER_SLOTS = "IncreaseCanisterSlots",
|
||||
ADDITIONAL_SLOTS = "AdditionalSlots",
|
||||
FUEL_CONSUMPTION = "FuelConsumption",
|
||||
REPAIR_WEAPON_BONUS = "RepairWeaponBonus",
|
||||
REPAIR_ARMOR_BONUS = "RepairArmorBonus",
|
||||
UNLOCK_WEAPON_REPAIR = "UnlockWeaponRepair",
|
||||
UNLOCK_ARMOR_REPAIR = "UnlockArmorRepair",
|
||||
STASH_SIZE = "StashSize",
|
||||
MAXIMUM_ENERGY_RESERVE = "MaximumEnergyReserve",
|
||||
TEXT_BONUS = "TextBonus",
|
||||
SKILL_GROUP_LEVELING_BOOST = "SkillGroupLevelingBoost"
|
||||
}
|
@ -12,6 +12,7 @@ import { ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader";
|
||||
import { IInsuredItemsData } from "@spt-aki/models/eft/inRaid/IInsuredItemsData";
|
||||
import { ISaveProgressRequestData } from "@spt-aki/models/eft/inRaid/ISaveProgressRequestData";
|
||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { MessageType } from "@spt-aki/models/enums/MessageType";
|
||||
import { Traders } from "@spt-aki/models/enums/Traders";
|
||||
@ -203,7 +204,7 @@ export class InsuranceService
|
||||
return this.timeUtil.getTimestamp() + this.insuranceConfig.returnTimeOverrideSeconds;
|
||||
}
|
||||
|
||||
const insuranceReturnTimeBonus = pmcData.Bonuses.find((b) => b.type === "InsuranceReturnTime");
|
||||
const insuranceReturnTimeBonus = pmcData.Bonuses.find((b) => b.type === BonusType.INSURANCE_RETURN_TIME);
|
||||
const insuranceReturnTimeBonusPercent = 1.0
|
||||
- (insuranceReturnTimeBonus ? Math.abs(insuranceReturnTimeBonus.value) : 0) / 100;
|
||||
|
||||
|
@ -11,6 +11,7 @@ import { IHideoutImprovement } from "@spt-aki/models/eft/common/tables/IBotBase"
|
||||
import { IPmcDataRepeatableQuest, IRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests";
|
||||
import { StageBonus } from "@spt-aki/models/eft/hideout/IHideoutArea";
|
||||
import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
|
||||
import { QuestStatus } from "@spt-aki/models/enums/QuestStatus";
|
||||
@ -890,12 +891,12 @@ export class ProfileFixerService
|
||||
return profileBonuses.find((x) => x.id === bonus.id);
|
||||
}
|
||||
|
||||
if (bonus.type.toLowerCase() === "stashsize")
|
||||
if (bonus.type === BonusType.STASH_SIZE)
|
||||
{
|
||||
return profileBonuses.find((x) => x.type === bonus.type && x.templateId === bonus.templateId);
|
||||
}
|
||||
|
||||
if (bonus.type.toLowerCase() === "additionalslots")
|
||||
if (bonus.type === BonusType.ADDITIONAL_SLOTS)
|
||||
{
|
||||
return profileBonuses.find((x) =>
|
||||
x.type === bonus.type && x.value === bonus.value && x.visible === bonus.visible
|
||||
|
@ -5,6 +5,7 @@ import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
|
||||
import { Item } from "@spt-aki/models/eft/common/tables/IItem";
|
||||
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
|
||||
import { IStorePlayerOfferTaxAmountRequestData } from "@spt-aki/models/eft/ragfair/IStorePlayerOfferTaxAmountRequestData";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { ILogger } from "@spt-aki/models/spt/utils/ILogger";
|
||||
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
||||
import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService";
|
||||
@ -88,7 +89,7 @@ export class RagfairTaxService
|
||||
itemPriceMult = 4 ** itemPriceMult;
|
||||
requirementPriceMult = 4 ** requirementPriceMult;
|
||||
|
||||
const hideoutFleaTaxDiscountBonus = pmcData.Bonuses.find((b) => b.type === "RagfairCommission");
|
||||
const hideoutFleaTaxDiscountBonus = pmcData.Bonuses.find((b) => b.type === BonusType.RAGFAIR_COMMISSION);
|
||||
const taxDiscountPercent = hideoutFleaTaxDiscountBonus ? Math.abs(hideoutFleaTaxDiscountBonus.value) : 0;
|
||||
|
||||
const tax = itemWorth * itemTaxMult * itemPriceMult
|
||||
|
@ -14,6 +14,7 @@ import { RepairKitsInfo } from "@spt-aki/models/eft/repair/IRepairActionDataRequ
|
||||
import { RepairItem } from "@spt-aki/models/eft/repair/ITraderRepairActionDataRequest";
|
||||
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
|
||||
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses";
|
||||
import { BonusType } from "@spt-aki/models/enums/BonusType";
|
||||
import { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
|
||||
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
|
||||
import { BonusSettings, IRepairConfig } from "@spt-aki/models/spt/config/IRepairConfig";
|
||||
@ -342,7 +343,7 @@ export class RepairService
|
||||
if (isArmor)
|
||||
{
|
||||
const durabilityPointCostArmor = globalRepairSettings.durabilityPointCostArmor;
|
||||
const repairArmorBonus = this.getBonusMultiplierValue("RepairArmorBonus", pmcData);
|
||||
const repairArmorBonus = this.getBonusMultiplierValue(BonusType.REPAIR_ARMOR_BONUS, pmcData);
|
||||
const armorBonus = 1.0 - (repairArmorBonus - 1.0) - intellectPointReduction;
|
||||
const materialType = itemToRepairDetails._props.ArmorMaterial ?? "";
|
||||
const armorMaterial = globals.config.ArmorMaterials[materialType] as IArmorType;
|
||||
@ -355,7 +356,7 @@ export class RepairService
|
||||
}
|
||||
else
|
||||
{
|
||||
const repairWeaponBonus = this.getBonusMultiplierValue("RepairWeaponBonus", pmcData) - 1;
|
||||
const repairWeaponBonus = this.getBonusMultiplierValue(BonusType.REPAIR_WEAPON_BONUS, pmcData) - 1;
|
||||
const repairPointMultiplier = 1.0 - repairWeaponBonus - intellectPointReduction;
|
||||
const durabilityPointCostGuns = globals.config.RepairSettings.durabilityPointCostGuns;
|
||||
|
||||
@ -365,13 +366,13 @@ export class RepairService
|
||||
|
||||
/**
|
||||
* Get the bonus multiplier for a skill from a player profile
|
||||
* @param skillBonusName Name of bonus to get multipler of
|
||||
* @param skillBonus Bonus to get multipler of
|
||||
* @param pmcData Player profile to look in for skill
|
||||
* @returns Multiplier value
|
||||
*/
|
||||
protected getBonusMultiplierValue(skillBonusName: string, pmcData: IPmcData): number
|
||||
protected getBonusMultiplierValue(skillBonus: BonusType, pmcData: IPmcData): number
|
||||
{
|
||||
const bonusesMatched = pmcData?.Bonuses?.filter((b) => b.type === skillBonusName);
|
||||
const bonusesMatched = pmcData?.Bonuses?.filter((b) => b.type === skillBonus);
|
||||
let value = 1;
|
||||
if (bonusesMatched != null)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user