diff --git a/.DS_Store b/.DS_Store index ed04ed6..37836ab 100644 Binary files a/.DS_Store and b/.DS_Store differ diff --git a/js/bullet.js b/js/bullet.js index 4658a55..f4d8b2f 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -111,6 +111,18 @@ const b = { // m.setMaxHealth(); // } }, + refundAmmo() { //triggers after firing when you removed ammo for a gun, but didn't need to (like a rail gun misfire) + if (tech.isCrouchAmmo && m.crouch) { + tech.isCrouchAmmo-- + if ((tech.isCrouchAmmo) % 2) { + b.guns[b.activeGun].ammo++; + simulation.updateGunHUD(); + } + } else { + b.guns[b.activeGun].ammo++; + simulation.updateGunHUD(); + } + }, giveGuns(gun = "random", ammoPacks = 10) { if (tech.isOneGun) b.removeAllGuns(); if (gun === "random") { @@ -192,7 +204,7 @@ const b = { if (bullet[i].endCycle < simulation.cycle) { bullet[i].onEnd(i); //some bullets do stuff on end if (bullet[i]) { - Matter.World.remove(engine.world, bullet[i]); + Matter.Composite.remove(engine.world, bullet[i]); bullet.splice(i, 1); } else { break; //if bullet[i] doesn't exist don't complete the for loop, because the game probably reset @@ -210,7 +222,7 @@ const b = { } ctx.lineTo(vertices[0].x, vertices[0].y); } - ctx.fillStyle = "#000"; + ctx.fillStyle = color.bullet; ctx.fill(); }, bulletDo() { @@ -224,7 +236,7 @@ const b = { x: m.Vx / 2 + speed * Math.cos(dir), y: m.Vy / 2 + speed * Math.sin(dir) }); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, fireCDscale: 1, setFireCD() { @@ -408,7 +420,7 @@ const b = { const size = 20 + 350 * Math.pow(body[i].mass, 0.25) const where = body[i].position const onLevel = level.onLevel //prevent explosions in the next level - Matter.World.remove(engine.world, body[i]); + Matter.Composite.remove(engine.world, body[i]); body.splice(i, 1); setTimeout(() => { if (onLevel === level.onLevel) b.explosion(where, size); //makes bullet do explosive damage at end @@ -733,7 +745,7 @@ const b = { bullet[me].do = function() { this.force.y += this.mass * 0.0025; //extra gravity for harder arcs }; - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world } grenadeRPG = function(where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle) { const me = bullet.length; @@ -753,7 +765,7 @@ const b = { x: m.Vx / 2 + speed * Math.cos(angle), y: m.Vy / 2 + speed * Math.sin(angle) }); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world bullet[me].endCycle = simulation.cycle + 70; bullet[me].frictionAir = 0.07; @@ -788,7 +800,7 @@ const b = { x: m.Vx / 2 + speed * Math.cos(angle), y: m.Vy / 2 + speed * Math.sin(angle) }); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world bullet[me].endCycle = simulation.cycle + 70; bullet[me].frictionAir = 0.07; @@ -914,7 +926,7 @@ const b = { x: m.Vx / 2 + speed * Math.cos(angle), y: m.Vy / 2 + speed * Math.sin(angle) }); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world } grenadeNeutron = function(where = { x: m.pos.x + 30 * Math.cos(m.angle), y: m.pos.y + 30 * Math.sin(m.angle) }, angle = m.angle) { @@ -1206,7 +1218,7 @@ const b = { x: m.Vx / 2 + speed * Math.cos(angle), y: m.Vy / 2 + speed * Math.sin(angle) }); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, lastAngle: 0, wasExtruderOn: false, @@ -1280,7 +1292,7 @@ const b = { } } }); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(m.angle), y: SPEED * Math.sin(m.angle) @@ -1600,7 +1612,7 @@ const b = { dmg: 0, // 0.14 //damage done in addition to the damage from momentum minDmgSpeed: 2, lookFrequency: 67 + Math.floor(7 * Math.random()), - drain: 0.6 * tech.isLaserDiode * tech.laserFieldDrain, + drain: 0.45 * tech.isLaserDiode * tech.laserFieldDrain, isArmed: false, torqueMagnitude: 0.000003 * (Math.round(Math.random()) ? 1 : -1), range: 1500, @@ -1662,7 +1674,7 @@ const b = { } }) Matter.Body.setVelocity(bullet[me], velocity); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, mine(where, velocity, angle = 0, isAmmoBack = false) { const bIndex = bullet.length; @@ -1758,7 +1770,7 @@ const b = { this.force.y += this.mass * 0.002; //extra gravity if (!(simulation.cycle % this.lookFrequency) && !m.isBodiesAsleep) { //find mob targets this.endCycle -= 8 - b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, false) + b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, false, 2) //targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) { if (!(simulation.cycle % (this.lookFrequency * 6))) { simulation.drawList.push({ x: this.position.x, @@ -1807,7 +1819,8 @@ const b = { }, onEnd() { if (this.isArmed) { - b.targetedNail(this.position, 22) + b.targetedNail(this.position, 22, 40 + 10 * Math.random(), 1200, true, 1.9) //targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) { + } if (tech.isMineAmmoBack && (!this.isArmed || Math.random() < 0.2)) { //get ammo back from tech.isMineAmmoBack for (i = 0, len = b.guns.length; i < len; i++) { //find which gun @@ -1831,7 +1844,7 @@ const b = { }); bullet[bIndex].torque += bullet[bIndex].inertia * 0.0002 * (0.5 - Math.random()) Matter.Body.setVelocity(bullet[bIndex], velocity); - World.add(engine.world, bullet[bIndex]); //add bullet to world + Composite.add(engine.world, bullet[bIndex]); //add bullet to world }, worm(where, isFreeze = tech.isSporeFreeze) { //used with the tech upgrade in mob.death() const bIndex = bullet.length; @@ -1924,7 +1937,7 @@ const b = { x: SPEED * Math.cos(ANGLE), y: SPEED * Math.sin(ANGLE) }); - World.add(engine.world, bullet[bIndex]); //add bullet to world + Composite.add(engine.world, bullet[bIndex]); //add bullet to world if (tech.isMutualism && m.health > 0.02) { m.health -= 0.005 - 0.005 * tech.isSporeWorm m.displayHealth(); @@ -2044,7 +2057,7 @@ const b = { x: SPEED * Math.cos(ANGLE), y: SPEED * Math.sin(ANGLE) }); - World.add(engine.world, bullet[bIndex]); //add bullet to world + Composite.add(engine.world, bullet[bIndex]); //add bullet to world if (tech.isMutualism && m.health > 0.02) { m.health -= 0.005 - 0.005 * tech.isSporeWorm @@ -2114,7 +2127,7 @@ const b = { } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world // Matter.Body.setAngularVelocity(bullet[me], 2 * (0.5 - Math.random())) //doesn't work due to high friction Matter.Body.setVelocity(bullet[me], { x: speed * Math.cos(dir), @@ -2242,7 +2255,7 @@ const b = { //pick up nearby power ups powerUps.onPickUp(powerUp[i]); powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); if (tech.isDroneGrab) { this.isImproved = true; @@ -2274,7 +2287,7 @@ const b = { //pick up nearby power ups powerUps.onPickUp(powerUp[i]); powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); if (tech.isDroneGrab) { this.isImproved = true; @@ -2318,7 +2331,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], { x: speed * Math.cos(dir), y: speed * Math.sin(dir) @@ -2458,7 +2471,7 @@ const b = { //pick up nearby power ups powerUps.onPickUp(powerUp[i]); powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); if (tech.isDroneGrab) { this.isImproved = true; @@ -2491,7 +2504,7 @@ const b = { //pick up nearby power ups powerUps.onPickUp(powerUp[i]); powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); if (tech.isDroneGrab) { this.isImproved = true; @@ -2535,7 +2548,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], { x: speed * Math.cos(dir), y: speed * Math.sin(dir) @@ -2631,14 +2644,14 @@ const b = { this.target = null this.collisionFilter.category = cat.bullet; this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield - if (tech.isFoamGrowOnDeath && bullet.length < 200) { + if (tech.isFoamGrowOnDeath && bullet.length < 180) { let targets = [] for (let i = 0, len = mob.length; i < len; i++) { const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position)); if (dist < 1000000) targets.push(mob[i]) } - const radius = Math.min(this.radius * 0.5, 10) - const len = bullet.length < 100 ? 2 : 1 + const radius = Math.min(this.radius * 0.5, 9) + const len = bullet.length < 80 ? 2 : 1 for (let i = 0; i < len; i++) { if (targets.length - i > 0) { const index = Math.floor(Math.random() * targets.length) @@ -2697,7 +2710,7 @@ const b = { } }); if (tech.isFoamTeleport) bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], velocity); }, targetedBlock(who, isSpin = false, speed = 50 - Math.min(20, who.mass * 2), range = 1600) { @@ -2718,7 +2731,7 @@ const b = { Matter.Body.setVelocity(who, velocity); } }, - targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true) { + targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) { const targets = [] //target nearby mobs for (let i = 0, len = mob.length; i < len; i++) { const dist = Vector.magnitude(Vector.sub(position, mob[i].position)); @@ -2734,13 +2747,13 @@ const b = { x: targets[index].x + SPREAD * (Math.random() - 0.5), y: targets[index].y + SPREAD * (Math.random() - 0.5) } - b.nail(position, Vector.mult(Vector.normalise(Vector.sub(WHERE, position)), speed), 1.4) + b.nail(position, Vector.mult(Vector.normalise(Vector.sub(WHERE, position)), speed), damage) } else if (isRandomAim) { // aim in random direction const ANGLE = 2 * Math.PI * Math.random() b.nail(position, { x: speed * Math.cos(ANGLE), y: speed * Math.sin(ANGLE) - }, 1.4) + }, damage) } } }, @@ -2748,7 +2761,7 @@ const b = { const me = bullet.length; bullet[me] = Bodies.rectangle(pos.x, pos.y, 25, 2, b.fireAttributes(Math.atan2(velocity.y, velocity.x))); Matter.Body.setVelocity(bullet[me], velocity); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world bullet[me].endCycle = simulation.cycle + 60 + 18 * Math.random(); bullet[me].dmg = tech.isNailRadiation ? 0 : dmg bullet[me].beforeDmg = function(who) { //beforeDmg is rewritten with ice crystal tech @@ -2822,7 +2835,7 @@ const b = { y: m.Vy / 2 + SPEED * Math.sin(angle) }); // Matter.Body.setDensity(bullet[me], 0.00001); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, // ************************************************************************************************** // ************************************************************************************************** @@ -3024,7 +3037,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world b.setDynamoBotDelay() }, nailBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { @@ -3079,7 +3092,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, missileBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { if (isConsole) simulation.makeTextLog(`b.missileBot()`); @@ -3130,7 +3143,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, foamBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { if (isConsole) simulation.makeTextLog(`b.foamBot()`); @@ -3185,7 +3198,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, laserBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { if (isConsole) simulation.makeTextLog(`b.laserBot()`); @@ -3273,7 +3286,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, boomBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { if (isConsole) simulation.makeTextLog(`b.boomBot()`); @@ -3358,7 +3371,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, plasmaBot(position = { x: player.position.x + 50 * (Math.random() - 0.5), y: player.position.y + 50 * (Math.random() - 0.5) }, isConsole = true) { if (isConsole) simulation.makeTextLog(`b.plasmaBot()`); @@ -3544,7 +3557,7 @@ const b = { } } }) - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world }, orbitBot(position = player.position, isConsole = true) { if (isConsole) simulation.makeTextLog(`b.orbitBot()`); @@ -3629,7 +3642,7 @@ const b = { // bullet[me].orbitalSpeed = Math.sqrt(0.7 / bullet[me].range) bullet[me].orbitalSpeed = Math.sqrt(0.25 / bullet[me].range) //also set in bot upgrade too! // bullet[me].phase = (index / tech.orbitBotCount) * 2 * Math.PI - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world //reorder orbital bot positions around a circle let totalOrbitalBots = 0 @@ -3721,7 +3734,7 @@ const b = { bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 5 * size, size, b.fireAttributes(m.angle)); bullet[me].dmg = tech.isNailRadiation ? 0 : 2.75 Matter.Body.setDensity(bullet[me], 0.002); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world const SPEED = m.crouch ? 55 : 44 Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(m.angle), @@ -3834,7 +3847,7 @@ const b = { bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle), m.pos.y + 35 * Math.sin(m.angle), 60, 27, b.fireAttributes(dir)); Matter.Body.setDensity(bullet[me], 0.007 * (tech.isShotgunReversed ? 1.6 : 1)); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world const SPEED = (m.crouch ? 45 : 35) + Math.random() * 6 Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(dir), @@ -3904,7 +3917,7 @@ const b = { this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion }; bullet[me].do = function() {} - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world } } else if (tech.isNailShot) { spread *= 0.65 @@ -3985,7 +3998,7 @@ const b = { const me = bullet.length; const dir = m.angle + (Math.random() - 0.5) * spread bullet[me] = Bodies.rectangle(m.pos.x + 35 * Math.cos(m.angle) + 15 * (Math.random() - 0.5), m.pos.y + 35 * Math.sin(m.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir)); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world const SPEED = 52 + Math.random() * 8 Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(dir), @@ -4019,7 +4032,7 @@ const b = { let dir = m.angle const me = bullet.length; bullet[me] = Bodies.polygon(m.pos.x + 30 * Math.cos(m.angle), m.pos.y + 30 * Math.sin(m.angle), 12, 21 * tech.bulletSize, b.fireAttributes(dir, false)); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(dir), y: SPEED * Math.sin(dir) @@ -4048,7 +4061,7 @@ const b = { for (let i = 0; i < tech.superBallNumber; i++) { const me = bullet.length; bullet[me] = Bodies.polygon(m.pos.x + 30 * Math.cos(m.angle), m.pos.y + 30 * Math.sin(m.angle), 12, 11 * tech.bulletSize, b.fireAttributes(dir, false)); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(dir), y: SPEED * Math.sin(dir) @@ -4081,7 +4094,7 @@ const b = { const fireBall = () => { const me = bullet.length; bullet[me] = Bodies.polygon(x, y, 12, 11 * tech.bulletSize, b.fireAttributes(dir, false)); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(dir), y: SPEED * Math.sin(dir) @@ -4412,7 +4425,7 @@ const b = { } } } - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world Matter.Body.setVelocity(bullet[me], { x: tech.waveBeamSpeed * Math.cos(m.angle), y: tech.waveBeamSpeed * Math.sin(m.angle) @@ -4559,7 +4572,7 @@ const b = { name: "mine", description: "toss a proximity mine that sticks to walls
fires nails at mobs within range", ammo: 0, - ammoPack: 2, + ammoPack: 1.5, have: false, do() {}, fire() { @@ -4833,7 +4846,7 @@ const b = { name: "rail gun", description: "use energy to launch a high-speed dense rod
hold left mouse to charge, release to fire", ammo: 0, - ammoPack: 3, + ammoPack: 5, have: false, do() {}, fire() { @@ -4886,7 +4899,7 @@ const b = { if (tech.isCapacitor) { if ((m.energy > 0.16 || tech.isRailEnergyGain)) { //&& m.immuneCycle < m.cycle m.energy += 0.16 * (tech.isRailEnergyGain ? 4.5 : -1) - m.fireCDcycle = m.cycle + Math.floor(30 * b.fireCDscale); + m.fireCDcycle = m.cycle + Math.floor(40 * b.fireCDscale); const me = bullet.length; bullet[me] = Bodies.rectangle(m.pos.x + 50 * Math.cos(m.angle), m.pos.y + 50 * Math.sin(m.angle), 60, 14, { density: 0.005, //0.001 is normal @@ -4956,7 +4969,7 @@ const b = { } } }); - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world const speed = 67 Matter.Body.setVelocity(bullet[me], { @@ -4968,9 +4981,9 @@ const b = { const KNOCK = (m.crouch ? 0.08 : 0.34) * (tech.isShotgunReversed ? -2 : 1) player.force.x -= KNOCK * Math.cos(m.angle) player.force.y -= KNOCK * Math.sin(m.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps - pushAway(800) } else { + b.refundAmmo() m.fireCDcycle = m.cycle + Math.floor(120); } } else { @@ -5007,7 +5020,7 @@ const b = { onEnd() {} }); m.fireCDcycle = Infinity; // cool down - World.add(engine.world, bullet[me]); //add bullet to world + Composite.add(engine.world, bullet[me]); //add bullet to world bullet[me].endCycle = Infinity bullet[me].charge = 0; bullet[me].do = function() { @@ -5015,6 +5028,7 @@ const b = { m.energy += 0.05 + this.charge * 0.2 m.fireCDcycle = m.cycle + 120; // cool down if out of energy this.endCycle = 0; + b.refundAmmo() return } @@ -5045,7 +5059,6 @@ const b = { player.force.y -= KNOCK * Math.sin(m.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps pushAway(1200 * this.charge) } else { // charging on mouse down - if (tech.isFireMoveLock) { Matter.Body.setVelocity(player, { x: 0, @@ -5055,10 +5068,9 @@ const b = { player.force.y = 0 } - m.fireCDcycle = Infinity //can't fire until mouse is released const previousCharge = this.charge - let smoothRate = 0.98 * (m.crouch ? 0.99 : 1) * (0.98 + 0.02 * b.fireCDscale) //small b.fireCDscale = faster shots, b.fireCDscale=1 = normal shot, big b.fireCDscale = slower chot + let smoothRate = (m.crouch ? 0.98 : 0.99) * (0.98 + 0.02 * b.fireCDscale) //small b.fireCDscale = faster shots, b.fireCDscale=1 = normal shot, big b.fireCDscale = slower chot this.charge = this.charge * smoothRate + 1 * (1 - smoothRate) if (tech.isRailEnergyGain) { m.energy += (this.charge - previousCharge) * 1.5 //energy drain is proportional to charge gained, but doesn't stop normal m.fieldRegen diff --git a/js/engine.js b/js/engine.js index 8a6b48a..0266fc5 100644 --- a/js/engine.js +++ b/js/engine.js @@ -1,7 +1,6 @@ //matter.js *********************************************************** // module aliases const Engine = Matter.Engine, - World = Matter.World, Events = Matter.Events, Composites = Matter.Composites, Composite = Matter.Composite, diff --git a/js/index.js b/js/index.js index df82d30..700f87f 100644 --- a/js/index.js +++ b/js/index.js @@ -13,6 +13,28 @@ const cat = { phased: 0x100000000, } +const color = { //light + background: "#ddd", + block: "rgba(140,140,140,0.85)", + blockS: "#222", + map: "#444", +} + +// const color = { //dark +// background: "#333", +// block: "#444", +// blockS: "#aab", +// map: "#556", +// bullet: "#fff" +// } + +// const color = { //dark +// background: "#999", +// block: "#888", +// blockS: "#111", +// map: "#444", +// } + function shuffle(array) { var currentIndex = array.length, temporaryValue, @@ -170,7 +192,7 @@ const build = { // level.onLevel++ // } // } - // for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); + // for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]); // bullet = []; //remove any bullets that might have spawned from tech // if (b.inventory.length > 0) { // b.activeGun = b.inventory[0] //set first gun to active gun @@ -342,6 +364,7 @@ const build = { const techID = document.getElementById("tech-" + i) if (!tech.tech[i].isExperimentHide && (!tech.tech[i].isNonRefundable || tech.tech[i].isExperimentalMode)) { if (tech.tech[i].allowed() || isAllowed || tech.tech[i].count > 0) { + // console.log(tech.tech[i].name, isAllowed, tech.tech[i].count, tech.haveGunCheck("nail gun")) const isCount = tech.tech[i].count > 1 ? `(${tech.tech[i].count}x)` : ""; if (tech.tech[i].isFieldTech) { @@ -537,7 +560,7 @@ const build = { b.activeGun = b.inventory[0] //set first gun to active gun simulation.makeGunHUD(); } - for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); + for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]); bullet = []; //remove any bullets that might have spawned from tech const levelsCleared = Math.abs(Number(document.getElementById("starting-level").value) - 1) level.difficultyIncrease(Math.min(99, levelsCleared * simulation.difficultyMode)) //increase difficulty based on modes @@ -547,7 +570,7 @@ const build = { function removeOne() { //recursive remove one at a time to avoid array problems for (let i = 0; i < powerUp.length; i++) { if (powerUp[i].name === "tech" || powerUp[i].name === "gun" || powerUp[i].name === "field") { - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); removeOne(); break @@ -928,7 +951,7 @@ window.addEventListener("keydown", function(event) { body[index].collisionFilter.category = cat.body; body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].classType = "body"; - World.add(engine.world, body[index]); //add to world + Composite.add(engine.world, body[index]); //add to world break case "7": const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)]; diff --git a/js/level.js b/js/level.js index eb793b0..8b20d91 100644 --- a/js/level.js +++ b/js/level.js @@ -13,12 +13,12 @@ const level = { if (level.levelsCleared === 0) { //this code only runs on the first level // localSettings.levelsClearedLastGame = 10 // simulation.enableConstructMode() //used to build maps in testing mode - // level.difficultyIncrease(30) //30 is near max on hard //60 is near max on why + // level.difficultyIncrease(10) //30 is near max on hard //60 is near max on why // simulation.isHorizontalFlipped = true // tech.isFieldFree = true // m.setField("time dilation") - // b.giveGuns("nail gun") - // tech.giveTech("needle gun") + // b.giveGuns("rail gun") + // tech.giveTech("half-wave rectifier") // b.giveGuns("wave beam") // tech.giveTech("Lenz's law") // for (let i = 0; i < 3; i++) tech.giveTech("packet length") @@ -86,7 +86,8 @@ const level = { if (b.inventoryGun > b.inventory.length - 1) b.inventoryGun = 0; simulation.switchGun(); } - if (tech.isSwitchReality) { + if (tech.isSwitchReality && powerUps.research.count > 0) { + powerUps.research.changeRerolls(-1); simulation.makeTextLog(`simulation.amplitude = ${Math.random()}`); m.switchWorlds() simulation.trails() @@ -266,13 +267,13 @@ const level = { body[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet } body[i].classType = "body"; - World.add(engine.world, body[i]); //add to world + Composite.add(engine.world, body[i]); //add to world } for (let i = 0; i < map.length; i++) { map[i].collisionFilter.category = cat.map; map[i].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; Matter.Body.setStatic(map[i], true); //make static - World.add(engine.world, map[i]); //add to world + Composite.add(engine.world, map[i]); //add to world } }, spinner(x, y, width, height, density = 0.001, angle = 0, frictionAir = 0.001, angularVelocity = 0) { @@ -303,7 +304,7 @@ const level = { stiffness: 1, damping: 1 }); - World.add(engine.world, constraint); + Composite.add(engine.world, constraint); return constraint }, boost(x, y, height = 1000) { //height is how high the player will be flung above y @@ -445,10 +446,10 @@ const level = { stiffness: 0.01, damping: 0.3 }); - World.add(engine.world, this.constraint); + Composite.add(engine.world, this.constraint); }, removeConstraint() { - World.remove(engine.world, this.constraint, true) + Composite.remove(engine.world, this.constraint, true) }, drawTrack() { ctx.fillStyle = "#ccc" @@ -483,7 +484,7 @@ const level = { stiffness: 0.1, damping: 0.3 }); - World.add(engine.world, constraint); + Composite.add(engine.world, constraint); constraint.plat = { position: who.position, speed: speed, @@ -516,7 +517,7 @@ const level = { x: x, y: y }); - World.add(engine.world, [rotor]); + Composite.add(engine.world, [rotor]); body[body.length] = rotor1 body[body.length] = rotor2 @@ -532,7 +533,7 @@ const level = { }, bodyB: rotor }); - World.add(engine.world, constraint); + Composite.add(engine.world, constraint); if (rotate) { rotor.rotate = function() { @@ -580,7 +581,7 @@ const level = { stiffness: 1, length: 0 }); - World.add(engine.world, [cons[cons.length - 1]]); + Composite.add(engine.world, [cons[cons.length - 1]]); return { flip: flip, @@ -609,7 +610,7 @@ const level = { ctx.fillStyle = "#3df" ctx.fill(); ctx.lineWidth = 1; - ctx.strokeStyle = simulation.draw.bodyStroke; + ctx.strokeStyle = color.blockS; ctx.stroke(); } }, @@ -795,7 +796,7 @@ const level = { if (body[i].isInPortal === this) body[i].isInPortal = null } else if (body[i].isInPortal !== this) { //touching this portal, but for the first time if (isRemoveBlocks) { - Matter.World.remove(engine.world, body[i]); + Matter.Composite.remove(engine.world, body[i]); body.splice(i, 1); break } @@ -829,7 +830,7 @@ const level = { // if (body[j] === touching[i].bodyB) { // body.splice(j, 1); // len-- - // Matter.World.remove(engine.world, touching[i].bodyB); + // Matter.Composite.remove(engine.world, touching[i].bodyB); // break; // } // } @@ -846,7 +847,7 @@ const level = { // } // } // } - // Matter.World.remove(engine.world, touching[0].bodyB); + // Matter.Composite.remove(engine.world, touching[0].bodyB); // } } @@ -869,13 +870,13 @@ const level = { }, unit: unitA, angle: angleA, - color: simulation.draw.mapFill, + color: color.map, draw: draw, query: query, lastPortalCycle: 0 }); Matter.Body.setStatic(mapA, true); //make static - World.add(engine.world, mapA); //add to world + Composite.add(engine.world, mapA); //add to world const mapB = composite[composite.length] = Bodies.rectangle(centerB.x - 0.5 * unitB.x * mapWidth, centerB.y - 0.5 * unitB.y * mapWidth, mapWidth, height + 10, { collisionFilter: { @@ -884,13 +885,13 @@ const level = { }, unit: unitB, angle: angleB, - color: simulation.draw.mapFill, + color: color.map, draw: draw, query: query, lastPortalCycle: 0, }); Matter.Body.setStatic(mapB, true); //make static - World.add(engine.world, mapB); //add to world + Composite.add(engine.world, mapB); //add to world mapA.portal = portalA mapB.portal = portalB @@ -1041,7 +1042,7 @@ const level = { stiffness: stiffness, damping: damping }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); } cons[cons.length] = Constraint.create({ //pin first block to a point in space pointA: { @@ -1052,7 +1053,7 @@ const level = { stiffness: 1, damping: damping }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); if (isAttached) { cons[cons.length] = Constraint.create({ //pin last block to a point in space pointA: { @@ -1063,7 +1064,7 @@ const level = { stiffness: 1, damping: damping }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); } }, //****************************************************************************************************************** @@ -1074,7 +1075,7 @@ const level = { level.isProcedural = true //used in generating text itn he level builder level.defaultZoom = 1700 simulation.zoomTransition(level.defaultZoom) - document.body.style.backgroundColor = "#dcdcdf"; + document.body.style.backgroundColor = "#d9d9de" //"#d3d3db" //"#dcdcdf"; let isDoorLeft, isDoorRight, x, y doCustom = [] doCustomTopLayer = [] @@ -1361,11 +1362,11 @@ const level = { body[index].collisionFilter.category = cat.body; body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].classType = "body"; - World.add(engine.world, body[index]); //add to world + Composite.add(engine.world, body[index]); //add to world setTimeout(() => { //remove block for (let i = 0; i < body.length; i++) { if (body[i] === bodyBullet) { - Matter.World.remove(engine.world, body[i]); + Matter.Composite.remove(engine.world, body[i]); body.splice(i, 1); } } @@ -1418,11 +1419,11 @@ const level = { body[index].collisionFilter.category = cat.body; body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].classType = "body"; - World.add(engine.world, body[index]); //add to world + Composite.add(engine.world, body[index]); //add to world setTimeout(() => { //remove block for (let i = 0; i < body.length; i++) { if (body[i] === bodyBullet) { - Matter.World.remove(engine.world, body[i]); + Matter.Composite.remove(engine.world, body[i]); body.splice(i, 1); } } @@ -1787,7 +1788,7 @@ const level = { // who.collisionFilter.category = cat.map; // who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; // Matter.Body.setStatic(who, true); //make static - // World.add(engine.world, who); //add to world + // Composite.add(engine.world, who); //add to world // } // const numberOfMapElementsAdded = 0 // for (let i = 0; i < numberOfMapElementsAdded; i++) addMapToLevelInProgress(map[map.length - 1 - i]) @@ -1821,7 +1822,7 @@ const level = { who.collisionFilter.category = cat.map; who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; Matter.Body.setStatic(who, true); //make static - World.add(engine.world, who); //add to world + Composite.add(engine.world, who); //add to world } let r = 150 let hexagon = `${r} 0 ${r*Math.cos(5.236)} ${r*Math.sin(5.236)} ${r*Math.cos(4.189)} ${r*Math.sin(4.189)} ${-r} 0 ${r*Math.cos(2.0944)} ${r*Math.sin(2.0944)} ${r*Math.cos(1.0472)} ${r*Math.sin(1.0472)} ` @@ -1908,7 +1909,7 @@ const level = { who.collisionFilter.category = cat.map; who.collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; Matter.Body.setStatic(who, true); //make static - World.add(engine.world, who); //add to world + Composite.add(engine.world, who); //add to world } //right side hexagons let r = 300 @@ -2040,7 +2041,7 @@ const level = { } } - let rows = [ + let columns = [ () => { offset.y = 0 outlineUpDown() @@ -2065,7 +2066,7 @@ const level = { rooms[3]() }, ] - rows = shuffle(rows) //********************************* RUN THIS LINE IN THE FINAL VERSION *************************************** + columns = shuffle(columns) //********************************* RUN THIS LINE IN THE FINAL VERSION *************************************** for (let i = 0; i < 3; i++) { if (i === 0) { isDoorLeft = false @@ -2078,7 +2079,7 @@ const level = { isDoorRight = false } offset.x = i * 2100 - rows[i]() + columns[i]() } level.custom = () => { for (let i = 0, len = doCustom.length; i < len; i++) doCustom[i]() //runs all the active code from each room @@ -2187,7 +2188,7 @@ const level = { level.setPosToSpawn(0, -50); //normal spawn spawn.mapRect(level.enter.x, level.enter.y + 25, 100, 10); level.exit.x = 0; - level.exit.y = 400; + level.exit.y = 40000; level.defaultZoom = 1000 simulation.zoomTransition(level.defaultZoom) // document.body.style.backgroundColor = "#aaa"; @@ -2230,7 +2231,7 @@ const level = { spawn.setSpawnList(); level.defaultZoom = 1500 simulation.zoomTransition(level.defaultZoom) - document.body.style.backgroundColor = "#ddd"; + document.body.style.backgroundColor = color.background //"#ddd"; // simulation.draw.mapFill = "#444" // simulation.draw.bodyFill = "rgba(140,140,140,0.85)" // simulation.draw.bodyStroke = "#222" @@ -2241,7 +2242,7 @@ const level = { spawn.mapRect(-950, -1800, 8200, 800); //roof spawn.mapRect(-250, -400, 1000, 600); // shelf spawn.mapRect(-250, -1200, 1000, 550); // shelf roof - // powerUps.spawnStartingPowerUps(600, -800); + powerUps.spawnStartingPowerUps(600, -800); // for (let i = 0; i < 50; ++i) powerUps.spawn(550, -800, "research", false); // powerUps.spawn(350, -800, "gun", false); @@ -2270,11 +2271,11 @@ const level = { spawn.mapRect(5300, -275, 50, 175); spawn.mapRect(5050, -100, 50, 150); spawn.mapRect(4850, -275, 50, 175); - spawn.starter(1900, -500, 200) //big boy + // spawn.starter(1900, -500, 200) //big boy // spawn.growBossCulture(1900, -500) // spawn.blinkBoss(1900, -500) // spawn.snakeBoss(1900, -500) - // spawn.grenadierBoss(1900, -500) + // spawn.growBossCulture(1900, -500) // spawn.sneaker(1900, -500) // spawn.historyBoss(1200, -500) // spawn.laserTargetingBoss(1600, -400) @@ -2285,7 +2286,7 @@ const level = { // spawn.streamBoss(1600, -500) // spawn.powerUpBoss(1600, -500) // spawn.cellBossCulture(1600, -500) - // spawn.shieldingBoss(1600, -500) + spawn.shieldingBoss(1600, -500) // spawn.grenadier(1200, -500) // spawn.shield(mob[mob.length - 1], 1800, -120, 1); @@ -2718,7 +2719,7 @@ const level = { if (!(m.cycle % 60)) { //so much work to catch blocks caught at the bottom of the vertical portals let touching = Matter.Query.collides(map[removeIndex1], body) if (touching.length) { - Matter.World.remove(engine.world, touching[0].bodyB); + Matter.Composite.remove(engine.world, touching[0].bodyB); for (let i = 0, len = body.length; i < len; i++) { if (body[i].id === touching[0].bodyB.id) { body.splice(i, 1); @@ -2728,7 +2729,7 @@ const level = { } touching = Matter.Query.collides(map[removeIndex2], body) if (touching.length) { - Matter.World.remove(engine.world, touching[0].bodyB); + Matter.Composite.remove(engine.world, touching[0].bodyB); for (let i = 0, len = body.length; i < len; i++) { if (body[i].id === touching[0].bodyB.id) { body.splice(i, 1); @@ -3981,7 +3982,7 @@ const level = { powerUps.spawn(-4200, -700, "ammo"); powerUps.spawn(-4000, -700, "ammo"); spawn.mapRect(-4450, -1000, 100, 500); - spawn.bodyRect(-3500, -750, 150, 150); + spawn.bodyRect(-3300, -750, 150, 150); //building 1 spawn.bodyRect(-1000, -675, 25, 25); @@ -4317,7 +4318,7 @@ const level = { stiffness: 0.0001815, length: 1 }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); spawn.bodyRect(600, 525, 125, 125, 1, spawn.propsSlide); //weight spawn.bodyRect(800, 600, 300, 100, 1, spawn.propsHoist); //hoist @@ -4330,7 +4331,7 @@ const level = { stiffness: 0.0001815, length: 1 }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); spawn.bodyRect(-2700, 1150, 100, 160, 1, spawn.propsSlide); //weight spawn.bodyRect(-2550, 1150, 200, 100, 1, spawn.propsSlide); //weight @@ -4344,7 +4345,7 @@ const level = { stiffness: 0.0005, length: 566 }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); } //blocks spawn.bodyRect(-165, -150, 30, 35, 1); @@ -4569,7 +4570,7 @@ const level = { bodyB: map[map.length - 1], stiffness: 1 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); spawn.mapRect(-600 + 300, -2000 * 0.75, 1900, 50); //3rd floor spawn.mapRect(-600 + 2000 * 0.7, -2000 * 0.74, 50, 375); //center wall spawn.bodyRect(-600 + 2000 * 0.7, -2000 * 0.5 - 106, 50, 106); //center block under wall @@ -4757,7 +4758,7 @@ const level = { stiffness: 0.0002, //1217, length: 200 }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); spawn.bodyRect(2799, -870, 310, 290); //Gros bloc angle toit spawn.mapRect(4000, -1750, 50, 400); //Right Wall Cuve @@ -4806,7 +4807,7 @@ const level = { bodyB: map[map.length - 1], stiffness: 1 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); spawn.bodyRect(650, 50, 70, 50); spawn.bodyRect(300, 0, 100, 60); spawn.bodyRect(400, 0, 100, 150); @@ -4996,7 +4997,7 @@ const level = { stiffness: 0.00014, length: 120 }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); spawn.bodyRect(0, -1250, 240, 190) //Fat cube ascenseur } else { /// Reversed spawn spawn.bodyRect(0, -650, 225, 175); @@ -5199,7 +5200,7 @@ const level = { map[len].collisionFilter.category = cat.map; map[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; Matter.Body.setStatic(map[len], true); //make static - World.add(engine.world, map[len]); //add to world + Composite.add(engine.world, map[len]); //add to world simulation.draw.setPaths() //update map graphics } @@ -5208,7 +5209,7 @@ const level = { len = body.length - 1 body[len].collisionFilter.category = cat.body; body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet - World.add(engine.world, body[len]); //add to world + Composite.add(engine.world, body[len]); //add to world body[len].classType = "body" } @@ -5656,8 +5657,8 @@ const level = { chair2 = Body.create({ parts: [part4, part5, part6], }); - World.add(engine.world, [chair]); - World.add(engine.world, [chair2]); + Composite.add(engine.world, [chair]); + Composite.add(engine.world, [chair2]); composite[composite.length] = chair; composite[composite.length] = chair2; body[body.length] = part1; @@ -5712,7 +5713,7 @@ const level = { rightLowerLeg, leftUpperLeg, rightUpperLeg ], }); - World.add(engine.world, [person]); + Composite.add(engine.world, [person]); composite[composite.length] = person body[body.length] = chest body[body.length] = head @@ -5773,7 +5774,7 @@ const level = { bodyB: map[map.length - 1], stiffness: 1 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); //table + chaises spawn.mapRect(4025, -850, 50, 175); @@ -6371,23 +6372,23 @@ const level = { //Boss Spawning if (simulation.difficulty > 10) { - spawn.pulsarBoss(-400, -200); + spawn.pulsarBoss(3600, -400); powerUps.chooseRandomPowerUp(4006, 400); powerUps.chooseRandomPowerUp(4407, 400); powerUps.spawnStartingPowerUps(4400, 400); if (simulation.difficulty > 30) { powerUps.chooseRandomPowerUp(4002, 400); powerUps.chooseRandomPowerUp(4004, 400); - spawn.pulsarBoss(3600, -400); + spawn.pulsarBoss(4200, 1000); if (simulation.difficulty > 60) { powerUps.chooseRandomPowerUp(4409, 400); - spawn.pulsarBoss(4200, 1000); + spawn.pulsarBoss(5800, -1200); if (simulation.difficulty > 80) { - spawn.pulsarBoss(5800, -1200); + spawn.pulsarBoss(-400, -200); if (simulation.difficulty > 100) { - spawn.pulsarBoss(-400, -200); + spawn.pulsarBoss(3600, -400); if (simulation.difficulty > 120) { - spawn.pulsarBoss(3600, -400); + spawn.pulsarBoss(-400, -200); } } } @@ -6541,7 +6542,7 @@ const level = { stiffness: 0.005, length: 700 }); - World.add(engine.world, [cons[cons.length - 2], cons[cons.length - 1]]); + Composite.add(engine.world, [cons[cons.length - 2], cons[cons.length - 1]]); spawn.bodyRect(5225, -2525, 300, 75); spawn.bodyRect(4700, -2525, 100, 75, 0.5); @@ -6649,7 +6650,7 @@ const level = { stiffness: 0.002, length: 1000 }); - World.add(engine.world, [cons[cons.length - 1], cons[cons.length - 2]]) + Composite.add(engine.world, [cons[cons.length - 1], cons[cons.length - 2]]) } const boost1 = level.boost(4400, -1385, 1200) @@ -6663,7 +6664,7 @@ const level = { if (!buttonGreen.isUp) { if (!g) { - Matter.World.remove(engine.world, cons[1]) + Matter.Composite.remove(engine.world, cons[1]) cons.splice(1, 2) } g = true; @@ -6715,7 +6716,7 @@ const level = { body[len] = Matter.Bodies.polygon(Math.floor(Math.random() * 1700) + 1050, 100, Math.floor(Math.random() * 11) + 10, Math.floor(Math.random() * 20) + 15) body[len].collisionFilter.category = cat.body; body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet; - World.add(engine.world, body[len]) + Composite.add(engine.world, body[len]) nextBlockSpawn = simulation.cycle + Math.floor(Math.random() * 60 + 30) } @@ -6738,7 +6739,7 @@ const level = { y: slowY * body[i].velocity.y }); if (body[i].mass < 0.05) { - Matter.World.remove(engine.world, body[i]) + Matter.Composite.remove(engine.world, body[i]) body.splice(i, 1) break } @@ -7169,7 +7170,7 @@ const level = { const compoundParts = Body.create({ parts: [part1, part2, part3], }); - World.add(engine.world, [compoundParts]); + Composite.add(engine.world, [compoundParts]); needGravity[needGravity.length] = compoundParts; composite[composite.length] = compoundParts; body[body.length] = part1; @@ -7198,7 +7199,7 @@ const level = { }, stiffness: stiff }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); } //I SINCERELY APOLOGIZE FOR THE ILLEGIBLE BLOCKS OF STRING CONCATENATION diff --git a/js/lore.js b/js/lore.js index aaea374..d02b2c6 100644 --- a/js/lore.js +++ b/js/lore.js @@ -305,7 +305,7 @@ const lore = { lore.talkingColor = "#dff" level.isHazardRise = true //remove all bullets, so they can't get endless energy - for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); + for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]); bullet = []; setTimeout(() => { lore.anand.text("I'm actually surprised you haven't been attacked by the adversarial network this time.") }, 500); }, @@ -401,7 +401,7 @@ const lore = { }, () => { lore.talkingColor = "#dff"; - setTimeout(() => { lore.anand.text("hurry back!") }, 1000); + setTimeout(() => { lore.anand.text("Hurry back!") }, 1000); }, () => { lore.talkingColor = "#dff" }, ], diff --git a/js/mob.js b/js/mob.js index 750db89..0e77675 100644 --- a/js/mob.js +++ b/js/mob.js @@ -222,7 +222,6 @@ const mobs = { alive: true, index: i, health: tech.mobSpawnWithHealth, - damageReduction: 1, showHealthBar: true, accelMag: 0.001 * simulation.accelScale, cd: 0, //game cycle when cooldown will be over @@ -1042,8 +1041,10 @@ const mobs = { if (tech.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.075 // if (this.isBoss) dmg *= 0.25 - dmg *= this.damageReduction - + if (this.damageReduction < 1) { //only used for bosses with this.armor() or shields + this.damageReductionGoal += dmg * this.damageReductionScale //reduce damageReductionGoal + dmg *= this.damageReduction + } //energy and heal drain should be calculated after damage boosts if (tech.energySiphon && dmg !== Infinity && this.isDropPowerUp && m.immuneCycle < m.cycle) m.energy += Math.min(this.health, dmg) * tech.energySiphon if (tech.healthDrain && dmg !== Infinity && this.isDropPowerUp) { @@ -1067,6 +1068,20 @@ const mobs = { // a placeholder for custom effects on mob death // to use declare custom method in mob spawn }, + damageReduction: 1, + damageReductionGoal: 0.001, //must add this to boss set up: me.damageReduction = me.damageReductionGoal + damageReductionScale: 0.004, //for bosses in this.onDamage determines the impact of dmg on damageReductionGoal + armor() { //slowly reduce damage reduction, for bosses + if (this.seePlayer.recall) { + if (this.damageReductionGoal > 0.24) { + this.damageReductionGoal = 0.25 + } else { + this.damageReductionGoal = this.damageReductionGoal * 0.999 + 0.001 * 0.25 //smooth the goal towards 0.25 damage reduction + } + this.damageReduction = this.damageReduction * 0.995 + 0.005 * this.damageReductionGoal //smooth damage reduction towards the goal + // console.log(`damageReduction = ${this.damageReduction.toFixed(4)}`, `damageReductionGoal = ${this.damageReductionGoal.toFixed(4)}`) + } + }, leaveBody: true, isDropPowerUp: true, death() { @@ -1217,7 +1232,7 @@ const mobs = { // body[len].collisionFilter.mask = cat.player | cat.bullet | cat.mob | cat.mobBullet; // } body[len].classType = "body"; - World.add(engine.world, body[len]); //add to world + Composite.add(engine.world, body[len]); //add to world //large mobs shrink so they don't block paths if (body[len].mass > 9) { @@ -1230,7 +1245,7 @@ const mobs = { }; shrink(body[len], 7 + 4 * Math.random()) } - Matter.World.remove(engine.world, this); + Matter.Composite.remove(engine.world, this); mob.splice(i, 1); if (tech.isMobBlockFling) { const who = body[body.length - 1] @@ -1238,12 +1253,12 @@ const mobs = { Matter.Body.setAngularVelocity(who, (0.5 + 0.2 * Math.random()) * (Math.random() < 0.5 ? -1 : 1)); } } else { - Matter.World.remove(engine.world, this); + Matter.Composite.remove(engine.world, this); mob.splice(i, 1); } } }); mob[i].alertRange2 = Math.pow(mob[i].radius * 3 + 550, 2); - World.add(engine.world, mob[i]); //add to world + Composite.add(engine.world, mob[i]); //add to world } }; \ No newline at end of file diff --git a/js/player.js b/js/player.js index 195e957..4422a9c 100644 --- a/js/player.js +++ b/js/player.js @@ -39,7 +39,7 @@ const m = { } }); Matter.Body.setMass(player, m.mass); - World.add(engine.world, [player]); + Composite.add(engine.world, [player]); }, cycle: 600, //starts at 600 cycles instead of 0 to prevent bugs with m.history lastKillCycle: 0, @@ -331,7 +331,7 @@ const m = { const randomBotCount = b.totalBots() b.zeroBotCount() //remove all bullets, respawn bots - for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); + for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]); bullet = []; //randomize health @@ -437,7 +437,7 @@ const m = { document.getElementById("fade-out").style.opacity = 1; //slowly fades out // build.shareURL(false) setTimeout(function() { - World.clear(engine.world); + Composite.clear(engine.world); Engine.clear(engine); simulation.splashReturn(); }, 3000); @@ -650,6 +650,7 @@ const m = { ctx.fillRect(0, 0, canvas.width, canvas.height); } setTimeout(function() { + tech.maxDuplicationEvent() simulation.wipe = function() { //set wipe to normal ctx.clearRect(0, 0, canvas.width, canvas.height); } @@ -679,6 +680,7 @@ const m = { ctx.fillRect(0, 0, canvas.width, canvas.height); } setTimeout(function() { + tech.maxDuplicationEvent() simulation.wipe = function() { //set wipe to normal ctx.clearRect(0, 0, canvas.width, canvas.height); } @@ -1130,7 +1132,7 @@ const m = { //remove block before pulse, so it doesn't get in the way for (let i = 0; i < body.length; i++) { if (body[i] === m.holdingTarget) { - Matter.World.remove(engine.world, body[i]); + Matter.Composite.remove(engine.world, body[i]); body.splice(i, 1); } } @@ -1264,7 +1266,7 @@ const m = { y: player.velocity.y + powerUp[i].velocity.y / player.mass * 5 }); powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); return; //because the array order is messed up after splice } @@ -2495,7 +2497,7 @@ const m = { ) { //use power up if it is close enough powerUps.onPickUp(powerUp[i]); powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); // m.fieldRadius += 50 break; //because the array order is messed up after splice @@ -2605,9 +2607,9 @@ const m = { }, { name: "wormhole", - description: "use energy to tunnel through a wormhole
wormholes attract blocks and power ups
11% chance to duplicate spawned power ups", //
bullets may also traverse wormholes + description: "use energy to tunnel through a wormhole
wormholes attract blocks and power ups
9% chance to duplicate spawned power ups", //
bullets may also traverse wormholes effect: function() { - m.duplicateChance = 0.11 + m.duplicateChance = 0.09 powerUps.setDo(); //needed after adjusting duplication chance m.hold = function() { @@ -2667,7 +2669,7 @@ const m = { m.fieldRange *= 0.8 powerUps.onPickUp(powerUp[i]); powerUp[i].effect(); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); break; //because the array order is messed up after splice } @@ -2691,7 +2693,7 @@ const m = { if (Vector.magnitude(Vector.sub(m.hole.pos1, body[i].position)) < shrinkRange) { Matter.Body.scale(body[i], shrinkScale, shrinkScale); if (body[i].mass < 0.05) { - Matter.World.remove(engine.world, body[i]); + Matter.Composite.remove(engine.world, body[i]); body.splice(i, 1); m.fieldRange *= 0.8 if (tech.isWormholeEnergy) m.energy += 0.63 @@ -2724,7 +2726,7 @@ const m = { if (Vector.magnitude(Vector.sub(m.hole.pos2, body[i].position)) < shrinkRange) { Matter.Body.scale(body[i], shrinkScale, shrinkScale); if (body[i].mass < 0.05) { - Matter.World.remove(engine.world, body[i]); + Matter.Composite.remove(engine.world, body[i]); body.splice(i, 1); m.fieldRange *= 0.8 // if (tech.isWormholeEnergy && m.energy < m.maxEnergy * 2) m.energy = m.maxEnergy * 2 @@ -2911,7 +2913,7 @@ const m = { // if (dxP * dxP + dyP * dyP < 50000 && !simulation.isChoosing && !(m.health === m.maxHealth && powerUp[i].name === "heal")) { // powerUps.onPickUp(player.position); // powerUp[i].effect(); - // Matter.World.remove(engine.world, powerUp[i]); + // Matter.Composite.remove(engine.world, powerUp[i]); // powerUp.splice(i, 1); // const shortPause = function() { // if (m.defaultFPSCycle < m.cycle) { //back to default values diff --git a/js/powerup.js b/js/powerup.js index 10c7d70..e84eca8 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -83,7 +83,7 @@ const powerUps = { for (let i = 0, len = powerUp.length; i < len; ++i) { if (powerUp[i].isDuplicated && Math.random() < 0.004) { // (1-0.004)^150 = chance to be removed after 3 seconds b.explosion(powerUp[i].position, 150 + (10 + 3 * Math.random()) * powerUp[i].size); - Matter.World.remove(engine.world, powerUp[i]); + Matter.Composite.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); break } @@ -209,7 +209,7 @@ const powerUps = { // document.body.style.overflow = "hidden" simulation.paused = false; simulation.isChoosing = false; //stops p from un pausing on key down - if (m.immuneCycle < m.cycle + tech.collisionImmuneCycles) m.immuneCycle = m.cycle + tech.collisionImmuneCycles; //player is immune to damage for 30 cycles + if (m.immuneCycle < m.cycle + 15) m.immuneCycle = m.cycle + 15; //player is immune to damage for 30 cycles build.unPauseGrid() requestAnimationFrame(cycle); if (m.holdingTarget) m.drop(); @@ -234,7 +234,7 @@ const powerUps = { } } if (tech.isRerollBots) { - for (const cost = 3; powerUps.research.count > cost - 1; powerUps.research.count -= cost) { + for (const cost = 4; powerUps.research.count > cost - 1; powerUps.research.count -= cost) { b.randomBot() if (tech.renormalization) { for (let i = 0; i < cost; i++) { @@ -373,7 +373,7 @@ const powerUps = { if (tech.isAmmoForGun && b.inventory.length > 0 && b.activeGun) { const target = b.guns[b.activeGun] if (target.ammo !== Infinity) { - const ammoAdded = Math.ceil((0.82 * Math.random() + 0.8 * Math.random()) * target.ammoPack) + const ammoAdded = Math.ceil((0.7 * Math.random() + 0.7 * Math.random()) * target.ammoPack) target.ammo += ammoAdded simulation.makeTextLog(`${target.name}.ammo += ${ammoAdded}`) } @@ -884,7 +884,7 @@ const powerUps = { y: Math.random() * -9 - 3 }); } - World.add(engine.world, powerUp[index]); //add to world + Composite.add(engine.world, powerUp[index]); //add to world }, spawn(x, y, target, moving = true, mode = null, size = powerUps[target].size()) { if ( diff --git a/js/simulation.js b/js/simulation.js index 98f9e6c..4f17b8a 100644 --- a/js/simulation.js +++ b/js/simulation.js @@ -526,7 +526,7 @@ const simulation = { m.spawn(); //spawns the player m.look = m.lookDefault } else { - World.add(engine.world, [player]) + Composite.add(engine.world, [player]) } simulation.isHorizontalFlipped = (Math.random() < 0.5) ? true : false //if true, some maps are flipped horizontally @@ -735,7 +735,8 @@ const simulation = { simulation.drawList = []; function removeAll(array) { - for (let i = 0; i < array.length; ++i) Matter.World.remove(engine.world, array[i]); + // for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]); + for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]); } removeAll(map); map = []; @@ -882,7 +883,7 @@ const simulation = { y: level.exit.y + 30 * (Math.random() - 0.5) }); } else { - Matter.World.remove(engine.world, who[i]); + Matter.Composite.remove(engine.world, who[i]); who.splice(i, 1); } } @@ -998,11 +999,8 @@ const simulation = { simulation.draw.mapPath.lineTo(vertices[0].x, vertices[0].y); } }, - mapFill: "#444", - bodyFill: "rgba(140,140,140,0.85)", //"#999", - bodyStroke: "#222", drawMapPath() { - ctx.fillStyle = simulation.draw.mapFill; + ctx.fillStyle = color.map; ctx.fill(simulation.draw.mapPath); }, body() { @@ -1016,9 +1014,9 @@ const simulation = { ctx.lineTo(vertices[0].x, vertices[0].y); } ctx.lineWidth = 2; - ctx.fillStyle = simulation.draw.bodyFill; + ctx.fillStyle = color.block; ctx.fill(); - ctx.strokeStyle = simulation.draw.bodyStroke; + ctx.strokeStyle = color.blockS; ctx.stroke(); }, cons() { @@ -1194,7 +1192,7 @@ const simulation = { map[len].collisionFilter.category = cat.map; map[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet; Matter.Body.setStatic(map[len], true); //make static - World.add(engine.world, map[len]); //add to world + Composite.add(engine.world, map[len]); //add to world simulation.draw.setPaths() //update map graphics } else if (e.which === 3) { //add body @@ -1209,7 +1207,7 @@ const simulation = { len = body.length - 1 body[len].collisionFilter.category = cat.body; body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet - World.add(engine.world, body[len]); //add to world + Composite.add(engine.world, body[len]); //add to world body[len].classType = "body" } } @@ -1230,12 +1228,12 @@ const simulation = { if (simulation.testing && e.keyCode === 90 && simulation.constructMapString.length) { if (simulation.constructMapString[simulation.constructMapString.length - 1][6] === 'm') { //remove map from current level const index = map.length - 1 - Matter.World.remove(engine.world, map[index]); + Matter.Composite.remove(engine.world, map[index]); map.splice(index, 1); simulation.draw.setPaths() //update map graphics } else if (simulation.constructMapString[simulation.constructMapString.length - 1][6] === 'b') { //remove body from current level const index = body.length - 1 - Matter.World.remove(engine.world, body[index]); + Matter.Composite.remove(engine.world, body[index]); body.splice(index, 1); } simulation.constructMapString.pop(); diff --git a/js/spawn.js b/js/spawn.js index 4d5c896..60e75fc 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -250,12 +250,12 @@ const spawn = { stiffness: 1, damping: 1 }); - World.add(engine.world, me.constraint); + Composite.add(engine.world, me.constraint); }, 2000); //add in a delay in case the level gets flipped left right me.isBoss = true; - me.damageReduction = 0.25; - me.damageReduction = 0.25; + + me.frictionAir = 0.01; me.memory = Infinity; me.hasRunDeathScript = false @@ -276,7 +276,7 @@ const spawn = { body[len].collisionFilter.category = cat.body; body[len].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet; body[len].classType = "body"; - World.add(engine.world, body[len]); //add to world + Composite.add(engine.world, body[len]); //add to world const expand = function(that, massLimit) { const scale = 1.05; Matter.Body.scale(that, scale, scale); @@ -291,7 +291,7 @@ const spawn = { level.exit.x = 5500; } level.exit.y = -330; - Matter.World.remove(engine.world, map[map.length - 1]); + Matter.Composite.remove(engine.world, map[map.length - 1]); map.splice(map.length - 1, 1); simulation.draw.setPaths(); //redraw map draw path } @@ -316,7 +316,7 @@ const spawn = { } else if (count === 780) { simulation.makeTextLog(`undefined = ${lore.techCount}/${lore.techGoal}`) } else if (count === 1020) { - simulation.makeTextLog(`World.clear(engine.world) //simulation successful`); + simulation.makeTextLog(`Composite.clear(engine.composite) //simulation successful`); } else if (count === 1260) { // tech.isImmortal = false; // m.death() @@ -331,7 +331,7 @@ const spawn = { // build.shareURL(false) setTimeout(function() { simulation.paused = true; - World.clear(engine.world); + Composite.clear(engine.composite); Engine.clear(engine); simulation.splashReturn(); }, 6000); @@ -353,7 +353,7 @@ const spawn = { level.difficultyIncrease(simulation.difficultyMode) //ramp up damage //remove power Ups, to avoid spamming console function removeAll(array) { - for (let i = 0; i < array.length; ++i) Matter.World.remove(engine.world, array[i]); + for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]); } removeAll(powerUp); powerUp = []; @@ -388,7 +388,9 @@ const spawn = { me.endCycle = 780; me.totalCycles = 0 me.mode = 0; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); // Matter.Body.setPosition(this, { // x: x, // y: y @@ -727,10 +729,9 @@ const spawn = { let me = mob[mob.length - 1]; me.stroke = "transparent" me.isBoss = true; - me.damageReduction = 0.25; me.isCell = true; me.cellID = cellID - me.accelMag = 0.00016 * simulation.accelScale; + me.accelMag = 0.000165 * simulation.accelScale; me.memory = 40; me.isVerticesChange = true me.frictionAir = 0.012 @@ -753,7 +754,9 @@ const spawn = { me.onDamage = function(dmg) { if (Math.random() < 0.33 * dmg * Math.sqrt(this.mass) && this.health > dmg) this.split(); } + me.damageReduction = 0.25 me.do = function() { + // this.armor(); if (!m.isBodiesAsleep) { this.seePlayerByDistOrLOS(); this.checkStatus(); @@ -805,7 +808,7 @@ const spawn = { mobs.spawn(x + Math.random(), y + Math.random(), 4, radius, "rgba(255,60,0,0.3)") //); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.isSpawnBoss = true; me.spawnID = spawnID me.accelMag = 0.0002 * simulation.accelScale; @@ -824,8 +827,10 @@ const spawn = { me.onHit = function() { //run this function on hitting player this.explode(); }; + me.damageReduction = 0.25 me.doAwake = function() { if (!m.isBodiesAsleep) { + // this.armor(); this.alwaysSeePlayer(); this.checkStatus(); this.attraction(); @@ -898,7 +903,7 @@ const spawn = { mobs.spawn(x + Math.random(), y + Math.random(), 6, radius, "hsl(144, 15%, 50%)") //); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.isBuffBoss = true; me.buffID = buffID me.memory = Infinity; @@ -917,7 +922,7 @@ const spawn = { this.accelMag += 0.000035 //* Math.sqrt(simulation.accelScale) // Matter.Body.setDensity(this, 0.001 + 0.0003 * this.buffCount) // normal density is 0.001 //+ 0.0005 * Math.sqrt(simulation.difficulty) this.fill = `hsl(144, ${5+10*this.buffCount}%, 50%)` - const scale = 1.13; + const scale = 1.132; Matter.Body.scale(this, scale, scale); this.radius *= scale; // this.health += 0.03 @@ -939,7 +944,9 @@ const spawn = { if (!count % 2) powerUps.spawnRandomPowerUp(this.position.x, this.position.y) // higher then normal chance to drop heals and ammo } } + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.alwaysSeePlayer(); this.checkStatus(); this.attraction(); @@ -965,7 +972,7 @@ const spawn = { mobs.spawn(x, y, vertices, radius, "transparent"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.frictionAir = 0.01 me.seeAtDistance2 = 1000000; me.accelMag = 0.0005 * simulation.accelScale; @@ -999,7 +1006,9 @@ const spawn = { } for (let i = 0; i < powerUp.length; i++) powerUp[i].collisionFilter.mask = cat.map | cat.powerUp }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.stroke = `hsl(0,0%,${80+25*Math.sin(simulation.cycle*0.01)}%)` //steal all power ups @@ -1073,7 +1082,7 @@ const spawn = { stiffness: springStiffness, damping: springDampening }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); cons[len].length = 100 + 1.5 * radius; me.cons = cons[len]; @@ -1089,7 +1098,7 @@ const spawn = { stiffness: springStiffness, damping: springDampening }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); cons[len2].length = 100 + 1.5 * radius; me.cons2 = cons[len2]; me.do = function() { @@ -1147,7 +1156,7 @@ const spawn = { mobs.spawn(x, y, 5, radius, "rgb(0,200,180)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.g = 0.005; //required if using 'gravity' me.frictionAir = 0.01; me.friction = 1 @@ -1166,7 +1175,9 @@ const spawn = { powerUps.spawnBossPowerUp(this.position.x, this.position.y) }; me.lastSpeed = me.speed + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.gravity(); this.seePlayerCheck(); this.checkStatus(); @@ -1365,7 +1376,7 @@ const spawn = { mobs.spawn(x, y, 12, radius, "#000"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.stroke = "transparent"; //used for drawSneaker me.eventHorizon = 1100; //required for black hole me.seeAtDistance2 = (me.eventHorizon + 1200) * (me.eventHorizon + 1200); //vision limit is event horizon @@ -1395,7 +1406,9 @@ const spawn = { // toMe(bullet, this.position, this.eventHorizon) } }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); //keep it slow, to stop issues from explosion knock backs if (this.speed > 1) { Matter.Body.setVelocity(this, { @@ -1477,7 +1490,7 @@ const spawn = { let me = mob[mob.length - 1]; Matter.Body.setDensity(me, 0.0035); //extra dense //normal is 0.001 //makes effective life much larger me.isBoss = true; - me.damageReduction = 0.25; + targets.push(me.id) //add to shield protection me.friction = 0; me.frictionAir = 0.0065; @@ -1498,7 +1511,7 @@ const spawn = { stiffness: springStiffness, damping: springDampening }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); cons[len].length = 100 + 1.5 * radius; me.cons = cons[len]; @@ -1514,10 +1527,12 @@ const spawn = { damping: springDampening, length: 0 }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); cons[len2].length = 100 + 1.5 * radius; me.cons2 = cons[len2]; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.gravity(); this.searchSpring(); this.checkStatus(); @@ -1552,7 +1567,7 @@ const spawn = { stiffness: attachmentStiffness, damping: 0.01 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); } //spawn shield around all nodes spawn.groupShield(targets, x, y, sideLength + 1 * radius + nodes * 5 - 25); @@ -1561,7 +1576,7 @@ const spawn = { // timeSkipBoss(x, y, radius = 55) { // mobs.spawn(x, y, 6, radius, '#000'); // let me = mob[mob.length - 1]; - // me.isBoss = true; me.damageReduction = 0.25; + // me.isBoss = true; // // me.stroke = "transparent"; //used for drawSneaker // me.timeSkipLastCycle = 0 // me.eventHorizon = 1800; //required for black hole @@ -1668,7 +1683,7 @@ const spawn = { me.laserRange = 300; me.seeAtDistance2 = 2000000; me.isBoss = true; - me.damageReduction = 0.25; + me.showHealthBar = false; //drawn in this.awake me.delayLimit = 60 + Math.floor(30 * Math.random()); me.followDelay = 600 - Math.floor(60 * Math.random()) @@ -1678,7 +1693,9 @@ const spawn = { me.onDeath = function() { powerUps.spawnBossPowerUp(this.position.x, this.position.y) }; + me.damageReduction = 0.25 me.awake = function() { + // this.armor(); this.checkStatus(); //health bar needs to be here because the position is being set const h = this.radius * 0.3; @@ -1834,7 +1851,7 @@ const spawn = { mobs.spawn(x, y, 3, radius, color); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front Matter.Body.rotate(me, Math.random() * Math.PI * 2); me.accelMag = 0.00018 * Math.sqrt(simulation.accelScale); @@ -1860,7 +1877,9 @@ const spawn = { me.onDeath = function() { powerUps.spawnBossPowerUp(this.position.x, this.position.y) }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.seePlayerByLookingAt(); this.checkStatus(); this.attraction(); @@ -1975,12 +1994,12 @@ const spawn = { Matter.Body.rotate(me, Math.PI * 0.1); Matter.Body.setDensity(me, 0.02); //extra dense //normal is 0.001 //makes effective life much larger me.isBoss = true; - me.damageReduction = 0.25; + me.frictionStatic = 0; me.friction = 0; me.memory = 240 me.seePlayerFreq = 60 - me.delay = 16 + 30 * simulation.CDScale; + me.delay = 20 + 30 * simulation.CDScale; me.nextBlinkCycle = me.delay; me.blinkRange = 235 me.grenadeDelay = 30 + 60 * simulation.CDScale @@ -2003,7 +2022,9 @@ const spawn = { } powerUps.spawnBossPowerUp(this.position.x, this.position.y) } + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.seePlayerByHistory() if (this.nextBlinkCycle < simulation.cycle && this.seePlayer.yes) { //teleport towards the player this.nextBlinkCycle = simulation.cycle + this.delay; @@ -2041,7 +2062,7 @@ const spawn = { stiffness: 0.0001, damping: 0.3 }); - World.add(engine.world, me.constraint); + Composite.add(engine.world, me.constraint); }, 2000); //add in a delay in case the level gets flipped left right me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front @@ -2057,7 +2078,7 @@ const spawn = { me.isFiring = false Matter.Body.setDensity(me, 0.01); //extra dense //normal is 0.001 //makes effective life much larger me.isBoss = true; - me.damageReduction = 0.25; + spawn.shield(me, x, y, 1); spawn.spawnOrbitals(me, radius + 200 + 300 * Math.random(), 1) me.onDeath = function() { @@ -2067,7 +2088,9 @@ const spawn = { me.do = function() { if (player.speed > 5) this.do = this.fire //don't attack until player moves } + me.damageReduction = 0.25 me.fire = function() { + // this.armor(); this.checkStatus(); if (!m.isBodiesAsleep) { if (!m.isCloak && !this.isStunned) { @@ -2306,11 +2329,11 @@ const spawn = { stiffness: 1, damping: 1 }); - World.add(engine.world, me.constraint); + Composite.add(engine.world, me.constraint); }, 2000); //add in a delay in case the level gets flipped left right me.isBoss = true; - me.damageReduction = 0.25; + // me.startingPosition = { // x: x, // y: y @@ -2326,7 +2349,9 @@ const spawn = { }; me.rotateVelocity = Math.min(0.0045, 0.0015 * simulation.accelScale * simulation.accelScale) * (level.levelsCleared > 8 ? 1 : -1) * (simulation.isHorizontalFlipped ? -1 : 1) + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.fill = '#' + Math.random().toString(16).substr(-6); //flash colors this.checkStatus(); @@ -2734,12 +2759,12 @@ const spawn = { mobs.spawn(x, y, 3, radius, "rgba(255,0,200,0.5)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + Matter.Body.setDensity(me, 0.002 + 0.0001 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger me.stroke = "transparent"; //used for drawGhost me.seeAtDistance2 = 1500000; - me.fireFreq = Math.floor(100 * simulation.CDScale); + me.fireFreq = 10 + Math.floor(70 * simulation.CDScale); me.searchTarget = map[Math.floor(Math.random() * (map.length - 1))].position; //required for search me.hoverElevation = 460 + (Math.random() - 0.5) * 200; //squared me.hoverXOff = (Math.random() - 0.5) * 100; @@ -2765,7 +2790,9 @@ const spawn = { me.onDeath = function() { powerUps.spawnBossPowerUp(this.position.x, this.position.y) }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.seePlayerCheckByDistance(); this.checkStatus(); if (this.seePlayer.recall) { @@ -2819,11 +2846,11 @@ const spawn = { stiffness: 0.00004, damping: 0.1 }); - World.add(engine.world, me.constraint); + Composite.add(engine.world, me.constraint); }, 2000); //add in a delay in case the level gets flipped left right me.isBoss = true; - me.damageReduction = 0.25; + me.vertices = Matter.Vertices.rotate(me.vertices, Math.PI, me.position); //make the pointy side of triangle the front me.isVerticesChange = true me.memory = 240; @@ -2851,7 +2878,9 @@ const spawn = { // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.seePlayerByLookingAt(); this.checkStatus(); this.fire(); @@ -3113,14 +3142,14 @@ const spawn = { mobs.spawn(x, y, 6, radius, "rgb(150,150,255)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; - me.accelMag = 0.00008 * simulation.accelScale; - me.fireFreq = Math.floor(360 * simulation.CDScale) + + me.accelMag = 0.0001 * simulation.accelScale; + me.fireFreq = Math.floor(330 * simulation.CDScale) me.frictionStatic = 0; me.friction = 0; me.frictionAir = 0.02; me.memory = 420; - me.repulsionRange = 1200000; //squared + me.repulsionRange = 1000000; //squared spawn.shield(me, x, y, 1); spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random()) @@ -3130,7 +3159,9 @@ const spawn = { // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed }; me.onDamage = function() {}; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.seePlayerCheck(); this.checkStatus(); this.attraction(); @@ -3154,7 +3185,7 @@ const spawn = { mobs.spawn(x, y, 6, radius, "rgb(215,80,190)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.accelMag = 0.0001 * simulation.accelScale; me.fireFreq = Math.floor(360 * simulation.CDScale) me.frictionStatic = 0; @@ -3193,7 +3224,9 @@ const spawn = { }); } }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); if (this.grenadeLimiter > 1) this.grenadeLimiter-- this.seePlayerCheck(); this.checkStatus(); @@ -3334,15 +3367,14 @@ const spawn = { stiffness: 0.0001, damping: 1 }); - World.add(engine.world, me.constraint); + Composite.add(engine.world, me.constraint); }, 2000); //add in a delay in case the level gets flipped left right Matter.Body.rotate(me, Math.random() * 2 * Math.PI) // me.stroke = "rgb(220,220,255)" me.isBoss = true; - me.damageReduction = 0.25; me.cycle = 0 - me.maxCycles = 120; + me.maxCycles = 110; me.frictionStatic = 0; me.friction = 0; me.frictionAir = 0.5; @@ -3350,7 +3382,7 @@ const spawn = { spawn.shield(me, x, y, 1); spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random()) - Matter.Body.setDensity(me, 0.004); //extra dense //normal is 0.001 //makes effective life much larger + Matter.Body.setDensity(me, 0.0045); //extra dense //normal is 0.001 //makes effective life much larger me.onDeath = function() { powerUps.spawnBossPowerUp(this.position.x, this.position.y) // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed @@ -3358,9 +3390,10 @@ const spawn = { me.onDamage = function() { this.cycle = 0 }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.checkStatus(); - ctx.beginPath(); //draw cycle timer ctx.moveTo(this.vertices[this.vertices.length - 1].x, this.vertices[this.vertices.length - 1].y) const phase = (this.vertices.length + 1) * this.cycle / this.maxCycles @@ -3396,7 +3429,6 @@ const spawn = { mobs.spawn(x, y, 5, radius, "rgb(245,180,255)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; // me.accelMag = 0.00023 * simulation.accelScale; me.accelMag = 0.00008 * simulation.accelScale; // me.fireFreq = Math.floor(30 * simulation.CDScale) @@ -3418,7 +3450,9 @@ const spawn = { // this.vertices = Matter.Vertices.hull(Matter.Vertices.clockwiseSort(this.vertices)) //helps collisions functions work better after vertex have been changed }; me.onDamage = function() {}; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.seePlayerCheck(); this.checkStatus(); this.attraction(); @@ -3606,16 +3640,19 @@ const spawn = { this.attraction(); }; }, - snakeBoss(x, y, radius = 60) { //snake boss with a laser head + snakeBoss(x, y, radius = 50) { //snake boss with a laser head + const nodes = Math.min(8 + Math.ceil(0.5 * simulation.difficulty), 40) + let angle = Math.PI + let mag = 300 + const color1 = "#f27" - mobs.spawn(x, y, 8, radius, color1); //"rgb(55,170,170)" + mobs.spawn(x + mag * Math.cos(angle), y + mag * Math.sin(angle), 8, radius, color1); //"rgb(55,170,170)" let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; - me.accelMag = 0.00075 * simulation.accelScale; + me.accelMag = 0.00077 * simulation.accelScale; me.memory = 250; me.laserRange = 500; - Matter.Body.setDensity(me, 0.0016 + 0.0001 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger + Matter.Body.setDensity(me, 0.00165 + 0.00011 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger me.onDeath = function() { powerUps.spawnBossPowerUp(this.position.x, this.position.y) for (let i = 0; i < mob.length; i++) { //wake up tail mobs @@ -3626,17 +3663,23 @@ const spawn = { } } }; + me.damageReduction = 0.25 me.do = function() { - // this.seePlayerCheck(); + // this.armor(); this.seePlayerByHistory() this.checkStatus(); this.attraction(); this.harmZone(); }; - - //snake tail - const nodes = Math.min(8 + Math.ceil(0.5 * simulation.difficulty), 40) - spawn.lineGroup(x + 105, y, "snakeBody", nodes); + //extra space to give head room + angle -= 0.1 + mag -= 10 + for (let i = 0; i < nodes; ++i) { + angle -= 0.15 + i * 0.008 + mag -= 5 + spawn.snakeBody(x + mag * Math.cos(angle), y + mag * Math.sin(angle), 20); + } + this.constrain2AdjacentMobs(nodes, Math.random() * 0.06 + 0.01); for (let i = mob.length - 1, len = i - nodes; i > len; i--) { //set alternating colors if (i % 2) { @@ -3651,28 +3694,24 @@ const spawn = { bodyB: mob[mob.length - 1 - nodes], stiffness: 0.05 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); consBB[consBB.length] = Constraint.create({ bodyA: mob[mob.length - nodes + 1], bodyB: mob[mob.length - 1 - nodes], stiffness: 0.05 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); consBB[consBB.length] = Constraint.create({ bodyA: mob[mob.length - nodes + 2], bodyB: mob[mob.length - 1 - nodes], stiffness: 0.05 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); // spawn.shield(me, x, y, 1); }, snakeBody(x, y, radius = 10) { mobs.spawn(x, y, 8, radius, "rgba(0,180,180,0.4)"); let me = mob[mob.length - 1]; - // me.onHit = function() { - // //run this function on hitting player - // this.explode(); - // }; me.collisionFilter.mask = cat.bullet | cat.player | cat.mob //| cat.body me.accelMag = 0.0004 * simulation.accelScale; me.leaveBody = false; @@ -3681,7 +3720,6 @@ const spawn = { me.frictionAir = 0.02; me.isSnakeTail = true; me.stroke = "transparent" - me.onDeath = function() { if (this.isSnakeTail) { //wake up tail mobs for (let i = 0; i < mob.length; i++) { @@ -3708,7 +3746,7 @@ const spawn = { mobs.spawn(x, y, 8, radius, "rgb(0,60,80)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; + me.g = 0.0001; //required if using 'gravity' me.accelMag = 0.002 * simulation.accelScale; me.memory = 20; @@ -3722,7 +3760,7 @@ const spawn = { bodyB: me, stiffness: 0.00012 }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); spawn.shield(me, x, y, 1); setTimeout(() => { spawn.spawnOrbitals(me, radius + 50 + 200 * Math.random()) }, 100); //have to wait a sec so the tether constraint doesn't attach to an orbital @@ -3730,7 +3768,9 @@ const spawn = { powerUps.spawnBossPowerUp(this.position.x, this.position.y) this.removeCons(); //remove constraint }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.gravity(); this.seePlayerCheck(); this.checkStatus(); @@ -3754,7 +3794,7 @@ const spawn = { stiffness: 0.4, damping: 0.1 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); me.onDamage = function() { //make sure the mob that owns the shield can tell when damage is done @@ -3804,7 +3844,7 @@ const spawn = { stiffness: stiffness, damping: 0.1 }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); } me.onDamage = function() { this.alertNearByMobs(); //makes sure the mob that owns the shield can tell when damage is done @@ -3884,25 +3924,25 @@ const spawn = { mobs.spawn(x, y, nodes, radius, "rgb(255,0,150)"); let me = mob[mob.length - 1]; me.isBoss = true; - me.damageReduction = 0.25; - Matter.Body.setDensity(me, 0.002 + 0.00015 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger + + Matter.Body.setDensity(me, 0.002 + 0.00025 * Math.sqrt(simulation.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger me.stroke = "transparent"; //used for drawGhost me.seeAtDistance2 = 2000000; me.memory = Infinity; me.frictionAir = 0.02; - me.accelMag = 0.00014 * Math.sqrt(simulation.accelScale) + me.accelMag = 0.00015 * Math.sqrt(simulation.accelScale) me.collisionFilter.mask = cat.player | cat.bullet //| cat.body spawn.shield(me, x, y, 1); const rangeInnerVsOuter = Math.random() - let speed = (0.003 + 0.0015 * Math.sqrt(simulation.difficulty)) * ((Math.random() < 0.5) ? 1 : -1) - let range = radius + 150 + 200 * rangeInnerVsOuter + nodes * 5 + let speed = (0.009 + 0.0011 * Math.sqrt(simulation.difficulty)) * ((Math.random() < 0.5) ? 1 : -1) + let range = radius + 400 + 200 * rangeInnerVsOuter + nodes * 7 for (let i = 0; i < nodes; i++) spawn.orbital(me, range, i / nodes * 2 * Math.PI, speed) const orbitalIndexes = [] //find indexes for all the current nodes for (let i = 0; i < nodes; i++) orbitalIndexes.push(mob.length - 1 - i) // add orbitals for each orbital - range = Math.max(60, 150 - nodes * 3 - rangeInnerVsOuter * 80) + range = Math.max(60, 100 + 100 * Math.random() - nodes * 3 - rangeInnerVsOuter * 80) speed = speed * (1.25 + 2 * Math.random()) const subNodes = Math.max(2, Math.floor(6 - 5 * nodeBalance + 0.5 * Math.sqrt(simulation.difficulty))) for (let j = 0; j < nodes; j++) { @@ -3911,7 +3951,9 @@ const spawn = { me.onDeath = function() { powerUps.spawnBossPowerUp(this.position.x, this.position.y) }; + me.damageReduction = 0.25 me.do = function() { + // this.armor(); this.seePlayerCheckByDistance(); this.checkStatus(); this.attraction(); @@ -3988,7 +4030,7 @@ const spawn = { bodyB: mob[mob.length - j], stiffness: stiffness }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); } } }, @@ -4000,7 +4042,7 @@ const spawn = { bodyB: mob[mob.length - i - 2], stiffness: stiffness }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); } if (nodes > 2) { for (let i = 0; i < nodes - 2; ++i) { @@ -4009,7 +4051,7 @@ const spawn = { bodyB: mob[mob.length - i - 3], stiffness: stiffness }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); } } //optional connect the tail to head @@ -4019,19 +4061,19 @@ const spawn = { bodyB: mob[mob.length - nodes], stiffness: stiffness }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); consBB[consBB.length] = Constraint.create({ bodyA: mob[mob.length - 2], bodyB: mob[mob.length - nodes], stiffness: stiffness }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); consBB[consBB.length] = Constraint.create({ bodyA: mob[mob.length - 1], bodyB: mob[mob.length - nodes + 1], stiffness: stiffness }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); } }, constraintPB(x, y, bodyIndex, stiffness) { @@ -4043,7 +4085,7 @@ const spawn = { bodyB: body[bodyIndex], stiffness: stiffness }); - World.add(engine.world, cons[cons.length - 1]); + Composite.add(engine.world, cons[cons.length - 1]); }, constraintBB(bodyIndexA, bodyIndexB, stiffness) { consBB[consBB.length] = Constraint.create({ @@ -4051,7 +4093,7 @@ const spawn = { bodyB: body[bodyIndexB], stiffness: stiffness }); - World.add(engine.world, consBB[consBB.length - 1]); + Composite.add(engine.world, consBB[consBB.length - 1]); }, // body and map spawns ****************************************************************************** //********************************************************************************************** diff --git a/js/tech.js b/js/tech.js index 5ca50b0..73ab11d 100644 --- a/js/tech.js +++ b/js/tech.js @@ -157,8 +157,10 @@ for (i = 0, len = b.inventory.length; i < len; i++) { if (b.guns[b.inventory[i]].name === name) return true } + return false + } else { + return b.inventory.length > 0 && b.guns[b.activeGun].name === name } - return b.inventory.length > 0 && b.guns[b.activeGun].name === name }, damageFromTech() { let dmg = 1 //m.fieldDamage @@ -178,9 +180,9 @@ if (tech.isEnergyLoss) dmg *= 1.55; if (tech.isAcidDmg && m.health > 1) dmg *= 1.35; if (tech.restDamage > 1 && player.speed < 1) dmg *= tech.restDamage - if (tech.isEnergyDamage) dmg *= 1 + m.energy / 9; + if (tech.isEnergyDamage) dmg *= 1 + m.energy / 11; if (tech.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005 - if (tech.isRerollDamage) dmg *= 1 + 0.04 * powerUps.research.count + if (tech.isRerollDamage) dmg *= 1 + 0.037 * powerUps.research.count if (tech.isOneGun && b.inventory.length < 2) dmg *= 1.23 if (tech.isNoFireDamage && m.cycle > m.fireCDcycle + 120) dmg *= 2 if (tech.isSpeedDamage) dmg *= 1 + Math.min(0.66, player.speed * 0.0165) @@ -193,15 +195,21 @@ maxDuplicationEvent() { if (tech.is100Duplicate && tech.duplicationChance() > 0.99) { tech.is100Duplicate = false - const range = 450 - spawn.randomLevelBoss(m.pos.x + range, m.pos.y, spawn.nonCollideBossList); - spawn.randomLevelBoss(m.pos.x, m.pos.y + range, spawn.nonCollideBossList); - spawn.randomLevelBoss(m.pos.x - range, m.pos.y, spawn.nonCollideBossList); - spawn.randomLevelBoss(m.pos.x, m.pos.y - range, spawn.nonCollideBossList); - spawn.randomLevelBoss(m.pos.x + range, m.pos.y + range, spawn.nonCollideBossList); - spawn.randomLevelBoss(m.pos.x + range, m.pos.y - range, spawn.nonCollideBossList); - spawn.randomLevelBoss(m.pos.x - range, m.pos.y + range, spawn.nonCollideBossList); - spawn.randomLevelBoss(m.pos.x - range, m.pos.y - range, spawn.nonCollideBossList); + + const range = 550 + for (let i = 0, len = 8; i < len; i++) { + const angle = 2 * Math.PI * i / len + spawn.randomLevelBoss(m.pos.x + range * Math.cos(angle), m.pos.y + range * Math.sin(angle), spawn.nonCollideBossList); + } + + // spawn.randomLevelBoss(m.pos.x + range, m.pos.y, spawn.nonCollideBossList); + // spawn.randomLevelBoss(m.pos.x, m.pos.y + range, spawn.nonCollideBossList); + // spawn.randomLevelBoss(m.pos.x - range, m.pos.y, spawn.nonCollideBossList); + // spawn.randomLevelBoss(m.pos.x, m.pos.y - range, spawn.nonCollideBossList); + // spawn.randomLevelBoss(m.pos.x + range, m.pos.y + range, spawn.nonCollideBossList); + // spawn.randomLevelBoss(m.pos.x + range, m.pos.y - range, spawn.nonCollideBossList); + // spawn.randomLevelBoss(m.pos.x - range, m.pos.y + range, spawn.nonCollideBossList); + // spawn.randomLevelBoss(m.pos.x - range, m.pos.y - range, spawn.nonCollideBossList); } }, setTechFrequency(name, frequency) { @@ -1409,16 +1417,16 @@ }, { name: "bot fabrication", - description: "anytime you collect 3 research
use them to build a random bot", + description: "anytime you collect 4 research
use them to build a random bot", maxCount: 1, count: 0, frequency: 2, frequencyDefault: 2, isBotTech: true, allowed() { - return powerUps.research.count > 2 || build.isExperimentSelection + return powerUps.research.count > 3 || build.isExperimentSelection }, - requires: "at least 3 research", + requires: "at least 4 research", effect() { tech.isRerollBots = true; powerUps.research.changeRerolls(0) @@ -2259,7 +2267,7 @@ }, { name: "electrolytes", - description: "increase damage by 1%
for every 9 stored energy", + description: "increase damage by 1%
for every 11 stored energy", maxCount: 1, count: 0, frequency: 2, @@ -2757,27 +2765,9 @@ tech.isImmortal = false; } }, - { - name: "many-worlds", - description: "each level is an alternate reality, where you
find a tech at the start of each level", - maxCount: 1, - count: 0, - frequency: 1, - frequencyDefault: 1, - allowed() { - return !tech.isResearchReality && !tech.isCollisionRealitySwitch - }, - requires: "not Ψ(t) collapse, non-unitary", - effect() { - tech.isSwitchReality = true; - }, - remove() { - tech.isSwitchReality = false; - } - }, { name: "non-unitary operator", - description: "reduce combat difficulty by 2 levels
after a collision enter an alternate reality", + description: "reduce combat difficulty by 2 levels, but
after a collision enter an alternate reality", maxCount: 1, count: 0, frequency: 1, @@ -2797,6 +2787,25 @@ } } }, + { + name: "many-worlds", + // description: "each level is an alternate reality, where you
find a tech at the start of each level", + description: "on each new level use 1 research to enter an
alternate reality and spawn a tech power up", + maxCount: 1, + count: 0, + frequency: 1, + frequencyDefault: 1, + allowed() { + return !tech.isResearchReality && !tech.isCollisionRealitySwitch + }, + requires: "not Ψ(t) collapse, non-unitary", + effect() { + tech.isSwitchReality = true; + }, + remove() { + tech.isSwitchReality = false; + } + }, { name: "Ψ(t) collapse", description: "enter an alternate reality after you research
spawn 16 research", @@ -2818,7 +2827,7 @@ }, { name: "decoherence", - description: "researched or canceled tech won't reoccur
spawn 5 research", + description: "researched or canceled tech won't reoccur
spawn 9 research", maxCount: 1, count: 0, frequency: 2, @@ -2829,7 +2838,7 @@ requires: "not determinism, at least 3 research", effect() { tech.isBanish = true - for (let i = 0; i < 5; i++) powerUps.spawn(m.pos.x + 60 * (Math.random() - 0.5), m.pos.y + 60 * (Math.random() - 0.5), "research", false); + for (let i = 0; i < 9; i++) powerUps.spawn(m.pos.x + 60 * (Math.random() - 0.5), m.pos.y + 60 * (Math.random() - 0.5), "research", false); }, remove() { tech.isBanish = false @@ -2896,7 +2905,7 @@ }, { name: "Bayesian statistics", - description: "increase damage by 4%
for each research in your inventory", + description: "increase damage by 3.7%
for each research in your inventory", maxCount: 1, count: 0, frequency: 2, @@ -2945,7 +2954,7 @@ requires: "more than 6 tech", effect: () => { //remove active bullets //to get rid of bots - for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); + for (let i = 0; i < bullet.length; ++i) Matter.Composite.remove(engine.world, bullet[i]); bullet = []; let count = 1 //count tech for (let i = 0, len = tech.tech.length; i < len; i++) { // spawn new tech power ups @@ -3409,7 +3418,7 @@ }, { name: "dark patterns", - description: "reduce combat difficulty by 1 level
+21 JUNK to the potential tech pool", + description: "reduce combat difficulty by 1 level
+31 JUNK to the potential tech pool", maxCount: 1, count: 0, frequency: 1, @@ -3427,7 +3436,7 @@ }, remove() { if (this.count > 0) { - tech.removeJunkTechFromPool(21) + tech.removeJunkTechFromPool(31) level.difficultyIncrease(simulation.difficultyMode) } } @@ -4444,7 +4453,7 @@ }, { name: "booby trap", - description: "drop a mine after picking up a power up
+13 JUNK to the potential tech pool", + description: "drop a mine after picking up a power up
+23 JUNK to the potential tech pool", maxCount: 1, count: 0, frequency: 2, @@ -4456,7 +4465,7 @@ effect() { tech.isMineDrop = true; if (tech.isMineDrop) b.mine(m.pos, { x: 0, y: 0 }, 0, tech.isMineAmmoBack) - tech.addJunkTechToPool(13) + tech.addJunkTechToPool(23) }, remove() { tech.isMineDrop = false; @@ -5954,7 +5963,7 @@ }, { name: "virtual particles", - description: "use 3 research to exploit your wormhole for a
19% chance to duplicate spawned power ups", + description: "use 3 research to exploit your wormhole for a
17% chance to duplicate spawned power ups", isFieldTech: true, maxCount: 1, count: 0, @@ -5965,7 +5974,7 @@ }, requires: "wormhole,below 100% duplication chance", effect() { - tech.wormDuplicate = 0.19 + tech.wormDuplicate = 0.17 powerUps.setDo(); //needed after adjusting duplication chance for (let i = 0; i < 3; i++) { if (powerUps.research.count > 0) powerUps.research.changeRerolls(-1) @@ -6940,7 +6949,7 @@ body[index].collisionFilter.category = cat.body; body[index].collisionFilter.mask = cat.player | cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet body[index].classType = "body"; - World.add(engine.world, body[index]); //add to world + Composite.add(engine.world, body[index]); //add to world }, i * 100); } diff --git a/todo.txt b/todo.txt index c6ba1c9..fa3ffa2 100644 --- a/todo.txt +++ b/todo.txt @@ -1,19 +1,57 @@ ******************************************************** NEXT PATCH ******************************************************** -tech: chain reaction now requires vacuum bomb, but it increases grenade radius and damage 33% - (and makes blocks explode) +Matter.World has been replaced with Matter.Composite + matter.js deprecated World + could cause problems merging your old code + (replace World with Composite in your code) -needle gun fires with more regular timing -needles despawn 1.5s faster, for performance reasons -intro level power ups are relocated -tech: decomposers renamed necrophage -if mobs are one shotted before they see you, they no longer alert nearby mobs -clicking on a mob in testing will log that mob in console +tech: many worlds - now costs 1 research at the start of each level to activate + a nerf, but also a buff because if you like a build you can freeze it by not getting research + +mine gun has 25% less ammo and 33% more damage + +railgun now gets 50% more ammo, but it fires slower +fixed rail gun ammo drain on misfire bug + +fixed experiment gun display bug ******************************************************** TODO ******************************************************** +dark mode + build color pallets in a photo editor by redrawing in game screenshots + what about just starting with setting the background to be a dark grey? + const color = { + map: + blocks: + background: + shadows: (0,0,0,0.1)? + bullets: + mob: + heal powerUps: + tech powerUps: + field powerUps: + gun powerUps: + damage circle: + harm circle: + } + +re-word the "reduce difficulty" text, so it's more clear what you get + +tech: Standing Wave: Shockwave. Use FIELD button to shrink your shield and charge up, release to unleash a Shockwave. + +make an area that prevents mob vision, like a bush you can hide in + a static block with non collide on most things? + +it would be helpful if there was a mechanism to recover mobs that fly off the map + add a ceiling system and a left/right walls system similar to the floor checks but only for mobs +make non moving bosses not move after getting hit + shooter, shielding, + buff missiles? maybe they can release grenades after they explode, like CPT grenades? + make the crouch rapid fire a tech, and make the missiles fire faster, and use less ammo? +buff railgun +buff mines make the player get a buff after using wormhole while energy lasts: drain energy and give damage buff @@ -193,9 +231,25 @@ n-gon outreach ideas ******************************************************** BUGS ******************************************************** +map elements from labs not getting removed from matter.js, but they are removed from map[] + seems to always be the top right room near the center. why??? + these 1-2 elements are probalby the last elements added to the engine + floor in labs loot room, showed up on warehouse map once, invisible + button floor and shelf that drops blocks from labs showed up invisible on next levels + 2 thin floors in loot room, rectangles + 2 of the 5 elements were not rectangles + is labs too big? + add a delay for loading maps? + +Matter.World module has now been replaced by Matter.Composite (is this a possible fix?) + // for (let i = 0; i < array.length; ++i) Matter.World.remove(engine.world, array[i]); + for (let i = 0; i < array.length; ++i) Matter.Composite.remove(engine.world, array[i]); + + sharing builds as html doesn't work for long lists... it shouldn't be sharing undefined at all probably some other problems too + (might be fixed...) blocks on buttons teleport into the button endlessly if they are being slowly floated away maybe add a cooldown? @@ -203,7 +257,7 @@ blocks on buttons teleport into the button endlessly if they are being slowly fl ants marching outline doesn't sync right on safari anymore. -door to exit in vats does nothing +door to exit in level: vats does nothing did I do that? death while in power up selection menu doesn't reset properly