diff --git a/js/bullet.js b/js/bullet.js
index 2dbe576..f77a635 100644
--- a/js/bullet.js
+++ b/js/bullet.js
@@ -966,11 +966,20 @@ const b = {
};
bullet[me].do = function () {};
},
+ // **************************************************************************************************
+ // **************************************************************************************************
+ // ******************************** Bots *********************************************
+ // **************************************************************************************************
+ // **************************************************************************************************
+ respawnBots() {
+ for (let i = 0; i < mod.laserBotCount; i++) b.laserBot()
+ for (let i = 0; i < mod.nailBotCount; i++) b.nailBot()
+ for (let i = 0; i < mod.foamBotCount; i++) b.foamBot()
+ for (let i = 0; i < mod.boomBotCount; i++) b.boomBot()
+ for (let i = 0; i < mod.plasmaBotCount; i++) b.plasmaBot()
+ },
randomBot(where = mech.pos, isKeep = true) {
- if (Math.random() < 0.05) { //very low chance of plasma bot
- b.plasmaBot(where)
- if (isKeep) mod.plasmaBotCount++;
- } else if (Math.random() < 0.25) {
+ if (Math.random() < 0.25) {
b.nailBot(where)
if (isKeep) mod.nailBotCount++;
} else if (Math.random() < 0.33) {
@@ -984,11 +993,12 @@ const b = {
if (isKeep) mod.boomBotCount++;
}
},
- nailBot(position = mech.pos) {
+ nailBot(position = mech.pos, isUpgraded = mod.isBotUpgrade) {
const me = bullet.length;
const dir = mech.angle;
const RADIUS = (12 + 4 * Math.random())
bullet[me] = Bodies.polygon(position.x, position.y, 4, RADIUS, {
+ isUpgraded: isUpgraded,
isBot: true,
angle: dir,
friction: 0,
@@ -997,7 +1007,8 @@ const b = {
restitution: 0.6 * (1 + 0.5 * Math.random()),
dmg: 0, // 0.14 //damage done in addition to the damage from momentum
minDmgSpeed: 2,
- lookFrequency: 56 + Math.floor(17 * Math.random()),
+ // lookFrequency: 56 + Math.floor(17 * Math.random()) - isUpgraded * 20,
+ lastLookCycle: game.cycle + 60 * Math.random(),
acceleration: 0.005 * (1 + 0.5 * Math.random()),
range: 70 * (1 + 0.3 * Math.random()),
endCycle: Infinity,
@@ -1012,7 +1023,8 @@ const b = {
},
onEnd() {},
do() {
- if (!(game.cycle % this.lookFrequency) && !mech.isStealth) {
+ if (this.lastLookCycle < game.cycle) {
+ this.lastLookCycle = game.cycle + 65 - this.isUpgraded * 30
let target
for (let i = 0, len = mob.length; i < len; i++) {
const dist = Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position));
@@ -1026,25 +1038,22 @@ const b = {
}
}
}
-
const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, mech.pos))
if (distanceToPlayer > this.range) { //if far away move towards player
this.force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, this.position)), this.mass * this.acceleration)
- // this.frictionAir = 0.1
} else { //close to player
- // this.frictionAir = 0
- //add player's velocity
- Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17)));
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
}
}
})
World.add(engine.world, bullet[me]); //add bullet to world
},
- foamBot(position = mech.pos) {
+ foamBot(position = mech.pos, isUpgraded = mod.isBotUpgrade) {
const me = bullet.length;
const dir = mech.angle;
const RADIUS = (10 + 5 * Math.random())
bullet[me] = Bodies.polygon(position.x, position.y, 6, RADIUS, {
+ isUpgraded: isUpgraded,
isBot: true,
angle: dir,
friction: 0,
@@ -1080,12 +1089,11 @@ const b = {
const radius = 6 + 7 * Math.random()
const SPEED = 29 - radius * 0.5; //(mech.crouch ? 32 : 20) - radius * 0.7;
const velocity = Vector.mult(Vector.normalise(Vector.sub(target, this.position)), SPEED)
- b.foam(this.position, velocity, radius)
+ b.foam(this.position, velocity, radius + 8 * this.isUpgraded)
break;
}
}
}
-
const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, mech.pos))
if (distanceToPlayer > this.range) { //if far away move towards player
this.force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, this.position)), this.mass * this.acceleration)
@@ -1096,279 +1104,12 @@ const b = {
})
World.add(engine.world, bullet[me]); //add bullet to world
},
- plasmaBot(position = mech.pos) {
- const me = bullet.length;
- const dir = mech.angle;
- const RADIUS = 21
- bullet[me] = Bodies.polygon(position.x, position.y, 5, RADIUS, {
- isBot: true,
- angle: dir,
- friction: 0,
- frictionStatic: 0,
- frictionAir: 0.05,
- restitution: 1,
- dmg: 0, // 0.14 //damage done in addition to the damage from momentum
- minDmgSpeed: 2,
- lookFrequency: 25,
- cd: 0,
- acceleration: 0.009,
- endCycle: Infinity,
- classType: "bullet",
- collisionFilter: {
- category: cat.bullet,
- mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
- },
- lockedOn: null,
- onDmg() {
- this.lockedOn = null
- },
- onEnd() {},
- do() {
- const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, mech.pos))
- if (distanceToPlayer > 150) { //if far away move towards player
- this.force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, this.position)), this.mass * this.acceleration)
- }
- Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
-
- //find closest
- if (!(game.cycle % this.lookFrequency)) {
- this.lockedOn = null;
- let closeDist = mod.isPlasmaRange * 1000;
- for (let i = 0, len = mob.length; i < len; ++i) {
- const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
- if (DIST < closeDist &&
- Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
- Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
- closeDist = DIST;
- this.lockedOn = mob[i]
- }
- }
- }
-
- //fire plasma at target
-
-
- if (this.lockedOn && this.lockedOn.alive && mech.fieldCDcycle < mech.cycle) {
- const sub = Vector.sub(this.lockedOn.position, this.position)
- const DIST = Vector.magnitude(sub);
- const unit = Vector.normalise(sub)
-
- const DRAIN = 0.0022
- if (DIST < mod.isPlasmaRange * 550 && mech.energy > DRAIN) {
- mech.energy -= DRAIN;
- if (mech.energy < 0) {
- mech.fieldCDcycle = mech.cycle + 120;
- mech.energy = 0;
- }
- //calculate laser collision
- let best;
- let range = mod.isPlasmaRange * (140 + 300 * Math.sqrt(Math.random()))
- const path = [{
- x: this.position.x,
- y: this.position.y
- },
- {
- x: this.position.x + range * unit.x,
- y: this.position.y + range * unit.y
- }
- ];
- const vertexCollision = function (v1, v1End, domain) {
- for (let i = 0; i < domain.length; ++i) {
- let vertices = domain[i].vertices;
- const len = vertices.length - 1;
- for (let j = 0; j < len; j++) {
- results = game.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]);
- if (results.onLine1 && results.onLine2) {
- const dx = v1.x - results.x;
- const dy = v1.y - results.y;
- const dist2 = dx * dx + dy * dy;
- if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) {
- best = {
- x: results.x,
- y: results.y,
- dist2: dist2,
- who: domain[i],
- v1: vertices[j],
- v2: vertices[j + 1]
- };
- }
- }
- }
- results = game.checkLineIntersection(v1, v1End, vertices[0], vertices[len]);
- if (results.onLine1 && results.onLine2) {
- const dx = v1.x - results.x;
- const dy = v1.y - results.y;
- const dist2 = dx * dx + dy * dy;
- if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) {
- best = {
- x: results.x,
- y: results.y,
- dist2: dist2,
- who: domain[i],
- v1: vertices[0],
- v2: vertices[len]
- };
- }
- }
- }
- };
-
- //check for collisions
- best = {
- x: null,
- y: null,
- dist2: Infinity,
- who: null,
- v1: null,
- v2: null
- };
- vertexCollision(path[0], path[1], mob);
- vertexCollision(path[0], path[1], map);
- vertexCollision(path[0], path[1], body);
- if (best.dist2 != Infinity) { //if hitting something
- path[path.length - 1] = {
- x: best.x,
- y: best.y
- };
- if (best.who.alive) {
- const dmg = 0.8 * b.dmgScale; //********** SCALE DAMAGE HERE *********************
- best.who.damage(dmg);
- best.who.locatePlayer();
-
- //push mobs away
- const force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, path[1])), -0.01 * Math.min(5, best.who.mass))
- Matter.Body.applyForce(best.who, path[1], force)
- Matter.Body.setVelocity(best.who, { //friction
- x: best.who.velocity.x * 0.7,
- y: best.who.velocity.y * 0.7
- });
- //draw mob damage circle
- game.drawList.push({
- x: path[1].x,
- y: path[1].y,
- radius: Math.sqrt(dmg) * 50,
- color: "rgba(255,0,255,0.2)",
- time: game.drawTime * 4
- });
- } else if (!best.who.isStatic) {
- //push blocks away
- const force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, path[1])), -0.007 * Math.sqrt(Math.sqrt(best.who.mass)))
- Matter.Body.applyForce(best.who, path[1], force)
- }
- }
-
- //draw blowtorch laser beam
- ctx.strokeStyle = "rgba(255,0,255,0.1)"
- ctx.lineWidth = 14
- ctx.beginPath();
- ctx.moveTo(path[0].x, path[0].y);
- ctx.lineTo(path[1].x, path[1].y);
- ctx.stroke();
- ctx.strokeStyle = "#f0f";
- ctx.lineWidth = 2
- ctx.stroke();
-
- //draw electricity
- let x = this.position.x + 20 * unit.x;
- let y = this.position.y + 20 * unit.y;
- ctx.beginPath();
- ctx.moveTo(x, y);
- const step = Vector.magnitude(Vector.sub(path[0], path[1])) / 5
- for (let i = 0; i < 4; i++) {
- x += step * (unit.x + 1.5 * (Math.random() - 0.5))
- y += step * (unit.y + 1.5 * (Math.random() - 0.5))
- ctx.lineTo(x, y);
- }
- ctx.lineWidth = 2 * Math.random();
- ctx.stroke();
- }
- }
- }
- })
- World.add(engine.world, bullet[me]); //add bullet to world
- },
- boomBot(position = mech.pos) {
- const me = bullet.length;
- const dir = mech.angle;
- const RADIUS = (7 + 2 * Math.random())
- bullet[me] = Bodies.polygon(position.x, position.y, 4, RADIUS, {
- isBot: true,
- angle: dir,
- friction: 0,
- frictionStatic: 0,
- frictionAir: 0.05,
- restitution: 1,
- dmg: 0,
- minDmgSpeed: 0,
- lookFrequency: 35 + Math.floor(7 * Math.random()),
- acceleration: 0.005 * (1 + 0.5 * Math.random()),
- range: 500 * (1 + 0.1 * Math.random()),
- endCycle: Infinity,
- classType: "bullet",
- collisionFilter: {
- category: cat.bullet,
- mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
- },
- lockedOn: null,
- explode: 0,
- onDmg() {
- if (this.lockedOn) {
- const explosionRadius = Math.min(170, Vector.magnitude(Vector.sub(this.position, mech.pos)) - 30)
- if (explosionRadius > 60) {
- this.explode = explosionRadius
- //
- //push away from player, because normal explosion knock doesn't do much
- // const sub = Vector.sub(this.lockedOn.position, mech.pos)
- // mag = Math.min(35, 20 / Math.sqrt(this.lockedOn.mass))
- // Matter.Body.setVelocity(this.lockedOn, Vector.mult(Vector.normalise(sub), mag))
- }
- this.lockedOn = null //lose target so bot returns to player
- }
- },
- onEnd() {},
- do() {
- if (this.explode) {
- b.explosion(this.position, this.explode); //makes bullet do explosive damage at end
- this.explode = 0;
- }
- const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, mech.pos))
- if (distanceToPlayer > 100) { //if far away move towards player
- this.force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, this.position)), this.mass * this.acceleration)
- } else if (distanceToPlayer < 250) { //close to player
- Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
- //find targets
- if (!(game.cycle % this.lookFrequency) && !mech.isStealth) {
- this.lockedOn = null;
- let closeDist = this.range;
- for (let i = 0, len = mob.length; i < len; ++i) {
- const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
- if (DIST < closeDist && mob[i].dropPowerUp &&
- Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
- Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
- closeDist = DIST;
- this.lockedOn = mob[i]
- }
- }
- }
- }
- //punch target
- if (this.lockedOn && this.lockedOn.alive) {
- const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position));
- if (DIST - this.lockedOn.radius < this.range &&
- Matter.Query.ray(map, this.position, this.lockedOn.position).length === 0) {
- //move towards the target
- this.force = Vector.add(this.force, Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), 0.012 * this.mass))
- }
- }
- }
- })
- World.add(engine.world, bullet[me]); //add bullet to world
- },
- laserBot(position = mech.pos) {
+ laserBot(position = mech.pos, isUpgraded = mod.isBotUpgrade) {
const me = bullet.length;
const dir = mech.angle;
const RADIUS = (14 + 6 * Math.random())
bullet[me] = Bodies.polygon(position.x, position.y, 3, RADIUS, {
+ isUpgraded: isUpgraded,
isBot: true,
angle: dir,
friction: 0,
@@ -1430,7 +1171,7 @@ const b = {
}
//hit target with laser
if (this.lockedOn && this.lockedOn.alive && mech.energy > 0.15) {
- mech.energy -= 0.0014 * mod.isLaserDiode
+ mech.energy -= 0.0014 * mod.isLaserDiode - 0.0007 * this.isUpgraded
//make sure you can still see vertex
const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position));
if (DIST - this.lockedOn.radius < this.range + 150 &&
@@ -1438,7 +1179,6 @@ const b = {
Matter.Query.ray(body, this.vertices[0], this.lockedOn.position).length === 0) {
//move towards the target
this.force = Vector.add(this.force, Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), 0.0013))
-
//find the closest vertex
let bestVertexDistance = Infinity
let bestVertex = null
@@ -1472,6 +1212,272 @@ const b = {
})
World.add(engine.world, bullet[me]); //add bullet to world
},
+ boomBot(position = mech.pos, isUpgraded = mod.isBotUpgrade) {
+ const me = bullet.length;
+ const dir = mech.angle;
+ const RADIUS = (7 + 2 * Math.random())
+ bullet[me] = Bodies.polygon(position.x, position.y, 4, RADIUS, {
+ isUpgraded: isUpgraded,
+ isBot: true,
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.05,
+ restitution: 1,
+ dmg: 0,
+ minDmgSpeed: 0,
+ lookFrequency: 35 + Math.floor(7 * Math.random()),
+ acceleration: 0.005 * (1 + 0.5 * Math.random()),
+ range: 500 * (1 + 0.1 * Math.random()),
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ lockedOn: null,
+ explode: 0,
+ onDmg() {
+ if (this.lockedOn) {
+ const explosionRadius = Math.min(170 + 70 * this.isUpgraded, Vector.magnitude(Vector.sub(this.position, mech.pos)) - 30)
+ if (explosionRadius > 60) {
+ this.explode = explosionRadius
+ //
+ //push away from player, because normal explosion knock doesn't do much
+ // const sub = Vector.sub(this.lockedOn.position, mech.pos)
+ // mag = Math.min(35, 20 / Math.sqrt(this.lockedOn.mass))
+ // Matter.Body.setVelocity(this.lockedOn, Vector.mult(Vector.normalise(sub), mag))
+ }
+ this.lockedOn = null //lose target so bot returns to player
+ }
+ },
+ onEnd() {},
+ do() {
+ if (this.explode) {
+ b.explosion(this.position, this.explode); //makes bullet do explosive damage at end
+ this.explode = 0;
+ }
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, mech.pos))
+ if (distanceToPlayer > 100) { //if far away move towards player
+ this.force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, this.position)), this.mass * this.acceleration)
+ } else if (distanceToPlayer < 250) { //close to player
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+ //find targets
+ if (!(game.cycle % this.lookFrequency) && !mech.isStealth) {
+ this.lockedOn = null;
+ let closeDist = this.range;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
+ if (DIST < closeDist && mob[i].dropPowerUp &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ }
+ //punch target
+ if (this.lockedOn && this.lockedOn.alive) {
+ const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position));
+ if (DIST - this.lockedOn.radius < this.range &&
+ Matter.Query.ray(map, this.position, this.lockedOn.position).length === 0) {
+ //move towards the target
+ this.force = Vector.add(this.force, Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), 0.012 * this.mass))
+ }
+ }
+ }
+ })
+ World.add(engine.world, bullet[me]); //add bullet to world
+ },
+ plasmaBot(position = mech.pos, isUpgraded = mod.isBotUpgrade) {
+ const me = bullet.length;
+ const dir = mech.angle;
+ const RADIUS = 21
+ bullet[me] = Bodies.polygon(position.x, position.y, 5, RADIUS, {
+ isUpgraded: isUpgraded,
+ isBot: true,
+ angle: dir,
+ friction: 0,
+ frictionStatic: 0,
+ frictionAir: 0.05,
+ restitution: 1,
+ dmg: 0, // 0.14 //damage done in addition to the damage from momentum
+ minDmgSpeed: 2,
+ lookFrequency: 25,
+ cd: 0,
+ acceleration: 0.009,
+ endCycle: Infinity,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ lockedOn: null,
+ onDmg() {
+ this.lockedOn = null
+ },
+ onEnd() {},
+ do() {
+ const distanceToPlayer = Vector.magnitude(Vector.sub(this.position, mech.pos))
+ if (distanceToPlayer > 150) { //if far away move towards player
+ this.force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, this.position)), this.mass * this.acceleration)
+ }
+ Matter.Body.setVelocity(this, Vector.add(Vector.mult(this.velocity, 0.90), Vector.mult(player.velocity, 0.17))); //add player's velocity
+ //find closest
+ if (!(game.cycle % this.lookFrequency)) {
+ this.lockedOn = null;
+ let closeDist = mod.isPlasmaRange * 1000;
+ for (let i = 0, len = mob.length; i < len; ++i) {
+ const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
+ if (DIST < closeDist &&
+ Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
+ Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
+ closeDist = DIST;
+ this.lockedOn = mob[i]
+ }
+ }
+ }
+ //fire plasma at target
+ if (this.lockedOn && this.lockedOn.alive && mech.fieldCDcycle < mech.cycle) {
+ const sub = Vector.sub(this.lockedOn.position, this.position)
+ const DIST = Vector.magnitude(sub);
+ const unit = Vector.normalise(sub)
+ const DRAIN = 0.0016 - 0.0008 * this.isUpgraded
+ if (DIST < mod.isPlasmaRange * 550 && mech.energy > DRAIN) {
+ mech.energy -= DRAIN;
+ if (mech.energy < 0) {
+ mech.fieldCDcycle = mech.cycle + 120;
+ mech.energy = 0;
+ }
+ //calculate laser collision
+ let best;
+ let range = mod.isPlasmaRange * (140 + 300 * Math.sqrt(Math.random()))
+ const path = [{
+ x: this.position.x,
+ y: this.position.y
+ },
+ {
+ x: this.position.x + range * unit.x,
+ y: this.position.y + range * unit.y
+ }
+ ];
+ const vertexCollision = function (v1, v1End, domain) {
+ for (let i = 0; i < domain.length; ++i) {
+ let vertices = domain[i].vertices;
+ const len = vertices.length - 1;
+ for (let j = 0; j < len; j++) {
+ results = game.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]);
+ if (results.onLine1 && results.onLine2) {
+ const dx = v1.x - results.x;
+ const dy = v1.y - results.y;
+ const dist2 = dx * dx + dy * dy;
+ if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) {
+ best = {
+ x: results.x,
+ y: results.y,
+ dist2: dist2,
+ who: domain[i],
+ v1: vertices[j],
+ v2: vertices[j + 1]
+ };
+ }
+ }
+ }
+ results = game.checkLineIntersection(v1, v1End, vertices[0], vertices[len]);
+ if (results.onLine1 && results.onLine2) {
+ const dx = v1.x - results.x;
+ const dy = v1.y - results.y;
+ const dist2 = dx * dx + dy * dy;
+ if (dist2 < best.dist2 && (!domain[i].mob || domain[i].alive)) {
+ best = {
+ x: results.x,
+ y: results.y,
+ dist2: dist2,
+ who: domain[i],
+ v1: vertices[0],
+ v2: vertices[len]
+ };
+ }
+ }
+ }
+ };
+ //check for collisions
+ best = {
+ x: null,
+ y: null,
+ dist2: Infinity,
+ who: null,
+ v1: null,
+ v2: null
+ };
+ vertexCollision(path[0], path[1], mob);
+ vertexCollision(path[0], path[1], map);
+ vertexCollision(path[0], path[1], body);
+ if (best.dist2 != Infinity) { //if hitting something
+ path[path.length - 1] = {
+ x: best.x,
+ y: best.y
+ };
+ if (best.who.alive) {
+ const dmg = 0.8 * b.dmgScale; //********** SCALE DAMAGE HERE *********************
+ best.who.damage(dmg);
+ best.who.locatePlayer();
+ //push mobs away
+ const force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, path[1])), -0.01 * Math.min(5, best.who.mass))
+ Matter.Body.applyForce(best.who, path[1], force)
+ Matter.Body.setVelocity(best.who, { //friction
+ x: best.who.velocity.x * 0.7,
+ y: best.who.velocity.y * 0.7
+ });
+ //draw mob damage circle
+ game.drawList.push({
+ x: path[1].x,
+ y: path[1].y,
+ radius: Math.sqrt(dmg) * 50,
+ color: "rgba(255,0,255,0.2)",
+ time: game.drawTime * 4
+ });
+ } else if (!best.who.isStatic) {
+ //push blocks away
+ const force = Vector.mult(Vector.normalise(Vector.sub(mech.pos, path[1])), -0.007 * Math.sqrt(Math.sqrt(best.who.mass)))
+ Matter.Body.applyForce(best.who, path[1], force)
+ }
+ }
+ //draw blowtorch laser beam
+ ctx.strokeStyle = "rgba(255,0,255,0.1)"
+ ctx.lineWidth = 14
+ ctx.beginPath();
+ ctx.moveTo(path[0].x, path[0].y);
+ ctx.lineTo(path[1].x, path[1].y);
+ ctx.stroke();
+ ctx.strokeStyle = "#f0f";
+ ctx.lineWidth = 2
+ ctx.stroke();
+ //draw electricity
+ let x = this.position.x + 20 * unit.x;
+ let y = this.position.y + 20 * unit.y;
+ ctx.beginPath();
+ ctx.moveTo(x, y);
+ const step = Vector.magnitude(Vector.sub(path[0], path[1])) / 5
+ for (let i = 0; i < 4; i++) {
+ x += step * (unit.x + 1.5 * (Math.random() - 0.5))
+ y += step * (unit.y + 1.5 * (Math.random() - 0.5))
+ ctx.lineTo(x, y);
+ }
+ ctx.lineWidth = 2 * Math.random();
+ ctx.stroke();
+ }
+ }
+ }
+ })
+ World.add(engine.world, bullet[me]); //add bullet to world
+ },
+ // **************************************************************************************************
+ // **************************************************************************************************
+ // ******************************** Guns *********************************************
+ // **************************************************************************************************
+ // **************************************************************************************************
giveGuns(gun = "random", ammoPacks = 6) {
if (gun === "random") {
//find what guns player doesn't have
@@ -1979,8 +1985,8 @@ const b = {
name: "flak",
description: "fire a cluster of short range projectiles
explodes on contact or after half a second",
ammo: 0,
- ammoPack: 7,
- defaultAmmoPack: 7, //use to revert ammoPack after mod changes drop rate
+ ammoPack: 6,
+ defaultAmmoPack: 6, //use to revert ammoPack after mod changes drop rate
have: false,
isEasyToAim: false,
fire() {
@@ -2098,12 +2104,11 @@ const b = {
for (let i = 0, len = mob.length; i < len; ++i) {
if (mob[i].shield) {
const dist = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
- if (dist < this.explodeRad) mob[i].damage(Infinity);
- } else if (mob[i].alive && !mob[i].isShielded) {
- const dist = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
- if (dist < this.explodeRad) mob[i].damage(0.8 * b.dmgScale);
+ if (dist < this.explodeRad) mob[i].health *= 0.8
}
}
+ const dist = Vector.magnitude(Vector.sub(this.position, player.position))
+ if (dist < this.explodeRad) mech.energy = 0 //remove player energy
}
}
bullet[me].onDmg = function () {
diff --git a/js/game.js b/js/game.js
index 8f1da98..ba1973f 100644
--- a/js/game.js
+++ b/js/game.js
@@ -200,7 +200,7 @@ const game = {
if (b.inventory[0] === b.activeGun) {
let lessDamage = 1
for (let i = 0, len = b.inventory.length; i < len; i++) {
- lessDamage *= 0.84 // 1 - 0.16
+ lessDamage *= 0.85 // 1 - 0.15
}
document.getElementById("mod-entanglement").innerHTML = " " + ((1 - lessDamage) * 100).toFixed(0) + "%"
} else {
@@ -908,9 +908,9 @@ const game = {
ctx.stroke();
},
wireFrame() {
- ctx.textAlign = "center";
- ctx.textBaseline = "middle";
- ctx.fillStyle = "#999";
+ // ctx.textAlign = "center";
+ // ctx.textBaseline = "middle";
+ // ctx.fillStyle = "#999";
const bodies = Composite.allBodies(engine.world);
ctx.beginPath();
for (let i = 0; i < bodies.length; ++i) {
@@ -928,17 +928,17 @@ const game = {
},
testing() {
//query zones
- ctx.beginPath();
- for (let i = 0, len = level.queryList.length; i < len; ++i) {
- ctx.rect(
- level.queryList[i].bounds.max.x,
- level.queryList[i].bounds.max.y,
- level.queryList[i].bounds.min.x - level.queryList[i].bounds.max.x,
- level.queryList[i].bounds.min.y - level.queryList[i].bounds.max.y
- );
- }
- ctx.fillStyle = "rgba(0, 0, 255, 0.2)";
- ctx.fill();
+ // ctx.beginPath();
+ // for (let i = 0, len = level.queryList.length; i < len; ++i) {
+ // ctx.rect(
+ // level.queryList[i].bounds.max.x,
+ // level.queryList[i].bounds.max.y,
+ // level.queryList[i].bounds.min.x - level.queryList[i].bounds.max.x,
+ // level.queryList[i].bounds.min.y - level.queryList[i].bounds.max.y
+ // );
+ // }
+ // ctx.fillStyle = "rgba(0, 0, 255, 0.2)";
+ // ctx.fill();
//jump
ctx.beginPath();
let bodyDraw = jumpSensor.vertices;
@@ -947,10 +947,10 @@ const game = {
ctx.lineTo(bodyDraw[j].x, bodyDraw[j].y);
}
ctx.lineTo(bodyDraw[0].x, bodyDraw[0].y);
- ctx.fillStyle = "rgba(255, 0, 0, 0.3)";
+ ctx.fillStyle = "rgba(255, 0, 0, 0.5)";
ctx.fill();
- ctx.strokeStyle = "#000";
- ctx.stroke();
+ // ctx.strokeStyle = "#000";
+ // ctx.stroke();
//main body
ctx.beginPath();
bodyDraw = playerBody.vertices;
@@ -959,9 +959,9 @@ const game = {
ctx.lineTo(bodyDraw[j].x, bodyDraw[j].y);
}
ctx.lineTo(bodyDraw[0].x, bodyDraw[0].y);
- ctx.fillStyle = "rgba(0, 255, 255, 0.3)";
+ ctx.fillStyle = "rgba(0, 255, 255, 0.25)";
ctx.fill();
- ctx.stroke();
+ // ctx.stroke();
//head
ctx.beginPath();
bodyDraw = playerHead.vertices;
@@ -970,9 +970,9 @@ const game = {
ctx.lineTo(bodyDraw[j].x, bodyDraw[j].y);
}
ctx.lineTo(bodyDraw[0].x, bodyDraw[0].y);
- ctx.fillStyle = "rgba(255, 255, 0, 0.3)";
+ ctx.fillStyle = "rgba(255, 255, 0, 0.4)";
ctx.fill();
- ctx.stroke();
+ // ctx.stroke();
//head sensor
ctx.beginPath();
bodyDraw = headSensor.vertices;
@@ -981,9 +981,9 @@ const game = {
ctx.lineTo(bodyDraw[j].x, bodyDraw[j].y);
}
ctx.lineTo(bodyDraw[0].x, bodyDraw[0].y);
- ctx.fillStyle = "rgba(0, 0, 255, 0.3)";
+ ctx.fillStyle = "rgba(0, 0, 255, 0.25)";
ctx.fill();
- ctx.stroke();
+ // ctx.stroke();
}
},
checkLineIntersection(v1, v1End, v2, v2End) {
diff --git a/js/index.js b/js/index.js
index c15f8b5..ac29206 100644
--- a/js/index.js
+++ b/js/index.js
@@ -93,20 +93,20 @@ const build = {
PAUSED press P to resume