From c63d0ac5f05dfab325a708ebd4886d261105abd5 Mon Sep 17 00:00:00 2001 From: landgreen Date: Wed, 15 Jul 2020 11:12:51 -0700 Subject: [PATCH] bug fixes --- js/bullet.js | 17 +++++++++-------- js/index.js | 15 +++++++++------ js/level.js | 35 ++++++++++++++++++++++------------- js/mob.js | 8 ++++---- js/mods.js | 16 +++++++++------- js/player.js | 5 +++-- js/powerup.js | 25 ++++++++++++++++--------- todo.txt | 11 +---------- 8 files changed, 73 insertions(+), 59 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 34bcc89..6e85e41 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -1143,18 +1143,19 @@ const b = { //fire plasma at target - const DRAIN = 0.002 - if (this.lockedOn && this.lockedOn.alive && mech.energy > DRAIN && mech.fieldCDcycle < mech.cycle) { - mech.energy -= DRAIN; - if (mech.energy < 0) { - mech.fieldCDcycle = mech.cycle + 120; - mech.energy = 0; - } + if (this.lockedOn && this.lockedOn.alive && mech.fieldCDcycle < mech.cycle) { const sub = Vector.sub(this.lockedOn.position, this.position) const DIST = Vector.magnitude(sub); const unit = Vector.normalise(sub) - if (DIST < mod.isPlasmaRange * 600) { + + const DRAIN = 0.0022 + if (DIST < mod.isPlasmaRange * 550 && mech.energy > DRAIN) { + mech.energy -= DRAIN; + if (mech.energy < 0) { + mech.fieldCDcycle = mech.cycle + 120; + mech.energy = 0; + } //calculate laser collision let best; let range = mod.isPlasmaRange * (140 + 300 * Math.sqrt(Math.random())) diff --git a/js/index.js b/js/index.js index 48c4a5d..c15f8b5 100644 --- a/js/index.js +++ b/js/index.js @@ -93,17 +93,20 @@ const build = { PAUSED               press P to resume
- level: ${level.levelsCleared} - ${level.levels[level.onLevel]} (${level.difficultyText()}) -
${mob.length} mobs,   ${body.length} blocks,   ${bullet.length} bullets,   ${powerUp.length} power ups -
mouse: (${game.mouseInGame.x.toFixed(1)}, ${game.mouseInGame.y.toFixed(1)})   ${mech.cycle} cycles + damage increase: ${((mod.damageFromMods()-1)*100).toFixed(0)}% +
harm reduction: ${((1-mech.harmReduction())*100).toFixed(0)}% +
fire delay decrease: ${((1-b.fireCD)*100).toFixed(0)}%


health: (${(mech.health*100).toFixed(0)} / ${(mech.maxHealth*100).toFixed(0)})   energy: (${(mech.energy*100).toFixed(0)} / ${(mech.maxEnergy*100).toFixed(0)})
mass: ${player.mass.toFixed(1)}   rerolls: ${powerUps.reroll.rerolls}
position: (${player.position.x.toFixed(1)}, ${player.position.y.toFixed(1)})   velocity: (${player.velocity.x.toFixed(1)}, ${player.velocity.y.toFixed(1)})
-
damage increase: ${((mod.damageFromMods()-1)*100).toFixed(0)}% -
harm reduction: ${((1-mech.harmReduction())*100).toFixed(0)}% -
fire delay decrease: ${((1-b.fireCD)*100).toFixed(0)}% +
level: ${level.levelsCleared} - ${level.levels[level.onLevel]} (${level.difficultyText()}) +
${mob.length} mobs,   ${body.length} blocks,   ${bullet.length} bullets,   ${powerUp.length} power ups +
mouse: (${game.mouseInGame.x.toFixed(1)}, ${game.mouseInGame.y.toFixed(1)})   ${mech.cycle} cycles +
harm difficulty scale: ${(game.dmgScale*100).toFixed(0)}% +
damage difficulty scale: ${(b.dmgScale*100).toFixed(0) }% +
heal difficulty scale: ${(game.healScale*100).toFixed(0)}%
`; let countGuns = 0 let countMods = 0 diff --git a/js/level.js b/js/level.js index 5323108..0ffa367 100644 --- a/js/level.js +++ b/js/level.js @@ -14,7 +14,7 @@ const level = { // level.difficultyIncrease(4) // game.enableConstructMode() //used to build maps in testing mode // mech.isStealth = true; - // mod.giveMod("superfluidity"); + // mod.giveMod("bot fabrication"); // b.giveGuns("ice IX") // mech.setField("plasma torch") @@ -64,8 +64,8 @@ const level = { mech.maxHealth += 0.05 * powerUps.totalPowerUps if (powerUps.totalPowerUps) game.makeTextLog(" max health increased by " + (0.05 * powerUps.totalPowerUps * 100).toFixed(0) + "%", 300) } - if (mod.isHealLowHealth && mech.health < mech.maxHealth * 0.5 * game.healScale) { - mech.health = mech.maxHealth * 0.5 * game.healScale + if (mod.isHealLowHealth && mech.health < mech.maxHealth * 0.66 * game.healScale) { + mech.health = mech.maxHealth * 0.66 * game.healScale mech.displayHealth(); } }, @@ -133,20 +133,20 @@ const level = { composite[composite.length] = rotor return rotor }, - button(x, y, width = 70, height = 20) { - spawn.mapVertex(x + 35, y + 27, "70 10 -70 10 -40 -10 40 -10"); + button(x, y, width = 70) { + spawn.mapVertex(x + 35, y + 2, "70 10 -70 10 -40 -10 40 -10"); return { isUp: false, min: { x: x, - y: y + y: y - 15 }, max: { x: x + width, - y: y + height + y: y - 5 }, width: width, - height: height, + height: 20, query() { if (Matter.Query.region(body, this).length === 0 && Matter.Query.region([player], this).length === 0) { this.isUp = true; @@ -156,11 +156,10 @@ const level = { }, draw() { ctx.fillStyle = "hsl(0, 100%, 70%)" - // ctx.fillStyle = "hsl(287, 30%, 65%)" if (this.isUp) { - ctx.fillRect(this.min.x, this.min.y, this.width, 20) + ctx.fillRect(this.min.x, this.min.y - 10, this.width, 20) } else { - ctx.fillRect(this.min.x, this.min.y + 10, this.width, 25) + ctx.fillRect(this.min.x, this.min.y, this.width, 25) } } } @@ -207,7 +206,7 @@ const level = { }, sewers() { const rotor = level.rotor(5100, 2425, -0.001) - const button = level.button(6600, 2650) + const button = level.button(6600, 2675) const hazard = level.hazard(4550, 2750, 4550, 150) level.custom = () => { @@ -324,6 +323,7 @@ const level = { spawn.randomMob(2075, 2025, 0.8); spawn.randomMob(3475, 2175, 0.8); if (game.difficulty > 3) spawn.randomLevelBoss(6000, 2300, ["spiderBoss", "launcherBoss", "laserTargetingBoss"]); + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, template() { level.custom = () => { @@ -360,6 +360,7 @@ const level = { // spawn.randomMob(2650, -975, 0.8); // spawn.randomBoss(1700, -900, 0.4); // if (game.difficulty > 3) spawn.randomLevelBoss(2200, -1300); + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, testing() { level.custom = () => { @@ -495,6 +496,7 @@ const level = { spawn.randomBoss(5000 + 500 * (Math.random() - 0.5), -800 + 200 * (Math.random() - 0.5), Infinity); } } + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, intro() { level.custom = () => { @@ -814,6 +816,7 @@ const level = { spawn.laserBoss(600 + 200 * Math.random(), -2150 + 250 * Math.random()); } } + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, rooftops() { level.custom = () => { @@ -1016,6 +1019,7 @@ const level = { spawn.randomBoss(2225, -1325, 0.4); spawn.randomBoss(4900, -1200, 0); if (game.difficulty > 3) spawn.randomLevelBoss(3200, -2050); + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, aerie() { level.custom = () => { @@ -1208,7 +1212,7 @@ const level = { spawn.suckerBoss(4500, -400); } } - //add mini boss, giant hopper? or a black hole that spawns hoppers? + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, skyscrapers() { level.custom = () => { @@ -1367,6 +1371,7 @@ const level = { spawn.randomBoss(3700, -1500, 0.4); spawn.randomBoss(1700, -900, 0.4); if (game.difficulty > 3) spawn.randomLevelBoss(2200, -1300); + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, highrise() { level.custom = () => { @@ -1529,6 +1534,7 @@ const level = { spawn.randomBoss(-3250, -2700, 0.2); spawn.randomBoss(-2450, -1100, 0); if (game.difficulty > 4) spawn.randomLevelBoss(-3400, -2800); + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, warehouse() { level.custom = () => { @@ -1698,6 +1704,7 @@ const level = { spawn.snakeBoss(-1300 + Math.random() * 2000, -2200); //boss snake with head } } + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, office() { level.custom = () => { @@ -1881,6 +1888,7 @@ const level = { spawn.shooterBoss(2200, -650); } } + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, stronghold() { // player made level by Francois 👑 from discord level.custom = () => { @@ -2116,6 +2124,7 @@ const level = { spawn.randomBoss(100, -450, 0.9); if (game.difficulty > 3) spawn.randomLevelBoss(1850, -1400); + powerUps.addRerollToLevel() //needs to run after mobs are spawned }, //****************************************************************************************************************** //****************************************************************************************************************** diff --git a/js/mob.js b/js/mob.js index a59da8e..032fc1d 100644 --- a/js/mob.js +++ b/js/mob.js @@ -973,19 +973,19 @@ const mobs = { if (!this.isShielded || isBypassShield) { dmg *= mod.damageFromMods() //mobs specific damage changes - dmg /= Math.sqrt(this.mass) - if (this.shield) dmg *= 0.05 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 //energy and heal drain should be calculated after damage boosts - if (mod.energySiphon && dmg !== Infinity) { + if (mod.energySiphon && dmg !== Infinity && this.dropPowerUp) { mech.energy += Math.min(this.health, dmg) * mod.energySiphon if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy } - if (mod.healthDrain && dmg !== Infinity) { + if (mod.healthDrain && dmg !== Infinity && this.dropPowerUp) { mech.addHealth(Math.min(this.health, dmg) * mod.healthDrain) if (mech.health > mech.maxHealth) mech.health = mech.maxHealth } + dmg /= Math.sqrt(this.mass) this.health -= dmg //this.fill = this.color + this.health + ')'; this.onDamage(dmg); //custom damage effects diff --git a/js/mods.js b/js/mods.js index ed49abb..ddb6a03 100644 --- a/js/mods.js +++ b/js/mods.js @@ -468,10 +468,11 @@ const mod = { }, requires: "at least 3 rerolls", effect() { - mob.isRerollBots = true; + mod.isRerollBots = true; + powerUps.reroll.changeRerolls(0) }, remove() { - mob.isRerollBots = false; + mod.isRerollBots = false; } }, { @@ -523,6 +524,7 @@ const mod = { b.guns[i].ammo = Math.floor(b.guns[i].ammo * 0.1); } } + game.updateGunHUD(); //double bots for (let i = 0; i < mod.nailBotCount; i++) { b.nailBot(); @@ -753,7 +755,7 @@ const mod = { }, { name: "energy conservation", - description: "13% of damage done recovered as energy", + description: "10% of damage done recovered as energy", maxCount: 9, count: 0, allowed() { @@ -761,7 +763,7 @@ const mod = { }, requires: "", effect() { - mod.energySiphon += 0.13; + mod.energySiphon += 0.1; }, remove() { mod.energySiphon = 0; @@ -818,7 +820,7 @@ const mod = { }, { name: "entropy exchange", - description: "heal for 1.5% of damage done", + description: "heal for 1% of damage done", maxCount: 9, count: 0, allowed() { @@ -826,7 +828,7 @@ const mod = { }, requires: "not mass-energy equivalence", effect() { - mod.healthDrain += 0.015; + mod.healthDrain += 0.01; }, remove() { mod.healthDrain = 0; @@ -852,7 +854,7 @@ const mod = { }, { name: "negentropy", - description: "at the start of each level
heal up to 50% of maximum health", + description: "at the start of each level
heal up to 66% of maximum health", maxCount: 1, count: 0, allowed() { diff --git a/js/player.js b/js/player.js index e4aecc2..9791101 100644 --- a/js/player.js +++ b/js/player.js @@ -472,7 +472,7 @@ const mech = { mech.energy = mech.maxEnergy // 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
", 420) + game.makeTextLog(` death avoided
1/${powerUps.reroll.rerolls} rerolls consumed
`, 420) game.wipe = function () { //set wipe to have trails ctx.fillStyle = "rgba(255,255,255,0.03)"; @@ -501,7 +501,8 @@ const mech = { mech.health = mech.maxHealth * game.healScale // 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
", 420) + game.makeTextLog(` death avoided
1/${powerUps.reroll.rerolls} rerolls consumed
`, 420) + // game.makeTextLog(" death avoided
1 reroll consumed
", 420) game.wipe = function () { //set wipe to have trails ctx.fillStyle = "rgba(255,255,255,0.03)"; diff --git a/js/powerup.js b/js/powerup.js index 78b6fa0..63a9b6d 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -55,14 +55,12 @@ const powerUps = { powerUps.reroll.rerolls += amount if (powerUps.reroll.rerolls < 0) powerUps.reroll.rerolls = 0 - if (mob.isRerollBots) { + if (mod.isRerollBots) { const limit = 3 for (; powerUps.reroll.rerolls > limit - 1; powerUps.reroll.rerolls -= limit) { b.randomBot() } } - - if (mod.isDeathAvoid && document.getElementById("mod-anthropic")) { document.getElementById("mod-anthropic").innerHTML = `(${powerUps.reroll.rerolls})` } @@ -405,11 +403,11 @@ const powerUps = { if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field"); return; } - if (Math.random() < 0.01) { - powerUps.spawn(x, y, "reroll"); - if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "reroll"); - return; - } + // if (Math.random() < 0.01) { + // powerUps.spawn(x, y, "reroll"); + // if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "reroll"); + // return; + // } }, randomPowerUpCounter: 0, spawnBossPowerUp(x, y) { //boss spawns field and gun mod upgrades @@ -465,14 +463,23 @@ const powerUps = { }, chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris - if (Math.random() < 0.05) { + if (Math.random() < 0.01) { powerUps.spawn(x, y, "reroll"); + if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "reroll"); } else if (Math.random() < 0.5) { powerUps.spawn(x, y, "heal", false); + if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "heal", false); } else if (!mod.bayesian) { powerUps.spawn(x, y, "ammo", false); } }, + addRerollToLevel() { //add a random power up to a location that has a mob, mostly used to give each level one randomly placed reroll + if (mob.length) { + const index = Math.floor(Math.random() * mob.length) + powerUps.spawn(mob[index].position.x, mob[index].position.y, "reroll"); + if (Math.random() < mod.bayesian) powerUps.spawn(mob[index].position.x, mob[index].position.y, "reroll"); + } + }, spawnStartingPowerUps(x, y) { //used for map specific power ups, mostly to give player a starting gun if (level.levelsCleared < 5) { if (b.inventory.length === 0) { diff --git a/todo.txt b/todo.txt index 572cc41..51c1570 100644 --- a/todo.txt +++ b/todo.txt @@ -1,14 +1,5 @@ -bubble fusion drops 2-3 power ups (down from 3) -perturbation theory: damage is 5% (down from 6%) per reroll - but the mod will not show up until you have 4 rerolls stockpiled -sporeangium grow faster when stuck to a mob - -mod: liquid cooling - freeze all mobs for 6 seconds after receiving harm -mod: perimeter defense - gain 6% harm reduction for each bot -mod: bot fabrication - anytime you have 3 rerolls, convert them into a random bot -mod: Ψ(x) collapse - 33% haste, if you have no rerolls -mod: mine synthesis - drop a mine after picking up a power up +rerolls now spawn at about 1 per level ************** TODO - n-gon **************