Skip to content

Commit

Permalink
Add spawn culler, update player spawns, update customs, fix floating …
Browse files Browse the repository at this point in the history
…point bug, use CorePointId to set first to last spawning
  • Loading branch information
Andrewgdewar committed Jan 30, 2025
1 parent effb89a commit 7be7354
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 40 deletions.
15 changes: 9 additions & 6 deletions src/SpawnZoneChanges/setupSpawn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
AddCustomBotSpawnPoints,
AddCustomPlayerSpawnPoints,
cleanClosest,
getClosestZone,
removeClosestSpawnsFromCustomBots,
} from "../Spawning/spawnZoneUtils";
import { shuffle } from "../Spawning/utils";
Expand Down Expand Up @@ -121,16 +122,17 @@ export const setupSpawns = (container: DependencyContainer) => {
if (advancedConfig.ActivateSpawnCullingOnServerStart) {
botSpawnHash[map] = removeClosestSpawnsFromCustomBots(nonBossSpawns, map, configLocations[mapIndex]) || []
}

nonBossSpawns = cleanClosest(
AddCustomBotSpawnPoints(nonBossSpawns, map, mapIndex),
configLocations[mapIndex]
).map((point, index) =>
configLocations[mapIndex],
).map((point) =>
!!point.Categories.length
? {
...point,
BotZoneName: point?.BotZoneName
? point.BotZoneName
: "open_" + index,
: getClosestZone(mapIndex, point.Position.x, point.Position.y, point.Position.z),
Categories: ["Bot"],
// Infiltration: "",
Sides: ["Savage"],
Expand All @@ -139,8 +141,9 @@ export const setupSpawns = (container: DependencyContainer) => {
: point
);

// if (map === "sandbox") {
// console.log(nonBossSpawns.map(({ BotZoneName }) => BotZoneName));
// if (map === "factory4_day") {
// zoneHash[mapIndex],
// console.log(new Set(nonBossSpawns.map(({ BotZoneName }) => BotZoneName)));
// }

indexedMapSpawns[mapIndex] = [
Expand Down Expand Up @@ -171,6 +174,6 @@ export const setupSpawns = (container: DependencyContainer) => {
});

advancedConfig.ActivateSpawnCullingOnServerStart && updateAllBotSpawns(botSpawnHash)
saveToFile(globalValues.zoneHash, "zoneHash.json");
// saveToFile(globalValues.zoneHash, "zoneHash.json");
globalValues.indexedMapSpawns = indexedMapSpawns;
};
1 change: 0 additions & 1 deletion src/Spawning/buildPmcs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ export default function buildPmcs(
let pmcZones = getSortedSpawnPointList(
locationList[index].base.SpawnPointParams.filter(
({ Categories, DelayToCanSpawnSec, BotZoneName }, index) =>
BotZoneName &&
index % 3 === 0 &&
!Categories.includes("Boss") &&
Categories[0] === "Bot" &&
Expand Down
7 changes: 4 additions & 3 deletions src/Spawning/buildScavMarksmanWaves.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ export default function buildScavMarksmanWaves(
// );

const {
Position: { x, z },
Position: { x, y, z },
} =
locationList[index].base.SpawnPointParams[
locationList[index].base.SpawnPointParams.length - 1
locationList[index].base.SpawnPointParams.length - 1
];

let sniperLocations = getSortedSpawnPointList(
Expand All @@ -113,6 +113,7 @@ export default function buildScavMarksmanWaves(
DelayToCanSpawnSec > 40)
),
x,
y,
z
).map(({ BotZoneName }) => BotZoneName);

Expand All @@ -129,7 +130,6 @@ export default function buildScavMarksmanWaves(
let scavZones = getSortedSpawnPointList(
locationList[index].base.SpawnPointParams.filter(
({ Categories, DelayToCanSpawnSec, BotZoneName }, index) =>
BotZoneName &&
!Categories.includes("Boss") &&
index % 3 !== 0 &&
Categories[0] === "Bot" &&
Expand All @@ -139,6 +139,7 @@ export default function buildScavMarksmanWaves(
)
),
x,
y,
z,
0.1
).map(({ BotZoneName }) => BotZoneName);
Expand Down
6 changes: 4 additions & 2 deletions src/Spawning/spawnZoneUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ function uuidv4() {
export const AddCustomBotSpawnPoints = (
SpawnPointParams: ISpawnPointParam[],
map: string,
mapIndex: number
mapIndex: number,
) => {
const mapConfigMap = configLocations[mapIndex];

Expand All @@ -148,7 +148,7 @@ export const AddCustomBotSpawnPoints = (

const botSpawns = BotSpawns[map].map((coords: Ixyz, index: number) => ({
BotZoneName:
getClosestZone(mapIndex, coords.x, coords.y, coords.z) || "Added_" + index,
getClosestZone(mapIndex, coords.x, coords.y, coords.z) || "",
Categories: ["Bot"],
ColliderParams: {
_parent: "SpawnSphereParams",
Expand Down Expand Up @@ -244,6 +244,7 @@ export const AddCustomPlayerSpawnPoints = (

export const getClosestZone = (mapIndex: number, x: number, y: number, z: number) => {
if (!globalValues.zoneHash[mapIndex]) return "";

let closest = Infinity;
let selectedZone = Object.keys(globalValues.zoneHash[mapIndex])?.[0];
Object.keys(globalValues.zoneHash[mapIndex]).forEach((zone) => {
Expand All @@ -254,6 +255,7 @@ export const getClosestZone = (mapIndex: number, x: number, y: number, z: number
selectedZone = zone;
}
});
// if (mapIndex === 0) console.log(selectedZone)

return selectedZone || "";
};
Expand Down
60 changes: 32 additions & 28 deletions src/Spawning/updateSpawnLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,16 @@ import _config from "../../config/config.json";
import { getRandomInArray, shuffle } from "./utils";
import { ISpawnPointParam } from "@spt/models/eft/common/ILocationBase";
import { globalValues } from "../GlobalValues";
import { getClosestZone } from "./spawnZoneUtils";
import getSortedSpawnPointList from "./spawnZoneUtils";

export default function updateSpawnLocations(locationList: ILocation[]) {
for (let index = 0; index < locationList.length; index++) {
const map = configLocations[index];
const playerSpawns: ISpawnPointParam[] = [];
const addedSpawns: ISpawnPointParam[] = [];
// const addedSpawns: ISpawnPointParam[] = [];
const mapSpawns = globalValues.indexedMapSpawns[index];

locationList[index].base.SpawnPointParams = [...mapSpawns].filter(
const filteredSpawns = [...mapSpawns].filter(
(point) => {
if (point?.Categories[0] === "Player") {
playerSpawns.push(point);
Expand All @@ -22,37 +22,41 @@ export default function updateSpawnLocations(locationList: ILocation[]) {

return true;
}
);
)

// console.log(playerSpawns.length);
// if (point.BotZoneName.includes("Added_")) {
// addedSpawns.push(point);
// return false;
// }

const playerSpawn: ISpawnPointParam = getRandomInArray(playerSpawns);
const { x, y, z } = playerSpawn.Position

const hash = {}

const sortedSpawnPointList = getSortedSpawnPointList(filteredSpawns, x, y, z).map((point, pIndex) => {
const { BotZoneName, Categories, DelayToCanSpawnSec } = point
if (BotZoneName && !Categories.includes("Boss") &&
Categories[0] === "Bot" &&
!(
BotZoneName?.toLowerCase().includes("snipe") ||
DelayToCanSpawnSec > 40
)) {

if (!hash[BotZoneName]) hash[BotZoneName] = 1

hash[BotZoneName] = pIndex % 2 === 0 ? hash[BotZoneName] + 1 : hash[BotZoneName]

point.CorePointId = hash[BotZoneName]

return point
} else return point
})


// console.log(map, hash)

locationList[index].base.SpawnPointParams = sortedSpawnPointList


playerSpawn.ColliderParams._props.Radius = 1;

// console.log(map, playerSpawn.Position);

// const spawnsToAdd = playerSpawns
// .filter((point) => point.Id !== playerSpawn.Id)
// .map((point, pindex) => ({
// ...point,
// BotZoneName: point.BotZoneName.includes("Added_")
// ? getClosestZone(pindex, point.Position.x, point.Position.y, point.Position.z)
// : point.BotZoneName,
// Categories: ["Bot"],
// // Infiltration: "",
// Sides: ["Savage"],
// CorePointId: 1,
// }))
// .filter(({ BotZoneName }) => !!BotZoneName);

// console.log(spawnsToAdd.map(({ BotZoneName }) => BotZoneName));

// locationList[index].base.SpawnPointParams.push(...spawnsToAdd);

const listToAddToOpenZones = shuffle<string[]>([
...new Set(
Expand Down

0 comments on commit 7be7354

Please sign in to comment.