2022-08-03 21:57:37 -04:00
|
|
|
import { DatabaseServer } from "@spt-aki/servers/DatabaseServer";
|
2022-08-17 17:51:28 -04:00
|
|
|
import { LocationsConfig } from "../config/ts/locations";
|
2022-08-03 21:57:37 -04:00
|
|
|
import { Logger } from "./logger";
|
|
|
|
|
|
|
|
export class Locations
|
|
|
|
{
|
2022-08-17 02:18:04 -04:00
|
|
|
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;
|
2022-08-17 02:18:04 -04:00
|
|
|
this.tables = databaseServer;
|
2022-08-03 21:57:37 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
public updateLocations(): void
|
|
|
|
{
|
2022-08-17 02:18:04 -04:00
|
|
|
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");
|
|
|
|
}
|
2022-08-17 17:51:28 -04:00
|
|
|
|
|
|
|
// 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
|
|
|
|
{
|
2022-08-17 02:18:04 -04:00
|
|
|
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
|
|
|
|
{
|
2022-08-17 02:18:04 -04:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2022-08-17 02:18:04 -04:00
|
|
|
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
|
|
|
|
{
|
2022-08-17 02:18:04 -04:00
|
|
|
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
|
|
|
|
{
|
|
|
|
|
2022-08-17 02:18:04 -04:00
|
|
|
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
|
|
|
}
|
2022-08-17 17:51:28 -04:00
|
|
|
|
|
|
|
private freeLabsEntry(): void
|
|
|
|
{
|
|
|
|
const locations = this.tables.getTables().locations.laboratory.base;
|
|
|
|
locations.AccessKeys = [];
|
|
|
|
}
|
2022-08-03 21:57:37 -04:00
|
|
|
}
|