Convert hideout area bonus property + Bonus type property into an enum and update code that uses altered property

This commit is contained in:
Dev 2024-01-29 10:42:02 +00:00
parent dbc6bd9a0b
commit e88a661e7e
10 changed files with 63 additions and 21 deletions

View File

@ -19,6 +19,7 @@ import { IGetRaidTimeResponse } from "@spt-aki/models/eft/game/IGetRaidTimeRespo
import { IServerDetails } from "@spt-aki/models/eft/game/IServerDetails"; import { IServerDetails } from "@spt-aki/models/eft/game/IServerDetails";
import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile"; import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile";
import { AccountTypes } from "@spt-aki/models/enums/AccountTypes"; 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 { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes"; import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
import { Traders } from "@spt-aki/models/enums/Traders"; import { Traders } from "@spt-aki/models/enums/Traders";
@ -569,15 +570,15 @@ export class GameController
let hpRegenPerHour = 456.6; let hpRegenPerHour = 456.6;
// Set new values, whatever is smallest // 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, (sum, curr) => sum + curr.value,
0, 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, (sum, curr) => sum + curr.value,
0, 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, (sum, curr) => sum + curr.value,
0, 0,
); );

View File

@ -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 { IBotType } from "@spt-aki/models/eft/common/tables/IBotType";
import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { AccountTypes } from "@spt-aki/models/enums/AccountTypes"; 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 { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { ItemAddedResult } from "@spt-aki/models/enums/ItemAddedResult"; import { ItemAddedResult } from "@spt-aki/models/enums/ItemAddedResult";
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
@ -313,7 +314,7 @@ export class PlayerScavGenerator
for (const bonus of pmcData.Bonuses) for (const bonus of pmcData.Bonuses)
{ {
if (bonus.type === "ScavCooldownTimer") if (bonus.type === BonusType.SCAV_COOLDOWN_TIMER)
{ {
// Value is negative, so add. // Value is negative, so add.
// Also note that for scav cooldown, multiple bonuses stack additively. // Also note that for scav cooldown, multiple bonuses stack additively.

View File

@ -11,8 +11,8 @@ import { IHideoutProduction } from "@spt-aki/models/eft/hideout/IHideoutProducti
import { IHideoutSingleProductionStartRequestData } from "@spt-aki/models/eft/hideout/IHideoutSingleProductionStartRequestData"; import { IHideoutSingleProductionStartRequestData } from "@spt-aki/models/eft/hideout/IHideoutSingleProductionStartRequestData";
import { IHideoutTakeProductionRequestData } from "@spt-aki/models/eft/hideout/IHideoutTakeProductionRequestData"; import { IHideoutTakeProductionRequestData } from "@spt-aki/models/eft/hideout/IHideoutTakeProductionRequestData";
import { IAddItemDirectRequest } from "@spt-aki/models/eft/inventory/IAddItemDirectRequest"; 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 { 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 { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas"; import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes"; import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
@ -134,7 +134,7 @@ export class HideoutHelper
// Handle additional changes some bonuses need before being added // Handle additional changes some bonuses need before being added
switch (bonus.type) switch (bonus.type)
{ {
case "StashSize": case BonusType.STASH_SIZE:
{ {
// Find stash item and adjust tpl to new tpl from bonus // Find stash item and adjust tpl to new tpl from bonus
const stashItem = pmcData.Inventory.items.find((x) => x._id === pmcData.Inventory.stash); const stashItem = pmcData.Inventory.items.find((x) => x._id === pmcData.Inventory.stash);
@ -148,11 +148,11 @@ export class HideoutHelper
stashItem._tpl = bonus.templateId; stashItem._tpl = bonus.templateId;
break; break;
} }
case "MaximumEnergyReserve": case BonusType.MAXIMUM_ENERGY_RESERVE:
// Amend max energy in profile // Amend max energy in profile
pmcData.Health.Energy.Maximum += bonus.value; pmcData.Health.Energy.Maximum += bonus.value;
break; break;
case "TextBonus": case BonusType.TEXT_BONUS:
// Delete values before they're added to profile // Delete values before they're added to profile
delete bonus.value; delete bonus.value;
delete bonus.passive; delete bonus.passive;
@ -412,7 +412,7 @@ export class HideoutHelper
let fuelDrainRate = this.databaseServer.getTables().hideout.settings.generatorFuelFlowRate let fuelDrainRate = this.databaseServer.getTables().hideout.settings.generatorFuelFlowRate
* this.hideoutConfig.runIntervalSeconds; * this.hideoutConfig.runIntervalSeconds;
// implemented moddable bonus for fuel consumption bonus instead of using solar power variable as before // 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; const fuelBonusPercent = 1.0 - (fuelBonus ? Math.abs(fuelBonus.value) : 0) / 100;
fuelDrainRate *= fuelBonusPercent; fuelDrainRate *= fuelBonusPercent;
// Hideout management resource consumption bonus: // Hideout management resource consumption bonus:

View File

@ -1,6 +1,7 @@
import { Item, Upd } from "@spt-aki/models/eft/common/tables/IItem"; import { Item, Upd } from "@spt-aki/models/eft/common/tables/IItem";
import { IPmcDataRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests"; import { IPmcDataRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests";
import { IRagfairOffer } from "@spt-aki/models/eft/ragfair/IRagfairOffer"; 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 { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
import { MemberCategory } from "@spt-aki/models/enums/MemberCategory"; import { MemberCategory } from "@spt-aki/models/enums/MemberCategory";
import { QuestStatus } from "@spt-aki/models/enums/QuestStatus"; import { QuestStatus } from "@spt-aki/models/enums/QuestStatus";
@ -493,7 +494,7 @@ export interface RagfairInfo
export interface Bonus export interface Bonus
{ {
id?: string; id?: string;
type: string; type: BonusType;
templateId?: string; templateId?: string;
passive?: boolean; passive?: boolean;
production?: boolean; production?: boolean;

View File

@ -1,3 +1,5 @@
import { BonusType } from "@spt-aki/models/enums/BonusType";
export interface IHideoutArea export interface IHideoutArea
{ {
_id: string; _id: string;
@ -82,7 +84,7 @@ export interface StageBonus
production: boolean; production: boolean;
visible: boolean; visible: boolean;
skillType?: string; skillType?: string;
type: string; type: BonusType;
filter?: string[]; filter?: string[];
icon?: string; icon?: string;
/** CHANGES PER DUMP */ /** CHANGES PER DUMP */

View 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"
}

View File

@ -12,6 +12,7 @@ import { ITraderBase } from "@spt-aki/models/eft/common/tables/ITrader";
import { IInsuredItemsData } from "@spt-aki/models/eft/inRaid/IInsuredItemsData"; import { IInsuredItemsData } from "@spt-aki/models/eft/inRaid/IInsuredItemsData";
import { ISaveProgressRequestData } from "@spt-aki/models/eft/inRaid/ISaveProgressRequestData"; import { ISaveProgressRequestData } from "@spt-aki/models/eft/inRaid/ISaveProgressRequestData";
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses"; 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 { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { MessageType } from "@spt-aki/models/enums/MessageType"; import { MessageType } from "@spt-aki/models/enums/MessageType";
import { Traders } from "@spt-aki/models/enums/Traders"; import { Traders } from "@spt-aki/models/enums/Traders";
@ -203,7 +204,7 @@ export class InsuranceService
return this.timeUtil.getTimestamp() + this.insuranceConfig.returnTimeOverrideSeconds; 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 const insuranceReturnTimeBonusPercent = 1.0
- (insuranceReturnTimeBonus ? Math.abs(insuranceReturnTimeBonus.value) : 0) / 100; - (insuranceReturnTimeBonus ? Math.abs(insuranceReturnTimeBonus.value) : 0) / 100;

View File

@ -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 { IPmcDataRepeatableQuest, IRepeatableQuest } from "@spt-aki/models/eft/common/tables/IRepeatableQuests";
import { StageBonus } from "@spt-aki/models/eft/hideout/IHideoutArea"; import { StageBonus } from "@spt-aki/models/eft/hideout/IHideoutArea";
import { IAkiProfile } from "@spt-aki/models/eft/profile/IAkiProfile"; 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 { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas"; import { HideoutAreas } from "@spt-aki/models/enums/HideoutAreas";
import { QuestStatus } from "@spt-aki/models/enums/QuestStatus"; import { QuestStatus } from "@spt-aki/models/enums/QuestStatus";
@ -890,12 +891,12 @@ export class ProfileFixerService
return profileBonuses.find((x) => x.id === bonus.id); 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); 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) => return profileBonuses.find((x) =>
x.type === bonus.type && x.value === bonus.value && x.visible === bonus.visible x.type === bonus.type && x.value === bonus.value && x.visible === bonus.visible

View File

@ -5,6 +5,7 @@ import { IPmcData } from "@spt-aki/models/eft/common/IPmcData";
import { Item } from "@spt-aki/models/eft/common/tables/IItem"; import { Item } from "@spt-aki/models/eft/common/tables/IItem";
import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem"; import { ITemplateItem } from "@spt-aki/models/eft/common/tables/ITemplateItem";
import { IStorePlayerOfferTaxAmountRequestData } from "@spt-aki/models/eft/ragfair/IStorePlayerOfferTaxAmountRequestData"; 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 { ILogger } from "@spt-aki/models/spt/utils/ILogger";
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer"; import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService"; import { RagfairPriceService } from "@spt-aki/services/RagfairPriceService";
@ -88,7 +89,7 @@ export class RagfairTaxService
itemPriceMult = 4 ** itemPriceMult; itemPriceMult = 4 ** itemPriceMult;
requirementPriceMult = 4 ** requirementPriceMult; 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 taxDiscountPercent = hideoutFleaTaxDiscountBonus ? Math.abs(hideoutFleaTaxDiscountBonus.value) : 0;
const tax = itemWorth * itemTaxMult * itemPriceMult const tax = itemWorth * itemTaxMult * itemPriceMult

View File

@ -14,6 +14,7 @@ import { RepairKitsInfo } from "@spt-aki/models/eft/repair/IRepairActionDataRequ
import { RepairItem } from "@spt-aki/models/eft/repair/ITraderRepairActionDataRequest"; import { RepairItem } from "@spt-aki/models/eft/repair/ITraderRepairActionDataRequest";
import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData"; import { IProcessBuyTradeRequestData } from "@spt-aki/models/eft/trade/IProcessBuyTradeRequestData";
import { BaseClasses } from "@spt-aki/models/enums/BaseClasses"; 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 { ConfigTypes } from "@spt-aki/models/enums/ConfigTypes";
import { SkillTypes } from "@spt-aki/models/enums/SkillTypes"; import { SkillTypes } from "@spt-aki/models/enums/SkillTypes";
import { BonusSettings, IRepairConfig } from "@spt-aki/models/spt/config/IRepairConfig"; import { BonusSettings, IRepairConfig } from "@spt-aki/models/spt/config/IRepairConfig";
@ -342,7 +343,7 @@ export class RepairService
if (isArmor) if (isArmor)
{ {
const durabilityPointCostArmor = globalRepairSettings.durabilityPointCostArmor; 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 armorBonus = 1.0 - (repairArmorBonus - 1.0) - intellectPointReduction;
const materialType = itemToRepairDetails._props.ArmorMaterial ?? ""; const materialType = itemToRepairDetails._props.ArmorMaterial ?? "";
const armorMaterial = globals.config.ArmorMaterials[materialType] as IArmorType; const armorMaterial = globals.config.ArmorMaterials[materialType] as IArmorType;
@ -355,7 +356,7 @@ export class RepairService
} }
else 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 repairPointMultiplier = 1.0 - repairWeaponBonus - intellectPointReduction;
const durabilityPointCostGuns = globals.config.RepairSettings.durabilityPointCostGuns; const durabilityPointCostGuns = globals.config.RepairSettings.durabilityPointCostGuns;
@ -365,13 +366,13 @@ export class RepairService
/** /**
* Get the bonus multiplier for a skill from a player profile * 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 * @param pmcData Player profile to look in for skill
* @returns Multiplier value * @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; let value = 1;
if (bonusesMatched != null) if (bonusesMatched != null)
{ {