From 3659fbe47d02e09203a09c1ad6fd1b945085b747 Mon Sep 17 00:00:00 2001 From: landgreen Date: Thu, 20 Aug 2020 05:43:55 -0700 Subject: [PATCH] harmonic shield bug fix --- js/bullet.js | 114 ++++++++++++++++++++++++++++++++------------------ js/game.js | 15 ++++--- js/index.js | 6 ++- js/level.js | 83 ++++++++++++++++++++++++++++++++---- js/mods.js | 16 +++---- js/player.js | 16 +++++-- js/powerup.js | 2 +- js/spawn.js | 2 +- style.css | 16 +++++-- todo.txt | 14 ++++++- 10 files changed, 211 insertions(+), 73 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 51d6db3..5e3643f 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -740,31 +740,38 @@ const b = { for (let i = 0, len = powerUp.length; i < len; ++i) { if ( (powerUp[i].name !== "heal" || mech.health < 0.9 * mech.maxHealth || mod.isDroneGrab) && - Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 && - Matter.Query.ray(body, this.position, powerUp[i].position).length === 0 + (powerUp[i].name !== "field" || !mod.isDeterminism) ) { - const TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position) - const DIST = Vector.magnitude(TARGET_VECTOR); - if (DIST < closeDist) { - closeDist = DIST; - this.lockedOn = powerUp[i] + //pick up nearby power ups + if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 60000 && + !game.isChoosing) { + powerUps.onPickUp(this.position); + powerUp[i].effect(); + Matter.World.remove(engine.world, powerUp[i]); + powerUp.splice(i, 1); + if (mod.isDroneGrab) { + this.isImproved = true; + const SCALE = 2 + Matter.Body.scale(this, SCALE, SCALE); + this.lookFrequency = 30; + this.endCycle = Infinity + this.dmg *= 1.5; + this.frictionAir = 0 + } + break; } - } - if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 60000 && !game.isChoosing) { - powerUps.onPickUp(this.position); - powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); - powerUp.splice(i, 1); - if (mod.isDroneGrab) { - this.isImproved = true; - const SCALE = 2 - Matter.Body.scale(this, SCALE, SCALE); - this.lookFrequency = 30; - this.endCycle = Infinity - this.dmg *= 1.5; - this.frictionAir = 0 + //look for power ups to lock onto + if ( + Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 && + Matter.Query.ray(body, this.position, powerUp[i].position).length === 0 + ) { + const TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position) + const DIST = Vector.magnitude(TARGET_VECTOR); + if (DIST < closeDist) { + closeDist = DIST; + this.lockedOn = powerUp[i] + } } - break; } } } @@ -1563,6 +1570,34 @@ const b = { } bullet[me].do = function () { this.force.y += this.mass * 0.0003; + + + // //place in bullet do + // //slow player + // const range = 1000 + // if (Vector.magnitude(Vector.sub(player.position, this.position)) < range) { + // Matter.Body.setVelocity(player, { + // x: player.velocity.x * 0.95, + // y: player.velocity.y * 0.95 + // }); + // } + // //aoe damage to mobs + // for (let i = 0, len = mob.length; i < len; i++) { + // if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < range) { + // 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 + // mob[i].damage(dmg); + // mob[i].locatePlayer(); + // } + // } + + // //draw it + // ctx.beginPath(); + // ctx.arc(this.position.x, this.position.y, range, 0, 2 * Math.PI); + // ctx.fillStyle = `rgba(255,0,0,0.2)`; + // ctx.fill(); + }; } }, @@ -1797,9 +1832,9 @@ const b = { }, { name: "wave beam", - description: "emit a sine wave of oscillating particles
particles slowly propagate through solids", + description: "emit a sine wave of oscillating particles
that can propagate through solids", ammo: 0, - ammoPack: 80, + ammoPack: 70, have: false, fire() { mech.fireCDcycle = mech.cycle + Math.floor(3 * b.fireCD); // cool down @@ -1871,7 +1906,7 @@ const b = { for (let i = 0; i < q.length; i++) { slowCheck = 0.3; Matter.Body.setPosition(this, Vector.add(this.position, q[i].velocity)) //move with the medium - let dmg = b.dmgScale * 0.37 / Math.sqrt(q[i].mass) * (mod.waveHelix === 1 ? 1 : 0.6) //1 - 0.4 = 0.6 for helix mod 40% damage reduction + let dmg = b.dmgScale * 0.36 / Math.sqrt(q[i].mass) * (mod.waveHelix === 1 ? 1 : 0.66) //1 - 0.4 = 0.6 for helix mod 40% damage reduction q[i].damage(dmg); q[i].foundPlayer(); game.drawList.push({ //add dmg to draw queue @@ -2202,7 +2237,7 @@ const b = { }, { name: "neutron bomb", - description: "toss a chunk of Cf-252 that emits neutrons
damages and drains energy in area of effect", + description: "toss a chunk of Cf-252 which emits neutrons
that do damage, harm, and energy drain", ammo: 0, ammoPack: 5, have: false, @@ -2591,19 +2626,18 @@ const b = { bullet[me].endCycle = Infinity bullet[me].charge = 0; bullet[me].do = function () { - if ((!game.mouseDown && this.charge > 0.6) || mech.energy < 0.005) { //fire on mouse release - if (mech.energy < 0.005 && !mod.isRailTimeSlow) { - // this.charge = 0; - mech.energy += this.charge * 0.4 - mech.fireCDcycle = mech.cycle + 120; // cool down if out of energy - this.endCycle = 0; - return - } else { - mech.fireCDcycle = mech.cycle + 2; // set fire cool down - //normal bullet behavior occurs after firing, overwrite this function - this.do = function () { - this.force.y += this.mass * 0.0003 / this.charge; // low gravity that scales with charge - } + if (mech.energy < 0.005 && !mod.isRailTimeSlow) { + mech.energy += 0.05 + this.charge * 0.3 + mech.fireCDcycle = mech.cycle + 120; // cool down if out of energy + this.endCycle = 0; + return + } + + if ((!game.mouseDown && this.charge > 0.6)) { //fire on mouse release or on low energy + mech.fireCDcycle = mech.cycle + 2; // set fire cool down + //normal bullet behavior occurs after firing, overwrites this function + this.do = function () { + this.force.y += this.mass * 0.0003 / this.charge; // low gravity that scales with charge } if (mod.isRailTimeSlow) { game.fpsCap = game.fpsCapDefault @@ -2653,7 +2687,7 @@ const b = { mob[i].force.y += 1.5 * FORCE.y; } } - } else if (mech.energy > 0.005) { // charging on mouse down + } else { // charging on mouse down mech.fireCDcycle = Infinity //can't fire until mouse is released const lastCharge = this.charge let chargeRate = (mech.crouch) ? 0.98 : 0.984 diff --git a/js/game.js b/js/game.js index 5da51c1..4811b8d 100644 --- a/js/game.js +++ b/js/game.js @@ -112,6 +112,7 @@ const game = { }, g: 0.0024, // applies to player, bodies, and power ups (not mobs) onTitlePage: true, + isCheating: false, paused: false, isChoosing: false, testing: false, //testing mode: shows wire frame and some variables @@ -347,8 +348,9 @@ const game = { if (game.isConstructionMode) { document.getElementById("construct").style.display = 'none' } - } else { + } else { //if (keys[191]) game.testing = true; + game.isCheating = true; if (game.isConstructionMode) { document.getElementById("construct").style.display = 'inline' } @@ -500,12 +502,14 @@ const game = { player.force.y += player.mass * game.g; }, reset() { //run on first run, and each later run after you die + game.isCheating = false b.removeAllGuns(); mod.setupAllMods(); //sets mods to default values b.setFireCD(); game.updateModHUD(); powerUps.totalPowerUps = 0; powerUps.reroll.rerolls = 0; + mech.setFillColors(); mech.maxHealth = 1 mech.maxEnergy = 1 mech.energy = 1 @@ -792,10 +796,11 @@ const game = { testingOutput() { ctx.fillStyle = "#000"; if (!game.isConstructionMode) { - ctx.textAlign = "right"; - let line = 500; - const x = canvas.width - 5; - ctx.fillText("T: exit testing mode", x, line); + // ctx.textAlign = "right"; + ctx.fillText("T: exit testing mode", canvas.width / 2, canvas.height - 10); + // let line = 500; + // const x = canvas.width - 5; + // ctx.fillText("T: exit testing mode", x, line); // line += 20; // ctx.fillText("Y: give all mods", x, line); // line += 20; diff --git a/js/index.js b/js/index.js index 945d40b..be0bcb3 100644 --- a/js/index.js +++ b/js/index.js @@ -398,6 +398,7 @@ const build = { function openCustomBuildMenu() { build.isURLBuild = false; + game.isCheating = true; document.getElementById("build-button").style.display = "none"; const el = document.getElementById("build-grid") el.style.display = "grid" @@ -441,6 +442,7 @@ if (localSettings) { isCommunityMaps: false, difficultyMode: '1', fpsCapDefault: 'max', + runCount: -1, }; localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage document.getElementById("community-maps").checked = localSettings.isCommunityMaps @@ -466,7 +468,9 @@ function setupCanvas() { canvas.width2 = canvas.width / 2; //precalculated because I use this often (in mouse look) canvas.height2 = canvas.height / 2; canvas.diagonal = Math.sqrt(canvas.width2 * canvas.width2 + canvas.height2 * canvas.height2); - ctx.font = "18px Arial"; + // ctx.font = "18px Arial"; + // ctx.textAlign = "center"; + ctx.font = "25px Arial"; ctx.lineJoin = "round"; ctx.lineCap = "round"; // ctx.lineCap='square'; diff --git a/js/level.js b/js/level.js index 545e9d2..80b2fe9 100644 --- a/js/level.js +++ b/js/level.js @@ -16,10 +16,9 @@ const level = { // game.zoomScale = 1000; // game.setZoom(); // mech.isStealth = true; - // mod.giveMod("bot replication"); - // mod.nailBotCount += 10 // b.giveGuns("rail gun") - // mech.setField("plasma torch") + // mech.setField("standing wave harmonics") + // mod.giveMod("frame-dragging"); level.intro(); //starting level // level.testing(); //not in rotation @@ -40,6 +39,10 @@ const level = { spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns // spawn.pickList = ["focuser", "focuser"] level[level.levels[level.onLevel]](); //picks the current map from the the levels array + if (!game.isCheating) { + localSettings.runCount += level.levelsCleared //track the number of total runs locally + localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage + } } level.levelAnnounce(); game.noCameraScroll(); @@ -629,7 +632,71 @@ const level = { level.custom = () => { level.playerExitCheck(); }; - level.customTopLayer = () => {}; + // ctx.font = "30px Arial"; + // ctx.textAlign = "center"; + level.customTopLayer = () => { + // ctx.fillStyle = '#000'; + // ctx.fillText(`${(localSettings.runCount >>> 0).toString(2)}`, 2850, -530); + }; + const binary = (localSettings.runCount >>> 0).toString(2) + const height = 25 + const thick = 2 + const color = "#aaa" + const xOff = -130 //2622 + const yOff = -45 //-580 + let xLetter = 0 + for (let i = 0; i < binary.length; i++) { + if (binary[i] === "0") { + zero(xOff + xLetter, yOff) + } else { + one(xOff + xLetter, yOff) + } + } + + function one(x, y) { + level.fillBG.push({ + x: x, + y: y, + width: thick, + height: height, + color: color + }); + xLetter += 10 + } + + function zero(x, y) { + const width = 10 + level.fillBG.push({ + x: x, + y: y, + width: thick, + height: height, + color: color + }); + level.fillBG.push({ + x: x + width, + y: y, + width: thick, + height: height, + color: color + }); + level.fillBG.push({ + x: x, + y: y, + width: width, + height: thick, + color: color + }); + level.fillBG.push({ + x: x, + y: y + height - thick, + width: width, + height: thick, + color: color + }); + xLetter += 10 + width + } + level.setPosToSpawn(460, -100); //normal spawn level.enter.x = -1000000; //hide enter graphic for first level by moving to the far left @@ -1981,13 +2048,13 @@ const level = { spawn.debris(3500, -650, 800, 5); //1st floor debris //16 debris per level powerUps.spawnStartingPowerUps(-525, -700); - spawn.mapRect(-600, 25, 5600, 300); //ground - spawn.mapRect(-600, 0, 2000, 50); //ground + spawn.mapRect(-600, 0, 2000, 325); //ground + spawn.mapRect(1400, 25, 1600, 300); //ground + spawn.mapRect(3000, 0, 2000, 325); //ground spawn.mapRect(-600, -1700, 50, 2000 - 100); //left wall spawn.bodyRect(-295, -1540, 40, 40); //center block under wall spawn.bodyRect(-298, -1580, 40, 40); //center block under wall spawn.bodyRect(1500, -1540, 30, 30); //left of entrance - spawn.mapRect(1550, -2000, 50, 550); //right wall spawn.mapRect(1350, -2000 + 505, 50, 1295); //right wall spawn.mapRect(-600, -2000 + 250, 2000 - 700, 50); //roof left @@ -2022,9 +2089,7 @@ const level = { spawn.bodyRect(700, -400, 100, 100); //center block under wall spawn.mapRect(1390, 13, 30, 20); //step left spawn.mapRect(2980, 13, 30, 20); //step right - spawn.mapRect(3000, 0, 2000, 50); //ground spawn.bodyRect(4250, -700, 50, 100); - // spawn.bodyRect(3000, -200, 50, 200); //door spawn.mapRect(3000, -1000, 50, 800); //left wall spawn.mapRect(3000 + 2000 - 50, -1300, 50, 1100); //right wall spawn.mapRect(4150, -600, 350, 150); //table diff --git a/js/mods.js b/js/mods.js index f3b15bf..d366785 100644 --- a/js/mods.js +++ b/js/mods.js @@ -86,7 +86,7 @@ const mod = { if (mod.isAcidDmg && mech.health > 1) dmg *= 1.4; if (mod.isRest && player.speed < 1) dmg *= 1.20; if (mod.isEnergyDamage) dmg *= 1 + mech.energy / 5.5; - if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005 + if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.004 if (mod.isRerollDamage) dmg *= 1 + 0.05 * powerUps.reroll.rerolls if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.25 return dmg * mod.slowFire @@ -693,7 +693,7 @@ const mod = { mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles }, remove() { - mod.collisionImmuneCycles = 15; + mod.collisionImmuneCycles = 25; } }, { @@ -1341,7 +1341,7 @@ const mod = { }, { name: "microstates", - description: "increase damage by 5%
for every 10 active bullets", + description: "increase damage by 4%
for every 10 active bullets", maxCount: 1, count: 0, allowed() { @@ -2013,6 +2013,8 @@ const mod = { }, remove() { mod.isRailTimeSlow = false; + game.fpsCap = game.fpsCapDefault + game.fpsInterval = 1000 / game.fpsCap; } }, { @@ -2268,7 +2270,7 @@ const mod = { }, requires: "standing wave harmonics", effect() { - mod.blockDmg += 0.35 //if you change this value also update the for loop in the electricity graphics in mech.pushMass + mod.blockDmg += 0.66 //if you change this value also update the for loop in the electricity graphics in mech.pushMass }, remove() { mod.blockDmg = 0; @@ -2284,7 +2286,7 @@ const mod = { }, requires: "standing wave harmonics", effect() { - mech.fieldRange += 175 * 0.21 + mech.fieldRange += 175 * 0.17 mech.fieldShieldingScale *= 0.6 }, remove() { @@ -2359,7 +2361,7 @@ const mod = { }, { name: "renormalization", - description: "using a reroll to change selection options
has a 60% chance to spawn a reroll", + description: "using a reroll to change selection options
has a 66% chance to spawn a reroll", maxCount: 1, count: 0, allowed() { @@ -2375,7 +2377,7 @@ const mod = { }, { name: "superposition", - description: "mobs that touch the phased player
are stunned for 4 seconds", + description: "mobs that touch the phased player
are stunned for 5 seconds", maxCount: 1, count: 0, allowed() { diff --git a/js/player.js b/js/player.js index eb0fc82..3093b3b 100644 --- a/js/player.js +++ b/js/player.js @@ -57,8 +57,16 @@ const mech = { lastHarmCycle: 0, width: 50, radius: 30, - fillColor: "#fff", //changed by mod piezoelectric plating (damage immunity) + fillColor: "#fff", fillColorDark: "#ccc", + 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}%)` + }, height: 42, yOffWhen: { crouch: 22, @@ -967,8 +975,8 @@ const mech = { } if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy; - if (mod.blockDmg && mech.fieldUpgrades[mech.fieldMode].name === "standing wave harmonics") { - who.damage(mod.blockDmg) + if (mod.blockDmg) { + who.damage(mod.blockDmg * b.dmgScale) //draw electricity const step = 40 ctx.beginPath(); @@ -1797,7 +1805,7 @@ const mech = { // inPlayer[i].damage(0.4 * b.dmgScale); //damage mobs inside the player // mech.energy += 0.005; - mobs.statusStun(inPlayer[i], 240) + mobs.statusStun(inPlayer[i], 300) //draw outline of mob in a few random locations to show blurriness const vertices = inPlayer[i].vertices; const off = 30 diff --git a/js/powerup.js b/js/powerup.js index 3ddfbfc..73815d9 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -100,7 +100,7 @@ const powerUps = { use(type) { //runs when you actually reroll a list of selections, type can be field, gun, or mod powerUps.reroll.changeRerolls(-1) powerUps[type].effect(); - if (mod.renormalization && Math.random() < 0.6) { + if (mod.renormalization && Math.random() < 0.66) { powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); } diff --git a/js/spawn.js b/js/spawn.js index b23847e..adb581e 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -368,7 +368,7 @@ const spawn = { // Matter.Body.setDensity(me, 0.0007); //extra dense //normal is 0.001 //makes effective life much lower me.friction = 0; me.frictionAir = 0; - me.accelMag = 0.001 * game.accelScale;; + me.accelMag = 0.001 * Math.sqrt(game.accelScale); me.g = me.accelMag * 0.6; //required if using 'gravity' me.memory = 50; spawn.shield(me, x, y); diff --git a/style.css b/style.css index ab327a5..0047fd7 100644 --- a/style.css +++ b/style.css @@ -492,11 +492,19 @@ em { } .circle-grid { - width: 23px; - height: 23px; + width: 27px; + height: 27px; border-radius: 50%; display: inline-block; - margin-bottom: -5px; + margin-bottom: -7px; +} + +.circle-grid-shadow { + width: 43px; + height: 43px; + border-radius: 50%; + display: inline-block; + margin-bottom: -15px; } .circle-gun-mod { @@ -527,7 +535,7 @@ em { } .gun { - background: #149; + background: rgb(15, 75, 179); } .heal { diff --git a/todo.txt b/todo.txt index 53a5d0c..c0ee1ba 100644 --- a/todo.txt +++ b/todo.txt @@ -1,9 +1,21 @@ -mods: foam does 200% more damage, but dissolves 50% faster +base collisions immunity frames is now 25/60 of a second (up from 15/60) + +mod: bremsstrahlung radiation - damage increased by 5x + bug fix it is now properly affected by damage scaling (huge nerf late game) + ************** TODO - n-gon ************** +look into why wave beam is so good vs. shields +group shields having way too much health at higher levels? + +give missiles a suck and delay explosion, like vacuum bomb + +bot, does AOE damage while it rotates around player + no physics / collisions + cap 3 ? Mod: "Instant Acceleration": Minigun instantly starts firing at max fire rate, skipping the accelerated fire rate stage.