field balance

This commit is contained in:
landgreen
2019-09-25 06:46:12 -07:00
parent f226965a6c
commit 26df511b76
2 changed files with 30 additions and 28 deletions

View File

@@ -24,7 +24,7 @@ const level = {
// game.levelsCleared = 3; //for testing to simulate possible mobs spawns // game.levelsCleared = 3; //for testing to simulate possible mobs spawns
// b.giveGuns(0) // set a starting gun for testing // b.giveGuns(0) // set a starting gun for testing
mech.fieldUpgrades[7]() //give a field power up for testing mech.fieldUpgrades[3]() //give a field power up for testing
} else { } else {
spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
this[this.levels[this.onLevel]](); //picks the current map from the the levels array this[this.levels[this.onLevel]](); //picks the current map from the the levels array

View File

@@ -818,7 +818,8 @@ const mech = {
}, },
() => { () => {
mech.fieldMode = 1; mech.fieldMode = 1;
game.makeTextLog("<strong style='font-size:30px;'>Time Dilation Field</strong><br> (right mouse or space bar)<p> field slows objects in range<br> field does <span style='color:#a00;'>not</span> shield player</p>", 1200); game.makeTextLog("<strong style='font-size:30px;'>Time Dilation Field</strong><br> (right mouse or space bar)<p> field slows objects in range</p>", 1200);
// <br> field does <span style='color:#a00;'>not</span> shield player
mech.setHoldDefaults(); mech.setHoldDefaults();
mech.fieldArc = 1; //field covers full 360 degrees mech.fieldArc = 1; //field covers full 360 degrees
mech.calculateFieldThreshold(); mech.calculateFieldThreshold();
@@ -924,11 +925,11 @@ const mech = {
}, },
() => { () => {
mech.fieldMode = 3; mech.fieldMode = 3;
game.makeTextLog("<strong style='font-size:30px;'>Negative Mass Field</strong><br> (right mouse or space bar)<p> nullifies gravity around player<br> can hold more massive objects<br> field does <span style='color:#a00;'>not</span> shield player</p>", 1200); game.makeTextLog("<strong style='font-size:30px;'>Negative Mass Field</strong><br> (right mouse or space bar)<p> field nullifies gravity<br> player can hold more massive objects</p>", 1200);
mech.setHoldDefaults(); mech.setHoldDefaults();
mech.holdingMassScale = 0.05; //can hold heavier blocks mech.holdingMassScale = 0.05; //can hold heavier blocks
// mech.fieldArc = 1; //field covers full 360 degrees // mech.fieldArc = 1; //field covers full 360 degrees
mech.grabRange = 150; mech.grabRange = 160;
mech.fieldArc = 0.1; mech.fieldArc = 0.1;
mech.calculateFieldThreshold(); mech.calculateFieldThreshold();
@@ -939,7 +940,7 @@ const mech = {
mech.holding(); mech.holding();
mech.throw(); mech.throw();
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //push away } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { //push away
const DRAIN = 0.0025 //mech.fieldRegen = 0.0015 const DRAIN = 0.002 //mech.fieldRegen = 0.0015
if (mech.fieldMeter > DRAIN) { if (mech.fieldMeter > DRAIN) {
mech.fieldMeter -= DRAIN; mech.fieldMeter -= DRAIN;
mech.grabPowerUp(); mech.grabPowerUp();
@@ -950,12 +951,13 @@ const mech = {
sub = Matter.Vector.sub(who[i].position, mech.pos); sub = Matter.Vector.sub(who[i].position, mech.pos);
dist = Matter.Vector.magnitude(sub); dist = Matter.Vector.magnitude(sub);
if (dist < range) { if (dist < range) {
who[i].force.y -= who[i].mass * game.g; who[i].force.y -= who[i].mass * (game.g * 1.03); //add a bit more then standard gravity
} }
} }
} }
// zeroG(powerUp); /no point to zero G power ups because the field just sucks them in. zeroG(powerUp);
zeroG(body); zeroG(body);
// zeroG(mob); //mobs are too irregular to make this work?
player.force.y -= player.mass * mech.gravity; // + 0.005 * Math.sin(game.cycle / 10); //wobble player.force.y -= player.mass * mech.gravity; // + 0.005 * Math.sin(game.cycle / 10); //wobble
@@ -975,7 +977,6 @@ const mech = {
mech.drawField(); mech.drawField();
mech.pushMobs(); mech.pushMobs();
} else { } else {
//trigger cool down //trigger cool down
mech.fieldCDcycle = game.cycle + 120; mech.fieldCDcycle = game.cycle + 120;
@@ -1111,11 +1112,12 @@ const mech = {
}, },
() => { () => {
mech.fieldMode = 7; mech.fieldMode = 7;
game.makeTextLog("<strong style='font-size:30px;'>Thermal Radiation Field</strong><br> (right mouse or space bar) <p>field damages all targets within range, <span style='color:#a00;'>including player</span><br>field does <span style='color:#a00;'>not</span> shield player</p>", 1200); game.makeTextLog("<strong style='font-size:30px;'>Thermal Radiation Field</strong><br> (right mouse or space bar) <p>field size grows while field is active<br>damages all targets within range, <span style='color:#a00;'>including player</span></p>", 1200);
// <br>field does <span style='color:#a00;'>not</span> shield player</br>
// game.makeTextLog("<strong style='font-size:30px;'>Thermal Radiation Field</strong><br> (right mouse or space bar) <p>field damages and pushes all targets within range<br> <span style='color:#a00;'>field damages player</span><br>field does <span style='color:#a00;'>not</span> shield player</p>", 1200); // game.makeTextLog("<strong style='font-size:30px;'>Thermal Radiation Field</strong><br> (right mouse or space bar) <p>field damages and pushes all targets within range<br> <span style='color:#a00;'>field damages player</span><br>field does <span style='color:#a00;'>not</span> shield player</p>", 1200);
mech.setHoldDefaults(); mech.setHoldDefaults();
mech.grabRange = 160; // mech.grabRange = 160;
mech.fieldArc = 0.11; //0.2 is normal mech.fieldArc = 1; //0.2 is normal
mech.rangeSmoothing = 0 mech.rangeSmoothing = 0
// mech.fieldRegen = 0.0008 //0.0015; // mech.fieldRegen = 0.0008 //0.0015;
mech.hold = function () { mech.hold = function () {
@@ -1126,17 +1128,17 @@ const mech = {
} else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < game.cycle)) { //not hold but field button is pressed } else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < game.cycle)) { //not hold but field button is pressed
mech.grabPowerUp(); mech.grabPowerUp();
mech.lookForPickUp(); mech.lookForPickUp();
//draw grab field // //draw grab field
ctx.beginPath(); // ctx.beginPath();
ctx.arc(this.pos.x, this.pos.y, this.grabRange - 20, this.angle - Math.PI * this.fieldArc, this.angle + Math.PI * this.fieldArc, false); // ctx.arc(this.pos.x, this.pos.y, this.grabRange - 20, this.angle - Math.PI * this.fieldArc, this.angle + Math.PI * this.fieldArc, false);
let EYE_RADIUS = 13; // let EYE_RADIUS = 13;
ctx.lineTo(mech.pos.x + EYE_RADIUS * Math.cos(this.angle), mech.pos.y + EYE_RADIUS * Math.sin(this.angle)); // ctx.lineTo(mech.pos.x + EYE_RADIUS * Math.cos(this.angle), mech.pos.y + EYE_RADIUS * Math.sin(this.angle));
if (this.holdingTarget) { // if (this.holdingTarget) {
ctx.fillStyle = "rgba(150,150,150," + (0.05 + 0.1 * Math.random()) + ")"; // ctx.fillStyle = "rgba(150,150,150," + (0.05 + 0.1 * Math.random()) + ")";
} else { // } else {
ctx.fillStyle = "rgba(150,150,150," + (0.15 + 0.15 * Math.random()) + ")"; // ctx.fillStyle = "rgba(150,150,150," + (0.15 + 0.15 * Math.random()) + ")";
} // }
ctx.fill(); // ctx.fill();
if (mech.health > 0.1) { if (mech.health > 0.1) {
const DRAIN = 0.0011 //mech.fieldRegen = 0.0015 const DRAIN = 0.0011 //mech.fieldRegen = 0.0015
@@ -1145,13 +1147,13 @@ const mech = {
mech.damage(0.0001) mech.damage(0.0001)
//draw damage field //draw damage field
mech.rangeSmoothing = mech.rangeSmoothing * 0.997 + (1350 + 60 * Math.cos(game.cycle / 20)) * 0.003 mech.grabRange = mech.grabRange * 0.997 + (1350 + 150 * Math.cos(game.cycle / 30)) * 0.003
let gradient = ctx.createRadialGradient(this.pos.x, this.pos.y, 0, this.pos.x, this.pos.y, mech.rangeSmoothing); let gradient = ctx.createRadialGradient(this.pos.x, this.pos.y, 0, this.pos.x, this.pos.y, mech.grabRange);
gradient.addColorStop(0, 'rgba(255,255,255,0)'); gradient.addColorStop(0, 'rgba(255,255,255,0)');
gradient.addColorStop(1, 'rgba(255,0,50,0.5)'); gradient.addColorStop(1, 'rgba(255,0,50,0.5)');
// gradient.addColorStop(1, 'rgba(255,0,0,0.05)'); // gradient.addColorStop(1, 'rgba(255,0,0,0.05)');
ctx.beginPath(); ctx.beginPath();
ctx.arc(this.pos.x, this.pos.y, mech.rangeSmoothing, 0, 2 * Math.PI); ctx.arc(this.pos.x, this.pos.y, mech.grabRange, 0, 2 * Math.PI);
ctx.fillStyle = gradient //rgba(255,0,0,0.2) ctx.fillStyle = gradient //rgba(255,0,0,0.2)
ctx.fill(); ctx.fill();
@@ -1160,7 +1162,7 @@ const mech = {
if (mob[i].alive) { if (mob[i].alive) {
sub = Matter.Vector.sub(this.pos, mob[i].position); sub = Matter.Vector.sub(this.pos, mob[i].position);
dist = Matter.Vector.magnitude(sub); dist = Matter.Vector.magnitude(sub);
if (dist < mech.rangeSmoothing) { if (dist < mech.grabRange) {
mob[i].damage(0.01); mob[i].damage(0.01);
mob[i].locatePlayer(); mob[i].locatePlayer();
// mech.fieldMeter -= DRAIN * 0.1; //extra drain for each additional target // mech.fieldMeter -= DRAIN * 0.1; //extra drain for each additional target
@@ -1174,10 +1176,10 @@ const mech = {
} }
} }
} else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released } else if (mech.holdingTarget && mech.fireCDcycle < game.cycle) { //holding, but field button is released
mech.rangeSmoothing = 0 mech.grabRange = 0
mech.pickUp(); mech.pickUp();
} else { } else {
mech.rangeSmoothing = 0 mech.grabRange = 0
mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists) mech.holdingTarget = null; //clears holding target (this is so you only pick up right after the field button is released and a hold target exists)
} }
mech.drawFieldMeter() mech.drawFieldMeter()