working on giving custom mods requirements (in progress, buggy)

This commit is contained in:
landgreen
2020-02-16 14:28:56 -08:00
parent be45c4d5d3
commit 32733909ab
7 changed files with 262 additions and 156 deletions

View File

@@ -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: "<strong class='color-e'>explosions</strong> do you no <strong>harm</strong>, but drain <strong class='color-f'>energy</strong>",
description: "<strong class='color-e'>explosions</strong> do no <strong>harm</strong><br> <strong class='color-e'>explosions</strong> drain <strong class='color-f'>energy</strong>",
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 <strong>7%</strong> of max <strong class='color-f'>energy</strong> every second<br>active for <strong>5 seconds</strong> after a mob <strong>dies</strong>",
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 <strong>1%</strong> of max <strong class='color-h'>health</strong> every second<br>active for <strong>5 seconds</strong> after a mob <strong>dies</strong>",
maxCount: 1,
count: 0,
@@ -356,6 +377,24 @@ const b = {
},
effect() {
b.isModHealthRecovery = true;
},
remove() {
b.isModHealthRecovery = false;
}
},
{
name: "acute stress response",
description: "increase <strong class='color-d'>damage</strong> by <strong>50%</strong><br>no <strong class='color-f'>energy</strong> for <strong>5 seconds</strong> after a mob <strong>dies</strong>",
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 <strong>precise</strong> 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
};

View File

@@ -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;
}
}

View File

