From 320f0ef28ca1d665ae3f5e8dd07949729f5f21c9 Mon Sep 17 00:00:00 2001 From: landgreen Date: Fri, 13 Dec 2019 19:01:09 -0800 Subject: [PATCH] added chronon gun --- js/bullets.js | 356 ++++++++++++++++++++++++++++++------------------- js/engine.js | 2 +- js/level.js | 10 +- js/mobs.js | 6 +- js/player.js | 4 +- js/powerups.js | 4 +- js/spawn.js | 4 +- 7 files changed, 237 insertions(+), 149 deletions(-) diff --git a/js/bullets.js b/js/bullets.js index 56468b4..ea0e30a 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -18,7 +18,7 @@ const b = { isModDroneOnDamage: null, modExtraDmg: null, annihilation: null, - fullHeal: null, + isModFullHeal: null, modSquirrelFx: null, modIsCrit: null, modMoreDrops: null, @@ -53,6 +53,7 @@ const b = { mech.jumpForce = 0.38; mech.throwChargeRate = 2; mech.throwChargeMax = 50; + mech.maxHealth = 1; for (let i = 0; i < b.mods.length; i++) { b.mods[i].have = false; } @@ -67,87 +68,6 @@ const b = { b.modBulletSize = 1.1; } }, - { - name: "auto-loading heuristics", - description: "your delay after firing is 15% shorter", - have: false, //1 - effect: () => { //good for guns with extra ammo: needles, M80, rapid fire, flak, super balls - b.modFireRate = 0.85 - } - }, - { - name: "desublimated ammunition", - description: "use 50% less ammo when crouching", - have: false, //2 - effect: () => { //good with guns that have less ammo: one shot, grenades, missiles, super balls, spray - b.modNoAmmo = 1 - } - }, - { - name: "Lorentzian topology", - description: "your bullets last 40% longer", - have: false, //3 - effect: () => { //good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range) - b.isModBulletsLastLonger = 1.40 - } - }, - { - name: "anti-matter cores", - description: "the radius of your explosions is doubled
be careful", - have: false, //4 - effect: () => { //at 1.4 gives a flat 40% increase, and increased range, balanced by limited guns and self damage - //testing at 1.3: grenade(+0.3), missiles, flak, M80 - b.modExplosionRadius = 1.8; //good for guns with explosions - } - }, - { - name: "ceramic plating", - description: "protection from to high temperatures
5x less damage from explosions and lasers", - have: false, //5 - effect: () => { - b.isModTempResist = true; //good for guns with explosions - } - }, - { - name: "ablative synthesis", - description: "rebuild your broken parts as drones
chance to occur after taking damage", - have: false, //6 - effect: () => { //makes dangerous situations more survivable - b.isModDroneOnDamage = true; - } - }, - { - name: "zoospore vector", - description: "enemies can discharge spores on death
spores seek out enemies", - have: false, //7 - effect: () => { //good late game maybe? - b.modSpores = 0.20; - } - }, - { - name: "energy transfer", - description: "gain energy proportional to damage done", - have: false, //8 - effect: () => { //good with laser, and all fields - b.modEnergySiphon = 0.2; - } - }, - { - name: "entropy transfer", - description: "heal proportional to damage done", - have: false, //9 - effect: () => { //good with guns that overkill: one shot, grenade - b.modHealthDrain = 0.015; - } - }, - { - name: "quantum immortality", - description: "after dying, continue in an alternate reality
guns, ammo, and field are randomized", - have: false, //10 - effect: () => { - b.modIsImmortal = true; - } - }, { name: "fluoroantimonic acid", description: "each bullet does extra chemical damage
instant damage, unaffected by momentum", @@ -156,42 +76,6 @@ const b = { b.modExtraDmg = 0.1 } }, - { - name: "annihilation", - description: "after touching enemies, they are annihilated
doesn't trigger health or energy transfer", - have: false, //12 - effect: () => { //good with mods that heal: superconductive healing, entropy transfer - b.modAnnihilation = true - } - }, - { - name: "recursive healing", - description: "healing power ups bring you to full health", - have: false, //13 - effect: () => { // good with ablative synthesis, melee builds - b.isModFullHeal = true - } - }, - { - name: "Gauss rifle", - description: "launch blocks at much higher speeds
hold onto larger blocks even after getting hit", - have: false, //14 - effect: () => { // good with guns that run out of ammo - mech.throwChargeRate = 4; - mech.throwChargeMax = 150; - mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping - } - }, - { - name: "squirrel-cage rotor", - description: "jump higher and move faster
reduced falling damage", - have: false, //15 - effect: () => { // good with melee builds, content skipping builds - b.modSquirrelFx = 1.2; - mech.Fx = 0.015 * b.modSquirrelFx; - mech.jumpForce = 0.38 * 1.1; - } - }, { name: "fracture analysis", description: "5x physical damage to unaware enemies
unaware enemies don't have a health bar", @@ -216,6 +100,115 @@ const b = { b.isModLowHealthDmg = true; //used in mob.damage() } }, + { + name: "auto-loading heuristics", + description: "your delay after firing is 15% shorter", + have: false, //1 + effect: () => { //good for guns with extra ammo: needles, M80, rapid fire, flak, super balls + b.modFireRate = 0.85 + } + }, + { + name: "desublimated ammunition", + description: "use 50% less ammo when crouching", + have: false, //2 + effect: () => { //good with guns that have less ammo: one shot, grenades, missiles, super balls, spray + b.modNoAmmo = 1 + } + }, + { + name: "Lorentzian topology", + description: "your bullets last 40% longer", + have: false, //3 + effect: () => { //good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range) + b.isModBulletsLastLonger = 1.40 + } + }, + { + name: "zoospore vector", + description: "enemies can discharge spores on death
spores seek out enemies", + have: false, //7 + effect: () => { //good late game maybe? + b.modSpores = 0.20; + } + }, + { + name: "ablative synthesis", + description: "rebuild your broken parts as drones
chance to occur after taking damage", + have: false, //6 + effect: () => { //makes dangerous situations more survivable + b.isModDroneOnDamage = true; + } + }, + { + name: "annihilation", + description: "after touching enemies, they are annihilated
doesn't trigger health or energy transfer", + have: false, //12 + effect: () => { //good with mods that heal: superconductive healing, entropy transfer + b.modAnnihilation = true + } + }, + { + name: "anti-matter cores", + description: "the radius of your explosions is doubled
be careful", + have: false, //4 + effect: () => { //at 1.4 gives a flat 40% increase, and increased range, balanced by limited guns and self damage + //testing at 1.3: grenade(+0.3), missiles, flak, M80 + b.modExplosionRadius = 1.8; //good for guns with explosions + } + }, + { + name: "ceramic plating", + description: "protection from to high temperatures
5x less damage from explosions and lasers", + have: false, //5 + effect: () => { + b.isModTempResist = true; //good for guns with explosions + } + }, + { + name: "Gauss rifle", + description: "launch blocks at much higher speeds
hold onto larger blocks even after getting hit", + have: false, //14 + effect: () => { // good with guns that run out of ammo + mech.throwChargeRate = 4; + mech.throwChargeMax = 150; + mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping + } + }, + { + name: "squirrel-cage rotor", + description: "jump higher and move faster
reduced falling damage", + have: false, //15 + effect: () => { // good with melee builds, content skipping builds + b.modSquirrelFx = 1.2; + mech.Fx = 0.015 * b.modSquirrelFx; + mech.jumpForce = 0.38 * 1.1; + } + }, + { + name: "energy transfer", + description: "gain energy proportional to damage done", + have: false, //8 + effect: () => { //good with laser, and all fields + b.modEnergySiphon = 0.2; + } + }, + { + name: "entropy transfer", + description: "heal proportional to damage done", + have: false, //9 + effect: () => { //good with guns that overkill: one shot, grenade + b.modHealthDrain = 0.015; + } + }, + { + name: "entanglement", + description: "using your first gun reduces damage taken
scales by 7% for each gun in your inventory", + have: false, //20 + effect: () => { // good with laser-bots + b.isModMonogamy = true + } + }, { name: "Bayesian inference", description: "20% chance for double power ups to drop", @@ -224,22 +217,38 @@ const b = { b.modMoreDrops = 0.20; } }, - { - name: "entanglement", - description: "using your first gun reduces damage taken
scales by 7% for each gun in your inventory", - have: false, //20 - effect: () => { // good with long term planning - b.isModMonogamy = true - } - }, { name: "mass-energy equivalence", description: "change the mass of power ups into energy
power ups fill your energy and heal for +3%", have: false, //21 - effect: () => { // good with long term planning + effect: () => { b.isModMassEnergy = true // used in mech.usePowerUp } }, + { + name: "supersaturation", + description: "heal 25% beyond your max health", + have: false, //22 + effect: () => { + mech.maxHealth = 1.25 + } + }, + { + name: "recursive healing", + description: "healing power ups bring you to full health", + have: false, //13 + effect: () => { // good with ablative synthesis, melee builds + b.isModFullHeal = true + } + }, + { + name: "quantum immortality", + description: "after dying, continue in an alternate reality
guns, ammo, and field are randomized", + have: false, //10 + effect: () => { + b.modIsImmortal = true; + } + }, ], giveMod(i) { b.mods[i].effect(); //give specific mod @@ -970,7 +979,8 @@ const b = { this.force.y += this.mass * 0.0005; }; } - }, { + }, + { name: "wave beam", //3 description: "emit a sine wave of oscillating particles
particles propagate through walls", ammo: 0, @@ -979,11 +989,11 @@ const b = { isStarterGun: true, fire() { const me = bullet.length; - const DIR = mech.angle + const dir = mech.angle const SCALE = (mech.crouch ? 0.963 : 0.95) const wiggleMag = ((mech.flipLegs === 1) ? 1 : -1) * ((mech.crouch) ? 0.004 : 0.005) - bullet[me] = Bodies.circle(mech.pos.x + 25 * Math.cos(DIR), mech.pos.y + 25 * Math.sin(DIR), 10 * b.modBulletSize, { - angle: DIR, + bullet[me] = Bodies.circle(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 10 * b.modBulletSize, { + angle: dir, cycle: -0.43, //adjust this number until the bullets line up with the cross hairs endCycle: game.cycle + Math.floor((mech.crouch ? 155 : 120) * b.isModBulletsLastLonger), inertia: Infinity, @@ -1011,8 +1021,8 @@ const b = { mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 8 : 4) * b.modFireRate); // cool down const SPEED = mech.crouch ? 5.2 : 4.5; Matter.Body.setVelocity(bullet[me], { - x: SPEED * Math.cos(DIR), - y: SPEED * Math.sin(DIR) + x: SPEED * Math.cos(dir), + y: SPEED * Math.sin(dir) }); bullet[me].direction = Matter.Vector.perp(bullet[me].velocity) // if (mech.angle + Math.PI / 2 > 0) { @@ -1083,7 +1093,7 @@ const b = { name: "fléchettes", //6 description: "fire a flight of long range needles", ammo: 0, - ammoPack: 25, + ammoPack: 16, have: false, isStarterGun: true, fire() { @@ -1781,6 +1791,84 @@ const b = { b.drawOneBullet(bullet[me].vertices); } }, + { + name: "chronon", //15 + description: "fire a bubble of null time
enemies are frozen for 5 seconds", + ammo: 0, + ammoPack: 80, + have: false, + isStarterGun: true, + fire() { + const me = bullet.length; + const dir = mech.angle + const RADIUS = 23 + 45 * Math.random() + bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 0, RADIUS, { + density: 0.0001, // 0.1 normal density to keep damage consistent + frictionAir: 0, + restitution: 0.3, + angle: dir, + friction: 0, + frictionAir: 0, + dmg: 0.5 + b.modExtraDmg, //damage done in addition to the damage from momentum + classType: "bullet", + collisionFilter: { + category: 0x000100, + mask: 0x010011 //mask: 0x000101, //for self collision + }, + minDmgSpeed: 0, + endCycle: Infinity, //game.cycle + Math.floor(265 * b.isModBulletsLastLonger), + radius: RADIUS, + onDmg(who) { + this.endCycle = 0; //bullet ends cycle after doing damage // also triggers explosion + if (!who.isSleeping) { + const sleep = function (who) { + if (who) { + who.storeVelocity = who.velocity + who.storeAngularVelocity = who.angularVelocity + Matter.Sleeping.set(who, true) + } + }; + setTimeout(sleep, 1, who); + + const awake = function (who) { + if (who) { + Matter.Sleeping.set(who, false) + if (who.storeVelocity) { + Matter.Body.setVelocity(who, { + x: who.storeVelocity.x, + y: who.storeVelocity.y + }) + Matter.Body.setAngularVelocity(who, who.storeAngularVelocity) + } + } + }; + setTimeout(awake, 5000, who); + } + }, + onEnd() {}, + do() { + //shrink + const SCALE = 0.994 + Matter.Body.scale(this, SCALE, SCALE); + this.radius *= SCALE; + if (this.radius < 5) this.endCycle = 0; + + ctx.beginPath() + ctx.arc(this.position.x, this.position.y, this.radius - 2, 0, 2 * Math.PI); + ctx.fillStyle = "#fff" + ctx.fill() + } + }); + World.add(engine.world, bullet[me]); //add bullet to world + mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 13 : 7) * b.modFireRate); // cool down + const SPEED = mech.crouch ? 9 : 5; + Matter.Body.setVelocity(bullet[me], { + x: mech.Vx / 2 + SPEED * Math.cos(dir), + y: mech.Vy / 2 + SPEED * Math.sin(dir) + }); + bullet[me].direction = Matter.Vector.perp(bullet[me].velocity) + } + }, // { // name: "dwarf star", //14 // description: "drop a mine that gravitational pulls in matter", diff --git a/js/engine.js b/js/engine.js index 285480a..ffd1051 100644 --- a/js/engine.js +++ b/js/engine.js @@ -182,7 +182,7 @@ function mobCollisionChecks(event) { if (b.modIsCrit && !mob[k].seePlayer.recall) dmg *= 5 mob[k].foundPlayer(); mob[k].damage(dmg); - obj.onDmg(); //some bullets do actions when they hits things, like despawn + obj.onDmg(mob[k]); //some bullets do actions when they hits things, like despawn game.drawList.push({ //add dmg to draw queue x: pairs[i].activeContacts[0].vertex.x, diff --git a/js/level.js b/js/level.js index 186d1ad..0c01ee9 100644 --- a/js/level.js +++ b/js/level.js @@ -14,12 +14,12 @@ const level = { start() { if (level.levelsCleared === 0) { // game.difficulty = 6; //for testing to simulate possible mobs spawns - // b.giveGuns(14) - // mech.fieldUpgrades[7].effect(); + b.giveGuns(15) + mech.fieldUpgrades[1].effect(); // b.giveMod(2) - this.intro(); //starting level - // this.testingMap(); + // this.intro(); //starting level + this.testingMap(); // this.bosses(); // this.aerie(); // this.rooftops(); @@ -110,7 +110,7 @@ const level = { // powerUps.spawn(450, -400, "mod", false, 6); // powerUps.spawn(450, -400, "mod", false); // spawn.bodyRect(-45, -100, 40, 50); - spawn.spinner(800, -1150); + spawn.shooter(800, -1150); // spawn.groupBoss(-600, -550); // spawn.hopper(800, -150); // spawn.beamer(800, -150); diff --git a/js/mobs.js b/js/mobs.js index 309a52a..ac473b0 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -696,7 +696,7 @@ const mobs = { // } }, grow() { - if (!mech.isBodiesAsleep) { + if (!this.isSleeping) { if (this.seePlayer.recall) { if (this.radius < 80) { const scale = 1.01; @@ -830,7 +830,7 @@ const mobs = { } }, fire() { - if (!mech.isBodiesAsleep) { + if (!this.isSleeping) { const setNoseShape = () => { const mag = this.radius + this.radius * this.noseLength; this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag; @@ -906,7 +906,7 @@ const mobs = { this.death(); //death with no power up or body }, timeLimit() { - if (!mech.isBodiesAsleep) { + if (!this.isSleeping) { this.timeLeft--; if (this.timeLeft < 0) { this.dropPowerUp = false; diff --git a/js/player.js b/js/player.js index ebf6d73..6488d75 100644 --- a/js/player.js +++ b/js/player.js @@ -406,6 +406,7 @@ const mech = { } }, health: 0, + maxHealth: 1, drawHealth() { if (this.health < 1) { ctx.fillStyle = "rgba(100, 100, 100, 0.5)"; @@ -431,7 +432,7 @@ const mech = { }, addHealth(heal) { this.health += heal; - if (this.health > 1 || b.isModFullHeal) this.health = 1; + if (this.health > mech.maxHealth) this.health = mech.maxHealth; this.displayHealth(); }, defaultFPSCycle: 0, //tracks when to return to normal fps @@ -882,7 +883,6 @@ const mech = { //knock backs const unit = Matter.Vector.normalise(Matter.Vector.sub(player.position, who.position)) const mass = Math.min(Math.sqrt(who.mass), 3.5); //large masses above 4*4 can start to overcome the push back - console.log(Math.sqrt(who.mass), mass) Matter.Body.setVelocity(who, { x: player.velocity.x - (15 * unit.x) / mass, y: player.velocity.y - (15 * unit.y) / mass diff --git a/js/powerups.js b/js/powerups.js index d3cbed4..ff7b6b0 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -9,8 +9,8 @@ const powerUps = { }, effect() { let heal = (this.size / 40) ** 2 - if (b.fullHeal) heal = Infinity - heal = Math.min(1 - mech.health, heal) + heal = Math.min(mech.maxHealth - mech.health, heal) + if (b.isModFullHeal) heal = mech.maxHealth mech.addHealth(heal); if (heal > 0) game.makeTextLog("
  heal " + (heal * 100).toFixed(0) + "%", 300) } diff --git a/js/spawn.js b/js/spawn.js index 30fc235..a9ea235 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -600,7 +600,7 @@ const spawn = { // if (Math.random() < Math.min(0.2 + game.difficulty * 0.1, 0.7)) spawn.shield(me, x, y); me.do = function () { this.healthBar(); - if (!mech.isBodiesAsleep) { + if (!this.isSleeping) { this.seePlayerByLookingAt(); const dist2 = this.distanceToPlayer2(); //laser Tracking @@ -703,7 +703,7 @@ const spawn = { this.attraction(); this.gravity(); //draw - if (!mech.isBodiesAsleep) { + if (!this.isSleeping) { if (this.seePlayer.yes) { if (this.alpha < 1) this.alpha += 0.01; } else {