From 8ce7f684c8353872baa6cb9fc2cd10e0a2784e98 Mon Sep 17 00:00:00 2001 From: landgreen Date: Tue, 8 Sep 2020 17:38:44 -0700 Subject: [PATCH] Bayesian statistics blocks drift towards the center of pilot wave's field mod: Bayesian statistics - no longer stops ammo spawns 30% to double power ups, but ejects a mod when you take damage mod: exciton-lattice - 40% damage, but no ammo can spawn --- js/bullet.js | 4 ++-- js/engine.js | 4 ++-- js/game.js | 22 +++++++++++++++++++ js/index.js | 50 ++++++++++++++++++++++++----------------- js/level.js | 10 ++++----- js/mob.js | 37 +++++++++++++++++-------------- js/mods.js | 61 ++++++++++++++++++++++++++------------------------- js/player.js | 24 ++++++++++++-------- js/powerup.js | 4 ++-- js/spawn.js | 3 +-- todo.txt | 23 +++++-------------- 11 files changed, 135 insertions(+), 107 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 14ab8e3..77c9e2e 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -243,7 +243,7 @@ const b = { sub = Vector.sub(where, mob[i].position); dist = Vector.magnitude(sub) - mob[i].radius; if (dist < radius) { - if (mob[i].shield) dmg *= 3 //balancing explosion dmg to shields + if (mob[i].shield) dmg *= 2.5 //balancing explosion dmg to shields if (Matter.Query.ray(map, mob[i].position, where).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way mob[i].damage(dmg * damageScale * b.dmgScale); mob[i].locatePlayer(); @@ -2378,7 +2378,7 @@ const b = { if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < this.damageRadius) { let dmg = b.dmgScale * 0.023 if (Matter.Query.ray(map, mob[i].position, this.position).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way - if (mob[i].shield) dmg *= 5 //x5 to make up for the /5 that shields normally take + if (mob[i].shield) dmg *= 4 //x5 to make up for the /5 that shields normally take mob[i].damage(dmg); mob[i].locatePlayer(); } diff --git a/js/engine.js b/js/engine.js index 091cbe6..17daab8 100644 --- a/js/engine.js +++ b/js/engine.js @@ -148,13 +148,13 @@ function collisionChecks(event) { dmg *= 0.85 } mech.damage(dmg); - if (mod.isEjectMod) { + if (mod.isBayesian) { const have = [] //find which mods you have for (let i = 0; i < mod.mods.length; i++) { if (mod.mods[i].count > 0) have.push(i) } const choose = have[Math.floor(Math.random() * have.length)] - game.makeTextLog(`
  ${mod.mods[choose].name} ejected by exciton-lattice`, 300) //message about what mod was lost + game.makeTextLog(`
  ${mod.mods[choose].name} ejected by Bayesian statistics`, 300) //message about what mod was lost for (let i = 0; i < mod.mods[choose].count; i++) powerUps.spawn(mech.pos.x, mech.pos.y, "mod"); mod.mods[choose].count = 0; mod.mods[choose].remove(); // remove a random mod form the list of mods you have diff --git a/js/game.js b/js/game.js index 1425a4c..503cdcd 100644 --- a/js/game.js +++ b/js/game.js @@ -381,6 +381,28 @@ const game = { // } // setupCanvas(); // } + + //color testing + // if (keys[49]) { + // mech.color.hue-- + // mech.setFillColors(); + // } else if (keys[50]) { + // mech.color.hue++ + // mech.setFillColors(); + // } else if (keys[51]) { + // mech.color.sat-- + // mech.setFillColors(); + // } else if (keys[52]) { + // mech.color.sat++ + // mech.setFillColors(); + // } else if (keys[53]) { + // mech.color.light-- + // mech.setFillColors(); + // } else if (keys[54]) { + // mech.color.light++ + // mech.setFillColors(); + // } + if (keys[69]) { // e swap to next active gun game.nextGun(); } else if (keys[81]) { //q swap to previous active gun diff --git a/js/index.js b/js/index.js index 27e74f3..2c76f8f 100644 --- a/js/index.js +++ b/js/index.js @@ -84,32 +84,20 @@ window.addEventListener('load', (event) => { } if (property.substring(0, 3) === "mod") { - let found = false - let index for (let i = 0; i < mod.mods.length; i++) { if (set[property] === mod.mods[i].name) { - index = i; - found = true; + build.choosePowerUp(document.getElementById(`mod-${i}`), i, 'mod', true) break; } } - if (found) build.choosePowerUp(document.getElementById(`mod-${index}`), index, 'mod', true) } if (property === "difficulty") { game.difficultyMode = Number(set[property]) - // localSettings.difficultyMode = Number(set[property]) - // localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage - // document.getElementById("difficulty-select").value = Number(set[property]) document.getElementById("difficulty-select-custom").value = Number(set[property]) } if (property === "level") { document.getElementById("starting-level").value = Number(set[property]) - - // level.levelsCleared += Number(set[property]); - // level.difficultyIncrease(Number(set[property]) * game.difficultyMode) //increase difficulty based on modes - // spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns - // level.onLevel++ } } } @@ -265,12 +253,8 @@ const build = { modID.classList.add("build-grid-disabled"); modID.onclick = null } - if (mod.mods[i].count > 0) { - mod.removeMod(i) - } - if (modID.classList.contains("build-mod-selected")) { - modID.classList.remove("build-mod-selected"); - } + if (mod.mods[i].count > 0) mod.removeMod(i) + if (modID.classList.contains("build-mod-selected")) modID.classList.remove("build-mod-selected"); } } } @@ -425,6 +409,7 @@ document.getElementById("build-button").addEventListener("click", () => { //setu modList.push(mod.mods[i].count) } } + openCustomBuildMenu(); if (!game.firstRun) { //if player has already died once load that previous build @@ -435,7 +420,32 @@ document.getElementById("build-button").addEventListener("click", () => { //setu } for (let i = 0; i < modList.length; i++) { for (let j = 0; j < modList[i]; j++) { - build.choosePowerUp(document.getElementById(`mod-${i}`), i, 'mod') + build.choosePowerUp(document.getElementById(`mod-${i}`), i, 'mod', true) + } + } + //update mod text //disable not allowed mods + for (let i = 0, len = mod.mods.length; i < len; i++) { + const modID = document.getElementById("mod-" + i) + if (!mod.mods[i].isCustomHide) { + if (mod.mods[i].allowed() || mod.mods[i].count > 1) { + if (mod.mods[i].count > 1) { + modID.innerHTML = `
  ${mod.mods[i].name} (${mod.mods[i].count}x)
