more pulsar balance and polish

This commit is contained in:
landgreen
2021-03-09 04:04:32 -08:00
parent b3c54e89f1
commit 06dfe46f8e
4 changed files with 106 additions and 65 deletions

BIN
.DS_Store vendored

Binary file not shown.

View File

@@ -37,8 +37,8 @@ const level = {
// m.shipMode() // m.shipMode()
// tech.isBotSwap = true; // tech.isBotSwap = true;
level.intro(); //starting level // level.intro(); //starting level
// level.testing(); //not in rotation level.testing(); //not in rotation
// level.final() //final boss level // level.final() //final boss level
// level.gauntlet(); //before final boss level // level.gauntlet(); //before final boss level
// level.testChamber() //less mobs, more puzzle // level.testChamber() //less mobs, more puzzle
@@ -1089,7 +1089,7 @@ const level = {
// simulation.difficulty = 30 // simulation.difficulty = 30
// spawn.starter(1900, -500, 200) //big boy // spawn.starter(1900, -500, 200) //big boy
// spawn.pulsar(1900, -500) spawn.pulsar(1900, -500)
spawn.pulsarBoss(1900, -500) spawn.pulsarBoss(1900, -500)
// spawn.historyBoss(1900, -500) // spawn.historyBoss(1900, -500)
// spawn.ghoster(2900, -500) // spawn.ghoster(2900, -500)
@@ -4032,11 +4032,15 @@ const level = {
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
if (mob[i].isBoss) me = mob[i] if (mob[i].isBoss) me = mob[i]
} }
me.onDeath = function() { if (me) {
this.removeCons(); //remove constraint me.onDeath = function() {
spawnCouloirEnHaut()
doorSortieSalle.isOpen = false;
};
} else {
spawnCouloirEnHaut() spawnCouloirEnHaut()
doorSortieSalle.isOpen = false; doorSortieSalle.isOpen = false;
}; }
// } // }
} else { } else {
spawn.randomLevelBoss(8000, 630, ["shooterBoss"]); spawn.randomLevelBoss(8000, 630, ["shooterBoss"]);
@@ -4044,10 +4048,15 @@ const level = {
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
if (mob[i].isBoss) me = mob[i] if (mob[i].isBoss) me = mob[i]
} }
me.onDeath = function() { if (me) {
me.onDeath = function() {
spawnCouloirEnHaut()
doorSortieSalle.isOpen = false;
};
} else {
spawnCouloirEnHaut() spawnCouloirEnHaut()
doorSortieSalle.isOpen = false; doorSortieSalle.isOpen = false;
}; }
} }
}, },
house() { house() {

View File

@@ -11,7 +11,7 @@ const spawn = {
"launcher", "launcher", "launcher", "launcher",
"springer", "springer", "springer", "springer",
"sucker", "sucker", "sucker", "sucker",
"pulsar", "pulsar", "pulsar", "pulsar", "pulsar", "pulsar", "pulsar", "pulsar",
"chaser", "chaser",
"sniper", "sniper",
"spinner", "spinner",
@@ -1493,14 +1493,12 @@ const spawn = {
me.pulseRadius = Math.min(500, 230 + simulation.difficulty * 3) me.pulseRadius = Math.min(500, 230 + simulation.difficulty * 3)
me.fireDelay = Math.max(60, 190 - simulation.difficulty * 2) me.fireDelay = Math.max(60, 190 - simulation.difficulty * 2)
me.isFiring = false me.isFiring = false
Matter.Body.setDensity(me, 0.03); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.03); //extra dense //normal is 0.001 //makes effective life much larger
spawn.shield(me, x, y, 1); spawn.shield(me, x, y, 1);
spawn.spawnOrbitals(me, radius + 200 + 300 * Math.random(), 1) spawn.spawnOrbitals(me, radius + 200 + 300 * Math.random(), 1)
me.onDeath = function() { me.onDeath = function() {
powerUps.spawnBossPowerUp(this.position.x, this.position.y) powerUps.spawnBossPowerUp(this.position.x, this.position.y)
}; };
me.onHit = function() {}; me.onHit = function() {};
me.do = function() { me.do = function() {
if (player.speed > 5) this.do = this.fire //don't attack until player moves if (player.speed > 5) this.do = this.fire //don't attack until player moves
@@ -1511,6 +1509,8 @@ const spawn = {
if (this.isFiring) { if (this.isFiring) {
if (this.fireCycle > this.fireDelay) { //fire if (this.fireCycle > this.fireDelay) { //fire
this.isFiring = false this.isFiring = false
this.fireCycle = 0
this.torque += (0.00008 + 0.00007 * Math.random()) * this.inertia * (Math.round(Math.random()) * 2 - 1) //randomly spin around after firing
//is player in beam path //is player in beam path
if (Matter.Query.ray([player], this.fireTarget, this.position).length) { if (Matter.Query.ray([player], this.fireTarget, this.position).length) {
unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100) unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100)
@@ -1528,42 +1528,52 @@ const spawn = {
color: "rgba(120,0,255,0.6)", color: "rgba(120,0,255,0.6)",
time: simulation.drawTime time: simulation.drawTime
}); });
ctx.beginPath();
ctx.moveTo(this.vertices[1].x, this.vertices[1].y)
ctx.lineTo(this.fireTarget.x, this.fireTarget.y)
ctx.lineWidth = 20;
ctx.strokeStyle = "rgba(120,0,255,0.2)";
ctx.stroke();
ctx.lineWidth = 4;
ctx.strokeStyle = "rgba(120,0,255,1)";
ctx.stroke();
} else { //delay before firing } else { //delay before firing
this.fireCycle++ this.fireCycle++
if (!(simulation.cycle % 3)) { //draw explosion outline
//draw explosion outline ctx.beginPath();
ctx.beginPath(); ctx.arc(this.fireTarget.x, this.fireTarget.y, this.pulseRadius, 0, 2 * Math.PI); //* this.fireCycle / this.fireDelay
ctx.arc(this.fireTarget.x, this.fireTarget.y, this.pulseRadius, 0, 2 * Math.PI); //* this.fireCycle / this.fireDelay ctx.fillStyle = "rgba(120,0,255,0.05)";
ctx.fillStyle = "rgba(120,0,255,0.1)"; ctx.fill();
ctx.fill(); //draw path from mob to explosion
//draw path from mob to explosion ctx.beginPath();
ctx.beginPath(); ctx.moveTo(this.vertices[1].x, this.vertices[1].y)
ctx.moveTo(this.vertices[1].x, this.vertices[1].y) ctx.lineTo(this.fireTarget.x, this.fireTarget.y)
ctx.lineTo(this.fireTarget.x, this.fireTarget.y) ctx.setLineDash([40 * Math.random(), 200 * Math.random()]);
ctx.setLineDash([40 * Math.random(), 200 * Math.random()]); ctx.lineWidth = 2;
ctx.lineWidth = 2; ctx.strokeStyle = "rgba(120,0,255,0.15)";
ctx.strokeStyle = "rgba(120,0,255,0.5)"; ctx.stroke();
ctx.stroke(); ctx.setLineDash([0, 0]);
ctx.setLineDash([0, 0]);
}
} }
} else { //aim at player } else { //aim at player
this.fireDir = Vector.normalise(Vector.sub(player.position, this.position)); //set direction to turn to fire this.fireCycle++
this.fireDir = Vector.normalise(Vector.sub(m.pos, this.position)); //set direction to turn to fire
//rotate towards fireAngle //rotate towards fireAngle
const angle = this.angle + Math.PI / 2; const angle = this.angle + Math.PI / 2;
const c = Math.cos(angle) * this.fireDir.x + Math.sin(angle) * this.fireDir.y; const c = Math.cos(angle) * this.fireDir.x + Math.sin(angle) * this.fireDir.y;
const threshold = 0.04; const threshold = 0.03;
if (c > threshold) { if (c > threshold) {
this.torque += 0.0000015 * this.inertia; this.torque += 0.000001 * this.inertia;
} else if (c < -threshold) { } else if (c < -threshold) {
this.torque -= 0.0000015 * this.inertia; this.torque -= 0.000001 * this.inertia;
} else { //fire } else if (this.fireCycle > 45) { //fire
unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100) unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100)
this.fireTarget = Vector.add(this.vertices[1], unit) this.fireTarget = Vector.add(this.vertices[1], unit)
Matter.Body.setAngularVelocity(this, 0) if (Vector.magnitude(Vector.sub(m.pos, this.fireTarget)) < 1000) { //if's possible for this to be facing 180 degrees away from the player, this makes sure that doesn't occur
this.fireLockCount = 0 Matter.Body.setAngularVelocity(this, 0)
this.isFiring = true this.fireLockCount = 0
this.fireCycle = 0 this.isFiring = true
this.fireCycle = 0
}
} }
} }
} }
@@ -1579,17 +1589,23 @@ const spawn = {
me.vertices[1].y = me.position.y + Math.sin(me.angle) * me.radius; me.vertices[1].y = me.position.y + Math.sin(me.angle) * me.radius;
me.fireCycle = 0 me.fireCycle = 0
me.fireTarget = { x: 0, y: 0 } me.fireTarget = { x: 0, y: 0 }
me.pulseRadius = Math.min(400, 200 + simulation.difficulty * 3) me.pulseRadius = Math.min(400, 150 + simulation.difficulty * 3)
me.fireDelay = Math.max(70, 220 - simulation.difficulty * 2) me.fireDelay = Math.max(70, 180 - simulation.difficulty)
me.isFiring = false me.isFiring = false
me.onHit = function() {}; me.onHit = function() {};
me.canSeeTarget = function() { me.canSeeTarget = function() {
const diff = Vector.normalise(Vector.sub(this.fireTarget, this.position)); //make a vector for the mob's direction of length 1 const diff = Vector.normalise(Vector.sub(this.fireTarget, this.position)); //make a vector for the mob's direction of length 1
const angle = this.angle + Math.PI / 2;
const dot = Vector.dot({ const dot = Vector.dot({
x: Math.cos(this.angle), x: Math.cos(angle),
y: Math.sin(this.angle) y: Math.sin(angle)
}, diff); //the dot product of diff and dir will return how much over lap between the vectors }, diff); //the dot product of di console.log(dot, 'see')
if (dot < 0.97 || Matter.Query.ray(map, this.fireTarget, this.position).length || Matter.Query.ray(body, this.fireTarget, this.position).length) { //if not looking at target //distance between the target and the player's location
if (
dot > 0.03 || // not looking at target
Matter.Query.ray(map, this.fireTarget, this.position).length || Matter.Query.ray(body, this.fireTarget, this.position).length || //something blocking line of sight
Vector.magnitude(Vector.sub(m.pos, this.fireTarget)) > 1000 // distance from player to target is very far, (this is because dot product can't tell if facing 180 degrees away)
) {
this.isFiring = false this.isFiring = false
return false return false
} else { } else {
@@ -1604,6 +1620,8 @@ const spawn = {
if (this.fireCycle > this.fireDelay) { //fire if (this.fireCycle > this.fireDelay) { //fire
if (!this.canSeeTarget()) return if (!this.canSeeTarget()) return
this.isFiring = false this.isFiring = false
this.fireCycle = 0
this.torque += (0.00002 + 0.0002 * Math.random()) * this.inertia * (Math.round(Math.random()) * 2 - 1) //randomly spin around after firing
//is player in beam path //is player in beam path
if (Matter.Query.ray([player], this.fireTarget, this.position).length) { if (Matter.Query.ray([player], this.fireTarget, this.position).length) {
unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100) unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100)
@@ -1621,37 +1639,49 @@ const spawn = {
color: "rgba(255,0,100,0.6)", color: "rgba(255,0,100,0.6)",
time: simulation.drawTime time: simulation.drawTime
}); });
ctx.beginPath();
ctx.moveTo(this.vertices[1].x, this.vertices[1].y)
ctx.lineTo(this.fireTarget.x, this.fireTarget.y)
ctx.lineWidth = 20;
ctx.strokeStyle = "rgba(255,0,100,0.2)";
ctx.stroke();
ctx.lineWidth = 4;
ctx.strokeStyle = "rgba(255,0,100,1)";
ctx.stroke();
} else { //delay before firing } else { //delay before firing
this.fireCycle++ this.fireCycle++
if (!(simulation.cycle % 3)) { if (!(simulation.cycle % 3)) {
if (!this.canSeeTarget()) return //if can't see stop firing if (!this.canSeeTarget()) return //if can't see stop firing
//draw explosion outline
ctx.beginPath();
ctx.arc(this.fireTarget.x, this.fireTarget.y, this.pulseRadius, 0, 2 * Math.PI); //* this.fireCycle / this.fireDelay
ctx.fillStyle = "rgba(255,0,100,0.1)";
ctx.fill();
//draw path from mob to explosion
ctx.beginPath();
ctx.moveTo(this.vertices[1].x, this.vertices[1].y)
ctx.lineTo(this.fireTarget.x, this.fireTarget.y)
ctx.setLineDash([40 * Math.random(), 200 * Math.random()]);
ctx.lineWidth = 2;
ctx.strokeStyle = "rgba(255,0,100,0.5)";
ctx.stroke();
ctx.setLineDash([0, 0]);
} }
//draw explosion outline
ctx.beginPath();
ctx.arc(this.fireTarget.x, this.fireTarget.y, this.pulseRadius, 0, 2 * Math.PI); //* this.fireCycle / this.fireDelay
ctx.fillStyle = "rgba(255,0,100,0.05)";
ctx.fill();
//draw path from mob to explosion
ctx.beginPath();
ctx.moveTo(this.vertices[1].x, this.vertices[1].y)
ctx.lineTo(this.fireTarget.x, this.fireTarget.y)
ctx.setLineDash([40 * Math.random(), 200 * Math.random()]);
ctx.lineWidth = 2;
ctx.strokeStyle = "rgba(255,0,100,0.15)";
ctx.stroke();
ctx.setLineDash([0, 0]);
} }
} else { //aim at player } else { //aim at player
this.fireCycle++
this.fireDir = Vector.normalise(Vector.sub(this.seePlayer.position, this.position)); //set direction to turn to fire this.fireDir = Vector.normalise(Vector.sub(this.seePlayer.position, this.position)); //set direction to turn to fire
//rotate towards fireAngle
const angle = this.angle + Math.PI / 2; const angle = this.angle + Math.PI / 2;
const c = Math.cos(angle) * this.fireDir.x + Math.sin(angle) * this.fireDir.y; const dot = Vector.dot({
const threshold = 0.04; x: Math.cos(angle),
if (c > threshold) { y: Math.sin(angle)
this.torque += 0.0000015 * this.inertia; }, this.fireDir)
} else if (c < -threshold) { const threshold = 0.03;
this.torque -= 0.0000015 * this.inertia; if (dot > threshold) { //rotate towards fireAngle
} else { //fire this.torque += 0.000001 * this.inertia;
} else if (dot < -threshold) {
this.torque -= 0.000001 * this.inertia;
} else if (this.fireCycle > 90) { // aim
unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100) unit = Vector.mult(Vector.normalise(Vector.sub(this.vertices[1], this.position)), this.distanceToPlayer() - 100)
this.fireTarget = Vector.add(this.vertices[1], unit) this.fireTarget = Vector.add(this.vertices[1], unit)
if (!this.canSeeTarget()) return if (!this.canSeeTarget()) return

View File

@@ -3,6 +3,8 @@
******************************************************** BUGS ******************************************************** ******************************************************** BUGS ********************************************************
inductive + MEE + 1st ion + negentrophy + electrolytes + tranceiver chip + dupe chance is ridiculously op
micro-extruder is laggy? micro-extruder is laggy?
mouse event e.which is deprecated mouse event e.which is deprecated
@@ -46,7 +48,7 @@ use the floor of portal sensor on the player? to unstuck player
******************************************************** TODO ******************************************************** ******************************************************** TODO ********************************************************
pulsar boss, ignores line of site, but a longer fire CD add a delay between each fire for pulsar mobs
mob bullets that blow up mob bullets that blow up
draw outline of exploded region, 2 seconds later damage player in region and remove bullet draw outline of exploded region, 2 seconds later damage player in region and remove bullet