harmonic shield bug fix

This commit is contained in:
landgreen
2020-08-20 05:43:55 -07:00
parent cc8c101776
commit 3659fbe47d
10 changed files with 211 additions and 73 deletions

View File

@@ -740,31 +740,38 @@ const b = {
for (let i = 0, len = powerUp.length; i < len; ++i) {
if (
(powerUp[i].name !== "heal" || mech.health < 0.9 * mech.maxHealth || mod.isDroneGrab) &&
Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 &&
Matter.Query.ray(body, this.position, powerUp[i].position).length === 0
(powerUp[i].name !== "field" || !mod.isDeterminism)
) {
const TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position)
const DIST = Vector.magnitude(TARGET_VECTOR);
if (DIST < closeDist) {
closeDist = DIST;
this.lockedOn = powerUp[i]
//pick up nearby power ups
if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 60000 &&
!game.isChoosing) {
powerUps.onPickUp(this.position);
powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1);
if (mod.isDroneGrab) {
this.isImproved = true;
const SCALE = 2
Matter.Body.scale(this, SCALE, SCALE);
this.lookFrequency = 30;
this.endCycle = Infinity
this.dmg *= 1.5;
this.frictionAir = 0
}
break;
}
}
if (Vector.magnitudeSquared(Vector.sub(this.position, powerUp[i].position)) < 60000 && !game.isChoosing) {
powerUps.onPickUp(this.position);
powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1);
if (mod.isDroneGrab) {
this.isImproved = true;
const SCALE = 2
Matter.Body.scale(this, SCALE, SCALE);
this.lookFrequency = 30;
this.endCycle = Infinity
this.dmg *= 1.5;
this.frictionAir = 0
//look for power ups to lock onto
if (
Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 &&
Matter.Query.ray(body, this.position, powerUp[i].position).length === 0
) {
const TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position)
const DIST = Vector.magnitude(TARGET_VECTOR);
if (DIST < closeDist) {
closeDist = DIST;
this.lockedOn = powerUp[i]
}
}
break;
}
}
}
@@ -1563,6 +1570,34 @@ const b = {
}
bullet[me].do = function () {
this.force.y += this.mass * 0.0003;
// //place in bullet do
// //slow player
// const range = 1000
// if (Vector.magnitude(Vector.sub(player.position, this.position)) < range) {
// Matter.Body.setVelocity(player, {
// x: player.velocity.x * 0.95,
// y: player.velocity.y * 0.95
// });
// }
// //aoe damage to mobs
// for (let i = 0, len = mob.length; i < len; i++) {
// if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < range) {
// let dmg = b.dmgScale * 0.023
// if (Matter.Query.ray(map, mob[i].position, this.position).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way
// if (mob[i].shield) dmg *= 5 //x5 to make up for the /5 that shields normally take
// mob[i].damage(dmg);
// mob[i].locatePlayer();
// }
// }
// //draw it
// ctx.beginPath();
// ctx.arc(this.position.x, this.position.y, range, 0, 2 * Math.PI);
// ctx.fillStyle = `rgba(255,0,0,0.2)`;
// ctx.fill();
};
}
},
@@ -1797,9 +1832,9 @@ const b = {
},
{
name: "wave beam",
description: "emit a <strong>sine wave</strong> of oscillating particles<br>particles <strong>slowly</strong> propagate through <strong>solids</strong>",
description: "emit a <strong>sine wave</strong> of oscillating particles<br>that can propagate <strong>through solids</strong>",
ammo: 0,
ammoPack: 80,
ammoPack: 70,
have: false,
fire() {
mech.fireCDcycle = mech.cycle + Math.floor(3 * b.fireCD); // cool down
@@ -1871,7 +1906,7 @@ const b = {
for (let i = 0; i < q.length; i++) {
slowCheck = 0.3;
Matter.Body.setPosition(this, Vector.add(this.position, q[i].velocity)) //move with the medium
let dmg = b.dmgScale * 0.37 / Math.sqrt(q[i].mass) * (mod.waveHelix === 1 ? 1 : 0.6) //1 - 0.4 = 0.6 for helix mod 40% damage reduction
let dmg = b.dmgScale * 0.36 / Math.sqrt(q[i].mass) * (mod.waveHelix === 1 ? 1 : 0.66) //1 - 0.4 = 0.6 for helix mod 40% damage reduction
q[i].damage(dmg);
q[i].foundPlayer();
game.drawList.push({ //add dmg to draw queue
@@ -2202,7 +2237,7 @@ const b = {
},
{
name: "neutron bomb",
description: "toss a chunk of <strong class='color-p'>Cf-252</strong> that emits <strong class='color-p'>neutrons</strong><br><strong class='color-d'>damages</strong> and drains <strong class='color-f'>energy</strong> in area of effect",
description: "toss a chunk of <strong class='color-p'>Cf-252</strong> which emits <strong class='color-p'>neutrons</strong><br>that do <strong class='color-d'>damage</strong>, <strong class='color-harm'>harm</strong>, and <strong class='color-f'>energy</strong> drain",
ammo: 0,
ammoPack: 5,
have: false,
@@ -2591,19 +2626,18 @@ const b = {
bullet[me].endCycle = Infinity
bullet[me].charge = 0;
bullet[me].do = function () {
if ((!game.mouseDown && this.charge > 0.6) || mech.energy < 0.005) { //fire on mouse release
if (mech.energy < 0.005 && !mod.isRailTimeSlow) {
// this.charge = 0;
mech.energy += this.charge * 0.4
mech.fireCDcycle = mech.cycle + 120; // cool down if out of energy
this.endCycle = 0;
return
} else {
mech.fireCDcycle = mech.cycle + 2; // set fire cool down
//normal bullet behavior occurs after firing, overwrite this function
this.do = function () {
this.force.y += this.mass * 0.0003 / this.charge; // low gravity that scales with charge
}
if (mech.energy < 0.005 && !mod.isRailTimeSlow) {
mech.energy += 0.05 + this.charge * 0.3
mech.fireCDcycle = mech.cycle + 120; // cool down if out of energy
this.endCycle = 0;
return
}
if ((!game.mouseDown && this.charge > 0.6)) { //fire on mouse release or on low energy
mech.fireCDcycle = mech.cycle + 2; // set fire cool down
//normal bullet behavior occurs after firing, overwrites this function
this.do = function () {
this.force.y += this.mass * 0.0003 / this.charge; // low gravity that scales with charge
}
if (mod.isRailTimeSlow) {
game.fpsCap = game.fpsCapDefault
@@ -2653,7 +2687,7 @@ const b = {
mob[i].force.y += 1.5 * FORCE.y;
}
}
} else if (mech.energy > 0.005) { // charging on mouse down
} else { // charging on mouse down
mech.fireCDcycle = Infinity //can't fire until mouse is released
const lastCharge = this.charge
let chargeRate = (mech.crouch) ? 0.98 : 0.984

View File

@@ -112,6 +112,7 @@ const game = {
},
g: 0.0024, // applies to player, bodies, and power ups (not mobs)
onTitlePage: true,
isCheating: false,
paused: false,
isChoosing: false,
testing: false, //testing mode: shows wire frame and some variables
@@ -347,8 +348,9 @@ const game = {
if (game.isConstructionMode) {
document.getElementById("construct").style.display = 'none'
}
} else {
} else { //if (keys[191])
game.testing = true;
game.isCheating = true;
if (game.isConstructionMode) {
document.getElementById("construct").style.display = 'inline'
}
@@ -500,12 +502,14 @@ const game = {
player.force.y += player.mass * game.g;
},
reset() { //run on first run, and each later run after you die
game.isCheating = false
b.removeAllGuns();
mod.setupAllMods(); //sets mods to default values
b.setFireCD();
game.updateModHUD();
powerUps.totalPowerUps = 0;
powerUps.reroll.rerolls = 0;
mech.setFillColors();
mech.maxHealth = 1
mech.maxEnergy = 1
mech.energy = 1
@@ -792,10 +796,11 @@ const game = {
testingOutput() {
ctx.fillStyle = "#000";
if (!game.isConstructionMode) {
ctx.textAlign = "right";
let line = 500;
const x = canvas.width - 5;
ctx.fillText("T: exit testing mode", x, line);
// ctx.textAlign = "right";
ctx.fillText("T: exit testing mode", canvas.width / 2, canvas.height - 10);
// let line = 500;
// const x = canvas.width - 5;
// ctx.fillText("T: exit testing mode", x, line);
// line += 20;
// ctx.fillText("Y: give all mods", x, line);
// line += 20;

View File

@@ -398,6 +398,7 @@ const build = {
function openCustomBuildMenu() {
build.isURLBuild = false;
game.isCheating = true;
document.getElementById("build-button").style.display = "none";
const el = document.getElementById("build-grid")
el.style.display = "grid"
@@ -441,6 +442,7 @@ if (localSettings) {
isCommunityMaps: false,
difficultyMode: '1',
fpsCapDefault: 'max',
runCount: -1,
};
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
document.getElementById("community-maps").checked = localSettings.isCommunityMaps
@@ -466,7 +468,9 @@ function setupCanvas() {
canvas.width2 = canvas.width / 2; //precalculated because I use this often (in mouse look)
canvas.height2 = canvas.height / 2;
canvas.diagonal = Math.sqrt(canvas.width2 * canvas.width2 + canvas.height2 * canvas.height2);
ctx.font = "18px Arial";
// ctx.font = "18px Arial";
// ctx.textAlign = "center";
ctx.font = "25px Arial";
ctx.lineJoin = "round";
ctx.lineCap = "round";
// ctx.lineCap='square';

View File

@@ -16,10 +16,9 @@ const level = {
// game.zoomScale = 1000;
// game.setZoom();
// mech.isStealth = true;
// mod.giveMod("bot replication");
// mod.nailBotCount += 10
// b.giveGuns("rail gun")
// mech.setField("plasma torch")
// mech.setField("standing wave harmonics")
// mod.giveMod("frame-dragging");
level.intro(); //starting level
// level.testing(); //not in rotation
@@ -40,6 +39,10 @@ const level = {
spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
// spawn.pickList = ["focuser", "focuser"]
level[level.levels[level.onLevel]](); //picks the current map from the the levels array
if (!game.isCheating) {
localSettings.runCount += level.levelsCleared //track the number of total runs locally
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
}
}
level.levelAnnounce();
game.noCameraScroll();
@@ -629,7 +632,71 @@ const level = {
level.custom = () => {
level.playerExitCheck();
};
level.customTopLayer = () => {};
// ctx.font = "30px Arial";
// ctx.textAlign = "center";
level.customTopLayer = () => {
// ctx.fillStyle = '#000';
// ctx.fillText(`${(localSettings.runCount >>> 0).toString(2)}`, 2850, -530);
};
const binary = (localSettings.runCount >>> 0).toString(2)
const height = 25
const thick = 2
const color = "#aaa"
const xOff = -130 //2622
const yOff = -45 //-580
let xLetter = 0
for (let i = 0; i < binary.length; i++) {
if (binary[i] === "0") {
zero(xOff + xLetter, yOff)
} else {
one(xOff + xLetter, yOff)
}
}
function one(x, y) {
level.fillBG.push({
x: x,
y: y,
width: thick,
height: height,
color: color
});
xLetter += 10
}
function zero(x, y) {
const width = 10
level.fillBG.push({
x: x,
y: y,
width: thick,
height: height,
color: color
});
level.fillBG.push({
x: x + width,
y: y,
width: thick,
height: height,
color: color
});
level.fillBG.push({
x: x,
y: y,
width: width,
height: thick,
color: color
});
level.fillBG.push({
x: x,
y: y + height - thick,
width: width,
height: thick,
color: color
});
xLetter += 10 + width
}
level.setPosToSpawn(460, -100); //normal spawn
level.enter.x = -1000000; //hide enter graphic for first level by moving to the far left
@@ -1981,13 +2048,13 @@ const level = {
spawn.debris(3500, -650, 800, 5); //1st floor debris //16 debris per level
powerUps.spawnStartingPowerUps(-525, -700);
spawn.mapRect(-600, 25, 5600, 300); //ground
spawn.mapRect(-600, 0, 2000, 50); //ground
spawn.mapRect(-600, 0, 2000, 325); //ground
spawn.mapRect(1400, 25, 1600, 300); //ground
spawn.mapRect(3000, 0, 2000, 325); //ground
spawn.mapRect(-600, -1700, 50, 2000 - 100); //left wall
spawn.bodyRect(-295, -1540, 40, 40); //center block under wall
spawn.bodyRect(-298, -1580, 40, 40); //center block under wall
spawn.bodyRect(1500, -1540, 30, 30); //left of entrance
spawn.mapRect(1550, -2000, 50, 550); //right wall
spawn.mapRect(1350, -2000 + 505, 50, 1295); //right wall
spawn.mapRect(-600, -2000 + 250, 2000 - 700, 50); //roof left
@@ -2022,9 +2089,7 @@ const level = {
spawn.bodyRect(700, -400, 100, 100); //center block under wall
spawn.mapRect(1390, 13, 30, 20); //step left
spawn.mapRect(2980, 13, 30, 20); //step right
spawn.mapRect(3000, 0, 2000, 50); //ground
spawn.bodyRect(4250, -700, 50, 100);
// spawn.bodyRect(3000, -200, 50, 200); //door
spawn.mapRect(3000, -1000, 50, 800); //left wall
spawn.mapRect(3000 + 2000 - 50, -1300, 50, 1100); //right wall
spawn.mapRect(4150, -600, 350, 150); //table

View File

@@ -86,7 +86,7 @@ const mod = {
if (mod.isAcidDmg && mech.health > 1) dmg *= 1.4;
if (mod.isRest && player.speed < 1) dmg *= 1.20;
if (mod.isEnergyDamage) dmg *= 1 + mech.energy / 5.5;
if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005
if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.004
if (mod.isRerollDamage) dmg *= 1 + 0.05 * powerUps.reroll.rerolls
if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.25
return dmg * mod.slowFire
@@ -693,7 +693,7 @@ const mod = {
mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles
},
remove() {
mod.collisionImmuneCycles = 15;
mod.collisionImmuneCycles = 25;
}
},
{
@@ -1341,7 +1341,7 @@ const mod = {
},
{
name: "microstates",
description: "increase <strong class='color-d'>damage</strong> by <strong>5%</strong><br>for every <strong>10</strong> active <strong>bullets</strong>",
description: "increase <strong class='color-d'>damage</strong> by <strong>4%</strong><br>for every <strong>10</strong> active <strong>bullets</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -2013,6 +2013,8 @@ const mod = {
},
remove() {
mod.isRailTimeSlow = false;
game.fpsCap = game.fpsCapDefault
game.fpsInterval = 1000 / game.fpsCap;
}
},
{
@@ -2268,7 +2270,7 @@ const mod = {
},
requires: "standing wave harmonics",
effect() {
mod.blockDmg += 0.35 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
mod.blockDmg += 0.66 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
},
remove() {
mod.blockDmg = 0;
@@ -2284,7 +2286,7 @@ const mod = {
},
requires: "standing wave harmonics",
effect() {
mech.fieldRange += 175 * 0.21
mech.fieldRange += 175 * 0.17
mech.fieldShieldingScale *= 0.6
},
remove() {
@@ -2359,7 +2361,7 @@ const mod = {
},
{
name: "renormalization",
description: "using a <strong class='color-r'>reroll</strong> to change selection options<br>has a <strong>60%</strong> chance to spawn a <strong class='color-r'>reroll</strong>",
description: "using a <strong class='color-r'>reroll</strong> to change selection options<br>has a <strong>66%</strong> chance to spawn a <strong class='color-r'>reroll</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -2375,7 +2377,7 @@ const mod = {
},
{
name: "superposition",
description: "mobs that <strong>touch</strong> the <strong>phased</strong> player<br> are <strong>stunned</strong> for <strong>4</strong> seconds",
description: "mobs that <strong>touch</strong> the <strong>phased</strong> player<br> are <strong>stunned</strong> for <strong>5</strong> seconds",
maxCount: 1,
count: 0,
allowed() {

View File

@@ -57,8 +57,16 @@ const mech = {
lastHarmCycle: 0,
width: 50,
radius: 30,
fillColor: "#fff", //changed by mod piezoelectric plating (damage immunity)
fillColor: "#fff",
fillColorDark: "#ccc",
setFillColors() {
const hue = 0
const saturation = 10
const light = 70 + mech.harmReduction() * 30
// console.log(mech.harmReduction())
this.fillColor = `hsl(${hue},${saturation}%,${light}%)`
this.fillColorDark = `hsl(${hue},${saturation}%,${light-20}%)`
},
height: 42,
yOffWhen: {
crouch: 22,
@@ -967,8 +975,8 @@ const mech = {
}
if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy;
if (mod.blockDmg && mech.fieldUpgrades[mech.fieldMode].name === "standing wave harmonics") {
who.damage(mod.blockDmg)
if (mod.blockDmg) {
who.damage(mod.blockDmg * b.dmgScale)
//draw electricity
const step = 40
ctx.beginPath();
@@ -1797,7 +1805,7 @@ const mech = {
// inPlayer[i].damage(0.4 * b.dmgScale); //damage mobs inside the player
// mech.energy += 0.005;
mobs.statusStun(inPlayer[i], 240)
mobs.statusStun(inPlayer[i], 300)
//draw outline of mob in a few random locations to show blurriness
const vertices = inPlayer[i].vertices;
const off = 30

View File

@@ -100,7 +100,7 @@ const powerUps = {
use(type) { //runs when you actually reroll a list of selections, type can be field, gun, or mod
powerUps.reroll.changeRerolls(-1)
powerUps[type].effect();
if (mod.renormalization && Math.random() < 0.6) {
if (mod.renormalization && Math.random() < 0.66) {
powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
}

View File

@@ -368,7 +368,7 @@ const spawn = {
// Matter.Body.setDensity(me, 0.0007); //extra dense //normal is 0.001 //makes effective life much lower
me.friction = 0;
me.frictionAir = 0;
me.accelMag = 0.001 * game.accelScale;;
me.accelMag = 0.001 * Math.sqrt(game.accelScale);
me.g = me.accelMag * 0.6; //required if using 'gravity'
me.memory = 50;
spawn.shield(me, x, y);