From b2cb88832cca8aaca185e884b3471e88413aee12 Mon Sep 17 00:00:00 2001 From: landgreen Date: Tue, 6 Oct 2020 05:01:59 -0700 Subject: [PATCH] difficulty bug fix --- js/bullet.js | 119 +++++++++++++++++++++++++++++++++++--------------- js/game.js | 4 +- js/level.js | 12 ++--- js/powerup.js | 2 +- js/spawn.js | 5 +-- todo.txt | 1 - 6 files changed, 94 insertions(+), 49 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 04ac2b7..b9f09a3 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -1837,6 +1837,84 @@ const b = { } mech.fireCDcycle = mech.cycle + Math.floor(CD * b.fireCD); // cool down + + // const range = 2000 + // const totalBullets = 6 + // const angleStep = (mech.crouch ? 0.06 : 0.25) / totalBullets + // let dir = mech.angle - angleStep * totalBullets / 2; + // for (let i = 0; i < totalBullets; i++) { + // dir += angleStep + // const vertexCollision = function (v1, v1End, domain) { + // for (let i = 0; i < domain.length; ++i) { + // let vertices = domain[i].vertices; + // const len = vertices.length - 1; + // for (let j = 0; j < len; j++) { + // results = game.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]); + // if (results.onLine1 && results.onLine2) { + // const dx = v1.x - results.x; + // const dy = v1.y - results.y; + // const dist2 = dx * dx + dy * dy; + // if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) { + // best = { + // x: results.x, + // y: results.y, + // dist2: dist2, + // who: domain[i], + // v1: vertices[j], + // v2: vertices[j + 1] + // }; + // } + // } + // } + // results = game.checkLineIntersection(v1, v1End, vertices[0], vertices[len]); + // if (results.onLine1 && results.onLine2) { + // const dx = v1.x - results.x; + // const dy = v1.y - results.y; + // const dist2 = dx * dx + dy * dy; + // if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) { + // best = { + // x: results.x, + // y: results.y, + // dist2: dist2, + // who: domain[i], + // v1: vertices[0], + // v2: vertices[len] + // }; + // } + // } + // } + // }; + // const path = [{ + // x: mech.pos.x, + // y: mech.pos.y + // }, + // { + // x: mech.pos.x + range * Math.cos(dir), + // y: mech.pos.y + range * Math.sin(dir) + // } + // ]; + // let best = { + // x: null, + // y: null, + // dist2: Infinity, + // who: null, + // v1: null, + // v2: null + // }; + // vertexCollision(path[path.length - 2], path[path.length - 1], mob); + // vertexCollision(path[path.length - 2], path[path.length - 1], map); + // vertexCollision(path[path.length - 2], path[path.length - 1], body); + + // if (best.dist2 !== Infinity) { //if hitting something + // b.explosion({ + // x: best.x, + // y: best.y + // }, (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50); + // } else { + // b.explosion(path[path.length - 1], (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50); + // } + // } + const speed = 30 + 6 * Math.random() + 9 * mod.nailInstantFireRate const angle = mech.angle + (Math.random() - 0.5) * (Math.random() - 0.5) * (mech.crouch ? 1.35 : 3.2) / CD const dmg = 0.9 @@ -1856,35 +1934,6 @@ const b = { mech.energy -= mech.fieldRegen + 0.008 if (mech.energy < 0.02) mech.fireCDcycle = mech.cycle + 60; // cool down } - - - - // } else { - // if (this.nextFireCycle + 1 < mech.cycle) this.startingHoldCycle = mech.cycle //reset if not constantly firing - // const CD = Math.max(11 - 0.06 * (mech.cycle - this.startingHoldCycle), 2) //CD scales with cycles fire is held down - // this.nextFireCycle = mech.cycle + CD * b.fireCD //predict next fire cycle if the fire button is held down - - // const me = bullet.length; - // const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.01 : 0.1); - // bullet[me] = Bodies.rectangle(pos.x, pos.y, 20 * mod.bulletSize, 6 * mod.bulletSize, b.fireAttributes(dir)); - // b.fireProps(CD, mech.crouch ? 38 : 34, dir, me); //cd , speed - - // bullet[me].endCycle = game.cycle + 70; - // bullet[me].dmg = 0.25; - // bullet[me].frictionAir = mech.crouch ? 0.001 : 0.003; - // if (mod.isIceCrystals) { - // bullet[me].onDmg = function (who) { - // mobs.statusSlow(who, 30) - // }; - // mech.energy -= mech.fieldRegen + 0.0075 - // if (mech.energy < 0.02) { - // mech.fireCDcycle = mech.cycle + 60; // cool down - // } - // } - // bullet[me].do = function () { - // this.force.y += this.mass * 0.0003; - // }; - // } } }, { @@ -2321,7 +2370,6 @@ const b = { const totalBullets = 6 const angleStep = (mech.crouch ? 0.06 : 0.25) / totalBullets let dir = mech.angle - angleStep * totalBullets / 2; - for (let i = 0; i < totalBullets; i++) { //5 -> 7 dir += angleStep const me = bullet.length; @@ -2331,7 +2379,6 @@ const b = { x: (SPEED + 15 * Math.random() - 2 * i) * Math.cos(dir), y: (SPEED + 15 * Math.random() - 2 * i) * Math.sin(dir) }); - bullet[me].endCycle = 2 * i + game.cycle + END bullet[me].restitution = 0; bullet[me].friction = 1; @@ -2343,7 +2390,7 @@ const b = { this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion }; bullet[me].do = function () { - this.force.y += this.mass * 0.0004; + // this.force.y += this.mass * 0.0004; } } } @@ -2651,7 +2698,7 @@ const b = { //aoe damage to mobs for (let i = 0, len = mob.length; i < len; i++) { if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < this.damageRadius) { - let dmg = b.dmgScale * 0.023 + let dmg = b.dmgScale * 0.025 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 *= 4 //x5 to make up for the /5 that shields normally take mob[i].damage(dmg); @@ -2830,10 +2877,10 @@ const b = { fire() { if (mech.crouch) { b.drone(45) - mech.fireCDcycle = mech.cycle + Math.floor(17 * b.fireCD); // cool down + mech.fireCDcycle = mech.cycle + Math.floor(13 * b.fireCD); // cool down } else { b.drone(1) - mech.fireCDcycle = mech.cycle + Math.floor(10 * b.fireCD); // cool down + mech.fireCDcycle = mech.cycle + Math.floor(6 * b.fireCD); // cool down } } }, @@ -3239,7 +3286,7 @@ const b = { mech.energy -= mech.fieldRegen + mod.laserFieldDrain * mod.isLaserDiode if (mod.isWideLaser) { const off = 8 - const dmg = 0.4 * mod.laserDamage // 5 * 0.4 = 200% more damage + const dmg = 0.55 * mod.laserDamage // 3.5 * 0.55 = 200% more damage const where = { x: mech.pos.x + 20 * Math.cos(mech.angle), y: mech.pos.y + 20 * Math.sin(mech.angle) diff --git a/js/game.js b/js/game.js index aa82260..b2c3597 100644 --- a/js/game.js +++ b/js/game.js @@ -659,7 +659,7 @@ const game = { game.difficultyMode = 1 level.difficultyDecrease(6); //if this stops being -6 change in build.calculateCustomDifficulty() } - if (game.difficultyMode === 4) level.difficultyIncrease(3) + if (game.difficultyMode > 1) level.difficultyIncrease(3) game.clearNow = true; document.getElementById("text-log").style.opacity = 0; @@ -844,7 +844,7 @@ const game = { if (!(mech.cycle % 60)) { //once a second //every second energy above max energy loses 25% - if (mech.energy > mech.maxEnergy) mech.energy = 1 + (mech.maxEnergy - mech.energy) * 0.75 + if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy + (mech.energy - mech.maxEnergy) * 0.75 if (mech.pos.y > game.fallHeight) { // if 4000px deep if (game.difficultyMode > 2) { diff --git a/js/level.js b/js/level.js index 60bd594..a79af99 100644 --- a/js/level.js +++ b/js/level.js @@ -10,21 +10,21 @@ const level = { levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber"], start() { if (level.levelsCleared === 0) { //this code only runs on the first level - level.difficultyIncrease(8) + // level.difficultyIncrease(8) // game.enableConstructMode() //used to build maps in testing mode // game.zoomScale = 1000; // game.setZoom(); // mech.isCloak = true; // mech.setField("perfect diamagnetism") - // b.giveGuns("laser") + // b.giveGuns("nail gun") // for (let i = 0; i < 10; i++) { // mod.giveMod("laser-bot"); // } // mod.giveMod("eddy current brake") - level.intro(); //starting level - // level.testing(); //not in rotation + // level.intro(); //starting level + level.testing(); //not in rotation // level.template() //not in rotation // level.testChamber() //less mobs, more puzzle // level.sewers(); @@ -150,12 +150,12 @@ const level = { // spawn.sniper(1800, -120) // spawn.sniper(2200, -120) // spawn.cellBossCulture(1600, -500) - spawn.starter(1600, -500) + // spawn.starter(1600, -500) // spawn.powerUpBoss(1600, -500) // spawn.shield(mob[mob.length - 1], 1200, -500, 1); // spawn.nodeBoss(1200, -500, "launcher") - // spawn.spiderBoss(1200, -500) + spawn.snakeBoss(1200, -500) // spawn.timeSkipBoss(2900, -500) // spawn.randomMob(1600, -500) }, diff --git a/js/powerup.js b/js/powerup.js index 70f6437..de92a68 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -506,7 +506,7 @@ const powerUps = { }, spawnStartingPowerUps(x, y) { //used for map specific power ups, mostly to give player a starting gun if (level.levelsCleared < 4) { //runs 4 times on all difficulty levels - if (game.difficultyMode === 4 && level.levelsCleared > 1) powerUps.spawn(x, y, "mod") + if (game.difficultyMode > 1 && level.levelsCleared > 1) powerUps.spawn(x, y, "mod") //bonus power ups for clearing runs in the last game if (level.levelsCleared === 0 && !game.isCheating) { diff --git a/js/spawn.js b/js/spawn.js index d8e3537..c384444 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -1984,12 +1984,11 @@ const spawn = { this.attraction(); }; }, - snakeBoss(x, y, radius = 80) { - //snake boss with a laser head + snakeBoss(x, y, radius = 75) { //snake boss with a laser head mobs.spawn(x, y, 8, radius, "rgb(255,50,130)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.accelMag = 0.0012 * game.accelScale; + me.accelMag = 0.0011 * game.accelScale; me.memory = 200; me.laserRange = 500; Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger diff --git a/todo.txt b/todo.txt index 40f25b6..d07ff0f 100644 --- a/todo.txt +++ b/todo.txt @@ -1,4 +1,3 @@ -mod perfect diamagnetism: eddy current brake - mobs have a speed limit when they are near you ************** TODO - n-gon **************