bubble fusion

This commit is contained in:
landgreen
2020-06-23 14:05:34 -07:00
parent d1cb3aff15
commit ffc5aa3e1e
6 changed files with 68 additions and 27 deletions

View File

@@ -378,7 +378,7 @@ const b = {
if (collide.length > 0) { if (collide.length > 0) {
for (let i = 0; i < collide.length; i++) { for (let i = 0; i < collide.length; i++) {
if (collide[i].bodyA.collisionFilter.category === cat.map) { // || collide[i].bodyB.collisionFilter.category === cat.map) { if (collide[i].bodyA.collisionFilter.category === cat.map) { // || collide[i].bodyB.collisionFilter.category === cat.map) {
const angle = Matter.Vector.angle(collide[i].normal, { const angle = Vector.angle(collide[i].normal, {
x: 1, x: 1,
y: 0 y: 0
}) })
@@ -726,14 +726,14 @@ const b = {
let closeDist = Infinity; let closeDist = Infinity;
for (let i = 0, len = powerUp.length; i < len; ++i) { for (let i = 0, len = powerUp.length; i < len; ++i) {
if ( if (
((powerUp[i].name !== "field" && powerUp[i].name !== "heal") || (powerUp[i].name === "heal" && mech.health < 0.8)) && ((powerUp[i].name !== "field" && powerUp[i].name !== "heal") || (powerUp[i].name === "heal" && mech.health < 0.9)) &&
Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 && Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 &&
Matter.Query.ray(body, 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 TARGET_VECTOR = Vector.sub(this.position, powerUp[i].position)
const DIST = Vector.magnitude(TARGET_VECTOR); const DIST = Vector.magnitude(TARGET_VECTOR);
if (DIST < closeDist) { if (DIST < closeDist) {
if (DIST < 50) { //eat the power up if close enough if (DIST < 60) { //eat the power up if close enough
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.World.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
@@ -875,7 +875,7 @@ const b = {
if (this.target.isShielded) { if (this.target.isShielded) {
this.target.damage(b.dmgScale * 0.005, true); //shield damage bypass this.target.damage(b.dmgScale * 0.005, true); //shield damage bypass
//shrink if mob is shielded //shrink if mob is shielded
const SCALE = 1 - 0.025 / mod.isBulletsLastLonger const SCALE = 1 - 0.016 / mod.isBulletsLastLonger
Matter.Body.scale(this, SCALE, SCALE); Matter.Body.scale(this, SCALE, SCALE);
this.radius *= SCALE; this.radius *= SCALE;
} else { } else {
@@ -886,14 +886,28 @@ const b = {
this.collisionFilter.category = cat.bullet; this.collisionFilter.category = cat.bullet;
this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield this.collisionFilter.mask = cat.mob //| cat.mobShield //cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
if (mod.isFoamGrowOnDeath) { if (mod.isFoamGrowOnDeath) {
// const SCALE = (this.radius < 30) ? 2 : 1 //Math.min(5, Math.max(1, 20 / (this.radius * this.radius))) let targets = []
// Matter.Body.scale(this, SCALE, SCALE); for (let i = 0, len = mob.length; i < len; i++) {
// this.radius *= SCALE; const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
const radius = Math.min(this.radius / 2, 10) if (dist < 1000000) {
b.foam(this.position, Matter.Vector.rotate(this.velocity, Math.PI * 2 / 3), radius) targets.push(mob[i])
b.foam(this.position, Matter.Vector.rotate(this.velocity, Math.PI * 1 / 3), radius) }
}
const radius = Math.min(this.radius * 0.5, 10)
for (let i = 0; i < 2; i++) {
if (targets.length - i > 0) {
const index = Math.floor(Math.random() * targets.length)
const speed = 10 + 10 * Math.random()
const velocity = Vector.mult(Vector.normalise(Vector.sub(targets[index].position, this.position)), speed)
b.foam(this.position, Vector.rotate(velocity, 0.5 * (Math.random() - 0.5)), radius)
} else {
b.foam(this.position, Vector.rotate({
x: 15 + 10 * Math.random(),
y: 0
}, 2 * Math.PI * Math.random()), radius)
}
}
} }
} }
} }
} }
@@ -1392,7 +1406,7 @@ const b = {
function makeFlechette(angle = mech.angle + 0.02 * (Math.random() - 0.5)) { function makeFlechette(angle = mech.angle + 0.02 * (Math.random() - 0.5)) {
const me = bullet.length; 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, 1.4, b.fireAttributes(angle)); bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 45, 1.4, b.fireAttributes(angle));
bullet[me].collisionFilter.mask = cat.body; //cat.mobShield | //cat.map | cat.body | bullet[me].collisionFilter.mask = mod.pierce ? 0 : cat.body; //cat.mobShield | //cat.map | cat.body |
Matter.Body.setDensity(bullet[me], 0.00001); //0.001 is normal Matter.Body.setDensity(bullet[me], 0.00001); //0.001 is normal
bullet[me].endCycle = game.cycle + 180; bullet[me].endCycle = game.cycle + 180;
bullet[me].dmg = 0; bullet[me].dmg = 0;
@@ -2269,7 +2283,7 @@ const b = {
if (who.shield) { if (who.shield) {
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
if (mob[i].id === who.shieldTargetID) { //apply some knock back to shield mob before shield breaks if (mob[i].id === who.shieldTargetID) { //apply some knock back to shield mob before shield breaks
Matter.Body.setVelocity(mob[i], Matter.Vector.mult(Matter.Vector.normalise(this.velocity), 10)); Matter.Body.setVelocity(mob[i], Vector.mult(Vector.normalise(this.velocity), 10));
break break
} }
} }

View File

@@ -16,10 +16,10 @@ const level = {
if (level.levelsCleared === 0) { //this code only runs on the first level if (level.levelsCleared === 0) { //this code only runs on the first level
// game.enableConstructMode() //used to build maps in testing mode // game.enableConstructMode() //used to build maps in testing mode
// level.difficultyIncrease(9) // level.difficultyIncrease(9)
// mech.isStealth = true;
mod.giveMod("automatic shotgun"); // mod.giveMod("necrophoresis");
// b.giveGuns("spores") // b.giveGuns("foam")
// mech.setField("plasma torch") // mech.setField("time dilation field")
level.intro(); //starting level level.intro(); //starting level
// level.testing(); // level.testing();

View File

@@ -991,7 +991,7 @@ const mobs = {
this.alive = false; //triggers mob removal in mob[i].replace(i) this.alive = false; //triggers mob removal in mob[i].replace(i)
if (this.dropPowerUp) { if (this.dropPowerUp) {
if (mod.isEnergyLoss) mech.energy *= 0.66; if (mod.isEnergyLoss) mech.energy *= 0.66;
powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius); powerUps.spawnRandomPowerUp(this.position.x, this.position.y);
mech.lastKillCycle = mech.cycle; //tracks the last time a kill was made, mostly used in game.checks() mech.lastKillCycle = mech.cycle; //tracks the last time a kill was made, mostly used in game.checks()
if (Math.random() < mod.sporesOnDeath) { if (Math.random() < mod.sporesOnDeath) {
const len = Math.min(30, Math.floor(4 + this.mass * Math.random())) const len = Math.min(30, Math.floor(4 + this.mass * Math.random()))
@@ -1011,6 +1011,17 @@ const mobs = {
} }
if (mod.isExplodeMob) b.explosion(this.position, Math.min(450, Math.sqrt(this.mass + 3) * 80)) if (mod.isExplodeMob) b.explosion(this.position, Math.min(450, Math.sqrt(this.mass + 3) * 80))
if (mod.nailsDeathMob) b.targetedNail(this.position, mod.nailsDeathMob) if (mod.nailsDeathMob) b.targetedNail(this.position, mod.nailsDeathMob)
} else if (mod.isShieldAmmo && this.shield) {
let type = "ammo"
if (Math.random() < 0.33 || mod.bayesian) {
type = "heal"
} else if (Math.random() < 0.5 && !mod.isSuperDeterminism) {
type = "reroll"
}
for (let i = 0; i < 3; i++) {
powerUps.spawn(this.position.x, this.position.y, type);
if (Math.random() < mod.bayesian) powerUps.spawn(this.position.x, this.position.y, type);
}
} }
}, },
removeConsBB() { removeConsBB() {

View File

@@ -785,6 +785,22 @@ const mod = {
mod.isMassEnergy = false; mod.isMassEnergy = false;
} }
}, },
{
name: "bubble fusion",
description: "after destroying a mob's <strong>shield</strong><br>spawn <strong>3</strong> <strong class='color-h'>heals</strong>, <strong>ammo</strong>, or <strong class='color-r'>rerolls</strong>",
maxCount: 1,
count: 0,
allowed() {
return true
},
requires: "",
effect() {
mod.isShieldAmmo = true;
},
remove() {
mod.isShieldAmmo = false;
}
},
{ {
name: "Bayesian inference", name: "Bayesian inference",
description: "<strong>40%</strong> chance for double <strong>power ups</strong> to drop<br><strong>ammo</strong> will no longer <strong>spawn</strong> from mobs", description: "<strong>40%</strong> chance for double <strong>power ups</strong> to drop<br><strong>ammo</strong> will no longer <strong>spawn</strong> from mobs",
@@ -1275,7 +1291,7 @@ const mod = {
}, },
{ {
name: "piercing needles", name: "piercing needles",
description: "<strong>needles</strong> penetrate <strong>mobs</strong><br>potentially hitting <strong>multiple</strong> targets", description: "<strong>needles</strong> penetrate <strong>mobs</strong> and <strong>blocks</strong><br>potentially hitting <strong>multiple</strong> targets",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {
@@ -1634,7 +1650,7 @@ const mod = {
}, },
{ {
name: "necrophoresis", name: "necrophoresis",
description: "<strong>foam</strong> splits into 3 <strong>copies</strong><br>when the mob it's stuck to <strong>dies</strong>", description: "if the mob <strong>foam</strong> is stuck to <strong>dies</strong><br><strong>foam</strong> grows and splits into 3 <strong>copies</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {

View File

@@ -1992,7 +1992,7 @@ const mech = {
for (let i = 0, len = body.length; i < len; ++i) { for (let i = 0, len = body.length; i < len; ++i) {
if (Vector.magnitude(Vector.sub(body[i].position, mech.fieldPosition)) < mech.fieldRadius) { if (Vector.magnitude(Vector.sub(body[i].position, mech.fieldPosition)) < mech.fieldRadius) {
const DRAIN = speed * body[i].mass * 0.000018 const DRAIN = speed * body[i].mass * 0.000015
if (mech.energy > DRAIN) { if (mech.energy > DRAIN) {
mech.energy -= DRAIN; mech.energy -= DRAIN;
Matter.Body.setVelocity(body[i], velocity); //give block mouse velocity Matter.Body.setVelocity(body[i], velocity); //give block mouse velocity

View File

@@ -4,21 +4,21 @@ freezing status effects only last 1/4 as long on boss mobs
mod - shotgun 66% increased fire rate and recoil mod - shotgun 66% increased fire rate and recoil
mod - slowly heal when below 25% health mod - slowly heal when below 25% health
mod - superdeterminism spawn 4 mods, but rerolls, fields, and guns no longer spawn mod - superdeterminism spawn 4 mods, but rerolls, fields, and guns no longer spawn
foam mod, necrophoresis now aims the foam bullets, which makes it more effective at groups
flechettes mod, piercing needles now goes through blocks as well as mobs
mod - spawn 3 ammo, rerolls, or heals after destroying a shield
************** TODO - n-gon ************** ************** TODO - n-gon **************
physics question: why don't the bound states of fields spread out. What is making them bound. physics question: why don't the bound states of fields spread out. What is making them bound.
rework reaction inhibitor to spawn mobs with 12% less life, rather then killing them at 12% mobs killed by _____ always drops ammo
issues getting the code to work
mod: all mobs have a shield (or just a higher rate) rework reaction inhibitor to spawn mobs with 12% less life, rather then killing them at 12%
all mobs drop an extra ammo power up?
levels: make a function in the main game loop that runs level specific code levels: make a function in the main game loop that runs level specific code
reset the level function as each new level loads reset the level function as each new level loads
mod: foam grenades
or maybe all explosions make foam?
mod: use the stealth flag from the phase decoherence field mod: use the stealth flag from the phase decoherence field
maybe trigger it along with the damage immunity CD maybe trigger it along with the damage immunity CD