difficulty bug fix

This commit is contained in:
landgreen
2020-10-06 05:01:59 -07:00
parent 0d2a570ebd
commit b2cb88832c
6 changed files with 94 additions and 49 deletions

View File

@@ -1837,6 +1837,84 @@ const b = {
} }
mech.fireCDcycle = mech.cycle + Math.floor(CD * b.fireCD); // cool down mech.fireCDcycle = mech.cycle + Math.floor(CD * b.fireCD); // cool down
// const range = 2000
// const totalBullets = 6
// const angleStep = (mech.crouch ? 0.06 : 0.25) / totalBullets
// let dir = mech.angle - angleStep * totalBullets / 2;
// for (let i = 0; i < totalBullets; i++) {
// dir += angleStep
// 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 path = [{
// x: mech.pos.x,
// y: mech.pos.y
// },
// {
// x: mech.pos.x + range * Math.cos(dir),
// y: mech.pos.y + range * Math.sin(dir)
// }
// ];
// let 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);
// if (best.dist2 !== Infinity) { //if hitting something
// b.explosion({
// x: best.x,
// y: best.y
// }, (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50);
// } else {
// b.explosion(path[path.length - 1], (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50);
// }
// }
const speed = 30 + 6 * Math.random() + 9 * mod.nailInstantFireRate const speed = 30 + 6 * Math.random() + 9 * mod.nailInstantFireRate
const angle = mech.angle + (Math.random() - 0.5) * (Math.random() - 0.5) * (mech.crouch ? 1.35 : 3.2) / CD const angle = mech.angle + (Math.random() - 0.5) * (Math.random() - 0.5) * (mech.crouch ? 1.35 : 3.2) / CD
const dmg = 0.9 const dmg = 0.9
@@ -1856,35 +1934,6 @@ const b = {
mech.energy -= mech.fieldRegen + 0.008 mech.energy -= mech.fieldRegen + 0.008
if (mech.energy < 0.02) mech.fireCDcycle = mech.cycle + 60; // cool down if (mech.energy < 0.02) mech.fireCDcycle = mech.cycle + 60; // cool down
} }
// } else {
// if (this.nextFireCycle + 1 < mech.cycle) this.startingHoldCycle = mech.cycle //reset if not constantly firing
// const CD = Math.max(11 - 0.06 * (mech.cycle - this.startingHoldCycle), 2) //CD scales with cycles fire is held down
// this.nextFireCycle = mech.cycle + CD * b.fireCD //predict next fire cycle if the fire button is held down
// const me = bullet.length;
// const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.01 : 0.1);
// bullet[me] = Bodies.rectangle(pos.x, pos.y, 20 * mod.bulletSize, 6 * mod.bulletSize, b.fireAttributes(dir));
// b.fireProps(CD, mech.crouch ? 38 : 34, dir, me); //cd , speed
// bullet[me].endCycle = game.cycle + 70;
// bullet[me].dmg = 0.25;
// bullet[me].frictionAir = mech.crouch ? 0.001 : 0.003;
// if (mod.isIceCrystals) {
// bullet[me].onDmg = function (who) {
// mobs.statusSlow(who, 30)
// };
// mech.energy -= mech.fieldRegen + 0.0075
// if (mech.energy < 0.02) {
// mech.fireCDcycle = mech.cycle + 60; // cool down
// }
// }
// bullet[me].do = function () {
// this.force.y += this.mass * 0.0003;
// };
// }
} }
}, },
{ {
@@ -2321,7 +2370,6 @@ const b = {
const totalBullets = 6 const totalBullets = 6
const angleStep = (mech.crouch ? 0.06 : 0.25) / totalBullets const angleStep = (mech.crouch ? 0.06 : 0.25) / totalBullets
let dir = mech.angle - angleStep * totalBullets / 2; let dir = mech.angle - angleStep * totalBullets / 2;
for (let i = 0; i < totalBullets; i++) { //5 -> 7 for (let i = 0; i < totalBullets; i++) { //5 -> 7
dir += angleStep dir += angleStep
const me = bullet.length; const me = bullet.length;
@@ -2331,7 +2379,6 @@ const b = {
x: (SPEED + 15 * Math.random() - 2 * i) * Math.cos(dir), x: (SPEED + 15 * Math.random() - 2 * i) * Math.cos(dir),
y: (SPEED + 15 * Math.random() - 2 * i) * Math.sin(dir) y: (SPEED + 15 * Math.random() - 2 * i) * Math.sin(dir)
}); });
bullet[me].endCycle = 2 * i + game.cycle + END bullet[me].endCycle = 2 * i + game.cycle + END
bullet[me].restitution = 0; bullet[me].restitution = 0;
bullet[me].friction = 1; bullet[me].friction = 1;
@@ -2343,7 +2390,7 @@ const b = {
this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
}; };
bullet[me].do = function () { bullet[me].do = function () {
this.force.y += this.mass * 0.0004; // this.force.y += this.mass * 0.0004;
} }
} }
} }
@@ -2651,7 +2698,7 @@ const b = {
//aoe damage to mobs //aoe damage to mobs
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < this.damageRadius) { if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < this.damageRadius) {
let dmg = b.dmgScale * 0.023 let dmg = b.dmgScale * 0.025
if (Matter.Query.ray(map, mob[i].position, this.position).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way if (Matter.Query.ray(map, mob[i].position, this.position).length > 0) dmg *= 0.5 //reduce damage if a wall is in the way
if (mob[i].shield) dmg *= 4 //x5 to make up for the /5 that shields normally take if (mob[i].shield) dmg *= 4 //x5 to make up for the /5 that shields normally take
mob[i].damage(dmg); mob[i].damage(dmg);
@@ -2830,10 +2877,10 @@ const b = {
fire() { fire() {
if (mech.crouch) { if (mech.crouch) {
b.drone(45) b.drone(45)
mech.fireCDcycle = mech.cycle + Math.floor(17 * b.fireCD); // cool down mech.fireCDcycle = mech.cycle + Math.floor(13 * b.fireCD); // cool down
} else { } else {
b.drone(1) b.drone(1)
mech.fireCDcycle = mech.cycle + Math.floor(10 * b.fireCD); // cool down mech.fireCDcycle = mech.cycle + Math.floor(6 * b.fireCD); // cool down
} }
} }
}, },
@@ -3239,7 +3286,7 @@ const b = {
mech.energy -= mech.fieldRegen + mod.laserFieldDrain * mod.isLaserDiode mech.energy -= mech.fieldRegen + mod.laserFieldDrain * mod.isLaserDiode
if (mod.isWideLaser) { if (mod.isWideLaser) {
const off = 8 const off = 8
const dmg = 0.4 * mod.laserDamage // 5 * 0.4 = 200% more damage const dmg = 0.55 * mod.laserDamage // 3.5 * 0.55 = 200% more damage
const where = { const where = {
x: mech.pos.x + 20 * Math.cos(mech.angle), x: mech.pos.x + 20 * Math.cos(mech.angle),
y: mech.pos.y + 20 * Math.sin(mech.angle) y: mech.pos.y + 20 * Math.sin(mech.angle)

View File

@@ -659,7 +659,7 @@ const game = {
game.difficultyMode = 1 game.difficultyMode = 1
level.difficultyDecrease(6); //if this stops being -6 change in build.calculateCustomDifficulty() level.difficultyDecrease(6); //if this stops being -6 change in build.calculateCustomDifficulty()
} }
if (game.difficultyMode === 4) level.difficultyIncrease(3) if (game.difficultyMode > 1) level.difficultyIncrease(3)
game.clearNow = true; game.clearNow = true;
document.getElementById("text-log").style.opacity = 0; document.getElementById("text-log").style.opacity = 0;
@@ -844,7 +844,7 @@ const game = {
if (!(mech.cycle % 60)) { //once a second if (!(mech.cycle % 60)) { //once a second
//every second energy above max energy loses 25% //every second energy above max energy loses 25%
if (mech.energy > mech.maxEnergy) mech.energy = 1 + (mech.maxEnergy - mech.energy) * 0.75 if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy + (mech.energy - mech.maxEnergy) * 0.75
if (mech.pos.y > game.fallHeight) { // if 4000px deep if (mech.pos.y > game.fallHeight) { // if 4000px deep
if (game.difficultyMode > 2) { if (game.difficultyMode > 2) {

View File

@@ -10,21 +10,21 @@ const level = {
levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber"], levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber"],
start() { start() {
if (level.levelsCleared === 0) { //this code only runs on the first level if (level.levelsCleared === 0) { //this code only runs on the first level
level.difficultyIncrease(8) // level.difficultyIncrease(8)
// game.enableConstructMode() //used to build maps in testing mode // game.enableConstructMode() //used to build maps in testing mode
// game.zoomScale = 1000; // game.zoomScale = 1000;
// game.setZoom(); // game.setZoom();
// mech.isCloak = true; // mech.isCloak = true;
// mech.setField("perfect diamagnetism") // mech.setField("perfect diamagnetism")
// b.giveGuns("laser") // b.giveGuns("nail gun")
// for (let i = 0; i < 10; i++) { // for (let i = 0; i < 10; i++) {
// mod.giveMod("laser-bot"); // mod.giveMod("laser-bot");
// } // }
// mod.giveMod("eddy current brake") // mod.giveMod("eddy current brake")
level.intro(); //starting level // level.intro(); //starting level
// level.testing(); //not in rotation level.testing(); //not in rotation
// level.template() //not in rotation // level.template() //not in rotation
// level.testChamber() //less mobs, more puzzle // level.testChamber() //less mobs, more puzzle
// level.sewers(); // level.sewers();
@@ -150,12 +150,12 @@ const level = {
// spawn.sniper(1800, -120) // spawn.sniper(1800, -120)
// spawn.sniper(2200, -120) // spawn.sniper(2200, -120)
// spawn.cellBossCulture(1600, -500) // spawn.cellBossCulture(1600, -500)
spawn.starter(1600, -500) // spawn.starter(1600, -500)
// spawn.powerUpBoss(1600, -500) // spawn.powerUpBoss(1600, -500)
// spawn.shield(mob[mob.length - 1], 1200, -500, 1); // spawn.shield(mob[mob.length - 1], 1200, -500, 1);
// spawn.nodeBoss(1200, -500, "launcher") // spawn.nodeBoss(1200, -500, "launcher")
// spawn.spiderBoss(1200, -500) spawn.snakeBoss(1200, -500)
// spawn.timeSkipBoss(2900, -500) // spawn.timeSkipBoss(2900, -500)
// spawn.randomMob(1600, -500) // spawn.randomMob(1600, -500)
}, },

View File

@@ -506,7 +506,7 @@ const powerUps = {
}, },
spawnStartingPowerUps(x, y) { //used for map specific power ups, mostly to give player a starting gun spawnStartingPowerUps(x, y) { //used for map specific power ups, mostly to give player a starting gun
if (level.levelsCleared < 4) { //runs 4 times on all difficulty levels if (level.levelsCleared < 4) { //runs 4 times on all difficulty levels
if (game.difficultyMode === 4 && level.levelsCleared > 1) powerUps.spawn(x, y, "mod") if (game.difficultyMode > 1 && level.levelsCleared > 1) powerUps.spawn(x, y, "mod")
//bonus power ups for clearing runs in the last game //bonus power ups for clearing runs in the last game
if (level.levelsCleared === 0 && !game.isCheating) { if (level.levelsCleared === 0 && !game.isCheating) {

View File

@@ -1984,12 +1984,11 @@ const spawn = {
this.attraction(); this.attraction();
}; };
}, },
snakeBoss(x, y, radius = 80) { snakeBoss(x, y, radius = 75) { //snake boss with a laser head
//snake boss with a laser head
mobs.spawn(x, y, 8, radius, "rgb(255,50,130)"); mobs.spawn(x, y, 8, radius, "rgb(255,50,130)");
let me = mob[mob.length - 1]; let me = mob[mob.length - 1];
me.isBoss = true; me.isBoss = true;
me.accelMag = 0.0012 * game.accelScale; me.accelMag = 0.0011 * game.accelScale;
me.memory = 200; me.memory = 200;
me.laserRange = 500; me.laserRange = 500;
Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger Matter.Body.setDensity(me, 0.001 + 0.0005 * Math.sqrt(game.difficulty)); //extra dense //normal is 0.001 //makes effective life much larger

View File

@@ -1,4 +1,3 @@
mod perfect diamagnetism: eddy current brake - mobs have a speed limit when they are near you
************** TODO - n-gon ************** ************** TODO - n-gon **************