From 9dc3bc43dfa6fd4215c1d54818c6ea45e36384fa Mon Sep 17 00:00:00 2001 From: landgreen Date: Sun, 23 Feb 2020 17:45:07 -0800 Subject: [PATCH] added basic field blocking mod --- index.html | 1 - js/bullets.js | 52 ++++++++++++++++++++++++++++++++++++++++++-------- js/level.js | 12 ++++++------ js/mobs.js | 2 +- js/player.js | 19 ++++++++++++++---- js/powerups.js | 12 +++++++----- todo.txt | 8 ++++++-- 7 files changed, 79 insertions(+), 27 deletions(-) diff --git a/index.html b/index.html index 63a9783..1784764 100644 --- a/index.html +++ b/index.html @@ -86,7 +86,6 @@
- Select 5 power ups and see how far you can progress. custom diff --git a/js/bullets.js b/js/bullets.js index b657e88..56b88bf 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -13,7 +13,7 @@ const b = { modNoAmmo: null, isModBulletsLastLonger: null, isModImmortal: null, - modSpores: null, + modSporesOnDeath: null, isModImmuneExplosion: null, isModExplodeMob: null, isModDroneOnDamage: null, @@ -52,6 +52,8 @@ const b = { isModDeathAvoidOnCD: null, modWaveSpeedMap: null, modWaveSpeedBody: null, + modFieldEfficiency: null, + isModSporeField: null, modOnHealthChange() { //used with acid mod if (b.isModAcidDmg && mech.health > 0.8) { game.playerDmgColor = "rgba(0,80,80,0.9)" @@ -268,13 +270,13 @@ const b = { }, requires: "", effect() { - b.modSpores += 0.11; + b.modSporesOnDeath += 0.11; for (let i = 0; i < 10; i++) { b.spore(player) } }, remove() { - b.modSpores = 0; + b.modSporesOnDeath = 0; } }, { @@ -513,7 +515,7 @@ const b = { }, { name: "weak anthropic principle", - description: "avoid harm that should be fatal
can occur once every 3 seconds", + description: "fatal harm can't happen
saves you up to once every 3 seconds", maxCount: 1, count: 0, allowed() { @@ -746,7 +748,7 @@ const b = { maxCount: 1, count: 0, allowed() { - return b.haveGunCheck("drones") || mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" + return b.haveGunCheck("drones") || (mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !b.isModSporeField) }, requires: "drones", effect() { @@ -762,7 +764,7 @@ const b = { maxCount: 1, count: 0, allowed() { - return b.haveGunCheck("spores") || b.modSpores > 0 || b.isModStomp + return b.haveGunCheck("spores") || b.modSporesOnDeath > 0 || b.isModStomp || b.isModSporeField }, requires: "spores", effect() { @@ -773,8 +775,8 @@ const b = { } }, { - name: "ice crystal nucleation", - description: "fire ice crystals formed from water vapour
your minigun no longer requires ammo", + name: "crystal nucleation", + description: "fire crystals formed from the air
your minigun no longer requires ammo", maxCount: 1, count: 0, allowed() { @@ -894,6 +896,40 @@ const b = { b.modWaveSpeedBody = 0.25 } }, + { + name: "perfect diamagnetism", + description: "when blocking with the basic field emitter
gain energy instead losing it", + maxCount: 1, + count: 0, + allowed() { + return mech.fieldUpgrades[mech.fieldMode].name === "field emitter" + }, + requires: "basic field emitter", + effect() { + b.modFieldEfficiency = -1 + mech.fieldShieldingScale = b.modFieldEfficiency; + }, + remove() { + b.modFieldEfficiency = 1; + if (mech.fieldUpgrades[mech.fieldMode].name === "field emitter") mech.fieldShieldingScale = b.modFieldEfficiency; + } + }, + { + name: "mycelium manufacturing", + description: "nano-scale manufacturing is modified to
grow spores instead of drones", + maxCount: 1, + count: 0, + allowed() { + return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" + }, + requires: "nano-scale manufacturing", + effect() { + b.isModSporeField = true; + }, + remove() { + b.isModSporeField = false; + } + }, // { // name: "super mines", diff --git a/js/level.js b/js/level.js index 853913d..300f408 100644 --- a/js/level.js +++ b/js/level.js @@ -13,21 +13,21 @@ const level = { levelsCleared: 0, start() { if (level.levelsCleared === 0) { - level.difficultyIncrease(5) + // level.difficultyIncrease(9) // b.giveGuns("wave beam") - // mech.setField("negative mass field") + // mech.setField("nano-scale manufacturing") // for (let i = 0; i < 9; i++) { - // b.giveMod("wave phase velocity"); + // b.giveMod("mycelium manufacturing"); // b.giveMod("anthropic principle"); // b.giveMod("acute stress response"); // } - // level.intro(); //starting level + level.intro(); //starting level // level.testingMap(); // level.bosses(); // level.satellite(); // level.skyscrapers(); - level.aerie(); + // level.aerie(); // level.rooftops(); // level.warehouse(); // level.highrise(); @@ -144,7 +144,7 @@ const level = { // powerUps.spawn(450, -400, "mod", false); // spawn.bodyRect(-45, -100, 40, 50); spawn.springer(800, -450); - // spawn.cellBoss(400, -750); + spawn.cellBoss(400, -750); // spawn.randomLevelBoss(400, -750) diff --git a/js/mobs.js b/js/mobs.js index 236a7e7..566b3df 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -967,7 +967,7 @@ const mobs = { if (this.dropPowerUp) { powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius); mech.lastKillCycle = mech.cycle; //tracks the last time a kill was made, mostly used in game.checks() - if (Math.random() < b.modSpores) { + if (Math.random() < b.modSporesOnDeath) { const len = Math.min(30, Math.floor(4 + this.mass * Math.random())) for (let i = 0; i < len; i++) { b.spore(this) //spawn drone diff --git a/js/player.js b/js/player.js index e3cf049..e9c7ccd 100644 --- a/js/player.js +++ b/js/player.js @@ -663,6 +663,7 @@ const mech = { fieldMode: 0, //basic field mode before upgrades fieldEnergyMax: 1, //can be increased by a mod holdingTarget: null, + fieldShieldingScale: 1, // these values are set on reset by setHoldDefaults() fieldMeter: 0, fieldRegen: 0, @@ -671,7 +672,6 @@ const mech = { holdingMassScale: 0, throwChargeRate: 0, throwChargeMax: 0, - fieldShieldingScale: 0, fieldRange: 175, fieldArc: 0, fieldThreshold: 0, @@ -685,7 +685,7 @@ const mech = { mech.fieldCDcycle = 0; mech.isStealth = false; player.collisionFilter.mask = cat.body | cat.map | cat.mob | cat.mobBullet | cat.mobShield - mech.fieldShieldingScale = 1; //scale energy loss after collision with mob + // mech.fieldShieldingScale = 1; //scale energy loss after collision with mob mech.holdingMassScale = 0.5; mech.throwChargeRate = 2; mech.throwChargeMax = 50; @@ -932,6 +932,7 @@ const mech = { if (mech.fieldMeter > fieldBlockCost * 0.2) { //shield needs at least some of the cost to block mech.fieldMeter -= fieldBlockCost * mech.fieldShieldingScale; if (mech.fieldMeter < 0) mech.fieldMeter = 0; + if (mech.fieldMeter > mech.fieldEnergyMax) mech.fieldMeter = mech.fieldEnergyMax; mech.drawHold(who); mech.fieldCDcycle = mech.cycle + 10; mech.holdingTarget = null @@ -1120,6 +1121,7 @@ const mech = { name: "field emitter", description: "use energy to shield yourself from damage
lets you pick up and throw objects", effect: () => { + mech.fieldShieldingScale = Number(b.modFieldEfficiency); game.replaceTextLog = true; //allow text over write mech.hold = function () { if (mech.isHolding) { @@ -1510,8 +1512,17 @@ const mech = { mech.hold = function () { if (mech.fieldMeter > mech.fieldEnergyMax - 0.02 && mech.fieldCDcycle < mech.cycle) { mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones - mech.fieldMeter -= 0.35; - b.drone(1) + if (b.isModSporeField) { + const len = Math.floor(6 + 3 * Math.random()) + mech.fieldMeter -= len * 0.12; + for (let i = 0; i < len; i++) { + b.spore(player) + } + } else { + mech.fieldMeter -= 0.33; + b.drone(1) + } + } if (mech.isHolding) { mech.drawHold(mech.holdingTarget); diff --git a/js/powerups.js b/js/powerups.js index 84e0177..80779af 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -25,12 +25,14 @@ const powerUps = { game.isChoosing = false; //stops p from un pausing on key down requestAnimationFrame(cycle); }, - cancel() { + isCanceledField: false, + cancel(what) { document.body.style.cursor = "none"; document.getElementById("choose-grid").style.display = "none" document.getElementById("choose-background").style.display = "none" game.paused = false; game.isChoosing = false; //stops p from un pausing on key down + if (what === "field") powerUps.isCanceledField = true; requestAnimationFrame(cycle); }, showDraft() { @@ -109,7 +111,7 @@ const powerUps = { let choice2 = pick(mech.fieldUpgrades, choice1) let choice3 = -1 if (choice1 > -1) { - let text = `

choose a field

` + let text = `

choose a field

` text += `
  ${mech.fieldUpgrades[choice1].name}
${mech.fieldUpgrades[choice1].description}
` if (choice2 > -1) text += `
  ${mech.fieldUpgrades[choice2].name}
${mech.fieldUpgrades[choice2].description}
` if (!b.isModBayesian) { @@ -153,7 +155,7 @@ const powerUps = { let choice2 = pick(choice1) let choice3 = -1 if (choice1 > -1) { - let text = "

choose a mod

" + let text = `

choose a mod

` text += `
  ${b.mods[choice1].name}
${b.mods[choice1].description}
` if (choice2 > -1) text += `
  ${b.mods[choice2].name}
${b.mods[choice2].description}
` if (!b.isModBayesian) { @@ -190,7 +192,7 @@ const powerUps = { let choice2 = pick(b.guns, choice1) let choice3 = -1 if (choice1 > -1) { - let text = "

choose a gun

" + let text = `

choose a gun

` text += `
  ${b.guns[choice1].name}
${b.guns[choice1].description}
` if (choice2 > -1) text += `
  ${b.guns[choice2].name}
${b.guns[choice2].description}
` if (!b.isModBayesian) { @@ -248,7 +250,7 @@ const powerUps = { } }, spawnBossPowerUp(x, y) { //boss spawns field and gun mod upgrades - if (mech.fieldMode === 0) { + if (mech.fieldMode === 0 && !powerUps.isCanceledField) { powerUps.spawn(x, y, "field") if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field") } else if (Math.random() < 0.80) { diff --git a/todo.txt b/todo.txt index e694c58..0433ea2 100644 --- a/todo.txt +++ b/todo.txt @@ -1,7 +1,11 @@ ************** TODO - n-gon ************** -level - add wrecking ball boss to other levels - it could work on rooftops and satellite +mod - ice crystal nucleaution should slow down mobs + add an on hit effect to *1.1 air friction? + +mod - starter field can block attacks with out draining energy + +mod - rail gun burst on impact into nails mod - make bodies destroyable they drop ammo and heals