From 9ecbe9c4797ce95d52fd5cef06128dd8417d6c8b Mon Sep 17 00:00:00 2001 From: landgreen Date: Fri, 14 Aug 2020 07:04:30 -0700 Subject: [PATCH] arsenal, generalist mod --- js/game.js | 11 ++++------- js/level.js | 5 +++++ js/mods.js | 42 +++++++++++++++++++++++++++++++++++++++++- js/player.js | 4 ++-- js/powerup.js | 19 ++++++++++++------- todo.txt | 10 ++++++++-- 6 files changed, 72 insertions(+), 19 deletions(-) diff --git a/js/game.js b/js/game.js index 696eda1..5da51c1 100644 --- a/js/game.js +++ b/js/game.js @@ -264,14 +264,14 @@ const game = { } }, nextGun() { - if (b.inventory.length > 0) { + if (b.inventory.length > 0 && !mod.isGunCycle) { b.inventoryGun++; if (b.inventoryGun > b.inventory.length - 1) b.inventoryGun = 0; game.switchGun(); } }, previousGun() { - if (b.inventory.length > 0) { + if (b.inventory.length > 0 && !mod.isGunCycle) { b.inventoryGun--; if (b.inventoryGun < 0) b.inventoryGun = b.inventory.length - 1; game.switchGun(); @@ -315,14 +315,11 @@ const game = { // } - if (keys[69]) { - // e swap to next active gun + if (keys[69]) { // e swap to next active gun game.nextGun(); - } else if (keys[81]) { - //q swap to previous active gun + } else if (keys[81]) { //q swap to previous active gun game.previousGun(); } - if (keys[80] && !game.isChoosing) { //p for pause if (game.paused) { build.unPauseGrid() diff --git a/js/level.js b/js/level.js index 209a72c..545e9d2 100644 --- a/js/level.js +++ b/js/level.js @@ -57,6 +57,11 @@ const level = { powerUps.spawn(mech.pos.x, mech.pos.y, "heal", false); } } + if (mod.isGunCycle) { + b.inventoryGun++; + if (b.inventoryGun > b.inventory.length - 1) b.inventoryGun = 0; + game.switchGun(); + } }, custom() {}, customTopLayer() {}, diff --git a/js/mods.js b/js/mods.js index 8a198be..c3684d7 100644 --- a/js/mods.js +++ b/js/mods.js @@ -70,6 +70,7 @@ const mod = { }, damageFromMods() { let dmg = 1 + if (mod.isDamageForGuns) dmg *= 1 + 0.07 * b.inventory.length if (mod.isLowHealthDmg) dmg *= 1 + 0.5 * Math.max(0, 1 - mech.health) if (mod.isHarmDamage && mech.lastHarmCycle + 600 > mech.cycle) dmg *= 2; if (mod.isEnergyLoss) dmg *= 1.33; @@ -1056,6 +1057,43 @@ const mod = { mod.bayesian = 0; } }, + { + name: "arsenal", + description: "increase damage by 7%
for each gun in your inventory", + maxCount: 1, + count: 0, + allowed() { + return b.inventory.length > 1 + }, + requires: "at least 2 guns", + effect() { + mod.isDamageForGuns = true; + }, + remove() { + mod.isDamageForGuns = false; + } + }, + { + name: "generalist", + description: "spawn 3 gun, but you can't switch guns
automatically cycle guns with each new level", + maxCount: 1, + count: 0, + isNonRefundable: true, + allowed() { + return mod.isDamageForGuns + }, + requires: "arsenal", + effect() { + mod.isGunCycle = true; + for (let i = 0; i < 3; i++) { + powerUps.spawn(mech.pos.x, mech.pos.y, "gun"); + if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "gun"); + } + }, + remove() { + mod.isGunCycle = false; + } + }, { name: "logistics", description: "ammo power ups give 200% ammo
but ammo is only added to your current gun", @@ -2561,5 +2599,7 @@ const mod = { isLaserBotUpgrade: null, isBoomBotUpgrade: null, isDroneGrab: null, - isOneGun: null + isOneGun: null, + isDamageForGuns: null, + isGunCycle: null } \ No newline at end of file diff --git a/js/player.js b/js/player.js index 23dcd5c..eb0fc82 100644 --- a/js/player.js +++ b/js/player.js @@ -1733,7 +1733,7 @@ const mech = { // } function drawField(radius) { - radius *= 0.9 + 2 * mech.energy * mech.energy; + radius *= 0.9 + 2.2 * mech.energy * mech.energy; const rotate = mech.cycle * 0.005; mech.fieldPhase += 0.5 - 0.5 * Math.sqrt(Math.max(0.01, Math.min(mech.energy, 1))); const off1 = 1 + 0.06 * Math.sin(mech.fieldPhase); @@ -1770,7 +1770,7 @@ const mech = { // game.draw.bodyFill = "transparent" // game.draw.bodyStroke = "transparent" - const DRAIN = 0.00014 + (mech.fireCDcycle > mech.cycle ? 0.007 : 0.001) + const DRAIN = 0.00013 + (mech.fireCDcycle > mech.cycle ? 0.005 : 0) if (mech.energy > DRAIN) { mech.energy -= DRAIN; // if (mech.energy < 0.001) { diff --git a/js/powerup.js b/js/powerup.js index 3af7e1d..92c458a 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -425,7 +425,7 @@ const powerUps = { if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "ammo"); return; } - if (Math.random() < 0.001 * (3 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 3 + if (Math.random() < 0.0015 * (3 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 3 powerUps.spawn(x, y, "gun"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "gun"); return; @@ -515,13 +515,18 @@ const powerUps = { } }, spawnStartingPowerUps(x, y) { //used for map specific power ups, mostly to give player a starting gun - if (level.levelsCleared < 6) { + if (level.levelsCleared < 4) { //runs 4 times on all difficulty levels if (b.inventory.length === 0) { - powerUps.spawn(x, y, "gun", false); - } else if (mod.totalCount === 0) { - powerUps.spawn(x, y, "mod", false); //starting gun - // } else if (b.inventory.length < 2 && Math.random() < 0.2) { - // powerUps.spawn(x, y, "gun", false); + powerUps.spawn(x, y, "gun", false); //first gun + } else if (mod.totalCount === 0) { //first mod + powerUps.spawn(x, y, "mod", false); + } else if (b.inventory.length < 2) { //second gun or extra ammo + if (Math.random() < 0.5) { + powerUps.spawn(x, y, "gun", false); + } else { + powerUps.spawn(x, y, "ammo", false); + powerUps.spawn(x, y, "ammo", false); + } } else { powerUps.spawnRandomPowerUp(x, y); powerUps.spawnRandomPowerUp(x, y); diff --git a/todo.txt b/todo.txt index d9adc9a..4a66d1b 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,11 @@ -mod: renormalization now gives a 60% chance to return a reroll after using a reroll - (the old renormalization was causing too much lag) +In the first 4 levels: added a much higher chance of getting a second gun + or extra ammo if you don't get a second gun + +mod - arsenal: +7% damage for each gun in your inventory + +mod- generalist: spawn 2 guns, but you can't switch guns + at the start of each level switch guns + requires arsenal ************** TODO - n-gon **************