removed pushbody field effect, flechettes balance, energy drain balance, starting choosemod code

This commit is contained in:
landgreen
2019-12-25 17:03:54 -08:00
parent fabc83b375
commit ccf4912c7d
8 changed files with 118 additions and 105 deletions

View File

@@ -839,41 +839,41 @@ const b = {
}
}
},
{
name: "fléchettes", //3
description: "fire a flight of long range needles",
description: "fire a volley of <strong>precise</strong> high velocity needles",
ammo: 0,
ammoPack: 16,
ammoPack: 60,
have: false,
isStarterGun: true,
count: 0, //used to track how many shots are in a volley before a big CD
lastFireCycle: 0, //use to remember how longs its been since last fire, used to reset count
fire() {
mech.fireCDcycle = mech.cycle + Math.floor(40 * b.modFireRate); // cool down
const CD = (mech.crouch) ? 35 : 25
if (this.lastFireCycle + CD < mech.cycle) this.count = 0 //reset count if it cycles past the CD
this.lastFireCycle = mech.cycle
function spawnFlechette(dir = mech.angle, speed, size = 1) {
const me = bullet.length;
bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(dir), mech.pos.y + 40 * Math.sin(dir), 32 * size * b.modBulletSize, 0.8 * size * b.modBulletSize, b.fireAttributes(dir));
bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
bullet[me].dmg = 0.13 * size + b.modExtraDmg;
bullet[me].do = function () {
this.force.y += this.mass * 0.0002; //low gravity
};
Matter.Body.setVelocity(bullet[me], {
x: mech.Vx / 2 + speed * Math.cos(dir),
y: mech.Vy / 2 + speed * Math.sin(dir)
});
World.add(engine.world, bullet[me]); //add bullet to world
}
if (mech.crouch) {
for (let i = 0; i < 3; i++) {
spawnFlechette(mech.angle + 0.02 * (Math.random() - 0.5), 50 + 4 * i, 1.55)
}
if (this.count > ((mech.crouch) ? 4 : 1)) {
this.count = 0
mech.fireCDcycle = mech.cycle + Math.floor(CD * b.modFireRate); // cool down
} else {
for (let i = 0; i < 8; i++) {
spawnFlechette(mech.angle + 0.12 * (Math.random() - 0.5), 43 + 8 * Math.random())
}
this.count++
mech.fireCDcycle = mech.cycle + Math.floor(2 * b.modFireRate); // cool down
}
const me = bullet.length;
bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 50 * b.modBulletSize, 1.3 * b.modBulletSize, b.fireAttributes(mech.angle));
bullet[me].endCycle = game.cycle + Math.floor(180 * b.isModBulletsLastLonger);
bullet[me].dmg = 0.7 + b.modExtraDmg;
bullet[me].do = function () {
this.force.y += this.mass * 0.0002; //low gravity
};
const SPEED = 45
Matter.Body.setVelocity(bullet[me], {
x: mech.Vx / 2 + SPEED * Math.cos(mech.angle),
y: mech.Vy / 2 + SPEED * Math.sin(mech.angle)
});
World.add(engine.world, bullet[me]); //add bullet to world
}
},
{
@@ -1289,7 +1289,7 @@ const b = {
bullet[me].endCycle = 2 * i + game.cycle + END
bullet[me].restitution = 0;
bullet[me].friction = 1;
bullet[me].explodeRad = (mech.crouch ? 70 : 50) + (Math.random() - 0.5) * 50;
bullet[me].explodeRad = (mech.crouch ? 85 : 60) + (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
@@ -1517,9 +1517,9 @@ const b = {
const me = bullet.length;
const dir = mech.angle;
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 20, 4.5, b.fireAttributes(dir, false));
b.fireProps(mech.crouch ? 65 : 45, mech.crouch ? 28 : 14, dir, me); //cd , speed
b.fireProps(mech.crouch ? 60 : 40, mech.crouch ? 28 : 14, dir, me); //cd , speed
Matter.Body.setDensity(bullet[me], 0.000001);
bullet[me].endCycle = game.cycle + 100;
bullet[me].endCycle = game.cycle + 80;
bullet[me].frictionAir = 0;
bullet[me].friction = 0.5;
bullet[me].restitution = 0.3;
@@ -1527,7 +1527,7 @@ const b = {
bullet[me].onDmg = function () {};
bullet[me].do = function () {
if (!mech.isBodiesAsleep) {
const SCALE = 1.017
const SCALE = 1.022
Matter.Body.scale(this, SCALE, SCALE);
this.frictionAir += 0.00023;
}
@@ -1611,7 +1611,7 @@ const b = {
}
if (this.lockedOn && this.lockedOn.alive && mech.fieldMeter > 0.15) { //hit target with laser
mech.fieldMeter -= 0.0016
mech.fieldMeter -= 0.001
//make sure you can still see target
const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position));
@@ -1941,7 +1941,7 @@ const b = {
name: "foam", //16
description: "spray bubbly foam that <strong>sticks</strong> to enemies<br>does <strong class='color-d'>damage</strong> over time and <strong>slows</strong> movement",
ammo: 0,
ammoPack: 90,
ammoPack: 100,
have: false,
isStarterGun: true,
fire() {

View File

@@ -82,6 +82,25 @@ game mechanics
*/
//find what mods I don't have
function doNotHave(who) {
let options = [];
for (let i = 0; i < who.length; i++) {
if (!who[i].have) options.push(i);
}
if (options.length > 0) return options[Math.floor(Math.random() * options.length)]
}
//give a random mod from the mods I don't have
let newMod = doNotHave(b.mods)
let t = ""
for (let i = 0; i < 3; i++) {
t += `<div class="choose-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div> ${b.mods[i].description}</div>`
}
// document.getElementById("choose-grid").innerHTML = t
//collision groups
// cat.player | cat.map | cat.body | cat.bullet | cat.powerUp | cat.mob | cat.mobBullet | cat.mobShield

View File

@@ -14,7 +14,7 @@ const level = {
start() {
if (level.levelsCleared === 0) {
// game.difficulty = 6; //for testing to simulate possible mobs spawns
// b.giveGuns(16)
// b.giveGuns(3)
// mech.fieldUpgrades[2].effect();
// b.giveMod(21)

View File

@@ -269,7 +269,7 @@ const mobs = {
// ctx.lineDashOffset = 6*(game.cycle % 215);
if (this.distanceToPlayer() < this.laserRange && !mech.isStealth) {
mech.damage(0.0003 * game.dmgScale);
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.004
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.003
ctx.beginPath();
ctx.moveTo(this.position.x, this.position.y);
ctx.lineTo(mech.pos.x, mech.pos.y);

View File

@@ -927,31 +927,31 @@ const mech = {
}
}
},
pushBodyFacing() { // push all body in range and in direction looking
for (let i = 0, len = body.length; i < len; ++i) {
if (
body[i].speed > 12 && body[i].mass > 2 &&
Vector.magnitude(Vector.sub(body[i].position, mech.pos)) < mech.grabRange &&
mech.lookingAt(body[i]) &&
Matter.Query.ray(map, body[i].position, mech.pos).length === 0
) {
mech.pushMass(body[i]);
}
}
},
pushBody360(range = mech.grabRange * 0.75) { // push all body in range and in direction looking
for (let i = 0, len = body.length; i < len; ++i) {
if (
body[i].speed > 12 && body[i].mass > 2 &&
Vector.magnitude(Vector.sub(body[i].position, mech.pos)) < range &&
mech.lookingAt(body[i]) &&
Matter.Query.ray(map, body[i].position, mech.pos).length === 0 &&
body[i].collisionFilter.category === cat.body
) {
mech.pushMass(body[i]);
}
}
},
// pushBodyFacing() { // push all body in range and in direction looking
// for (let i = 0, len = body.length; i < len; ++i) {
// if (
// body[i].speed > 12 && body[i].mass > 2 &&
// Vector.magnitude(Vector.sub(body[i].position, mech.pos)) < mech.grabRange &&
// mech.lookingAt(body[i]) &&
// Matter.Query.ray(map, body[i].position, mech.pos).length === 0
// ) {
// mech.pushMass(body[i]);
// }
// }
// },
// pushBody360(range = mech.grabRange * 0.75) { // push all body in range and in direction looking
// for (let i = 0, len = body.length; i < len; ++i) {
// if (
// body[i].speed > 12 && body[i].mass > 2 &&
// Vector.magnitude(Vector.sub(body[i].position, mech.pos)) < range &&
// mech.lookingAt(body[i]) &&
// Matter.Query.ray(map, body[i].position, mech.pos).length === 0 &&
// body[i].collisionFilter.category === cat.body
// ) {
// mech.pushMass(body[i]);
// }
// }
// },
lookForPickUp(range = mech.grabRange) { //find body to pickup
mech.fieldMeter -= mech.fieldRegen;
const grabbing = {
@@ -1057,7 +1057,6 @@ const mech = {
mech.drawField();
mech.grabPowerUp();
mech.lookForPickUp();
mech.pushBodyFacing();
mech.pushMobsFacing();
} else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released
mech.pickUp();
@@ -1461,7 +1460,6 @@ const mech = {
mech.grabPowerUp();
mech.lookForPickUp();
mech.pushMobsFacing();
mech.pushBodyFacing();
} else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle && mech.fieldMeter > 0.05) { //holding, but field button is released
mech.pickUp();
} else {

View File

@@ -444,8 +444,7 @@ const spawn = {
//when player is inside event horizon
if (Vector.magnitude(Vector.sub(this.position, player.position)) < eventHorizon && !mech.isStealth) {
mech.damage(0.00015 * game.dmgScale);
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.007
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.0045
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x);
player.force.x -= 1.25 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.8 : 1);
player.force.y -= 0.96 * player.mass * game.g * Math.sin(angle);
@@ -534,7 +533,7 @@ const spawn = {
//when player is inside event horizon
if (Vector.magnitude(Vector.sub(this.position, player.position)) < eventHorizon && !mech.isStealth) {
mech.damage(0.00015 * game.dmgScale);
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.007
if (mech.fieldMeter > 0.1) mech.fieldMeter -= 0.0045
const angle = Math.atan2(player.position.y - this.position.y, player.position.x - this.position.x);
player.force.x -= 1.3 * Math.cos(angle) * player.mass * game.g * (mech.onGround ? 1.7 : 1);
player.force.y -= 1.2 * Math.sin(angle) * player.mass * game.g;