Skip to content

Commit

Permalink
Sniper zones added.
Browse files Browse the repository at this point in the history
  • Loading branch information
Andrewgdewar committed Feb 2, 2025
1 parent 582e2a0 commit a46b26d
Show file tree
Hide file tree
Showing 11 changed files with 158 additions and 79 deletions.
4 changes: 2 additions & 2 deletions config/Presets.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
"pmcGroupChance": 0.8,
"pmcMaxGroupSize": 6,
"scavMaxGroupSize": 6,
"sniperGroupChance": 1,
"sniperGroupChance": 0.5,
"bossOpenZones": true,
"randomRaiderGroup": true,
"randomRaiderGroupChance": 50,
Expand All @@ -66,7 +66,7 @@
"mainBossChanceBuff": 35
},
"sniper-buddies": {
"sniperMaxGroupSize": 2.5,
"sniperMaxGroupSize": 2,
"sniperGroupChance": 1
}
}
4 changes: 2 additions & 2 deletions config/config.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"pmcDifficulty": 0.6,
"scavDifficulty": 0.4,

"scavWaveDistribution": 0.8,
"scavWaveDistribution": 1,
"scavWaveQuantity": 1,

"startingPmcs": false,
Expand All @@ -28,7 +28,7 @@

"pmcMaxGroupSize": 4,
"scavMaxGroupSize": 3,
"sniperMaxGroupSize": 1.6,
"sniperMaxGroupSize": 1,

"bossOpenZones": false,

