diff --git a/js/bullets.js b/js/bullets.js index 02dfb5d..b5bebae 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -47,6 +47,9 @@ const b = { isModEnergyRecovery: null, isModHealthRecovery: null, isModEnergyLoss: null, + isModFoamShieldHit: null, + isModDeathAvoid: null, + isModDeathAvoidOnCD: null, modOnHealthChange() { //used with acid mod if (b.isModAcidDmg && mech.health > 0.8) { game.playerDmgColor = "rgba(0,80,80,0.9)" @@ -357,22 +360,6 @@ const b = { mech.fieldRange = 175; } }, - { - name: "entanglement", - description: "only when your first gun is equipped
reduce harm by 10% for each gun you have", - maxCount: 1, - count: 0, - allowed() { - return true - }, - requires: "", - effect() { - b.isModEntanglement = true - }, - remove() { - b.isModEntanglement = false; - } - }, { name: "waste energy recovery", description: "regen 7% of max energy every second
active for 5 seconds after a mob dies", @@ -457,6 +444,22 @@ const b = { b.isModStomp = false; } }, + { + name: "entanglement", + description: "only when your first gun is equipped
reduce harm by 10% for each gun you have", + maxCount: 1, + count: 0, + allowed() { + return true + }, + requires: "", + effect() { + b.isModEntanglement = true + }, + remove() { + b.isModEntanglement = false; + } + }, { name: "Pauli exclusion", description: `unable to collide with enemies for +2 seconds
activates after being harmed from a collision`, @@ -490,6 +493,40 @@ const b = { b.isModAnnihilation = false; } }, + { + name: "quantum immortality", + description: "after dying, continue in an alternate reality
guns, ammo, field, and mods are randomized", + maxCount: 1, + count: 0, + allowed() { + return true + }, + requires: "", + effect() { + b.isModImmortal = true; + }, + remove() { + b.isModImmortal = false; + } + }, + { + name: "weak anthropic principle", + description: "avoid harm that should be fatal
can occur once every 3 seconds", + maxCount: 1, + count: 0, + allowed() { + return b.isModImmortal + }, + requires: "quantum immortality", + effect() { + b.isModDeathAvoid = true; + b.isModDeathAvoidOnCD = false; + }, + remove() { + b.isModDeathAvoid = false; + b.isModDeathAvoidOnCD = false; + } + }, { name: "piezoelectricity", description: "colliding with enemies charges your energy", @@ -576,7 +613,7 @@ const b = { }, { name: "recursive healing", - description: "healing power ups trigger one extra time.", + description: "healing power ups trigger one extra time", maxCount: 9, count: 0, allowed() { @@ -607,22 +644,6 @@ const b = { b.isModMassEnergy = false; } }, - { - name: "quantum immortality", - description: "after dying, continue in an alternate reality
guns, ammo, field, and mods are randomized", - maxCount: 1, - count: 0, - allowed() { - return true - }, - requires: "", - effect() { - b.isModImmortal = true; - }, - remove() { - b.isModImmortal = false; - } - }, { name: "Bayesian inference", description: "20% chance for double power ups to drop
one fewer choice when selecting power ups", @@ -805,6 +826,22 @@ const b = { } } }, + { + name: "foam stabilization", + description: "foam can stick to shields", + maxCount: 1, + count: 0, + allowed() { + return b.haveGunCheck("foam") + }, + requires: "foam", + effect() { + b.isModFoamShieldHit = true; + }, + remove() { + b.isModFoamShieldHit = false; + } + }, // { // name: "super mines", // description: "mines fire super balls when triggered", @@ -1705,11 +1742,11 @@ const b = { num: 5, isStarterGun: true, fire() { - mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 30 : 20) * b.modFireRate); // cool down + mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 25 : 20) * b.modFireRate); // cool down b.muzzleFlash(20); // mobs.alert(450); const SPEED = mech.crouch ? 40 : 30 - const SPREAD = mech.crouch ? 0.04 : 0.15 + const SPREAD = mech.crouch ? 0.08 : 0.15 let dir = mech.angle - SPREAD * (b.modSuperBallNumber - 1) / 2; for (let i = 0; i < b.modSuperBallNumber; i++) { const me = bullet.length; @@ -2215,7 +2252,7 @@ const b = { target: null, targetVertex: null, onDmg(who) { - if (!this.target && who.alive && who.dropPowerUp && !who.isShielded) { + if (!this.target && who.alive && (who.dropPowerUp || b.isModFoamShieldHit) && (!who.isShielded || b.isModFoamShieldHit)) { this.target = who; this.collisionFilter.category = cat.body; this.collisionFilter.mask = null; @@ -2260,7 +2297,12 @@ const b = { Matter.Body.setPosition(this, this.target.vertices[this.targetVertex]) Matter.Body.setVelocity(this.target, Vector.mult(this.target.velocity, 0.9)) Matter.Body.setAngularVelocity(this.target, this.target.angularVelocity * 0.9) - this.target.damage(b.dmgScale * 0.005); + if (this.target.isShielded) { + this.target.damage(b.dmgScale * 0.001); + } else { + this.target.damage(b.dmgScale * 0.005); + } + } else if (this.target !== null) { //look for a new target this.target = null this.collisionFilter.category = cat.bullet; diff --git a/js/game.js b/js/game.js index cfb3feb..5ef4744 100644 --- a/js/game.js +++ b/js/game.js @@ -640,7 +640,7 @@ const game = { mech.death(); } - if (!(mech.cycle % 60)) { //once a second checks + if (!(mech.cycle % 60)) { //once a second if (mech.lastKillCycle + 300 > mech.cycle) { //effects active for 5 seconds after killing a mob if (b.isModEnergyRecovery) { @@ -653,6 +653,9 @@ const game = { if (b.isModEnergyLoss) { mech.fieldMeter = 0.05; } + + } else { //haven't killed a mob in the last 5 seconds + } if (!(game.cycle % 420)) { //once every 7 seconds diff --git a/js/level.js b/js/level.js index b4956f6..815e686 100644 --- a/js/level.js +++ b/js/level.js @@ -13,12 +13,12 @@ const level = { levelsCleared: 0, start() { if (level.levelsCleared === 0) { - // level.difficultyIncrease(4) - // b.giveGuns("laser") + // level.difficultyIncrease(14) + // b.giveGuns("foam") // mech.setField("negative mass field") // for (let i = 0; i < 9; i++) { - // b.giveMod("waste energy recovery"); - // b.giveMod("thermal runaway"); + // b.giveMod("foam stabilization"); + // b.giveMod("anthropic principle"); // b.giveMod("acute stress response"); // } @@ -143,8 +143,8 @@ const level = { // powerUps.spawn(450, -400, "mod", false, 6); // powerUps.spawn(450, -400, "mod", false); // spawn.bodyRect(-45, -100, 40, 50); - // spawn.bomberBoss(800, -450); - spawn.cellBoss(400, -750); + spawn.bomberBoss(800, -450); + // spawn.cellBoss(400, -750); // spawn.randomLevelBoss(400, -750) @@ -362,7 +362,9 @@ const level = { powerUps.spawn(1900, -150, "heal", false); //starting gun powerUps.spawn(2050, -150, "heal", false); //starting gun // powerUps.spawn(2050, -150, "field", false); //starting gun - powerUps.spawn(2300, -150, "gun", false); //starting gun + powerUps.spawnStartingPowerUps(2300, -150); + + // powerUps.spawn(2300, -150, "gun", false); //starting gun // if (game.isEasyMode) { // // powerUps.spawn(2050, -150, "mod", false); //starting gun // // powerUps.spawn(2050, -150, "mod", false); //starting gun @@ -785,6 +787,9 @@ const level = { level.enter.x = mech.spawnPos.x - 50; level.enter.y = mech.spawnPos.y + 20; spawn.mapRect(level.enter.x, level.enter.y + 20, 100, 20); + spawn.mapRect(level.exit.x, level.exit.y + 15, 100, 20); + // spawn.mapRect(3950, -3260, 100, 30); + level.addZone(level.exit.x, level.exit.y, 100, 30, "nextLevel"); powerUps.spawnStartingPowerUps(1075, -550); spawn.debris(-250, 50, 1650, 2); //16 debris per level @@ -914,7 +919,6 @@ const level = { spawn.mapRect(3700, -3700, 50, 500); spawn.mapRect(4250, -3700, 50, 300); spawn.mapRect(3700, -3250, 1100, 100); - spawn.mapRect(3950, -3260, 100, 30); spawn.randomSmallMob(-225, 25); spawn.randomSmallMob(1000, -1100); diff --git a/js/player.js b/js/player.js index 4fe0400..9db1818 100644 --- a/js/player.js +++ b/js/player.js @@ -317,7 +317,7 @@ const mech = { game.clearNow = true; //triggers a map reset //count mods - let totalMods = -2; //lose 2 mods for balance reasons + let totalMods = 0; for (let i = 0; i < b.mods.length; i++) { totalMods += b.mods[i].count } @@ -352,13 +352,14 @@ const mech = { } function randomizeHealth() { - mech.health = 0.5 + Math.random() + mech.health = 0.55 + Math.random() if (mech.health > 1) mech.health = 1; mech.displayHealth(); } function randomizeGuns() { - const length = Math.round(b.inventory.length * (1 + 0.4 * (Math.random() - 0.5))) + // const length = Math.round(b.inventory.length * (1 + 0.4 * (Math.random() - 0.5))) + const length = b.inventory.length //removes guns and ammo b.inventory = []; b.activeGun = null; @@ -367,16 +368,12 @@ const mech = { b.guns[i].have = false; if (b.guns[i].ammo !== Infinity) b.guns[i].ammo = 0; } - //give random guns - for (let i = 0; i < length; i++) { - b.giveGuns() - } - + for (let i = 0; i < length; i++) b.giveGuns() //randomize ammo for (let i = 0, len = b.inventory.length; i < len; i++) { if (b.guns[b.inventory[i]].ammo !== Infinity) { - b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(6 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.3))) + b.guns[b.inventory[i]].ammo = Math.max(0, Math.floor(6 * b.guns[b.inventory[i]].ammo * (Math.random() - 0.1))) } } game.makeGunHUD(); //update gun HUD @@ -466,9 +463,31 @@ const mech = { } mech.health -= dmg; if (mech.health < 0) { - mech.health = 0; - mech.death(); - return; + console.log(b.isModDeathAvoid, b.isModDeathAvoidOnCD) + if (b.isModDeathAvoid && !b.isModDeathAvoidOnCD) { //&& Math.random() < 0.5 + b.isModDeathAvoidOnCD = true; + mech.health += dmg //undo the damage + mech.collisionImmune = mech.cycle + 30 //disable this.collisionImmune bonus seconds + + game.wipe = function () { //set wipe to have trails + ctx.fillStyle = "rgba(255,255,255,0.02)"; + ctx.fillRect(0, 0, canvas.width, canvas.height); + } + setTimeout(function () { + game.wipe = function () { //set wipe to normal + ctx.clearRect(0, 0, canvas.width, canvas.height); + } + // game.replaceTextLog = true; + // game.makeTextLog("death avoided", 360); + b.isModDeathAvoidOnCD = false; + }, 3000); + + return; + } else { + mech.health = 0; + mech.death(); + return; + } } b.modOnHealthChange(); mech.displayHealth(); diff --git a/js/powerups.js b/js/powerups.js index 168b009..84e0177 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -289,10 +289,12 @@ const powerUps = { } }, spawnStartingPowerUps(x, y) { //used for map specific power ups, mostly to give player a starting gun - if (b.modCount < 1) { + if (b.inventory.length === 0) { + powerUps.spawn(x, y, "gun", false); + } else if (b.modCount === 0) { powerUps.spawn(x, y, "mod", false); //starting gun } else if (b.inventory.length < 2) { - powerUps.spawn(x, y, "gun", false); //starting gun + powerUps.spawn(x, y, "gun", false); } else { powerUps.spawnRandomPowerUp(x, y); powerUps.spawnRandomPowerUp(x, y); diff --git a/todo.txt b/todo.txt index 10e3a4f..d5355dc 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,8 @@ ************** TODO - n-gon ************** +mod - Collision avoidance system + 10% chance to dodge a collision + mod - mines - fire something instead of needles on activation foam?, flak?, vacuum bomb, super balls make a different mod for each type of bullet mine can fire @@ -45,14 +48,6 @@ css transition for pause menu field that pushes everything back, and can destroy smaller blocks converts blocks into ammo power ups -mod: make player invisible when... - use the flag from phase field - when health is low? - -field: a larger radius that attracted enemies - still deflected them near the robot - convert the health of mobs into energy when they are being attracted - mod: chance to not die from fatal damage also push mobs and bodies away? also heal?