diff --git a/js/bullet.js b/js/bullet.js index a1516d0..af4fac3 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -378,7 +378,7 @@ const b = { if (collide.length > 0) { for (let i = 0; i < collide.length; i++) { if (collide[i].bodyA.collisionFilter.category === cat.map) { // || collide[i].bodyB.collisionFilter.category === cat.map) { - const angle = Matter.Vector.angle(collide[i].normal, { + const angle = Vector.angle(collide[i].normal, { x: 1, y: 0 }) @@ -726,14 +726,14 @@ const b = { let closeDist = Infinity; for (let i = 0, len = powerUp.length; i < len; ++i) { if ( - ((powerUp[i].name !== "field" && powerUp[i].name !== "heal") || (powerUp[i].name === "heal" && mech.health < 0.8)) && + ((powerUp[i].name !== "field" && powerUp[i].name !== "heal") || (powerUp[i].name === "heal" && mech.health < 0.9)) && Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 && Matter.Query.ray(body, this.position, powerUp[i].position).length === 0 ) { const TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position) const DIST = Vector.magnitude(TARGET_VECTOR); if (DIST < closeDist) { - if (DIST < 50) { //eat the power up if close enough + if (DIST < 60) { //eat the power up if close enough powerUp[i].effect(); Matter.World.remove(engine.world, powerUp[i]); powerUp.splice(i, 1); @@ -875,7 +875,7 @@ const b = { if (this.target.isShielded) { this.target.damage(b.dmgScale * 0.005, true); //shield damage bypass //shrink if mob is shielded - const SCALE = 1 - 0.025 / mod.isBulletsLastLonger + const SCALE = 1 - 0.016 / mod.isBulletsLastLonger Matter.Body.scale(this, SCALE, SCALE); this.radius *= SCALE; } else { @@ -886,14 +886,28 @@ const b = { this.collisionFilter.category = cat.bullet; this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield if (mod.isFoamGrowOnDeath) { - // const SCALE = (this.radius < 30) ? 2 : 1 //Math.min(5, Math.max(1, 20 / (this.radius * this.radius))) - // Matter.Body.scale(this, SCALE, SCALE); - // this.radius *= SCALE; - const radius = Math.min(this.radius / 2, 10) - b.foam(this.position, Matter.Vector.rotate(this.velocity, Math.PI * 2 / 3), radius) - b.foam(this.position, Matter.Vector.rotate(this.velocity, Math.PI * 1 / 3), radius) + 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) + for (let i = 0; i < 2; i++) { + if (targets.length - i > 0) { + const index = Math.floor(Math.random() * targets.length) + const speed = 10 + 10 * Math.random() + const velocity = Vector.mult(Vector.normalise(Vector.sub(targets[index].position, this.position)), speed) + b.foam(this.position, Vector.rotate(velocity, 0.5 * (Math.random() - 0.5)), radius) + } else { + b.foam(this.position, Vector.rotate({ + x: 15 + 10 * Math.random(), + y: 0 + }, 2 * Math.PI * Math.random()), radius) + } + } } - } } } @@ -1392,7 +1406,7 @@ const b = { function makeFlechette(angle = mech.angle + 0.02 * (Math.random() - 0.5)) { const me = bullet.length; bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 45, 1.4, b.fireAttributes(angle)); - bullet[me].collisionFilter.mask = cat.body; //cat.mobShield | //cat.map | cat.body | + bullet[me].collisionFilter.mask = mod.pierce ? 0 : cat.body; //cat.mobShield | //cat.map | cat.body | Matter.Body.setDensity(bullet[me], 0.00001); //0.001 is normal bullet[me].endCycle = game.cycle + 180; bullet[me].dmg = 0; @@ -2269,7 +2283,7 @@ const b = { if (who.shield) { for (let i = 0, len = mob.length; i < len; i++) { if (mob[i].id === who.shieldTargetID) { //apply some knock back to shield mob before shield breaks - Matter.Body.setVelocity(mob[i], Matter.Vector.mult(Matter.Vector.normalise(this.velocity), 10)); + Matter.Body.setVelocity(mob[i], Vector.mult(Vector.normalise(this.velocity), 10)); break } } diff --git a/js/level.js b/js/level.js index 2ca8244..36fa4ea 100644 --- a/js/level.js +++ b/js/level.js @@ -16,10 +16,10 @@ const level = { if (level.levelsCleared === 0) { //this code only runs on the first level // game.enableConstructMode() //used to build maps in testing mode // level.difficultyIncrease(9) - - mod.giveMod("automatic shotgun"); - // b.giveGuns("spores") - // mech.setField("plasma torch") + // mech.isStealth = true; + // mod.giveMod("necrophoresis"); + // b.giveGuns("foam") + // mech.setField("time dilation field") level.intro(); //starting level // level.testing(); diff --git a/js/mob.js b/js/mob.js index e7a9409..97be741 100644 --- a/js/mob.js +++ b/js/mob.js @@ -991,7 +991,7 @@ const mobs = { this.alive = false; //triggers mob removal in mob[i].replace(i) if (this.dropPowerUp) { if (mod.isEnergyLoss) mech.energy *= 0.66; - powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius); + powerUps.spawnRandomPowerUp(this.position.x, this.position.y); mech.lastKillCycle = mech.cycle; //tracks the last time a kill was made, mostly used in game.checks() if (Math.random() < mod.sporesOnDeath) { const len = Math.min(30, Math.floor(4 + this.mass * Math.random())) @@ -1011,6 +1011,17 @@ const mobs = { } if (mod.isExplodeMob) b.explosion(this.position, Math.min(450, Math.sqrt(this.mass + 3) * 80)) if (mod.nailsDeathMob) b.targetedNail(this.position, mod.nailsDeathMob) + } else if (mod.isShieldAmmo && this.shield) { + let type = "ammo" + if (Math.random() < 0.33 || mod.bayesian) { + type = "heal" + } else if (Math.random() < 0.5 && !mod.isSuperDeterminism) { + type = "reroll" + } + for (let i = 0; i < 3; i++) { + powerUps.spawn(this.position.x, this.position.y, type); + if (Math.random() < mod.bayesian) powerUps.spawn(this.position.x, this.position.y, type); + } } }, removeConsBB() { diff --git a/js/mods.js b/js/mods.js index 8896e66..bdcd1d8 100644 --- a/js/mods.js +++ b/js/mods.js @@ -785,6 +785,22 @@ const mod = { mod.isMassEnergy = false; } }, + { + name: "bubble fusion", + description: "after destroying a mob's shield
spawn 3 heals, ammo, or rerolls", + maxCount: 1, + count: 0, + allowed() { + return true + }, + requires: "", + effect() { + mod.isShieldAmmo = true; + }, + remove() { + mod.isShieldAmmo = false; + } + }, { name: "Bayesian inference", description: "40% chance for double power ups to drop
ammo will no longer spawn from mobs", @@ -1275,7 +1291,7 @@ const mod = { }, { name: "piercing needles", - description: "needles penetrate mobs
potentially hitting multiple targets", + description: "needles penetrate mobs and blocks
potentially hitting multiple targets", maxCount: 1, count: 0, allowed() { @@ -1634,7 +1650,7 @@ const mod = { }, { name: "necrophoresis", - description: "foam splits into 3 copies
when the mob it's stuck to dies", + description: "if the mob foam is stuck to dies
foam grows and splits into 3 copies", maxCount: 1, count: 0, allowed() { diff --git a/js/player.js b/js/player.js index 17dfe23..a4bce4a 100644 --- a/js/player.js +++ b/js/player.js @@ -1992,7 +1992,7 @@ const mech = { for (let i = 0, len = body.length; i < len; ++i) { if (Vector.magnitude(Vector.sub(body[i].position, mech.fieldPosition)) < mech.fieldRadius) { - const DRAIN = speed * body[i].mass * 0.000018 + const DRAIN = speed * body[i].mass * 0.000015 if (mech.energy > DRAIN) { mech.energy -= DRAIN; Matter.Body.setVelocity(body[i], velocity); //give block mouse velocity diff --git a/todo.txt b/todo.txt index 9b7d1e9..620e576 100644 --- a/todo.txt +++ b/todo.txt @@ -4,21 +4,21 @@ freezing status effects only last 1/4 as long on boss mobs mod - shotgun 66% increased fire rate and recoil mod - slowly heal when below 25% health mod - superdeterminism spawn 4 mods, but rerolls, fields, and guns no longer spawn +foam mod, necrophoresis now aims the foam bullets, which makes it more effective at groups +flechettes mod, piercing needles now goes through blocks as well as mobs +mod - spawn 3 ammo, rerolls, or heals after destroying a shield ************** TODO - n-gon ************** physics question: why don't the bound states of fields spread out. What is making them bound. -rework reaction inhibitor to spawn mobs with 12% less life, rather then killing them at 12% +mobs killed by _____ always drops ammo + issues getting the code to work -mod: all mobs have a shield (or just a higher rate) - all mobs drop an extra ammo power up? +rework reaction inhibitor to spawn mobs with 12% less life, rather then killing them at 12% levels: make a function in the main game loop that runs level specific code reset the level function as each new level loads -mod: foam grenades - or maybe all explosions make foam? - mod: use the stealth flag from the phase decoherence field maybe trigger it along with the damage immunity CD