Expand Down
12 changes: 12 additions & 0 deletions config/mapConfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
{
"customs": {
"sniperQuantity": 3,
"initialSpawnDelay": 15,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 8,
Expand All @@ -16,6 +17,7 @@
]
},
"factoryDay": {
"sniperQuantity": 3,
"initialSpawnDelay": 10,
"smoothingDistribution": 0.6,
"mapCullingNearPointValuePlayer": 2,
Expand All @@ -28,6 +30,7 @@
"zombieWaveCount": 6
},
"factoryNight": {
"sniperQuantity": 3,
"initialSpawnDelay": 10,
"smoothingDistribution": 0.6,
"mapCullingNearPointValuePlayer": 2,
Expand All @@ -40,6 +43,7 @@
"zombieWaveCount": 6
},
"interchange": {
"sniperQuantity": 3,
"initialSpawnDelay": 20,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 3,
Expand All @@ -54,6 +58,7 @@
]
},
"laboratory": {
"sniperQuantity": 0,
"initialSpawnDelay": 15,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 4,
Expand All @@ -64,6 +69,7 @@
"zombieWaveCount": 12
},
"lighthouse": {
"sniperQuantity": 3,
"initialSpawnDelay": 20,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 2.5,
Expand All @@ -78,6 +84,7 @@
]
},
"rezervbase": {
"sniperQuantity": 3,
"initialSpawnDelay": 20,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 3,
Expand All @@ -94,6 +101,7 @@
]
},
"shoreline": {
"sniperQuantity": 3,
"initialSpawnDelay": 20,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 5,
Expand All @@ -110,6 +118,7 @@
]
},
"tarkovstreets": {
"sniperQuantity": 5,
"initialSpawnDelay": 20,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 4,
Expand All @@ -120,6 +129,7 @@
"zombieWaveCount": 13
},
"woods": {
"sniperQuantity": 20,
"initialSpawnDelay": 20,
"smoothingDistribution": 0.9,
"mapCullingNearPointValuePlayer": 6,
Expand All @@ -136,6 +146,7 @@
]
},
"gzLow": {
"sniperQuantity": 3,
"initialSpawnDelay": 10,
"smoothingDistribution": 0.7,
"mapCullingNearPointValuePlayer": 4,
Expand All @@ -147,6 +158,7 @@
"zombieWaveCount": 9
},
"gzHigh": {
"sniperQuantity": 3,
"initialSpawnDelay": 10,
"smoothingDistribution": 0.7,
"mapCullingNearPointValuePlayer": 4,
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "MOAR",
"version": "3.0.0-alpha.1",
"version": "3.0.0-alpha.2",
"main": "src/mod.js",
"license": "MIT",
"author": "DewardianDev",
Expand Down
31 changes: 20 additions & 11 deletions src/SpawnZoneChanges/setupSpawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,25 @@ export const setupSpawns = (container: DependencyContainer) => {
let sniperSpawnSpawnPoints: ISpawnPointParam[] = [];
let coopSpawns: ISpawnPointParam[] = [];

const bossZoneList = new Set([
"Zone_Blockpost",
"Zone_RoofRocks",
"Zone_RoofContainers",
"Zone_RoofBeach",
"Zone_TreatmentRocks",
"Zone_TreatmentBeach",
"Zone_Hellicopter",
"Zone_Island",
"BotZoneGate1",
"BotZoneGate2",
"BotZoneBasement",
]);

shuffle<ISpawnPointParam[]>(locations[map].base.SpawnPointParams).forEach(
(point) => {
switch (true) {
case point.Categories.includes("Boss"):
case point.Categories.includes("Boss") ||
bossZoneList.has(point.BotZoneName):
bossSpawn.push(point);
break;

Expand All @@ -71,12 +86,6 @@ export const setupSpawns = (container: DependencyContainer) => {
return val;
});

const sniperZones = new Set(
sniperSpawnSpawnPoints
.map((point) => point.BotZoneName)
.filter((item) => !!item)
);

const limit = mapConfig[configLocations[mapIndex]].spawnMinDistance;

coopSpawns = cleanClosest(
Expand Down Expand Up @@ -142,10 +151,10 @@ export const setupSpawns = (container: DependencyContainer) => {
);

indexedMapSpawns[mapIndex] = [
...sniperSpawnSpawnPoints,
...bossSpawn,
...nonBossSpawns,
...coopSpawns,
...sniperSpawnSpawnPoints.map((point) => ({ ...point, type: "sniper" })),
...bossSpawn.map((point) => ({ ...point, type: "boss" })),
...nonBossSpawns.map((point) => ({ ...point, type: "nonBoss" })),
...coopSpawns.map((point) => ({ ...point, type: "coop" })),
];

// const added = indexedMapSpawns[mapIndex].filter(
Expand Down
13 changes: 4 additions & 9 deletions src/Spawning/buildPmcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,17 @@ export default function buildPmcs(

let pmcZones = getSortedSpawnPointList(
locationList[index].base.SpawnPointParams.filter(
({ Categories, DelayToCanSpawnSec, BotZoneName }, index) =>
index % 3 === 0 &&
!Categories.includes("Boss") &&
Categories[0] === "Bot" &&
!(
BotZoneName?.toLowerCase().includes("snipe") ||
DelayToCanSpawnSec > 40
)
),
(point) => point["type"] === "nonBoss"
).filter((_, sIndex) => sIndex % 3 === 0),
x,
y,
z,
0.1
).map(({ BotZoneName }) => BotZoneName);
looselyShuffle(pmcZones);

// console.log(pmcZones);

if (map === "laboratory") {
pmcZones = new Array(10).fill(pmcZones).flat(1);
}
Expand Down
50 changes: 26 additions & 24 deletions src/Spawning/buildScavMarksmanWaves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export default function buildScavMarksmanWaves(
maxBotCapOverride,
EscapeTimeLimit,
scavHotZones = [],
sniperQuantity = 1,
scavWaveCount,
initialSpawnDelay,
} = (mapConfig?.[map] as MapSettings) || {};
Expand Down Expand Up @@ -105,23 +106,29 @@ export default function buildScavMarksmanWaves(
locationList[index].base.SpawnPointParams.length - 1
];

let sniperLocations = getSortedSpawnPointList(
[...locationList[index].base.SpawnPointParams].filter(
({ Categories, DelayToCanSpawnSec, BotZoneName, Sides }) =>
!Categories.includes("Boss") &&
Sides[0] === "Savage" &&
(BotZoneName?.toLowerCase().includes("snipe") ||
DelayToCanSpawnSec > 40)
const sniperSpawns = getSortedSpawnPointList(
locationList[index].base.SpawnPointParams.filter(
(point) => point["type"] === "sniper"
),
x,
y,
z
).map(({ BotZoneName }) => BotZoneName);
);

// Prevent too many snipers on streets
if (map === "tarkovstreets") {
sniperLocations = sniperLocations.filter((_, index) => index % 2 === 0);
}
let sniperLocations = sniperSpawns.map(({ BotZoneName }) => BotZoneName);
// console.log(sniperLocations);

const sniperDelay = 20;
// Make sure that the sniper spawns permit snipers to actually spawn early.
const sniperIds = new Set(sniperSpawns.map(({ Id }) => Id));

locationList[index].base.SpawnPointParams.forEach((point, snipeIndex) => {
if (sniperIds.has(point.Id)) {
locationList[index].base.SpawnPointParams[
snipeIndex
].DelayToCanSpawnSec = 20;
}
});

if (sniperLocations.length) {
locationList[index].base.MinMaxBots = [
Expand All @@ -135,15 +142,8 @@ export default function buildScavMarksmanWaves(

let scavZones = getSortedSpawnPointList(
locationList[index].base.SpawnPointParams.filter(
({ Categories, DelayToCanSpawnSec, BotZoneName }, index) =>
!Categories.includes("Boss") &&
index % 3 !== 0 &&
Categories[0] === "Bot" &&
!(
BotZoneName?.toLowerCase().includes("snipe") ||
DelayToCanSpawnSec > 40
)
),
(point) => point["type"] === "nonBoss"
).filter((_, sIndex) => sIndex % 3 !== 0),
x,
y,
z,
Expand Down Expand Up @@ -183,19 +183,21 @@ export default function buildScavMarksmanWaves(
);

const timeLimit = locationList[index].base.EscapeTimeLimit * 60;

if (config.disableCascadingSpawns)
sniperLocations = shuffle<string[]>(sniperLocations);
// console.log(map);
const snipers = buildBotWaves(
sniperLocations.length,
timeLimit,
Math.min(sniperQuantity, sniperLocations.length),
timeLimit / 2, //TODO:
sniperMaxGroupSize,
sniperGroupChance,
sniperLocations,
0.7,
WildSpawnType.MARKSMAN,
true,
0.3,
60
sniperDelay
);

if (config.disableCascadingSpawns) scavZones = shuffle<string[]>(scavZones);
Expand Down
29 changes: 16 additions & 13 deletions src/Spawning/spawnZoneUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export const AddCustomBotSpawnPoints = (
Id: uuidv4(),
Infiltration: "",
Position: coords,
Rotation: 116.208389,
Rotation: random360(),
Sides: ["Savage"],
}));

Expand All @@ -212,7 +212,9 @@ export const AddCustomSniperSpawnPoints = (
}

const sniperSpawns = SniperSpawns[map].map((coords: Ixyz, index: number) => ({
BotZoneName: "SniperZone_" + index,
BotZoneName:
getClosestZone(SpawnPointParams, coords.x, coords.y, coords.z) ||
"custom_snipe_" + index,
Categories: ["Bot"],
ColliderParams: {
_parent: "SpawnSphereParams",
Expand All @@ -230,13 +232,14 @@ export const AddCustomSniperSpawnPoints = (
Id: uuidv4(),
Infiltration: "",
Position: coords,
Rotation: 116.208389,
Rotation: random360(),
Sides: ["Savage"],
}));

return [...SpawnPointParams, ...sniperSpawns];
};

export const random360 = () => Math.random() * 360;
export const AddCustomPlayerSpawnPoints = (
SpawnPointParams: ISpawnPointParam[],
map: string
Expand Down Expand Up @@ -295,7 +298,7 @@ export const AddCustomPlayerSpawnPoints = (
Id: uuidv4(),
Infiltration: getClosestInfil(coords.x, coords.y, coords.z),
Position: coords,
Rotation: 116.208389,
Rotation: random360(),
Sides: ["Pmc"],
}));

Expand Down Expand Up @@ -358,14 +361,14 @@ export const removeClosestSpawnsFromCustomBots = (
return result;
});

console.log(
map,
coords.length,
">",
filteredCoords.length,
"culled",
coords.length - filteredCoords.length,
"spawns"
);
// console.log(
// map,
// coords.length,
// ">",
// filteredCoords.length,
// "culled",
// coords.length - filteredCoords.length,
// "spawns"
// );
return filteredCoords;
};
Loading

0 comments on commit a46b26d

Please sign in to comment.