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

@@ -25,7 +25,6 @@ const b = {
if (mech.health > 2 * mod.isAmmoFromHealth * mech.maxHealth) {
mech.damage(mod.isAmmoFromHealth * mech.maxHealth / mech.harmReduction());
powerUps.spawn(mech.pos.x, mech.pos.y, "ammo");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "ammo");
} else {
game.replaceTextLog = true;
game.makeTextLog("not enough health for catabolism to produce ammo", 120);
@@ -1545,60 +1544,46 @@ const b = {
nextFireCycle: 0, //use to remember how longs its been since last fire, used to reset count
startingHoldCycle: 0,
fire() {
const me = bullet.length;
const dir = mech.angle + (Math.random() - 0.5) * ((mech.crouch) ? 0.01 : 0.1);
bullet[me] = Bodies.rectangle(mech.pos.x + 23 * Math.cos(mech.angle), mech.pos.y + 23 * Math.sin(mech.angle), 20 * mod.bulletSize * mod.highCaliber, 6 * mod.bulletSize, b.fireAttributes(dir));
//fire delay decreases as you hold fire, down to 3 from 15
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) * mod.highCaliber //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
b.fireProps(CD, mech.crouch ? 38 : 34, dir, me); //cd , speed
// b.fireProps(mech.crouch ? 7 : 4, mech.crouch ? 40 : 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
}
const pos = {
x: mech.pos.x + 23 * Math.cos(mech.angle),
y: mech.pos.y + 23 * Math.sin(mech.angle)
}
bullet[me].do = function () {
this.force.y += this.mass * 0.0003;
if (mod.nailGun) {
mech.fireCDcycle = mech.cycle + Math.floor(2.1 * b.fireCD); // cool down
const speed = 33 + 10 * Math.random()
const angle = mech.angle + (Math.random() - 0.5) * (Math.random() - 0.5) * (mech.crouch ? 0.22 : 0.65)
const velocity = {
x: speed * Math.cos(angle),
y: speed * Math.sin(angle)
}
b.nail(pos, velocity, 1) //position, velocity, damage
} 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
// //place in bullet do
// //slow player
// const range = 1000
// if (Vector.magnitude(Vector.sub(player.position, this.position)) < range) {
// Matter.Body.setVelocity(player, {
// x: player.velocity.x * 0.95,
// y: player.velocity.y * 0.95
// });
// }
// //aoe damage to mobs
// for (let i = 0, len = mob.length; i < len; i++) {
// if (Vector.magnitude(Vector.sub(mob[i].position, this.position)) < range) {
// let dmg = b.dmgScale * 0.023
// 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 *= 5 //x5 to make up for the /5 that shields normally take
// mob[i].damage(dmg);
// mob[i].locatePlayer();
// }
// }
// //draw it
// ctx.beginPath();
// ctx.arc(this.position.x, this.position.y, range, 0, 2 * Math.PI);
// ctx.fillStyle = `rgba(255,0,0,0.2)`;
// ctx.fill();
};
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;
};
}
}
},
{

View File

@@ -360,17 +360,17 @@ const game = {
//in testing mode
if (game.testing) {
if (keys[192]) { // `
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "reroll");
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "reroll");
} else if (keys[49]) { // give power ups with 1
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "heal");
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "heal");
} else if (keys[50]) { // 2
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "ammo");
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "ammo");
} else if (keys[51]) { // 3
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "gun");
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "gun");
} else if (keys[52]) { // 4
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "field");
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "field");
} else if (keys[53]) { // 5
powerUps.spawn(game.mouseInGame.x, game.mouseInGame.y, "mod");
powerUps.directSpawn(game.mouseInGame.x, game.mouseInGame.y, "mod");
} else if (keys[54]) { // 6 spawn mob
const pick = spawn.fullPickList[Math.floor(Math.random() * spawn.fullPickList.length)];
spawn.allowShields = false;
@@ -399,6 +399,16 @@ const game = {
x: 0,
y: 0
});
// move bots to follow player
for (let i = 0; i < bullet.length; i++) {
if (bullet[i].botType) {
Matter.Body.setPosition(bullet[i], player.position);
Matter.Body.setVelocity(bullet[i], {
x: 0,
y: 0
});
}
}
// game.noCameraScroll()
} else if (keys[85]) { // next level with U
level.nextLevel();

View File

@@ -16,9 +16,9 @@ const level = {
// game.zoomScale = 1000;
// game.setZoom();
// mech.isStealth = true;
// b.giveGuns("rail gun")
// b.giveGuns("minigun")
// mech.setField("standing wave harmonics")
// mod.giveMod("frame-dragging");
// mod.giveMod("nail gun");
level.intro(); //starting level
// level.testing(); //not in rotation
@@ -59,7 +59,6 @@ const level = {
const len = Math.floor((mech.maxHealth - mech.health) / 0.5)
for (let i = 0; i < len; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "heal", false);
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "heal", false);
}
}
if (mod.isGunCycle) {
@@ -138,7 +137,7 @@ const level = {
// spawn.laserTargetingBoss(1600, -400)
// spawn.spawner(1600, -500)
// spawn.sniper(1700, -120, 50)
spawn.springer(1400, -120)
spawn.starter(1400, -120, 100)
// spawn.sniper(1800, -120)
// spawn.sniper(2200, -120)
// spawn.cellBossCulture(1600, -500)
@@ -3214,8 +3213,8 @@ const level = {
level.levelsCleared++;
level.onLevel++; //cycles map to next level
if (level.onLevel > level.levels.length - 1) level.onLevel = 0;
level.difficultyIncrease(game.difficultyMode) //increase difficulty based on modes
if (level.levelsCleared > level.levels.length) level.difficultyIncrease(game.difficultyMode)
if (game.isEasyMode && level.levelsCleared % 2) level.difficultyDecrease(1);
game.clearNow = true; //triggers in game.clearMap to remove all physics bodies and setup for new map
},

View File

@@ -1020,14 +1020,13 @@ const mobs = {
if (mod.nailsDeathMob) b.targetedNail(this.position, mod.nailsDeathMob)
} else if (mod.isShieldAmmo && this.shield) {
let type = "ammo"
if (Math.random() < 0.4 || mod.bayesian) {
if (Math.random() < 0.4) {
type = "heal"
} else if (Math.random() < 0.3 && !mod.isSuperDeterminism) {
type = "reroll"
}
for (let i = 0, len = Math.ceil(2.8 * Math.random()); i < len; i++) {
powerUps.spawn(this.position.x, this.position.y, type);
if (Math.random() < mod.bayesian) powerUps.spawn(this.position.x, this.position.y, type);
}
}
},

View File

@@ -1011,7 +1011,7 @@ const mod = {
},
{
name: "Bayesian inference",
description: "<strong>33%</strong> chance to <strong>duplicate</strong> spawned <strong>power ups</strong><br><strong class='color-g'>ammo</strong> will no longer <strong>spawn</strong> from mobs",
description: "<strong>33%</strong> chance to <strong>duplicate</strong> spawned <strong>power ups</strong><br><strong class='color-g'>ammo</strong> will no longer <strong>spawn</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -1019,10 +1019,10 @@ const mod = {
},
requires: "",
effect: () => {
mod.bayesian = 0.33;
mod.isBayesian = true
},
remove() {
mod.bayesian = 0;
mod.isBayesian = false
}
},
{
@@ -1081,7 +1081,6 @@ const mod = {
mod.isGunCycle = true;
for (let i = 0; i < 5; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "gun");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "gun");
}
},
remove() {
@@ -1200,7 +1199,6 @@ const mod = {
mod.isDeterminism = true;
for (let i = 0; i < 5; i++) { //if you change the six also change it in Born rule
powerUps.spawn(mech.pos.x, mech.pos.y, "mod");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "mod");
}
},
remove() {
@@ -1221,7 +1219,6 @@ const mod = {
mod.isSuperDeterminism = true;
for (let i = 0; i < 4; i++) { //if you change the six also change it in Born rule
powerUps.spawn(mech.pos.x, mech.pos.y, "mod");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "mod");
}
},
remove() {
@@ -1333,7 +1330,6 @@ const mod = {
for (let i = 0; i < 2; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "gun");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "gun");
}
},
remove() {}
@@ -1380,7 +1376,7 @@ const mod = {
count: 0,
maxCount: 9,
allowed() {
return mod.haveGunCheck("minigun") || mod.haveGunCheck("shotgun") || mod.haveGunCheck("super balls")
return (mod.haveGunCheck("minigun") && !mod.nailGun) || mod.haveGunCheck("shotgun") || mod.haveGunCheck("super balls")
},
requires: "minigun, shotgun, super balls",
effect() {
@@ -1391,28 +1387,28 @@ const mod = {
}
},
{
name: "high caliber",
description: "<strong>100%</strong> increased <strong>minigun</strong> bullet size<br><strong>100%</strong> increased <strong>delay</strong> after firing",
name: "nail gun",
description: "the <strong>minigun</strong> is modified to fire <strong>nails</strong><br>with a short <strong>fire delay</strong> and a low <strong>precision</strong>",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("minigun")
return mod.haveGunCheck("minigun") && !mod.isIceCrystals
},
requires: "minigun",
effect() {
mod.highCaliber = 2
mod.nailGun = true
},
remove() {
mod.highCaliber = 1
mod.nailGun = false
}
},
{
name: "ice crystal nucleation",
description: "your <strong>minigun</strong> uses <strong class='color-f'>energy</strong> to condense<br>unlimited <strong class='color-s'>freezing</strong> <strong>bullets</strong> from water vapor",
description: "the <strong>minigun</strong> uses <strong class='color-f'>energy</strong> to condense<br>unlimited <strong class='color-s'>freezing</strong> <strong>bullets</strong> from water vapor",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("minigun")
return mod.haveGunCheck("minigun") && !mod.nailGun
},
requires: "minigun",
effect() {
@@ -1847,7 +1843,7 @@ const mod = {
maxCount: 1,
count: 0,
allowed() {
return mod.nailBotCount + mod.grenadeFragments + mod.nailsDeathMob / 2 + (mod.haveGunCheck("mine") + mod.isRailNails + mod.isNailShot) * 2 > 1
return mod.nailBotCount + mod.grenadeFragments + mod.nailsDeathMob / 2 + (mod.haveGunCheck("mine") + mod.isRailNails + mod.isNailShot + mod.nailGun) * 2 > 1
},
requires: "nails",
effect() {
@@ -2456,7 +2452,6 @@ const mod = {
effect() {
for (let i = 0; i < 6; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "heal");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "heal");
}
this.count--
},
@@ -2476,7 +2471,6 @@ const mod = {
effect() {
for (let i = 0; i < 6; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "ammo");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "ammo");
}
this.count--
},
@@ -2497,7 +2491,6 @@ const mod = {
effect() {
for (let i = 0; i < 5; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
}
this.count--
},
@@ -2516,7 +2509,6 @@ const mod = {
requires: "not superdeterminism",
effect() {
powerUps.spawn(mech.pos.x, mech.pos.y, "gun");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "gun");
this.count--
},
remove() {}
@@ -2534,7 +2526,6 @@ const mod = {
requires: "not superdeterminism",
effect() {
powerUps.spawn(mech.pos.x, mech.pos.y, "field");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "field");
this.count--
},
remove() {}
@@ -2558,7 +2549,6 @@ const mod = {
largerHeals: null,
squirrelFx: null,
isCrit: null,
bayesian: null,
isLowHealthDmg: null,
isFarAwayDmg: null,
isEntanglement: null,
@@ -2659,5 +2649,7 @@ const mod = {
isDamageForGuns: null,
isGunCycle: null,
isFastFoam: null,
isSporeGrowth: null
isSporeGrowth: null,
isBayesian: null,
nailGun: null
}

View File

@@ -428,7 +428,8 @@ const mech = {
},
displayHealth() {
id = document.getElementById("health");
id.style.width = Math.floor(300 * mech.health) + "px";
// health display follows a x^1.5 rule to make it seem like the player has lower health, this makes the player feel more excitement
id.style.width = Math.floor(300 * Math.pow(mech.health, 1.5)) + "px";
//css animation blink if health is low
if (mech.health < 0.3) {
id.classList.add("low-health");
@@ -500,12 +501,12 @@ const mech = {
mech.health -= dmg;
if (mech.health < 0 || isNaN(mech.health)) {
if (mod.isDeathAvoid && powerUps.reroll.rerolls > 0) { //&& Math.random() < 0.5
mech.health = 0.05
powerUps.reroll.changeRerolls(-1)
for (let i = 0; i < 4; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "heal", false);
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "heal", false);
}
// if (mech.health < 0.05) mech.health = 0.05
mech.immuneCycle = mech.cycle + 120 //disable this.immuneCycle bonus seconds
game.makeTextLog(`<span style='font-size:115%;'> <strong>death</strong> avoided<br><strong>1/${powerUps.reroll.rerolls}</strong> <strong class='color-r'>rerolls</strong> consumed</span>`, 420)
// game.makeTextLog("<span style='font-size:115%;'> <strong>death</strong> avoided<br><strong>1</strong> <strong class='color-r'>reroll</strong> consumed</span>", 420)

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)
}
},
};