Valens-AIO/src/locations.ts

192 lines
6.2 KiB
TypeScript
Raw Permalink Normal View History

2022-08-03 21:57:37 -04:00
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
import { LocationsConfig } from "../config/ts/locations";
2022-08-03 21:57:37 -04:00
import { Logger } from "./logger";
export class Locations
{
private modConfig: LocationsConfig = require("../config/locations.json");
2022-08-03 21:57:37 -04:00
private logger: Logger;
2022-08-08 20:03:48 -04:00
private tables: DatabaseServer;
2022-08-03 21:57:37 -04:00
constructor (logger: Logger, databaseServer: DatabaseServer)
{
this.logger = logger;
this.tables = databaseServer;
2022-08-03 21:57:37 -04:00
}
public updateLocations(): void
{
const mod = this.modConfig;
2022-08-03 21:57:37 -04:00
// Gives all extracts 100% chance to spawn.
if (mod.allExtractsAvailable)
{
2022-08-06 14:44:30 -04:00
this.allExtractsAvailable();
this.logger.info("All Extracts @ 100% Chance to Spawn");
2022-08-03 21:57:37 -04:00
}
// Sets exfil/extract timer to config.
if (mod.exfilTime != 8)
{
2022-08-06 14:44:30 -04:00
this.exfilTime();
this.logger.info(`Exfil Time Set to ${mod.exfilTime}`);
2022-08-03 21:57:37 -04:00
}
// Remove extracts restrictions
if (mod.noExtractRestrictions)
{
2022-08-06 14:44:30 -04:00
this.noExtractRestrictions();
this.logger.info("No Extract Restrictions Enabled");
}
// Make all extractions of the map available regardless of the infill
if (mod.extractionsExtended)
{
this.extractionsExtended();
this.logger.info("Extractions Are Extended");
}
// Remove the access key "5c94bbff86f7747ee735c08f" (Labs access card) from Labs.
if (mod.freeLabsEntry)
{
this.freeLabsEntry();
this.logger.info("Labs is now Free to enter");
}
2022-08-06 14:44:30 -04:00
}
private allExtractsAvailable(): void
{
const locations = this.tables.getTables().locations;
2022-08-06 14:44:30 -04:00
for (const i in locations)
{
if (i !== "base")
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
for (const x in locations[i].base.exits)
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
if (locations[i].base.exits[x].Name !== "EXFIL_Train")
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
if (locations[i].base.exits[x].Chance !== 100)
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
locations[i].base.exits[x].Chance = 100;
2022-08-03 21:57:37 -04:00
}
}
}
}
}
2022-08-06 14:44:30 -04:00
}
2022-08-03 21:57:37 -04:00
2022-08-06 14:44:30 -04:00
private exfilTime(): void
{
const maps = this.tables.getTables().locations;
const mod = this.modConfig;
2022-08-06 14:44:30 -04:00
for (const map in maps)
{
if (map.toLowerCase() === "base")
{
continue;
}
const mapBase = this.tables.getTables().locations[map].base;
2022-08-06 14:44:30 -04:00
if (mapBase.Locked === true || mapBase?.EnabledCoop === undefined)
{
continue;
}
for (const exit of mapBase.exits)
{
exit.ExfiltrationTime = mod.exfilTime;
}
}
}
private noExtractRestrictions(): void
{
const locations = this.tables.getTables().locations;
2022-08-06 14:44:30 -04:00
for (const i in locations)
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
if (i !== "base")
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
for (const x in locations[i].base.exits)
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
if (locations[i].base.exits[x].Name !== "EXFIL_Train" &&
!locations[i].base.exits[x].Name.includes("lab") ||
locations[i].base.exits[x].Name === "lab_Vent")
{
if (locations[i].base.exits[x].PassageRequirement !== "None")
{
locations[i].base.exits[x].PassageRequirement = "None";
}
if (locations[i].base.exits[x].ExfiltrationType !== "Individual")
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
locations[i].base.exits[x].ExfiltrationType = "Individual";
2022-08-03 21:57:37 -04:00
}
2022-08-06 14:44:30 -04:00
if (locations[i].base.exits[x].Id !== "")
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
locations[i].base.exits[x].Id = "";
2022-08-03 21:57:37 -04:00
}
2022-08-06 14:44:30 -04:00
if (locations[i].base.exits[x].Count !== 0)
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
locations[i].base.exits[x].Count = 0;
2022-08-03 21:57:37 -04:00
}
2022-08-06 14:44:30 -04:00
if (locations[i].base.exits[x].RequirementTip !== "")
2022-08-03 21:57:37 -04:00
{
2022-08-06 14:44:30 -04:00
locations[i].base.exits[x].RequirementTip = "";
2022-08-03 21:57:37 -04:00
}
2022-08-06 14:44:30 -04:00
if (locations[i].base.exits[x].RequiredSlot)
{
delete locations[i].base.exits[x].RequiredSlot;
}
}
2022-08-03 21:57:37 -04:00
}
}
2022-08-06 14:44:30 -04:00
}
}
private extractionsExtended(): void
{
const locations = this.tables.getTables().locations;
2022-08-06 14:44:30 -04:00
for (const map in locations)
{
switch (map)
{
case "base":
break;
case "bigmap":
for (const extract in locations[map].base.exits)
{
locations[map].base.exits[extract].EntryPoints = "Customs,Boiler Tanks";
}
break;
case "interchange":
for (const extract in locations[map].base.exits)
{
locations[map].base.exits[extract].EntryPoints = "MallSE,MallNW";
}
break;
case "shoreline":
for (const extract in locations[map].base.exits)
{
locations[map].base.exits[extract].EntryPoints = "Village,Riverside";
}
break;
case "woods":
for (const extract in locations[map].base.exits)
{
locations[map].base.exits[extract].EntryPoints = "House,Old Station";
}
break;
default:
break;
}
2022-08-03 21:57:37 -04:00
}
2022-08-06 14:44:30 -04:00
2022-08-03 21:57:37 -04:00
}
private freeLabsEntry(): void
{
const locations = this.tables.getTables().locations.laboratory.base;
locations.AccessKeys = [];
}
2022-08-03 21:57:37 -04:00
}