removed several !m.isBodiesAsleep

this could cause some bugs for bullets or mobs when time is dilated
This commit is contained in:
landgreen
2022-01-18 18:59:26 -08:00
parent 4b8ecfce40
commit 728e33aaad
6 changed files with 967 additions and 1102 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -1272,7 +1272,6 @@ const b = {
}
},
do() {
if (!m.isBodiesAsleep) {
this.cycle++
// if (this.cycle > 40) {
// this.frictionAir = 0.003
@@ -1331,7 +1330,6 @@ const b = {
// this.frictionAir = 0.8
// }
// }
}
},
});
Matter.Body.setVelocity(bullet[me], {
@@ -1470,7 +1468,7 @@ const b = {
}
}
} else {
if (m.energy > 0.005 && !m.isBodiesAsleep) m.energy -= 0.005
if (m.energy > 0.005) m.energy -= 0.005
const sub = Vector.sub(this.position, m.pos)
const rangeScale = 1 + 0.000001 * Vector.magnitude(sub) * Vector.magnitude(sub) //return faster when far from player
const returnForce = Vector.mult(Vector.normalise(sub), rangeScale * this.thrustMag * this.mass)
@@ -1503,7 +1501,6 @@ const b = {
}
},
do() {
if (!m.isBodiesAsleep) {
this.cycle++
if (isReturn) {
if (this.cycle > totalCycles) {
@@ -1576,7 +1573,6 @@ const b = {
// this.frictionAir = 0.8
// }
// }
}
this.draw()
},
});
@@ -1608,48 +1604,6 @@ const b = {
}
}
Composite.add(engine.world, bullet[me]); //add bullet to world
/* todo
despawn
when player gets far away?
set time
release mouse?
*/
// if (true && input.down) {
// Matter.Body.setVelocity(bullet[me], {
// x: m.Vx / 2 + 70 * Math.cos(bullet[me].angle),
// y: m.Vy / 2 + 70 * Math.sin(bullet[me].angle)
// });
// bullet[me].frictionAir = 0.0011
// bullet[me].endCycle = simulation.cycle + Infinity
// bullet[me].do = function() {
// if (!m.isBodiesAsleep) {
// this.cycle++
// if (Matter.Query.collides(this, map).length) {
// // this.collisionFilter.mask = 0; //non collide with everything
// this.collisionFilter.category = cat.map
// this.collisionFilter.mask = cat.player | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet;
// Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(this.lastVelocity), 30))) //move a bit into the wall
// Matter.Body.setVelocity(this, { x: 0, y: 0 });
// Matter.Body.setStatic(this, true) //don't set to static if not touching map
// Matter.Body.setAngularVelocity(this, 0)
// const unit = Vector.normalise(Vector.sub({ x: this.position.x, y: this.position.y - 150 }, player.position))
// const push = Vector.mult(unit, 1)
// player.force.x += push.x
// player.force.y += push.y
// //pull player back in
// this.do = () => {
// }
// }
// this.lastVelocity = { x: this.velocity.x, y: this.velocity.y }
// }
// this.drawString()
// }
// }
},
missile(where, angle, speed, size = 1) {
if (tech.missileSize) size *= 1.5
@@ -1709,7 +1663,6 @@ const b = {
}
},
do() {
if (!m.isBodiesAsleep) {
if (!(m.cycle % this.lookFrequency)) this.tryToLockOn();
if (this.lockedOn) { //rotate missile towards the target
const face = {
@@ -1737,15 +1690,6 @@ const b = {
11 * size, 0, 2 * Math.PI);
ctx.fillStyle = "rgba(255,155,0,0.5)";
ctx.fill();
} else {
//draw rocket with time stop
ctx.beginPath();
ctx.arc(this.position.x - Math.cos(this.angle) * (30 * size - 3) + (Math.random() - 0.5) * 4,
this.position.y - Math.sin(this.angle) * (30 * size - 3) + (Math.random() - 0.5) * 4,
2 + 9 * size, 0, 2 * Math.PI);
ctx.fillStyle = "rgba(255,155,0,0.5)";
ctx.fill();
}
},
});
const thrust = 0.0066 * bullet[me].mass * (tech.missileSize ? 0.6 : 1);
@@ -1793,7 +1737,6 @@ const b = {
beforeDmg() {},
onEnd() {},
do() {
if (!m.isBodiesAsleep) {
if (this.endCycle < simulation.cycle + 1) this.isWave = false
if (Matter.Query.point(map, this.position).length) { //check if inside map
this.isBranch = true;
@@ -1817,7 +1760,6 @@ const b = {
const velocity = Vector.mult(player.velocity, 0.4) //move with player
Matter.Body.setPosition(this, Vector.add(velocity, Vector.add(this.position, wiggle)))
}
}
});
Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], {
@@ -2290,7 +2232,7 @@ const b = {
}
}
} else {
if (this.speed < 1 && this.angularSpeed < 0.01 && !m.isBodiesAsleep) this.stillCount++
if (this.speed < 1 && this.angularSpeed < 0.01) this.stillCount++
}
if (this.stillCount > 25) this.arm();
},
@@ -2326,7 +2268,7 @@ const b = {
this.endCycle = simulation.cycle + 1020
this.do = function() { //overwrite the do method for this bullet
this.force.y += this.mass * 0.002; //extra gravity
if (!(simulation.cycle % this.lookFrequency) && !m.isBodiesAsleep) { //find mob targets
if (!(simulation.cycle % this.lookFrequency)) { //find mob targets
b.targetedNail(this.position, 1, 45 + 5 * Math.random(), 1100, false, 2.3) //targetedNail(position, num = 1, speed = 40 + 10 * Math.random(), range = 1200, isRandomAim = true, damage = 1.4) {
if (!(simulation.cycle % (this.lookFrequency * 6))) {
simulation.drawList.push({
@@ -3136,7 +3078,6 @@ const b = {
},
onEnd() {},
do() {
if (!m.isBodiesAsleep) { //if time dilation isn't active
if (this.count < 20) {
this.count++
//grow
@@ -3234,7 +3175,6 @@ const b = {
Matter.Body.setPosition(this, Vector.add(this.position, Vector.rotate({ x: range, y: 0 }, 2 * Math.PI * Math.random())))
}
}
}
});
if (tech.isBulletTeleport) bullet[me].nextPortCycle = simulation.cycle + bullet[me].portFrequency
Composite.add(engine.world, bullet[me]); //add bullet to world
@@ -3318,7 +3258,6 @@ const b = {
// bullet[me].turnRate = 0.005 * (Math.random() - 0.5)
bullet[me].isInMap = false
bullet[me].do = function() {
if (!m.isBodiesAsleep) {
const whom = Matter.Query.collides(this, mob)
if (whom.length && this.speed > 20) { //if touching a mob
for (let i = 0, len = whom.length; i < len; i++) {
@@ -3369,7 +3308,6 @@ const b = {
} else if (this.speed < 30) {
this.force.y += this.mass * 0.001; //no gravity until it slows down to improve aiming
}
}
};
} else {
bullet[me].endCycle = simulation.cycle + 100;
@@ -3630,7 +3568,6 @@ const b = {
// }
//check for damage
if (!m.isBodiesAsleep) {
if (m.immuneCycle < m.cycle && !((m.cycle + this.phase) % 30)) { //twice a second
if (Vector.magnitude(Vector.sub(this.position, player.position)) < 250 && m.immuneCycle < m.cycle) { //give energy
Matter.Body.setAngularVelocity(this, this.spin)
@@ -3692,7 +3629,6 @@ const b = {
let history = m.history[(m.cycle - this.followDelay) % 600]
Matter.Body.setPosition(this, { x: history.position.x, y: history.position.y - history.yOff + 24.2859 }) //bullets move with player
}
}
})
Composite.add(engine.world, bullet[me]); //add bullet to world
b.setDynamoBotDelay()
@@ -4317,7 +4253,7 @@ const b = {
orbitalSpeed: 0,
phase: 2 * Math.PI * Math.random(),
do() {
if (!m.isCloak && !m.isBodiesAsleep) { //if time dilation isn't active
if (!m.isCloak) { //if time dilation isn't active
const size = 33
q = Matter.Query.region(mob, {
min: { x: this.position.x - size, y: this.position.y - size },
@@ -4850,10 +4786,8 @@ const b = {
// bullet[me].restitution = 0.4
bullet[me].frictionAir = 0.034;
bullet[me].do = function() {
if (!m.isBodiesAsleep) {
const scale = 1 - 0.034 / tech.isBulletsLastLonger
Matter.Body.scale(this, scale, scale);
}
};
}
}
@@ -5016,15 +4950,10 @@ const b = {
ctx.moveTo(this.waves[i].position.x + this.waves[i].radius, this.waves[i].position.y)
ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, 0, 2 * Math.PI);
// collisions
if (!m.isBodiesAsleep) {
if (tech.isBulletTeleport && Math.random() < 0.04) {
const scale = 400 * Math.random()
this.waves[i].position = Vector.add(this.waves[i].position, { x: scale * (Math.random() - 0.5), y: scale * (Math.random() - 0.5) })
}
for (let j = 0, len = mob.length; j < len; j++) {
const dist = Vector.magnitude(Vector.sub(this.waves[i].position, mob[j].position))
const r = mob[j].radius + 30
@@ -5071,7 +5000,6 @@ const b = {
}
}
this.waves[i].radius += tech.waveBeamSpeed * this.waves[i].expanding //expand / move
}
// if (this.waves[i].radius > end) this.waves.splice(i, 1) //end
if (this.waves[i].radius > end) {
this.waves[i].expanding = -1
@@ -5109,7 +5037,6 @@ const b = {
ctx.arc(this.waves[i].position.x, this.waves[i].position.y, this.waves[i].radius, this.waves[i].angle, this.waves[i].angle + this.waves[i].arc);
// collisions
//using small angle linear approximation of circle arc, this will not work if the arc gets large // https://stackoverflow.com/questions/13652518/efficiently-find-points-inside-a-circle-sector
if (!m.isBodiesAsleep) {
if (tech.isBulletTeleport && Math.random() < 0.05) {
if (Math.random() < 0.5) {
// const scale = 500 * Math.random()
@@ -5166,7 +5093,6 @@ const b = {
// ctx.stroke(); //draw vibes
this.waves[i].radius += tech.waveBeamSpeed * 2 * this.waves[i].expanding //expand / move
}
if (this.waves[i].radius > end) {
this.waves[i].expanding = -1
this.waves[i].reflection--
@@ -5291,7 +5217,6 @@ const b = {
if (tech.waveReflections) {
bullet[me].reflectCycle = totalCycles / tech.waveReflections //tech.waveLengthRange
bullet[me].do = function() {
if (!m.isBodiesAsleep) {
this.query()
if (this.cycle > this.reflectCycle) {
this.reflectCycle += totalCycles / tech.waveReflections
@@ -5300,15 +5225,12 @@ const b = {
}
this.wiggle()
}
}
} else {
bullet[me].do = function() {
if (!m.isBodiesAsleep) {
this.query()
this.wiggle();
}
}
}
Composite.add(engine.world, bullet[me]); //add bullet to world
Matter.Body.setVelocity(bullet[me], {
x: tech.waveBeamSpeed * Math.cos(m.angle),
@@ -5502,10 +5424,8 @@ const b = {
ctx.arc(this.position.x, this.position.y, this.maxRadius, 0, 2 * Math.PI);
ctx.fill();
}
bullet[me].grow = function() {
this.stuck(); //runs different code based on what the bullet is stuck to
if (!m.isBodiesAsleep) {
let scale = 1.01
if (tech.isSporeGrowth && !(simulation.cycle % 40)) { //release a spore
if (tech.isSporeWorm) {
@@ -5524,8 +5444,6 @@ const b = {
this.radius *= scale
if (this.radius > this.maxRadius) this.endCycle = 0;
}
}
// this.force.y += this.mass * 0.00045;
//draw green glow

View File

@@ -59,7 +59,7 @@ const mobs = {
}
function applySlow(whom) {
if (!whom.shield && !whom.isShielded && !m.isBodiesAsleep) {
if (!whom.shield && !whom.isShielded) {
if (whom.isBoss) cycles = Math.floor(cycles * 0.25)
let i = whom.status.length
while (i--) {
@@ -98,7 +98,7 @@ const mobs = {
}
},
statusStun(who, cycles = 180) {
if (!who.shield && !who.isShielded && !m.isBodiesAsleep) {
if (!who.shield && !who.isShielded) {
Matter.Body.setVelocity(who, {
x: who.velocity.x * 0.8,
y: who.velocity.y * 0.8
@@ -153,7 +153,7 @@ const mobs = {
if (!who.isShielded && who.alive && who.damageReduction > 0) {
who.status.push({
effect() {
if ((simulation.cycle - this.startCycle) % 30 === 0 && !m.isBodiesAsleep) {
if ((simulation.cycle - this.startCycle) % 30 === 0) {
let dmg = b.dmgScale * this.dmg
who.damage(dmg);
if (who.damageReduction) {
@@ -822,7 +822,6 @@ const mobs = {
}
},
grow() {
if (!m.isBodiesAsleep) {
if (this.seePlayer.recall) {
if (this.radius < 80) {
const scale = 1.01;
@@ -843,7 +842,6 @@ const mobs = {
this.fill = `hsl(144, ${this.radius}%, 50%)`;
}
}
}
},
search() {
//be sure to declare searchTarget in mob spawn
@@ -943,7 +941,6 @@ const mobs = {
}
},
fire() {
if (!m.isBodiesAsleep) {
const setNoseShape = () => {
const mag = this.radius + this.radius * this.noseLength;
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
@@ -991,7 +988,6 @@ const mobs = {
// this.noseLength += this.fireFreq / 4;
// setNoseShape();
// }
}
},
// launch() {
// if (this.seePlayer.recall) {
@@ -1038,13 +1034,11 @@ const mobs = {
}
},
timeLimit() {
if (!m.isBodiesAsleep) {
this.timeLeft--;
if (this.timeLeft < 0) {
this.isDropPowerUp = false;
this.death(); //death with no power up
}
}
},
healthBar() { //draw health by mob //most health bars are drawn in mobs.healthbar();
if (this.seePlayer.recall) {

View File

@@ -14,14 +14,16 @@ const simulation = {
}
m.move();
m.look();
simulation.checks();
simulation.camera();
level.custom();
powerUps.do();
mobs.draw();
simulation.draw.cons();
simulation.draw.body();
if (!m.isBodiesAsleep) mobs.loop();
if (!m.isBodiesAsleep) {
simulation.checks();
mobs.loop();
}
mobs.healthBar();
m.draw();
m.hold();
@@ -873,7 +875,7 @@ const simulation = {
// }
// },
checks() {
if (!(simulation.cycle % 60) && !m.isBodiesAsleep) { //once a second
if (!(simulation.cycle % 60)) { //once a second
//energy overfill
if (m.energy > m.maxEnergy) m.energy = m.maxEnergy + (m.energy - m.maxEnergy) * tech.overfillDrain //every second energy above max energy loses 25%
if (tech.isFlipFlopEnergy && m.immuneCycle < m.cycle) {

View File

@@ -431,9 +431,8 @@ const spawn = {
// });
this.modeDo(); //this does different things based on the mode
this.checkStatus();
if (!m.isBodiesAsleep) this.cycle++; //switch modes÷ if time isn't paused
this.cycle++; //switch modes÷ if time isn't paused
this.totalCycles++;
// if (!m.isBodiesAsleep) {
if (this.health > 0.25) {
if (this.cycle > this.endCycle) {
this.cycle = 0;
@@ -491,7 +490,7 @@ const spawn = {
}
me.spawnInterval = 395
me.modeSpawns = function() {
if (!(this.cycle % this.spawnInterval) && !m.isBodiesAsleep && mob.length < 40) {
if (!(this.cycle % this.spawnInterval) && mob.length < 40) {
if (this.mode !== 3) Matter.Body.setAngularVelocity(this, 0.1)
//fire a bullet from each vertex
const whoSpawn = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
@@ -504,7 +503,7 @@ const spawn = {
y: this.velocity.y + velocity.y
});
}
if (!(this.cycle % 2 * this.spawnInterval) && !m.isBodiesAsleep && mob.length < 40) {
if (!(this.cycle % 2 * this.spawnInterval) && mob.length < 40) {
const len = (this.totalCycles / 600 + simulation.difficulty / 2 - 30) / 15
for (let i = 0; i < len; i++) {
spawn.randomLevelBoss(3000 * (simulation.isHorizontalFlipped ? -1 : 1) + 2000 * (Math.random() - 0.5), -1100 + 200 * (Math.random() - 0.5))
@@ -650,7 +649,7 @@ const spawn = {
ctx.lineTo(best.x, best.y);
}
me.modeLasers = function() {
if (!m.isBodiesAsleep && !this.isStunned) {
if (!this.isStunned) {
let slowed = false //check if slowed
for (let i = 0; i < this.status.length; i++) {
if (this.status[i].type === "slow") {
@@ -795,7 +794,7 @@ const spawn = {
this.force.y += force.y;
}
if (!(simulation.cycle % 30) && !m.isBodiesAsleep) {
if (!(simulation.cycle % 30)) {
//find blocks to turn into mobs
for (let i = 0; i < body.length; i++) {
if (Vector.magnitude(Vector.sub(this.position, body[i].position)) < 700 && !body[i].isNotHoldable) { // check distance for each block
@@ -899,8 +898,6 @@ const spawn = {
me.do = function() { //grow phase only occurs for growCycles
this.checkStatus();
this.seePlayerCheck();
if (!m.isBodiesAsleep) {
this.cycle++
if (this.cycle > growCycles) {
this.damageReduction = 1.8 //take extra damage
@@ -911,7 +908,6 @@ const spawn = {
this.radius *= scale;
}
}
}
me.normalDo = function() {
this.gravity();
this.checkStatus();
@@ -957,8 +953,6 @@ const spawn = {
}
me.damageReduction = 0.17 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1); //me.damageReductionGoal
me.do = function() {
// // this.armor();
if (!m.isBodiesAsleep) {
this.seePlayerByDistOrLOS();
this.checkStatus();
this.attraction();
@@ -983,7 +977,6 @@ const spawn = {
}
}
}
}
};
me.onDeath = function() {
this.isCell = false;
@@ -1030,8 +1023,6 @@ const spawn = {
};
me.damageReduction = 0.2 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1);
me.doAwake = function() {
if (!m.isBodiesAsleep) {
// this.armor();
this.alwaysSeePlayer();
this.checkStatus();
this.attraction();
@@ -1052,7 +1043,6 @@ const spawn = {
}
}
}
}
me.do = function() {
this.checkStatus();
if (this.seePlayer.recall) {
@@ -1153,7 +1143,7 @@ const spawn = {
me.do = function() {
if (this.isInvulnerable) {
if (this.invulnerabilityCountDown > 0) {
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
this.invulnerabilityCountDown--
ctx.beginPath();
let vertices = this.vertices;
ctx.moveTo(vertices[0].x, vertices[0].y);
@@ -1234,7 +1224,7 @@ const spawn = {
me.do = function() {
if (this.isInvulnerable) {
if (this.invulnerabilityCountDown > 0) {
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
this.invulnerabilityCountDown--
ctx.beginPath();
let vertices = this.vertices;
ctx.moveTo(vertices[0].x, vertices[0].y);
@@ -1745,7 +1735,7 @@ const spawn = {
this.checkStatus();
if (this.seePlayer.recall) {
//throw large seekers
if (!(simulation.cycle % 240) && !m.isBodiesAsleep) {
if (!(simulation.cycle % 240)) {
spawn.seeker(this.position.x, this.position.y, 15 * (0.7 + 0.5 * Math.random()), 7); //give the bullet a rotational velocity as if they were attached to a vertex
const who = mob[mob.length - 1]
Matter.Body.setDensity(who, 0.00001); //normal is 0.001
@@ -1982,7 +1972,7 @@ const spawn = {
ctx.strokeStyle = "rgba(255,255,255,0.7)";
ctx.stroke();
} else if (this.invulnerabilityCountDown > 0) {
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
this.invulnerabilityCountDown--
} else {
this.isInvulnerable = true
if (this.damageReduction) this.startingDamageReduction = this.damageReduction
@@ -2369,7 +2359,7 @@ const spawn = {
// ctx.setLineDash([]);
// ctx.fillStyle = "rgba(150,0,255,0.03)";
// ctx.fill();
if (!m.isBodiesAsleep && !this.isStunned && !this.isSlowed) {
if (!this.isStunned && !this.isSlowed) {
if (this.followDelay > this.delayLimit) this.followDelay -= 0.15;
let history = m.history[(m.cycle - Math.floor(this.followDelay)) % 600]
Matter.Body.setPosition(this, { x: history.position.x, y: history.position.y - history.yOff + 24.2859 }) //bullets move with player
@@ -2403,7 +2393,6 @@ const spawn = {
};
spawn.shield(me, x, y);
me.do = function() {
if (!m.isBodiesAsleep) {
this.seePlayerByLookingAt();
this.checkStatus();
this.attraction();
@@ -2449,7 +2438,6 @@ const spawn = {
} else {
this.laserPos = this.position;
}
};
}
},
laserTargetingBoss(x, y, radius = 80) {
@@ -2850,7 +2838,6 @@ const spawn = {
me.fire = function() {
// this.armor();
this.checkStatus();
if (!m.isBodiesAsleep) {
if (!m.isCloak && !this.isStunned) {
if (this.isFiring) {
if (this.fireCycle > this.fireDelay) { //fire
@@ -2929,7 +2916,6 @@ const spawn = {
} else {
this.isFiring = false
}
}
};
},
pulsar(x, y, radius = 40) {
@@ -2971,7 +2957,6 @@ const spawn = {
me.do = function() {
this.seePlayerByLookingAt();
this.checkStatus();
if (!m.isBodiesAsleep) {
if (this.seePlayer.recall) {
if (this.isFiring) {
if (this.fireCycle > this.fireDelay) { //fire
@@ -3055,7 +3040,6 @@ const spawn = {
} else {
this.isFiring = false
}
}
};
},
laser(x, y, radius = 30) {
@@ -3092,12 +3076,6 @@ const spawn = {
});
Composite.add(engine.world, me.constraint);
}, 2000); //add in a delay in case the level gets flipped left right
// me.startingPosition = {
// x: x,
// y: y
// }
me.count = 0;
me.frictionAir = 0.03;
// me.torque -= me.inertia * 0.002
@@ -3105,12 +3083,10 @@ const spawn = {
Matter.Body.setDensity(me, 0.03); //extra dense //normal is 0.001 //makes effective life much larger
me.damageReduction = 0.25 / (tech.isScaleMobsWithDuplication ? 1 + tech.duplicationChance() : 1)
me.isBoss = true;
// spawn.shield(me, x, y, 1); //not working, not sure why
me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
};
me.rotateVelocity = Math.min(0.0045, 0.0015 * simulation.accelScale * simulation.accelScale) * (level.levelsCleared > 8 ? 1 : -1) * (simulation.isHorizontalFlipped ? -1 : 1)
me.do = function() {
// this.armor();
@@ -3118,7 +3094,6 @@ const spawn = {
this.checkStatus();
if (!this.isStunned) {
if (!m.isBodiesAsleep) {
//check if slowed
let slowed = false
for (let i = 0; i < this.status.length; i++) {
@@ -3132,7 +3107,7 @@ const spawn = {
Matter.Body.setAngle(this, this.count * this.rotateVelocity)
Matter.Body.setAngularVelocity(this, 0)
}
}
ctx.beginPath();
this.lasers(this.vertices[0], this.angle + Math.PI / 3);
this.lasers(this.vertices[1], this.angle + Math.PI);
@@ -3254,12 +3229,9 @@ const spawn = {
}
};
me.do = function() {
if (!m.isBodiesAsleep) {
// this.gravity();
this.seePlayerByLookingAt();
this.checkStatus();
this.attraction();
if (this.isSpikeReset) {
if (this.seePlayer.recall) {
const dist = Vector.sub(this.seePlayer.position, this.position);
@@ -3304,7 +3276,6 @@ const spawn = {
this.vertices[this.spikeVertex].x = this.position.x + spike.x
this.vertices[this.spikeVertex].y = this.position.y + spike.y
}
}
};
},
@@ -3385,7 +3356,6 @@ const spawn = {
powerUps.spawnBossPowerUp(this.position.x, this.position.y)
};
//invulnerability every 1/4 fraction of life lost
//required setup for invulnerable
me.isInvulnerable = false
@@ -3401,7 +3371,7 @@ const spawn = {
}
if (this.isInvulnerable) {
if (this.invulnerabilityCountDown > 0) {
if (!m.isBodiesAsleep) this.invulnerabilityCountDown--
this.invulnerabilityCountDown--
//graphics //draw a super shield?
ctx.beginPath();
let vertices = this.vertices;
@@ -3452,7 +3422,7 @@ const spawn = {
this.seePlayerByHistory(60);
this.attraction();
//traveling laser
if (!m.isBodiesAsleep) this.laserAngle += this.isInvulnerable ? 0.06 : 0.015
this.laserAngle += this.isInvulnerable ? 0.06 : 0.015
for (let i = 0, len = this.vertices.length; i < len; i++) {
// this.laserSword(this.vertices[1], this.angle + laserAngle);
const bend = bendFactor * Math.cos(this.laserAngle + 2 * Math.PI * i / len)
@@ -3551,7 +3521,7 @@ const spawn = {
this.seePlayerByHistory();
this.attraction();
this.checkStatus();
if (!m.isBodiesAsleep) this.sword() //does various things depending on what stage of the sword swing
this.sword() //does various things depending on what stage of the sword swing
// ctx.beginPath(); //hide map
// ctx.arc(this.position.x, this.position.y, 3000, 0, 2 * Math.PI); //* this.fireCycle / this.fireDelay
@@ -3703,7 +3673,7 @@ const spawn = {
this.checkStatus();
this.seePlayerByHistory(15);
this.attraction();
if (!m.isBodiesAsleep) this.sword() //does various things depending on what stage of the sword swing
this.sword() //does various things depending on what stage of the sword swing
};
me.swordWaiting = function() {
if (
@@ -3822,13 +3792,11 @@ const spawn = {
this.checkStatus();
this.attraction();
//draw
if (!m.isBodiesAsleep) {
if (this.seePlayer.recall) {
if (this.alpha < 1) this.alpha += 0.003 + 0.003 / simulation.CDScale;
} else {
if (this.alpha > 0) this.alpha -= 0.03;
}
}
if (this.alpha > 0) {
if (this.alpha > 0.7) {
this.healthBar();
@@ -3880,13 +3848,11 @@ const spawn = {
this.attraction();
this.search();
//draw
if (!m.isBodiesAsleep) {
if (this.distanceToPlayer2() < this.seeAtDistance2) {
if (this.alpha < 1) this.alpha += 0.005 * simulation.CDScale; //near player go solid
} else {
if (this.alpha > 0) this.alpha -= 0.05; ///away from player, hide
}
}
if (this.alpha > 0) {
if (this.alpha > 0.8 && this.seePlayer.recall) {
this.healthBar();
@@ -4200,7 +4166,6 @@ const spawn = {
this.seePlayerCheck();
this.checkStatus();
if (!m.isBodiesAsleep) {
const setNoseShape = () => {
const mag = this.radius + this.radius * this.noseLength;
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
@@ -4255,7 +4220,6 @@ const spawn = {
} else {
if (this.alpha > 0) this.alpha -= 0.03;
}
}
//draw
if (this.alpha > 0) {
if (this.alpha > 0.95) {
@@ -4324,7 +4288,7 @@ const spawn = {
this.seePlayerCheck();
this.checkStatus();
this.attraction();
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq) && !m.isBodiesAsleep) {
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq)) {
Matter.Body.setAngularVelocity(this, 0.14)
spawn.seeker(this.vertices[0].x, this.vertices[0].y, 20, 9); //give the bullet a rotational velocity as if they were attached to a vertex
const who = mob[mob.length - 1]
@@ -4354,7 +4318,7 @@ const spawn = {
this.seePlayerCheck();
this.checkStatus();
this.attraction();
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq) && !m.isBodiesAsleep) {
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq)) {
Matter.Body.setAngularVelocity(this, 0.14)
//fire a bullet from each vertex
for (let i = 0, len = this.vertices.length; i < len; i++) {
@@ -4397,7 +4361,7 @@ const spawn = {
this.checkStatus();
this.attraction();
this.repulsion();
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq) && !m.isBodiesAsleep) {
if (this.seePlayer.recall && !(simulation.cycle % this.fireFreq)) {
Matter.Body.setAngularVelocity(this, 0.11)
//fire a bullet from each vertex
for (let i = 0, len = this.vertices.length; i < len; i++) {
@@ -4494,7 +4458,6 @@ const spawn = {
this.seePlayerCheck();
this.checkStatus();
if (!m.isBodiesAsleep) {
const setNoseShape = () => {
const mag = this.radius + this.radius * this.noseLength;
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
@@ -4539,7 +4502,6 @@ const spawn = {
this.noseLength -= this.fireFreq / 2;
setNoseShape();
}
}
};
},
grenade(x, y, lifeSpan = 90 + Math.ceil(60 / simulation.accelScale), pulseRadius = Math.min(550, 250 + simulation.difficulty * 3), size = 3) {
@@ -4637,7 +4599,6 @@ const spawn = {
ctx.strokeStyle = "rgb(255,255,255)"
ctx.stroke();
if (!m.isBodiesAsleep) {
this.cycle++
if (this.cycle > this.maxCycles) {
this.cycle = 0
@@ -4656,7 +4617,6 @@ const spawn = {
ctx.strokeStyle = "rgb(200,200,255)"
ctx.stroke();
}
}
};
},
streamBoss(x, y, radius = 110) {
@@ -4693,7 +4653,7 @@ const spawn = {
this.repulsion();
this.cycle++
if (this.seePlayer.recall && ((this.cycle % 15) === 0) && !m.isBodiesAsleep) {
if (this.seePlayer.recall && ((this.cycle % 15) === 0)) {
if (this.canFire) {
if (this.cycle > 120) {
this.cycle = 0
@@ -4910,7 +4870,7 @@ const spawn = {
this.checkStatus();
this.attraction();
this.cycle++
if (this.seePlayer.recall && ((this.cycle % 10) === 0) && !m.isBodiesAsleep) {
if (this.seePlayer.recall && ((this.cycle % 10) === 0)) {
if (this.canFire) {
if (this.cycle > 120) {
this.cycle = 0

View File

@@ -1,16 +1,7 @@
******************************************************** NEXT PATCH **************************************************
exit door has a 1 second delay and animation
reservoir map now has a flipped horizontal chance
map ruins renamed -> pavilion
all the individual !m.isBodiesAsleep are replaced with ones in the main game loop
this needs extensive bug testing?
should behave similarly to testing mode, which doesn't have issues
todo remove the checks from bullets and mobs, do this after update so it can be easy to revert
bug fixes
removed about 80 !m.isBodiesAsleep
this could cause some bugs for bullets or mobs when time is dilated
******************************************************** TODO ********************************************************