reworked text display, with colors
This commit is contained in:
388
js/bullets.js
388
js/bullets.js
@@ -29,7 +29,7 @@ const b = {
|
||||
},
|
||||
mods: [{
|
||||
name: "depleted uranium rounds",
|
||||
description: "your bullets are <strong>larger</strong> and do more physical damage",
|
||||
description: "your bullets are <strong>larger</strong> and do more physical <span class='color-d'>damage</span>",
|
||||
have: false,
|
||||
effect: () => {
|
||||
//good for guns that do mostly projectile damage:
|
||||
@@ -41,7 +41,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "auto-loading heuristics",
|
||||
description: "your <strong>rate of fire</strong> is 15% faster",
|
||||
description: "your rate of fire is 15% faster",
|
||||
have: false,
|
||||
effect: () => {
|
||||
//good for guns with extra ammo: needles, M80, rapid fire, flak, super balls
|
||||
@@ -51,7 +51,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "desublimated ammunition",
|
||||
description: "use 50% less <strong>ammo</strong> when <strong>crouching</strong>",
|
||||
description: "use 50% less <span class='color-b'>ammo</span> when <strong>crouching</strong>",
|
||||
have: false,
|
||||
effect: () => {
|
||||
//good with guns that have less ammo: one shot, grenades, missiles, super balls, spray
|
||||
@@ -60,7 +60,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "corrosion resistant topology",
|
||||
description: "your bullets <strong>last 40% longer</strong>",
|
||||
description: "your <span class='color-b'>bullets</span> last 40% longer",
|
||||
have: false,
|
||||
effect: () => {
|
||||
//good with: drones, super balls, spore, missiles, wave beam(range), rapid fire(range), flak(range)
|
||||
@@ -69,7 +69,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "anti-matter cores",
|
||||
description: "the radius of your <strong>explosions</strong> is doubled",
|
||||
description: "the radius of your <strong class='color-e'>explosions</strong> is doubled<br><span style='opacity:0.3;'>be careful</span>",
|
||||
have: false,
|
||||
effect: () => {
|
||||
//at 1.4 gives a flat 40% increase, and increased range, balanced by limited guns and self damage
|
||||
@@ -79,16 +79,16 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "energy siphon",
|
||||
description: "regenerate <strong>energy</strong> proportional to your damage done",
|
||||
description: "regenerate <span class='color-f'>energy</span> proportional to your <span class='color-d'>damage</span> done",
|
||||
have: false,
|
||||
effect: () => {
|
||||
//good with laser, and all fields
|
||||
b.modEnergySiphon = 0.25;
|
||||
b.modEnergySiphon = 0.2;
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "entropy transfer",
|
||||
description: "<strong>heal</strong> proportional to your damage done",
|
||||
description: "<span class='color-h'>heal</span> proportional to your <span class='color-d'>damage</span> done",
|
||||
have: false,
|
||||
effect: () => {
|
||||
//good with guns that overkill: one shot, grenade
|
||||
@@ -97,7 +97,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "quantum immortality",
|
||||
description: "after you die continue in an alternate reality with randomized abilities",
|
||||
description: "after you <strong style='color: #606;'>die</strong> continue in an <em>alternate reality</em><br>guns, ammo, and field are randomized",
|
||||
have: false,
|
||||
effect: () => {
|
||||
b.modIsImmortal = true;
|
||||
@@ -105,7 +105,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "zoospore vector",
|
||||
description: "when an enemy dies it has a 20% chance to release <strong>spores</strong>",
|
||||
description: "when an enemy <span style='color: #888;'>dies</span> it has a 20% chance to release <strong class='color-s'>spores</strong>",
|
||||
have: false,
|
||||
effect: () => {
|
||||
b.modSpores = 0.20; //good late game maybe?
|
||||
@@ -128,6 +128,7 @@ const b = {
|
||||
giveGuns(gun = "all", ammoPacks = 2) {
|
||||
if (gun === "all") {
|
||||
b.activeGun = 0;
|
||||
b.inventoryGun = 0;
|
||||
for (let i = 0; i < b.guns.length; i++) {
|
||||
b.guns[i].have = true;
|
||||
b.guns[i].ammo = b.guns[i].ammoPack * ammoPacks;
|
||||
@@ -277,7 +278,7 @@ const b = {
|
||||
x: bullet[me].position.x,
|
||||
y: bullet[me].position.y,
|
||||
radius: radius,
|
||||
color: "rgba(255,0,0,0.4)",
|
||||
color: "rgba(255,25,0,0.6)",
|
||||
time: game.drawTime
|
||||
});
|
||||
let dist, sub, knock;
|
||||
@@ -297,7 +298,7 @@ const b = {
|
||||
sub = Matter.Vector.sub(bullet[me].position, player.position);
|
||||
dist = Matter.Vector.magnitude(sub);
|
||||
if (dist < radius) {
|
||||
mech.damage(radius * 0.00035);
|
||||
mech.damage(radius * 0.0002);
|
||||
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), -Math.sqrt(dmg) * player.mass / 30);
|
||||
player.force.x += knock.x;
|
||||
player.force.y += knock.y;
|
||||
@@ -309,7 +310,6 @@ const b = {
|
||||
mech.drop();
|
||||
}
|
||||
|
||||
|
||||
//body knock backs
|
||||
for (let i = 0, len = body.length; i < len; ++i) {
|
||||
sub = Matter.Vector.sub(bullet[me].position, body[i].position);
|
||||
@@ -340,54 +340,6 @@ const b = {
|
||||
}
|
||||
}
|
||||
|
||||
// bullet knock backs (not working: no effect for drones, crash for superballs)
|
||||
// for (let i = 0, len = bullet.length; i < len; ++i) {
|
||||
// if (me !== i) {
|
||||
// sub = Matter.Vector.sub(bullet[me].position, bullet[i].position);
|
||||
// dist = Matter.Vector.magnitude(sub);
|
||||
// if (dist < radius) {
|
||||
// knock = Matter.Vector.mult(Matter.Vector.normalise(sub), (-Math.sqrt(dmg) * bullet[i].mass) / 10);
|
||||
// bullet[i].force.x += knock.x;
|
||||
// bullet[i].force.y += knock.y;
|
||||
// console.log(sub, dist, knock)
|
||||
// } else if (dist < alertRange) {
|
||||
// knock = Matter.Vector.mult(Matter.Vector.normalise(sub), (-Math.sqrt(dmg) * bullet[i].mass) / 20);
|
||||
// bullet[i].force.x += knock.x;
|
||||
// bullet[i].force.y += knock.y;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//destroy all bullets in range
|
||||
// for (let i = 0, len = bullet.length; i < len; ++i) {
|
||||
// if (me != i) {
|
||||
// sub = Matter.Vector.sub(bullet[me].position, bullet[i].position);
|
||||
// dist = Matter.Vector.magnitude(sub);
|
||||
// if (dist < radius) {
|
||||
// bullet[i].endCycle = mech.cycle;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//mob damage and knock back with no alert
|
||||
// for (let i = 0, len = mob.length; i < len; ++i) {
|
||||
// if (mob[i].alive) {
|
||||
// let vertices = mob[i].vertices;
|
||||
// for (let j = 0, len = vertices.length; j < len; j++) {
|
||||
// sub = Matter.Vector.sub(bullet[me].position, vertices[j]);
|
||||
// dist = Matter.Vector.magnitude(sub);
|
||||
// if (dist < radius) {
|
||||
// mob[i].damage(dmg);
|
||||
// mob[i].locatePlayer();
|
||||
// knock = Matter.Vector.mult(Matter.Vector.normalise(sub), -Math.sqrt(dmg) * mob[i].mass / 18);
|
||||
// mob[i].force.x += knock.x;
|
||||
// mob[i].force.y += knock.y;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
//mob damage and knock back with alert
|
||||
let damageScale = 1; // reduce dmg for each new target to limit total AOE damage
|
||||
for (let i = 0, len = mob.length; i < len; ++i) {
|
||||
@@ -475,7 +427,7 @@ const b = {
|
||||
},
|
||||
guns: [{
|
||||
name: "laser",
|
||||
description: "fire a beam of coherent light<br>reflects off walls at 75% intensity<br>uses energy instead of ammunition",
|
||||
description: "fire a <span style='color:#f00;'>beam</span> of coherent light<br>reflects off walls at 75% intensity<br>uses <span class='color-f'>energy</span> instead of ammunition",
|
||||
ammo: 0,
|
||||
// ammoPack: 350,
|
||||
ammoPack: Infinity,
|
||||
@@ -633,132 +585,9 @@ const b = {
|
||||
ctx.globalAlpha = 1;
|
||||
}
|
||||
}
|
||||
// }, {
|
||||
// name: "entropic beam",
|
||||
// description: "steal entropy to heal<br>reflects off walls at 75% intensity<br>uses energy instead of ammunition",
|
||||
// ammo: 0,
|
||||
// // ammoPack: 350,
|
||||
// ammoPack: Infinity,
|
||||
// have: false,
|
||||
// fire() {
|
||||
// // mech.fireCDcycle = mech.cycle + 1
|
||||
// //laser drains energy as well as bullets
|
||||
// const FIELD_DRAIN = 0.0001 //should be 0.001
|
||||
// if (mech.fieldMeter < FIELD_DRAIN) {
|
||||
// mech.fireCDcycle = mech.cycle + 100; // cool down if out of energy
|
||||
// } else {
|
||||
// mech.fieldMeter -= mech.fieldRegen + FIELD_DRAIN
|
||||
// let best;
|
||||
// const color = "#a0a";
|
||||
// const range = 600;
|
||||
// const path = [{
|
||||
// x: mech.pos.x + 20 * Math.cos(mech.angle),
|
||||
// y: mech.pos.y + 20 * Math.sin(mech.angle)
|
||||
// },
|
||||
// {
|
||||
// x: mech.pos.x + range * Math.cos(mech.angle),
|
||||
// y: mech.pos.y + range * Math.sin(mech.angle)
|
||||
// }
|
||||
// ];
|
||||
// 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]
|
||||
// };
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// };
|
||||
// const checkforCollisions = function () {
|
||||
// best = {
|
||||
// x: null,
|
||||
// y: null,
|
||||
// dist2: Infinity,
|
||||
// who: null,
|
||||
// v1: null,
|
||||
// v2: null
|
||||
// };
|
||||
// vertexCollision(path[path.length - 2], path[path.length - 1], mob);
|
||||
// vertexCollision(path[path.length - 2], path[path.length - 1], map);
|
||||
// vertexCollision(path[path.length - 2], path[path.length - 1], body);
|
||||
// };
|
||||
// const laserHitMob = function (dmg) {
|
||||
// if (best.who.alive) {
|
||||
// dmg *= b.dmgScale * 0.02;
|
||||
// mech.addHealth(0.002)
|
||||
// best.who.damage(dmg);
|
||||
// best.who.locatePlayer();
|
||||
// //draw mob damage circle
|
||||
// ctx.fillStyle = color;
|
||||
// ctx.beginPath();
|
||||
// ctx.arc(path[path.length - 1].x, path[path.length - 1].y, Math.sqrt(dmg) * 100, 0, 2 * Math.PI);
|
||||
// ctx.fill();
|
||||
// }
|
||||
// };
|
||||
// checkforCollisions();
|
||||
// if (best.dist2 != Infinity) {
|
||||
// //if hitting something
|
||||
// path[path.length - 1] = {
|
||||
// x: best.x,
|
||||
// y: best.y
|
||||
// };
|
||||
// laserHitMob(1);
|
||||
// }
|
||||
// ctx.fillStyle = color;
|
||||
// ctx.strokeStyle = color;
|
||||
// ctx.lineWidth = 4;
|
||||
// for (let i = 1, len = path.length; i < len; ++i) {
|
||||
// d = {
|
||||
// x: path[i].x - path[i - 1].x,
|
||||
// y: path[i].y - path[i - 1].y
|
||||
// }
|
||||
// const a = mech.cycle * 5
|
||||
// p1 = {
|
||||
// x: d.x / 2 * Math.cos(a) - d.y / 2 * Math.sin(a),
|
||||
// y: d.x / 2 * Math.sin(a) + d.y / 2 * Math.cos(a),
|
||||
// }
|
||||
// const wave = 300 / Math.sqrt(d.x * d.x + d.y * d.y)
|
||||
// ctx.beginPath();
|
||||
// ctx.moveTo(path[i - 1].x, path[i - 1].y);
|
||||
// ctx.bezierCurveTo(path[i - 1].x + p1.x * wave, path[i - 1].y + p1.y * wave, path[i].x + p1.x * wave, path[i].y + p1.y * wave, path[i].x, path[i].y);
|
||||
// ctx.stroke();
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
}, {
|
||||
name: "kinetic slugs",
|
||||
description: "fire a huge rod with high recoil<br>effective at long distances",
|
||||
description: "fire a large <strong>rod</strong> that does excessive physical <span class='color-d'>damage</span><br><em>high recoil</em>",
|
||||
ammo: 0,
|
||||
ammoPack: 5,
|
||||
have: false,
|
||||
@@ -782,7 +611,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "minigun",
|
||||
description: "fire a stream of bullets",
|
||||
description: "rapidly fire a stream of small bullets",
|
||||
ammo: 0,
|
||||
ammoPack: 105,
|
||||
have: false,
|
||||
@@ -790,11 +619,11 @@ const b = {
|
||||
const me = bullet.length;
|
||||
b.muzzleFlash(15);
|
||||
// if (Math.random() > 0.2) mobs.alert(500);
|
||||
const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.07 : 0.16);
|
||||
const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.03 : 0.14);
|
||||
bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 17 * b.modBulletSize, 5 * b.modBulletSize, b.fireAttributes(dir));
|
||||
b.fireProps(mech.crouch ? 11 : 5, mech.crouch ? 44 : 36, dir, me); //cd , speed
|
||||
bullet[me].endCycle = game.cycle + Math.floor(65 * b.modBulletsLastLonger);
|
||||
bullet[me].frictionAir = 0.01;
|
||||
bullet[me].frictionAir = mech.crouch ? 0.007 : 0.01;
|
||||
bullet[me].do = function () {
|
||||
this.force.y += this.mass * 0.0005;
|
||||
};
|
||||
@@ -802,7 +631,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "wave beam",
|
||||
description: "fire a stream of oscillating particles<br>propagates through solids<br>effective at close range",
|
||||
description: "fire a stream of oscillating particles<br><strong style='opacity: 0.4;'>propagates through solids</strong>",
|
||||
ammo: 0,
|
||||
ammoPack: 85,
|
||||
have: false,
|
||||
@@ -855,7 +684,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "super balls",
|
||||
description: "fire 3 very bouncy balls",
|
||||
description: "fire 3 very <strong>bouncy</strong> balls",
|
||||
ammo: 0,
|
||||
ammoPack: 11,
|
||||
have: false,
|
||||
@@ -883,7 +712,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "shotgun",
|
||||
description: "fire a burst of bullets with high recoil<br>more effective at close range",
|
||||
description: "fire a <strong>burst</strong> of bullets<br><em>high recoil</em>",
|
||||
ammo: 0,
|
||||
ammoPack: 8,
|
||||
have: false,
|
||||
@@ -911,7 +740,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "fléchettes",
|
||||
description: "fire a narrow projectile<br>effective at long distances",
|
||||
description: "fire an accurate high speed needle<br>",
|
||||
ammo: 0,
|
||||
ammoPack: 19,
|
||||
have: false,
|
||||
@@ -935,9 +764,9 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "missiles",
|
||||
description: "fire a missile that accelerates towards nearby targets<br>explodes when near target",
|
||||
description: "fire a missile that accelerates towards nearby targets<br><span class='color-e'>explodes</span> when near target",
|
||||
ammo: 0,
|
||||
ammoPack: 9,
|
||||
ammoPack: 8,
|
||||
have: false,
|
||||
fireCycle: 0,
|
||||
ammoLoaded: 0,
|
||||
@@ -953,7 +782,7 @@ const b = {
|
||||
bullet[me].force.y += 0.00045; //a small push down at first to make it seem like the missile is briefly falling
|
||||
bullet[me].frictionAir = 0
|
||||
bullet[me].endCycle = game.cycle + Math.floor((265 + Math.random() * 20) * b.modBulletsLastLonger);
|
||||
bullet[me].explodeRad = 150 + 40 * Math.random();
|
||||
bullet[me].explodeRad = 165 + 40 * Math.random();
|
||||
bullet[me].lookFrequency = Math.floor(8 + Math.random() * 7);
|
||||
bullet[me].onEnd = b.explode; //makes bullet do explosive damage at end
|
||||
bullet[me].onDmg = function () {
|
||||
@@ -1040,7 +869,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "flak",
|
||||
description: "fire a cluster of explosive projectiles<br>explode on contact or after half a second",
|
||||
description: "fire a cluster of short range projectiles<br><span class='color-e'>explode</span> on contact or after half a second",
|
||||
ammo: 0,
|
||||
ammoPack: 20,
|
||||
have: false,
|
||||
@@ -1048,9 +877,9 @@ const b = {
|
||||
b.muzzleFlash(30);
|
||||
const totalBullets = 5
|
||||
const angleStep = (mech.crouch ? 0.06 : 0.15) / totalBullets
|
||||
const SPEED = mech.crouch ? 27 : 20
|
||||
const CD = mech.crouch ? 30 : 15
|
||||
const END = Math.floor((mech.crouch ? 27 : 18) * b.modBulletsLastLonger);
|
||||
const SPEED = mech.crouch ? 30 : 25
|
||||
const CD = mech.crouch ? 45 : 11
|
||||
const END = Math.floor((mech.crouch ? 30 : 18) * b.modBulletsLastLonger);
|
||||
let dir = mech.angle - angleStep * totalBullets / 2;
|
||||
const side1 = 17 * b.modBulletSize
|
||||
const side2 = 4 * b.modBulletSize
|
||||
@@ -1059,13 +888,13 @@ const b = {
|
||||
dir += angleStep
|
||||
const me = bullet.length;
|
||||
bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), side1, side2, b.fireAttributes(dir));
|
||||
b.fireProps(CD, SPEED + 25 * Math.random() - i, dir, me); //cd , speed
|
||||
b.fireProps(CD, SPEED + 15 * Math.random() - 2 * i, dir, me); //cd , speed
|
||||
// Matter.Body.setDensity(bullet[me], 0.005);
|
||||
bullet[me].endCycle = i + game.cycle + END
|
||||
bullet[me].endCycle = 2 * i + game.cycle + END
|
||||
bullet[me].restitution = 0;
|
||||
bullet[me].friction = 1;
|
||||
// bullet[me].dmg = 0.15;
|
||||
bullet[me].explodeRad = 45 + (Math.random() - 0.5) * 50;
|
||||
bullet[me].explodeRad = (mech.crouch ? 70 : 45) + (Math.random() - 0.5) * 50;
|
||||
bullet[me].onEnd = b.explode;
|
||||
bullet[me].onDmg = function () {
|
||||
this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
|
||||
@@ -1083,50 +912,48 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "grenades",
|
||||
description: "fire a bomb that explodes on contact or after 1.6 seconds",
|
||||
description: "fire a projectile that <span class='color-e'>explodes</span> on contact or after one second",
|
||||
ammo: 0,
|
||||
ammoPack: 14,
|
||||
ammoPack: 11,
|
||||
have: false,
|
||||
fire() {
|
||||
const me = bullet.length;
|
||||
const dir = mech.angle; // + Math.random() * 0.05;
|
||||
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 15 * b.modBulletSize, b.fireAttributes(dir, false));
|
||||
b.fireProps(mech.crouch ? 40 : 25, mech.crouch ? 41 : 32, dir, me); //cd , speed
|
||||
b.fireProps(mech.crouch ? 40 : 20, mech.crouch ? 43 : 32, dir, me); //cd , speed
|
||||
b.drawOneBullet(bullet[me].vertices);
|
||||
// Matter.Body.setDensity(bullet[me], 0.000001);
|
||||
bullet[me].totalCycles = 100;
|
||||
bullet[me].endCycle = game.cycle + Math.floor(70 * b.modBulletsLastLonger);
|
||||
bullet[me].restitution = 0.25;
|
||||
bullet[me].explodeRad = 220;
|
||||
bullet[me].endCycle = game.cycle + Math.floor((mech.crouch ? 120 : 60) * b.modBulletsLastLonger);
|
||||
bullet[me].restitution = 0.5;
|
||||
bullet[me].explodeRad = 210;
|
||||
bullet[me].onEnd = b.explode; //makes bullet do explosive damage before despawn
|
||||
bullet[me].minDmgSpeed = 1;
|
||||
bullet[me].dmg = 0.5;
|
||||
bullet[me].onDmg = function () {
|
||||
this.endCycle = 0; //bullet ends cycle after doing damage //this triggers explosion
|
||||
this.endCycle = 0; //bullet ends cycle after doing damage //this also triggers explosion
|
||||
};
|
||||
bullet[me].do = function () {
|
||||
//extra gravity for harder arcs
|
||||
this.force.y += this.mass * 0.0022;
|
||||
this.force.y += this.mass * 0.002;
|
||||
};
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "vacuum bomb",
|
||||
description: "fire a huge bomb that sucks before it explodes",
|
||||
description: "fire a huge bomb that sucks before it <span class='color-e'>explodes</span><br>click left mouse <strong>again</strong> to detonate",
|
||||
ammo: 0,
|
||||
ammoPack: 5,
|
||||
ammoPack: 4,
|
||||
have: false,
|
||||
fire() {
|
||||
const me = bullet.length;
|
||||
const dir = mech.angle;
|
||||
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 26 * b.modBulletSize, b.fireAttributes(dir, false));
|
||||
bullet[me].radius = 22; //used from drawing timer
|
||||
b.fireProps(mech.crouch ? 80 : 50, mech.crouch ? 37 : 0, dir, me); //cd , speed
|
||||
b.fireProps(10, mech.crouch ? 42 : 26, dir, me); //cd , speed
|
||||
|
||||
b.drawOneBullet(bullet[me].vertices);
|
||||
// Matter.Body.setDensity(bullet[me], 0.001);
|
||||
bullet[me].endCycle = game.cycle + Math.floor((mech.crouch ? 100 : 150) * b.modBulletsLastLonger);
|
||||
bullet[me].endCycleLength = bullet[me].endCycle - game.cycle
|
||||
bullet[me].endCycle = Infinity
|
||||
bullet[me].endCycle = Infinity
|
||||
// bullet[me].restitution = 0.3;
|
||||
// bullet[me].frictionAir = 0.01;
|
||||
// bullet[me].friction = 0.15;
|
||||
@@ -1140,78 +967,89 @@ const b = {
|
||||
bullet[me].onDmg = function () {
|
||||
// this.endCycle = 0; //bullet ends cycle after doing damage //this triggers explosion
|
||||
};
|
||||
bullet[me].isArmed = false;
|
||||
bullet[me].isSucking = false;
|
||||
bullet[me].do = function () {
|
||||
//extra gravity for harder arcs
|
||||
this.force.y += this.mass * 0.0022;
|
||||
mech.fireCDcycle = mech.cycle + 10 //can't fire until after the explosion
|
||||
|
||||
//before the explosion suck in stuff
|
||||
if (game.cycle > this.endCycle - 35 && !mech.isBodiesAsleep) {
|
||||
const that = this
|
||||
let mag = 0.1
|
||||
//set armed and sucking status
|
||||
if (!this.isArmed && !game.mouseDown) {
|
||||
this.isArmed = true
|
||||
} else if (this.isArmed && game.mouseDown && !this.isSucking) {
|
||||
this.isSucking = true;
|
||||
this.endCycle = game.cycle + 35;
|
||||
}
|
||||
|
||||
function suck(who, radius = that.explodeRad * 2) {
|
||||
for (i = 0, len = who.length; i < len; i++) {
|
||||
const sub = Matter.Vector.sub(that.position, who[i].position);
|
||||
const dist = Matter.Vector.magnitude(sub);
|
||||
if (dist < radius && dist > 150) {
|
||||
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), mag * who[i].mass / Math.sqrt(dist));
|
||||
who[i].force.x += knock.x;
|
||||
who[i].force.y += knock.y;
|
||||
if (this.isSucking) {
|
||||
if (!mech.isBodiesAsleep) {
|
||||
const that = this
|
||||
let mag = 0.1
|
||||
|
||||
function suck(who, radius = that.explodeRad * 2) {
|
||||
for (i = 0, len = who.length; i < len; i++) {
|
||||
const sub = Matter.Vector.sub(that.position, who[i].position);
|
||||
const dist = Matter.Vector.magnitude(sub);
|
||||
if (dist < radius && dist > 150) {
|
||||
knock = Matter.Vector.mult(Matter.Vector.normalise(sub), mag * who[i].mass / Math.sqrt(dist));
|
||||
who[i].force.x += knock.x;
|
||||
who[i].force.y += knock.y;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (game.cycle > this.endCycle - 5) {
|
||||
mag = -0.22
|
||||
suck(body)
|
||||
suck(mob)
|
||||
suck(powerUp)
|
||||
suck([player])
|
||||
} else {
|
||||
mag = 0.1
|
||||
suck(body)
|
||||
suck(mob)
|
||||
suck(powerUp)
|
||||
suck([player])
|
||||
}
|
||||
//keep bomb in place
|
||||
Matter.Body.setVelocity(this, {
|
||||
x: 0,
|
||||
y: 0
|
||||
});
|
||||
//draw suck
|
||||
const radius = 2.5 * this.explodeRad * (this.endCycle - game.cycle) / 35
|
||||
ctx.fillStyle = "rgba(0,0,0,0.1)";
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, radius, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
}
|
||||
if (game.cycle > this.endCycle - 5) {
|
||||
mag = -0.22
|
||||
suck(body)
|
||||
suck(mob)
|
||||
suck(powerUp)
|
||||
suck([player])
|
||||
} else {
|
||||
mag = 0.1
|
||||
suck(body)
|
||||
suck(mob)
|
||||
suck(powerUp)
|
||||
suck([player])
|
||||
} else {
|
||||
// flashing lights to show armed
|
||||
if (!(game.cycle % 10)) {
|
||||
if (this.isFlashOn) {
|
||||
this.isFlashOn = false;
|
||||
} else {
|
||||
this.isFlashOn = true;
|
||||
}
|
||||
}
|
||||
|
||||
//keep bomb in place
|
||||
Matter.Body.setVelocity(this, {
|
||||
x: 0,
|
||||
y: 0
|
||||
});
|
||||
//draw suck
|
||||
const radius = 9 * this.explodeRad * (this.endCycle - game.cycle) / this.endCycleLength
|
||||
ctx.fillStyle = "rgba(0,0,0,0.1)";
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, radius, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
}
|
||||
|
||||
//draw timer
|
||||
if (!(game.cycle % 10)) {
|
||||
if (this.isFlashOn) {
|
||||
this.isFlashOn = false;
|
||||
} else {
|
||||
this.isFlashOn = true;
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, this.radius, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
//draw clock on timer
|
||||
ctx.fillStyle = "#f04";
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, this.radius * 0.5, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
}
|
||||
}
|
||||
if (this.isFlashOn) {
|
||||
ctx.fillStyle = "#000";
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, this.radius, 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
//draw clock on timer
|
||||
ctx.fillStyle = "#f12";
|
||||
ctx.beginPath();
|
||||
ctx.arc(this.position.x, this.position.y, this.radius * (1 - (this.endCycle - game.cycle) / this.endCycleLength), 0, 2 * Math.PI);
|
||||
ctx.fill();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
name: "spores",
|
||||
description: "release an orb that discharges spores after 2 seconds<br>spores seek out targets<br>spores can pass through blocks",
|
||||
description: "release an orb that discharges <span class='color-s'>spores</span> after 2 seconds<br><span class='color-s'>spores</span> seek out targets<br><span class='color-s'>spores</span> can pass through blocks",
|
||||
ammo: 0,
|
||||
ammoPack: 5,
|
||||
have: false,
|
||||
@@ -1314,7 +1152,7 @@ const b = {
|
||||
},
|
||||
{
|
||||
name: "drones",
|
||||
description: "release drones that seek out targets<br>if no targets, drones move to mouse<br>",
|
||||
description: "release <span class='color-b'>drones</span> that seek out targets<br>if no targets are found, <span class='color-b'>drones</span> move towards mouse<br>",
|
||||
ammo: 0,
|
||||
ammoPack: 20,
|
||||
have: false,
|
||||
|
||||
Reference in New Issue
Block a user