explosion damage immunity mod

This commit is contained in:
landgreen
2020-08-07 08:41:11 -07:00
parent d13b1fb16d
commit 2e9ff7e292
6 changed files with 122 additions and 76 deletions

View File

@@ -177,7 +177,7 @@ const b = {
time: game.drawTime
});
let dist, sub, knock;
let dmg = b.dmgScale * radius * 0.009;
let dmg = radius * 0.01;
const alertRange = 100 + radius * 2; //alert range
//add alert to draw queue
@@ -194,17 +194,15 @@ const b = {
dist = Vector.magnitude(sub);
if (dist < radius) {
if (mod.isImmuneExplosion) {
mech.energy += Math.max(radius * 0.0003, 0.15)
} else {
mech.damage(radius * 0.0002); //normal player damage from explosions
if (!(mod.isImmuneExplosion && mech.energy > 0.75)) {
mech.damage(radius * 0.0001); //normal player damage from explosions
mech.drop();
}
knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 30);
knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass * 0.015);
player.force.x += knock.x;
player.force.y += knock.y;
} else if (dist < alertRange) {
knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 55);
knock = Vector.mult(Vector.normalise(sub), -Math.sqrt(dmg) * player.mass * 0.008);
player.force.x += knock.x;
player.force.y += knock.y;
}
@@ -214,11 +212,11 @@ const b = {
sub = Vector.sub(where, body[i].position);
dist = Vector.magnitude(sub);
if (dist < radius) {
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * body[i].mass) / 18);
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * body[i].mass) * 0.022);
body[i].force.x += knock.x;
body[i].force.y += knock.y;
} else if (dist < alertRange) {
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * body[i].mass) / 40);
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * body[i].mass) * 0.013);
body[i].force.x += knock.x;
body[i].force.y += knock.y;
}
@@ -229,11 +227,11 @@ const b = {
sub = Vector.sub(where, powerUp[i].position);
dist = Vector.magnitude(sub);
if (dist < radius) {
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * powerUp[i].mass) / 30);
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * powerUp[i].mass) * 0.015);
powerUp[i].force.x += knock.x;
powerUp[i].force.y += knock.y;
} else if (dist < alertRange) {
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * powerUp[i].mass) / 45);
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg) * powerUp[i].mass) * 0.01);
powerUp[i].force.x += knock.x;
powerUp[i].force.y += knock.y;
}
@@ -248,16 +246,16 @@ const b = {
if (dist < radius) {
if (mob[i].shield) dmg *= 3 //balancing explosion dmg to shields
if (Matter.Query.ray(map, mob[i].position, where).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way
mob[i].damage(dmg * damageScale);
mob[i].damage(dmg * damageScale * b.dmgScale);
mob[i].locatePlayer();
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg * damageScale) * mob[i].mass) / 50);
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg * damageScale) * mob[i].mass) * 0.01);
mob[i].force.x += knock.x;
mob[i].force.y += knock.y;
radius *= 0.95 //reduced range for each additional explosion target
damageScale *= 0.85 //reduced damage for each additional explosion target
damageScale *= 0.87 //reduced damage for each additional explosion target
} else if (!mob[i].seePlayer.recall && dist < alertRange) {
mob[i].locatePlayer();
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg * damageScale) * mob[i].mass) / 80);
knock = Vector.mult(Vector.normalise(sub), (-Math.sqrt(dmg * damageScale) * mob[i].mass) * 0.006);
mob[i].force.x += knock.x;
mob[i].force.y += knock.y;
}
@@ -910,7 +908,8 @@ const b = {
this.target = null
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) {
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));
@@ -933,6 +932,7 @@ const b = {
}
}
}
}
}
}
@@ -1360,8 +1360,9 @@ const b = {
const sub = Vector.sub(this.lockedOn.position, this.position)
const DIST = Vector.magnitude(sub);
const unit = Vector.normalise(sub)
const DRAIN = 0.0016 - 0.0008 * this.isUpgraded
if (DIST < mod.isPlasmaRange * 550 && mech.energy > DRAIN) {
const DRAIN = 0.002
if (DIST < mod.isPlasmaRange * 500 && mech.energy > DRAIN) {
console.log('fire')
mech.energy -= DRAIN;
if (mech.energy < 0) {
mech.fieldCDcycle = mech.cycle + 120;
@@ -1369,7 +1370,7 @@ const b = {
}
//calculate laser collision
let best;
let range = mod.isPlasmaRange * (140 + 300 * Math.sqrt(Math.random()))
let range = mod.isPlasmaRange * (120 + 300 * Math.sqrt(Math.random()))
const path = [{
x: this.position.x,
y: this.position.y

View File

@@ -761,9 +761,9 @@ const game = {
});
}
}
if (game.difficultyMode === 2) mech.damage(0.3);
if (game.difficultyMode === 2) mech.damage(0.25);
if (game.difficultyMode === 1) mech.damage(0.1);
mech.energy = 0;
mech.energy = 0.01;
}
}

View File

@@ -51,9 +51,11 @@ const level = {
mech.maxHealth += 0.05 * powerUps.totalPowerUps
if (powerUps.totalPowerUps) game.makeTextLog("<span style='font-size:115%;'> max health increased by " + (0.05 * powerUps.totalPowerUps * 100).toFixed(0) + "%</span>", 300)
}
if (mod.isHealLowHealth && mech.health < 0.8 * mech.maxHealth * Math.sqrt(game.healScale)) {
mech.health = mech.maxHealth * game.healScale
mech.displayHealth();
if (mod.isHealLowHealth) {
const len = Math.floor((mech.maxHealth - mech.health) / 0.5)
for (let i = 0; i < len; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "heal", false);
}
}
},
custom() {},
@@ -412,10 +414,14 @@ const level = {
powerUps.addRerollToLevel() //needs to run after mobs are spawned
},
sewers() {
const rotor = level.rotor(5100, 2425, -0.001)
const rotor = level.rotor(5100, 2475, -0.001)
const button = level.button(6600, 2675)
const hazard = level.hazard(4550, 2750, 4550, 150)
const balance1 = level.spinner(300, -395, 25, 390, 0.001) //entrance
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();
@@ -425,6 +431,17 @@ const level = {
level.playerExitCheck();
};
level.customTopLayer = () => {
ctx.fillStyle = "#233"
ctx.beginPath();
ctx.arc(balance1.pointA.x, balance1.pointA.y, 9, 0, 2 * Math.PI);
ctx.moveTo(balance2.pointA.x, balance2.pointA.y)
ctx.arc(balance2.pointA.x, balance2.pointA.y, 9, 0, 2 * Math.PI);
ctx.moveTo(balance3.pointA.x, balance3.pointA.y)
ctx.arc(balance3.pointA.x, balance3.pointA.y, 9, 0, 2 * Math.PI);
ctx.moveTo(balance4.pointA.x, balance4.pointA.y)
ctx.arc(balance4.pointA.x, balance4.pointA.y, 9, 0, 2 * Math.PI);
ctx.fill();
hazard.draw();
};
@@ -440,26 +457,26 @@ const level = {
spawn.debris(4575, 2550, 1600, 9); //16 debris per level
spawn.debris(7000, 2550, 2000, 7); //16 debris per level
level.fill.push({
x: 9300,
y: 2200,
width: 600,
height: 400,
color: "rgba(0,255,255,0.1)"
});
// level.fill.push({
// x: 9325,
// y: 2200,
// width: 575,
// height: 400,
// color: "rgba(0,255,255,0.1)"
// });
level.fillBG.push({
x: 9300,
y: 2200,
width: 600,
height: 400,
color: "hsl(138, 10%, 80%)" //c4f4f4
color: "hsl(175, 15%, 76%)" //c4f4f4
});
spawn.mapRect(-500, -600, 200, 800); //left entrance wall
spawn.mapRect(-400, -600, 3550, 200); //ceiling
spawn.mapRect(-400, 0, 3000, 200); //floor
spawn.mapRect(300, -500, 50, 400); //right entrance wall
spawn.bodyRect(312, -100, 25, 100);
// spawn.mapRect(300, -500, 50, 400); //right entrance wall
// spawn.bodyRect(312, -100, 25, 100);
spawn.bodyRect(1450, -300, 150, 50);
const xPos = shuffle([600, 1250, 2000]);
@@ -473,15 +490,23 @@ const level = {
spawn.mapRect(3050, -600, 200, 800); //right down tube wall
spawn.mapRect(3100, 0, 1200, 200); //tube right exit ceiling
spawn.mapRect(4200, 0, 200, 1900);
spawn.mapRect(3000, 400, 1000, 1250);
spawn.mapRect(3000, 1925, 1000, 150);
spawn.mapRect(3100, 1875, 800, 100);
spawn.mapRect(3100, 1600, 800, 100);
spawn.mapRect(3100, 350, 800, 100);
spawn.mapRect(3100, 2025, 800, 100);
spawn.mapRect(2400, 0, 200, 1950); //left down tube wall
spawn.mapVertex(3500, 1000, "-500 -500 -400 -600 400 -600 500 -500 500 500 400 600 -400 600 -500 500");
spawn.mapVertex(3600, 1940, "-400 -40 -350 -90 350 -90 400 -40 400 40 350 90 -350 90 -400 40");
spawn.mapRect(3925, 2288, 310, 50);
spawn.mapRect(3980, 2276, 200, 50);
spawn.mapRect(2625, 2288, 650, 50);
spawn.mapRect(2700, 2276, 500, 50);
// spawn.mapRect(3000, 400, 1000, 1250);
// spawn.mapRect(3000, 1925, 1000, 150);
// spawn.mapRect(3100, 1875, 800, 100);
// spawn.mapRect(3100, 1600, 800, 100);
// spawn.mapRect(3100, 350, 800, 100);
// spawn.mapRect(3100, 2025, 800, 100);
spawn.mapRect(2400, 0, 200, 1925); //left down tube wall
spawn.mapRect(600, 2300, 3750, 200);
spawn.bodyRect(3800, 275, 125, 125);
@@ -490,8 +515,8 @@ const level = {
spawn.mapRect(600, 1700, 2000, 200); //bottom left room ceiling
spawn.mapRect(500, 1700, 200, 800); //left wall
spawn.mapRect(1775, 2225, 550, 125);
spawn.mapRect(675, 1875, 325, 150);
spawn.mapRect(675, 1875, 325, 150, 0.5);
spawn.mapRect(4450, 2900, 4900, 200); //boss room floor
spawn.mapRect(4150, 2600, 400, 500);
@@ -508,7 +533,7 @@ const level = {
spawn.mapRect(9100, 1700, 900, 500); //exit
spawn.mapRect(9100, 2600, 900, 500);
spawn.mapRect(9900, 1700, 200, 1400); //back wall
spawn.mapRect(9300, 2150, 50, 250);
// spawn.mapRect(9300, 2150, 50, 250);
spawn.mapRect(9300, 2590, 650, 25);
spawn.mapRect(9700, 2580, 100, 50);
@@ -772,7 +797,7 @@ const level = {
// spawn.mapRect(-100, -410, 100, 30);
spawn.mapRect(-300, -800, 500, 50);
spawn.mapRect(150, -800, 50, 110);
spawn.bodyRect(170, -690, 14, 175, 1, spawn.propsFriction); //door to exit room
spawn.bodyRect(170, -690, 14, 180, 1, spawn.propsFriction); //door to exit room
spawn.mapRect(-300, -400, 500, 100); //far left starting ceiling
level.fill.push({
x: -250,
@@ -2289,7 +2314,7 @@ const level = {
basement() { // player made level by Francois 👑 from discord
let button, door, buttonDoor, buttonPlateformEnd, doorPlateform
let isLevelReversed = Math.random();
if (isLevelReversed < 0.1) {
if (isLevelReversed < 0.7) {
isLevelReversed = false;
} else {
isLevelReversed = true;
@@ -2841,7 +2866,35 @@ const level = {
World.add(engine.world, consBB[i]);
}
},
platform(x, y, width, height, speed) {
spinner(x, y, width, height, density = 0.001) {
x = x + width / 2
y = y + height / 2
const who = body[body.length] = Bodies.rectangle(x, y, width, height, {
collisionFilter: {
category: cat.body,
mask: cat.player | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet //cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet
},
isNotHoldable: true,
frictionAir: 0.001,
friction: 1,
frictionStatic: 1,
restitution: 0,
});
Matter.Body.setDensity(who, density)
const constraint = Constraint.create({ //fix rotor in place, but allow rotation
pointA: {
x: x,
y: y
},
bodyB: who,
stiffness: 1,
damping: 1
});
World.add(engine.world, constraint);
return constraint
},
platform(x, y, width, height, speed = 0, density = 0.001) {
x = x + width / 2
y = y + height / 2
const who = body[body.length] = Bodies.rectangle(x, y, width, height, {
@@ -2856,6 +2909,7 @@ const level = {
restitution: 0,
});
Matter.Body.setDensity(who, density)
const constraint = Constraint.create({ //fix rotor in place, but allow rotation
pointA: {
x: x,
@@ -2870,23 +2924,10 @@ const level = {
position: who.position,
speed: speed,
}
// constraint.move = function () {
// if (this.plat.position.y > 350) {
// this.plat.speed = speed
// } else if (this.plat.position.y < -2435) {
// this.plat.speed = -speed
// }
// this.plat.position = {
// x: this.plat.position.x,
// y: this.plat.position.y + this.plat.speed
// }
// this.pointA = this.plat.position
// }
constraint.pauseUntilCycle = 0 //to to pause platform at top and bottom
return constraint
},
rotor(x, y, rotate = 0, radius = 900, width = 50, density = 0.0005) {
rotor(x, y, rotate = 0, radius = 800, width = 40, density = 0.0005) {
const rotor1 = Matter.Bodies.rectangle(x, y, width, radius, {
density: density,
isNotHoldable: true

View File

@@ -77,7 +77,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.006
if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005
if (mod.isRerollDamage) dmg *= 1 + 0.05 * powerUps.reroll.rerolls
if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.22
return dmg * mod.slowFire
@@ -954,7 +954,7 @@ const mod = {
},
{
name: "negentropy",
description: `at the start of each <strong>level</strong><br><strong class='color-h'>heal</strong> a percent of <strong>maximum health</strong>`,
description: `at the start of each <strong>level</strong><br>spawn a <strong class='color-h'>heal</strong> for every <strong>50%</strong> missing health`,
maxCount: 1,
count: 0,
allowed() {
@@ -1315,7 +1315,7 @@ const mod = {
},
{
name: "microstates",
description: "increase <strong class='color-d'>damage</strong> by <strong>6%</strong><br>for every <strong>10</strong> active <strong>bullets</strong>",
description: "increase <strong class='color-d'>damage</strong> by <strong>5%</strong><br>for every <strong>10</strong> active <strong>bullets</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -1622,11 +1622,11 @@ const mod = {
},
{
name: "electric reactive armor",
description: "<strong class='color-e'>explosions</strong> give you <strong class='color-f'>energy</strong><br>instead of <strong>harming</strong> you",
description: "<strong class='color-e'>explosions</strong> do no <strong class='color-harm'>harm</strong><br> while your <strong class='color-f'>energy</strong> is above <strong>75%</strong>",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.haveGunCheck("pulse") || mod.isMissileField || mod.isExplodeMob
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || (mod.haveGunCheck("pulse") && mech.maxEnergy > 1) || mod.isMissileField || mod.isExplodeMob
},
requires: "an explosive gun",
effect: () => {
@@ -1953,7 +1953,7 @@ const mod = {
allowed() {
return game.fpsCapDefault > 45 && mod.haveGunCheck("rail gun") && !mod.isSlowFPS
},
requires: "rail gun && FPS above 45",
requires: "rail gun and FPS above 45",
effect() {
mod.isRailTimeSlow = true;
},

View File

@@ -81,8 +81,8 @@ const spawn = {
}
}
},
//"shooterBoss", "cellBossCulture", "bomberBoss", "spiderBoss", "launcherBoss", "laserTargetingBoss",
randomLevelBoss(x, y, options = ["powerUpBoss"]) {
randomLevelBoss(x, y, options = ["shooterBoss", "cellBossCulture", "bomberBoss", "spiderBoss", "launcherBoss", "laserTargetingBoss", "powerUpBoss"]) {
// other bosses: suckerBoss, laserBoss, tetherBoss, snakeBoss //all need a particular level to work so they are not included
spawn[options[Math.floor(Math.random() * options.length)]](x, y)
},

View File

@@ -1,10 +1,14 @@
power up level boss: adjustments
added rotating platforms to sewers level
mod negentropy: now spawns a heal power up for every 50% missing health at the start of a level
all explosions do about 10% more damage
knock back no longer gets weaker at high levels
mod - electric reactive armor now gives explosion damage immunity when your energy is above 75%
************** TODO - n-gon **************
level concept: several stationary platforms that are free to rotate, but with some air friction
foam isFoamGrowOnDeath causes performance issues when too many mobs die fast
level element: a hanging chain of connected blocks
give mobs more animal-like behaviors like rain world
mobs play, look for food, explore
@@ -67,7 +71,6 @@ minigun: high caliber - rework
portals:
portal while holding block sometimes send player back to original portal
only seems to happen with the bottom right block
extend to bodies (mobs?)
use buttons to turn on and off?
level boss: fires a line intersection in a random direction every few seconds.
@@ -128,6 +131,7 @@ redblobgames.com/articles/visibility
could apply to explosions, neutron bomb, player LOS
possible names for mods
holonomy - parallel transport of a vector leads to movement (applies to curved space)
Hypergolic - A hypergolic propellant combination used in a rocket engine is one whose components spontaneously ignite when they come into contact with each other.
have a mob apply a positive status effect on other mobs,