diff --git a/js/bullets.js b/js/bullets.js
index 678f3e3..ef47558 100644
--- a/js/bullets.js
+++ b/js/bullets.js
@@ -42,65 +42,26 @@ const b = {
modLaserFieldDrain: null,
isModNoAmmo: null,
isModAmmoFromHealth: null,
- mobDieAtHealth: null,
+ modMobDieAtHealth: null,
isModEnergyRecovery: null,
isModHealthRecovery: null,
- setModDefaults() {
- b.modCount = 0;
- b.modFireRate = 1;
- b.modExplosionRadius = 1;
- b.isModImmuneExplosion = false;
- b.modBulletSize = 1;
- b.isModDroneOnDamage = false;
- b.modEnergySiphon = 0;
- b.modHealthDrain = 0;
- b.modNoAmmo = 0;
- b.isModBulletsLastLonger = 1;
- b.isModDroneCollide = true;
- b.isModFastSpores = false
- b.isModImmortal = false;
- b.modSpores = 0;
- b.modAcidDmg = 0;
- b.isModAcidDmg = false;
- game.playerDmgColor = "rgba(0,0,0,0.7)"
- b.isModAnnihilation = false;
- b.modRecursiveHealing = 1;
- b.modSquirrelFx = 1;
- b.isModCrit = false;
- b.isModBayesian = 0;
- b.isModFourOptions = false;
- b.isModLowHealthDmg = false;
- b.isModFarAwayDmg = false;
- b.isModEntanglement = false;
- b.isModMassEnergy = false;
- b.modLaserBotCount = 0;
- b.modNailBotCount = 0;
- b.modBlockDmg = 0;
- b.isModPiezo = false;
- b.isModStomp = false;
- b.modCollisionImmuneCycles = 30;
- b.modSuperBallNumber = 4;
- b.modLaserReflections = 2;
- b.modLaserDamage = 0.05;
- b.modLaserFieldDrain = 0.002;
- b.isModNoAmmo = false;
- b.isModAmmoFromHealth = 0;
- b.mobDieAtHealth = 0.05;
- b.isModEnergyRecovery = false;
- b.isModHealthRecovery = false;
- mech.fieldRange = 175;
- mech.Fx = 0.016; //if this changes update the values in definePlayerMass
- mech.jumpForce = 0.42; //was 0.38 at 0.0019 gravity
- mech.maxHealth = 1;
- mech.fieldEnergyMax = 1;
- for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak
- if (b.guns[i].name === "flak") b.guns[i].ammoPack = b.guns[i].defaultAmmoPack;
- }
- for (let i = 0; i < b.mods.length; i++) {
+ isModEnergyLoss: null,
+ removeAllMods() {
+ for (let i = 0, len = b.mods.length; i < len; i++) {
+ b.mods[i].remove();
b.mods[i].count = 0
}
+ b.modCount = 0;
+
},
- modOnHealthChange() {
+ setModDefaults() {
+ for (let i = 0, len = b.mods.length; i < len; i++) {
+ if (b.mods[i].count) b.mods[i].remove();
+ b.mods[i].count = 0
+ }
+ b.modCount = 0;
+ },
+ modOnHealthChange() { //used with acid mod
if (b.isModAcidDmg && mech.health > 0.8) {
game.playerDmgColor = "rgba(0,80,80,0.9)"
b.modAcidDmg = 0.9
@@ -119,6 +80,9 @@ const b = {
},
effect() {
b.modBulletSize += 0.13
+ },
+ remove() {
+ b.modBulletSize = 1;
}
},
{
@@ -127,11 +91,16 @@ const b = {
maxCount: 1,
count: 0,
allowed() {
- return mech.health > 0.8
+ return mech.health > 0.8 || level.isBuildRun
},
effect() {
b.isModAcidDmg = true;
b.modOnHealthChange();
+ },
+ remove() {
+ b.modAcidDmg = 0;
+ b.isModAcidDmg = false;
+ game.playerDmgColor = "rgba(0,0,0,0.7)"
}
},
{
@@ -144,6 +113,9 @@ const b = {
},
effect() {
b.isModCrit = true;
+ },
+ remove() {
+ b.isModCrit = false;
}
},
{
@@ -156,6 +128,9 @@ const b = {
},
effect() {
b.isModFarAwayDmg = true; //used in mob.damage()
+ },
+ remove() {
+ b.isModFarAwayDmg = false;
}
},
{
@@ -168,6 +143,9 @@ const b = {
},
effect() {
b.isModLowHealthDmg = true; //used in mob.damage()
+ },
+ remove() {
+ b.isModLowHealthDmg = false;
}
},
{
@@ -180,11 +158,14 @@ const b = {
},
effect: () => {
b.modExplosionRadius += 0.2;
+ },
+ remove() {
+ b.modExplosionRadius = 1;
}
},
{
name: "electric reactive armour",
- description: "explosions do you no harm, but drain energy",
+ description: "explosions do no harm
explosions drain energy",
maxCount: 1,
count: 0,
allowed() {
@@ -192,6 +173,10 @@ const b = {
},
effect: () => {
b.isModImmuneExplosion = true;
+ },
+ remove() {
+ b.isModImmuneExplosion = false;
+
}
},
{
@@ -204,6 +189,9 @@ const b = {
},
effect() {
b.modFireRate *= 0.86
+ },
+ remove() {
+ b.modFireRate = 1;
}
},
{
@@ -216,6 +204,9 @@ const b = {
},
effect() {
b.modNoAmmo = 1
+ },
+ remove() {
+ b.modNoAmmo = 0;
}
},
{
@@ -228,6 +219,9 @@ const b = {
},
effect() {
b.isModBulletsLastLonger += 0.33
+ },
+ remove() {
+ b.isModBulletsLastLonger = 1;
}
},
{
@@ -239,7 +233,10 @@ const b = {
return true
},
effect: () => {
- b.mobDieAtHealth = 0.15
+ b.modMobDieAtHealth = 0.15
+ },
+ remove() {
+ b.modMobDieAtHealth = 0.05;
}
},
{
@@ -255,6 +252,9 @@ const b = {
for (let i = 0; i < 10; i++) {
b.spore(player)
}
+ },
+ remove() {
+ b.modSpores = 0;
}
},
{
@@ -268,6 +268,9 @@ const b = {
effect() {
b.modLaserBotCount++;
b.laserBot();
+ },
+ remove() {
+ b.modLaserBotCount = 0;
}
},
{
@@ -281,6 +284,9 @@ const b = {
effect() {
b.modNailBotCount++;
b.nailBot();
+ },
+ remove() {
+ b.modNailBotCount = 0;
}
},
{
@@ -296,6 +302,9 @@ const b = {
for (let i = 0; i < 4; i++) {
b.drone() //spawn drone
}
+ },
+ remove() {
+ b.isModDroneOnDamage = false;
}
},
{
@@ -308,6 +317,9 @@ const b = {
},
effect() {
b.modBlockDmg += 0.7 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
+ },
+ remove() {
+ b.modBlockDmg = 0;
}
},
{
@@ -319,7 +331,10 @@ const b = {
return mech.fieldUpgrades[mech.fieldMode].name !== "time dilation field" && mech.fieldUpgrades[mech.fieldMode].name !== "phase decoherence field"
},
effect() {
- mech.fieldRange = 175 * 1.4 //175 is default
+ mech.fieldRange = 175 * 1.4
+ },
+ remove() {
+ mech.fieldRange = 175;
}
},
{
@@ -332,10 +347,13 @@ const b = {
},
effect() {
b.isModEntanglement = true
+ },
+ remove() {
+ b.isModEntanglement = false;
}
},
{
- name: "waste energy recycling",
+ name: "waste energy recovery",
description: "regen 7% of max energy every second
active for 5 seconds after a mob dies",
maxCount: 1,
count: 0,
@@ -344,10 +362,13 @@ const b = {
},
effect() {
b.isModEnergyRecovery = true;
+ },
+ remove() {
+ b.isModEnergyRecovery = false;
}
},
{
- name: "waste scrap recycling",
+ name: "scrap recycling",
description: "regen up to 1% of max health every second
active for 5 seconds after a mob dies",
maxCount: 1,
count: 0,
@@ -356,6 +377,24 @@ const b = {
},
effect() {
b.isModHealthRecovery = true;
+ },
+ remove() {
+ b.isModHealthRecovery = false;
+ }
+ },
+ {
+ name: "acute stress response",
+ description: "increase damage by 50%
no energy for 5 seconds after a mob dies",
+ maxCount: 1,
+ count: 0,
+ allowed() {
+ return b.isModHealthRecovery
+ },
+ effect() {
+ b.isModEnergyLoss = true;
+ },
+ remove() {
+ b.isModEnergyLoss = false;
}
},
{
@@ -370,6 +409,11 @@ const b = {
b.modSquirrelFx += 0.2;
mech.Fx = 0.016 * b.modSquirrelFx;
mech.jumpForce += 0.038;
+ },
+ remove() {
+ b.modSquirrelFx = 1;
+ mech.Fx = 0.016; //if this changes update the values in definePlayerMass
+ mech.jumpForce = 0.42; //was 0.38 at 0.0019 gravity
}
},
{
@@ -382,6 +426,9 @@ const b = {
},
effect() {
b.isModStomp = true
+ },
+ remove() {
+ b.isModStomp = false;
}
},
{
@@ -395,6 +442,9 @@ const b = {
effect() {
b.modCollisionImmuneCycles += 120;
mech.collisionImmune = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
+ },
+ remove() {
+ b.modCollisionImmuneCycles = 30;
}
},
{
@@ -407,6 +457,9 @@ const b = {
},
effect() {
b.isModAnnihilation = true
+ },
+ remove() {
+ b.isModAnnihilation = false;
}
},
{
@@ -420,6 +473,9 @@ const b = {
effect() {
b.isModPiezo = true;
mech.fieldMeter = mech.fieldEnergyMax;
+ },
+ remove() {
+ b.isModPiezo = false;
}
},
{
@@ -433,6 +489,9 @@ const b = {
effect() {
b.modEnergySiphon += 0.15;
mech.fieldMeter = mech.fieldEnergyMax
+ },
+ remove() {
+ b.modEnergySiphon = 0;
}
},
{
@@ -445,6 +504,9 @@ const b = {
},
effect() {
b.modHealthDrain += 0.015;
+ },
+ remove() {
+ b.modHealthDrain = 0;
}
},
{
@@ -458,6 +520,9 @@ const b = {
effect() {
mech.fieldEnergyMax += 0.5
mech.fieldMeter += 0.5
+ },
+ remove() {
+ mech.fieldEnergyMax = 1;
}
},
{
@@ -471,6 +536,9 @@ const b = {
effect() {
mech.maxHealth += 0.50
mech.addHealth(0.50)
+ },
+ remove() {
+ mech.maxHealth = 1;
}
},
{
@@ -483,6 +551,9 @@ const b = {
},
effect() {
b.modRecursiveHealing += 1
+ },
+ remove() {
+ b.modRecursiveHealing = 1;
}
},
{
@@ -496,6 +567,9 @@ const b = {
effect: () => {
b.isModMassEnergy = true // used in mech.grabPowerUp
mech.fieldMeter = mech.fieldEnergyMax * 2
+ },
+ remove() {
+ b.isModMassEnergy = false;
}
},
{
@@ -508,6 +582,9 @@ const b = {
},
effect() {
b.isModImmortal = true;
+ },
+ remove() {
+ b.isModImmortal = false;
}
},
{
@@ -520,6 +597,9 @@ const b = {
},
effect: () => {
b.isModBayesian = 0.20;
+ },
+ remove() {
+ b.isModBayesian = 0;
}
},
{
@@ -532,6 +612,9 @@ const b = {
},
effect: () => {
b.isModAmmoFromHealth = 0.03;
+ },
+ remove() {
+ b.isModAmmoFromHealth = 0;
}
},
{
@@ -552,6 +635,9 @@ const b = {
powerUps.spawn(mech.pos.x, mech.pos.y, "heal");
if (Math.random() < b.isModBayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "heal");
}
+ },
+ remove() {
+ b.isModNoAmmo = false;
}
},
{
@@ -564,6 +650,9 @@ const b = {
},
effect: () => {
b.isModFourOptions = true;
+ },
+ remove() {
+ b.isModFourOptions = false;
}
},
{
@@ -582,6 +671,9 @@ const b = {
}
b.setModDefaults(); // remove all mods
//have state is checked in mech.death()
+ },
+ remove() {
+ //nothing to undo
}
},
{
@@ -594,6 +686,9 @@ const b = {
},
effect() {
b.isModDroneCollide = true
+ },
+ remove() {
+ b.isModDroneCollide = true;
}
},
{
@@ -606,6 +701,9 @@ const b = {
},
effect() {
b.isModFastSpores = true
+ },
+ remove() {
+ b.isModFastSpores = false
}
},
{
@@ -618,6 +716,9 @@ const b = {
},
effect() {
b.modSuperBallNumber++
+ },
+ remove() {
+ b.modSuperBallNumber = 4;
}
},
{
@@ -632,6 +733,11 @@ const b = {
b.modLaserReflections++;
b.modLaserDamage += 0.010; //base is 0.05
b.modLaserFieldDrain += 0.0004 //base is 0.002
+ },
+ remove() {
+ b.modLaserReflections = 2;
+ b.modLaserDamage = 0.05;
+ b.modLaserFieldDrain = 0.002;
}
},
{
@@ -646,6 +752,11 @@ const b = {
for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak
if (b.guns[i].name === "flak") b.guns[i].ammoPack = b.guns[i].defaultAmmoPack * (2 + this.count);
}
+ },
+ remove() {
+ for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak
+ if (b.guns[i].name === "flak") b.guns[i].ammoPack = b.guns[i].defaultAmmoPack;
+ }
}
},
// {
@@ -1551,7 +1662,7 @@ const b = {
name: "fléchettes", //3
description: "fire a volley of precise high velocity needles",
ammo: 0,
- ammoPack: 20,
+ ammoPack: 22,
have: false,
isStarterGun: true,
count: 0, //used to track how many shots are in a volley before a big CD
@@ -1572,7 +1683,7 @@ const b = {
const me = bullet.length;
bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 45 * b.modBulletSize, 1.4 * b.modBulletSize, b.fireAttributes(mech.angle));
bullet[me].endCycle = game.cycle + 180;
- bullet[me].dmg = 1.1;
+ bullet[me].dmg = 1.15;
bullet[me].do = function () {
if (this.speed < 10) this.force.y += this.mass * 0.0003; //no gravity until it slows don to improve aiming
};
diff --git a/js/game.js b/js/game.js
index d34b5e1..9ee2aff 100644
--- a/js/game.js
+++ b/js/game.js
@@ -436,12 +436,12 @@ const game = {
if (b.guns[i].ammo != Infinity) b.guns[i].ammo = 0;
}
b.activeGun = null;
- b.setModDefaults(); //remove mods
+
+ b.removeAllMods(); //sets mods to defauls values
game.updateModHUD();
mech.maxHealth = 1
mech.fieldEnergyMax = 1
game.paused = false;
- build.isShowingBuilds = false
engine.timing.timeScale = 1;
game.fpsCap = game.fpsCapDefault;
game.makeGunHUD();
@@ -460,6 +460,7 @@ const game = {
game.CDScale = 1;
game.difficulty = 0;
game.difficultyMode = Number(document.getElementById("difficulty-select").value)
+ level.isBuildRun = false;
if (game.difficultyMode === 0) {
game.isEasyMode = true;
game.difficultyMode = 1
@@ -490,7 +491,6 @@ const game = {
document.getElementById("build-grid").style.display = "none"
document.getElementById("pause-grid-left").style.display = "none"
document.getElementById("pause-grid-right").style.display = "none"
- isShowingBuilds = false
document.getElementById("splash").style.display = "inline";
document.getElementById("dmg").style.display = "none";
document.getElementById("health-bg").style.display = "none";
@@ -499,9 +499,11 @@ const game = {
fpsInterval: 0, //set in startGame
then: null,
startGame() {
- level.isBuildRun = false; //can get set back to true in build.startBuildRun()
+ if (!level.isBuildRun) { //if a build run logic flow returns to "build-button").addEventListener
+ document.body.style.cursor = "none";
+ document.body.style.overflow = "hidden"
+ }
game.onTitlePage = false;
- document.body.style.overflow = "hidden"
document.getElementById("choose-grid").style.display = "none"
document.getElementById("build-grid").style.display = "none"
document.getElementById("info").style.display = "none";
@@ -529,7 +531,6 @@ const game = {
// // mech.throwBlock();
// };
- document.body.style.cursor = "none";
if (game.firstRun) {
mech.spawn(); //spawns the player
b.setModDefaults(); //doesn't run on reset so that gun mods carry over to new runs
@@ -674,6 +675,9 @@ const game = {
if (b.isModHealthRecovery) {
mech.addHealth(0.01)
}
+ if (b.isModEnergyLoss) {
+ mech.fieldMeter = 0.05;
+ }
}
diff --git a/js/index.js b/js/index.js
index 387aa9f..3534708 100644
--- a/js/index.js
+++ b/js/index.js
@@ -14,9 +14,13 @@ const cat = {
//build build grid display
const build = {
- isShowingBuilds: false,
- list: [],
choosePowerUp(who, index, type) {
+
+ // mech.setField(build.list[i].index)
+ // b.giveGuns(build.list[i].index)
+ // b.giveMod(build.list[i].index)
+
+
if (type === "field" || type === "gun") {
let isDeselect = false
//if already click, toggle off
@@ -30,6 +34,7 @@ const build = {
}
//check if trying to get a second field
if (type === "field") {
+ mech.setField(index)
for (let i = 0; i < build.list.length; i++) {
if (build.list[i].type === "field") { //if already click, toggle off
build.list[i].who.style.backgroundColor = "#fff"
@@ -79,9 +84,9 @@ const build = {
// document.title = `effective starting level: ${build.list.length * game.difficultyMode}`
// build.calculateCustomDifficulty()
},
- makeGrid() {
+ populateGrid() {
let text = `
-