classic n-gon links

nailgun mod
This commit is contained in:
landgreen
2020-08-27 05:25:02 -07:00
parent 21b8c6fc2b
commit d3514ee4f1
10 changed files with 144 additions and 177 deletions

View File

@@ -24,7 +24,6 @@ const powerUps = {
endDraft() {
if (mod.manyWorlds && powerUps.reroll.rerolls < 1) {
powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
}
document.body.style.cursor = "none";
document.getElementById("choose-grid").style.display = "none"
@@ -64,18 +63,16 @@ const powerUps = {
if (Math.random() < 0.37) {
mech.fieldCDcycle = mech.cycle + 30;
powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
}
}
}
}
}
if (mod.isDeathAvoid && document.getElementById("mod-anthropic")) {
document.getElementById("mod-anthropic").innerHTML = `(${powerUps.reroll.rerolls})`
document.getElementById("mod-anthropic").innerHTML = `-${powerUps.reroll.rerolls}`
}
if (mod.renormalization && Math.random() < 0.37 && amount < 0) {
powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
}
if (mod.isRerollHaste) {
if (powerUps.reroll.rerolls === 0) {
@@ -426,52 +423,39 @@ const powerUps = {
spawnRandomPowerUp(x, y) { //mostly used after mob dies, doesn't always return a power up
if ((Math.random() * Math.random() - 0.3 > Math.sqrt(mech.health) && !mod.isEnergyHealth) || Math.random() < 0.035) { //spawn heal chance is higher at low health
powerUps.spawn(x, y, "heal");
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "heal");
return;
}
if (Math.random() < 0.15 && b.inventory.length > 0 && !mod.bayesian) {
if (Math.random() < 0.15 && b.inventory.length > 0) {
powerUps.spawn(x, y, "ammo");
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "ammo");
return;
}
if (Math.random() < 0.0015 * (3 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 3
powerUps.spawn(x, y, "gun");
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "gun");
return;
}
if (Math.random() < 0.0027 * (26 - mod.totalCount)) { //a new mod has a low chance for each not acquired mod up to 15
powerUps.spawn(x, y, "mod");
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod");
return;
}
if (Math.random() < 0.006) {
powerUps.spawn(x, y, "field");
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field");
return;
}
// if (Math.random() < 0.01) {
// powerUps.spawn(x, y, "reroll");
// if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "reroll");
// return;
// }
},
randomPowerUpCounter: 0,
spawnBossPowerUp(x, y) { //boss spawns field and gun mod upgrades
if (game.difficultyMode < 2) { //easy and normal mode
powerUps.randomPowerUpCounter += 0.65;
} else if (game.difficultyMode === 2) { //hard mode
powerUps.randomPowerUpCounter += 1;
} else { //why mode
powerUps.randomPowerUpCounter += 1.33;
if (Math.random() < 0.5) { //why mode gets a free power up chance
powerUps.randomPowerUpCounter *= 0.5
spawnPowerUps()
}
powerUps.randomPowerUpCounter++;
if (game.difficultyMode === 4 && Math.random() < 0.5) { //why mode gets a free power up chance
powerUps.randomPowerUpCounter *= 0.5
spawnPowerUps()
}
const chance = Math.max(level.levelsCleared, 10) * 0.1 //1 until level 10, then 1.1, 1.2, 1.3, ...
if (Math.random() * chance < powerUps.randomPowerUpCounter) {
const chanceToFail = Math.max(level.levelsCleared, 10) * 0.1 //1 until level 10, then 1.1, 1.2, 1.3, ...
if (Math.random() * chanceToFail < powerUps.randomPowerUpCounter) {
powerUps.randomPowerUpCounter = 0;
spawnPowerUps()
} else {
@@ -482,11 +466,7 @@ const powerUps = {
if (mech.health < 0.65 && !mod.isEnergyHealth) {
powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal");
if (Math.random() < mod.bayesian) {
powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal");
}
} else if (!mod.bayesian) {
} else {
powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo");
}
@@ -495,21 +475,17 @@ const powerUps = {
function spawnPowerUps() {
if (mech.fieldMode === 0) {
powerUps.spawn(x, y, "field")
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field")
} else if (Math.random() < 0.95) {
powerUps.spawn(x, y, "mod")
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod")
} else {
powerUps.spawn(x, y, "gun")
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "gun")
}
}
},
chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris
if (Math.random() < 0.5) {
powerUps.spawn(x, y, "heal", false);
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "heal", false);
} else if (!mod.bayesian) {
} else {
powerUps.spawn(x, y, "ammo", false);
}
},
@@ -517,7 +493,6 @@ const powerUps = {
if (mob.length && Math.random() < 0.8) { // 80% chance
const index = Math.floor(Math.random() * mob.length)
powerUps.spawn(mob[index].position.x, mob[index].position.y, "reroll");
if (Math.random() < mod.bayesian) powerUps.spawn(mob[index].position.x, mob[index].position.y, "reroll");
}
},
spawnStartingPowerUps(x, y) { //used for map specific power ups, mostly to give player a starting gun
@@ -547,36 +522,43 @@ const powerUps = {
powerUps.spawnRandomPowerUp(x, y);
}
},
spawn(x, y, target, moving = true, mode = null) {
if (!(mod.isSuperDeterminism && (target === 'gun' || target === 'field' || target === 'reroll'))) {
let index = powerUp.length;
target = powerUps[target];
size = target.size();
powerUp[index] = Matter.Bodies.polygon(x, y, 0, size, {
density: 0.001,
frictionAir: 0.01,
restitution: 0.8,
inertia: Infinity, //prevents rotation
collisionFilter: {
group: 0,
category: cat.powerUp,
mask: cat.map | cat.powerUp
},
color: target.color,
effect: target.effect,
name: target.name,
size: size
directSpawn(x, y, target, moving = true, mode = null) {
let index = powerUp.length;
target = powerUps[target];
size = target.size();
powerUp[index] = Matter.Bodies.polygon(x, y, 0, size, {
density: 0.001,
frictionAir: 0.01,
restitution: 0.8,
inertia: Infinity, //prevents rotation
collisionFilter: {
group: 0,
category: cat.powerUp,
mask: cat.map | cat.powerUp
},
color: target.color,
effect: target.effect,
name: target.name,
size: size
});
if (mode) {
powerUp[index].mode = mode
}
if (moving) {
Matter.Body.setVelocity(powerUp[index], {
x: (Math.random() - 0.5) * 15,
y: Math.random() * -9 - 3
});
if (mode) {
powerUp[index].mode = mode
}
if (moving) {
Matter.Body.setVelocity(powerUp[index], {
x: (Math.random() - 0.5) * 15,
y: Math.random() * -9 - 3
});
}
World.add(engine.world, powerUp[index]); //add to world
}
World.add(engine.world, powerUp[index]); //add to world
},
spawn(x, y, target, moving = true, mode = null) {
if (
!(mod.isSuperDeterminism && (target === 'gun' || target === 'field' || target === 'reroll')) &&
!(mod.isBayesian && target === 'ammo')
) {
powerUps.directSpawn(x, y, target, moving, mode)
if (mod.isBayesian && Math.random() < 0.33) powerUps.directSpawn(x, y, target, moving, mode)
}
},
};