|
|
|
|
@@ -19,6 +19,7 @@ const b = {
|
|
|
|
|
modExtraDmg: null,
|
|
|
|
|
annihilation: null,
|
|
|
|
|
fullHeal: null,
|
|
|
|
|
modSquirrelFx: 1,
|
|
|
|
|
setModDefaults() {
|
|
|
|
|
b.modCount = 0;
|
|
|
|
|
b.modFireRate = 1;
|
|
|
|
|
@@ -35,6 +36,7 @@ const b = {
|
|
|
|
|
b.modExtraDmg = 0;
|
|
|
|
|
b.modAnnihilation = false;
|
|
|
|
|
b.isModFullHeal = false;
|
|
|
|
|
b.modSquirrelFx = 1;
|
|
|
|
|
mech.Fx = 0.015;
|
|
|
|
|
mech.jumpForce = 0.38;
|
|
|
|
|
mech.throwChargeRate = 2;
|
|
|
|
|
@@ -145,7 +147,7 @@ const b = {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "annihilation",
|
|
|
|
|
description: "after you touch any enemy, they are <strong class='color-l'>annihilated</strong><br><em>touching enemies damages you, but destroys them</em>",
|
|
|
|
|
description: "after you touch any enemy, they are <strong class='color-l'>annihilated</strong><br><em>touching enemies <span class='color-d'>damages</span> you, but <span class='color-d'>destroys</span> them</em>",
|
|
|
|
|
have: false, //12
|
|
|
|
|
effect: () => { //good with mods that heal: superconductive healing, entropy transfer
|
|
|
|
|
b.modAnnihilation = true
|
|
|
|
|
@@ -175,7 +177,8 @@ const b = {
|
|
|
|
|
description: "jump higher and move faster",
|
|
|
|
|
have: false, //15
|
|
|
|
|
effect: () => { //
|
|
|
|
|
mech.Fx = 0.015 * 1.2;
|
|
|
|
|
b.modSquirrelFx = 1.2;
|
|
|
|
|
mech.Fx = 0.015 * b.modSquirrelFx;
|
|
|
|
|
mech.jumpForce = 0.38 * 1.1;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
@@ -560,7 +563,7 @@ const b = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
const checkforCollisions = function () {
|
|
|
|
|
const checkForCollisions = function () {
|
|
|
|
|
best = {
|
|
|
|
|
x: null,
|
|
|
|
|
y: null,
|
|
|
|
|
@@ -595,7 +598,7 @@ const b = {
|
|
|
|
|
path[path.length] = Matter.Vector.add(Matter.Vector.mult(r, range), path[path.length - 1]);
|
|
|
|
|
};
|
|
|
|
|
//beam before reflection
|
|
|
|
|
checkforCollisions();
|
|
|
|
|
checkForCollisions();
|
|
|
|
|
if (best.dist2 != Infinity) {
|
|
|
|
|
//if hitting something
|
|
|
|
|
path[path.length - 1] = {
|
|
|
|
|
@@ -608,7 +611,7 @@ const b = {
|
|
|
|
|
reflection();
|
|
|
|
|
//ugly bug fix: this stops the reflection on a bug where the beam gets trapped inside a body
|
|
|
|
|
let who = best.who;
|
|
|
|
|
checkforCollisions();
|
|
|
|
|
checkForCollisions();
|
|
|
|
|
if (best.dist2 != Infinity) {
|
|
|
|
|
//if hitting something
|
|
|
|
|
path[path.length - 1] = {
|
|
|
|
|
@@ -621,7 +624,7 @@ const b = {
|
|
|
|
|
//ugly bug fix: this stops the reflection on a bug where the beam gets trapped inside a body
|
|
|
|
|
if (who !== best.who) {
|
|
|
|
|
reflection();
|
|
|
|
|
checkforCollisions();
|
|
|
|
|
checkForCollisions();
|
|
|
|
|
if (best.dist2 != Infinity) {
|
|
|
|
|
//if hitting something
|
|
|
|
|
path[path.length - 1] = {
|
|
|
|
|
@@ -652,16 +655,17 @@ const b = {
|
|
|
|
|
ctx.globalAlpha = 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
name: "rail gun", //15
|
|
|
|
|
description: "<strong>hold left mouse</strong> to charge and release to fire<br>charging repels enemies and drains <span class='color-f'>field energy</span><br><em><strong>crouching</strong> improves charging and reduces recoil</em>",
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "rail gun", //1
|
|
|
|
|
description: "<strong>hold left mouse</strong> to charge and release to fire<br>charging repels small enemies<br><em>crouching charges quicker and reduces recoil</em>",
|
|
|
|
|
ammo: 0,
|
|
|
|
|
ammoPack: 9,
|
|
|
|
|
ammoPack: 12,
|
|
|
|
|
have: false,
|
|
|
|
|
isStarterGun: false,
|
|
|
|
|
fire() {
|
|
|
|
|
const me = bullet.length;
|
|
|
|
|
bullet[me] = Bodies.rectangle(9, -90, 0.01 * b.modBulletSize, 0.0015 * b.modBulletSize, {
|
|
|
|
|
bullet[me] = Bodies.rectangle(9, -90, 0.01 * b.modBulletSize, 0.0017 * b.modBulletSize, {
|
|
|
|
|
// density: 0.0015, //frictionAir: 0.01, //restitution: 0,
|
|
|
|
|
angle: 0,
|
|
|
|
|
friction: 0.5,
|
|
|
|
|
@@ -683,15 +687,10 @@ const b = {
|
|
|
|
|
bullet[me].charge = 0;
|
|
|
|
|
bullet[me].do = function () {
|
|
|
|
|
if (this.isCharging) {
|
|
|
|
|
const DRAIN = 0.0001 + mech.fieldRegen
|
|
|
|
|
if ((!game.mouseDown && this.charge > 0.5) || mech.fieldMeter < DRAIN) { //fire on mouse release
|
|
|
|
|
if ((!game.mouseDown && this.charge > 0.5)) { //fire on mouse release
|
|
|
|
|
this.isCharging = false
|
|
|
|
|
if (mech.fieldMeter < DRAIN) {
|
|
|
|
|
mech.fireCDcycle = mech.cycle + 120; // long CD if out of mana
|
|
|
|
|
} else {
|
|
|
|
|
mech.fireCDcycle = mech.cycle + 2; // set fire cool down
|
|
|
|
|
}
|
|
|
|
|
Matter.Body.scale(this, 10000, 10000) // un hide the bullet by scaling it up (don't judge me... I know this is a bad way to do it)
|
|
|
|
|
Matter.Body.scale(this, 8000, 8000) // show the bullet by scaling it up (don't judge me... I know this is a bad way to do it)
|
|
|
|
|
this.endCycle = game.cycle + Math.floor(140 * b.isModBulletsLastLonger)
|
|
|
|
|
this.collisionFilter.category = 0x000100
|
|
|
|
|
Matter.Body.setPosition(this, {
|
|
|
|
|
@@ -706,34 +705,45 @@ const b = {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
//knock back
|
|
|
|
|
const KNOCK = ((mech.crouch) ? 0.1 : 0.7) * b.modBulletSize * b.modBulletSize * this.charge * this.charge
|
|
|
|
|
const KNOCK = ((mech.crouch) ? 0.1 : 0.5) * b.modBulletSize * b.modBulletSize * this.charge * this.charge
|
|
|
|
|
player.force.x -= KNOCK * Math.cos(mech.angle)
|
|
|
|
|
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.3 //reduce knock back in vertical direction to stop super jumps
|
|
|
|
|
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps
|
|
|
|
|
|
|
|
|
|
//push away blocks on fire
|
|
|
|
|
//push away blocks when firing
|
|
|
|
|
const RANGE = 450 * this.charge
|
|
|
|
|
for (let i = 0, len = body.length; i < len; ++i) {
|
|
|
|
|
const SUB = Matter.Vector.sub(body[i].position, mech.pos)
|
|
|
|
|
const DISTANCE = Matter.Vector.magnitude(SUB)
|
|
|
|
|
if (DISTANCE < RANGE) {
|
|
|
|
|
const DEPTH = RANGE - DISTANCE
|
|
|
|
|
const DEPTH = Math.max(RANGE - DISTANCE, 100)
|
|
|
|
|
const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.005 * Math.sqrt(DEPTH) * Math.sqrt(body[i].mass))
|
|
|
|
|
body[i].force.x += FORCE.x
|
|
|
|
|
body[i].force.y += FORCE.y - body[i].mass * (game.g * 25); //kick up a bit to give them some arc
|
|
|
|
|
body[i].force.y += FORCE.y - body[i].mass * (game.g * 1.5); //kick up a bit to give them some arc
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//push mobs around player when firing
|
|
|
|
|
// for (let i = 0, len = mob.length; i < len; ++i) {
|
|
|
|
|
// const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
|
|
|
|
|
// const DISTANCE = Matter.Vector.magnitude(SUB)
|
|
|
|
|
// if (DISTANCE < RANGE) {
|
|
|
|
|
// const DEPTH = RANGE - DISTANCE
|
|
|
|
|
// const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.00000001 * DEPTH * DEPTH * DEPTH * Math.sqrt(mob[i].mass))
|
|
|
|
|
// mob[i].force.x += FORCE.x
|
|
|
|
|
// mob[i].force.y += FORCE.y
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { // charging on mouse down
|
|
|
|
|
mech.fieldMeter -= DRAIN;
|
|
|
|
|
mech.fireCDcycle = Infinity //can't fire until mouse is released
|
|
|
|
|
if (mech.crouch) {
|
|
|
|
|
this.charge = this.charge * 0.97 + 0.03 // this.charge converges to 1
|
|
|
|
|
} else {
|
|
|
|
|
this.charge = this.charge * 0.99 + 0.01 // this.charge converges to 1
|
|
|
|
|
this.charge = this.charge * 0.98 + 0.02 // this.charge converges to 1
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//gently push away mobs while charging
|
|
|
|
|
const RANGE = 300 * this.charge
|
|
|
|
|
const RANGE = 350 * this.charge
|
|
|
|
|
for (let i = 0, len = mob.length; i < len; ++i) {
|
|
|
|
|
const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
|
|
|
|
|
const DISTANCE = Matter.Vector.magnitude(SUB)
|
|
|
|
|
@@ -861,31 +871,8 @@ const b = {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// }, {
|
|
|
|
|
// name: "kinetic slugs", //1
|
|
|
|
|
// 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,
|
|
|
|
|
// isStarterGun: true,
|
|
|
|
|
// fire() {
|
|
|
|
|
// b.muzzleFlash(45);
|
|
|
|
|
// // mobs.alert(800);
|
|
|
|
|
// const me = bullet.length;
|
|
|
|
|
// const dir = mech.angle;
|
|
|
|
|
// bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 70 * b.modBulletSize, 30 * b.modBulletSize, b.fireAttributes(dir));
|
|
|
|
|
// b.fireProps(mech.crouch ? 55 : 40, 50, dir, me); //cd , speed
|
|
|
|
|
// bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
|
|
|
|
|
// bullet[me].do = function () {
|
|
|
|
|
// this.force.y += this.mass * 0.0005;
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// //knock back
|
|
|
|
|
// const KNOCK = ((mech.crouch) ? 0.025 : 0.25) * b.modBulletSize * b.modBulletSize
|
|
|
|
|
// player.force.x -= KNOCK * Math.cos(dir)
|
|
|
|
|
// player.force.y -= KNOCK * Math.sin(dir) * 0.3 //reduce knock back in vertical direction to stop super jumps
|
|
|
|
|
// }
|
|
|
|
|
}, {
|
|
|
|
|
},
|
|
|
|
|
{
|
|
|
|
|
name: "minigun", //2
|
|
|
|
|
description: "rapidly fire a stream of small <strong>bullets</strong>",
|
|
|
|
|
ammo: 0,
|
|
|
|
|
@@ -1203,7 +1190,7 @@ const b = {
|
|
|
|
|
ammo: 0,
|
|
|
|
|
ammoPack: 9,
|
|
|
|
|
have: false,
|
|
|
|
|
isStarterGun: true,
|
|
|
|
|
isStarterGun: false,
|
|
|
|
|
fire() {
|
|
|
|
|
const me = bullet.length;
|
|
|
|
|
const dir = mech.angle; // + Math.random() * 0.05;
|
|
|
|
|
@@ -1519,12 +1506,12 @@ const b = {
|
|
|
|
|
bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
|
|
|
|
|
angle: dir,
|
|
|
|
|
inertia: Infinity,
|
|
|
|
|
friction: 0,
|
|
|
|
|
friction: 0.05,
|
|
|
|
|
frictionAir: 0.0005,
|
|
|
|
|
restitution: 1,
|
|
|
|
|
dmg: 0.14 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
|
|
|
|
lookFrequency: 79 + Math.floor(37 * Math.random()),
|
|
|
|
|
endCycle: game.cycle + Math.floor((780 + 360 * Math.random()) * b.isModBulletsLastLonger),
|
|
|
|
|
endCycle: game.cycle + Math.floor((960 + 360 * Math.random()) * b.isModBulletsLastLonger),
|
|
|
|
|
classType: "bullet",
|
|
|
|
|
collisionFilter: {
|
|
|
|
|
category: 0x000100,
|
|
|
|
|
@@ -1538,6 +1525,10 @@ const b = {
|
|
|
|
|
},
|
|
|
|
|
onEnd() {},
|
|
|
|
|
do() {
|
|
|
|
|
if (game.cycle + 180 > this.endCycle) { //fall and die
|
|
|
|
|
this.force.y += this.mass * 0.0012;
|
|
|
|
|
this.restitution = 0.2;
|
|
|
|
|
} else {
|
|
|
|
|
this.force.y += this.mass * 0.0002;
|
|
|
|
|
//find mob targets
|
|
|
|
|
if (!(game.cycle % this.lookFrequency)) {
|
|
|
|
|
@@ -1594,83 +1585,245 @@ const b = {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 35 : 1, dir, me); //cd , speed
|
|
|
|
|
b.drawOneBullet(bullet[me].vertices);
|
|
|
|
|
}
|
|
|
|
|
}, {
|
|
|
|
|
//draw a halo, since there will only be 1-3 balls
|
|
|
|
|
name: "junk-bots", //14
|
|
|
|
|
description: "release large <strong>drones</strong> that defend the space around the player<br>despawn after not doing <span class='color-d'>damage</span> for 3 seconds",
|
|
|
|
|
ammo: 0,
|
|
|
|
|
ammoPack: 20,
|
|
|
|
|
have: false,
|
|
|
|
|
isStarterGun: true,
|
|
|
|
|
fire() {
|
|
|
|
|
const THRUST = 0.004
|
|
|
|
|
const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
|
|
|
|
const me = bullet.length;
|
|
|
|
|
const RADIUS = (18 + 5 * Math.random()) * b.modBulletSize
|
|
|
|
|
const LENGTH = 0.6 + 0.8 * Math.random()
|
|
|
|
|
bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS * LENGTH, RADIUS / LENGTH, {
|
|
|
|
|
isOrb: true,
|
|
|
|
|
angle: dir,
|
|
|
|
|
// inertia: Infinity,
|
|
|
|
|
friction: 0,
|
|
|
|
|
frictionAir: 0.06,
|
|
|
|
|
restitution: 1,
|
|
|
|
|
dmg: b.modExtraDmg, // 0.14 //damage done in addition to the damage from momentum
|
|
|
|
|
minDmgSpeed: 2,
|
|
|
|
|
lookFrequency: 37 + Math.floor(37 * Math.random()),
|
|
|
|
|
endCycle: game.cycle + Math.floor((170 + 120 * Math.random()) * b.isModBulletsLastLonger),
|
|
|
|
|
classType: "bullet",
|
|
|
|
|
collisionFilter: {
|
|
|
|
|
category: 0x000100,
|
|
|
|
|
mask: 0x010111 //self, mob,map,body collide
|
|
|
|
|
},
|
|
|
|
|
range: 700,
|
|
|
|
|
lockedOn: null,
|
|
|
|
|
onDmg() {
|
|
|
|
|
// {
|
|
|
|
|
// name: "dwarf star", //14
|
|
|
|
|
// description: "drop a mine that gravitational pulls in matter",
|
|
|
|
|
// ammo: 0,
|
|
|
|
|
// ammoPack: 1000,
|
|
|
|
|
// have: false,
|
|
|
|
|
// isStarterGun: false,
|
|
|
|
|
// fire() {
|
|
|
|
|
// const me = bullet.length;
|
|
|
|
|
// const dir = mech.angle
|
|
|
|
|
// const TOTAL_CYCLES = 1020
|
|
|
|
|
// bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(dir), mech.pos.y + 30 * Math.sin(dir), 3 * b.modBulletSize, {
|
|
|
|
|
// density: 0.05,
|
|
|
|
|
// //frictionAir: 0.01,
|
|
|
|
|
// restitution: 0,
|
|
|
|
|
// angle: 0,
|
|
|
|
|
// friction: 1,
|
|
|
|
|
// // frictionAir: 1,
|
|
|
|
|
// endCycle: game.cycle + TOTAL_CYCLES,
|
|
|
|
|
// dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
|
|
|
|
|
// classType: "bullet",
|
|
|
|
|
// collisionFilter: {
|
|
|
|
|
// category: 0x000100,
|
|
|
|
|
// mask: 0x010011 //mask: 0x000101, //for self collision
|
|
|
|
|
// },
|
|
|
|
|
// minDmgSpeed: 5,
|
|
|
|
|
// range: 0,
|
|
|
|
|
// onDmg() {
|
|
|
|
|
// this.endCycle = 0;
|
|
|
|
|
this.lockedOn = null
|
|
|
|
|
this.endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger)
|
|
|
|
|
},
|
|
|
|
|
onEnd() {},
|
|
|
|
|
do() {
|
|
|
|
|
if (!(game.cycle % this.lookFrequency)) {
|
|
|
|
|
this.lockedOn = null;
|
|
|
|
|
let closeDist = Infinity;
|
|
|
|
|
for (let i = 0, len = mob.length; i < len; ++i) {
|
|
|
|
|
const TARGET_VECTOR = Matter.Vector.sub(mech.pos, mob[i].position)
|
|
|
|
|
const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
|
|
|
|
if (DIST < this.range && DIST < closeDist && Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
|
|
|
|
|
closeDist = DIST;
|
|
|
|
|
this.lockedOn = mob[i]
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// }, //this.endCycle = 0 //triggers despawn
|
|
|
|
|
// onEnd() {},
|
|
|
|
|
// do() {
|
|
|
|
|
// this.force.y += this.mass * 0.005;
|
|
|
|
|
// this.range += 0.5
|
|
|
|
|
|
|
|
|
|
const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
|
|
|
|
|
if (this.lockedOn) { //accelerate towards mobs
|
|
|
|
|
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
|
|
|
|
|
this.frictionAir = 0.06
|
|
|
|
|
} else if (distanceToPlayer > 0.2 * this.range) {
|
|
|
|
|
this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.3)
|
|
|
|
|
this.frictionAir = 0.02
|
|
|
|
|
// // speed cap instead of friction to give more agility
|
|
|
|
|
// if (this.speed > 14) {
|
|
|
|
|
// Matter.Body.setVelocity(this, {
|
|
|
|
|
// x: this.velocity.x * 0.97,
|
|
|
|
|
// y: this.velocity.y * 0.97
|
|
|
|
|
// });
|
|
|
|
|
// //damage nearby mobs
|
|
|
|
|
// const dmg = b.dmgScale * 0.02
|
|
|
|
|
// for (let i = 0, len = mob.length; i < len; ++i) {
|
|
|
|
|
// if (mob[i].alive) {
|
|
|
|
|
// sub = Matter.Vector.sub(this.position, mob[i].position);
|
|
|
|
|
// dist = Matter.Vector.magnitude(sub) - mob[i].radius;
|
|
|
|
|
// if (dist < this.range) {
|
|
|
|
|
// mob[i].damage(dmg);
|
|
|
|
|
// mob[i].locatePlayer();
|
|
|
|
|
// }
|
|
|
|
|
} else { //must be close to player //add some random motion
|
|
|
|
|
this.frictionAir = 0
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
b.fireProps(mech.crouch ? 40 : 10, mech.crouch ? 40 : 10, dir, me); //cd , speed
|
|
|
|
|
b.drawOneBullet(bullet[me].vertices);
|
|
|
|
|
}
|
|
|
|
|
}, ]
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// //pull in body, and power ups?, and bullets?
|
|
|
|
|
// for (let i = 0, len = body.length; i < len; ++i) {
|
|
|
|
|
// sub = Matter.Vector.sub(this.position, body[i].position);
|
|
|
|
|
// dist = Matter.Vector.magnitude(sub)
|
|
|
|
|
// if (dist < this.range) {
|
|
|
|
|
// this.range += body[i].mass * 2
|
|
|
|
|
// Matter.World.remove(engine.world, body[i]);
|
|
|
|
|
// body.splice(i, 1);
|
|
|
|
|
// break;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// //draw
|
|
|
|
|
// const opacity = (this.endCycle - game.cycle) / TOTAL_CYCLES
|
|
|
|
|
// ctx.fillStyle = `rgba(170,220,255,${opacity})`;
|
|
|
|
|
// ctx.beginPath();
|
|
|
|
|
// ctx.arc(this.position.x, this.position.y, this.range, 0, 2 * Math.PI);
|
|
|
|
|
// ctx.fill();
|
|
|
|
|
// }
|
|
|
|
|
// });
|
|
|
|
|
// b.fireProps(60, 0, dir, me); //cd , speed
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// name: "kinetic slugs", //1
|
|
|
|
|
// 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,
|
|
|
|
|
// isStarterGun: true,
|
|
|
|
|
// fire() {
|
|
|
|
|
// b.muzzleFlash(45);
|
|
|
|
|
// // mobs.alert(800);
|
|
|
|
|
// const me = bullet.length;
|
|
|
|
|
// const dir = mech.angle;
|
|
|
|
|
// bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 70 * b.modBulletSize, 30 * b.modBulletSize, b.fireAttributes(dir));
|
|
|
|
|
// b.fireProps(mech.crouch ? 55 : 40, 50, dir, me); //cd , speed
|
|
|
|
|
// bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
|
|
|
|
|
// bullet[me].do = function () {
|
|
|
|
|
// this.force.y += this.mass * 0.0005;
|
|
|
|
|
// };
|
|
|
|
|
|
|
|
|
|
// //knock back
|
|
|
|
|
// const KNOCK = ((mech.crouch) ? 0.025 : 0.25) * b.modBulletSize * b.modBulletSize
|
|
|
|
|
// player.force.x -= KNOCK * Math.cos(dir)
|
|
|
|
|
// player.force.y -= KNOCK * Math.sin(dir) * 0.3 //reduce knock back in vertical direction to stop super jumps
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// name: "triboelectricty", //14
|
|
|
|
|
// description: "release <strong>particles</strong> that quickly seek out targets",
|
|
|
|
|
// ammo: 0,
|
|
|
|
|
// ammoPack: 40,
|
|
|
|
|
// have: false,
|
|
|
|
|
// isStarterGun: true,
|
|
|
|
|
// fire() {
|
|
|
|
|
// const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
|
|
|
|
// const me = bullet.length;
|
|
|
|
|
// const RADIUS = 6 * b.modBulletSize
|
|
|
|
|
// bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS, {
|
|
|
|
|
// angle: dir,
|
|
|
|
|
// inertia: Infinity,
|
|
|
|
|
// // friction: 0.05,
|
|
|
|
|
// // frictionAir: 0.05,
|
|
|
|
|
// restitution: 0.8,
|
|
|
|
|
// dmg: 0.14 + b.modExtraDmg, //damage done in addition to the damage from momentum
|
|
|
|
|
// lookFrequency: 3,
|
|
|
|
|
// endCycle: game.cycle + Math.floor(120 * b.isModBulletsLastLonger),
|
|
|
|
|
// classType: "bullet",
|
|
|
|
|
// collisionFilter: {
|
|
|
|
|
// category: 0x000100,
|
|
|
|
|
// mask: 0x010111 //self collide
|
|
|
|
|
// },
|
|
|
|
|
// minDmgSpeed: 0,
|
|
|
|
|
// lockedOn: null,
|
|
|
|
|
// isFollowMouse: true,
|
|
|
|
|
// onDmg() {
|
|
|
|
|
// this.endCycle = 0;
|
|
|
|
|
// },
|
|
|
|
|
// onEnd() {},
|
|
|
|
|
// do() {
|
|
|
|
|
// if (this.lockedOn) { //accelerate towards mobs
|
|
|
|
|
// this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * 0.01)
|
|
|
|
|
// Matter.Body.setVelocity(this, {
|
|
|
|
|
// x: this.velocity.x * 0.93,
|
|
|
|
|
// y: this.velocity.y * 0.93
|
|
|
|
|
// });
|
|
|
|
|
// } else {
|
|
|
|
|
// this.force.y += this.mass * 0.0004;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
|
|
|
|
|
// b.fireProps(mech.crouch ? 19 : 15, mech.crouch ? 45 : 30, dir, me); //cd , speed
|
|
|
|
|
// b.drawOneBullet(bullet[me].vertices);
|
|
|
|
|
|
|
|
|
|
// //find mob targets
|
|
|
|
|
// let closeDist = Infinity;
|
|
|
|
|
// for (let i = 0, len = mob.length; i < len; ++i) {
|
|
|
|
|
// if (
|
|
|
|
|
// Matter.Query.ray(map, bullet[me].position, mob[i].position).length === 0 &&
|
|
|
|
|
// Matter.Query.ray(body, bullet[me].position, mob[i].position).length === 0
|
|
|
|
|
// ) {
|
|
|
|
|
// const TARGET_VECTOR = Matter.Vector.sub(bullet[me].position, mob[i].position)
|
|
|
|
|
// const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
|
|
|
|
// if (DIST < closeDist) {
|
|
|
|
|
// closeDist = DIST;
|
|
|
|
|
// bullet[me].lockedOn = mob[i]
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
// {
|
|
|
|
|
// //draw a halo, since there will only be 1-3 balls
|
|
|
|
|
// name: "junk-bots", //14
|
|
|
|
|
// description: "release unreliable <strong>drones</strong> that defend the space around the player<br><strong>collisions</strong> may cause <span class='color-d'>malfunction</span>",
|
|
|
|
|
// ammo: 0,
|
|
|
|
|
// ammoPack: 15,
|
|
|
|
|
// have: false,
|
|
|
|
|
// isStarterGun: false,
|
|
|
|
|
// fire() {
|
|
|
|
|
// const THRUST = 0.004
|
|
|
|
|
// const dir = mech.angle + 0.2 * (Math.random() - 0.5);
|
|
|
|
|
// const me = bullet.length;
|
|
|
|
|
// const RADIUS = (15 + 8 * Math.random()) * b.modBulletSize
|
|
|
|
|
// const LENGTH = 0.6 + 0.8 * Math.random()
|
|
|
|
|
|
|
|
|
|
// bullet[me] = Bodies.rectangle(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), RADIUS * LENGTH, RADIUS / LENGTH, {
|
|
|
|
|
// isOrb: true,
|
|
|
|
|
// angle: dir,
|
|
|
|
|
// // inertia: Infinity,
|
|
|
|
|
// // friction: 0,
|
|
|
|
|
// density: 0.001, //normal is 0.001
|
|
|
|
|
// frictionAir: 0.06,
|
|
|
|
|
// restitution: 0.8,
|
|
|
|
|
// dmg: b.modExtraDmg, // 0.14 //damage done in addition to the damage from momentum
|
|
|
|
|
// minDmgSpeed: 2,
|
|
|
|
|
// lookFrequency: 7 + Math.floor(17 * Math.random()),
|
|
|
|
|
// endCycle: game.cycle + Math.floor((200 + 60 * Math.random()) * b.isModBulletsLastLonger),
|
|
|
|
|
// classType: "bullet",
|
|
|
|
|
// collisionFilter: {
|
|
|
|
|
// category: 0x000100,
|
|
|
|
|
// mask: 0x010111 //self, mob,map,body collide
|
|
|
|
|
// },
|
|
|
|
|
// range: 300,
|
|
|
|
|
// lockedOn: null,
|
|
|
|
|
// onDmg() {
|
|
|
|
|
// this.lockedOn = null
|
|
|
|
|
// // this.endCycle -= 120; //lose 2 seconds after damage is done
|
|
|
|
|
// },
|
|
|
|
|
// onEnd() {},
|
|
|
|
|
// do() {
|
|
|
|
|
// if (game.cycle + 120 > this.endCycle) { //fall and die
|
|
|
|
|
// this.force.y += this.mass * 0.0012;
|
|
|
|
|
// } else {
|
|
|
|
|
// if (!(game.cycle % this.lookFrequency)) {
|
|
|
|
|
// this.lockedOn = null;
|
|
|
|
|
// let closeDist = Infinity;
|
|
|
|
|
// for (let i = 0, len = mob.length; i < len; ++i) {
|
|
|
|
|
// const TARGET_VECTOR = Matter.Vector.sub(mech.pos, mob[i].position)
|
|
|
|
|
// const DIST = Matter.Vector.magnitude(TARGET_VECTOR);
|
|
|
|
|
// // DIST - mob[i].radius < this.range &&
|
|
|
|
|
// if (DIST < closeDist && Matter.Query.ray(map, this.position, mob[i].position).length === 0) {
|
|
|
|
|
// closeDist = DIST;
|
|
|
|
|
// this.lockedOn = mob[i]
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// const distanceToPlayer = Matter.Vector.magnitude(Matter.Vector.sub(this.position, mech.pos))
|
|
|
|
|
// if (this.lockedOn) { //accelerate towards mobs
|
|
|
|
|
// this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, this.lockedOn.position)), -this.mass * THRUST)
|
|
|
|
|
// this.frictionAir = 0.06
|
|
|
|
|
// } else if (distanceToPlayer > 100) {
|
|
|
|
|
// this.force = Matter.Vector.mult(Matter.Vector.normalise(Matter.Vector.sub(this.position, mech.pos)), -this.mass * THRUST * 0.3)
|
|
|
|
|
// this.frictionAir = 0.02
|
|
|
|
|
// } else { //must be close to player //add some random motion
|
|
|
|
|
// this.frictionAir = 0
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
// })
|
|
|
|
|
// b.fireProps(mech.crouch ? 5 : 10, 15, dir, me); //cd , speed
|
|
|
|
|
// b.drawOneBullet(bullet[me].vertices);
|
|
|
|
|
// }
|
|
|
|
|
// },
|
|
|
|
|
]
|
|
|
|
|
};
|