foam bug fixes
This commit is contained in:
@@ -1789,13 +1789,13 @@ const b = {
|
||||
name: "foam", //15
|
||||
description: "spray bubbly foam that <strong>sticks</strong> to enemies<br>does <strong class='color-d'>damage</strong> over time and <strong>slows</strong> movement",
|
||||
ammo: 0,
|
||||
ammoPack: 80,
|
||||
ammoPack: 95,
|
||||
have: false,
|
||||
isStarterGun: true,
|
||||
fire() {
|
||||
const me = bullet.length;
|
||||
const dir = mech.angle + 0.1 * (Math.random() - 0.5)
|
||||
const RADIUS = (9 + 12 * Math.random()) * b.modBulletSize
|
||||
const dir = mech.angle + 0.2 * (Math.random() - 0.5)
|
||||
const RADIUS = (6 + 16 * Math.random()) * b.modBulletSize
|
||||
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 25, RADIUS, {
|
||||
angle: dir,
|
||||
density: 0.000001, // 0.001 is normal density
|
||||
@@ -1803,7 +1803,7 @@ const b = {
|
||||
frictionAir: 0,
|
||||
friction: 0.2,
|
||||
restitution: 0.2,
|
||||
dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||
dmg: 0.04 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
||||
classType: "bullet",
|
||||
collisionFilter: {
|
||||
category: 0x000100,
|
||||
@@ -1815,7 +1815,7 @@ const b = {
|
||||
radius: RADIUS,
|
||||
target: null,
|
||||
onDmg(who) {
|
||||
if (!this.target && who.alive) {
|
||||
if (!this.target && who.alive && who.dropPowerUp) {
|
||||
this.target = who;
|
||||
this.collisionFilter.category = 0x000000;
|
||||
}
|
||||
@@ -1852,7 +1852,7 @@ const b = {
|
||||
Matter.Body.setPosition(this, this.target.position)
|
||||
Matter.Body.setVelocity(this.target, Matter.Vector.mult(this.target.velocity, 0.95))
|
||||
Matter.Body.setAngularVelocity(this.target, this.target.angularVelocity * 0.96)
|
||||
this.target.damage(b.dmgScale * 0.0035);
|
||||
this.target.damage(b.dmgScale * 0.0025);
|
||||
} else {
|
||||
//look for a new target
|
||||
this.target = null
|
||||
@@ -1863,7 +1863,7 @@ const b = {
|
||||
});
|
||||
World.add(engine.world, bullet[me]); //add bullet to world
|
||||
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 15 : 3) * b.modFireRate); // cool down
|
||||
const SPEED = mech.crouch ? 25 : 16 - RADIUS * 0.25;
|
||||
const SPEED = mech.crouch ? 22 : 15 - RADIUS * 0.25;
|
||||
Matter.Body.setVelocity(bullet[me], {
|
||||
x: SPEED * Math.cos(dir),
|
||||
y: SPEED * Math.sin(dir)
|
||||
|
||||
@@ -110,7 +110,7 @@ const level = {
|
||||
// powerUps.spawn(450, -400, "mod", false, 6);
|
||||
// powerUps.spawn(450, -400, "mod", false);
|
||||
// spawn.bodyRect(-45, -100, 40, 50);
|
||||
spawn.shooter(800, -1150);
|
||||
spawn.shooter(800, -1050);
|
||||
// spawn.groupBoss(-600, -550);
|
||||
// spawn.hopper(800, -150);
|
||||
// spawn.beamer(800, -150);
|
||||
|
||||
@@ -711,7 +711,7 @@ const mobs = {
|
||||
// }
|
||||
},
|
||||
grow() {
|
||||
if (!this.isSleeping) {
|
||||
if (!mech.isBodiesAsleep) {
|
||||
if (this.seePlayer.recall) {
|
||||
if (this.radius < 80) {
|
||||
const scale = 1.01;
|
||||
@@ -845,7 +845,7 @@ const mobs = {
|
||||
}
|
||||
},
|
||||
fire() {
|
||||
if (!this.isSleeping) {
|
||||
if (!mech.isBodiesAsleep) {
|
||||
const setNoseShape = () => {
|
||||
const mag = this.radius + this.radius * this.noseLength;
|
||||
this.vertices[1].x = this.position.x + Math.cos(this.angle) * mag;
|
||||
@@ -921,7 +921,7 @@ const mobs = {
|
||||
this.death(); //death with no power up or body
|
||||
},
|
||||
timeLimit() {
|
||||
if (!this.isSleeping) {
|
||||
if (!mech.isBodiesAsleep) {
|
||||
this.timeLeft--;
|
||||
if (this.timeLeft < 0) {
|
||||
this.dropPowerUp = false;
|
||||
|
||||
30
js/player.js
30
js/player.js
@@ -846,13 +846,13 @@ const mech = {
|
||||
},
|
||||
grabPowerUp() { //look for power ups to grab with field
|
||||
if (mech.fieldCDcycle < mech.cycle) {
|
||||
const grabPowerUpRange2 = (this.grabRange + 220) * (this.grabRange + 220)
|
||||
const grabPowerUpRange2 = (mech.grabRange + 220) * (mech.grabRange + 220)
|
||||
for (let i = 0, len = powerUp.length; i < len; ++i) {
|
||||
const dxP = mech.pos.x - powerUp[i].position.x;
|
||||
const dyP = mech.pos.y - powerUp[i].position.y;
|
||||
const dist2 = dxP * dxP + dyP * dyP;
|
||||
// float towards player if looking at and in range or if very close to player
|
||||
if (dist2 < grabPowerUpRange2 && this.lookingAt(powerUp[i]) || dist2 < 16000) {
|
||||
if (dist2 < grabPowerUpRange2 && mech.lookingAt(powerUp[i]) || dist2 < 16000) {
|
||||
if (dist2 < 5000) { //use power up if it is close enough
|
||||
Matter.Body.setVelocity(player, { //player knock back, after grabbing power up
|
||||
x: player.velocity.x + ((powerUp[i].velocity.x * powerUp[i].mass) / player.mass) * 0.3,
|
||||
@@ -861,7 +861,7 @@ const mech = {
|
||||
mech.usePowerUp(i);
|
||||
return;
|
||||
}
|
||||
this.fieldMeter -= this.fieldRegen * 0.5;
|
||||
mech.fieldMeter -= mech.fieldRegen * 0.5;
|
||||
powerUp[i].force.x += 7 * (dxP / dist2) * powerUp[i].mass;
|
||||
powerUp[i].force.y += 7 * (dyP / dist2) * powerUp[i].mass - powerUp[i].mass * game.g; //negate gravity
|
||||
//extra friction
|
||||
@@ -876,11 +876,12 @@ const mech = {
|
||||
pushMass(who) {
|
||||
const speed = Matter.Vector.magnitude(Matter.Vector.sub(who.velocity, player.velocity))
|
||||
const fieldBlockCost = 0.03 + Math.sqrt(who.mass) * speed * 0.003 //0.012
|
||||
if (this.fieldMeter > fieldBlockCost * 0.6) { //shield needs at least some of the cost to block
|
||||
this.fieldMeter -= fieldBlockCost * this.fieldShieldingScale;
|
||||
if (this.fieldMeter < 0) this.fieldMeter = 0;
|
||||
this.drawHold(who);
|
||||
if (mech.fieldMeter > fieldBlockCost * 0.6) { //shield needs at least some of the cost to block
|
||||
mech.fieldMeter -= fieldBlockCost * mech.fieldShieldingScale;
|
||||
if (mech.fieldMeter < 0) mech.fieldMeter = 0;
|
||||
mech.drawHold(who);
|
||||
mech.fieldCDcycle = mech.cycle + 10;
|
||||
mech.holdingTarget = null
|
||||
//knock backs
|
||||
const unit = Matter.Vector.normalise(Matter.Vector.sub(player.position, who.position))
|
||||
const mass = Math.min(Math.sqrt(who.mass), 3.5); //large masses above 4*4 can start to overcome the push back
|
||||
@@ -1061,9 +1062,9 @@ const mech = {
|
||||
} else if ((keys[32] || game.mouseDownRight && mech.fieldMeter > 0.1 && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
||||
mech.drawField();
|
||||
mech.grabPowerUp();
|
||||
mech.pushMobsFacing();
|
||||
mech.pushBodyFacing();
|
||||
mech.lookForPickUp();
|
||||
mech.pushBodyFacing();
|
||||
mech.pushMobsFacing();
|
||||
} else if (mech.holdingTarget && mech.fireCDcycle < mech.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released
|
||||
mech.pickUp();
|
||||
} else {
|
||||
@@ -1294,10 +1295,10 @@ const mech = {
|
||||
ctx.lineWidth = 2 * Math.random();
|
||||
ctx.stroke();
|
||||
|
||||
mech.pushMobs360(110);
|
||||
// mech.pushBody360(100); //disabled because doesn't work at short range
|
||||
mech.grabPowerUp();
|
||||
mech.lookForPickUp();
|
||||
mech.pushMobs360(110);
|
||||
// mech.pushBody360(100); //disabled because doesn't work at short range
|
||||
} else {
|
||||
mech.fieldCDcycle = mech.cycle + 120; //if out of energy
|
||||
}
|
||||
@@ -1327,10 +1328,9 @@ const mech = {
|
||||
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //push away
|
||||
const DRAIN = 0.0004
|
||||
if (mech.fieldMeter > DRAIN) {
|
||||
mech.pushMobs360(170);
|
||||
mech.pushBody360(180);
|
||||
mech.grabPowerUp();
|
||||
mech.lookForPickUp(170);
|
||||
mech.pushMobs360(170);
|
||||
//look for nearby objects to make zero-g
|
||||
function zeroG(who, mag = 1.06) {
|
||||
for (let i = 0, len = who.length; i < len; ++i) {
|
||||
@@ -1462,11 +1462,11 @@ const mech = {
|
||||
mech.holding();
|
||||
mech.throw();
|
||||
} else if ((keys[32] || game.mouseDownRight && mech.fieldMeter > 0.1 && mech.fieldCDcycle < mech.cycle)) { //not hold but field button is pressed
|
||||
mech.pushMobsFacing();
|
||||
mech.pushBodyFacing();
|
||||
mech.drawField();
|
||||
mech.grabPowerUp();
|
||||
mech.lookForPickUp();
|
||||
mech.pushMobsFacing();
|
||||
mech.pushBodyFacing();
|
||||
} else if (mech.holdingTarget && mech.fireCDcycle < mech.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released
|
||||
mech.pickUp();
|
||||
} else {
|
||||
|
||||
@@ -587,7 +587,7 @@ const spawn = {
|
||||
};
|
||||
// if (Math.random() < Math.min(0.2 + game.difficulty * 0.1, 0.7)) spawn.shield(me, x, y);
|
||||
me.do = function () {
|
||||
if (!this.isSleeping) {
|
||||
if (!mech.isBodiesAsleep) {
|
||||
this.seePlayerByLookingAt();
|
||||
const dist2 = this.distanceToPlayer2();
|
||||
//laser Tracking
|
||||
@@ -689,7 +689,7 @@ const spawn = {
|
||||
this.attraction();
|
||||
this.gravity();
|
||||
//draw
|
||||
if (!this.isSleeping) {
|
||||
if (!mech.isBodiesAsleep) {
|
||||
if (this.seePlayer.yes) {
|
||||
if (this.alpha < 1) this.alpha += 0.01;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user