From bf5f55a7ecdaf018cf41482dee02f44155a0c8f9 Mon Sep 17 00:00:00 2001 From: landgreen Date: Sun, 9 Aug 2020 05:43:00 -0700 Subject: [PATCH] URL build goes to custom, ammo goes to all guns --- js/bullet.js | 22 +++++++------- js/game.js | 20 +----------- js/index.js | 69 ++++++++++++++++++++++++++++++++++++++++-- js/level.js | 2 +- js/mods.js | 20 +++++------- js/powerup.js | 84 ++++++++++++++++++++++++++++++--------------------- todo.txt | 16 +++++++--- 7 files changed, 148 insertions(+), 85 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index d13d80d..6faedf6 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -485,7 +485,7 @@ const b = { spore(where, isFreeze = mod.isSporeFreeze) { //used with the mod upgrade in mob.death() const bIndex = bullet.length; const side = 4; - bullet[bIndex] = Bodies.polygon(where.x, where.y, 5, side, { + bullet[bIndex] = Bodies.polygon(where.x, where.y, 4, side, { // density: 0.0015, //frictionAir: 0.01, inertia: Infinity, isFreeze: isFreeze, @@ -1578,7 +1578,7 @@ const b = { name: "shotgun", description: "fire a burst of short range bullets
crouch to reduce recoil", ammo: 0, - ammoPack: 8, + ammoPack: 6, have: false, fire() { let knock, spread @@ -1591,7 +1591,7 @@ const b = { mech.fireCDcycle = mech.cycle + Math.floor(45 * b.fireCD); // cool down if (mod.isShotgunImmune) mech.immuneCycle = mech.cycle + Math.floor(47 * b.fireCD); //player is immune to collision damage for 30 cycles spread = 1.3 - knock = 0.08 + knock = 0.1 } if (mod.isShotgunRecoil) { @@ -1616,27 +1616,27 @@ const b = { x: speed * Math.cos(dir), y: speed * Math.sin(dir) } - b.nail(pos, velocity, 0.6) + b.nail(pos, velocity, 1) } } else { - const side = 19 * mod.bulletSize + const side = 21 * mod.bulletSize for (let i = 0; i < 15; i++) { const me = bullet.length; const dir = mech.angle + (Math.random() - 0.5) * spread bullet[me] = Bodies.rectangle(mech.pos.x + 35 * Math.cos(mech.angle) + 15 * (Math.random() - 0.5), mech.pos.y + 35 * Math.sin(mech.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir)); World.add(engine.world, bullet[me]); //add bullet to world - const SPEED = 50 + Math.random() * 10 + const SPEED = 52 + Math.random() * 8 Matter.Body.setVelocity(bullet[me], { x: SPEED * Math.cos(dir), y: SPEED * Math.sin(dir) }); bullet[me].endCycle = game.cycle + 40 - bullet[me].minDmgSpeed = 20 + bullet[me].minDmgSpeed = 15 // bullet[me].dmg = 0.1 bullet[me].frictionAir = 0.034; bullet[me].do = function () { if (!mech.isBodiesAsleep) { - const scale = 1 - 0.035 / mod.isBulletsLastLonger + const scale = 1 - 0.034 / mod.isBulletsLastLonger Matter.Body.scale(this, scale, scale); } }; @@ -2093,7 +2093,7 @@ const b = { name: "vacuum bomb", description: "fire a bomb that sucks before exploding
click left mouse again to detonate", ammo: 0, - ammoPack: 3, + ammoPack: 2.5, have: false, fire() { const me = bullet.length; @@ -2105,7 +2105,7 @@ const b = { bullet[me].restitution = 0.2; bullet[me].friction = 0.3; bullet[me].endCycle = Infinity - bullet[me].explodeRad = 450 + Math.floor(Math.random() * 30); + bullet[me].explodeRad = 450 + Math.floor(Math.random() * 50); bullet[me].onEnd = function () { b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end @@ -2562,7 +2562,7 @@ const b = { name: "rail gun", description: "use energy to launch a high-speed dense rod
hold left mouse to charge, release to fire", ammo: 0, - ammoPack: 4, + ammoPack: 3, have: false, fire() { const me = bullet.length; diff --git a/js/game.js b/js/game.js index f2f1f17..696eda1 100644 --- a/js/game.js +++ b/js/game.js @@ -199,7 +199,7 @@ const game = { if (b.inventory[0] === b.activeGun) { let lessDamage = 1 for (let i = 0, len = b.inventory.length; i < len; i++) { - lessDamage *= 0.85 // 1 - 0.15 + lessDamage *= 0.87 // 1 - 0.15 } document.getElementById("mod-entanglement").innerHTML = " " + ((1 - lessDamage) * 100).toFixed(0) + "%" } else { @@ -595,24 +595,6 @@ const game = { document.getElementById("dmg").style.display = "inline"; document.getElementById("health-bg").style.display = "inline"; - // window.onmousedown = function (e) { - // //mouse up event in set in index.js - - // // game.mouseDown = true; - // if (e.which === 3) { - // game.mouseDownRight = true; - // } else { - // game.mouseDown = true; - // } - // // keep this disabled unless building maps - // // if (!game.mouseDown){ - // // game.getCoords.pos1.x = Math.round(game.mouseInGame.x / 25) * 25; - // // game.getCoords.pos1.y = Math.round(game.mouseInGame.y / 25) * 25; - // // } - - // // mech.throwBlock(); - // }; - if (game.firstRun) { mech.spawn(); //spawns the player mod.setupAllMods(); //doesn't run on reset so that gun mods carry over to new runs diff --git a/js/index.js b/js/index.js index 45c9a27..6e01e20 100644 --- a/js/index.js +++ b/js/index.js @@ -51,7 +51,66 @@ window.addEventListener('load', (event) => { const set = getUrlVars() if (Object.keys(set).length !== 0) { build.isURLBuild = true; - game.startGame() + // game.startGame() + openCustomBuildMenu(); + //add custom selections based on url + for (const property in set) { + // console.log(set[property], property); + set[property] = set[property].replace(/%20/g, " ") + if (property.substring(0, 3) === "gun") { + let found = false + let index + for (let i = 0; i < b.guns.length; i++) { + if (set[property] === b.guns[i].name) { + index = i; + found = true; + break; + } + } + if (found) build.choosePowerUp(document.getElementById(`gun-${index}`), index, 'gun') + } + + if (property.substring(0, 3) === "mod") { + let found = false + let index + for (let i = 0; i < mod.mods.length; i++) { + if (set[property] === mod.mods[i].name) { + index = i; + found = true; + break; + } + } + if (found) build.choosePowerUp(document.getElementById(`mod-${index}`), index, 'mod') + } + + if (property === "field") { + let found = false + let index + for (let i = 0; i < mech.fieldUpgrades.length; i++) { + if (set[property] === mech.fieldUpgrades[i].name) { + index = i; + found = true; + break; + } + } + if (found) build.choosePowerUp(document.getElementById(`field-${index}`), index, 'field') + } + if (property === "difficulty") { + game.difficultyMode = Number(set[property]) + localSettings.difficultyMode = Number(set[property]) + localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage + document.getElementById("difficulty-select").value = Number(set[property]) + document.getElementById("difficulty-select-custom").value = Number(set[property]) + } + if (property === "level") { + document.getElementById("starting-level").value = Number(set[property]) + + // level.levelsCleared += Number(set[property]); + // level.difficultyIncrease(Number(set[property]) * game.difficultyMode) //increase difficulty based on modes + // spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns + // level.onLevel++ + } + } } }); @@ -248,7 +307,7 @@ const build = { text += `
  ${mech.fieldUpgrades[i].name}
${mech.fieldUpgrades[i].description}
` } for (let i = 0, len = b.guns.length; i < len; i++) { - text += `
  ${b.guns[i].name}
${b.guns[i].description}
` + text += `
  ${b.guns[i].name}
${b.guns[i].description}
` } for (let i = 0, len = mod.mods.length; i < len; i++) { if (!mod.mods[i].allowed()) { // || mod.mods[i].name === "+1 cardinality") { //|| mod.mods[i].name === "leveraged investment" @@ -333,7 +392,7 @@ const build = { } } -document.getElementById("build-button").addEventListener("click", () => { //setup build run +function openCustomBuildMenu() { build.isURLBuild = false; document.getElementById("build-button").style.display = "none"; const el = document.getElementById("build-grid") @@ -347,6 +406,10 @@ document.getElementById("build-button").addEventListener("click", () => { //setu build.isCustomSelection = true; game.paused = true; build.reset(); +} + +document.getElementById("build-button").addEventListener("click", () => { //setup build run + openCustomBuildMenu(); }); diff --git a/js/level.js b/js/level.js index b340093..a3a7e05 100644 --- a/js/level.js +++ b/js/level.js @@ -9,7 +9,7 @@ const level = { levelsCleared: 0, levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber"], start() { - if (build.isURLBuild && level.levelsCleared === 0) build.onLoadPowerUps(); + // if (build.isURLBuild && level.levelsCleared === 0) build.onLoadPowerUps(); if (level.levelsCleared === 0) { //this code only runs on the first level // level.difficultyIncrease(12) // game.enableConstructMode() //used to build maps in testing mode diff --git a/js/mods.js b/js/mods.js index 30f0937..6c923b6 100644 --- a/js/mods.js +++ b/js/mods.js @@ -79,7 +79,7 @@ const mod = { if (mod.isEnergyDamage) dmg *= 1 + mech.energy / 5.5; if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005 if (mod.isRerollDamage) dmg *= 1 + 0.05 * powerUps.reroll.rerolls - if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.22 + if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.25 return dmg * mod.slowFire }, totalBots() { @@ -87,7 +87,7 @@ const mod = { }, mods: [{ name: "integrated armament", - description: "increase damage by 22%
your inventory can only hold 1 gun", + description: "increase damage by 25%
your inventory can only hold 1 gun", maxCount: 1, count: 0, allowed() { @@ -759,13 +759,13 @@ const mod = { game.boldActiveGunHUD(); }, 1000); }, - description: "while your first gun is equipped
reduce harm by 15% for each of your guns", + description: "while your first gun is equipped
reduce harm by 13% for each of your guns", maxCount: 1, count: 0, allowed() { - return !mod.isEnergyHealth + return b.inventory.length > 1 && !mod.isEnergyHealth }, - requires: "not mass-energy equivalence", + requires: "at least 2 guns", effect() { mod.isEntanglement = true setTimeout(function () { @@ -1059,19 +1059,15 @@ const mod = { }, { name: "logistics", - description: "ammo power ups add to your current gun
spawn 7 ammo", + description: "ammo power ups give 100% more ammo
but ammo is only added to your current gun", maxCount: 1, count: 0, allowed() { - return b.inventory.length > 1 + return true }, - requires: "at least 2 guns", + requires: "", effect() { mod.isAmmoForGun = true; - for (let i = 0; i < 7; i++) { - powerUps.spawn(mech.pos.x, mech.pos.y, "ammo"); - if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "ammo"); - } }, remove() { mod.isAmmoForGun = false; diff --git a/js/powerup.js b/js/powerup.js index dd43d0a..129f228 100644 --- a/js/powerup.js +++ b/js/powerup.js @@ -125,39 +125,55 @@ const powerUps = { return 17; }, effect() { - //only get ammo for guns player has - let target; - if (b.inventory.length > 0) { - if (mod.isAmmoForGun) { - target = b.guns[b.activeGun]; - } else { - //find a gun in your inventory - target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]; - //try 3 more times to give ammo to a gun with ammo, not Infinity - if (target.ammo === Infinity) { - target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]] - if (target.ammo === Infinity) { - target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]] - if (target.ammo === Infinity) target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]] - } + //give ammo to all guns in inventory + if (mod.isAmmoForGun) { + const target = b.guns[b.activeGun] + target.ammo += Math.ceil(Math.random() * target.ammoPack) + target.ammo += Math.ceil(Math.random() * target.ammoPack) + } else { + for (let i = 0, len = b.inventory.length; i < len; i++) { + const target = b.guns[b.inventory[i]] + if (target.ammo !== Infinity) { + target.ammo += Math.ceil(Math.random() * target.ammoPack) } } - //give ammo - if (target.ammo === Infinity) { - if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy; - if (!game.lastLogTime) game.makeTextLog("+energy", 300); - } else { - let ammo = Math.ceil((target.ammoPack * (0.8 + 0.25 * Math.random()))); - // if (level.isBuildRun) ammo = Math.floor(ammo * 1.1) //extra ammo on build run because no ammo from getting a new gun - target.ammo += ammo; - game.updateGunHUD(); - game.makeTextLog("
  +" + ammo + " ammo for " + target.name + "", 300); - } - } else { - // target = b.guns[Math.floor(Math.random() * b.guns.length)]; //if you don't have any guns just add ammo to a random gun you don't have yet - if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy; - if (!game.lastLogTime) game.makeTextLog("+energy", 300); } + game.updateGunHUD(); + + + // //only get ammo for guns player has + // let target; + // if (b.inventory.length > 0) { + // if (mod.isAmmoForGun) { + // target = b.guns[b.activeGun]; + // } else { + // //find a gun in your inventory + // target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]; + // //try 3 more times to give ammo to a gun with ammo, not Infinity + // if (target.ammo === Infinity) { + // target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]] + // if (target.ammo === Infinity) { + // target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]] + // if (target.ammo === Infinity) target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]] + // } + // } + // } + // //give ammo + // if (target.ammo === Infinity) { + // if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy; + // if (!game.lastLogTime) game.makeTextLog("+energy", 300); + // } else { + // let ammo = Math.ceil((target.ammoPack * (0.8 + 0.25 * Math.random()))); + // // if (level.isBuildRun) ammo = Math.floor(ammo * 1.1) //extra ammo on build run because no ammo from getting a new gun + // target.ammo += ammo; + // game.updateGunHUD(); + // game.makeTextLog("
  +" + ammo + " ammo for " + target.name + "", 300); + // } + // } else { + // // target = b.guns[Math.floor(Math.random() * b.guns.length)]; //if you don't have any guns just add ammo to a random gun you don't have yet + // if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy; + // if (!game.lastLogTime) game.makeTextLog("+energy", 300); + // } } }, field: { @@ -405,7 +421,7 @@ const powerUps = { if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "ammo"); return; } - if (Math.random() < 0.002 * (3 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 3 + if (Math.random() < 0.001 * (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; @@ -468,7 +484,7 @@ const powerUps = { if (mech.fieldMode === 0) { powerUps.spawn(x, y, "field") if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field") - } else if (Math.random() < 0.94) { + } else if (Math.random() < 0.95) { powerUps.spawn(x, y, "mod") if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod") } else { @@ -500,8 +516,8 @@ const powerUps = { 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.5) { - powerUps.spawn(x, y, "gun", false); + // } else if (b.inventory.length < 2 && Math.random() < 0.2) { + // powerUps.spawn(x, y, "gun", false); } else { powerUps.spawnRandomPowerUp(x, y); powerUps.spawnRandomPowerUp(x, y); diff --git a/todo.txt b/todo.txt index 06ad809..b1e2400 100644 --- a/todo.txt +++ b/todo.txt @@ -1,13 +1,19 @@ -added rotating platforms to sewers level -mod negentropy: now spawns a heal power up for every 50% missing health at the start of a level +ammo power ups give ammo to every gun in your inventory now, + but they only give half as much for each ammo power up + this should give a greater incentive for having more guns +mod: logistics now gives double ammo to only your current gun -all explosions do about 10% more damage -knock back no longer gets weaker at high levels -mod - electric reactive armor now gives explosion damage immunity when your energy is above 75% +custom build links now bring you to the custom build menu, not directly into the game ************** TODO - n-gon ************** +have custom links goto the custom build menu, not the intro level + +performance issues with large numbers of spores +consider limiting total bullets? + 300? + level element: a hanging chain of connected blocks give mobs more animal-like behaviors like rain world