${mod.mods[i].description}` + } else { + modID.innerHTML = `
  ${mod.mods[i].name}
${mod.mods[i].description}` + } + if (modID.classList.contains("build-grid-disabled")) { + modID.classList.remove("build-grid-disabled"); + modID.setAttribute("onClick", `javascript: build.choosePowerUp(this,${i},'mod')`); + } + } else { + modID.innerHTML = `
  ${mod.mods[i].name}
requires: ${mod.mods[i].requires}` + if (!modID.classList.contains("build-grid-disabled")) { + modID.classList.add("build-grid-disabled"); + modID.onclick = null + } + // if (mod.mods[i].count > 0) mod.removeMod(i) + // if (modID.classList.contains("build-mod-selected")) modID.classList.remove("build-mod-selected"); + } } } } diff --git a/js/level.js b/js/level.js index eedaae6..9d9c131 100644 --- a/js/level.js +++ b/js/level.js @@ -15,7 +15,7 @@ const level = { // game.zoomScale = 1000; // game.setZoom(); // mech.isStealth = true; - // mech.setField("time dilation field") + // mech.setField("pilot wave") // b.giveGuns("ice IX") // mod.giveMod("quantum immortality"); @@ -3166,8 +3166,8 @@ const level = { difficultyIncrease(num = 1) { for (let i = 0; i < num; i++) { game.difficulty++ - game.dmgScale += 0.3; //damage done by mobs increases each level - b.dmgScale *= 0.93; //damage done by player decreases each level + game.dmgScale += 0.35; //damage done by mobs increases each level + b.dmgScale *= 0.92; //damage done by player decreases each level if (game.accelScale < 5) game.accelScale *= 1.027 //mob acceleration increases each level if (game.lookFreqScale > 0.2) game.lookFreqScale *= 0.975 //mob cycles between looks decreases each level if (game.CDScale > 0.2) game.CDScale *= 0.966 //mob CD time decreases each level @@ -3177,9 +3177,9 @@ const level = { difficultyDecrease(num = 1) { //used in easy mode for game.reset() for (let i = 0; i < num; i++) { game.difficulty-- - game.dmgScale -= 0.3; //damage done by mobs increases each level + game.dmgScale -= 0.35; //damage done by mobs increases each level if (game.dmgScale < 0.1) game.dmgScale = 0.1; - b.dmgScale /= 0.93; //damage done by player decreases each level + b.dmgScale /= 0.92; //damage done by player decreases each level if (game.accelScale > 0.2) game.accelScale /= 1.027 //mob acceleration increases each level if (game.lookFreqScale < 5) game.lookFreqScale /= 0.975 //mob cycles between looks decreases each level if (game.CDScale < 5) game.CDScale /= 0.966 //mob CD time decreases each level diff --git a/js/mob.js b/js/mob.js index 8aaccd2..d579395 100644 --- a/js/mob.js +++ b/js/mob.js @@ -60,37 +60,37 @@ const mobs = { }); } - function applySlow(target) { - if (!target.shield && !target.isShielded && !mech.isBodiesAsleep) { - if (target.isBoss) cycles = Math.floor(cycles * 0.25) + function applySlow() { + if (!who.shield && !who.isShielded && !mech.isBodiesAsleep) { + if (who.isBoss) cycles = Math.floor(cycles * 0.25) - let i = target.status.length + let i = who.status.length while (i--) { - if (target.status[i].type === "slow") target.status.splice(i, 1); //remove other "slow" effects on this mob + if (who.status[i].type === "slow") who.status.splice(i, 1); //remove other "slow" effects on this mob } - target.isSlowed = true; - target.status.push({ + who.isSlowed = true; + who.status.push({ effect() { - Matter.Body.setVelocity(target, { + Matter.Body.setVelocity(who, { x: 0, y: 0 }); - Matter.Body.setAngularVelocity(target, 0); + Matter.Body.setAngularVelocity(who, 0); ctx.beginPath(); - ctx.moveTo(target.vertices[0].x, target.vertices[0].y); - for (let j = 1, len = target.vertices.length; j < len; ++j) { - ctx.lineTo(target.vertices[j].x, target.vertices[j].y); + ctx.moveTo(who.vertices[0].x, who.vertices[0].y); + for (let j = 1, len = who.vertices.length; j < len; ++j) { + ctx.lineTo(who.vertices[j].x, who.vertices[j].y); } - ctx.lineTo(target.vertices[0].x, target.vertices[0].y); + ctx.lineTo(who.vertices[0].x, who.vertices[0].y); ctx.strokeStyle = "rgba(0,100,255,0.8)"; ctx.lineWidth = 15; ctx.stroke(); - ctx.fillStyle = target.fill + ctx.fillStyle = who.fill ctx.fill(); }, endEffect() { //check to see if there are not other freeze effects? - target.isSlowed = false; + who.isSlowed = false; }, type: "slow", endCycle: game.cycle + cycles, @@ -110,6 +110,7 @@ const mobs = { while (i--) { if (who.status[i].type === "stun") who.status.splice(i, 1); } + who.isStunned = true; who.status.push({ effect() { who.seePlayer.yes = false; @@ -142,7 +143,9 @@ const mobs = { }, - endEffect() {}, + endEffect() { + who.isStunned = false + }, type: "stun", endCycle: game.cycle + cycles, }) @@ -996,7 +999,7 @@ const mobs = { dmg *= mod.damageFromMods() //mobs specific damage changes if (mod.isFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(500, Math.min(3000, this.distanceToPlayer())) - 500) * 0.0067 //up to 50% dmg at max range of 3500 - if (this.shield) dmg *= 0.05 + if (this.shield) dmg *= 0.075 //energy and heal drain should be calculated after damage boosts if (mod.energySiphon && dmg !== Infinity && this.dropPowerUp) { diff --git a/js/mods.js b/js/mods.js index d3710d6..fe2be5c 100644 --- a/js/mods.js +++ b/js/mods.js @@ -79,8 +79,9 @@ const mod = { }, damageFromMods() { let dmg = 1 + if (mod.isEnergyNoAmmo) dmg *= 1.4 if (mod.isDamageForGuns) dmg *= 1 + 0.07 * b.inventory.length - if (mod.isLowHealthDmg) dmg *= 1 + 0.5 * Math.max(0, 1 - mech.health) + if (mod.isLowHealthDmg) dmg *= 1 + 0.6 * Math.max(0, 1 - mech.health) if (mod.isHarmDamage && mech.lastHarmCycle + 600 > mech.cycle) dmg *= 2; if (mod.isEnergyLoss) dmg *= 1.37; if (mod.isAcidDmg && mech.health > 1) dmg *= 1.4; @@ -126,6 +127,22 @@ const mod = { mod.isEnergyDamage = false; } }, + { + name: "exciton-lattice", + description: `increase damage by 40%, but
ammo will no longer spawn`, + maxCount: 1, + count: 0, + allowed() { + return (mod.haveGunCheck("nail gun") && mod.isIceCrystals) || mod.haveGunCheck("laser") || mod.haveGunCheck("pulse") || mech.fieldUpgrades[mech.fieldMode].name === "plasma torch" || mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" || mech.fieldUpgrades[mech.fieldMode].name === "pilot wave" + }, + requires: "energy based damage", + effect() { + mod.isEnergyNoAmmo = true; + }, + remove() { + mod.isEnergyNoAmmo = false; + } + }, { name: "acute stress response", description: "increase damage by 37%
if a mob dies drain stored energy by 25%", @@ -193,7 +210,7 @@ const mod = { }, { name: "negative feedback", - description: "increase damage by 5%
for every 10% missing base health", + description: "increase damage by 6%
for every 10% missing base health", maxCount: 1, count: 0, allowed() { @@ -713,22 +730,6 @@ const mod = { mod.isHarmArmor = false; } }, - { - name: "exciton-lattice", - description: `reduce harm by 80%, but
after a collision, eject one of your mods`, - maxCount: 1, - count: 0, - allowed() { - return !mod.isEnergyHealth && (mod.isBayesian || mod.isExtraChoice || mod.manyWorlds || mod.isImmortal || mod.isMineDrop || mod.renormalization) - }, - requires: "Bayesian, cardinality, many worlds, immortality, renormalization, or mine synthesis", - effect() { - mod.isEjectMod = true; - }, - remove() { - mod.isEjectMod = false; - } - }, { name: "clock gating", description: `slow time by 50% after receiving harm
reduce harm by 15%`, @@ -768,9 +769,9 @@ const mod = { maxCount: 1, count: 0, allowed() { - return mod.superposition + !!mod.isStunField + mod.isPulseStun + !!mod.isNeutronStun + mod.oneSuperBall + mod.isHarmFreeze + mod.isIceField + mod.isIceCrystals + mod.isSporeFreeze + mod.isAoESlow + mod.isFreezeMobs + mod.isPilotFreeze + mod.haveGunCheck("ice IX") > 1 + return mod.superposition || mod.isStunField || mod.isPulseStun || mod.isNeutronStun || mod.oneSuperBall || mod.isHarmFreeze || mod.isIceField || mod.isIceCrystals || mod.isSporeFreeze || mod.isAoESlow || mod.isFreezeMobs || mod.isPilotFreeze || mod.haveGunCheck("ice IX") }, - requires: "at least 2 freezing or stunning effects", + requires: "a freezing or stunning effect", effect() { mod.isFreezeHarmImmune = true; }, @@ -1027,8 +1028,8 @@ const mod = { } }, { - name: "Bayesian inference", - description: "33% chance to duplicate spawned power ups
ammo will no longer spawn", + name: "Bayesian statistics", + description: "25% chance to duplicate spawned power ups
after a collision, eject one of your mods", maxCount: 1, count: 0, allowed() { @@ -1110,9 +1111,9 @@ const mod = { maxCount: 1, count: 0, allowed() { - return !mod.isBayesian + return true }, - requires: "not Bayesian inference", + requires: "", effect() { mod.isAmmoForGun = true; }, @@ -1144,9 +1145,9 @@ const mod = { maxCount: 1, count: 0, allowed() { - return !mod.isEnergyHealth && !mod.isBayesian + return !mod.isEnergyHealth }, - requires: "not mass-energy equivalence
not Bayesian inference", + requires: "not mass-energy equivalence", effect: () => { mod.isAmmoFromHealth = 0.023; }, @@ -1840,7 +1841,7 @@ const mod = { }, { name: "inertial confinement", - description: "neutron bomb's initial detonation
stuns nearby mobs for 1 seconds", + description: "neutron bomb's detonation
stuns nearby mobs for 1.5 seconds", maxCount: 3, count: 0, allowed() { @@ -1848,7 +1849,7 @@ const mod = { }, requires: "neutron bomb", effect() { - mod.isNeutronStun += 60; + mod.isNeutronStun += 90; }, remove() { mod.isNeutronStun = 0; @@ -2183,7 +2184,7 @@ const mod = { }, { name: "shock wave", - description: "mobs caught in pulse's explosion are stunned", + description: "mobs caught in pulse's explosion are stunned
for up to 2 seconds", maxCount: 1, count: 0, allowed() { @@ -2719,6 +2720,6 @@ const mod = { nailGun: null, nailInstantFireRate: null, isCapacitor: null, - isEjectMod: null, + isEnergyNoAmmo: null, isFreezeHarmImmune: null } \ No newline at end of file diff --git a/js/player.js b/js/player.js index e05d35b..566532f 100644 --- a/js/player.js +++ b/js/player.js @@ -59,13 +59,15 @@ const mech = { radius: 30, fillColor: "#fff", fillColorDark: "#ccc", + color: { + hue: 0, + sat: 0, + light: 100, + }, setFillColors() { - const hue = 0 - const saturation = 10 - const light = 70 + mech.harmReduction() * 30 - // console.log(mech.harmReduction()) - this.fillColor = `hsl(${hue},${saturation}%,${light}%)` - this.fillColorDark = `hsl(${hue},${saturation}%,${light-20}%)` + console.log(mech.color) + this.fillColor = `hsl(${mech.color.hue},${mech.color.sat}%,${mech.color.light}%)` + this.fillColorDark = `hsl(${mech.color.hue},${mech.color.sat}%,${mech.color.light-20}%)` }, height: 42, yOffWhen: { @@ -473,7 +475,6 @@ const mech = { let dmg = 1 dmg *= mech.fieldHarmReduction dmg *= mod.isSlowFPS ? 0.85 : 1 - if (mod.isEjectMod) dmg *= 0.2 if (mod.isHarmReduce && mech.fieldUpgrades[mech.fieldMode].name === "negative mass field" && mech.isFieldActive) dmg *= 0.6 if (mod.isBotArmor) dmg *= 0.95 ** mod.totalBots() if (mod.isHarmArmor && mech.lastHarmCycle + 600 > mech.cycle) dmg *= 0.5; @@ -1481,7 +1482,7 @@ const mech = { }); } if (mod.isFreezeMobs) { - const ICE_DRAIN = 0.00015 + const ICE_DRAIN = 0.0003 for (let i = 0, len = mob.length; i < len; i++) { if (mob[i].distanceToPlayer() + mob[i].radius < this.fieldDrawRadius && !mob[i].shield && !mob[i].isShielded) { if (mech.energy > ICE_DRAIN * 2) { @@ -2009,7 +2010,12 @@ const mech = { mech.energy -= DRAIN; Matter.Body.setVelocity(body[i], velocity); //give block mouse velocity Matter.Body.setAngularVelocity(body[i], body[i].angularVelocity * 0.8) - body[i].force.y -= body[i].mass * game.g; //remove gravity effects + // body[i].force.y -= body[i].mass * game.g; //remove gravity effects + //blocks drift towards center of pilot wave + const sub = Vector.sub(mech.fieldPosition, body[i].position) + const unit = Vector.mult(Vector.normalise(sub), 0.00005 * Vector.magnitude(sub)) + body[i].force.x += unit.x + body[i].force.y += unit.y - body[i].mass * game.g //remove gravity effects } else { mech.fieldCDcycle = mech.cycle + 120; mech.fieldOn = false diff --git a/js/powerup.js b/js/powerup.js index 1b5b6ec..65fdc3e 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -557,10 +557,10 @@ const powerUps = { spawn(x, y, target, moving = true, mode = null) { if ( !(mod.isSuperDeterminism && (target === 'gun' || target === 'field' || target === 'reroll')) && - !(mod.isBayesian && target === 'ammo') + !(mod.isEnergyNoAmmo && target === 'ammo') ) { powerUps.directSpawn(x, y, target, moving, mode) - if (mod.isBayesian && Math.random() < 0.33) powerUps.directSpawn(x, y, target, moving, mode) + if (mod.isBayesian && Math.random() < 0.3) powerUps.directSpawn(x, y, target, moving, mode) } }, }; \ No newline at end of file diff --git a/js/spawn.js b/js/spawn.js index c367287..04f6743 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -81,8 +81,7 @@ const spawn = { } } }, - //"shooterBoss", "cellBossCulture", "bomberBoss", "spiderBoss", "launcherBoss", "laserTargetingBoss", "powerUpBoss", - randomLevelBoss(x, y, options = ["snakeBoss"]) { + randomLevelBoss(x, y, options = ["shooterBoss", "cellBossCulture", "bomberBoss", "spiderBoss", "launcherBoss", "laserTargetingBoss", "powerUpBoss", "snakeBoss"]) { // other bosses: suckerBoss, laserBoss, tetherBoss, //all need a particular level to work so they are not included spawn[options[Math.floor(Math.random() * options.length)]](x, y) }, diff --git a/todo.txt b/todo.txt index 7e463ac..93bdbfb 100644 --- a/todo.txt +++ b/todo.txt @@ -1,15 +1,13 @@ -after you die, you can find the build you used in the custom menu +blocks drift towards the center of pilot wave's field -shooterBoss - smaller, but more massive, - aims better at short range, and fires faster -bomberBoss fires faster, bombs are more likely to split +mod: Bayesian statistics - no longer stops ammo spawns + 30% to double power ups, but ejects a mod when you take damage -mod: osmoprotectant - stunned or frozen mobs cause no harm +mod: exciton-lattice - 40% damage, but no ammo can spawn ************** TODO - n-gon ************** -after you die custom should be populated with your last build -also you should be able to share while paused +change player color based on harm reduction standing wave harmonics mod - push things away push scales with mass up to about 4 @@ -18,19 +16,8 @@ standing wave harmonics mod - push things away or push away at the peak of an oscillation or always push -give drones bremstranlung radiation? - name: micro-harmonics? - reduce drone life span by 50% - drone drain energy on hits? - -add tailed level boss to random pool? - hit scan bullets -> nails -mod: frozen mobs can't do collision damage - also stunned mobs can't do collision damage - or they do reduced damage - new gun or field - fire 3+ balls in arc name: something about energy does damage in area, like neutron bomb