grav and stealth field balance

This commit is contained in:
landgreen
2019-10-03 06:08:54 -07:00
parent 498157a183
commit 9ff5746afe
3 changed files with 32 additions and 40 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[4]() //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

@@ -98,13 +98,11 @@ const mobs = {
}, },
seePlayerFreq: 20 + Math.round(Math.random() * 20), //how often NPC checks to see where player is, lower numbers have better vision seePlayerFreq: 20 + Math.round(Math.random() * 20), //how often NPC checks to see where player is, lower numbers have better vision
foundPlayer() { foundPlayer() {
if (!mech.isStealth) {
this.locatePlayer(); this.locatePlayer();
if (!this.seePlayer.yes) { if (!this.seePlayer.yes) {
this.alertNearByMobs(); this.alertNearByMobs();
this.seePlayer.yes = true; this.seePlayer.yes = true;
} }
}
}, },
lostPlayer() { lostPlayer() {
this.seePlayer.yes = false; this.seePlayer.yes = false;
@@ -113,16 +111,18 @@ const mobs = {
}, },
memory: 120, //default time to remember player's location memory: 120, //default time to remember player's location
locatePlayer() { locatePlayer() {
if (!mech.isStealth) {
// updates mob's memory of player location // updates mob's memory of player location
this.seePlayer.recall = this.memory + Math.round(this.memory * Math.random()); //seconds before mob falls a sleep this.seePlayer.recall = this.memory + Math.round(this.memory * Math.random()); //seconds before mob falls a sleep
this.seePlayer.position.x = player.position.x; this.seePlayer.position.x = player.position.x;
this.seePlayer.position.y = player.position.y; this.seePlayer.position.y = player.position.y;
},
locatePlayerByDist() {
if (this.distanceToPlayer2() < this.locateRange) {
this.locatePlayer();
} }
}, },
// locatePlayerByDist() {
// if (this.distanceToPlayer2() < this.locateRange) {
// this.locatePlayer();
// }
// },
seePlayerCheck() { seePlayerCheck() {
if (!(game.cycle % this.seePlayerFreq)) { if (!(game.cycle % this.seePlayerFreq)) {
if ( if (

View File

@@ -973,7 +973,7 @@ const mech = {
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<br> <span style='color:#a00;'>decreased</span> field shielding efficiency</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<br> <span style='color:#a00;'>decreased</span> field shielding efficiency</p>", 1200);
mech.setHoldDefaults(); mech.setHoldDefaults();
mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping mech.holdingMassScale = 0.05; //can hold heavier blocks with lower cost to jumping
mech.fieldShieldingScale = 20; mech.fieldShieldingScale = 4;
// mech.fieldArc = 1; //field covers full 360 degrees // mech.fieldArc = 1; //field covers full 360 degrees
// mech.grabRange = 150; // mech.grabRange = 150;
// mech.fieldArc = 1 //0.08; // mech.fieldArc = 1 //0.08;
@@ -1007,29 +1007,20 @@ const mech = {
// zeroG(bullet); //works fine, but not that noticeable and maybe not worth the possible performance hit // zeroG(bullet); //works fine, but not that noticeable and maybe not worth the possible performance hit
// zeroG(mob); //mobs are too irregular to make this work? // 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 -= 0.0009 + player.mass * mech.gravity; //constant upward drift
Matter.Body.setVelocity(player, {
//allow player to fly up and down a bit
flyForce = 0.003;
if (keys[83] || keys[40]) { //down
player.force.y += flyForce
Matter.Body.setVelocity(player, { //friction, only when flying
x: player.velocity.x, x: player.velocity.x,
y: player.velocity.y * 0.97 y: player.velocity.y * 0.97
}); });
} else if (keys[87] || keys[38]) { //up
player.force.y -= flyForce if (keys[83] || keys[40]) { //down
Matter.Body.setVelocity(player, { //friction, only when flying player.force.y += 0.003
x: player.velocity.x,
y: player.velocity.y * 0.95
});
// mech.fieldMeter -= DRAIN; //extra energy used to fly upwards
} }
//add extra friction for horizontal motion //add extra friction for horizontal motion
if (keys[65] || keys[68] || keys[37] || keys[39]) { if (keys[65] || keys[68] || keys[37] || keys[39]) {
Matter.Body.setVelocity(player, { Matter.Body.setVelocity(player, {
x: player.velocity.x * 0.95, x: player.velocity.x * 0.88,
y: player.velocity.y y: player.velocity.y
}); });
} }
@@ -1128,9 +1119,10 @@ const mech = {
}, },
() => { () => {
mech.fieldMode = 6; mech.fieldMode = 6;
game.makeTextLog("<strong style='font-size:30px;'>Metamaterial Refractive Optics</strong><br> (right mouse or space bar) <p>localized invisibility field<br> greatly <span style='color:#a00;'>decreased</span> field shielding efficiency</p>", 1200); game.makeTextLog("<strong style='font-size:30px;'>Metamaterial Refractive Optics</strong><br> (right mouse or space bar) <p>player is invisible while field is active.<br> <span style='color:#a00;'>decreased</span> field shielding efficiency</p>", 1200);
// <br>player <span style='color:#a00;'>can't see</span> while field is active</p>", 1200);
mech.setHoldDefaults(); mech.setHoldDefaults();
mech.fieldShieldingScale = 10; mech.fieldShieldingScale = 5;
// mech.grabRange = 160; // mech.grabRange = 160;
mech.hold = function () { mech.hold = function () {
@@ -1141,14 +1133,15 @@ const mech = {
mech.holding(); mech.holding();
mech.throw(); mech.throw();
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) { } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < game.cycle) {
const DRAIN = 0.0003 //mech.fieldRegen = 0.0015 const DRAIN = 0.0002 //mech.fieldRegen = 0.0015
if (mech.fieldMeter > DRAIN) { if (mech.fieldMeter > DRAIN) {
mech.fieldMeter -= DRAIN; mech.fieldMeter -= DRAIN;
mech.isStealth = true //isStealth is checked in mob foundPlayer()
if (mech.crouch) { if (mech.crouch) {
mech.grabRange = mech.grabRange * 0.96 + 240 * 0.04; mech.grabRange = mech.grabRange * 0.96 + 360 * 0.04;
} else { } else {
mech.grabRange = mech.grabRange * 0.96 + 160 * 0.04; mech.grabRange = mech.grabRange * 0.96 + 180 * 0.04;
} }
ctx.beginPath(); ctx.beginPath();
@@ -1160,9 +1153,8 @@ const mech = {
ctx.fillStyle = `rgba(0,30,50,${0.5+0.07*Math.random()})` //"rgba(210,230," + HUE + ",0.5)"; ctx.fillStyle = `rgba(0,30,50,${0.5+0.07*Math.random()})` //"rgba(210,230," + HUE + ",0.5)";
ctx.fill(); ctx.fill();
mech.isStealth = false //isStealth is checked in mob foundPlayer() // mech.isStealth = false //isStealth is checked in mob foundPlayer()
mech.pushMobs360(130); mech.pushMobs360(150);
mech.isStealth = true //isStealth is checked in mob foundPlayer()
mech.grabPowerUp(); mech.grabPowerUp();
mech.lookForPickUp(); mech.lookForPickUp();
} else { } else {