diff --git a/js/bullets.js b/js/bullets.js index fc57a8e..972cc66 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -409,9 +409,9 @@ const b = { maxCount: 1, count: 0, allowed() { - return true + return !b.isModEnergyHealth }, - requires: "", + requires: "not mass-energy equivalence", effect() { b.isModHealthRecovery = true; }, @@ -556,10 +556,12 @@ const b = { mech.health = 0 b.modOnHealthChange(); mech.displayHealth(); + document.getElementById("health-bg").style.display = "none" b.isModEnergyHealth = true; }, remove() { b.isModEnergyHealth = false; + document.getElementById("health-bg").style.display = "inline" mech.health = mech.energy; } }, @@ -621,9 +623,9 @@ const b = { maxCount: 9, count: 0, allowed() { - return true + return !b.isModEnergyHealth }, - requires: "", + requires: "not mass-energy equivalence", effect() { b.modHealthDrain += 0.015; }, @@ -654,9 +656,9 @@ const b = { maxCount: 9, count: 0, allowed() { - return true + return !b.isModEnergyHealth }, - requires: "", + requires: "not mass-energy equivalence", effect() { mech.maxHealth += 0.50 mech.addHealth(0.50) @@ -673,9 +675,9 @@ const b = { maxCount: 9, count: 0, allowed() { - return mech.health < 0.7 || build.isCustomSelection + return (mech.health < 0.7 || build.isCustomSelection) && !b.isModEnergyHealth }, - requires: "health below 70%", + requires: "not mass-energy equivalence", effect() { b.modRecursiveHealing += 1 }, @@ -734,13 +736,13 @@ const b = { }, { name: "catabolism", - description: "gain ammo when you fire while out of ammo
drains 3% of current remaining health", + description: "gain ammo when you fire while out of ammo
drains 3% of current remaining health", maxCount: 1, count: 0, allowed() { - return true + return !b.isModEnergyHealth }, - requires: "", + requires: "not mass-energy equivalence", effect: () => { b.isModAmmoFromHealth = 0.03; }, @@ -972,26 +974,8 @@ const b = { } }, { - name: "wave phase velocity", - description: "the wave beam propagates faster in solids", - maxCount: 1, - count: 0, - allowed() { - return b.haveGunCheck("wave beam") - }, - requires: "wave beam", - effect() { - b.modWaveSpeedMap = 3 - b.modWaveSpeedBody = 1.9 - }, - remove() { - b.modWaveSpeedMap = 0.08 - b.modWaveSpeedBody = 0.25 - } - }, - { - name: "double helix", - description: "wave beam emits two out of phase particles
wave particles do 40% less damage", + name: "wave packet", + description: "wave beam emits two oscillating particles
wave particles do 40% less damage", maxCount: 1, count: 0, allowed() { @@ -1005,14 +989,31 @@ const b = { b.modWaveHelix = 1 } }, - { - name: "pocket universe", - description: "wave beam bullets last 4 times longer
bullets are confined to a region around player", + name: "phase velocity", + description: "the wave beam propagates faster in solids", maxCount: 1, count: 0, allowed() { - return b.haveGunCheck("wave beam") + return b.haveGunCheck("wave beam") && !b.isModWaveReflect + }, + requires: "wave beam", + effect() { + b.modWaveSpeedMap = 3 //needs to be 3 for pocket universe require check + b.modWaveSpeedBody = 1.9 + }, + remove() { + b.modWaveSpeedMap = 0.08 + b.modWaveSpeedBody = 0.25 + } + }, + { + name: "pocket universe", + description: "wave beam bullets last 5x longer
bullets are confined to a region around player", + maxCount: 1, + count: 0, + allowed() { + return b.haveGunCheck("wave beam") && b.modWaveSpeedMap !== 3 }, requires: "wave beam", effect() { @@ -1235,7 +1236,7 @@ const b = { } }, { - name: "foam stabilization", + name: "quantum foam", description: "foam can stick to shields", maxCount: 1, count: 0, @@ -1466,7 +1467,7 @@ const b = { }, { name: "renormalization", - description: "phase decoherence field has 3x visibility
and 3x less energy drain when firing", + description: "phase decoherence field has increased visibility
and 3x less energy drain when firing", maxCount: 1, count: 0, allowed() { @@ -1474,10 +1475,10 @@ const b = { }, requires: "phase decoherence field", effect() { - b.modRenormalization = 3; + b.modRenormalization = true; }, remove() { - b.modRenormalization = 1; + b.modRenormalization = false; } }, { @@ -2540,7 +2541,7 @@ const b = { game.makeGunHUD(); }, guns: [{ - name: "minigun", //0 + name: "minigun", description: "rapidly fire a stream of small bullets", ammo: 0, ammoPack: 65, @@ -2577,7 +2578,7 @@ const b = { } }, { - name: "shotgun", //1 + name: "shotgun", description: "fire a burst of short range bullets
crouch to reduce recoil", ammo: 0, ammoPack: 11, @@ -2624,7 +2625,7 @@ const b = { } }, { - name: "super balls", //2 + name: "super balls", description: "fire four balls in a wide arc
balls bounce with no momentum loss", ammo: 0, ammoPack: 14, @@ -2681,7 +2682,7 @@ const b = { } }, { - name: "flechettes", //3 + name: "flechettes", description: "fire a volley of uranium-235 needles
does damage over 3 seconds", ammo: 0, ammoPack: 23, @@ -2735,7 +2736,7 @@ const b = { } }, { - name: "wave beam", //4 + name: "wave beam", description: "emit a sine wave of oscillating particles
particles slowly propagate through solids", ammo: 0, ammoPack: 110, @@ -2746,14 +2747,20 @@ const b = { mech.fireCDcycle = mech.cycle + Math.floor(3 * b.modFireRate); // cool down const dir = mech.angle const SPEED = 10 - const wiggleMag = mech.crouch ? 6 : 12 + let wiggleMag + if (b.modWaveHelix === 2) { + wiggleMag = (mech.crouch ? 6 : 12) * (1 + Math.sin(mech.cycle * 0.1)) + } else { + wiggleMag = mech.crouch ? 6 : 12 + } + // const wiggleMag = b.modWaveHelix ? (mech.crouch ? 6 + 6 * Math.sin(mech.cycle * 0.1) : 13 + 13 * Math.sin(mech.cycle * 0.1)) : (mech.crouch ? 6 : 12) const size = 5 * (b.modWaveHelix === 1 ? 1 : 0.7) for (let i = 0; i < b.modWaveHelix; i++) { const me = bullet.length; bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 7, size, { angle: dir, cycle: -0.5, - endCycle: game.cycle + Math.floor((b.isModWaveReflect ? 480 : 120) * b.isModBulletsLastLonger), + endCycle: game.cycle + Math.floor((b.isModWaveReflect ? 600 : 120) * b.isModBulletsLastLonger), inertia: Infinity, frictionAir: 0, slow: 0, @@ -2769,36 +2776,62 @@ const b = { onEnd() {}, do() { if (!mech.isBodiesAsleep) { - let slowCheck = 1; - if (Matter.Query.point(map, this.position).length) { //check if inside map - slowCheck = b.modWaveSpeedMap - } else { //check if inside a body - let q = Matter.Query.point(body, this.position) - if (q.length) { - slowCheck = b.modWaveSpeedBody - Matter.Body.setPosition(this, Vector.add(this.position, q[0].velocity)) //move with the medium - } else { // check if inside a mob - q = Matter.Query.point(mob, this.position) - 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.43 / Math.sqrt(q[i].mass) * (b.modWaveHelix === 1 ? 1 : 0.6) //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 - x: this.position.x, - y: this.position.y, - radius: Math.log(2 * dmg + 1.1) * 40, - color: 'rgba(0,0,0,0.4)', - time: game.drawTime - }); + if (b.isModWaveReflect) { + // check if inside a mob + q = Matter.Query.point(mob, this.position) + for (let i = 0; i < q.length; i++) { + let dmg = b.dmgScale * 0.43 / Math.sqrt(q[i].mass) * (b.modWaveHelix === 1 ? 1 : 0.6) //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 + x: this.position.x, + y: this.position.y, + radius: Math.log(2 * dmg + 1.1) * 40, + color: 'rgba(0,0,0,0.4)', + time: game.drawTime + }); + } + Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player + const sub = Vector.sub(this.position, mech.pos) + const range = 558 //93 * x + if (Vector.magnitude(sub) > range) { + // Matter.Body.setPosition(this, Vector.sub(this.position, Vector.mult(Vector.normalise(sub), 2 * range))) //teleport to opposite side + Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); + // Matter.Body.setPosition(this, Vector.add(mech.pos, Vector.mult(Vector.normalise(sub), range))) + } + } else { + let slowCheck = 1 + if (Matter.Query.point(map, this.position).length) { //check if inside map + slowCheck = b.modWaveSpeedMap + } else { //check if inside a body + let q = Matter.Query.point(body, this.position) + if (q.length) { + slowCheck = b.modWaveSpeedBody + Matter.Body.setPosition(this, Vector.add(this.position, q[0].velocity)) //move with the medium + } else { // check if inside a mob + q = Matter.Query.point(mob, this.position) + 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.43 / Math.sqrt(q[i].mass) * (b.modWaveHelix === 1 ? 1 : 0.6) //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 + x: this.position.x, + y: this.position.y, + radius: Math.log(2 * dmg + 1.1) * 40, + color: 'rgba(0,0,0,0.4)', + time: game.drawTime + }); + } } } + if (slowCheck !== this.slow) { //toggle velocity based on inside and outside status change + this.slow = slowCheck + Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), SPEED * slowCheck)); + } } - if (slowCheck !== this.slow) { //toggle velocity based on inside and outside status change - this.slow = slowCheck - Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), SPEED * slowCheck)); - } + this.cycle++ const wiggle = Vector.mult(transverse, wiggleMag * Math.cos(this.cycle * 0.35) * ((i % 2) ? -1 : 1)) Matter.Body.setPosition(this, Vector.add(this.position, wiggle)) @@ -2814,14 +2847,6 @@ const b = { // } // } - if (b.isModWaveReflect) { - Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player - const sub = Vector.sub(this.position, mech.pos) - if (Vector.magnitude(sub) > 630) { - Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * 630))) //teleport to opposite side - } - } - // if (b.isModWaveReflect) { // Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player @@ -2917,7 +2942,7 @@ const b = { } }, { - name: "grenades", //7 + name: "grenades", description: "lob a single bouncy projectile
explodes on contact or after one second", ammo: 0, ammoPack: 7, @@ -2979,7 +3004,7 @@ const b = { } }, { - name: "vacuum bomb", //8 + name: "vacuum bomb", description: "fire a bomb that sucks before exploding
click left mouse again to detonate", ammo: 0, ammoPack: 3, @@ -3101,7 +3126,7 @@ const b = { } }, { - name: "mine", //9 + name: "mine", description: "toss a proximity mine that sticks to walls
fires nails at mobs within range", ammo: 0, ammoPack: 3, @@ -3121,7 +3146,7 @@ const b = { } }, { - name: "spores", //10 + name: "spores", description: "fire a sporangium that discharges spores", ammo: 0, ammoPack: (game.difficultyMode > 3) ? 3 : 4, @@ -3167,7 +3192,7 @@ const b = { } }, { - name: "drones", //11 + name: "drones", description: "deploy drones that crash into mobs
collisions reduce their lifespan by 1 second", ammo: 0, ammoPack: 12, @@ -3180,7 +3205,7 @@ const b = { } }, { - name: "ice IX", //11 + name: "ice IX", description: "synthesize short-lived ice crystals
crystals seek out and freeze mobs", ammo: 0, ammoPack: 75, @@ -3199,7 +3224,7 @@ const b = { } }, { - name: "foam", //12 + name: "foam", description: "spray bubbly foam that sticks to mobs
slows mobs and does damage over time", ammo: 0, ammoPack: 35, @@ -3299,7 +3324,7 @@ const b = { } }, { - name: "rail gun", //13 + name: "rail gun", description: "use energy to launch a high-speed dense rod
hold left mouse to charge, release to fire", ammo: 0, ammoPack: 4, @@ -3553,7 +3578,7 @@ const b = { } }, { - name: "laser", //14 + name: "laser", description: "emit a beam of collimated coherent light
drains energy instead of ammunition", ammo: 0, ammoPack: Infinity, @@ -3712,7 +3737,7 @@ const b = { } }, { - name: "pulse", //15 + name: "pulse", description: "convert 25% of your energy into a pulsed laser
instantly initiates a fusion explosion", ammo: 0, ammoPack: Infinity, diff --git a/js/engine.js b/js/engine.js index 38f9f5b..665e3fd 100644 --- a/js/engine.js +++ b/js/engine.js @@ -144,7 +144,19 @@ function collisionChecks(event) { } mech.damage(dmg); if (mob[k].onHit) mob[k].onHit(k); - if (b.isModAnnihilation) { + + //extra kick between player and mob //this section would be better with forces but they don't work... + let angle = Math.atan2(player.position.y - mob[k].position.y, player.position.x - mob[k].position.x); + Matter.Body.setVelocity(player, { + x: player.velocity.x + 8 * Math.cos(angle), + y: player.velocity.y + 8 * Math.sin(angle) + }); + Matter.Body.setVelocity(mob[k], { + x: mob[k].velocity.x - 8 * Math.cos(angle), + y: mob[k].velocity.y - 8 * Math.sin(angle) + }); + + if (b.isModAnnihilation && !mob[k].shield && !mob[k].isShielded) { mob[k].death(); game.drawList.push({ //add dmg to draw queue @@ -165,16 +177,6 @@ function collisionChecks(event) { }); } - //extra kick between player and mob //this section would be better with forces but they don't work... - let angle = Math.atan2(player.position.y - mob[k].position.y, player.position.x - mob[k].position.x); - Matter.Body.setVelocity(player, { - x: player.velocity.x + 8 * Math.cos(angle), - y: player.velocity.y + 8 * Math.sin(angle) - }); - Matter.Body.setVelocity(mob[k], { - x: mob[k].velocity.x - 8 * Math.cos(angle), - y: mob[k].velocity.y - 8 * Math.sin(angle) - }); return; } //mob + bullet collisions diff --git a/js/level.js b/js/level.js index 8ed243b..1087efa 100644 --- a/js/level.js +++ b/js/level.js @@ -15,12 +15,14 @@ const level = { if (build.isURLBuild && level.levelsCleared === 0) build.onLoadPowerUps(); if (level.levelsCleared === 0) { //this code only runs on the first level // level.difficultyIncrease(9) - b.giveGuns("rail gun") - // mech.setField("pilot wave") - // b.giveMod("nonlocality"); + // b.giveGuns("wave beam") + // mech.setField("phase decoherence field") + // b.giveMod("renormalization"); + // b.giveMod("pocket universe"); + // b.giveMod("wave packet"); - // level.intro(); //starting level - level.testing(); + level.intro(); //starting level + // level.testing(); // level.stronghold() // level.bosses(); // level.satellite(); diff --git a/js/player.js b/js/player.js index 91e746b..e5df93b 100644 --- a/js/player.js +++ b/js/player.js @@ -1318,9 +1318,9 @@ const mech = { // mech.fieldArc = 0.3; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) // mech.calculateFieldThreshold(); mech.hold = function () { - const wave = Math.sin(mech.cycle * 0.02); - mech.fieldRange = 165 + 10 * wave - mech.fieldArc = 0.3 + 0.03 * wave //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) + const wave = Math.sin(mech.cycle * 0.022); + mech.fieldRange = 165 + 12 * wave + mech.fieldArc = 0.3 + 0.035 * wave //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) mech.calculateFieldThreshold(); if (mech.isHolding) { mech.drawHold(mech.holdingTarget); @@ -1517,7 +1517,6 @@ const mech = { if (mob[i].distanceToPlayer2() < this.fieldDrawRadius * this.fieldDrawRadius && Matter.Query.ray(map, mech.pos, mob[i].position).length === 0 && Matter.Query.ray(body, mech.pos, mob[i].position).length === 0) { mob[i].damage(b.dmgScale * 0.085); mob[i].locatePlayer(); - //draw electricity const sub = Vector.sub(mob[i].position, mech.pos) const unit = Vector.normalise(sub); @@ -1535,7 +1534,6 @@ const mech = { ctx.lineWidth = 1; ctx.strokeStyle = "rgba(0,255,0,0.5)" //"#fff"; ctx.stroke(); - } } } @@ -1821,23 +1819,24 @@ const mech = { mech.hold = function () { function drawField(radius) { - radius *= 0.6 + 0.7 * mech.energy * b.modRenormalization; + radius *= 0.7 + 0.6 * mech.energy; const rotate = mech.cycle * 0.005; - mech.fieldPhase += 0.5 - 0.5 * Math.sqrt(Math.min(mech.energy, 1)); + mech.fieldPhase += 0.5 - 0.5 * Math.sqrt(Math.max(0.01, Math.min(mech.energy, 1))); const off1 = 1 + 0.06 * Math.sin(mech.fieldPhase); const off2 = 1 - 0.06 * Math.sin(mech.fieldPhase); ctx.beginPath(); ctx.ellipse(mech.pos.x, mech.pos.y, radius * off1, radius * off2, rotate, 0, 2 * Math.PI); - if (mech.fireCDcycle > mech.cycle && (keys[32] || game.mouseDownRight)) { - ctx.lineWidth = 5; - ctx.strokeStyle = `rgba(0, 204, 255,1)` - ctx.stroke() - } if (b.modRenormalization) { for (let i = 0; i < bullet.length; i++) { ctx.moveTo(bullet[i].position.x, bullet[i].position.y) ctx.arc(bullet[i].position.x, bullet[i].position.y, radius, 0, 2 * Math.PI); } + } else { + if (mech.fireCDcycle > mech.cycle && (keys[32] || game.mouseDownRight)) { + ctx.lineWidth = 5; + ctx.strokeStyle = `rgba(0, 204, 255,1)` + ctx.stroke() + } } ctx.fillStyle = "#fff" //`rgba(0,0,0,${0.5+0.5*mech.energy})`; ctx.globalCompositeOperation = "destination-in"; //in or atop @@ -1857,7 +1856,7 @@ const mech = { mech.grabPowerUp(); mech.lookForPickUp(); - const DRAIN = (0.0004 + 0.00007 * player.speed) * (mech.fireCDcycle > mech.cycle ? 7 / b.modRenormalization : 1) //game.mouseDown + const DRAIN = 0.0004 + 0.0002 * player.speed + ((!b.modRenormalization && mech.fireCDcycle > mech.cycle) ? 0.005 : 0.0017) if (mech.energy > DRAIN) { mech.energy -= DRAIN; if (mech.energy < 0.001) { @@ -1875,9 +1874,9 @@ const mech = { if (inPlayer.length > 0) { for (let i = 0; i < inPlayer.length; i++) { if (inPlayer[i].shield) { - mech.energy -= 0.01; //shields drain player energy + mech.energy -= 0.005; //shields drain player energy //draw outline of shield - ctx.fillStyle = `rgba(0, 204, 255,0.6)` + ctx.fillStyle = `rgba(140,217,255,0.5)` ctx.fill() } else if (b.superposition && inPlayer[i].dropPowerUp) { // inPlayer[i].damage(0.4 * b.dmgScale); //damage mobs inside the player diff --git a/js/powerups.js b/js/powerups.js index 9d655a8..7d83a2f 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -225,7 +225,7 @@ const powerUps = { } }, spawnRandomPowerUp(x, y) { //mostly used after mob dies - if (Math.random() * Math.random() - 0.3 > Math.sqrt(mech.health) || Math.random() < 0.035) { //spawn heal chance is higher at low health + if ((Math.random() * Math.random() - 0.3 > Math.sqrt(mech.health) && !b.isModEnergyHealth) || Math.random() < 0.035) { //spawn heal chance is higher at low health powerUps.spawn(x, y, "heal"); if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "heal"); return; @@ -264,7 +264,7 @@ const powerUps = { // } else if (Math.random() < 0.5) { // powerUps.spawn(x, y, "field"); // if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field"); - } else if (mech.health < 0.65) { + } else if (mech.health < 0.65 && !b.isModEnergyHealth) { powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal"); diff --git a/js/spawn.js b/js/spawn.js index 7fc169e..f002e14 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -833,7 +833,7 @@ const spawn = { me.onDeath = function () { powerUps.spawnBossPowerUp(this.position.x, this.position.y) }; - me.rotateVelocity = Math.min(0.01, 0.0025 * game.accelScale * game.accelScale) * (level.levelsCleared > 8 ? 1 : -1) + me.rotateVelocity = Math.min(0.0054, 0.0022 * game.accelScale * game.accelScale) * (level.levelsCleared > 8 ? 1 : -1) me.do = function () { this.fill = '#' + Math.random().toString(16).substr(-6); //flash colors // Matter.Body.rotate(this, -0.003 / (0.3 + this.health))