plasma bot, boom bot
mod - boomBot: explodes on mobs in close range mod - plasma-bot: bot that fires your plasma torch
This commit is contained in:
294
js/bullet.js
294
js/bullet.js
@@ -156,7 +156,7 @@ const b = {
|
||||
}
|
||||
}
|
||||
},
|
||||
explosion(where, radius, isBurn = false) {
|
||||
explosion(where, radius) {
|
||||
radius *= mod.explosionRadius
|
||||
// typically explode is used for some bullets with .onEnd
|
||||
//add dmg to draw queue
|
||||
@@ -969,7 +969,7 @@ const b = {
|
||||
nailBot(position = mech.pos) {
|
||||
const me = bullet.length;
|
||||
const dir = mech.angle;
|
||||
const RADIUS = (10 + 5 * Math.random())
|
||||
const RADIUS = (12 + 4 * Math.random())
|
||||
bullet[me] = Bodies.polygon(position.x, position.y, 4, RADIUS, {
|
||||
angle: dir,
|
||||
friction: 0,
|
||||
@@ -1076,6 +1076,273 @@ 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 = 18
|
||||
bullet[me] = Bodies.polygon(position.x, position.y, 5, RADIUS, {
|
||||
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: 15,
|
||||
cd: 0,
|
||||
acceleration: 0.0085,
|
||||
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 > 100) { //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 && 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]
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//fire plasma at target
|
||||
|
||||
const DRAIN = 0.0014
|
||||
if (this.lockedOn && this.lockedOn.alive && mech.energy > DRAIN && mech.fieldCDcycle < mech.cycle) {
|
||||
mech.energy -= DRAIN;
|
||||
if (mech.energy < 0) {
|
||||
mech.fieldCDcycle = mech.cycle + 120;
|
||||
mech.energy = 0;
|
||||
}
|
||||
|
||||
const sub = Vector.sub(this.lockedOn.position, this.position)
|
||||
const DIST = Vector.magnitude(sub);
|
||||
const unit = Vector.normalise(sub)
|
||||
if (DIST < mod.isPlasmaRange * 600) {
|
||||
//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
|
||||
const Dx = Math.cos(mech.angle);
|
||||
const Dy = Math.sin(mech.angle);
|
||||
let x = this.position.x + 20 * Dx;
|
||||
let y = this.position.y + 20 * Dy;
|
||||
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 * (Dx + 1.5 * (Math.random() - 0.5))
|
||||
y += step * (Dy + 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, {
|
||||
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) {
|
||||
const me = bullet.length;
|
||||
const dir = mech.angle;
|
||||
@@ -2212,7 +2479,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "drones",
|
||||
description: "deploy drones that <strong>crash</strong> into mobs<br>collisions reduce their <strong>lifespan</strong> by 1 second",
|
||||
description: "deploy drones that <strong>crash</strong> into mobs<br>crashes reduce their <strong>lifespan</strong> by 1 second",
|
||||
ammo: 0,
|
||||
ammoPack: 14,
|
||||
have: false,
|
||||
@@ -2660,7 +2927,7 @@ const b = {
|
||||
isEasyToAim: false,
|
||||
fire() {
|
||||
//calculate laser collision
|
||||
let best;
|
||||
let best, energy, explosionRange;
|
||||
let range = 3000
|
||||
const path = [{
|
||||
x: mech.pos.x + 20 * Math.cos(mech.angle),
|
||||
@@ -2722,15 +2989,22 @@ const b = {
|
||||
v2: null
|
||||
};
|
||||
if (mod.isPulseAim) { //find mobs in line of sight
|
||||
let dist = 2200
|
||||
energy = 0.25 * Math.min(mech.energy, 1.75)
|
||||
explosionRange = 1000 * energy
|
||||
for (let i = 0, len = mob.length; i < len; i++) {
|
||||
if (Vector.magnitude(Vector.sub(path[0], mob[i].position)) < 2200 &&
|
||||
const newDist = Vector.magnitude(Vector.sub(path[0], mob[i].position))
|
||||
if (explosionRange < newDist &&
|
||||
newDist < dist &&
|
||||
Matter.Query.ray(map, path[0], mob[i].position).length === 0 &&
|
||||
Matter.Query.ray(body, path[0], mob[i].position).length === 0) {
|
||||
dist = newDist
|
||||
best.who = mob[i]
|
||||
path[path.length - 1] = mob[i].position
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
if (!best.who) {
|
||||
vertexCollision(path[0], path[1], mob);
|
||||
@@ -2743,16 +3017,16 @@ const b = {
|
||||
};
|
||||
}
|
||||
}
|
||||
let energy
|
||||
|
||||
if (mod.isPulseAim) {
|
||||
energy = 0.25 * Math.min(mech.energy, 1.75)
|
||||
mech.energy -= energy * mod.isLaserDiode
|
||||
if (best.who) b.explosion(path[1], 1000 * energy, true)
|
||||
if (best.who) b.explosion(path[1], explosionRange, true)
|
||||
mech.fireCDcycle = mech.cycle + Math.floor(25 * b.fireCD); // cool down
|
||||
} else {
|
||||
energy = 0.3 * Math.min(mech.energy, 1.75)
|
||||
mech.energy -= energy * mod.isLaserDiode
|
||||
if (best.who) b.explosion(path[1], 1000 * energy, true)
|
||||
explosionRange = 1000 * energy
|
||||
if (best.who) b.explosion(path[1], explosionRange, true)
|
||||
mech.fireCDcycle = mech.cycle + Math.floor(50 * b.fireCD); // cool down
|
||||
}
|
||||
if (mod.isPulseStun) {
|
||||
|
||||
@@ -208,7 +208,7 @@ function collisionChecks(event) {
|
||||
if (mod.isCrit && !mob[k].seePlayer.recall && !mob[k].shield) dmg *= 5
|
||||
mob[k].foundPlayer();
|
||||
mob[k].damage(dmg);
|
||||
obj.onDmg(mob[k]); //some bullets do actions when they hits things, like despawn
|
||||
obj.onDmg(mob[k]); //some bullets do actions when they hits things, like despawn //forces don't seem to work here
|
||||
game.drawList.push({ //add dmg to draw queue
|
||||
x: pairs[i].activeContacts[0].vertex.x,
|
||||
y: pairs[i].activeContacts[0].vertex.y,
|
||||
|
||||
113
js/game.js
113
js/game.js
@@ -2,33 +2,6 @@
|
||||
//*********************************************************************
|
||||
const game = {
|
||||
loop() {}, //main game loop, gets se tto normal or testing loop
|
||||
testingLoop() {
|
||||
game.gravity();
|
||||
Engine.update(engine, game.delta);
|
||||
game.wipe();
|
||||
game.textLog();
|
||||
if (mech.onGround) {
|
||||
mech.groundControl()
|
||||
} else {
|
||||
mech.airControl()
|
||||
}
|
||||
level.checkZones();
|
||||
level.checkQuery();
|
||||
mech.move();
|
||||
mech.look();
|
||||
game.checks();
|
||||
ctx.save();
|
||||
game.camera();
|
||||
mech.draw();
|
||||
game.draw.wireFrame();
|
||||
game.draw.cons();
|
||||
game.draw.testing();
|
||||
game.drawCircle();
|
||||
game.constructCycle()
|
||||
ctx.restore();
|
||||
game.testingOutput();
|
||||
game.drawCursor();
|
||||
},
|
||||
normalLoop() {
|
||||
game.gravity();
|
||||
Engine.update(engine, game.delta);
|
||||
@@ -39,7 +12,8 @@ const game = {
|
||||
} else {
|
||||
mech.airControl()
|
||||
}
|
||||
level.checkZones();
|
||||
// level.checkZones();
|
||||
level.custom();
|
||||
level.checkQuery();
|
||||
mech.move();
|
||||
mech.look();
|
||||
@@ -65,10 +39,38 @@ const game = {
|
||||
b.bulletDraw();
|
||||
b.bulletDo();
|
||||
game.drawCircle();
|
||||
game.clip();
|
||||
// game.clip();
|
||||
ctx.restore();
|
||||
game.drawCursor();
|
||||
},
|
||||
testingLoop() {
|
||||
game.gravity();
|
||||
Engine.update(engine, game.delta);
|
||||
game.wipe();
|
||||
game.textLog();
|
||||
if (mech.onGround) {
|
||||
mech.groundControl()
|
||||
} else {
|
||||
mech.airControl()
|
||||
}
|
||||
// level.checkZones();
|
||||
level.custom();
|
||||
level.checkQuery();
|
||||
mech.move();
|
||||
mech.look();
|
||||
game.checks();
|
||||
ctx.save();
|
||||
game.camera();
|
||||
mech.draw();
|
||||
game.draw.wireFrame();
|
||||
game.draw.cons();
|
||||
game.draw.testing();
|
||||
game.drawCircle();
|
||||
game.constructCycle()
|
||||
ctx.restore();
|
||||
game.testingOutput();
|
||||
game.drawCursor();
|
||||
},
|
||||
isTimeSkipping: false,
|
||||
timeSkip(cycles = 60) {
|
||||
game.isTimeSkipping = true;
|
||||
@@ -146,9 +148,9 @@ const game = {
|
||||
// };
|
||||
// requestAnimationFrame(normalFPS);
|
||||
// },
|
||||
clip() {
|
||||
// clip() {
|
||||
|
||||
},
|
||||
// },
|
||||
drawCursor() {
|
||||
const size = 10;
|
||||
ctx.beginPath();
|
||||
@@ -397,7 +399,7 @@ const game = {
|
||||
});
|
||||
// game.noCameraScroll()
|
||||
} else if (keys[85]) { // next level with U
|
||||
level.zoneActions.nextLevel();
|
||||
level.nextLevel();
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -659,11 +661,9 @@ const game = {
|
||||
|
||||
powerUps.totalPowerUps = powerUp.length
|
||||
|
||||
//if player is holding something this remembers it before it gets deleted
|
||||
let holdTarget;
|
||||
if (mech.holdingTarget) {
|
||||
holdTarget = mech.holdingTarget;
|
||||
}
|
||||
let holdTarget; //if player is holding something this remembers it before it gets deleted
|
||||
if (mech.holdingTarget) holdTarget = mech.holdingTarget;
|
||||
|
||||
mech.fireCDcycle = 0
|
||||
mech.drop();
|
||||
level.fill = [];
|
||||
@@ -697,7 +697,11 @@ const game = {
|
||||
frictionAir: holdTarget.frictionAir,
|
||||
frictionStatic: holdTarget.frictionStatic
|
||||
});
|
||||
Matter.Body.setPosition(body[len], mech.pos);
|
||||
mech.isHolding = true
|
||||
mech.holdingTarget = body[len];
|
||||
mech.holdingTarget.collisionFilter.category = 0;
|
||||
mech.holdingTarget.collisionFilter.mask = 0;
|
||||
}
|
||||
},
|
||||
getCoords: {
|
||||
@@ -811,20 +815,20 @@ const game = {
|
||||
let line = 500;
|
||||
const x = canvas.width - 5;
|
||||
ctx.fillText("T: exit testing mode", x, line);
|
||||
line += 20;
|
||||
ctx.fillText("Y: give all mods", x, line);
|
||||
line += 20;
|
||||
ctx.fillText("R: teleport to mouse", x, line);
|
||||
line += 20;
|
||||
ctx.fillText("F: cycle field", x, line);
|
||||
line += 20;
|
||||
ctx.fillText("G: give all guns", x, line);
|
||||
line += 20;
|
||||
ctx.fillText("H: heal", x, line);
|
||||
line += 20;
|
||||
ctx.fillText("U: next level", x, line);
|
||||
line += 20;
|
||||
ctx.fillText("1-7: spawn things", x, line);
|
||||
// line += 20;
|
||||
// ctx.fillText("Y: give all mods", x, line);
|
||||
// line += 20;
|
||||
// ctx.fillText("R: teleport to mouse", x, line);
|
||||
// line += 20;
|
||||
// ctx.fillText("F: cycle field", x, line);
|
||||
// line += 20;
|
||||
// ctx.fillText("G: give all guns", x, line);
|
||||
// line += 20;
|
||||
// ctx.fillText("H: heal", x, line);
|
||||
// line += 20;
|
||||
// ctx.fillText("U: next level", x, line);
|
||||
// line += 20;
|
||||
// ctx.fillText("1-7: spawn things", x, line);
|
||||
}
|
||||
ctx.textAlign = "center";
|
||||
ctx.fillText(`(${game.mouseInGame.x.toFixed(1)}, ${game.mouseInGame.y.toFixed(1)})`, game.mouse.x, game.mouse.y - 20);
|
||||
@@ -924,13 +928,6 @@ const game = {
|
||||
ctx.stroke();
|
||||
},
|
||||
testing() {
|
||||
//zones
|
||||
ctx.beginPath();
|
||||
for (let i = 0, len = level.zones.length; i < len; ++i) {
|
||||
ctx.rect(level.zones[i].x1, level.zones[i].y1 + 70, level.zones[i].x2 - level.zones[i].x1, level.zones[i].y2 - level.zones[i].y1);
|
||||
}
|
||||
ctx.fillStyle = "rgba(0, 255, 0, 0.3)";
|
||||
ctx.fill();
|
||||
//query zones
|
||||
ctx.beginPath();
|
||||
for (let i = 0, len = level.queryList.length; i < len; ++i) {
|
||||
|
||||
744
js/level.js
744
js/level.js
File diff suppressed because it is too large
Load Diff
@@ -1000,12 +1000,14 @@ const mobs = {
|
||||
}
|
||||
}
|
||||
if (Math.random() < mod.isBotSpawner) {
|
||||
if (Math.random() < 0.33) {
|
||||
if (Math.random() < 0.25) {
|
||||
b.nailBot(this.position)
|
||||
} else if (Math.random() < 0.5) {
|
||||
} else if (Math.random() < 0.33) {
|
||||
b.laserBot(this.position)
|
||||
} else {
|
||||
} else if (Math.random() < 0.5) {
|
||||
b.foamBot(this.position)
|
||||
} else {
|
||||
b.boomBot(this.position)
|
||||
}
|
||||
// if (mech.energy > 0.33) mech.energy -= 0.33
|
||||
}
|
||||
|
||||
92
js/mods.js
92
js/mods.js
@@ -276,23 +276,6 @@ const mod = {
|
||||
mod.throwChargeRate = 1
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "laser-bot",
|
||||
description: "a bot <strong>defends</strong> the space around you<br>uses a <strong>short range</strong> laser that drains <strong class='color-f'>energy</strong>",
|
||||
maxCount: 9,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return true
|
||||
},
|
||||
requires: "",
|
||||
effect() {
|
||||
mod.laserBotCount++;
|
||||
b.laserBot();
|
||||
},
|
||||
remove() {
|
||||
mod.laserBotCount = 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "nail-bot",
|
||||
description: "a bot fires <strong>nails</strong> at targets in line of sight",
|
||||
@@ -327,13 +310,64 @@ const mod = {
|
||||
mod.foamBotCount = 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "boom-bot",
|
||||
description: "a bot <strong>defends</strong> the space around you<br>ignites an <strong class='color-e'>explosion</strong> after hitting a mob",
|
||||
maxCount: 9,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return true
|
||||
},
|
||||
requires: "",
|
||||
effect() {
|
||||
mod.boomBotCount++;
|
||||
b.boomBot();
|
||||
},
|
||||
remove() {
|
||||
mod.boomBotCount = 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "laser-bot",
|
||||
description: "a bot <strong>defends</strong> the space around you<br>uses a <strong>short range</strong> laser that drains <strong class='color-f'>energy</strong>",
|
||||
maxCount: 9,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return true
|
||||
},
|
||||
requires: "",
|
||||
effect() {
|
||||
mod.laserBotCount++;
|
||||
b.laserBot();
|
||||
},
|
||||
remove() {
|
||||
mod.laserBotCount = 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "plasma-bot",
|
||||
description: "a bot uses <strong class='color-f'>energy</strong> to emit short range <strong>plasma</strong><br>plasma <strong class='color-d'>damages</strong> and <strong>pushes</strong> mobs",
|
||||
maxCount: 1,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return mech.fieldUpgrades[mech.fieldMode].name === "plasma torch"
|
||||
},
|
||||
requires: "plasma torch",
|
||||
effect() {
|
||||
mod.plasmaBotCount++;
|
||||
b.plasmaBot();
|
||||
},
|
||||
remove() {
|
||||
mod.plasmaBotCount = 0;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "scrap bots",
|
||||
description: "<strong>12%</strong> chance to build a <strong>bot</strong> after killing a mob<br>the bot only functions until the end of the level",
|
||||
maxCount: 6,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return mod.foamBotCount + mod.nailBotCount + mod.laserBotCount > 0
|
||||
return mod.foamBotCount + mod.nailBotCount + mod.laserBotCount + mod.boomBotCount + mod.plasmaBotCount > 0
|
||||
},
|
||||
requires: "a bot",
|
||||
effect() {
|
||||
@@ -345,19 +379,19 @@ const mod = {
|
||||
},
|
||||
{
|
||||
name: "bot replication",
|
||||
description: "<strong>duplicate</strong> your permanent <strong>bots</strong><br>remove <strong>80%</strong> of your <strong>ammo</strong>",
|
||||
description: "<strong>duplicate</strong> your permanent <strong>bots</strong><br>remove <strong>90%</strong> of your <strong>ammo</strong>",
|
||||
maxCount: 1,
|
||||
count: 0,
|
||||
// isNonRefundable: true,
|
||||
allowed() {
|
||||
return mod.foamBotCount + mod.nailBotCount + mod.laserBotCount > 2
|
||||
return mod.foamBotCount + mod.nailBotCount + mod.laserBotCount + mod.boomBotCount + mod.plasmaBotCount > 1
|
||||
},
|
||||
requires: "3 or more bots",
|
||||
requires: "2 or more bots",
|
||||
effect() {
|
||||
//remove ammo
|
||||
for (let i = 0, len = b.guns.length; i < len; ++i) {
|
||||
if (b.guns[i].ammo != Infinity) {
|
||||
b.guns[i].ammo = Math.floor(b.guns[i].ammo * 0.2);
|
||||
b.guns[i].ammo = Math.floor(b.guns[i].ammo * 0.1);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,6 +408,14 @@ const mod = {
|
||||
b.foamBot();
|
||||
}
|
||||
mod.foamBotCount *= 2
|
||||
for (let i = 0; i < mod.boomBotCount; i++) {
|
||||
b.boomBot();
|
||||
}
|
||||
mod.boomBotCount *= 2
|
||||
for (let i = 0; i < mod.plasmaBotCount; i++) {
|
||||
b.plasmaBot();
|
||||
}
|
||||
mod.plasmaBotCount *= 2
|
||||
},
|
||||
remove() {}
|
||||
},
|
||||
@@ -545,7 +587,7 @@ const mod = {
|
||||
},
|
||||
{
|
||||
name: "Pauli exclusion",
|
||||
description: `<strong>immune</strong> to <strong>harm</strong> for <strong>1</strong> seconds<br>activates after being <strong>harmed</strong> from a collision`,
|
||||
description: `<strong>immune</strong> to <strong>harm</strong> for <strong>1</strong> second<br>activates after being <strong>harmed</strong> from a collision`,
|
||||
maxCount: 9,
|
||||
count: 0,
|
||||
allowed() {
|
||||
@@ -1400,7 +1442,7 @@ const mod = {
|
||||
maxCount: 1,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.haveGunCheck("pulse") || mod.isMissileField;
|
||||
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.haveGunCheck("pulse") || mod.isMissileField || mod.isExplodeMob
|
||||
},
|
||||
requires: "an explosive gun",
|
||||
effect: () => {
|
||||
@@ -2163,6 +2205,8 @@ const mod = {
|
||||
laserBotCount: null,
|
||||
nailBotCount: null,
|
||||
foamBotCount: null,
|
||||
boomBotCount: null,
|
||||
plasmaBotCount: null,
|
||||
collisionImmuneCycles: null,
|
||||
blockDmg: null,
|
||||
isPiezo: null,
|
||||
|
||||
16
js/player.js
16
js/player.js
@@ -94,20 +94,6 @@ const mech = {
|
||||
x: 0,
|
||||
y: 0
|
||||
},
|
||||
setPosToSpawn(xPos, yPos) {
|
||||
this.spawnPos.x = this.pos.x = xPos;
|
||||
this.spawnPos.y = this.pos.y = yPos;
|
||||
this.transX = this.transSmoothX = canvas.width2 - this.pos.x;
|
||||
this.transY = this.transSmoothY = canvas.height2 - this.pos.y;
|
||||
this.Vx = this.spawnVel.x;
|
||||
this.Vy = this.spawnVel.y;
|
||||
player.force.x = 0;
|
||||
player.force.y = 0;
|
||||
Matter.Body.setPosition(player, this.spawnPos);
|
||||
Matter.Body.setVelocity(player, this.spawnVel);
|
||||
// mech.transX = -player.position.x
|
||||
// mech.transY = player.position.y
|
||||
},
|
||||
Sy: 0, //adds a smoothing effect to vertical only
|
||||
Vx: 0,
|
||||
Vy: 0,
|
||||
@@ -1507,7 +1493,7 @@ const mech = {
|
||||
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //not hold but field button is pressed
|
||||
mech.grabPowerUp();
|
||||
mech.lookForPickUp();
|
||||
const DRAIN = 0.0013
|
||||
const DRAIN = 0.0014
|
||||
if (mech.energy > DRAIN) {
|
||||
mech.energy -= DRAIN;
|
||||
if (mech.energy < 0) {
|
||||
|
||||
Reference in New Issue
Block a user