Temp fix to ensure dynamic loot count generator doesnt generate a negative value

This commit is contained in:
Dev 2024-01-16 21:55:25 +00:00
parent 15be241dbf
commit 03a451115c
2 changed files with 5 additions and 7 deletions

View File

@ -603,7 +603,7 @@ export class LocationGenerator
// Draw from random distribution // Draw from random distribution
const desiredSpawnpointCount = Math.round( const desiredSpawnpointCount = Math.round(
this.getLooseLootMultiplerForLocation(locationName) this.getLooseLootMultiplerForLocation(locationName)
* this.randomUtil.randn(dynamicLootDist.spawnpointCount.mean, dynamicLootDist.spawnpointCount.std), * Math.abs(this.randomUtil.randn(dynamicLootDist.spawnpointCount.mean, dynamicLootDist.spawnpointCount.std)),
); );
// Positions not in forced but have 100% chance to spawn // Positions not in forced but have 100% chance to spawn

View File

@ -292,8 +292,8 @@ export class RandomUtil
{ {
v = Math.random(); v = Math.random();
} }
const w = Math.sqrt(-2.0 * Math.log(u)) * Math.cos(2.0 * Math.PI * v); const w = Math.sqrt(-2.0 * Math.log(u)) * Math.cos((2.0 * Math.PI) * v);
return mu + w * sigma; return w * sigma + mu;
} }
/** /**
@ -309,10 +309,8 @@ export class RandomUtil
{ {
return low + Math.floor(Math.random() * (high - low)); return low + Math.floor(Math.random() * (high - low));
} }
else
{ return Math.floor(Math.random() * low);
return Math.floor(Math.random() * low);
}
} }
/** /**