Skip to content

Commit

Permalink
constraint balance
Browse files Browse the repository at this point in the history
tech: hidden-variable theory - after choosing a fieldtech gain 1.15x damage
  for pilot wave only
polariton - boosts also give 0.3x damage taken

constraints
  removed
    full damage taken after boss dies
      wording is too unclear
  new
    0.5x energy regen from all sources
  balanced
    slow bots
      bots have roughly 15% reduction in damage in addition to a slow follow speed
    mob death heals mobs
      has 1000->700 range and 1->0.33 healing
    periodically spawn WIMPs
      has a 30s delay and a 15->6s spawn rate
    50->40% JUNK chance

heuristics gives (1-1.5x)->(1-2x) fire rate and +5% JUNK
autonomous defense harpoon now scale from Bessemer process
  but at half the rate since there are 6 harpoons
Bessemer process and rail gun scale at 0.1->0.07

bugs
  crash with training level "heal" and power ups
  set difficulty mode level 2 for training
  • Loading branch information
landgreen committed Aug 19, 2024
1 parent 52046ca commit 220a6b4
Show file tree
Hide file tree
Showing 14 changed files with 223 additions and 164 deletions.
File renamed without changes.
Binary file added img/hidden-variable theory.webp
Binary file not shown.
Binary file added img/polariton.webp
Binary file not shown.
41 changes: 16 additions & 25 deletions js/bullet.js
Original file line number Diff line number Diff line change
Expand Up @@ -1498,7 +1498,7 @@ const b = {
if (this.pickUpTarget) {
if (tech.isReel && this.blockDist > 150) {
// console.log(0.0003 * Math.min(this.blockDist, 1000))
m.energy += 0.00113 * Math.min(this.blockDist, 800) //max 0.352 energy
m.energy += 0.00113 * Math.min(this.blockDist, 800) * level.isReducedRegen //max 0.352 energy
simulation.drawList.push({ //add dmg to draw queue
x: m.pos.x,
y: m.pos.y,
Expand Down Expand Up @@ -2925,7 +2925,7 @@ const b = {
if (!who.isInvulnerable) {
if (tech.iceEnergy && !who.shield && !who.isShielded && who.isDropPowerUp && who.alive && m.immuneCycle < m.cycle) {
setTimeout(() => {
if (!who.alive) m.energy += tech.iceEnergy * 0.8
if (!who.alive) m.energy += tech.iceEnergy * 0.8 * level.isReducedRegen
}, 10);
}
mobs.statusSlow(who, tech.iceIXFreezeTime)
Expand Down Expand Up @@ -4683,7 +4683,7 @@ const b = {
if (Vector.magnitude(Vector.sub(this.position, player.position)) < 250 && m.immuneCycle < m.cycle) { //give energy
Matter.Body.setAngularVelocity(this, this.spin)
if (this.isUpgraded) {
m.energy += 0.12
m.energy += 0.12 * level.isReducedRegen
simulation.drawList.push({ //add dmg to draw queue
x: this.position.x,
y: this.position.y,
Expand All @@ -4692,7 +4692,7 @@ const b = {
time: simulation.drawTime
});
} else {
m.energy += 0.04
m.energy += 0.04 * level.isReducedRegen
simulation.drawList.push({ //add dmg to draw queue
x: this.position.x,
y: this.position.y,
Expand All @@ -4705,7 +4705,7 @@ const b = {
}

if (!m.isCloak) { //if cloaking field isn't active
const size = 33
const size = 33 - 6 * isKeep
q = Matter.Query.region(mob, {
min: {
x: this.position.x - size,
Expand Down Expand Up @@ -4760,7 +4760,7 @@ const b = {
minDmgSpeed: 2,
// lookFrequency: 56 + Math.floor(17 * Math.random()) - isUpgraded * 20,
lastLookCycle: simulation.cycle + 60 * Math.random(),
delay: Math.floor((tech.isNailBotUpgrade ? 22 : 85)),
delay: Math.floor((tech.isNailBotUpgrade ? 22 : 85) + 10 * isKeep),
acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
range: 60 * (1 + 0.3 * Math.random()) + 3 * b.totalBots() + !isKeep * 100,
endCycle: Infinity,
Expand Down Expand Up @@ -4895,7 +4895,7 @@ const b = {
lookFrequency: 60 + Math.floor(17 * Math.random()) - 50 * tech.isFoamBotUpgrade,
cd: 0,
fireCount: 0,
fireLimit: 5 + 2 * tech.isFoamBotUpgrade,
fireLimit: 5 + 2 * tech.isFoamBotUpgrade - isKeep,
delay: Math.floor((200 + (tech.isFoamBotUpgrade ? 0 : 200))),// + 30 - 20 * tech.isFoamBotUpgrade,//20 + Math.floor(85 * b.fireCDscale) - 20 * tech.isFoamBotUpgrade,
acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
range: 60 * (1 + 0.3 * Math.random()) + 3 * b.totalBots() + !isKeep * 100, //how far from the player the bot will move
Expand Down Expand Up @@ -4968,7 +4968,7 @@ const b = {
lookFrequency: 17 + Math.floor(7 * Math.random()) - 3 * tech.isSoundBotUpgrade,
cd: 0,
fireCount: 0,
fireLimit: 5,
fireLimit: 5 - isKeep,
delay: Math.floor(140),// + 30 - 20 * tech.isFoamBotUpgrade,//20 + Math.floor(85 * b.fireCDscale) - 20 * tech.isFoamBotUpgrade,
acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
range: 60 * (1 + 0.3 * Math.random()) + 3 * b.totalBots() + !isKeep * 100, //how far from the player the bot will move
Expand Down Expand Up @@ -5136,7 +5136,7 @@ const b = {
lookFrequency: 20 + Math.floor(7 * Math.random()) - 13 * tech.isLaserBotUpgrade,
range: (600 + 375 * tech.isLaserBotUpgrade) * (1 + 0.12 * Math.random()),
drainThreshold: 0.15 + 0.5 * Math.random() + (tech.isEnergyHealth ? 0.3 : 0),// laser bot will not attack if the player is below this energy
drain: (0.57 - 0.43 * tech.isLaserBotUpgrade) * tech.laserDrain,
drain: (0.57 - 0.43 * tech.isLaserBotUpgrade + isKeep * 0.08) * tech.laserDrain,
laserDamage: 0.75 + 0.75 * tech.isLaserBotUpgrade,
endCycle: Infinity,
classType: "bullet",
Expand Down Expand Up @@ -5313,7 +5313,7 @@ const b = {
restitution: 1,
dmg: 0,
minDmgSpeed: 0,
lookFrequency: 43 + Math.floor(7 * Math.random()) - 13 * tech.isBoomBotUpgrade,
lookFrequency: 43 + Math.floor(7 * Math.random()) - 15 * tech.isBoomBotUpgrade,
acceleration: (isKeep ? 0.005 : 0.001) * (1 + 0.5 * Math.random()),
attackAcceleration: 0.012 + 0.005 * tech.isBoomBotUpgrade,
range: 500 * (1 + 0.1 * Math.random()) + 250 * tech.isBoomBotUpgrade + !isKeep * 100,
Expand Down Expand Up @@ -5443,11 +5443,7 @@ const b = {
const DIST = Vector.magnitude(sub);
const unit = Vector.normalise(sub)
if (DIST < tech.isPlasmaRange * 450 && m.energy > this.drainThreshold) {
m.energy -= 0.0013 //0.004; //normal plasma field is 0.00008 + m.fieldRegen = 0.00108
// if (m.energy < 0) {
// m.fieldCDcycle = m.cycle + 120;
// m.energy = 0;
// }
m.energy -= 0.001
//calculate laser collision
let best;
let range = tech.isPlasmaRange * (120 + 300 * Math.sqrt(Math.random()))
Expand All @@ -5466,9 +5462,9 @@ const b = {
// Matter.Body.applyForce(best.who, path[1], force)
//push mobs away
if (best.who.speed > 3) {
const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.005 * Math.min(5, best.who.mass))
const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.004 * Math.min(5, best.who.mass))
Matter.Body.applyForce(best.who, path[1], force)
Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.4, y: best.who.velocity.y * 0.4 });
Matter.Body.setVelocity(best.who, { x: best.who.velocity.x * 0.5, y: best.who.velocity.y * 0.5 });
} else {
const force = Vector.mult(Vector.normalise(Vector.sub(m.pos, path[1])), -0.01 * Math.min(5, best.who.mass))
Matter.Body.applyForce(best.who, path[1], force)
Expand Down Expand Up @@ -5558,7 +5554,7 @@ const b = {
}
}
},
range: 190 + 170 * tech.isOrbitBotUpgrade + !isKeep * 60 * (0.5 - Math.random()), //range is set in bot upgrade too!
range: 160 + 170 * tech.isOrbitBotUpgrade + !isKeep * 100 * (0.5 - Math.random()), //range is set in bot upgrade too!
orbitalSpeed: 0,
phase: 2 * Math.PI * Math.random(),
do() {
Expand Down Expand Up @@ -7211,8 +7207,6 @@ const b = {
const DRAIN = (tech.isRailEnergy ? 0 : 0.002)
//exit railgun charging without firing
if (m.energy < DRAIN) {
// m.energy += 0.025 + this.charge * 22 * this.drain
// m.energy -= this.drain
m.fireCDcycle = m.cycle + 120; // cool down if out of energy
this.endCycle = 0;
this.charge = 0
Expand Down Expand Up @@ -7292,7 +7286,7 @@ const b = {
const recoil = Vector.mult(Vector.normalise(Vector.sub(where, m.pos)), m.crouch ? 0.03 : 0.06)
player.force.x -= recoil.x
player.force.y -= recoil.y
const harpoonSize = tech.isLargeHarpoon ? 1 + 0.1 * Math.sqrt(this.ammo) : 1
const harpoonSize = tech.isLargeHarpoon ? 1 + 0.07 * Math.sqrt(this.ammo) : 1
const thrust = 0.15 * (this.charge)
if (tech.extraHarpoons) {
let targetCount = 0
Expand Down Expand Up @@ -7452,10 +7446,7 @@ const b = {
if (tech.extraHarpoons && !m.crouch) { //multiple harpoons
const SPREAD = 0.2
let angle = m.angle - SPREAD * tech.extraHarpoons / 2;
const dir = {
x: Math.cos(angle),
y: Math.sin(angle)
}; //make a vector for the player's direction of length 1; used in dot product
const dir = { x: Math.cos(angle), y: Math.sin(angle) }; //make a vector for the player's direction of length 1; used in dot product
const range = 450 * (tech.isFilament ? 1 + 0.012 * Math.min(110, this.ammo) : 1)
let targetCount = 0
for (let i = 0, len = mob.length; i < len; ++i) {
Expand Down
8 changes: 5 additions & 3 deletions js/engine.js
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function collisionChecks(event) {
simulation.trails(90)
simulation.inGameConsole(`simulation.amplitude <span class='color-symbol'>=</span> ${Math.random()}`);
}
if (tech.isPiezo) m.energy += 20.48;
if (tech.isPiezo) m.energy += 20.48 * level.isReducedRegen;
if (tech.isCouplingNoHit && m.coupling > 0) {
m.couplingChange(-3)

Expand Down Expand Up @@ -162,10 +162,12 @@ function collisionChecks(event) {
const maxCount = 10 + 3 * tech.extraHarpoons //scale the number of hooks fired
let count = maxCount - 1
const angle = Math.atan2(mob[k].position.y - player.position.y, mob[k].position.x - player.position.x);
b.harpoon(m.pos, mob[k], angle, 0.75, true, 7) // harpoon(where, target, angle = m.angle, harpoonSize = 1, isReturn = false, totalCycles = 35, isReturnAmmo = true, thrust = 0.1) {

const mass = 0.75 * (tech.isLargeHarpoon ? 1 + 0.05 * Math.sqrt(this.ammo) : 1)
b.harpoon(m.pos, mob[k], angle, mass, true, 7) // harpoon(where, target, angle = m.angle, harpoonSize = 1, isReturn = false, totalCycles = 35, isReturnAmmo = true, thrust = 0.1) {
bullet[bullet.length - 1].drain = 0
for (; count > 0; count--) {
b.harpoon(m.pos, mob[k], angle + count * 2 * Math.PI / maxCount, 0.75, true, 7)
b.harpoon(m.pos, mob[k], angle + count * 2 * Math.PI / maxCount, mass, true, 7)
bullet[bullet.length - 1].drain = 0
}
}
Expand Down
5 changes: 3 additions & 2 deletions js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,8 @@ function beforeUnloadEventListener(event) {
event.preventDefault();
if (tech.isExitPrompt) {
tech.damage *= 1.25
simulation.inGameConsole(`damage <span class='color-symbol'>*=</span> ${1.25}`)
// simulation.inGameConsole(`<strong class='color-d'>damage</strong> <span class='color-symbol'>*=</span> ${1.25}`)
simulation.inGameConsole(`<span class='color-var'>tech</span>.damage *= ${1.25} //beforeunload`);
if (Math.random() < 0.25) {
removeEventListener('beforeunload', beforeUnloadEventListener);
}
Expand Down Expand Up @@ -490,7 +491,7 @@ const build = {
<span style="float: right;"><strong class='color-defense'>level</strong> ${(simulation.dmgScale).toPrecision(4)}x</span>
<br><strong class='color-h'>health</strong> (${(m.health * 100).toFixed(0)} / ${(m.maxHealth * 100).toFixed(0)})
<span style="float: right;">${powerUps.research.count} ${powerUps.orb.research()}</span>
<br><strong class='color-f'>energy</strong> (${(m.energy * 100).toFixed(0)} / ${(m.maxEnergy * 100).toFixed(0)}) + (${(m.fieldRegen * 6000).toFixed(0)}/s)
<br><strong class='color-f'>energy</strong> (${(m.energy * 100).toFixed(0)} / ${(m.maxEnergy * 100).toFixed(0)}) + (${(m.fieldRegen * 6000 * level.isReducedRegen).toFixed(0)}/s)
<span style="float: right;">${tech.totalCount} ${powerUps.orb.tech()}</span>
<br><strong><em>fire rate</em></strong> ${(1 / b.fireCDscale).toFixed(2)}x
<span style="float: right;">mass ${player.mass.toFixed(1)}</span>
Expand Down
56 changes: 34 additions & 22 deletions js/level.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ const level = {
// for (let i = 0; i < 1; i++) powerUps.directSpawn(450, -50, "tech");
// for (let i = 0; i < 3; i++) powerUps.directSpawn(m.pos.x + 200, m.pos.y - 50, "boost", false);
// spawn.bodyRect(575, -700, 150, 150); //block mob line of site on testing
// level.satellite();
// level.heal();

level[simulation.isTraining ? "walk" : "initial"]() //normal starting level **************************************************

Expand Down Expand Up @@ -129,7 +129,9 @@ const level = {
powerUps.directSpawn(flip * localSettings.entanglement.position.x, localSettings.entanglement.position.y, "entanglement", false);
}
level.newLevelOrPhase()
if (!simulation.isTraining) {
if (simulation.isTraining) {
simulation.difficultyMode = 2
} else {
simulation.inGameConsole(`<span class='color-var'>level</span>.onLevel <span class='color-symbol'>=</span> "<span class='color-text'>${level.levels[level.onLevel]}</span>"`);
document.title = "n-gon: " + level.levelAnnounce();
}
Expand Down Expand Up @@ -332,6 +334,15 @@ const level = {
constraintDescription1: "", //used in pause menu and console
constraintDescription2: "",
constraint: [
{
description: "0.5x energy regen",
effect() {
level.isReducedRegen = 0.5
},
remove() {
level.isReducedRegen = 1
}
},
{
description: "0.5x max health",
effect() {
Expand All @@ -351,7 +362,7 @@ const level = {
}
},
{
description: "periodically spawn WIMPs",
description: "after 30 seconds spawn WIMPs",
effect() {
simulation.ephemera.push({
name: "WIMPS",
Expand All @@ -360,7 +371,7 @@ const level = {
do() {
this.time++
if (level.levels[level.onLevel] === this.levelName) {
if (!(this.time % 900)) spawn.WIMP(level.enter.x, level.enter.y)
if (this.time > 1800 && !(this.time % 360)) spawn.WIMP(level.enter.x, level.enter.y)
} else {
simulation.removeEphemera(this.name);
}
Expand All @@ -383,7 +394,7 @@ const level = {
}
},
{
description: "mobs heal for your lost health",
description: "mobs heal after you take damage",
effect() {
level.isMobHealPlayerDamage = true
},
Expand All @@ -400,16 +411,16 @@ const level = {
level.isMobDeathHeal = false
}
},
{
description: "full damage taken after boss dies",
// description: "after boss dies damage taken = 1",
effect() {
level.noDefenseSetting = 1 //defense goes to zero once equal to 2
},
remove() {
level.noDefenseSetting = 0
}
},
// {
// description: "full damage taken after boss dies",
// // description: "after boss dies damage taken = 1",
// effect() {
// level.noDefenseSetting = 1 //defense goes to zero once equal to 2
// },
// remove() {
// level.noDefenseSetting = 0
// }
// },
{
description: "4x shielded mobs",
effect() {
Expand All @@ -420,9 +431,9 @@ const level = {
}
},
{
description: "50% JUNK chance",
description: "40% JUNK chance",
effect() {
level.junkAdded = 0.5
level.junkAdded = 0.4
},
remove() {
level.junkAdded = 0
Expand Down Expand Up @@ -542,13 +553,14 @@ const level = {
is2xAmmo: false,
isReducedEnergy: false,
isSlowBots: false,
noDefenseSetting: 0,
// noDefenseSetting: 0,
isMobDeathHeal: false,
isMobHealPlayerDamage: false,
isNoDamage: false,
noDamageCycle: 0,
reducedHealthLost: 0,
isReducedHealth: false,
isReducedRegen: 1,
levelAnnounce() {
const cheating = simulation.isCheating ? "(testing)" : ""
if (level.levelsCleared === 0) {
Expand Down Expand Up @@ -1239,7 +1251,7 @@ const level = {
ctx.moveTo(x, y + height / 2);
ctx.lineTo(x, maxHeight - height / 2);
ctx.strokeStyle = `rgba(0,0,0,0.2)`
// ctx.lineWidth = "3"
ctx.lineWidth = "2"
ctx.stroke();

//draw body
Expand Down Expand Up @@ -35293,9 +35305,9 @@ const level = {
spawn.mapRect(1375, -16, 50, 50);
spawn.mapRect(1400, -8, 50, 25);
spawn.mapRect(750, -24, 650, 100);
powerUps.directSpawn(875, -40, "heal", false, null, 15);
powerUps.directSpawn(1075, -50, "heal", false, null, 25);
powerUps.directSpawn(1275, -65, "heal", false, null, 35);
powerUps.directSpawn(875, -40, "heal", false, 15);
powerUps.directSpawn(1075, -50, "heal", false, 25);
powerUps.directSpawn(1275, -65, "heal", false, 35);

const door = level.door(1612.5, -175, 25, 190, 185, 3)
spawn.mapRect(1600, -1200, 500, 850); //exit roof
Expand Down
Loading

0 comments on commit 220a6b4

Please sign in to comment.