removed several !m.isBodiesAsleep
this could cause some bugs for bullets or mobs when time is dilated
This commit is contained in:
1026
js/bullet.js
1026
js/bullet.js
File diff suppressed because it is too large
Load Diff
144
js/mob.js
144
js/mob.js
@@ -59,7 +59,7 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function applySlow(whom) {
|
function applySlow(whom) {
|
||||||
if (!whom.shield && !whom.isShielded && !m.isBodiesAsleep) {
|
if (!whom.shield && !whom.isShielded) {
|
||||||
if (whom.isBoss) cycles = Math.floor(cycles * 0.25)
|
if (whom.isBoss) cycles = Math.floor(cycles * 0.25)
|
||||||
let i = whom.status.length
|
let i = whom.status.length
|
||||||
while (i--) {
|
while (i--) {
|
||||||
@@ -98,7 +98,7 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
statusStun(who, cycles = 180) {
|
statusStun(who, cycles = 180) {
|
||||||
if (!who.shield && !who.isShielded && !m.isBodiesAsleep) {
|
if (!who.shield && !who.isShielded) {
|
||||||
Matter.Body.setVelocity(who, {
|
Matter.Body.setVelocity(who, {
|
||||||
x: who.velocity.x * 0.8,
|
x: who.velocity.x * 0.8,
|
||||||
y: who.velocity.y * 0.8
|
y: who.velocity.y * 0.8
|
||||||
@@ -153,7 +153,7 @@ const mobs = {
|
|||||||
if (!who.isShielded && who.alive && who.damageReduction > 0) {
|
if (!who.isShielded && who.alive && who.damageReduction > 0) {
|
||||||
who.status.push({
|
who.status.push({
|
||||||
effect() {
|
effect() {
|
||||||
if ((simulation.cycle - this.startCycle) % 30 === 0 && !m.isBodiesAsleep) {
|
if ((simulation.cycle - this.startCycle) % 30 === 0) {
|
||||||
let dmg = b.dmgScale * this.dmg
|
let dmg = b.dmgScale * this.dmg
|
||||||
who.damage(dmg);
|
who.damage(dmg);
|
||||||
if (who.damageReduction) {
|
if (who.damageReduction) {
|
||||||
@@ -822,27 +822,25 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
grow() {
|
grow() {
|
||||||
if (!m.isBodiesAsleep) {
|
if (this.seePlayer.recall) {
|
||||||
if (this.seePlayer.recall) {
|
if (this.radius < 80) {
|
||||||
if (this.radius < 80) {
|
const scale = 1.01;
|
||||||
const scale = 1.01;
|
Matter.Body.scale(this, scale, scale);
|
||||||
Matter.Body.scale(this, scale, scale);
|
this.radius *= scale;
|
||||||
this.radius *= scale;
|
// this.torque = -0.00002 * this.inertia;
|
||||||
// this.torque = -0.00002 * this.inertia;
|
this.fill = `hsl(144, ${this.radius}%, 50%)`;
|
||||||
this.fill = `hsl(144, ${this.radius}%, 50%)`;
|
if (this.isShielded) { //remove shield if shielded when growing
|
||||||
if (this.isShielded) { //remove shield if shielded when growing
|
this.isShielded = false;
|
||||||
this.isShielded = false;
|
this.removeConsBB();
|
||||||
this.removeConsBB();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (this.radius > 15) {
|
|
||||||
const scale = 0.99;
|
|
||||||
Matter.Body.scale(this, scale, scale);
|
|
||||||
this.radius *= scale;
|
|
||||||
this.fill = `hsl(144, ${this.radius}%, 50%)`;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
if (this.radius > 15) {
|
||||||
|
const scale = 0.99;
|
||||||
|
Matter.Body.scale(this, scale, scale);
|
||||||
|
this.radius *= scale;
|
||||||
|
this.fill = `hsl(144, ${this.radius}%, 50%)`;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
search() {
|
search() {
|
||||||
@@ -943,55 +941,53 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
fire() {
|
fire() {
|
||||||
if (!m.isBodiesAsleep) {
|
const setNoseShape = () => {
|
||||||
const setNoseShape = () => {
|
const mag = this.radius + this.radius * this.noseLength;
|
||||||
const mag = this.radius + this.radius * this.noseLength;
|
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
||||||
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
this.vertices[1].y = this.position.y + Math.sin(this.angle) * mag;
|
||||||
this.vertices[1].y = this.position.y + Math.sin(this.angle) * mag;
|
};
|
||||||
};
|
//throw a mob/bullet at player
|
||||||
//throw a mob/bullet at player
|
if (this.seePlayer.recall) {
|
||||||
if (this.seePlayer.recall) {
|
//set direction to turn to fire
|
||||||
//set direction to turn to fire
|
if (!(simulation.cycle % this.seePlayerFreq)) {
|
||||||
if (!(simulation.cycle % this.seePlayerFreq)) {
|
this.fireDir = Vector.normalise(Vector.sub(this.seePlayer.position, this.position));
|
||||||
this.fireDir = Vector.normalise(Vector.sub(this.seePlayer.position, this.position));
|
this.fireDir.y -= Math.abs(this.seePlayer.position.x - this.position.x) / 2500; //gives the bullet an arc //was / 1600
|
||||||
this.fireDir.y -= Math.abs(this.seePlayer.position.x - this.position.x) / 2500; //gives the bullet an arc //was / 1600
|
|
||||||
}
|
|
||||||
//rotate towards fireAngle
|
|
||||||
const angle = this.angle + Math.PI / 2;
|
|
||||||
const dot = Vector.dot({
|
|
||||||
x: Math.cos(angle),
|
|
||||||
y: Math.sin(angle)
|
|
||||||
}, this.fireDir)
|
|
||||||
// c = Math.cos(angle) * this.fireDir.x + Math.sin(angle) * this.fireDir.y;
|
|
||||||
const threshold = 0.1;
|
|
||||||
if (dot > threshold) {
|
|
||||||
this.torque += 0.000004 * this.inertia;
|
|
||||||
} else if (dot < -threshold) {
|
|
||||||
this.torque -= 0.000004 * this.inertia;
|
|
||||||
} else if (this.noseLength > 1.5 && dot > -0.2 && dot < 0.2) {
|
|
||||||
//fire
|
|
||||||
spawn.bullet(this.vertices[1].x, this.vertices[1].y, 9 + Math.ceil(this.radius / 15));
|
|
||||||
const v = 15;
|
|
||||||
Matter.Body.setVelocity(mob[mob.length - 1], {
|
|
||||||
x: this.velocity.x + this.fireDir.x * v + 3 * Math.random(),
|
|
||||||
y: this.velocity.y + this.fireDir.y * v + 3 * Math.random()
|
|
||||||
});
|
|
||||||
this.noseLength = 0;
|
|
||||||
// recoil
|
|
||||||
this.force.x -= 0.005 * this.fireDir.x * this.mass;
|
|
||||||
this.force.y -= 0.005 * this.fireDir.y * this.mass;
|
|
||||||
}
|
|
||||||
if (this.noseLength < 1.5) this.noseLength += this.fireFreq;
|
|
||||||
setNoseShape();
|
|
||||||
} else if (this.noseLength > 0.1) {
|
|
||||||
this.noseLength -= this.fireFreq / 2;
|
|
||||||
setNoseShape();
|
|
||||||
}
|
}
|
||||||
// else if (this.noseLength < -0.1) {
|
//rotate towards fireAngle
|
||||||
// this.noseLength += this.fireFreq / 4;
|
const angle = this.angle + Math.PI / 2;
|
||||||
// setNoseShape();
|
const dot = Vector.dot({
|
||||||
// }
|
x: Math.cos(angle),
|
||||||
|
y: Math.sin(angle)
|
||||||
|
}, this.fireDir)
|
||||||
|
// c = Math.cos(angle) * this.fireDir.x + Math.sin(angle) * this.fireDir.y;
|
||||||
|
const threshold = 0.1;
|
||||||
|
if (dot > threshold) {
|
||||||
|
this.torque += 0.000004 * this.inertia;
|
||||||
|
} else if (dot < -threshold) {
|
||||||
|
this.torque -= 0.000004 * this.inertia;
|
||||||
|
} else if (this.noseLength > 1.5 && dot > -0.2 && dot < 0.2) {
|
||||||
|
//fire
|
||||||
|
spawn.bullet(this.vertices[1].x, this.vertices[1].y, 9 + Math.ceil(this.radius / 15));
|
||||||
|
const v = 15;
|
||||||
|
Matter.Body.setVelocity(mob[mob.length - 1], {
|
||||||
|
x: this.velocity.x + this.fireDir.x * v + 3 * Math.random(),
|
||||||
|
y: this.velocity.y + this.fireDir.y * v + 3 * Math.random()
|
||||||
|
});
|
||||||
|
this.noseLength = 0;
|
||||||
|
// recoil
|
||||||
|
this.force.x -= 0.005 * this.fireDir.x * this.mass;
|
||||||
|
this.force.y -= 0.005 * this.fireDir.y * this.mass;
|
||||||
|
}
|
||||||
|
if (this.noseLength < 1.5) this.noseLength += this.fireFreq;
|
||||||
|
setNoseShape();
|
||||||
|
} else if (this.noseLength > 0.1) {
|
||||||
|
this.noseLength -= this.fireFreq / 2;
|
||||||
|
setNoseShape();
|
||||||
}
|
}
|
||||||
|
// else if (this.noseLength < -0.1) {
|
||||||
|
// this.noseLength += this.fireFreq / 4;
|
||||||
|
// setNoseShape();
|
||||||
|
// }
|
||||||
},
|
},
|
||||||
// launch() {
|
// launch() {
|
||||||
// if (this.seePlayer.recall) {
|
// if (this.seePlayer.recall) {
|
||||||
@@ -1038,12 +1034,10 @@ const mobs = {
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
timeLimit() {
|
timeLimit() {
|
||||||
if (!m.isBodiesAsleep) {
|
this.timeLeft--;
|
||||||
this.timeLeft--;
|
if (this.timeLeft < 0) {
|
||||||
if (this.timeLeft < 0) {
|
this.isDropPowerUp = false;
|
||||||
this.isDropPowerUp = false;
|
this.death(); //death with no power up
|
||||||
this.death(); //death with no power up
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
healthBar() { //draw health by mob //most health bars are drawn in mobs.healthbar();
|
healthBar() { //draw health by mob //most health bars are drawn in mobs.healthbar();
|
||||||
|
|||||||
@@ -14,14 +14,16 @@ const simulation = {
|
|||||||
}
|
}
|
||||||
m.move();
|
m.move();
|
||||||
m.look();
|
m.look();
|
||||||
simulation.checks();
|
|
||||||
simulation.camera();
|
simulation.camera();
|
||||||
level.custom();
|
level.custom();
|
||||||
powerUps.do();
|
powerUps.do();
|
||||||
mobs.draw();
|
mobs.draw();
|
||||||
simulation.draw.cons();
|
simulation.draw.cons();
|
||||||
simulation.draw.body();
|
simulation.draw.body();
|
||||||
if (!m.isBodiesAsleep) mobs.loop();
|
if (!m.isBodiesAsleep) {
|
||||||
|
simulation.checks();
|
||||||
|
mobs.loop();
|
||||||
|
}
|
||||||
mobs.healthBar();
|
mobs.healthBar();
|
||||||
m.draw();
|
m.draw();
|
||||||
m.hold();
|
m.hold();
|
||||||
@@ -873,7 +875,7 @@ const simulation = {
|
|||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
checks() {
|
checks() {
|
||||||
if (!(simulation.cycle % 60) && !m.isBodiesAsleep) { //once a second
|
if (!(simulation.cycle % 60)) { //once a second
|
||||||
//energy overfill
|
//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 (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) {
|
if (tech.isFlipFlopEnergy && m.immuneCycle < m.cycle) {
|
||||||
|
|||||||
878
js/spawn.js
878
js/spawn.js
File diff suppressed because it is too large
Load Diff
13
todo.txt
13
todo.txt
@@ -1,16 +1,7 @@
|
|||||||
******************************************************** NEXT PATCH **************************************************
|
******************************************************** NEXT PATCH **************************************************
|
||||||
|
|
||||||
exit door has a 1 second delay and animation
|
removed about 80 !m.isBodiesAsleep
|
||||||
|
this could cause some bugs for bullets or mobs when time is dilated
|
||||||
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
|
|
||||||
|
|
||||||
******************************************************** TODO ********************************************************
|
******************************************************** TODO ********************************************************
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user