From 6bfc53d3beaa58f64611d49ace622aa932d071b4 Mon Sep 17 00:00:00 2001 From: landgreen Date: Thu, 13 Aug 2020 05:33:49 -0700 Subject: [PATCH] renormalization --- js/bullet.js | 56 ++++++++++++++++++++------------------------------- js/level.js | 34 +++++++++++++++++++++++++++---- js/mods.js | 30 ++++++++++++++++++--------- js/player.js | 21 +++++++------------ js/powerup.js | 10 ++++++--- js/spawn.js | 4 ++-- todo.txt | 16 +++++++++------ 7 files changed, 99 insertions(+), 72 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 749cc2f..c881ee5 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -751,7 +751,7 @@ const b = { } } if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 60000 && !game.isChoosing) { - powerUps.onPickUp(); + powerUps.onPickUp(this.position); powerUp[i].effect(); Matter.World.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); @@ -898,7 +898,7 @@ const b = { if (this.target.isShielded) { this.target.damage(b.dmgScale * 0.005, true); //shield damage bypass //shrink if mob is shielded - const SCALE = 1 - 0.016 / mod.isBulletsLastLonger + const SCALE = 1 - 0.018 / mod.isBulletsLastLonger Matter.Body.scale(this, SCALE, SCALE); this.radius *= SCALE; } else { @@ -977,9 +977,7 @@ const b = { bullet[me].endCycle = game.cycle + 60 + 18 * Math.random(); bullet[me].dmg = dmg bullet[me].onDmg = function (who) { - if (mod.isNailPoison) { - mobs.statusDoT(who, dmg * 0.055, 300) //66% / (360 / 30) one tick every 30 cycles in 360 cycles total - } + if (mod.isNailPoison) mobs.statusDoT(who, dmg * 0.15, 180) // one tick every 30 cycles }; bullet[me].do = function () {}; }, @@ -1137,7 +1135,7 @@ const b = { minDmgSpeed: 2, lookFrequency: 40 + Math.floor(7 * Math.random()), acceleration: 0.0015 * (1 + 0.3 * Math.random()), - range: 600 * (1 + 0.2 * Math.random()) + 200 * mod.isLaserBotUpgrade, + range: 500 * (1 + 0.2 * Math.random()) + 150 * mod.isLaserBotUpgrade, followRange: 150 + Math.floor(30 * Math.random()), offPlayer: { x: 0, @@ -1206,7 +1204,7 @@ const b = { bestVertexDistance = dist } } - const dmg = b.dmgScale * (0.04 + 0.04 * this.isUpgraded); + const dmg = b.dmgScale * (0.06 + 0.06 * this.isUpgraded); this.lockedOn.damage(dmg); this.lockedOn.locatePlayer(); @@ -1577,7 +1575,8 @@ const b = { name: "shotgun", description: "fire a burst of short range bullets
crouch to reduce recoil", ammo: 0, - ammoPack: 6, + ammoPack: 7, + defaultAmmoPack: 7, have: false, fire() { let knock, spread @@ -1619,7 +1618,7 @@ const b = { } } else { const side = 21 * mod.bulletSize - for (let i = 0; i < 15; i++) { + for (let i = 0; i < 17; i++) { const me = bullet.length; const dir = mech.angle + (Math.random() - 0.5) * spread bullet[me] = Bodies.rectangle(mech.pos.x + 35 * Math.cos(mech.angle) + 15 * (Math.random() - 0.5), mech.pos.y + 35 * Math.sin(mech.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir)); @@ -1631,7 +1630,7 @@ const b = { }); bullet[me].endCycle = game.cycle + 40 bullet[me].minDmgSpeed = 15 - // bullet[me].dmg = 0.1 + // bullet[me].restitution = 0.4 bullet[me].frictionAir = 0.034; bullet[me].do = function () { if (!mech.isBodiesAsleep) { @@ -1702,8 +1701,8 @@ const b = { name: "flechettes", description: "fire a volley of uranium-235 needles
does damage over 3 seconds", ammo: 0, - ammoPack: 35, - defaultAmmoPack: 35, + ammoPack: 40, + defaultAmmoPack: 40, have: false, count: 0, //used to track how many shots are in a volley before a big CD lastFireCycle: 0, //use to remember how longs its been since last fire, used to reset count @@ -1731,9 +1730,9 @@ const b = { who.foundPlayer(); if (mod.isFastDot) { - mobs.statusDoT(who, 3.6, 30) + mobs.statusDoT(who, 3.9, 30) } else { - mobs.statusDoT(who, 0.6, mod.isSlowDot ? 360 : 180) + mobs.statusDoT(who, 0.65, mod.isSlowDot ? 360 : 180) } game.drawList.push({ //add dmg to draw queue @@ -1774,7 +1773,6 @@ const b = { } }; - const SPEED = 50 Matter.Body.setVelocity(bullet[me], { x: mech.Vx / 2 + SPEED * Math.cos(angle), @@ -1806,7 +1804,7 @@ const b = { name: "wave beam", description: "emit a sine wave of oscillating particles
particles slowly propagate through solids", ammo: 0, - ammoPack: 90, + ammoPack: 80, have: false, fire() { mech.fireCDcycle = mech.cycle + Math.floor(3 * b.fireCD); // cool down @@ -2311,13 +2309,6 @@ const b = { } else { if (Matter.Query.collides(this, map).length) { onCollide(this) - - // this.stuck = function () { - // Matter.Body.setVelocity(this, { - // x: 0, - // y: 0 - // }); - // } } else { //if colliding with nothing just fall this.force.y += this.mass * 0.001; } @@ -2527,7 +2518,7 @@ const b = { fire() { if (mech.crouch) { b.iceIX(10, 0.3) - mech.fireCDcycle = mech.cycle + Math.floor(10 * b.fireCD); // cool down + mech.fireCDcycle = mech.cycle + Math.floor(8 * b.fireCD); // cool down } else { b.iceIX(2) mech.fireCDcycle = mech.cycle + Math.floor(3 * b.fireCD); // cool down @@ -2606,13 +2597,12 @@ const b = { 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) { - this.charge = 0.1; + 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 - //normal bullet behavior occurs after firing, overwrite this function - this.do = function () { - this.force.y += this.mass * 0.001; //normal gravity - } + this.endCycle = 0; + return } else { mech.fireCDcycle = mech.cycle + 2; // set fire cool down //normal bullet behavior occurs after firing, overwrite this function @@ -3024,7 +3014,7 @@ const b = { if (mod.isPulseAim) { //find mobs in line of sight let dist = 2200 energy = 0.25 * Math.min(mech.energy, 1.75) - explosionRange = 1000 * energy + explosionRange = 1100 * energy for (let i = 0, len = mob.length; i < len; i++) { const newDist = Vector.magnitude(Vector.sub(path[0], mob[i].position)) if (explosionRange < newDist && @@ -3036,8 +3026,6 @@ const b = { path[path.length - 1] = mob[i].position } } - - } if (!best.who) { vertexCollision(path[0], path[1], mob); @@ -3058,7 +3046,7 @@ const b = { } else { energy = 0.3 * Math.min(mech.energy, 1.75) mech.energy -= energy * mod.isLaserDiode - explosionRange = 1000 * energy + explosionRange = 1100 * energy if (best.who) b.explosion(path[1], explosionRange, true) mech.fireCDcycle = mech.cycle + Math.floor(50 * b.fireCD); // cool down } diff --git a/js/level.js b/js/level.js index fa56bb4..209a72c 100644 --- a/js/level.js +++ b/js/level.js @@ -18,7 +18,7 @@ const level = { // mech.isStealth = true; // mod.giveMod("bot replication"); // mod.nailBotCount += 10 - // b.giveGuns("neutron bomb") + // b.giveGuns("rail gun") // mech.setField("plasma torch") level.intro(); //starting level @@ -418,8 +418,8 @@ const level = { const button = level.button(6600, 2675) const hazard = level.hazard(4550, 2750, 4550, 150) const balance1 = level.spinner(300, -395, 25, 390, 0.001) //entrance - const balance2 = level.spinner(2605, 500, 390, 25, 0.005) //falling - const balance3 = level.spinner(2608, 1900, 584, 25, 0.005) //falling + const balance2 = level.spinner(2605, 500, 390, 25, 0.001) //falling + const balance3 = level.spinner(2608, 1900, 584, 25, 0.001) //falling const balance4 = level.spinner(9300, 2205, 25, 380, 0.001) //exit level.custom = () => { @@ -526,7 +526,7 @@ const level = { spawn.bodyRect(6800, 2490, 50, 50); spawn.bodyRect(6800, 2540, 50, 50); spawn.bodyRect(6800, 2590, 50, 50); - spawn.bodyRect(8225, 2200, 100, 400); + spawn.bodyRect(8225, 2225, 50, 375); spawn.mapRect(6250, 1875, 700, 150); spawn.mapRect(8000, 1875, 600, 150); @@ -745,6 +745,8 @@ const level = { spawn.wireHead(); }, satellite() { + // level.chain(4025, -1175, 15, 20) + const elevator = level.platform(4210, -1325, 380, 30, -10) level.custom = () => { level.playerExitCheck(); @@ -3315,4 +3317,28 @@ const level = { } } }, + chain(x, y, len = 15, radius = 20) { + for (let i = 0; i < len; i++) { + body[body.length] = Bodies.polygon(x, y + 2 * radius * i, 12, radius, { + inertia: Infinity + }); + } + for (let i = 1; i < len; i++) { + consBB[consBB.length] = Constraint.create({ + bodyA: body[body.length - i], + bodyB: body[body.length - i - 1], + stiffness: 0.4, + damping: 0.01 + }); + } + cons[cons.length] = Constraint.create({ //pin first block to a point in space + pointA: { + x: x, + y: y - radius + }, + bodyB: body[body.length - len], + stiffness: 0.4, + damping: 0.01 + }); + }, }; \ No newline at end of file diff --git a/js/mods.js b/js/mods.js index 7a0e9dd..8a198be 100644 --- a/js/mods.js +++ b/js/mods.js @@ -70,7 +70,7 @@ const mod = { }, damageFromMods() { let dmg = 1 - if (mod.isLowHealthDmg) dmg *= 1 + 0.4 * Math.max(0, 1 - mech.health) + if (mod.isLowHealthDmg) dmg *= 1 + 0.5 * Math.max(0, 1 - mech.health) if (mod.isHarmDamage && mech.lastHarmCycle + 600 > mech.cycle) dmg *= 2; if (mod.isEnergyLoss) dmg *= 1.33; if (mod.isAcidDmg && mech.health > 1) dmg *= 1.4; @@ -199,7 +199,7 @@ const mod = { }, { name: "negative feedback", - description: "increase damage by 4%
for each 10% missing health", + description: "increase damage by 5%
for every 10% missing base health", maxCount: 1, count: 0, allowed() { @@ -1058,7 +1058,7 @@ const mod = { }, { name: "logistics", - description: "ammo power ups give 100% more ammo
but ammo is only added to your current gun", + description: "ammo power ups give 200% ammo
but ammo is only added to your current gun", maxCount: 1, count: 0, allowed() { @@ -1391,7 +1391,7 @@ const mod = { }, { name: "shotgun spin-statistics", - description: "firing the shotgun makes you
immune to harm while on cooldown", + description: "immune to harm while firing the shotgun
receive 33% less shotgun ammo", maxCount: 1, count: 0, allowed() { @@ -1400,9 +1400,21 @@ const mod = { requires: "shotgun", effect() { mod.isShotgunImmune = true; + for (i = 0, len = b.guns.length; i < len; i++) { //find which gun + if (b.guns[i].name === "shotgun") { + b.guns[i].ammoPack = b.guns[i].defaultAmmoPack * 0.66 + break; + } + } }, remove() { mod.isShotgunImmune = false; + for (i = 0, len = b.guns.length; i < len; i++) { //find which gun + if (b.guns[i].name === "shotgun") { + b.guns[i].ammoPack = b.guns[i].defaultAmmoPack; + break; + } + } } }, { @@ -1785,7 +1797,7 @@ const mod = { maxCount: 1, count: 0, allowed() { - return mod.nailBotCount + mod.grenadeFragments + mod.nailsDeathMob / 2 + mod.haveGunCheck("mine") + mod.isRailNails + mod.isNailShot > 1 + return mod.nailBotCount + mod.grenadeFragments + mod.nailsDeathMob / 2 + (mod.haveGunCheck("mine") + mod.isRailNails + mod.isNailShot) * 2 > 1 }, requires: "nails", effect() { @@ -1999,12 +2011,12 @@ const mod = { requires: "laser", effect() { mod.laserReflections++; - mod.laserDamage += 0.045; //base is 0.08 + mod.laserDamage += 0.05; //base is 0.1 mod.laserFieldDrain += 0.001 //base is 0.002 }, remove() { mod.laserReflections = 2; - mod.laserDamage = 0.09; + mod.laserDamage = 0.1; mod.laserFieldDrain = 0.002; } }, @@ -2097,7 +2109,7 @@ const mod = { }, { name: "Lorentz transformation", - description: "move, jump, and shoot 33% faster
while time dilation is active or inactive ", + description: "move, jump, and shoot 33% faster", maxCount: 1, count: 0, allowed() { @@ -2300,7 +2312,7 @@ const mod = { }, { name: "renormalization", - description: "phase decoherence adds visibility to bullets
80% less energy drain when firing", + description: "using a reroll to change selection options
has a 60% chance to spawn a reroll", maxCount: 1, count: 0, allowed() { diff --git a/js/player.js b/js/player.js index 7429c45..23dcd5c 100644 --- a/js/player.js +++ b/js/player.js @@ -942,7 +942,7 @@ const mech = { y: powerUp[i].velocity.y * 0.11 }); if (dist2 < 5000 && !game.isChoosing) { //use power up if it is close enough - powerUps.onPickUp(); + powerUps.onPickUp(mech.pos); Matter.Body.setVelocity(player, { //player knock back, after grabbing power up x: player.velocity.x + ((powerUp[i].velocity.x * powerUp[i].mass) / player.mass) * 0.3, y: player.velocity.y + ((powerUp[i].velocity.y * powerUp[i].mass) / player.mass) * 0.3 @@ -1733,24 +1733,17 @@ const mech = { // } function drawField(radius) { - radius *= 0.9 + 1.5 * mech.energy * mech.energy; + radius *= 0.9 + 2 * mech.energy * mech.energy; const rotate = mech.cycle * 0.005; 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 (mod.renormalization) { - 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() - } + 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 @@ -1777,7 +1770,7 @@ const mech = { // game.draw.bodyFill = "transparent" // game.draw.bodyStroke = "transparent" - const DRAIN = 0.00014 + ((!mod.renormalization && mech.fireCDcycle > mech.cycle) ? 0.007 : 0.001) + const DRAIN = 0.00014 + (mech.fireCDcycle > mech.cycle ? 0.007 : 0.001) if (mech.energy > DRAIN) { mech.energy -= DRAIN; // if (mech.energy < 0.001) { diff --git a/js/powerup.js b/js/powerup.js index 129f228..3af7e1d 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -100,6 +100,10 @@ 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) { + powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); + if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); + } }, }, heal: { @@ -388,11 +392,11 @@ const powerUps = { } } }, - onPickUp() { + onPickUp(where) { if (mod.isMassEnergy) mech.energy = mech.maxEnergy * 3; if (mod.isMineDrop) b.mine({ - x: mech.pos.x, - y: mech.pos.y + x: where.x, + y: where.y }, { x: 0, y: 0 diff --git a/js/spawn.js b/js/spawn.js index 74c95c9..b23847e 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -228,7 +228,7 @@ const spawn = { } } }, - powerUpBoss(x, y, vertices = 9, radius = 150) { + powerUpBoss(x, y, vertices = 9, radius = 130) { mobs.spawn(x, y, vertices, radius, "transparent"); let me = mob[mob.length - 1]; me.isBoss = true; @@ -1124,7 +1124,7 @@ const spawn = { me.onDeath = function () { powerUps.spawnBossPowerUp(this.position.x, this.position.y) }; - me.rotateVelocity = Math.min(0.005, 0.002 * game.accelScale * game.accelScale) * (level.levelsCleared > 8 ? 1 : -1) + me.rotateVelocity = Math.min(0.0045, 0.0015 * game.accelScale * game.accelScale) * (level.levelsCleared > 8 ? 1 : -1) me.do = function () { this.fill = '#' + Math.random().toString(16).substr(-6); //flash colors if (!mech.isBodiesAsleep) { diff --git a/todo.txt b/todo.txt index 6773626..d9adc9a 100644 --- a/todo.txt +++ b/todo.txt @@ -1,12 +1,21 @@ - +mod: renormalization now gives a 60% chance to return a reroll after using a reroll + (the old renormalization was causing too much lag) ************** TODO - n-gon ************** +level Boss: fractal SierpiƄski triangle + https://en.wikipedia.org/wiki/Sierpi%C5%84ski_triangle + spawns a 1/2 size version of the boss, this version can also spawn a smaller version, but it is capped at some size level + they spawn once at the start of the level + if a version dies, one can be replaced every ten seconds by the largest version + performance issues with large numbers of spores consider limiting total bullets? 300? level element: a hanging chain of connected blocks +level element: a zone with wind, anti-gravity, extra gravity + control with button give mobs more animal-like behaviors like rain world mobs play, look for food, explore @@ -149,8 +158,6 @@ an effect when canceling a power up add player Scent Trails for mob navigation https://abitawake.com/news/articles/enemy-ai-chasing-a-player-without-navigation2d-or-a-star-pathfinding -mod - you can no longer see your current health - settings - custom keys binding css transition for pause menu @@ -163,9 +170,6 @@ gun: Spirit Bomb (singularity) uses energy hold above the player's head -make power ups keep moving to player if the pickup field is turned off before they get picked up - not sure how to do this without adding a constant check - animate new level spawn by having the map aspects randomly fly into place n-gon outreach ideas