lower momentum needed to crouch on landing, laser-bot has less flicker
This commit is contained in:
@@ -1687,10 +1687,9 @@ const b = {
|
||||
restitution: 0.8,
|
||||
dmg: b.modExtraDmg, // 0.14 //damage done in addition to the damage from momentum
|
||||
minDmgSpeed: 2,
|
||||
lookFrequency: 47 + Math.floor(37 * Math.random()),
|
||||
range: 450 + Math.floor(200 * Math.random()),
|
||||
lookFrequency: 37 + Math.floor(27 * Math.random()),
|
||||
range: 500 + Math.floor(200 * Math.random()),
|
||||
endCycle: Infinity,
|
||||
modulus: Math.floor(2 * Math.random()), //offsets the modulus so the bullets don't all fire at the same time
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
@@ -1717,50 +1716,49 @@ const b = {
|
||||
}
|
||||
}
|
||||
|
||||
if (!((game.cycle + this.modulus) % 2)) {
|
||||
const FIELD_DRAIN = 0.006
|
||||
if (this.lockedOn && this.lockedOn.alive && mech.fieldMeter > FIELD_DRAIN) { //hit target with laser
|
||||
mech.fieldMeter -= FIELD_DRAIN
|
||||
const FIELD_DRAIN = 0.001
|
||||
if (this.lockedOn && this.lockedOn.alive && mech.fieldMeter > FIELD_DRAIN) { //hit target with laser
|
||||
mech.fieldMeter -= FIELD_DRAIN
|
||||
|
||||
//make sure you can still see target
|
||||
const TARGET_VECTOR = Matter.Vector.sub(this.vertices[0], this.lockedOn.position)
|
||||
const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
||||
if (DIST - this.lockedOn.radius < this.range + 200 &&
|
||||
Matter.Query.ray(map, this.vertices[0], this.lockedOn.position).length === 0 &&
|
||||
Matter.Query.ray(body, this.vertices[0], this.lockedOn.position).length === 0) {
|
||||
//find the closest vertex
|
||||
let bestVertexDistance = Infinity
|
||||
let bestVertex = null
|
||||
for (let i = 0; i < this.lockedOn.vertices.length; i++) {
|
||||
const dist = Matter.Vector.magnitude(Matter.Vector.sub(this.vertices[0], this.lockedOn.vertices[i]));
|
||||
if (dist < bestVertexDistance) {
|
||||
bestVertex = i
|
||||
bestVertexDistance = dist
|
||||
}
|
||||
//make sure you can still see target
|
||||
const TARGET_VECTOR = Matter.Vector.sub(this.vertices[0], this.lockedOn.position)
|
||||
const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
||||
if (DIST - this.lockedOn.radius < this.range + 150 &&
|
||||
Matter.Query.ray(map, this.vertices[0], this.lockedOn.position).length === 0 &&
|
||||
Matter.Query.ray(body, this.vertices[0], this.lockedOn.position).length === 0) {
|
||||
//find the closest vertex
|
||||
let bestVertexDistance = Infinity
|
||||
let bestVertex = null
|
||||
for (let i = 0; i < this.lockedOn.vertices.length; i++) {
|
||||
const dist = Matter.Vector.magnitude(Matter.Vector.sub(this.vertices[0], this.lockedOn.vertices[i]));
|
||||
if (dist < bestVertexDistance) {
|
||||
bestVertex = i
|
||||
bestVertexDistance = dist
|
||||
}
|
||||
const dmg = b.dmgScale * 0.10;
|
||||
this.lockedOn.damage(dmg);
|
||||
this.lockedOn.locatePlayer();
|
||||
|
||||
//draw laser
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.vertices[0].x, this.vertices[0].y);
|
||||
ctx.lineTo(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y);
|
||||
ctx.strokeStyle = "#f00";
|
||||
ctx.lineWidth = "2"
|
||||
ctx.lineDashOffset = 300 * Math.random()
|
||||
ctx.setLineDash([50 + 100 * Math.random(), 100 * Math.random()]);
|
||||
ctx.stroke();
|
||||
ctx.setLineDash([0, 0]);
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y, Math.sqrt(dmg) * 100, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = "#f00"
|
||||
ctx.fill();
|
||||
}
|
||||
const dmg = b.dmgScale * 0.03;
|
||||
this.lockedOn.damage(dmg);
|
||||
this.lockedOn.locatePlayer();
|
||||
|
||||
//draw laser
|
||||
ctx.beginPath();
|
||||
ctx.moveTo(this.vertices[0].x, this.vertices[0].y);
|
||||
ctx.lineTo(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y);
|
||||
ctx.strokeStyle = "rgb(255,0,40)";
|
||||
ctx.lineWidth = "2"
|
||||
ctx.lineDashOffset = 300 * Math.random()
|
||||
ctx.setLineDash([50 + 100 * Math.random(), 100 * Math.random()]);
|
||||
ctx.stroke();
|
||||
ctx.setLineDash([0, 0]);
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y, Math.sqrt(dmg) * 100, 0, 2 * Math.PI);
|
||||
ctx.fillStyle = "rgba(255,0,40,0.7)" //"#f00"
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
|
||||
const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
|
||||
if (distanceToPlayer > this.range * 0.25) { //if far away move towards player
|
||||
if (distanceToPlayer > this.range * 0.2) { //if far away move towards player
|
||||
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(mech.pos, this.position)), this.mass * 0.002)
|
||||
this.frictionAir = 0.02
|
||||
} else { //close to player
|
||||
|
||||
@@ -14,7 +14,7 @@ const level = {
|
||||
start() {
|
||||
if (level.levelsCleared === 0) {
|
||||
// game.difficulty = 6; //for testing to simulate possible mobs spawns
|
||||
b.giveGuns(14)
|
||||
// b.giveGuns(14)
|
||||
// mech.fieldUpgrades[2].effect();
|
||||
// b.giveMod(5)
|
||||
|
||||
|
||||
@@ -199,7 +199,7 @@ const mech = {
|
||||
//sets a hard land where player stays in a crouch for a bit and can't jump
|
||||
//crouch is forced in keyMove() on ground section below
|
||||
const momentum = player.velocity.y * player.mass //player mass is 5 so this triggers at 20 down velocity, unless the player is holding something
|
||||
if (momentum > 100) {
|
||||
if (momentum > 120) {
|
||||
this.doCrouch();
|
||||
this.yOff = this.yOffWhen.jump;
|
||||
this.hardLandCD = mech.cycle + Math.min(momentum / 6 - 6, 40)
|
||||
|
||||
@@ -130,7 +130,7 @@ const spawn = {
|
||||
//easy mob for on level 1
|
||||
mobs.spawn(x, y, 8, radius, "#9ccdc6");
|
||||
let me = mob[mob.length - 1];
|
||||
me.accelMag = 0.00055 * game.accelScale;
|
||||
me.accelMag = 0.0005 * game.accelScale;
|
||||
me.memory = 60;
|
||||
Matter.Body.setDensity(me, 0.0005) // normal density is 0.001 // this reduces life by half and decreases knockback
|
||||
|
||||
@@ -141,7 +141,6 @@ const spawn = {
|
||||
};
|
||||
},
|
||||
healer(x, y, radius = 20) {
|
||||
//easy mob for on level 1
|
||||
mobs.spawn(x, y, 3, radius, "rgba(50,255,200,0.4)");
|
||||
let me = mob[mob.length - 1];
|
||||
me.frictionAir = 0.02;
|
||||
|
||||
Reference in New Issue
Block a user