Skip to content

Commit 850a63b

Browse files
committed
New Reset Timer Configuration Option
Once a bug, now a feature! New configuration option for resetting a payment extract (like car) if you leave the extract area and return.
1 parent 5b548ae commit 850a63b

File tree

6 files changed

+42
-17
lines changed

6 files changed

+42
-17
lines changed

config/config.json5

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@
2222
// Maximum number of seconds to wait to extract in extraction area
2323
maxExtractionTime: 60,
2424

25+
// Reset payment extract timers when the player leaves the extract area.
26+
resetTimerOnLeave: false,
27+
2528
// Update percentages for random extract availability.
2629
// Only change the numbers... Do not change the keys/names!
2730
random: {

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "open-extracts",
3-
"version": "1.4.1",
3+
"version": "1.4.2",
44
"main": "src/OpenExtracts.js",
55
"license": "MIT",
66
"author": "Refringe",

src/adjusters/ExtractAdjuster.ts

Lines changed: 33 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ export class ExtractAdjuster {
4949
for (const locationName of enabledLocations) {
5050
const location = locations[locationName].base as ILocationBase;
5151
for (const extract of location.exits) {
52-
this.commonAdjustments(extract);
5352
this.enableAllEntryPoints(extract, location);
5453
this.adjustChanceEnabled(extract, location);
5554
this.adjustMaximumExtractTime(extract, location);
@@ -61,6 +60,7 @@ export class ExtractAdjuster {
6160

6261
this.convertCooperationToPayment(extract, location);
6362
this.adjustVehiclePayment(extract, location);
63+
this.resetTimerOnLeave(extract, location);
6464
this.removeBackpackRequirement(extract, location);
6565
this.removeCliffRequirements(extract, location);
6666
}
@@ -91,15 +91,6 @@ export class ExtractAdjuster {
9191
]);
9292
}
9393

94-
/**
95-
* Performs common adjustments that are applicable to all extracts.
96-
*/
97-
private commonAdjustments(extract: Exit): void {
98-
// This is SPT; all extracts should be individual and have no minimum player requirement.
99-
extract.ExfiltrationType = "Individual";
100-
extract.PlayersCount = 0;
101-
}
102-
10394
/**
10495
* Enables all entry points for a specified extract, making it usable regardless of the player's spawn location.
10596
*/
@@ -195,7 +186,7 @@ export class ExtractAdjuster {
195186
return;
196187
}
197188

198-
if (!ExtractAdjuster.isCooperationExtract(extract)) {
189+
if (!this.isCooperationExtract(extract)) {
199190
// This isn't a cooperation extract;
200191
return;
201192
}
@@ -219,7 +210,7 @@ export class ExtractAdjuster {
219210
/**
220211
* Determines whether the specified extract is a cooperation extract.
221212
*/
222-
private static isCooperationExtract(extract: Exit): boolean {
213+
private isCooperationExtract(extract: Exit): boolean {
223214
return extract.PassageRequirement === "ScavCooperation";
224215
}
225216

@@ -278,7 +269,7 @@ export class ExtractAdjuster {
278269
return;
279270
}
280271

281-
if (!ExtractAdjuster.isCliffExtract(extract)) {
272+
if (!this.isCliffExtract(extract)) {
282273
// This isn't a cliff extract.
283274
return;
284275
}
@@ -300,7 +291,7 @@ export class ExtractAdjuster {
300291
/**
301292
* Determines whether the specified extract is a cliff extract.
302293
*/
303-
private static isCliffExtract(extract: Exit): boolean {
294+
private isCliffExtract(extract: Exit): boolean {
304295
return extract.Name.trim().toLowerCase().includes("alp") && extract.PassageRequirement === "Reference";
305296
}
306297

@@ -373,4 +364,32 @@ export class ExtractAdjuster {
373364
vehicleExtracts.includes(extract.Name.trim().toLowerCase())
374365
);
375366
}
367+
368+
/**
369+
* This will cause the timer for an extract to reset when a player leaves the extract zone.
370+
*/
371+
private resetTimerOnLeave(extract: Exit, location: ILocationBase): void {
372+
if (!OpenExtracts.config.extracts.resetTimerOnLeave) {
373+
// Option has been disabled in the configuration file.
374+
return;
375+
}
376+
377+
if (!this.isVehicleExtract(extract) && !this.isCooperationExtract(extract)) {
378+
// This isn't a compatible extract.
379+
return;
380+
}
381+
382+
extract.ExfiltrationType = "Individual";
383+
extract.PlayersCount = 0;
384+
385+
if (OpenExtracts.config.general.debug) {
386+
OpenExtracts.logger.log(
387+
`OpenExtracts: ${extract.Name.trim()} on ${this.getLocationName(
388+
location.Id,
389+
"human"
390+
)} will have the extract timer reset on leave.`,
391+
"gray"
392+
);
393+
}
394+
}
376395
}

src/schemas/ConfigSchema.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export class ConfigSchema {
2121
ignoreCliffRequirements: { type: "boolean" },
2222
ignoreBackpackRequirements: { type: "boolean" },
2323
maxExtractionTime: { type: "number" },
24+
resetTimerOnLeave: { type: "boolean" },
2425
random: {
2526
type: "object",
2627
properties: {
@@ -133,6 +134,7 @@ export class ConfigSchema {
133134
"ignoreCliffRequirements",
134135
"ignoreBackpackRequirements",
135136
"maxExtractionTime",
137+
"resetTimerOnLeave",
136138
"random",
137139
"cooperation",
138140
],

src/types.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ export interface Extracts {
1616
ignoreCliffRequirements: boolean;
1717
ignoreBackpackRequirements: boolean;
1818
maxExtractionTime: number;
19+
resetTimerOnLeave: boolean;
1920
random: Random;
2021
cooperation: Cooperation;
2122
vehicle: Vehicle;

0 commit comments

Comments
 (0)