From 0c4caa186af4df9e03ad34860c404d7602e6b08f Mon Sep 17 00:00:00 2001 From: landgreen Date: Sun, 9 Aug 2020 16:24:35 -0700 Subject: [PATCH] custom url bug fix --- js/bullet.js | 37 ++++++++++++++++++------------------- js/index.js | 46 +++++++++++++++++++++++++--------------------- js/level.js | 6 +++--- js/mods.js | 37 ++++++++++++++++++------------------- js/spawn.js | 2 +- todo.txt | 8 -------- 6 files changed, 65 insertions(+), 71 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 6faedf6..e7e3408 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -750,7 +750,7 @@ const b = { this.lockedOn = powerUp[i] } } - if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 60000) { + if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 60000 && !game.isChoosing) { powerUps.onPickUp(); powerUp[i].effect(); Matter.World.remove(engine.world, powerUp[i]); @@ -909,7 +909,6 @@ const b = { this.collisionFilter.category = cat.bullet; this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield if (mod.isFoamGrowOnDeath && bullet.length < 300) { - console.log(bullet.length) let targets = [] for (let i = 0, len = mob.length; i < len; i++) { const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position)); @@ -1539,8 +1538,8 @@ const b = { name: "minigun", description: "rapidly fire a stream of small bullets
fire delay decreases as you shoot", ammo: 0, - ammoPack: 70, - defaultAmmoPack: 70, + ammoPack: 65, + defaultAmmoPack: 65, recordedAmmo: 0, have: false, nextFireCycle: 0, //use to remember how longs its been since last fire, used to reset count @@ -1648,7 +1647,7 @@ const b = { name: "super balls", description: "fire four balls in a wide arc
balls bounce with no momentum loss", ammo: 0, - ammoPack: 13, + ammoPack: 12, have: false, num: 5, fire() { @@ -1703,8 +1702,8 @@ const b = { name: "flechettes", description: "fire a volley of uranium-235 needles
does damage over 3 seconds", ammo: 0, - ammoPack: 38, - defaultAmmoPack: 38, + ammoPack: 35, + defaultAmmoPack: 35, have: false, count: 0, //used to track how many shots are in a volley before a big CD lastFireCycle: 0, //use to remember how longs its been since last fire, used to reset count @@ -1807,7 +1806,7 @@ const b = { name: "wave beam", description: "emit a sine wave of oscillating particles
particles slowly propagate through solids", ammo: 0, - ammoPack: 100, + ammoPack: 90, have: false, fire() { mech.fireCDcycle = mech.cycle + Math.floor(3 * b.fireCD); // cool down @@ -1942,7 +1941,7 @@ const b = { name: "missiles", description: "launch missiles that accelerate towards mobs
explodes when near target", ammo: 0, - ammoPack: 4, + ammoPack: 3, have: false, fireCycle: 0, ammoLoaded: 0, @@ -1998,8 +1997,8 @@ const b = { name: "flak", description: "fire a cluster of short range projectiles
explodes on contact or after half a second", ammo: 0, - ammoPack: 5, - defaultAmmoPack: 5, //use to revert ammoPack after mod changes drop rate + ammoPack: 4, + defaultAmmoPack: 4, //use to revert ammoPack after mod changes drop rate have: false, fire() { mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 25 : 10) * b.fireCD); // cool down @@ -2042,7 +2041,7 @@ const b = { name: "grenades", description: "lob a single bouncy projectile
explodes on contact or after one second", ammo: 0, - ammoPack: 6, + ammoPack: 5, have: false, fire() { const me = bullet.length; @@ -2093,7 +2092,7 @@ const b = { name: "vacuum bomb", description: "fire a bomb that sucks before exploding
click left mouse again to detonate", ammo: 0, - ammoPack: 2.5, + ammoPack: 2, have: false, fire() { const me = bullet.length; @@ -2212,7 +2211,7 @@ const b = { name: "neutron bomb", description: "toss a chunk of Cf-252 that emits neutrons
damages and drains energy in area of effect", ammo: 0, - ammoPack: 6, + ammoPack: 5, have: false, fire() { const me = bullet.length; @@ -2370,7 +2369,7 @@ const b = { name: "mine", description: "toss a proximity mine that sticks to walls
fires nails at mobs within range", ammo: 0, - ammoPack: 3, + ammoPack: 2.7, have: false, fire() { const pos = { @@ -2392,7 +2391,7 @@ const b = { name: "spores", description: "fire a sporangium that discharges spores
spores seek out nearby mobs", ammo: 0, - ammoPack: 4, + ammoPack: 3.5, have: false, fire() { const me = bullet.length; @@ -2523,7 +2522,7 @@ const b = { name: "ice IX", description: "synthesize short-lived ice crystals
crystals seek out and freeze mobs", ammo: 0, - ammoPack: 69, + ammoPack: 64, have: false, fire() { if (mech.crouch) { @@ -2540,7 +2539,7 @@ const b = { name: "foam", description: "spray bubbly foam that sticks to mobs
slows mobs and does damage over time", ammo: 0, - ammoPack: 45, + ammoPack: 40, have: false, fire() { mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 20 : 6) * b.fireCD); // cool down @@ -2562,7 +2561,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: 3, + ammoPack: 2.6, have: false, fire() { const me = bullet.length; diff --git a/js/index.js b/js/index.js index 6e01e20..faa2712 100644 --- a/js/index.js +++ b/js/index.js @@ -57,6 +57,20 @@ window.addEventListener('load', (event) => { for (const property in set) { // console.log(set[property], property); set[property] = set[property].replace(/%20/g, " ") + + 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.substring(0, 3) === "gun") { let found = false let index @@ -80,26 +94,14 @@ window.addEventListener('load', (event) => { break; } } - if (found) build.choosePowerUp(document.getElementById(`mod-${index}`), index, 'mod') + if (found) build.choosePowerUp(document.getElementById(`mod-${index}`), index, 'mod', true) } - 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]) + // 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") { @@ -206,7 +208,7 @@ const build = { window.scrollTo(0, 0); }, isCustomSelection: true, - choosePowerUp(who, index, type) { + choosePowerUp(who, index, type, isAllowed = false) { if (type === "gun") { let isDeselect = false for (let i = 0, len = b.inventory.length; i < len; i++) { //look for selection in inventory @@ -265,7 +267,7 @@ const build = { modID.classList.add("build-grid-disabled"); modID.onclick = null } - if (mod.mods[i].count > 0) { + if (mod.mods[i].count > 0 && !isAllowed) { mod.removeMod(i) } if (modID.classList.contains("build-mod-selected")) { @@ -348,12 +350,14 @@ const build = { shareURL() { let url = "https://landgreen.github.io/sidescroller/index.html?" let count = 0; - for (let i = 0; i < b.guns.length; i++) { - if (b.guns[i].have) { - url += `&gun${count}=${encodeURIComponent(b.guns[i].name.trim())}` + + for (let i = 0; i < b.inventory.length; i++) { + if (b.guns[b.inventory[i]].have) { + url += `&gun${count}=${encodeURIComponent(b.guns[b.inventory[i]].name.trim())}` count++ } } + count = 0; for (let i = 0; i < mod.mods.length; i++) { for (let j = 0; j < mod.mods[i].count; j++) { diff --git a/js/level.js b/js/level.js index a3a7e05..fa56bb4 100644 --- a/js/level.js +++ b/js/level.js @@ -421,7 +421,7 @@ const level = { const balance2 = level.spinner(2605, 500, 390, 25, 0.005) //falling const balance3 = level.spinner(2608, 1900, 584, 25, 0.005) //falling const balance4 = level.spinner(9300, 2205, 25, 380, 0.001) //exit - console.log(balance1) + level.custom = () => { button.query(); button.draw(); @@ -1789,7 +1789,7 @@ const level = { // spawn.mapRect(-1950, -400, 100, 25); spawn.mapRect(-3150, 50, 775, 100); spawn.mapRect(-2600, -250, 775, 100); - spawn.bodyRect(-1350, -200, 200, 200, 1, spawn.propsSlide); //weight + spawn.bodyRect(-1350, -100, 100, 100, 1, spawn.propsSlide); //weight spawn.bodyRect(-1800, 0, 300, 100, 1, spawn.propsHoist); //hoist cons[cons.length] = Constraint.create({ pointA: { @@ -1801,7 +1801,7 @@ const level = { length: 1 }); - spawn.bodyRect(400, 400, 200, 200, 1, spawn.propsSlide); //weight + spawn.bodyRect(400, 500, 100, 100, 1, spawn.propsSlide); //weight spawn.bodyRect(800, 600, 300, 100, 1, spawn.propsHoist); //hoist cons[cons.length] = Constraint.create({ pointA: { diff --git a/js/mods.js b/js/mods.js index 6c923b6..7a0e9dd 100644 --- a/js/mods.js +++ b/js/mods.js @@ -37,32 +37,31 @@ const mod = { } if (!found) return //if name not found don't give any mod } - mod.mods[index].effect(); //give specific mod mod.mods[index].count++ mod.totalCount++ //used in power up randomization game.updateModHUD(); } }, - giveBasicMod(index = 'random') { - // if (isNaN(index)) { //find index by name - // let found = false; - // for (let i = 0; i < mod.mods.length; i++) { - // if (index === mod.mods[i].name) { - // index = i; - // found = true; - // break; - // } - // } - // if (!found) return //if name not found don't give any mod - // } + // giveBasicMod(index = 'random') { + // // if (isNaN(index)) { //find index by name + // // let found = false; + // // for (let i = 0; i < mod.mods.length; i++) { + // // if (index === mod.mods[i].name) { + // // index = i; + // // found = true; + // // break; + // // } + // // } + // // if (!found) return //if name not found don't give any mod + // // } - mod.basicMods[index].effect(); //give specific mod - mod.mods[index].count++ - mod.totalCount++ //used in power up randomization - game.updateModHUD(); + // mod.basicMods[index].effect(); //give specific mod + // mod.mods[index].count++ + // mod.totalCount++ //used in power up randomization + // game.updateModHUD(); - }, + // }, haveGunCheck(name) { for (i = 0, len = b.inventory.length; i < len; i++) { if (b.guns[b.inventory[i]].name === name) return true @@ -1927,7 +1926,7 @@ const mod = { }, { name: "necrophoresis", - description: "if the mob foam is stuck to dies
foam grows and splits into 3 copies", + description: "foam bullets grow and split into 3 copies
when the mob they are stuck to dies", maxCount: 1, count: 0, allowed() { diff --git a/js/spawn.js b/js/spawn.js index 3228e14..74c95c9 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -781,7 +781,7 @@ const spawn = { stiffness: attachmentStiffness, damping: 0.01 }); - console.log(consBB[consBB.length - 1]) + // console.log(consBB[consBB.length - 1]) } }, timeSkipBoss(x, y, radius = 55) { diff --git a/todo.txt b/todo.txt index b1e2400..6773626 100644 --- a/todo.txt +++ b/todo.txt @@ -1,15 +1,7 @@ -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 - -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?