From 4a355caa6027d3b407d36c7bfd75bd2b4696b452 Mon Sep 17 00:00:00 2001 From: landgreen Date: Sun, 17 May 2020 19:23:24 -0700 Subject: [PATCH] mod - microstates mod - many worlds: 100% chance on choosing a power up to spawn a reroll if you have no rerolls mod - microstates: +7% damage for every 10 active bullets (requires mod: Lorentzian topology) mod - laser diode: laser, pulse, and laser-bots use 37% less energy 25% increase in difficulty scaling (level 10 should now have the difficulty of level 12) effects: player damage, mod damage, mob acceleration, mob reaction time, mob cooldown time --- index.html | 1 + js/bullets.js | 55 +++++++++++++++++++++++++++++++++++++----------- js/game.js | 7 +++++- js/level.js | 41 +++++++++++++++++++++++++++++------- js/mobs.js | 2 +- js/player.js | 18 ++++++++-------- js/powerups.js | 2 +- js/visibility.js | 43 +++++++++++++++++++++++++++++++++++++ style.css | 8 +++---- todo.txt | 16 ++++++++------ 10 files changed, 151 insertions(+), 42 deletions(-) create mode 100644 js/visibility.js diff --git a/index.html b/index.html index e9d2bb7..9691749 100644 --- a/index.html +++ b/index.html @@ -519,6 +519,7 @@ + diff --git a/js/bullets.js b/js/bullets.js index 1ec48a0..a73efdc 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -87,6 +87,8 @@ const b = { isModSlowFPS: null, isModNeutronStun: null, manyWorlds: null, + isModDamageFromBulletCount: null, + isModLaserDiode: null, modOnHealthChange() { //used with acid mod if (b.isModAcidDmg && mech.health > 0.8) { b.modAcidDmg = 0.5 @@ -816,8 +818,8 @@ const b = { } }, { - name: "many worlds", - description: "after choosing a gun, field, or mod
66% chance to spawn a reroll", + name: "many-worlds", + description: "if you have zero rerolls, spawn a reroll
after choosing a gun, field, or mod", maxCount: 1, count: 0, allowed() { @@ -826,10 +828,6 @@ const b = { requires: "", effect: () => { b.manyWorlds = true; - // for (let i = 0; i < 9; i++) { - // powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); - // if (Math.random() < b.modBayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); - // } }, remove() { b.manyWorlds = false; @@ -944,6 +942,22 @@ const b = { b.isModBulletsLastLonger = 1; } }, + { + name: "microstates", + description: "+7% damage for every 10 active bullets", + maxCount: 3, + count: 0, + allowed() { + return b.isModBulletsLastLonger > 1 + }, + requires: "Lorentzian topology", + effect() { + b.isModDamageFromBulletCount = true + }, + remove() { + b.isModDamageFromBulletCount = false + } + }, { name: "depleted uranium rounds", description: `your bullets are +16% larger
increased mass and physical damage`, @@ -1432,6 +1446,22 @@ const b = { b.isModRailNails = false; } }, + { + name: "laser diodes", + description: "lasers drain 37% less energy
effects laser gun, pulse gun, and laser-bot", + maxCount: 1, + count: 0, + allowed() { + return b.haveGunCheck("pulse") || b.haveGunCheck("laser") || b.modLaserBotCount > 1 + }, + requires: "laser", + effect() { + b.isModLaserDiode = 0.63; //100%-37% + }, + remove() { + b.isModLaserDiode = 1; + } + }, { name: "specular reflection", description: "laser beams gain +1 reflection
+50% laser damage and energy drain", @@ -1604,7 +1634,7 @@ const b = { maxCount: 1, count: 0, allowed() { - return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModMissileField || b.isModIceField) + return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModMissileField || b.isModIceField || b.isModFastDrones) }, requires: "nano-scale manufacturing", effect() { @@ -1620,7 +1650,7 @@ const b = { maxCount: 1, count: 0, allowed() { - return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModIceField) + return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModIceField || b.isModFastDrones) }, requires: "nano-scale manufacturing", effect() { @@ -1636,7 +1666,7 @@ const b = { maxCount: 1, count: 0, allowed() { - return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModMissileField) + return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModMissileField || b.isModFastDrones) }, requires: "nano-scale manufacturing", effect() { @@ -1801,6 +1831,7 @@ const b = { if (b.isModEnergyLoss) dmg *= 1.33; if (b.isModRest && player.speed < 1) dmg *= 1.20; if (b.isModEnergyDamage) dmg *= 1 + mech.energy / 5.5; + if (b.isModDamageFromBulletCount) dmg *= 1 + bullet.length * 0.007 return dmg }, bulletRemove() { //run in main loop @@ -2834,7 +2865,7 @@ const b = { //hit target with laser if (this.lockedOn && this.lockedOn.alive && mech.energy > 0.15) { - mech.energy -= 0.0014 + mech.energy -= 0.0014 * b.isModLaserDiode //make sure you can still see vertex const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position)); if (DIST - this.lockedOn.radius < this.range + 150 && @@ -4117,7 +4148,7 @@ const b = { if (mech.energy < b.modLaserFieldDrain) { mech.fireCDcycle = mech.cycle + 100; // cool down if out of energy } else { - mech.energy -= mech.fieldRegen + b.modLaserFieldDrain + mech.energy -= mech.fieldRegen + b.modLaserFieldDrain * b.isModLaserDiode let best = { x: null, y: null, @@ -4345,7 +4376,7 @@ const b = { //use energy to explode const energy = 0.3 * Math.min(mech.energy, 1.75) - mech.energy -= energy + mech.energy -= energy * b.isModLaserDiode if (best.who) b.explosion(path[1], 1000 * energy, true) mech.fireCDcycle = mech.cycle + Math.floor(60 * b.modFireRate); // cool down diff --git a/js/game.js b/js/game.js index dc65ec2..5f8c0b7 100644 --- a/js/game.js +++ b/js/game.js @@ -49,6 +49,7 @@ const game = { mobs.healthBar(); mech.draw(); mech.hold(); + // v.draw(); //working on visibility work in progress level.drawFills(); game.draw.drawMapPath(); b.fire(); @@ -515,7 +516,8 @@ const game = { game.difficultyMode = 1 level.difficultyDecrease(6); //if this stops being -6 change in build.calculateCustomDifficulty() } - if (game.difficultyMode === 4) level.difficultyIncrease(6) + if (game.difficultyMode === 2) level.difficultyIncrease(1) + if (game.difficultyMode === 4) level.difficultyIncrease(4) game.clearNow = true; document.getElementById("text-log").style.opacity = 0; @@ -703,6 +705,9 @@ const game = { }, checks() { if (!(mech.cycle % 60)) { //once a second + console.log(bullet.length * 0.005) + + if (mech.pos.y > game.fallHeight) { // if 4000px deep if (game.difficultyMode > 2) { mech.death(); diff --git a/js/level.js b/js/level.js index 76cdee6..8003b2f 100644 --- a/js/level.js +++ b/js/level.js @@ -60,27 +60,52 @@ const level = { // if (level.isBuildRun) num++ for (let i = 0; i < num; i++) { game.difficulty++ - game.dmgScale += 0.17; //damage done by mobs increases each level + game.dmgScale += 0.205; //damage done by mobs increases each level b.dmgScale *= 0.91; //damage done by player decreases each level - game.accelScale *= 1.02 //mob acceleration increases each level - game.lookFreqScale *= 0.98 //mob cycles between looks decreases each level - game.CDScale *= 0.97 //mob CD time decreases each level + game.accelScale *= 1.024 //mob acceleration increases each level + game.lookFreqScale *= 0.976 //mob cycles between looks decreases each level + game.CDScale *= 0.964 //mob CD time decreases each level } game.healScale = 1 / (1 + game.difficulty * 0.09) //a higher denominator makes for lower heals // mech.health += heal * game.healScale; }, difficultyDecrease(num = 1) { //used in easy mode for game.reset() for (let i = 0; i < num; i++) { game.difficulty-- - game.dmgScale -= 0.17; //damage done by mobs increases each level + game.dmgScale -= 0.205; //damage done by mobs increases each level if (game.dmgScale < 0.1) game.dmgScale = 0.1; b.dmgScale /= 0.91; //damage done by player decreases each level - game.accelScale /= 1.02 //mob acceleration increases each level - game.lookFreqScale /= 0.98 //mob cycles between looks decreases each level - game.CDScale /= 0.97 //mob CD time decreases each level + game.accelScale /= 1.024 //mob acceleration increases each level + game.lookFreqScale /= 0.976 //mob cycles between looks decreases each level + game.CDScale /= 0.964 //mob CD time decreases each level } if (game.difficulty < 1) game.difficulty = 0; game.healScale = 1 / (1 + game.difficulty * 0.09) }, + // difficultyIncrease(num = 1) { + // // if (level.isBuildRun) num++ + // for (let i = 0; i < num; i++) { + // game.difficulty++ + // game.dmgScale += 0.17; //damage done by mobs increases each level + // b.dmgScale *= 0.91; //damage done by player decreases each level + // game.accelScale *= 1.02 //mob acceleration increases each level + // game.lookFreqScale *= 0.98 //mob cycles between looks decreases each level + // game.CDScale *= 0.97 //mob CD time decreases each level + // } + // game.healScale = 1 / (1 + game.difficulty * 0.09) //a higher denominator makes for lower heals // mech.health += heal * game.healScale; + // }, + // difficultyDecrease(num = 1) { //used in easy mode for game.reset() + // for (let i = 0; i < num; i++) { + // game.difficulty-- + // game.dmgScale -= 0.17; //damage done by mobs increases each level + // if (game.dmgScale < 0.1) game.dmgScale = 0.1; + // b.dmgScale /= 0.91; //damage done by player decreases each level + // game.accelScale /= 1.02 //mob acceleration increases each level + // game.lookFreqScale /= 0.98 //mob cycles between looks decreases each level + // game.CDScale /= 0.97 //mob CD time decreases each level + // } + // if (game.difficulty < 1) game.difficulty = 0; + // game.healScale = 1 / (1 + game.difficulty * 0.09) + // }, difficultyText(mode = document.getElementById("difficulty-select").value) { if (mode === "0") { return "easy" diff --git a/js/mobs.js b/js/mobs.js index 4beba84..02f29be 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -1089,7 +1089,7 @@ const mobs = { const len = body.length; const v = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //might help with vertex collision issue, not sure body[len] = Matter.Bodies.fromVertices(this.position.x, this.position.y, v); - Matter.Body.setVelocity(body[len], this.velocity); + Matter.Body.setVelocity(body[len], Vector.mult(this.velocity, 0.5)); Matter.Body.setAngularVelocity(body[len], this.angularVelocity); body[len].collisionFilter.category = cat.body; body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet; diff --git a/js/player.js b/js/player.js index dcb3390..932af36 100644 --- a/js/player.js +++ b/js/player.js @@ -378,7 +378,7 @@ const mech = { b.mods[i].name !== "Born rule" && b.mods[i].name !== "determinism" && b.mods[i].name !== "reallocation" && - b.mods[i].name !== "many worlds" && + b.mods[i].name !== "many-worlds" && b.mods[i].allowed() ) options.push(i); } @@ -551,7 +551,7 @@ const mech = { mech.energy = mech.maxEnergy * 0.5 // if (mech.energy < 0.05) mech.energy = 0.05 mech.immuneCycle = mech.cycle + 120 //disable this.immuneCycle bonus seconds - game.makeTextLog(" death avoided
1 reroll consumed
", 300) + game.makeTextLog(" death avoided
1 reroll consumed
", 420) game.wipe = function () { //set wipe to have trails ctx.fillStyle = "rgba(255,255,255,0.03)"; @@ -579,7 +579,7 @@ const mech = { mech.health = mech.maxHealth * 0.5 // if (mech.health < 0.05) mech.health = 0.05 mech.immuneCycle = mech.cycle + 120 //disable this.immuneCycle bonus seconds - game.makeTextLog(" death avoided
1 reroll consumed
", 300) + game.makeTextLog(" death avoided
1 reroll consumed
", 420) game.wipe = function () { //set wipe to have trails ctx.fillStyle = "rgba(255,255,255,0.03)"; @@ -1829,12 +1829,12 @@ const mech = { mech.fieldPhase = 0; mech.hold = function () { - function expandField() { - if (this.fieldRange < 2000) { - this.fieldRange += 100 - drawField(this.fieldRange) - } - } + // function expandField() { + // if (this.fieldRange < 2000) { + // this.fieldRange += 100 + // drawField(this.fieldRange) + // } + // } function drawField(radius) { radius *= 0.9 + 1 * mech.energy; diff --git a/js/powerups.js b/js/powerups.js index a6b0cd1..6698b41 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -21,7 +21,7 @@ const powerUps = { powerUps.endDraft(); }, endDraft() { - if (b.manyWorlds && Math.random() < 0.66) { + if (b.manyWorlds && powerUps.reroll.rerolls < 1) { powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); if (Math.random() < b.modBayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); } diff --git a/js/visibility.js b/js/visibility.js new file mode 100644 index 0000000..2a10809 --- /dev/null +++ b/js/visibility.js @@ -0,0 +1,43 @@ +// redblobgames.com/articles/visibility +// https://github.com/Silverwolf90/2d-visibility/tree/master/src +// could apply to explosions, neutron bomb, player LOS + + +const v = { + points: [], + populate() { + v.points = [{ + x: -150, + y: -950 + }, { + x: 710, + y: -950 + }, { + x: 710, + y: -940 + }, { + x: 710, + y: -710 + }, { + x: 710, + y: -700 + }, { + x: -150, + y: -700 + }] + }, + draw() { + ctx.beginPath(); + ctx.moveTo(v.points[0].x, v.points[0].y) + for (let i = 0, len = v.points.length; i < len; i++) { + ctx.lineTo(v.points[i].x, v.points[i].y) + } + // ctx.fillStyle = "#333" + ctx.globalCompositeOperation = "destination-in"; + ctx.fill(); + ctx.globalCompositeOperation = "source-over"; + ctx.clip(); + } +} +v.populate(); +// console.log(v.points) \ No newline at end of file diff --git a/style.css b/style.css index f0fdf70..20ca940 100644 --- a/style.css +++ b/style.css @@ -250,11 +250,11 @@ summary { } .build-mod-selected { - background-color: hsl(247, 100%, 84%); + background-color: hsl(253, 100%, 84%); } .build-mod-selected:hover { - background-color: hsl(247, 100%, 81%); + background-color: hsl(253, 100%, 81%); } .build-grid-disabled { @@ -462,7 +462,7 @@ em { } .color-m { - color: hsl(246, 57%, 52%); + color: hsl(253, 57%, 52%); letter-spacing: 1px; } @@ -500,7 +500,7 @@ em { .mod { /* background: rgb(116, 102, 238); */ - background: hsl(246, 80%, 67%); + background: hsl(253, 80%, 67%); } .grey { diff --git a/todo.txt b/todo.txt index a17cbf9..d600ab6 100644 --- a/todo.txt +++ b/todo.txt @@ -1,12 +1,16 @@ -anthropic principle - now consumes 1 rerolls, and heals player to 50% health instead of letting them die -many worlds - 66% chance for rerolls -quantum immortality - also gives 3 rerolls -mod drones - Brushless Motor: drones move faster -mod drones - redundant systems: removed -choices in power up selection should no longer repeat the previous choices when possible +mod - many worlds: 100% chance on choosing a power up to spawn a reroll if you have no rerolls +mod - microstates: +7% damage for every 10 active bullets + (requires mod: Lorentzian topology) +mod - laser diode: laser, pulse, and laser-bots use 37% less energy +25% increase in difficulty scaling (level 10 should now have the difficulty of level 12) + effects: player damage, mod damage, mob acceleration, mob reaction time, mob cooldown time ************** TODO - n-gon ************** +rays can have width, how to use this? + Matter.Query.ray(bodies, startPoint, endPoint, [rayWidth]) + wide lasers? + bug - mines spawn extra mines when fired at thin map wall while jumping mod - negative mass field move faster