From 89d0ea18a70561eee162067afe32505d2d457e24 Mon Sep 17 00:00:00 2001 From: landgreen Date: Tue, 28 Jan 2020 05:50:00 -0800 Subject: [PATCH] added allowed requirements for mod selection --- js/bullets.js | 112 ++++++++++++++++++++++++++++++++++++++++++++++++- js/index.js | 17 ++++++++ js/powerups.js | 37 ++++++++-------- 3 files changed, 146 insertions(+), 20 deletions(-) diff --git a/js/bullets.js b/js/bullets.js index 6184ae3..e6d177b 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -33,6 +33,7 @@ const b = { modCollisionImmuneCycles: null, modBlockDmg: null, isModPiezo: null, + isModFastDrones: null, setModDefaults() { b.modCount = 0; b.modFireRate = 1; @@ -44,6 +45,7 @@ const b = { b.modHealthDrain = 0; b.modNoAmmo = 0; b.isModBulletsLastLonger = 1; + b.isModFastDrones = false; b.isModImmortal = false; b.modSpores = 0; b.modAcidDmg = 0; @@ -86,6 +88,9 @@ const b = { description: `your bullets are +13% larger
increased mass and physical damage`, count: 0, maxCount: 9, + allowed() { + return true + }, effect() { b.modBulletSize += 0.13 } @@ -95,6 +100,9 @@ const b = { description: "each bullet does extra chemical damage
only active when you are above 90% health", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModAcidDmg = true; b.modOnHealthChange(); @@ -105,6 +113,9 @@ const b = { description: "5x physical damage to unaware enemies
unaware enemies don't have a health bar", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModCrit = true; } @@ -114,6 +125,9 @@ const b = { description: "do up to 33% more damage at a distance
increase maxes out at about 40 steps away", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModFarAwayDmg = true; //used in mob.damage() } @@ -123,6 +137,9 @@ const b = { description: "do extra damage at low health
up to 50% increase when near death", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModLowHealthDmg = true; //used in mob.damage() } @@ -132,6 +149,9 @@ const b = { description: "the radius of explosions are +20% larger
immune to harm from explosions", maxCount: 3, count: 0, + allowed() { + return true + }, effect: () => { b.modExplosionRadius += 0.2; b.isModImmuneExplosion = true; @@ -142,6 +162,9 @@ const b = { description: "your delay after firing is +14% shorter", maxCount: 3, count: 0, + allowed() { + return true + }, effect() { b.modFireRate *= 0.86 } @@ -151,6 +174,9 @@ const b = { description: "use 50% less ammo when crouching", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.modNoAmmo = 1 } @@ -160,6 +186,9 @@ const b = { description: "your bullets last +33% longer", maxCount: 3, count: 0, + allowed() { + return true + }, effect() { b.isModBulletsLastLonger += 0.33 } @@ -169,6 +198,9 @@ const b = { description: "enemies discharge spores on death
+11% chance", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { b.modSpores += 0.11; for (let i = 0; i < 10; i++) { @@ -181,6 +213,9 @@ const b = { description: "a bot defends the space around you
uses a short range laser that drains energy", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { b.modLaserBotCount++; b.laserBot(); @@ -191,6 +226,9 @@ const b = { description: "a bot fires nails at targets in line of sight", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { b.modNailBotCount++; b.nailBot(); @@ -201,6 +239,9 @@ const b = { description: "rebuild your broken parts as drones
chance to occur after being harmed", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModDroneOnDamage = true; for (let i = 0; i < 3; i++) { @@ -213,6 +254,9 @@ const b = { description: "when your field blocks it also does damage", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { b.modBlockDmg += 0.7 //if you change this value also update the for loop in the electricity graphics in mech.pushMass } @@ -222,6 +266,9 @@ const b = { description: "using your first gun reduces harm
scales by 10% for each gun in your inventory", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModEntanglement = true } @@ -231,6 +278,9 @@ const b = { description: "jump higher and move faster
reduced harm from falling ", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { // good with melee builds, content skipping builds b.modSquirrelFx = 1.2; mech.Fx = 0.015 * b.modSquirrelFx; @@ -242,6 +292,9 @@ const b = { description: "unable to collide with enemies for +2 second
activates after being harmed from a collision", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { b.modCollisionImmuneCycles += 120; mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles @@ -252,6 +305,9 @@ const b = { description: "after touching enemies, they are annihilated", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModAnnihilation = true } @@ -261,6 +317,9 @@ const b = { description: "colliding with enemies fills your energy", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModPiezo = true; mech.fieldMeter = mech.fieldEnergyMax; @@ -271,6 +330,9 @@ const b = { description: "gain energy proportional to damage done", maxCount: 3, count: 0, + allowed() { + return true + }, effect() { b.modEnergySiphon += 0.15; mech.fieldMeter = mech.fieldEnergyMax @@ -281,6 +343,9 @@ const b = { description: "heal proportional to damage done", maxCount: 3, count: 0, + allowed() { + return true + }, effect() { b.modHealthDrain += 0.015; } @@ -290,6 +355,9 @@ const b = { description: "charge energy +33% beyond your maximum", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { mech.fieldEnergyMax += 0.33 mech.fieldMeter += 0.33 @@ -300,6 +368,9 @@ const b = { description: "heal +33% beyond your max health", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { mech.maxHealth += 0.33 mech.addHealth(0.33) @@ -310,6 +381,9 @@ const b = { description: "healing power ups trigger one extra time.", maxCount: 9, count: 0, + allowed() { + return true + }, effect() { b.modRecursiveHealing += 1 } @@ -319,6 +393,9 @@ const b = { description: "power ups fill your energy and heal for +5%", maxCount: 1, count: 0, + allowed() { + return true + }, effect: () => { b.isModMassEnergy = true // used in mech.grabPowerUp mech.fieldMeter = mech.fieldEnergyMax @@ -329,6 +406,9 @@ const b = { description: "after dying, continue in an alternate reality
guns, ammo, field, and mods are randomized", maxCount: 1, count: 0, + allowed() { + return true + }, effect() { b.isModImmortal = true; } @@ -338,6 +418,9 @@ const b = { description: "20% chance for double power ups to drop
one fewer choice when selecting power ups", maxCount: 1, count: 0, + allowed() { + return true + }, effect: () => { b.isModBayesian = 0.20; } @@ -347,6 +430,9 @@ const b = { description: "one extra choice when selecting power ups", maxCount: 1, count: 0, + allowed() { + return true + }, effect: () => { b.isModFourOptions = true; } @@ -356,6 +442,9 @@ const b = { description: "remove all current mods
spawn new mods to replace them", maxCount: 1, count: 0, + allowed() { + return (b.modCount > 6) + }, effect: () => { for (let i = 0; i < b.modCount; i++) { // spawn new mods powerUps.spawn(mech.pos.x, mech.pos.y, "mod"); @@ -364,12 +453,25 @@ const b = { //have state is checked in mech.death() } }, + { + name: "accelerated drones", //7 + description: "your drones accelerate 50% faster", + maxCount: 1, + count: 0, + allowed() { + return b.haveGunCheck("drones") + }, + effect() { + b.isModFastDrones = true + } + }, ], giveMod(index = 'random') { if (index === 'random') { let options = []; for (let i = 0; i < b.mods.length; i++) { - if (b.mods[i].count < b.mods[i].maxCount) options.push(i); + if (b.mods[i].count < b.mods[i].maxCount && b.mods[i].allowed()) + options.push(i); } // give a random mod from the mods I don't have @@ -384,6 +486,12 @@ const b = { game.updateModHUD(); } }, + haveGunCheck(name) { + for (i = 0, len = b.inventory.length; i < len; i++) { + if (b.guns[b.inventory[i]].name === name) return true + } + return false + }, activeGun: null, //current gun in use by player inventoryGun: 0, inventory: [], //list of what guns player has // 0 starts with basic gun @@ -817,7 +925,7 @@ const b = { }, drone(speed = 1) { const me = bullet.length; - const THRUST = 0.0015 + const THRUST = b.isModFastDrones ? 0.003 : 0.0015 const dir = mech.angle + 0.2 * (Math.random() - 0.5); const RADIUS = (4.5 + 3 * Math.random()) * b.modBulletSize bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 8, RADIUS, { diff --git a/js/index.js b/js/index.js index e555883..1f9db99 100644 --- a/js/index.js +++ b/js/index.js @@ -2,6 +2,23 @@ /* TODO: ******************************************* ***************************************************** +field that pushes everything back, and can destroy smaller blocks + converts blocks into ammo power ups + +give mods a requirement + check for require before choosing mods displayed in selection + require: { + type: "gun" + name: "drone" + } + drones move faster + require: { + type: "mod" + name: "high explosives" + } + immunity to explosions + remove immunity from high explosives, but buff explosion radius a bit + mod: make player invisible when... use the flag from phase field diff --git a/js/powerups.js b/js/powerups.js index dfaf450..c6614a0 100644 --- a/js/powerups.js +++ b/js/powerups.js @@ -98,7 +98,7 @@ const powerUps = { return 45; }, effect() { - function doNotHave(who, skip1 = -1, skip2 = -1, skip3 = -1) { + function pick(who, skip1 = -1, skip2 = -1, skip3 = -1) { let options = []; for (let i = 1; i < who.length; i++) { if (i !== mech.fieldMode && i !== skip1 && i !== skip2 && i !== skip3) options.push(i); @@ -106,19 +106,19 @@ const powerUps = { if (options.length > 0) return options[Math.floor(Math.random() * options.length)] } - let choice1 = doNotHave(mech.fieldUpgrades) - let choice2 = doNotHave(mech.fieldUpgrades, choice1) + let choice1 = pick(mech.fieldUpgrades) + let choice2 = pick(mech.fieldUpgrades, choice1) let choice3 = -1 if (choice1 > -1) { 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) { - choice3 = doNotHave(mech.fieldUpgrades, choice1, choice2) + choice3 = pick(mech.fieldUpgrades, choice1, choice2) if (choice3 > -1) text += `
  ${mech.fieldUpgrades[choice3].name}
${mech.fieldUpgrades[choice3].description}
` } if (b.isModFourOptions) { - let choice4 = doNotHave(mech.fieldUpgrades, choice1, choice2, choice3) + let choice4 = pick(mech.fieldUpgrades, choice1, choice2, choice3) if (choice4 > -1) text += `
  ${mech.fieldUpgrades[choice4].name}
${mech.fieldUpgrades[choice4].description}
` } // text += `
${game.SVGrightMouse} activate the shield with the right mouse
fields shield you from damage
and let you pick up and throw blocks
` @@ -136,12 +136,13 @@ const powerUps = { return 42; }, effect() { - function doNotHave(who, skip1 = -1, skip2 = -1, skip3 = -1) { + function pick(skip1 = -1, skip2 = -1, skip3 = -1) { let options = []; - for (let i = 0; i < who.length; i++) { - if (who[i].count < who[i].maxCount && + for (let i = 0; i < b.mods.length; i++) { + if ( + b.mods[i].count < b.mods[i].maxCount && i !== skip1 && i !== skip2 && i !== skip3 && - (b.modCount > 4 || who[i].name !== "Born rule") + b.mods[i].allowed() ) { options.push(i); } @@ -149,19 +150,19 @@ const powerUps = { if (options.length > 0) return options[Math.floor(Math.random() * options.length)] } - let choice1 = doNotHave(b.mods) - let choice2 = doNotHave(b.mods, choice1) + let choice1 = pick() + let choice2 = pick(choice1) let choice3 = -1 if (choice1 > -1) { 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) { - choice3 = doNotHave(b.mods, choice1, choice2) + choice3 = pick(choice1, choice2) if (choice3 > -1) text += `
  ${b.mods[choice3].name}
${b.mods[choice3].description}
` } if (b.isModFourOptions) { - let choice4 = doNotHave(b.mods, choice1, choice2, choice3) + let choice4 = pick(choice1, choice2, choice3) if (choice4 > -1) text += `
  ${b.mods[choice4].name}
${b.mods[choice4].description}
` } document.getElementById("choose-grid").innerHTML = text @@ -178,7 +179,7 @@ const powerUps = { return 35; }, effect() { - function doNotHave(who, skip1 = -1, skip2 = -1, skip3 = -1) { + function pick(who, skip1 = -1, skip2 = -1, skip3 = -1) { let options = []; for (let i = 0; i < who.length; i++) { if (!who[i].have && i !== skip1 && i !== skip2 && i !== skip3) options.push(i); @@ -186,19 +187,19 @@ const powerUps = { if (options.length > 0) return options[Math.floor(Math.random() * options.length)] } - let choice1 = doNotHave(b.guns) - let choice2 = doNotHave(b.guns, choice1) + let choice1 = pick(b.guns) + let choice2 = pick(b.guns, choice1) let choice3 = -1 if (choice1 > -1) { 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) { - choice3 = doNotHave(b.guns, choice1, choice2) + choice3 = pick(b.guns, choice1, choice2) if (choice3 > -1) text += `
  ${b.guns[choice3].name}
${b.guns[choice3].description}
` } if (b.isModFourOptions) { - let choice4 = doNotHave(b.guns, choice1, choice2, choice3) + let choice4 = pick(b.guns, choice1, choice2, choice3) if (choice4 > -1) text += `
  ${b.guns[choice4].name}
${b.guns[choice4].description}
` } document.getElementById("choose-grid").innerHTML = text