final boss

missile moves slightly differently
  it used to slow when locked on to a target
  now it slows when turning
missiles explode when near any mob

wormhole mod: cosmic string - now stuns mobs and applies radiation damage
mod time dilation:  - quadruple your default energy regeneration

added final boss level, it's still in progress so I'd love some feedback
also the game loops back to the intro level after the boss
  I'll be working on the ending in the next patch, so the intro level is just a placeholder
This commit is contained in:
landgreen
2020-11-01 18:31:25 -08:00
parent a4a2a9bf2a
commit d7ab196dc3
8 changed files with 15114 additions and 15339 deletions

View File

@@ -278,39 +278,42 @@ const b = {
},
missile(where, angle, speed, size = 1, spawn = 0) {
const me = bullet.length;
bullet[me] = Bodies.rectangle(where.x, where.y, 30 * size, 4 * size, b.fireAttributes(angle));
const thrust = 0.00417 * bullet[me].mass;
Matter.Body.setVelocity(bullet[me], {
x: mech.Vx / 2 + speed * Math.cos(angle),
y: mech.Vy / 2 + speed * Math.sin(angle)
});
World.add(engine.world, bullet[me]); //add bullet to world
bullet[me].frictionAir = 0.023
bullet[me].endCycle = game.cycle + Math.floor((280 + 40 * Math.random()) * mod.isBulletsLastLonger);
bullet[me].explodeRad = 170 + 60 * Math.random();
bullet[me].lookFrequency = Math.floor(21 + Math.random() * 7);
bullet[me].onEnd = function () {
bullet[me] = Bodies.rectangle(where.x, where.y, 30 * size, 4 * size, {
angle: angle,
friction: 0.5,
frictionAir: 0.045,
dmg: 0, //damage done in addition to the damage from momentum
classType: "bullet",
endCycle: game.cycle + Math.floor((230 + 40 * Math.random()) * mod.isBulletsLastLonger),
collisionFilter: {
category: cat.bullet,
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
},
minDmgSpeed: 10,
lookFrequency: Math.floor(15 + Math.random() * 3),
explodeRad: 170 + 60 * Math.random(),
beforeDmg() {
this.tryToLockOn();
this.endCycle = 0; //bullet ends cycle after doing damage // also triggers explosion
}, //this.endCycle = 0 //triggers despawn
onEnd() {
b.explosion(this.position, this.explodeRad * size); //makes bullet do explosive damage at end
if (spawn) {
for (let i = 0; i < mod.recursiveMissiles; i++) {
if (0.3 - 0.03 * i > Math.random()) {
if (0.2 - 0.02 * i > Math.random()) {
b.missile(this.position, this.angle + Math.PI + 0.5 * (Math.random() - 0.5), 0, 0.33 + size, mod.recursiveMissiles)
break;
}
}
}
}
bullet[me].beforeDmg = function () {
this.tryToLockOn();
this.endCycle = 0; //bullet ends cycle after doing damage // also triggers explosion
};
bullet[me].lockedOn = null;
bullet[me].tryToLockOn = function () {
this.lockedOn = null;
},
lockedOn: null,
tryToLockOn() {
let closeDist = Infinity;
//look for closest target to where the missile will be in 30 cycles
const futurePos = Vector.add(this.position, Vector.mult(this.velocity, 30))
const futurePos = Vector.add(this.position, Vector.mult(this.velocity, 50))
this.lockedOn = null;
// const futurePos = this.lockedOn ? :Vector.add(this.position, Vector.mult(this.velocity, 50))
for (let i = 0, len = mob.length; i < len; ++i) {
if (
mob[i].alive && mob[i].dropPowerUp &&
@@ -321,25 +324,24 @@ const b = {
if (futureDist < closeDist) {
closeDist = futureDist;
this.lockedOn = mob[i];
this.frictionAir = 0.05; //extra friction once a target it locked
// this.frictionAir = 0.04; //extra friction once a target it locked
}
if (Vector.magnitude(Vector.sub(this.position, mob[i].position) < this.explodeRad)) {
this.endCycle = 0; //bullet ends cycle after doing damage //also triggers explosion
mob[i].lockedOn.damage(b.dmgScale * 2 * size); //does extra damage to target
}
}
}
//explode when bullet is close enough to target
if (this.lockedOn && Vector.magnitude(Vector.sub(this.position, this.lockedOn.position)) < this.explodeRad) {
// console.log('hit')
this.endCycle = 0; //bullet ends cycle after doing damage //also triggers explosion
this.lockedOn.damage(b.dmgScale * 4 * size); //does extra damage to target
}
};
bullet[me].do = function () {
},
do() {
if (!mech.isBodiesAsleep) {
if (!(mech.cycle % this.lookFrequency)) {
this.tryToLockOn();
}
//rotate missile towards the target
if (this.lockedOn) {
if (!(mech.cycle % this.lookFrequency)) this.tryToLockOn();
if (this.lockedOn) { //rotate missile towards the target
const face = {
x: Math.cos(this.angle),
y: Math.sin(this.angle)
@@ -347,10 +349,13 @@ const b = {
const target = Vector.normalise(Vector.sub(this.position, this.lockedOn.position));
if (Vector.dot(target, face) > -0.98) {
if (Vector.cross(target, face) > 0) {
Matter.Body.rotate(this, 0.08);
Matter.Body.rotate(this, 0.1);
} else {
Matter.Body.rotate(this, -0.08);
Matter.Body.rotate(this, -0.1);
}
this.frictionAir = 0.06; //extra friction if turning
} else {
this.frictionAir = 0.025; //low friction if not turning
}
}
//accelerate in direction bullet is facing
@@ -358,8 +363,7 @@ const b = {
this.force.x += Math.cos(dir) * thrust;
this.force.y += Math.sin(dir) * thrust;
//draw rocket
ctx.beginPath();
ctx.beginPath(); //draw rocket
ctx.arc(this.position.x - Math.cos(this.angle) * (25 * size - 3) + (Math.random() - 0.5) * 4,
this.position.y - Math.sin(this.angle) * (25 * size - 3) + (Math.random() - 0.5) * 4,
11 * size, 0, 2 * Math.PI);
@@ -374,7 +378,14 @@ const b = {
ctx.fillStyle = "rgba(255,155,0,0.5)";
ctx.fill();
}
}
},
});
const thrust = 0.0044 * bullet[me].mass;
Matter.Body.setVelocity(bullet[me], {
x: mech.Vx / 2 + speed * Math.cos(angle),
y: mech.Vy / 2 + speed * Math.sin(angle)
});
World.add(engine.world, bullet[me]); //add bullet to world
},
laser(where = {
x: mech.pos.x + 20 * Math.cos(mech.angle),
@@ -403,7 +414,7 @@ const b = {
y: whereEnd.y
}
];
const vertexCollision = function (v1, v1End, domain) {
const vertexCollision = function(v1, v1End, domain) {
for (let i = 0; i < domain.length; ++i) {
let vertices = domain[i].vertices;
const len = vertices.length - 1;
@@ -444,7 +455,7 @@ const b = {
}
};
const checkForCollisions = function () {
const checkForCollisions = function() {
best = {
x: null,
y: null,
@@ -457,7 +468,7 @@ const b = {
vertexCollision(path[path.length - 2], path[path.length - 1], map);
vertexCollision(path[path.length - 2], path[path.length - 1], body);
};
const laserHitMob = function () {
const laserHitMob = function() {
if (best.who.alive) {
best.who.damage(damage);
best.who.locatePlayer();
@@ -474,7 +485,7 @@ const b = {
// ctx.arc(path[path.length - 1].x, path[path.length - 1].y, Math.sqrt(damage) * 100, 0, 2 * Math.PI);
// ctx.fill();
};
const reflection = function () { // https://math.stackexchange.com/questions/13261/how-to-get-a-reflection-vector
const reflection = function() { // https://math.stackexchange.com/questions/13261/how-to-get-a-reflection-vector
const n = Vector.perp(Vector.normalise(Vector.sub(best.v1, best.v2)));
const d = Vector.sub(path[path.length - 1], path[path.length - 2]);
const nn = Vector.mult(n, 2 * Vector.dot(d, n));
@@ -587,7 +598,7 @@ const b = {
//sometimes the mine can't attach to map and it just needs to be reset
const that = this
setTimeout(function () {
setTimeout(function() {
if (Matter.Query.collides(that, map).length === 0 || Matter.Query.point(map, that.position).length > 0) {
// console.log(that)
that.endCycle = 0 // if not touching map explode
@@ -612,7 +623,7 @@ const b = {
},
arm() {
this.lookFrequency = game.cycle + 60
this.do = function () { //overwrite the do method for this bullet
this.do = function() { //overwrite the do method for this bullet
this.force.y += this.mass * 0.002; //extra gravity
if (game.cycle > this.lookFrequency) {
@@ -626,7 +637,7 @@ const b = {
color: "#f00",
time: 4
});
this.do = function () { //overwrite the do method for this bullet
this.do = function() { //overwrite the do method for this bullet
this.force.y += this.mass * 0.002; //extra gravity
if (!(game.cycle % this.lookFrequency)) { //find mob targets
for (let i = 0, len = mob.length; i < len; ++i) {
@@ -806,7 +817,7 @@ const b = {
this.endCycle = game.cycle
if (mod.isHeavyWater) mobs.statusDoT(who, 0.15, 300)
if (mod.iceEnergy && !who.shield && !who.isShielded && who.dropPowerUp && who.alive) {
setTimeout(function () {
setTimeout(function() {
if (!who.alive) {
mech.energy += mod.iceEnergy * 0.66 * mech.maxEnergy
mech.addHealth(mod.iceEnergy * 0.04)
@@ -1164,11 +1175,11 @@ const b = {
World.add(engine.world, bullet[me]); //add bullet to world
bullet[me].endCycle = game.cycle + 60 + 18 * Math.random();
bullet[me].dmg = dmg
bullet[me].beforeDmg = function (who) { //beforeDmg is rewritten with ice crystal mod
bullet[me].beforeDmg = function(who) { //beforeDmg is rewritten with ice crystal mod
if (mod.isNailPoison) mobs.statusDoT(who, dmg * 0.22, 120) // one tick every 30 cycles
if (mod.isNailCrit && !who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.99) this.dmg *= 5 //crit if hit near center
};
bullet[me].do = function () {};
bullet[me].do = function() {};
},
// **************************************************************************************************
// **************************************************************************************************
@@ -1302,7 +1313,7 @@ const b = {
const radius = 6 + 7 * Math.random()
const SPEED = 29 - radius * 0.5; //(mech.crouch ? 32 : 20) - radius * 0.7;
const velocity = Vector.mult(Vector.normalise(Vector.sub(target, this.position)), SPEED)
b.foam(this.position, velocity, radius + 14 * this.isUpgraded)
b.foam(this.position, velocity, radius + 9 * this.isUpgraded)
break;
}
}
@@ -1582,7 +1593,7 @@ const b = {
y: this.position.y + range * unit.y
}
];
const vertexCollision = function (v1, v1End, domain) {
const vertexCollision = function(v1, v1End, domain) {
for (let i = 0; i < domain.length; ++i) {
let vertices = domain[i].vertices;
const len = vertices.length - 1;
@@ -1713,8 +1724,21 @@ const b = {
mask: 0 //cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
},
beforeDmg() {},
onEnd() {},
range: 190 + 50 * mod.isOrbitBotUpgrade, //range is set in bot upgrade too! //150 + (80 + 100 * mod.isOrbitBotUpgrade) * Math.random(), // + 5 * mod.orbitBotCount,
onEnd() {
//reorder orbital bot positions around a circle
let totalOrbitalBots = 0
for (let i = 0; i < bullet.length; i++) {
if (bullet[i].botType === 'orbit' && bullet[i] !== this) totalOrbitalBots++
}
let index = 0
for (let i = 0; i < bullet.length; i++) {
if (bullet[i].botType === 'orbit' && bullet[i] !== this) {
bullet[i].phase = (index / totalOrbitalBots) * 2 * Math.PI
index++
}
}
},
range: 190 + 60 * mod.isOrbitBotUpgrade, //range is set in bot upgrade too! //150 + (80 + 100 * mod.isOrbitBotUpgrade) * Math.random(), // + 5 * mod.orbitBotCount,
orbitalSpeed: 0,
phase: 2 * Math.PI * Math.random(),
do() {
@@ -1735,7 +1759,7 @@ const b = {
})
for (let i = 0; i < q.length; i++) {
mobs.statusStun(q[i], 180)
const dmg = 0.5 * b.dmgScale * (this.isUpgraded ? 2.25 : 1) * (mod.isCrit ? 4 : 1)
const dmg = 0.5 * b.dmgScale * (this.isUpgraded ? 2 : 1) * (mod.isCrit ? 4 : 1)
q[i].damage(dmg);
q[i].foundPlayer();
game.drawList.push({ //add dmg to draw queue
@@ -1759,7 +1783,6 @@ const b = {
// bullet[me].orbitalSpeed = Math.sqrt(0.7 / bullet[me].range)
bullet[me].orbitalSpeed = Math.sqrt(0.25 / bullet[me].range) //also set in bot upgrade too!
// bullet[me].phase = (index / mod.orbitBotCount) * 2 * Math.PI
World.add(engine.world, bullet[me]); //add bullet to world
//reorder orbital bot positions around a circle
@@ -1856,7 +1879,7 @@ const b = {
y: mech.Vy / 2 + speed * Math.sin(angle)
}, dmg) //position, velocity, damage
if (mod.isIceCrystals) {
bullet[bullet.length - 1].beforeDmg = function (who) {
bullet[bullet.length - 1].beforeDmg = function(who) {
mobs.statusSlow(who, 30)
if (mod.isNailPoison) mobs.statusDoT(who, dmg * 0.22, 120) // one tick every 30 cycles
if (mod.isNailCrit && !who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.99) this.dmg *= 5 //crit if hit near center
@@ -1927,7 +1950,7 @@ const b = {
bullet[me].minDmgSpeed = 15
// bullet[me].restitution = 0.4
bullet[me].frictionAir = 0.034;
bullet[me].do = function () {
bullet[me].do = function() {
if (!mech.isBodiesAsleep) {
const scale = 1 - 0.034 / mod.isBulletsLastLonger
Matter.Body.scale(this, scale, scale);
@@ -1961,10 +1984,10 @@ const b = {
bullet[me].minDmgSpeed = 0;
bullet[me].restitution = 1;
bullet[me].friction = 0;
bullet[me].do = function () {
bullet[me].do = function() {
this.force.y += this.mass * 0.001;
};
bullet[me].beforeDmg = function (who) {
bullet[me].beforeDmg = function(who) {
mobs.statusStun(who, 180) // (2.3) * 2 / 14 ticks (2x damage over 7 seconds)
};
} else {
@@ -1984,7 +2007,7 @@ const b = {
bullet[me].minDmgSpeed = 0;
bullet[me].restitution = 0.99;
bullet[me].friction = 0;
bullet[me].do = function () {
bullet[me].do = function() {
this.force.y += this.mass * 0.001;
};
dir += SPREAD;
@@ -2010,7 +2033,7 @@ const b = {
bullet[me].endCycle = game.cycle + 180;
bullet[me].dmg = 0;
bullet[me].immuneList = []
bullet[me].do = function () {
bullet[me].do = function() {
const whom = Matter.Query.collides(this, mob)
if (whom.length && this.speed > 20) { //if touching a mob
who = whom[0].bodyA
@@ -2065,7 +2088,7 @@ const b = {
x: 0,
y: 0
});
this.do = function () {}
this.do = function() {}
} else if (this.speed < 30) {
this.force.y += this.mass * 0.0007; //no gravity until it slows down to improve aiming
}
@@ -2140,7 +2163,7 @@ const b = {
// check if inside a mob
q = Matter.Query.point(mob, this.position)
for (let i = 0; i < q.length; i++) {
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
let dmg = b.dmgScale * 0.36 / Math.sqrt(q[i].mass) * (mod.waveHelix === 1 ? 1 : 0.8) //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
@@ -2173,7 +2196,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.36 / Math.sqrt(q[i].mass) * (mod.waveHelix === 1 ? 1 : 0.66) //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.8) //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
@@ -2243,7 +2266,7 @@ const b = {
fire() {
if (mod.is3Missiles) {
if (mech.crouch) {
mech.fireCDcycle = mech.cycle + 60 * b.fireCD; // cool down
mech.fireCDcycle = mech.cycle + 50 * b.fireCD; // cool down
const direction = {
x: Math.cos(mech.angle),
y: Math.sin(mech.angle)
@@ -2259,7 +2282,7 @@ const b = {
bullet[bullet.length - 1].force.y += push.y * (i - 1);
}
} else {
mech.fireCDcycle = mech.cycle + 45 * b.fireCD; // cool down
mech.fireCDcycle = mech.cycle + 35 * b.fireCD; // cool down
const direction = {
x: Math.cos(mech.angle),
y: Math.sin(mech.angle)
@@ -2276,7 +2299,7 @@ const b = {
}
}
} else {
mech.fireCDcycle = mech.cycle + Math.floor(mech.crouch ? 45 : 30) * b.fireCD; // cool down
mech.fireCDcycle = mech.cycle + Math.floor(mech.crouch ? 40 : 25) * b.fireCD; // cool down
b.missile({
x: mech.pos.x + 40 * Math.cos(mech.angle),
y: mech.pos.y + 40 * Math.sin(mech.angle) - 3
@@ -2318,13 +2341,13 @@ const b = {
bullet[me].restitution = 0;
bullet[me].friction = 1;
bullet[me].explodeRad = (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50;
bullet[me].onEnd = function () {
bullet[me].onEnd = function() {
b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
}
bullet[me].beforeDmg = function () {
bullet[me].beforeDmg = function() {
this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
};
bullet[me].do = function () {
bullet[me].do = function() {
// this.force.y += this.mass * 0.0004;
}
}
@@ -2345,12 +2368,12 @@ const b = {
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, b.fireAttributes(dir, false));
Matter.Body.setDensity(bullet[me], 0.0005);
bullet[me].explodeRad = 275;
bullet[me].onEnd = function () {
bullet[me].onEnd = function() {
b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
if (mod.grenadeFragments) b.targetedNail(this.position, mod.grenadeFragments)
}
bullet[me].minDmgSpeed = 1;
bullet[me].beforeDmg = function () {
bullet[me].beforeDmg = function() {
this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
};
if (mod.isRPG) {
@@ -2362,7 +2385,7 @@ const b = {
x: bullet[me].mass * MAG * Math.cos(dir),
y: bullet[me].mass * MAG * Math.sin(dir)
}
bullet[me].do = function () {
bullet[me].do = function() {
this.force.x += this.thrust.x;
this.force.y += this.thrust.y;
if (Matter.Query.collides(this, map).length || Matter.Query.collides(this, body).length) {
@@ -2373,7 +2396,7 @@ const b = {
b.fireProps(mech.crouch ? 40 : 30, mech.crouch ? 43 : 32, dir, me); //cd , speed
bullet[me].endCycle = game.cycle + Math.floor(mech.crouch ? 120 : 80);
bullet[me].restitution = 0.4;
bullet[me].do = function () {
bullet[me].do = function() {
this.force.y += this.mass * 0.0025; //extra gravity for harder arcs
};
}
@@ -2384,16 +2407,16 @@ const b = {
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, b.fireAttributes(dir, false));
Matter.Body.setDensity(bullet[me], 0.0003);
bullet[me].explodeRad = 350 + Math.floor(Math.random() * 50);;
bullet[me].onEnd = function () {
bullet[me].onEnd = function() {
b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
if (mod.grenadeFragments) b.targetedNail(this.position, mod.grenadeFragments)
}
bullet[me].beforeDmg = function () {};
bullet[me].beforeDmg = function() {};
const cd = mech.crouch ? 90 : 75
b.fireProps(cd, mech.crouch ? 46 : 35, dir, me); //cd , speed
bullet[me].endCycle = game.cycle + cd;
bullet[me].restitution = 0.4;
bullet[me].do = function () {
bullet[me].do = function() {
this.force.y += this.mass * 0.0025; //extra gravity for harder arcs
const suckCycles = 40
@@ -2464,9 +2487,9 @@ const b = {
bullet[me].maxDamageRadius = (435 + 150 * Math.random()) * (mod.isNeutronImmune ? 1.2 : 1)
bullet[me].stuckTo = null;
bullet[me].stuckToRelativePosition = null;
bullet[me].beforeDmg = function () {};
bullet[me].stuck = function () {};
bullet[me].do = function () {
bullet[me].beforeDmg = function() {};
bullet[me].stuck = function() {};
bullet[me].do = function() {
function onCollide(that) {
that.collisionFilter.mask = 0; //non collide with everything
Matter.Body.setVelocity(that, {
@@ -2511,14 +2534,14 @@ const b = {
//find the relative position for when the mob is at angle zero by undoing the mobs rotation
this.stuckToRelativePosition = Vector.rotate(Vector.sub(this.position, this.stuckTo.position), -this.stuckTo.angle)
}
this.stuck = function () {
this.stuck = function() {
if (this.stuckTo && this.stuckTo.alive) {
const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
Matter.Body.setVelocity(this, this.stuckTo.velocity); //so that it will move properly if it gets unstuck
} else {
this.collisionFilter.mask = cat.map | cat.body | cat.player | cat.mob; //non collide with everything but map
this.stuck = function () {
this.stuck = function() {
this.force.y += this.mass * 0.001;
}
}
@@ -2534,7 +2557,7 @@ const b = {
} else {
this.do = this.radiationMode;
}
this.stuck = function () {
this.stuck = function() {
if (this.stuckTo) {
const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
@@ -2552,7 +2575,7 @@ const b = {
}
}
}
bullet[me].radiationMode = function () {
bullet[me].radiationMode = function() {
this.stuck(); //runs different code based on what the bullet is stuck to
if (!mech.isBodiesAsleep) {
this.damageRadius = this.damageRadius * 0.85 + 0.15 * this.maxDamageRadius //smooth radius towards max
@@ -2634,9 +2657,9 @@ const b = {
bullet[me].restitution = 0.3;
bullet[me].minDmgSpeed = 0;
bullet[me].totalSpores = 8 + 2 * mod.isFastSpores + 2 * mod.isSporeFreeze
bullet[me].stuck = function () {};
bullet[me].beforeDmg = function () {};
bullet[me].do = function () {
bullet[me].stuck = function() {};
bullet[me].beforeDmg = function() {};
bullet[me].do = function() {
function onCollide(that) {
that.collisionFilter.mask = 0; //non collide with everything
Matter.Body.setVelocity(that, {
@@ -2660,14 +2683,14 @@ const b = {
//find the relative position for when the mob is at angle zero by undoing the mobs rotation
this.stuckToRelativePosition = Vector.rotate(Vector.sub(this.position, this.stuckTo.position), -this.stuckTo.angle)
}
this.stuck = function () {
this.stuck = function() {
if (this.stuckTo && this.stuckTo.alive) {
const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
Matter.Body.setVelocity(this, this.stuckTo.velocity); //so that it will move properly if it gets unstuck
} else {
this.collisionFilter.mask = cat.map; //non collide with everything but map
this.stuck = function () {
this.stuck = function() {
this.force.y += this.mass * 0.0006;
}
}
@@ -2683,7 +2706,7 @@ const b = {
} else {
this.do = this.grow;
}
this.stuck = function () {
this.stuck = function() {
if (this.stuckTo) {
const rotate = Vector.rotate(this.stuckToRelativePosition, this.stuckTo.angle) //add in the mob's new angle to the relative position vector
Matter.Body.setPosition(this, Vector.add(Vector.add(rotate, this.stuckTo.velocity), this.stuckTo.position))
@@ -2707,7 +2730,7 @@ const b = {
ctx.fill();
}
bullet[me].grow = function () {
bullet[me].grow = function() {
this.stuck(); //runs different code based on what the bullet is stuck to
if (!mech.isBodiesAsleep) {
let scale = 1.01
@@ -2736,7 +2759,7 @@ const b = {
};
//spawn bullets on end
bullet[me].onEnd = function () {
bullet[me].onEnd = function() {
const NUM = this.totalSpores
for (let i = 0; i < NUM; i++) {
b.spore(this.position)
@@ -2958,7 +2981,7 @@ const b = {
World.add(engine.world, bullet[me]); //add bullet to world
bullet[me].endCycle = Infinity
bullet[me].charge = 0;
bullet[me].do = function () {
bullet[me].do = function() {
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
@@ -2969,7 +2992,7 @@ const b = {
if ((!input.fire && 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.do = function() {
this.force.y += this.mass * 0.0003 / this.charge; // low gravity that scales with charge
}
if (mod.isRailTimeSlow) {
@@ -3046,7 +3069,7 @@ const b = {
y: mech.pos.y + range * Math.sin(dir)
}
];
const vertexCollision = function (v1, v1End, domain) {
const vertexCollision = function(v1, v1End, domain) {
for (let i = 0; i < domain.length; ++i) {
let vertices = domain[i].vertices;
const len = vertices.length - 1;
@@ -3257,7 +3280,7 @@ const b = {
y: mech.pos.y + range * Math.sin(angle)
}
];
const vertexCollision = function (v1, v1End, domain) {
const vertexCollision = function(v1, v1End, domain) {
for (let i = 0; i < domain.length; ++i) {
let vertices = domain[i].vertices;
const len = vertices.length - 1;

View File

@@ -459,70 +459,14 @@ const game = {
addGravity(body, game.g);
player.force.y += player.mass * game.g;
},
reset() { //run on first run, and each later run after you die
input.endKeySensing();
b.removeAllGuns();
game.isNoPowerUps = false;
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
mech.hole.isOn = false
game.paused = false;
engine.timing.timeScale = 1;
game.fpsCap = game.fpsCapDefault;
game.isAutoZoom = true;
game.makeGunHUD();
mech.drop();
mech.holdingTarget = null
mech.addHealth(Infinity);
mech.alive = true;
level.onLevel = 0;
level.levelsCleared = 0;
// reset() { //run on first run, and each later run after you die
//resetting difficulty
game.dmgScale = 0; //increases in level.difficultyIncrease
b.dmgScale = 1; //decreases in level.difficultyIncrease
game.accelScale = 1;
game.lookFreqScale = 1;
game.CDScale = 1;
game.difficulty = 0;
game.difficultyMode = Number(document.getElementById("difficulty-select").value)
build.isCustomSelection = false;
// if (game.difficultyMode > 2) {
// level.difficultyIncrease(game.difficultyMode)
// level.difficultyIncrease(game.difficultyMode)
// }
game.clearNow = true;
document.getElementById("text-log").style.opacity = 0;
document.getElementById("fade-out").style.opacity = 0;
document.title = "n-gon";
//set to default field
mech.fieldMode = 0;
game.replaceTextLog = true;
game.makeTextLog(`${game.SVGrightMouse}<strong style='font-size:30px;'> ${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'></span><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 600);
mech.setField(mech.fieldMode)
//exit testing
if (game.testing) {
game.testing = false;
game.loop = game.normalLoop
if (game.isConstructionMode) {
document.getElementById("construct").style.display = 'none'
}
}
game.isCheating = false
},
// },
firstRun: true,
splashReturn() {
game.onTitlePage = true;
// document.getElementById('splash').onclick = 'run(this)';
document.getElementById("splash").onclick = function () {
document.getElementById("splash").onclick = function() {
game.startGame();
};
document.getElementById("choose-grid").style.display = "none"
@@ -553,8 +497,8 @@ const game = {
document.getElementById("dmg").style.display = "inline";
document.getElementById("health-bg").style.display = "inline";
if (game.firstRun) {
mech.spawn(); //spawns the player
if (game.isCommunityMaps) {
level.levels.push("stronghold");
level.levels.push("basement");
@@ -562,9 +506,64 @@ const game = {
level.levels.push("house");
}
level.levels = shuffle(level.levels); //shuffles order of maps
level.levels.unshift("bosses"); //add bosses level to the end of the randomized levels list
level.levels.unshift("intro"); //add level to the start of the randomized levels list
level.levels.push("gauntlet"); //add level to the end of the randomized levels list
level.levels.push("finalBoss"); //add level to the end of the randomized levels list
input.endKeySensing();
b.removeAllGuns();
game.isNoPowerUps = false;
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
mech.hole.isOn = false
game.paused = false;
engine.timing.timeScale = 1;
game.fpsCap = game.fpsCapDefault;
game.isAutoZoom = true;
game.makeGunHUD();
mech.drop();
mech.holdingTarget = null
mech.health = 0.25;
mech.displayHealth();
mech.alive = true;
level.onLevel = 0;
level.levelsCleared = 0;
//resetting difficulty
game.dmgScale = 0; //increases in level.difficultyIncrease
b.dmgScale = 1; //decreases in level.difficultyIncrease
game.accelScale = 1;
game.lookFreqScale = 1;
game.CDScale = 1;
game.difficulty = 0;
game.difficultyMode = Number(document.getElementById("difficulty-select").value)
build.isCustomSelection = false;
game.clearNow = true;
document.getElementById("text-log").style.opacity = 0;
document.getElementById("fade-out").style.opacity = 0;
document.title = "n-gon";
//set to default field
mech.fieldMode = 0;
game.replaceTextLog = true;
game.makeTextLog(`${game.SVGrightMouse}<strong style='font-size:30px;'> ${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'></span><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 600);
mech.setField(mech.fieldMode)
//exit testing
if (game.testing) {
game.testing = false;
game.loop = game.normalLoop
if (game.isConstructionMode) {
document.getElementById("construct").style.display = 'none'
}
game.reset();
}
game.isCheating = false
game.firstRun = false;
//setup FPS cap
@@ -744,7 +743,7 @@ const game = {
}
if (!(game.cycle % 420)) { //once every 7 seconds
fallCheck = function (who, save = false) {
fallCheck = function(who, save = false) {
let i = who.length;
while (i--) {
if (who[i].position.y > game.fallHeight) {

View File

@@ -53,7 +53,7 @@ if (screen.height < 800) {
//difficulty is 0 easy, 1 normal, 2 hard, 4 why
function getUrlVars() {
let vars = {};
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function (m, k, v) {
window.location.href.replace(/[?&]+([^=&]+)=([^&]*)/gi, function(m, k, v) {
vars[k] = v;
});
return vars;
@@ -122,7 +122,7 @@ const ctx = canvas.getContext("2d");
document.body.style.backgroundColor = "#fff";
//disable pop up menu on right click
document.oncontextmenu = function () {
document.oncontextmenu = function() {
return false;
}
@@ -191,7 +191,7 @@ const build = {
<br>position: (${player.position.x.toFixed(1)}, ${player.position.y.toFixed(1)}) &nbsp; velocity: (${player.velocity.x.toFixed(1)}, ${player.velocity.y.toFixed(1)})
<br>mouse: (${game.mouseInGame.x.toFixed(1)}, ${game.mouseInGame.y.toFixed(1)}) &nbsp; mass: ${player.mass.toFixed(1)}
<br>
<br>level: ${level.levelsCleared} - ${level.levelsCleared===0?"intro":level.levels[level.onLevel]} (${level.difficultyText()}) &nbsp; ${mech.cycle} cycles
<br>level: ${level.levels[level.onLevel]} (${level.difficultyText()}) &nbsp; ${mech.cycle} cycles
<br>${mob.length} mobs, &nbsp; ${body.length} blocks, &nbsp; ${bullet.length} bullets, &nbsp; ${powerUp.length} power ups
<br>damage difficulty scale: ${(b.dmgScale*100).toFixed(2) }%
<br>harm difficulty scale: ${(game.dmgScale*100).toFixed(0)}%
@@ -642,14 +642,14 @@ document.getElementById("control-table").addEventListener('click', (event) => {
window.addEventListener("keydown", input.setKeys);
}
});
document.getElementById("control-details").addEventListener("toggle", function () {
document.getElementById("control-details").addEventListener("toggle", function() {
input.controlTextUpdate()
input.endKeySensing();
})
document.getElementById("control-reset").addEventListener('click', input.setDefault);
window.addEventListener("keyup", function (event) {
window.addEventListener("keyup", function(event) {
switch (event.code) {
case input.key.right:
case "ArrowRight":
@@ -673,7 +673,7 @@ window.addEventListener("keyup", function (event) {
}
});
window.addEventListener("keydown", function (event) {
window.addEventListener("keydown", function(event) {
switch (event.code) {
case input.key.right:
case "ArrowRight":
@@ -703,7 +703,7 @@ window.addEventListener("keydown", function (event) {
case input.key.pause:
if (!game.isChoosing && input.isPauseKeyReady && mech.alive) {
input.isPauseKeyReady = false
setTimeout(function () {
setTimeout(function() {
input.isPauseKeyReady = true
}, 300);
if (game.paused) {

File diff suppressed because it is too large Load Diff

View File

@@ -87,12 +87,12 @@ const mod = {
if (mod.isDamageForGuns) dmg *= 1 + 0.07 * b.inventory.length
if (mod.isLowHealthDmg) dmg *= 1 + 0.6 * Math.max(0, 1 - mech.health)
if (mod.isHarmDamage && mech.lastHarmCycle + 600 > mech.cycle) dmg *= 2;
if (mod.isEnergyLoss) dmg *= 1.43;
if (mod.isEnergyLoss) dmg *= 1.5;
if (mod.isAcidDmg && mech.health > 1) dmg *= 1.4;
if (mod.restDamage > 1 && player.speed < 1) dmg *= mod.restDamage
if (mod.isEnergyDamage) dmg *= 1 + mech.energy / 5.5;
if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.0038
if (mod.isRerollDamage) dmg *= 1 + 0.05 * powerUps.reroll.rerolls
if (mod.isRerollDamage) dmg *= 1 + 0.06 * powerUps.reroll.rerolls
if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.25
if (mod.isNoFireDamage && mech.cycle > mech.fireCDcycle + 120) dmg *= 1.5
return dmg * mod.slowFire * mod.aimDamage
@@ -149,7 +149,7 @@ const mod = {
},
{
name: "acute stress response",
description: "increase <strong class='color-d'>damage</strong> by <strong>43%</strong><br>if a mob <strong>dies</strong> drain stored <strong class='color-f'>energy</strong> by <strong>25%</strong>",
description: "increase <strong class='color-d'>damage</strong> by <strong>50%</strong><br>if a mob <strong>dies</strong> drain stored <strong class='color-f'>energy</strong> by <strong>25%</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -245,7 +245,7 @@ const mod = {
},
{
name: "perturbation theory",
description: "increase <strong class='color-d'>damage</strong> by <strong>5%</strong><br>for each of your <strong class='color-r'>rerolls</strong>",
description: "increase <strong class='color-d'>damage</strong> by <strong>6%</strong><br>for each of your <strong class='color-r'>rerolls</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -259,26 +259,6 @@ const mod = {
mod.isRerollDamage = false;
}
},
{
name: "Ψ(t) collapse",
description: "<strong>60%</strong> decreased <strong>delay</strong> after firing<br>if you have no <strong class='color-r'>rerolls</strong>",
maxCount: 1,
count: 0,
allowed() {
return powerUps.reroll.rerolls === 0 && !mod.manyWorlds
},
requires: "no rerolls",
effect() {
mod.isRerollHaste = true;
mod.rerollHaste = 0.4;
b.setFireCD();
},
remove() {
mod.isRerollHaste = false;
mod.rerollHaste = 1;
b.setFireCD();
}
},
{
name: "electrostatic discharge",
description: "increase <strong class='color-d'>damage</strong> by <strong>20%</strong><br><strong>20%</strong> increased <strong>delay</strong> after firing",
@@ -296,6 +276,26 @@ const mod = {
b.setFireCD();
}
},
{
name: "Ψ(t) collapse",
description: "<strong>66%</strong> decreased <strong>delay</strong> after firing<br>if you have no <strong class='color-r'>rerolls</strong>",
maxCount: 1,
count: 0,
allowed() {
return powerUps.reroll.rerolls === 0 && !mod.manyWorlds
},
requires: "no rerolls",
effect() {
mod.isRerollHaste = true;
mod.rerollHaste = 0.33;
b.setFireCD();
},
remove() {
mod.isRerollHaste = false;
mod.rerollHaste = 1;
b.setFireCD();
}
},
{
name: "auto-loading heuristics",
description: "<strong>30%</strong> decreased <strong>delay</strong> after firing",
@@ -558,7 +558,7 @@ const mod = {
},
{
name: "foam-bot upgrade",
description: "<strong>200%</strong> increased <strong>foam size</strong><br><em>applies to all current and future foam-bots</em>",
description: "<strong>150%</strong> increased <strong>foam size</strong><br><em>applies to all current and future foam-bots</em>",
maxCount: 1,
count: 0,
allowed() {
@@ -675,7 +675,7 @@ const mod = {
},
{
name: "orbital-bot upgrade",
description: "<strong>125%</strong> increased <strong class='color-d'>damage</strong><br><em>applies to all current and future orbit-bots</em>",
description: "increase <strong class='color-d'>damage</strong> by <strong>100%</strong> and <strong>radius</strong> by <strong>30%</strong><br><em>applies to all current and future orbit-bots</em>",
maxCount: 1,
count: 0,
allowed() {
@@ -684,15 +684,24 @@ const mod = {
requires: "2 or more orbital bots",
effect() {
mod.isOrbitBotUpgrade = true
const range = 190 + 60 * mod.isOrbitBotUpgrade
for (let i = 0; i < bullet.length; i++) {
if (bullet[i].botType === 'orbit') bullet[i].isUpgraded = true
if (bullet[i].botType === 'orbit') {
bullet[i].isUpgraded = true
bullet[i].range = range
bullet[i].orbitalSpeed = Math.sqrt(0.25 / range)
}
}
},
remove() {
mod.isOrbitBotUpgrade = false
const range = 190 + 60 * mod.isOrbitBotUpgrade
for (let i = 0; i < bullet.length; i++) {
if (bullet[i].botType === 'orbit') bullet[i].isUpgraded = false
if (bullet[i].botType === 'orbit') {
bullet[i].range = range
bullet[i].orbitalSpeed = Math.sqrt(0.25 / range)
}
}
}
},
@@ -946,7 +955,7 @@ const mod = {
maxCount: 1,
count: 0,
allowed() {
return mod.isPiezo
return mod.isPiezo && !mod.timeEnergyRegen
},
requires: "piezoelectricity",
effect: () => {
@@ -1169,7 +1178,7 @@ const mod = {
name: "anthropic principle",
nameInfo: "<span id = 'mod-anthropic'></span>",
addNameInfo() {
setTimeout(function () {
setTimeout(function() {
powerUps.reroll.changeRerolls(0)
}, 1000);
},
@@ -1182,7 +1191,7 @@ const mod = {
requires: "at least 1 reroll",
effect() {
mod.isDeathAvoid = true;
setTimeout(function () {
setTimeout(function() {
powerUps.reroll.changeRerolls(0)
}, 1000);
},
@@ -1254,7 +1263,7 @@ const mod = {
name: "entanglement",
nameInfo: "<span id = 'mod-entanglement'></span>",
addNameInfo() {
setTimeout(function () {
setTimeout(function() {
game.boldActiveGunHUD();
}, 1000);
},
@@ -1267,7 +1276,7 @@ const mod = {
requires: "at least 2 guns",
effect() {
mod.isEntanglement = true
setTimeout(function () {
setTimeout(function() {
game.boldActiveGunHUD();
}, 1000);
@@ -1893,7 +1902,7 @@ const mod = {
},
{
name: "wave packet",
description: "<strong>wave beam</strong> emits <strong>two</strong> oscillating particles<br>decrease wave <strong class='color-d'>damage</strong> by <strong>33%</strong>",
description: "<strong>wave beam</strong> emits <strong>two</strong> oscillating particles<br>decrease wave <strong class='color-d'>damage</strong> by <strong>20%</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -1943,7 +1952,7 @@ const mod = {
},
{
name: "recursion",
description: "after <strong>missiles</strong> <strong class='color-e'>explode</strong> they have a<br><strong>30%</strong> chance to launch a larger <strong>missile</strong>",
description: "after <strong>missiles</strong> <strong class='color-e'>explode</strong> they have a<br><strong>20%</strong> chance to launch a larger <strong>missile</strong>",
maxCount: 6,
count: 0,
allowed() {
@@ -2622,6 +2631,24 @@ const mod = {
b.setFireCD();
}
},
{
name: "time crystals",
description: "<strong>quadruple</strong> your default <strong class='color-f'>energy</strong> regeneration",
maxCount: 1,
count: 0,
allowed() {
return mech.fieldUpgrades[mech.fieldMode].name === "time dilation field"
},
requires: "time dilation field",
effect: () => {
mod.energyRegen = 0.004;
mech.fieldRegen = mod.energyRegen;
},
remove() {
mod.energyRegen = 0.001;
mech.fieldRegen = mod.energyRegen;
}
},
{
name: "plasma jet",
description: "increase <strong class='color-plasma'>plasma</strong> <strong>torch's</strong> range by <strong>27%</strong>",
@@ -2871,7 +2898,7 @@ const mod = {
},
{
name: "cosmic string",
description: "when you <strong> tunnel</strong> through a <strong class='color-worm'>wormhole</strong><br>mobs between the <strong>endpoints</strong> take <strong class='color-d'>damage</strong>",
description: "<strong>stun</strong> and do <strong class='color-p'>radioactive</strong> <strong class='color-d'>damage</strong> to <strong>mobs</strong><br>if you tunnel through them with a <strong class='color-worm'>wormhole</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -3178,5 +3205,6 @@ const mod = {
isWormBullets: null,
isWideLaser: null,
wideLaser: null,
isPulseLaser: null
isPulseLaser: null,
timeEnergyRegen: null
}

View File

@@ -373,7 +373,7 @@ const mech = {
}
game.wipe = function () { //set wipe to have trails
game.wipe = function() { //set wipe to have trails
ctx.fillStyle = "rgba(255,255,255,0)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
// pixelWindows()
@@ -395,11 +395,11 @@ const mech = {
randomizeEverything()
const swapPeriod = 1000
for (let i = 0, len = 5; i < len; i++) {
setTimeout(function () {
setTimeout(function() {
randomizeEverything()
game.replaceTextLog = true;
game.makeTextLog(`probability amplitude will synchronize in ${len-i-1} seconds`, swapPeriod);
game.wipe = function () { //set wipe to have trails
game.wipe = function() { //set wipe to have trails
ctx.fillStyle = `rgba(255,255,255,${(i+1)*(i+1)*0.006})`;
ctx.fillRect(0, 0, canvas.width, canvas.height);
// pixelWindows()
@@ -407,8 +407,8 @@ const mech = {
}, (i + 1) * swapPeriod);
}
setTimeout(function () {
game.wipe = function () { //set wipe to normal
setTimeout(function() {
game.wipe = function() { //set wipe to normal
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
game.replaceTextLog = true;
@@ -422,7 +422,7 @@ const mech = {
mech.displayHealth();
document.getElementById("text-log").style.opacity = 0; //fade out any active text logs
document.getElementById("fade-out").style.opacity = 1; //slowly fades out
setTimeout(function () {
setTimeout(function() {
game.splashReturn();
}, 3000);
}
@@ -503,12 +503,12 @@ const mech = {
game.makeTextLog(`<span style='font-size:115%;'> <strong>death</strong> avoided<br><strong>${powerUps.reroll.rerolls}</strong> <strong class='color-r'>rerolls</strong> left</span>`, 420)
mech.energy = mech.maxEnergy
mech.immuneCycle = mech.cycle + 120 //disable this.immuneCycle bonus seconds
game.wipe = function () { //set wipe to have trails
game.wipe = function() { //set wipe to have trails
ctx.fillStyle = "rgba(255,255,255,0.03)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
setTimeout(function () {
game.wipe = function () { //set wipe to normal
setTimeout(function() {
game.wipe = function() { //set wipe to normal
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
}, 2000);
@@ -535,12 +535,12 @@ const mech = {
mech.immuneCycle = mech.cycle + 120 //disable this.immuneCycle bonus seconds
// game.makeTextLog("<span style='font-size:115%;'> <strong>death</strong> avoided<br><strong>1</strong> <strong class='color-r'>reroll</strong> consumed</span>", 420)
game.wipe = function () { //set wipe to have trails
game.wipe = function() { //set wipe to have trails
ctx.fillStyle = "rgba(255,255,255,0.03)";
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
setTimeout(function () {
game.wipe = function () { //set wipe to normal
setTimeout(function() {
game.wipe = function() { //set wipe to normal
ctx.clearRect(0, 0, canvas.width, canvas.height);
}
}, 2000);
@@ -557,7 +557,7 @@ const mech = {
if (dmg > 0.06 / mech.holdingMassScale) mech.drop(); //drop block if holding
const normalFPS = function () {
const normalFPS = function() {
if (mech.defaultFPSCycle < mech.cycle) { //back to default values
game.fpsCap = game.fpsCapDefault
game.fpsInterval = 1000 / game.fpsCap;
@@ -918,7 +918,7 @@ const mech = {
mech.holdingTarget.collisionFilter.category = cat.body; //cat.bullet;
mech.holdingTarget.collisionFilter.mask = cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield;
//check every second to see if player is away from thrown body, and make solid
const solid = function (that) {
const solid = function(that) {
const dx = that.position.x - player.position.x;
const dy = that.position.y - player.position.y;
if (dx * dx + dy * dy > 10000 && that !== mech.holdingTarget) {
@@ -1122,31 +1122,6 @@ const mech = {
}
}
},
// pushBodyFacing() { // push all body in range and in direction looking
// for (let i = 0, len = body.length; i < len; ++i) {
// if (
// body[i].speed > 12 && body[i].mass > 2 &&
// Vector.magnitude(Vector.sub(body[i].position, mech.pos)) < mech.fieldRange &&
// mech.lookingAt(body[i]) &&
// Matter.Query.ray(map, body[i].position, mech.pos).length === 0
// ) {
// mech.pushMass(body[i]);
// }
// }
// },
// pushBody360(range = mech.fieldRange * 0.75) { // push all body in range and in direction looking
// for (let i = 0, len = body.length; i < len; ++i) {
// if (
// body[i].speed > 12 && body[i].mass > 2 &&
// Vector.magnitude(Vector.sub(body[i].position, mech.pos)) < range &&
// mech.lookingAt(body[i]) &&
// Matter.Query.ray(map, body[i].position, mech.pos).length === 0 &&
// body[i].collisionFilter.category === cat.body
// ) {
// mech.pushMass(body[i]);
// }
// }
// },
lookForPickUp() { //find body to pickup
if (mech.energy > mech.fieldRegen) mech.energy -= mech.fieldRegen;
const grabbing = {
@@ -1250,7 +1225,7 @@ const mech = {
description: "use <strong class='color-f'>energy</strong> to <strong>block</strong> mobs<br><strong>throw</strong> blocks to <strong class='color-d'>damage</strong> mobs<br><strong>pick up</strong> power ups",
effect: () => {
game.replaceTextLog = true; //allow text over write
mech.hold = function () {
mech.hold = function() {
if (mech.isHolding) {
mech.drawHold(mech.holdingTarget);
mech.holding();
@@ -1277,7 +1252,7 @@ const mech = {
effect: () => {
// mech.fieldHarmReduction = 0.80;
mech.fieldBlockCD = 0;
mech.hold = function () {
mech.hold = function() {
if (mech.isHolding) {
mech.drawHold(mech.holdingTarget);
mech.holding();
@@ -1323,7 +1298,7 @@ const mech = {
// mech.fieldMeterColor = "#0af"
// mech.fieldArc = 0.3; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
// mech.calculateFieldThreshold();
mech.hold = function () {
mech.hold = function() {
const wave = Math.sin(mech.cycle * 0.022);
mech.fieldRange = 170 + 12 * wave
mech.fieldArc = 0.33 + 0.045 * wave //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
@@ -1370,11 +1345,11 @@ const mech = {
mech.drawFieldMeter()
if (mod.isPerfectBrake) { //cap mob speed around player
const range = 400 + 120 * wave
const range = 350 + 140 * wave
for (let i = 0; i < mob.length; i++) {
const distance = Vector.magnitude(Vector.sub(mech.pos, mob[i].position))
if (distance < range) {
const cap = mob[i].isShielded ? 8 : 4
const cap = mob[i].isShielded ? 8.5 : 4.5
if (mob[i].speed > cap && Vector.dot(mob[i].velocity, Vector.sub(mech.pos, mob[i].position)) > 0) { // if velocity is directed towards player
Matter.Body.setVelocity(mob[i], Vector.mult(Vector.normalise(mob[i].velocity), cap)); //set velocity to cap, but keep the direction
}
@@ -1390,9 +1365,9 @@ const mech = {
},
{
name: "nano-scale manufacturing",
description: "use <strong class='color-f'>energy</strong> to <strong>block</strong> mobs<br>excess <strong class='color-f'>energy</strong> used to build <strong>drones</strong><br>increase <strong class='color-f'>energy</strong> regeneration by <strong>100%</strong>",
description: "use <strong class='color-f'>energy</strong> to <strong>block</strong> mobs<br>excess <strong class='color-f'>energy</strong> used to build <strong>drones</strong><br><strong>double</strong> your default <strong class='color-f'>energy</strong> regeneration",
effect: () => {
mech.hold = function () {
mech.hold = function() {
if (mech.energy > mech.maxEnergy - 0.02 && mech.fieldCDcycle < mech.cycle) {
if (mod.isSporeField) {
// mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones
@@ -1453,7 +1428,7 @@ const mech = {
mech.fieldHarmReduction = 0.6;
mech.fieldDrawRadius = 0;
mech.hold = function () {
mech.hold = function() {
mech.airSpeedLimit = 125 //5 * player.mass * player.mass
mech.FxAir = 0.016
mech.isFieldActive = false;
@@ -1567,7 +1542,7 @@ const mech = {
description: "use <strong class='color-f'>energy</strong> to emit short range <strong class='color-plasma'>plasma</strong><br><strong class='color-d'>damages</strong> and <strong>pushes</strong> mobs away",
effect() {
mech.fieldMeterColor = "#f0f"
mech.hold = function () {
mech.hold = function() {
if (mech.isHolding) {
mech.drawHold(mech.holdingTarget);
mech.holding();
@@ -1595,7 +1570,7 @@ const mech = {
y: mech.pos.y + range * Math.sin(mech.angle)
}
];
const vertexCollision = function (v1, v1End, domain) {
const vertexCollision = function(v1, v1End, domain) {
for (let i = 0; i < domain.length; ++i) {
let vertices = domain[i].vertices;
const len = vertices.length - 1;
@@ -1724,7 +1699,7 @@ const mech = {
// mech.fieldMeterColor = "#000"
mech.fieldFire = true;
mech.isBodiesAsleep = false;
mech.hold = function () {
mech.hold = function() {
if (mech.isHolding) {
mech.wakeCheck();
mech.drawHold(mech.holdingTarget);
@@ -1734,7 +1709,7 @@ const mech = {
mech.grabPowerUp();
mech.lookForPickUp(180);
const DRAIN = 0.0006
const DRAIN = 0.0008
if (mech.energy > DRAIN) {
mech.energy -= DRAIN;
if (mech.energy < DRAIN) {
@@ -1822,7 +1797,7 @@ const mech = {
mech.fieldDrawRadius = 0
const drawRadius = 1000
mech.hold = function () {
mech.hold = function() {
if (mech.isHolding) {
mech.drawHold(mech.holdingTarget);
mech.holding();
@@ -2101,7 +2076,7 @@ const mech = {
mech.fieldOn = false;
mech.fieldRadius = 0;
mech.drop();
mech.hold = function () {
mech.hold = function() {
if (input.field) {
if (mech.fieldCDcycle < mech.cycle) {
const scale = 25
@@ -2258,7 +2233,7 @@ const mech = {
// angle: 0,
// unit:{x:0,y:0},
// }
mech.hold = function () {
mech.hold = function() {
if (mech.hole.isOn) {
// draw holes
mech.fieldRange = 0.97 * mech.fieldRange + 0.03 * (50 + 10 * Math.sin(game.cycle * 0.025))
@@ -2461,19 +2436,11 @@ const mech = {
mech.hole.unit = Vector.perp(Vector.normalise(sub))
if (mod.isWormholeDamage) {
who = Matter.Query.ray(mob, mech.pos, game.mouseInGame, 60)
who = Matter.Query.ray(mob, mech.pos, game.mouseInGame, 80)
for (let i = 0; i < who.length; i++) {
if (who[i].body.alive) {
const dmg = b.dmgScale * 6
who[i].body.damage(dmg);
who[i].body.locatePlayer();
game.drawList.push({ //add dmg to draw queue
x: who[i].body.position.x,
y: who[i].body.position.y,
radius: Math.log(2 * dmg + 1.1) * 40,
color: game.playerDmgColor,
time: game.drawTime
});
mobs.statusDoT(who[i].body, 0.6, 420)
mobs.statusStun(who[i].body, 240)
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -1,10 +1,46 @@
neutron bomb does 60% more damage
powerUpBoss has a shorter vision range, and accelerates slower
custom mode has the option to disable mod, guns, and fields
several changes to community maps (by Francois 👑)
missile moves slightly differently
it used to slow when locked on to a target
now it slows when turning
missiles explode when near any mob
wormhole mod: cosmic string - now stuns mobs and applies radiation damage
mod time dilation: - quadruple your default energy regeneration
added final boss level, it's still in progress so I'd love some feedback
also the game loops back to the intro level after the boss
I'll be working on the ending in the next patch, so the intro level is just a placeholder
************** TODO - n-gon **************
final boss has elements of other bosses
laser mode
if player is on left rotate counter clockwise
if player is on right rotate clockwise
start of laser mode
push block either left or right, not away
vibrating shape
grow and shrink
oscillate elliptical deformation (not sure how)
a bot that eats ammo and converts them into rerolls
or 2 ammo power ups = 1 reroll
been getting some fps slow down after playing for a few minutes
new status effect: fear - push mob away from player for a time
new status effect - apply status effect to mobs that makes blocks attracted to them
only lasts a few cycles
in hard and why have some mobs spawn in later in the level
where
at defined points in array levelSpawns = [{x:0,y:0},{x:0,y:0}]
store the locations of mobs when the level starts to use as respawn points
remove the locations that are close to player
when?
after some mobs are dead
after the boss is killed
mod - explosions apply radiation damage over time
or spawn a neutron bomb with a short timer
@@ -13,26 +49,15 @@ mod self destruct - drones explode when they die
add an ending to the game
add a final boss battle level
final boss has elements of other bosses
alternate between black hole aura and laser beams
fire seeker bullets
drop bombs
tail of shielded mobs
shield
mirror ending (if no cheats)
level after final boss battle is the intro level, but flipped left right, with a fake player
damage the fake player to end the game?
damage the fake player to end the game
message about go outside
no ending (if cheats)
game goes on forever
around level 15
also game goes on if player attacks, the fake player
game never ends if you have used cheats
new status effect - push mob away from player for a time
new status effect - apply status effect to mobs that makes blocks attracted to them
only lasts a few cycles
foam or spore bullet on dmg shrink effect
it might mess with the foam position of other bullets on the mob
shrink when foam bullets end while attached, or shrink on collision?