diff --git a/js/bullets.js b/js/bullets.js index f3103c4..4ab5d2c 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -16,7 +16,8 @@ const b = { modSpores: null, isModImmuneExplosion: null, isModDroneOnDamage: null, - modExtraDmg: null, + modAcidDmg: null, + isModAcidDmg: null, annihilation: null, modRecursiveHealing: null, modSquirrelFx: null, @@ -45,7 +46,8 @@ const b = { b.isModBulletsLastLonger = 1; b.isModImmortal = false; b.modSpores = 0; - b.modExtraDmg = 0; + b.modAcidDmg = 0; + b.isModAcidDmg = false; game.playerDmgColor = "rgba(0,0,0,0.7)" b.isModAnnihilation = false; b.modRecursiveHealing = 1; @@ -70,6 +72,15 @@ const b = { b.mods[i].count = 0 } }, + acidModSetCheck() { + if (mech.health > 0.9) { + game.playerDmgColor = "rgba(0,80,80,0.9)" + b.isModAcidDmg = true; + } else { + game.playerDmgColor = "rgba(0,0,0,0.7)" + b.isModAcidDmg = false; + } + }, mods: [{ name: "depleted uranium rounds", //0 description: `your bullets are +13% larger
increased mass and physical damage`, @@ -81,12 +92,12 @@ const b = { }, { name: "fluoroantimonic acid", //1 - description: "each bullet does extra chemical damage
instant damage, unaffected by momentum", - maxCount: 9, + description: "each bullet does extra chemical damage
only active when you are above 90% health", + maxCount: 1, count: 0, effect() { - b.modExtraDmg += 0.3 - game.playerDmgColor = "rgba(0,80,80,0.9)" + b.modAcidDmg = 0.9 + b.acidModSetCheck(); } }, { @@ -608,100 +619,6 @@ const b = { } } }, - explode(me) { - // typically explode is used for some bullets with .onEnd - let radius = bullet[me].explodeRad * b.modExplosionRadius - //add dmg to draw queue - game.drawList.push({ - x: bullet[me].position.x, - y: bullet[me].position.y, - radius: radius, - color: "rgba(255,25,0,0.6)", - time: game.drawTime - }); - let dist, sub, knock; - let dmg = b.dmgScale * radius * 0.009; - - const alertRange = 100 + radius * 2; //alert range - //add alert to draw queue - game.drawList.push({ - x: bullet[me].position.x, - y: bullet[me].position.y, - radius: alertRange, - color: "rgba(100,20,0,0.03)", - time: game.drawTime - }); - - //player damage and knock back - sub = Vector.sub(bullet[me].position, player.position); - dist = Vector.magnitude(sub); - if (dist < radius) { - if (!b.isModImmuneExplosion) mech.damage(radius * 0.0002); - knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 30); - player.force.x += knock.x; - player.force.y += knock.y; - mech.drop(); - } else if (dist < alertRange) { - knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 55); - player.force.x += knock.x; - player.force.y += knock.y; - mech.drop(); - } - - //body knock backs - for (let i = 0, len = body.length; i < len; ++i) { - sub = Vector.sub(bullet[me].position, body[i].position); - dist = Vector.magnitude(sub); - if (dist < radius) { - knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * body[i].mass) / 18); - body[i].force.x += knock.x; - body[i].force.y += knock.y; - } else if (dist < alertRange) { - knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * body[i].mass) / 40); - body[i].force.x += knock.x; - body[i].force.y += knock.y; - } - } - - //power up knock backs - for (let i = 0, len = powerUp.length; i < len; ++i) { - sub = Vector.sub(bullet[me].position, powerUp[i].position); - dist = Vector.magnitude(sub); - if (dist < radius) { - knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * powerUp[i].mass) / 30); - powerUp[i].force.x += knock.x; - powerUp[i].force.y += knock.y; - } else if (dist < alertRange) { - knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * powerUp[i].mass) / 45); - powerUp[i].force.x += knock.x; - powerUp[i].force.y += knock.y; - } - } - - //mob damage and knock back with alert - let damageScale = 1.5; // reduce dmg for each new target to limit total AOE damage - for (let i = 0, len = mob.length; i < len; ++i) { - if (mob[i].alive && !mob[i].isShielded) { - sub = Vector.sub(bullet[me].position, mob[i].position); - dist = Vector.magnitude(sub) - mob[i].radius; - if (dist < radius) { - if (mob[i].shield) dmg *= 3 //balancing explosion dmg to shields - mob[i].damage(dmg * damageScale); - mob[i].locatePlayer(); - knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg * damageScale) * mob[i].mass) / 50); - mob[i].force.x += knock.x; - mob[i].force.y += knock.y; - radius *= 0.93 //reduced range for each additional explosion target - damageScale *= 0.8 //reduced damage for each additional explosion target - } else if (!mob[i].seePlayer.recall && dist < alertRange) { - mob[i].locatePlayer(); - knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg * damageScale) * mob[i].mass) / 80); - mob[i].force.x += knock.x; - mob[i].force.y += knock.y; - } - } - } - }, mine(where, velocity, angle = 0) { const bIndex = bullet.length; bullet[bIndex] = Bodies.rectangle(where.x, where.y, 45 * b.modBulletSize, 16 * b.modBulletSize, { @@ -1346,22 +1263,22 @@ const b = { name: "wave beam", //4 description: "emit a sine wave of oscillating particles
particles propagate through walls", ammo: 0, - ammoPack: 32, + ammoPack: 35, have: false, isStarterGun: true, fire() { const me = bullet.length; const dir = mech.angle - const SCALE = (mech.crouch ? 0.963 : 0.95) + 0.03 * Math.min(1, 0.5 * (b.isModBulletsLastLonger - 1)) + const SCALE = (mech.crouch ? 0.967 : 0.955) + 0.03 * Math.min(1, 0.5 * (b.isModBulletsLastLonger - 1)) const wiggleMag = ((mech.crouch) ? 0.004 : 0.005) * ((mech.flipLegs === 1) ? 1 : -1) bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 10, 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), + endCycle: game.cycle + Math.floor((mech.crouch ? 170 : 130) * b.isModBulletsLastLonger), inertia: Infinity, frictionAir: 0, minDmgSpeed: 0, - dmg: 0.3, //damage done in addition to the damage from momentum + dmg: 0.4, //damage done in addition to the damage from momentum classType: "bullet", collisionFilter: { category: cat.bullet, @@ -1418,7 +1335,9 @@ const b = { bullet[me].endCycle = game.cycle + Math.floor((280 + 40 * Math.random()) * b.isModBulletsLastLonger); bullet[me].explodeRad = 170 + 60 * Math.random(); bullet[me].lookFrequency = Math.floor(31 + Math.random() * 11); - bullet[me].onEnd = b.explode; //makes bullet do explosive damage at end + bullet[me].onEnd = function () { + b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end + } bullet[me].onDmg = function () { this.tryToLockOn(); // this.endCycle = 0; //bullet ends cycle after doing damage // also triggers explosion @@ -1524,7 +1443,9 @@ const b = { bullet[me].restitution = 0; bullet[me].friction = 1; bullet[me].explodeRad = (mech.crouch ? 85 : 60) + (Math.random() - 0.5) * 50; - bullet[me].onEnd = b.explode; + bullet[me].onEnd = function () { + b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end + } bullet[me].onDmg = function () { this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion }; @@ -1550,7 +1471,9 @@ const b = { bullet[me].endCycle = game.cycle + Math.floor(mech.crouch ? 120 : 80); bullet[me].restitution = 0.2; bullet[me].explodeRad = 275; - bullet[me].onEnd = b.explode; //makes bullet do explosive damage before despawn + bullet[me].onEnd = function () { + b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end + } bullet[me].minDmgSpeed = 1; bullet[me].onDmg = function () { this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion @@ -1578,7 +1501,9 @@ const b = { bullet[me].friction = 0.3; bullet[me].endCycle = Infinity bullet[me].explodeRad = 380 + Math.floor(Math.random() * 60); - bullet[me].onEnd = b.explode; //makes bullet do explosive damage before despawn + bullet[me].onEnd = function () { + b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end + } bullet[me].onDmg = function () { // this.endCycle = 0; //bullet ends cycle after doing damage //this triggers explosion }; @@ -1732,7 +1657,7 @@ const b = { name: "drones", //11 description: "deploy drones that crash into enemies
collisions reduce drone cycles by 1 second", ammo: 0, - ammoPack: 9, + ammoPack: 10, have: false, isStarterGun: true, fire() { @@ -1836,7 +1761,7 @@ const b = { }, { name: "rail gun", //13 - description: "electro-magnetically launch a dense rod
holding left mouse uses energy to charge ", + description: "use energy to launch a high-speed dense rod
hold left mouse to charge, release to fire", ammo: 0, ammoPack: 2, have: false, diff --git a/js/engine.js b/js/engine.js index 527af55..8e9bf0b 100644 --- a/js/engine.js +++ b/js/engine.js @@ -175,7 +175,7 @@ function collisionChecks(event) { //mob + bullet collisions if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) { // const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))); - let dmg = b.dmgScale * (obj.dmg + b.modExtraDmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))) + let dmg = b.dmgScale * (obj.dmg + b.modAcidDmg * b.isModAcidDmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))) if (b.isModCrit && !mob[k].seePlayer.recall && !mob[k].shield) dmg *= 5 mob[k].foundPlayer(); mob[k].damage(dmg); @@ -193,7 +193,7 @@ function collisionChecks(event) { if (obj.classType === "body" && obj.speed > 5) { const v = Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)); if (v > 8) { - let dmg = b.dmgScale * (b.modExtraDmg + v * Math.sqrt(obj.mass) * 0.07); + let dmg = b.dmgScale * (b.modAcidDmg * b.isModAcidDmg + v * Math.sqrt(obj.mass) * 0.07); mob[k].damage(dmg); if (mob[k].distanceToPlayer2() < 1000000) mob[k].foundPlayer(); game.drawList.push({ diff --git a/js/index.js b/js/index.js index 3550423..f2ed4b2 100644 --- a/js/index.js +++ b/js/index.js @@ -2,6 +2,11 @@ /* TODO: ******************************************* ***************************************************** +mod: do something when at full health + extra damage (seems too simple) + power up drop rate? (hard to see directly) + regenerate (if above 90% max health) + add mouse constraint in testing mode https://github.com/liabru/matter-js/blob/master/examples/events.js @@ -184,28 +189,28 @@ const build = { build.calculateCustomDifficulty() }, makeGrid() { - let text = - `
- - - start - - - - - reset - - -
-
-
- - + let text = ` +
+ + + start + + + + + reset + + +
+
+
+ +
` for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) { text += `
  ${mech.fieldUpgrades[i].name}
${mech.fieldUpgrades[i].description}
` diff --git a/js/level.js b/js/level.js index 49999be..6adbe6e 100644 --- a/js/level.js +++ b/js/level.js @@ -13,13 +13,13 @@ const level = { levelsCleared: 0, start() { if (level.levelsCleared === 0) { - // game.difficulty = 6; //for testing to simulate possible mobs spawns - // b.giveGuns(13) + level.difficultyIncrease(10) + b.giveGuns(0) // mech.setField(3) - // b.giveMod(6); + b.giveMod(1); - level.intro(); //starting level - // level.testingMap(); + // level.intro(); //starting level + level.testingMap(); // level.bosses(); // level.skyscrapers(); // level.aerie(); diff --git a/js/player.js b/js/player.js index d31a345..11547ca 100644 --- a/js/player.js +++ b/js/player.js @@ -437,6 +437,7 @@ const mech = { addHealth(heal) { mech.health += heal * game.healScale; if (mech.health > mech.maxHealth) mech.health = mech.maxHealth; + b.acidModSetCheck(); mech.displayHealth(); }, defaultFPSCycle: 0, //tracks when to return to normal fps @@ -453,6 +454,7 @@ const mech = { mech.death(); return; } + b.acidModSetCheck(); mech.displayHealth(); document.getElementById("dmg").style.transition = "opacity 0s"; document.getElementById("dmg").style.opacity = 0.1 + Math.min(0.6, dmg * 4); diff --git a/style.css b/style.css index 4c70aac..1cc3de3 100644 --- a/style.css +++ b/style.css @@ -16,6 +16,9 @@ canvas { select { font-size: 0.8em; + /* margin-bottom: -20px; */ + /* position: "relative"; + top: "-15px"; */ } #splash {