@@ -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 = `
<div style="display: flex; justify-content: space-around; align-items: center;">
<div style="display: flex; justify-content: space-around; align-items: center;">
<svg class="SVG-button" onclick="build.startBuildRun()" width="115" height="51">
<g stroke='none' fill='#333' stroke-width="2" font-size="40px" font-family="Ariel, sans-serif">
<text x="18" y="38">start</text>
@@ -94,7 +99,7 @@ const build = {
</svg>
</div>
<div style="align-items: center; text-align:center; font-size: 1.00em; line-height: 220%;background-color:#c4ccd8;">
<div>starting level: <input id='starting-level' type="number" step="1" value="0" min="0" max="99"></div>
<div>starting level: <input id='starting-level' type="number" step="1" value="0" min="0" max="99"></div>
<label for="difficulty-select" title="effects: number of mobs, damage done by mobs, damage done to mobs, mob speed, heal effects">difficulty:</label>
<select name="difficulty-select" id="difficulty-select-custom">
<option value="0">easy</option>
@@ -110,16 +115,21 @@ const build = {
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'gun')"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[i].name}</div> ${b.guns[i].description}</div>`
}
for (let i = 0, len = b.mods.length; i < len; i++) {
if (b.mods[i].name === "Born rule" || b.mods[i].name === "+1 cardinality" || b.mods[i].name === "leveraged investment") {
if (
!b.mods[i].allowed() ||
b.mods[i].name === "+1 cardinality" || b.mods[i].name === "leveraged investment"
) {
text += `<div class="build-grid-module" style="opacity:0.3;"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
} else {
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
}
}
const el = document.getElementById("build-grid")
el.innerHTML = text
el.style.display = "none"
document.getElementById("build-grid").innerHTML = text
},
reset() {
build.populateGrid();
document.getElementById("difficulty-select-custom").value = localSettings.difficultyMode
document.getElementById("difficulty-select-custom").addEventListener("input", () => {
document.getElementById("difficulty-select").value = document.getElementById("difficulty-select-custom").value
game.difficultyMode = Number(document.getElementById("difficulty-select-custom").value)
@@ -127,14 +137,24 @@ const build = {
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
// build.calculateCustomDifficulty()
});
},
reset() {
build.list = []
build.makeGrid();
document.getElementById("build-grid").style.display = "grid"
// build.calculateCustomDifficulty()
document.getElementById("difficulty-select-custom").value = localSettings.difficultyMode
},
startBuildRun() {
spawn.setSpawnList(); //gives random mobs, not starter mobs
spawn.setSpawnList();
const increase = Number(document.getElementById("starting-level").value) * game.difficultyMode
level.levelsCleared += increase;
level.difficultyIncrease(increase) //increase difficulty based on modes
document.body.style.cursor = "none";
document.body.style.overflow = "hidden"
document.getElementById("build-grid").style.display = "none"
game.paused = false;
requestAnimationFrame(cycle);
},
pauseGrid() {
// let text = `<div class="pause-grid-module" style="border:0px;background:none;"></div>`
let text = `
@@ -161,7 +181,11 @@ const build = {
text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[mech.fieldMode].name}</div> ${mech.fieldUpgrades[mech.fieldMode].description}</div>`
for (let i = 0, len = b.mods.length; i < len; i++) {
if (b.mods[i].count > 0) {
text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
if (b.mods[i].count === 1) {
text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
} else {
text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name} (${b.mods[i].count}x)</div> ${b.mods[i].description}</div>`
}
countMods++
}
}
@@ -178,59 +202,20 @@ const build = {
document.getElementById("pause-grid-left").style.display = "none"
document.getElementById("pause-grid-right").style.display = "none"
},
// calculateCustomDifficulty() {
// let difficulty = build.list.length * game.difficultyMode
// if (game.difficultyMode === 0) difficulty = build.list.length * 1 - 6
// if (game.difficultyMode === 4) difficulty = build.list.length * 4 + 8
// document.getElementById("starting-level").innerHTML = `starting difficulty: <strong style="font-size:1.05em;">${difficulty}</strong>`
// },
startBuildRun() {
spawn.setSpawnList(); //gives random mobs, not starter mobs
spawn.setSpawnList();
game.startGame();
level.isBuildRun = true;
const increase = Number(document.getElementById("starting-level").value) * game.difficultyMode
level.levelsCleared += increase;
level.difficultyIncrease(increase) //increase difficulty based on modes
level.onLevel = 1;
build.givePowerUps();
},
givePowerUps() {
for (let i = 0; i < build.list.length; i++) {
if (build.list[i].type === "field") {
mech.setField(build.list[i].index)
} else if (build.list[i].type === "gun") {
b.giveGuns(build.list[i].index)
} else if (build.list[i].type === "mod") {
b.giveMod(build.list[i].index)
}
}
}
}
build.makeGrid();
document.getElementById("build-button").addEventListener("click", () => {
document.getElementById("build-button").addEventListener("click", () => { //setup build run
document.getElementById("build-button").style.display = "none";
const el = document.getElementById("build-grid")
if (build.isShowingBuilds) {
el.style.display = "none"
build.isShowingBuilds = false
document.body.style.overflow = "hidden"
document.getElementById("info").style.display = 'inline'
} else {
build.list = []
build.reset()
// let text = '<p>The difficulty increases by one level for each power up you choose.<br> <button type="button" id="build-begin-button" onclick="build.startBuildRun()">Begin Run</button></p>'
build.isShowingBuilds = true
el.style.display = "grid"
document.body.style.overflowY = "scroll";
document.body.style.overflowX = "hidden";
document.getElementById("info").style.display = 'none'
}
// build.calculateCustomDifficulty()
el.style.display = "grid"
document.body.style.overflowY = "scroll";
document.body.style.overflowX = "hidden";
document.getElementById("info").style.display = 'none'
level.isBuildRun = true;
game.startGame(); //starts game, but pauses it
game.paused = true;
build.reset();
});
@@ -243,7 +228,6 @@ if (localSettings) {
game.difficultyMode = localSettings.difficultyMode
document.getElementById("difficulty-select").value = localSettings.difficultyMode
document.getElementById("difficulty-select-custom").value = localSettings.difficultyMode
if (localSettings.fpsCapDefault === 'max') {
game.fpsCapDefault = 999999999;
@@ -358,7 +342,6 @@ document.getElementById("body-damage").addEventListener("input", () => {
// difficulty-select-custom event listener is set in build.makeGrid
document.getElementById("difficulty-select").addEventListener("input", () => {
document.getElementById("difficulty-select-custom").value = document.getElementById("difficulty-select").value
game.difficultyMode = Number(document.getElementById("difficulty-select").value)
localSettings.difficultyMode = game.difficultyMode
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage

View File

@@ -17,8 +17,9 @@ const level = {
// b.giveGuns("laser")
// mech.setField("negative mass field")
// for (let i = 0; i < 9; i++) {
// b.giveMod("waste energy recycling");
// b.giveMod("field superposition");
// b.giveMod("waste energy recovery");
// b.giveMod("scrap recycling");
// b.giveMod("acute stress response");
// }
level.intro(); //starting level
@@ -37,7 +38,6 @@ const level = {
level[level.levels[level.onLevel]](); //picks the current map from the the levels array
level.levelAnnounce();
}
// if (level.isBuildRun) build.givePowerUps();
game.noCameraScroll();
game.setZoom();
level.addToWorld(); //add bodies to game engine
@@ -1261,7 +1261,7 @@ const level = {
level.defaultZoom = 1300
game.zoomTransition(level.defaultZoom)
document.body.style.backgroundColor = "#f2f5f3";
document.body.style.backgroundColor = "#dcdcde" //"#f2f5f3";
mech.setPosToSpawn(25, -60); //normal spawn
//mech.setPosToSpawn(-2000, -1700); // left ledge spawn
level.enter.x = mech.spawnPos.x - 50;

View File

@@ -940,13 +940,14 @@ const mobs = {
if (b.isModLowHealthDmg) dmg *= (3 / (2 + mech.health)) //up to 50% dmg at zero player health
// if (b.isModFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(1000, Math.min(3500, this.distanceToPlayer())) - 1000) * 0.01 //up to 50% dmg at max range of 3500
if (b.isModEnergyLoss) dmg *= 1.5;
if (b.isModFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(500, Math.min(3000, this.distanceToPlayer())) - 500) * 0.0067 //up to 50% dmg at max range of 3500
if (b.modEnergySiphon && dmg !== Infinity) mech.fieldMeter += Math.min(this.health, dmg) * b.modEnergySiphon
if (b.modHealthDrain && dmg !== Infinity) mech.addHealth(Math.min(this.health, dmg) * b.modHealthDrain)
this.health -= dmg
//this.fill = this.color + this.health + ')';
this.onDamage(dmg); //custom damage effects
if (this.health < b.mobDieAtHealth && this.alive) this.death();
if (this.health < b.modMobDieAtHealth && this.alive) this.death();
}
},
onDamage() {

View File

@@ -67,7 +67,7 @@ const mech = {
defaultMass: 5,
mass: 5,
FxNotHolding: 0.015,
Fx: null, //run Force on ground //0.015 //this is set in b.setModDefaults()
Fx: 0.015, //run Force on ground //
FxAir: 0.016, //run Force in Air
yOff: 70,
yOffGoal: 70,
@@ -105,7 +105,7 @@ const mech = {
Sy: 0, //adds a smoothing effect to vertical only
Vx: 0,
Vy: 0,
jumpForce: null, //0.38 //this is reset in b.setModDefaults()
jumpForce: 0.38, //0.38 //this is reset in b.setModDefaults()
gravity: 0.0024, //0.0019 //game.g is 0.001
friction: {
ground: 0.01,
@@ -653,7 +653,7 @@ const mech = {
throwChargeRate: 0,
throwChargeMax: 0,
fieldShieldingScale: 0,
fieldRange: 0,
fieldRange: 175,
fieldArc: 0,
fieldThreshold: 0,
calculateFieldThreshold() {
@@ -1375,11 +1375,11 @@ const mech = {
mech.lookForPickUp();
mech.pushMobs360();
//look for nearby objects to make zero-g
function zeroG(who, mag = 1.06) {
function zeroG(who, range, mag = 1.06) {
for (let i = 0, len = who.length; i < len; ++i) {
sub = Vector.sub(who[i].position, mech.pos);
dist = Vector.magnitude(sub);
if (dist < mech.fieldRange) {
if (dist < range) {
who[i].force.y -= who[i].mass * (game.g * mag); //add a bit more then standard gravity
}
}
@@ -1390,20 +1390,20 @@ const mech = {
if (keys[83] || keys[40]) { //down
player.force.y -= 0.5 * player.mass * mech.gravity;
this.fieldDrawRadius = this.fieldDrawRadius * 0.97 + 400 * 0.03;
zeroG(powerUp, 0.7);
zeroG(body, 0.7);
zeroG(powerUp, this.fieldDrawRadius, 0.7);
zeroG(body, this.fieldDrawRadius, 0.7);
} else if (keys[87] || keys[38]) { //up
mech.fieldMeter -= 5 * DRAIN;
this.fieldDrawRadius = this.fieldDrawRadius * 0.97 + 850 * 0.03;
player.force.y -= 1.45 * player.mass * mech.gravity;
zeroG(powerUp, 1.38);
zeroG(body, 1.38);
zeroG(powerUp, this.fieldDrawRadius, 1.38);
zeroG(body, this.fieldDrawRadius, 1.38);
} else {
mech.fieldMeter -= DRAIN;
this.fieldDrawRadius = this.fieldDrawRadius * 0.97 + 650 * 0.03;
player.force.y -= 1.07 * player.mass * mech.gravity; // slow upward drift
zeroG(powerUp);
zeroG(body);
zeroG(powerUp, this.fieldDrawRadius);
zeroG(body, this.fieldDrawRadius);
}
//add extra friction for horizontal motion