file reoganization, mod has it's own file

This commit is contained in:
landgreen
2020-05-19 19:03:53 -07:00
parent 4a355caa60
commit c31c1c2d7a
13 changed files with 2104 additions and 2084 deletions

View File

@@ -514,9 +514,10 @@
<script src='lib/randomColor.min.js'></script> <script src='lib/randomColor.min.js'></script>
<script src="js/game.js"></script> <script src="js/game.js"></script>
<script src="js/player.js"></script> <script src="js/player.js"></script>
<script src="js/powerups.js"></script> <script src="js/powerup.js"></script>
<script src="js/bullets.js"></script> <script src="js/mods.js"></script>
<script src="js/mobs.js"></script> <script src="js/bullet.js"></script>
<script src="js/mob.js"></script>
<script src="js/spawn.js"></script> <script src="js/spawn.js"></script>
<script src="js/level.js"></script> <script src="js/level.js"></script>
<script src="js/visibility.js"></script> <script src="js/visibility.js"></script>

File diff suppressed because it is too large Load Diff

View File

@@ -108,7 +108,7 @@ function collisionChecks(event) {
} }
function hit(dmg) { function hit(dmg) {
mech.immuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles
dmg = Math.min(Math.max(Math.sqrt(dmg) * obj.mass * 0.01, 0.02), 0.15); dmg = Math.min(Math.max(Math.sqrt(dmg) * obj.mass * 0.01, 0.02), 0.15);
mech.damage(dmg); mech.damage(dmg);
game.drawList.push({ //add dmg to draw queue game.drawList.push({ //add dmg to draw queue
@@ -136,10 +136,10 @@ function collisionChecks(event) {
function collideMob(obj) { function collideMob(obj) {
//player + mob collision //player + mob collision
if (mech.immuneCycle < mech.cycle && (obj === playerBody || obj === playerHead)) { if (mech.immuneCycle < mech.cycle && (obj === playerBody || obj === playerHead)) {
mech.immuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles
mob[k].foundPlayer(); mob[k].foundPlayer();
let dmg = Math.min(Math.max(0.025 * Math.sqrt(mob[k].mass), 0.05), 0.3) * game.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0 let dmg = Math.min(Math.max(0.025 * Math.sqrt(mob[k].mass), 0.05), 0.3) * game.dmgScale; //player damage is capped at 0.3*dmgScale of 1.0
if (b.isModPiezo) { if (mod.isPiezo) {
mech.energy = mech.maxEnergy; mech.energy = mech.maxEnergy;
dmg *= 0.85 dmg *= 0.85
} }
@@ -157,7 +157,7 @@ function collisionChecks(event) {
y: mob[k].velocity.y - 8 * Math.sin(angle) y: mob[k].velocity.y - 8 * Math.sin(angle)
}); });
if (b.isModAnnihilation && !mob[k].shield && !mob[k].isShielded) { if (mod.isAnnihilation && !mob[k].shield && !mob[k].isShielded) {
mob[k].death(); mob[k].death();
game.drawList.push({ game.drawList.push({
//add dmg to draw queue //add dmg to draw queue
@@ -183,10 +183,10 @@ function collisionChecks(event) {
//mob + bullet collisions //mob + bullet collisions
if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) { if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) {
// const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))); // const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)));
let dmg = b.dmgScale * (obj.dmg + b.modAcidDmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))) let dmg = b.dmgScale * (obj.dmg + mod.acidDmg + 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)))
// console.log(obj.dmg, 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))) // console.log(obj.dmg, 0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)))
// console.log(obj.dmg / (0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)))) // console.log(obj.dmg / (0.15 * obj.mass * Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity))))
if (b.isModCrit && !mob[k].seePlayer.recall && !mob[k].shield) dmg *= 5 if (mod.isCrit && !mob[k].seePlayer.recall && !mob[k].shield) dmg *= 5
mob[k].foundPlayer(); mob[k].foundPlayer();
mob[k].damage(dmg); mob[k].damage(dmg);
obj.onDmg(mob[k]); //some bullets do actions when they hits things, like despawn obj.onDmg(mob[k]); //some bullets do actions when they hits things, like despawn
@@ -203,8 +203,8 @@ function collisionChecks(event) {
if (obj.classType === "body" && obj.speed > 6) { if (obj.classType === "body" && obj.speed > 6) {
const v = Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity)); const v = Vector.magnitude(Vector.sub(mob[k].velocity, obj.velocity));
if (v > 9) { if (v > 9) {
let dmg = b.dmgScale * (v * obj.mass * 0.07) * b.modThrowChargeRate; let dmg = b.dmgScale * (v * obj.mass * 0.07) * mod.throwChargeRate;
if (b.isModCrit && !mob[k].seePlayer.recall && !mob[k].shield) dmg *= 5 if (mod.isCrit && !mob[k].seePlayer.recall && !mob[k].shield) dmg *= 5
if (mob[k].isShielded) dmg *= 0.5 if (mob[k].isShielded) dmg *= 0.5
mob[k].damage(dmg, true); mob[k].damage(dmg, true);
if (mob[k].distanceToPlayer2() < 1000000) mob[k].foundPlayer(); if (mob[k].distanceToPlayer2() < 1000000) mob[k].foundPlayer();

View File

@@ -180,7 +180,7 @@ const game = {
if (document.getElementById(b.activeGun)) document.getElementById(b.activeGun).style.opacity = "1"; if (document.getElementById(b.activeGun)) document.getElementById(b.activeGun).style.opacity = "1";
} }
if (b.isModEntanglement && document.getElementById("mod-entanglement")) { if (mod.isEntanglement && document.getElementById("mod-entanglement")) {
if (b.inventory[0] === b.activeGun) { if (b.inventory[0] === b.activeGun) {
let lessDamage = 1 let lessDamage = 1
for (let i = 0, len = b.inventory.length; i < len; i++) { for (let i = 0, len = b.inventory.length; i < len; i++) {
@@ -215,16 +215,16 @@ const game = {
}, },
updateModHUD() { updateModHUD() {
let text = "" let text = ""
for (let i = 0, len = b.mods.length; i < len; i++) { //add mods for (let i = 0, len = mod.mods.length; i < len; i++) { //add mods
if (b.mods[i].count > 0) { if (mod.mods[i].count > 0) {
if (text) text += "<br>" //add a new line, but not on the first line if (text) text += "<br>" //add a new line, but not on the first line
text += b.mods[i].name text += mod.mods[i].name
if (b.mods[i].nameInfo) text += b.mods[i].nameInfo if (mod.mods[i].nameInfo) text += mod.mods[i].nameInfo
if (b.mods[i].count > 1) text += ` (${b.mods[i].count}x)` if (mod.mods[i].count > 1) text += ` (${mod.mods[i].count}x)`
} }
} }
document.getElementById("mods").innerHTML = text document.getElementById("mods").innerHTML = text
b.modOnHealthChange() mod.onHealthChange()
}, },
replaceTextLog: true, replaceTextLog: true,
// <!-- <path d="M832.41,106.64 V323.55 H651.57 V256.64 c0-82.5,67.5-150,150-150 Z" fill="#789" stroke="none" /> // <!-- <path d="M832.41,106.64 V323.55 H651.57 V256.64 c0-82.5,67.5-150,150-150 Z" fill="#789" stroke="none" />
@@ -261,7 +261,7 @@ const game = {
} }
}, },
switchGun() { switchGun() {
if (b.modNoAmmo) b.modNoAmmo = 1 //this prevents hacking the mod by switching guns if (mod.noAmmo) mod.noAmmo = 1 //this prevents hacking the mod by switching guns
b.activeGun = b.inventory[b.inventoryGun]; b.activeGun = b.inventory[b.inventoryGun];
game.updateGunHUD(); game.updateGunHUD();
game.boldActiveGunHUD(); game.boldActiveGunHUD();
@@ -376,7 +376,7 @@ const game = {
mech.addHealth(Infinity) mech.addHealth(Infinity)
mech.energy = mech.maxEnergy; mech.energy = mech.maxEnergy;
} else if (keys[89]) { //add mods with y } else if (keys[89]) { //add mods with y
b.giveMod() mod.giveMod()
} else if (keys[82]) { // teleport to mouse with R } else if (keys[82]) { // teleport to mouse with R
Matter.Body.setPosition(player, game.mouseInGame); Matter.Body.setPosition(player, game.mouseInGame);
Matter.Body.setVelocity(player, { Matter.Body.setVelocity(player, {
@@ -484,11 +484,12 @@ const game = {
} }
b.activeGun = null; b.activeGun = null;
b.setupAllMods(); //sets mods to default values mod.setupAllMods(); //sets mods to default values
game.updateModHUD(); game.updateModHUD();
powerUps.reroll.rerolls = 0; powerUps.reroll.rerolls = 0;
mech.maxHealth = 1 mech.maxHealth = 1
mech.maxEnergy = 1 mech.maxEnergy = 1
mech.energy = 1
game.paused = false; game.paused = false;
engine.timing.timeScale = 1; engine.timing.timeScale = 1;
game.fpsCap = game.fpsCapDefault; game.fpsCap = game.fpsCapDefault;
@@ -516,8 +517,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 === 2) level.difficultyIncrease(1) if (game.difficultyMode === 4) level.difficultyIncrease(2)
if (game.difficultyMode === 4) level.difficultyIncrease(4)
game.clearNow = true; game.clearNow = true;
document.getElementById("text-log").style.opacity = 0; document.getElementById("text-log").style.opacity = 0;
@@ -585,7 +585,7 @@ const game = {
if (game.firstRun) { if (game.firstRun) {
mech.spawn(); //spawns the player mech.spawn(); //spawns the player
b.setupAllMods(); //doesn't run on reset so that gun mods carry over to new runs mod.setupAllMods(); //doesn't run on reset so that gun mods carry over to new runs
function shuffle(array) { function shuffle(array) {
var currentIndex = array.length, var currentIndex = array.length,
@@ -606,7 +606,6 @@ const game = {
if (game.isCommunityMaps) level.levels.push("stronghold"); if (game.isCommunityMaps) level.levels.push("stronghold");
level.levels = shuffle(level.levels); //shuffles order of maps level.levels = shuffle(level.levels); //shuffles order of maps
level.levels.unshift("bosses"); //add bosses level to the end of the randomized levels list level.levels.unshift("bosses"); //add bosses level to the end of the randomized levels list
// console.log(level.levels)
} }
game.reset(); game.reset();
game.firstRun = false; game.firstRun = false;
@@ -618,14 +617,14 @@ const game = {
}, },
clearNow: false, clearNow: false,
clearMap() { clearMap() {
if (b.isModMineAmmoBack) { if (mod.isMineAmmoBack) {
let count = 0; let count = 0;
for (i = 0, len = bullet.length; i < len; i++) { //count mines left on map for (i = 0, len = bullet.length; i < len; i++) { //count mines left on map
if (bullet[i].bulletType === "mine") count++ if (bullet[i].bulletType === "mine") count++
} }
for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is mine for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is mine
if (b.guns[i].name === "mine") { if (b.guns[i].name === "mine") {
if (b.modNoAmmo) count = Math.ceil(count / 2) if (mod.noAmmo) count = Math.ceil(count / 2)
b.guns[i].ammo += count b.guns[i].ammo += count
game.updateGunHUD(); game.updateGunHUD();
break; break;
@@ -705,9 +704,6 @@ const game = {
}, },
checks() { checks() {
if (!(mech.cycle % 60)) { //once a second if (!(mech.cycle % 60)) { //once a second
console.log(bullet.length * 0.005)
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) {
mech.death(); mech.death();
@@ -732,10 +728,10 @@ const game = {
} }
} }
// if (b.isModEnergyDamage) { // if (mod.isEnergyDamage) {
// document.getElementById("mod-capacitor").innerHTML = `(+${(mech.energy/0.05).toFixed(0)}%)` // document.getElementById("mod-capacitor").innerHTML = `(+${(mech.energy/0.05).toFixed(0)}%)`
// } // }
// if (b.isModRest) { // if (mod.isRest) {
// if (player.speed < 1) { // if (player.speed < 1) {
// document.getElementById("mod-rest").innerHTML = `(+20%)` // document.getElementById("mod-rest").innerHTML = `(+20%)`
// } else { // } else {
@@ -744,11 +740,11 @@ const game = {
// } // }
if (mech.lastKillCycle + 300 > mech.cycle) { //effects active for 5 seconds after killing a mob if (mech.lastKillCycle + 300 > mech.cycle) { //effects active for 5 seconds after killing a mob
if (b.isModEnergyRecovery) { if (mod.isEnergyRecovery) {
mech.energy += mech.maxEnergy * 0.07 mech.energy += mech.maxEnergy * 0.07
if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy; if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy;
} }
if (b.isModHealthRecovery) mech.addHealth(0.01) if (mod.isHealthRecovery) mech.addHealth(0.01)
} }
if (!(game.cycle % 420)) { //once every 7 seconds if (!(game.cycle % 420)) { //once every 7 seconds

View File

@@ -48,7 +48,7 @@ const build = {
// console.log(`${property}: ${give[property]}`); // console.log(`${property}: ${give[property]}`);
set[property] = set[property].replace(/%20/g, " ") set[property] = set[property].replace(/%20/g, " ")
if (property.substring(0, 3) === "gun") b.giveGuns(set[property]) if (property.substring(0, 3) === "gun") b.giveGuns(set[property])
if (property.substring(0, 3) === "mod") b.giveMod(set[property]) if (property.substring(0, 3) === "mod") mod.giveMod(set[property])
if (property === "field") mech.setField(set[property]) if (property === "field") mech.setField(set[property])
if (property === "difficulty") { if (property === "difficulty") {
game.difficultyMode = Number(set[property]) game.difficultyMode = Number(set[property])
@@ -68,7 +68,7 @@ const build = {
b.activeGun = b.inventory[0] //set first gun to active gun b.activeGun = b.inventory[0] //set first gun to active gun
game.makeGunHUD(); game.makeGunHUD();
} }
b.modOnHealthChange(); mod.onHealthChange();
} }
}, },
pauseGrid() { pauseGrid() {
@@ -84,7 +84,7 @@ const build = {
<br>health: ${(mech.health*100).toFixed(0)}% &nbsp; energy: ${(mech.energy*100).toFixed(0)}% &nbsp; <br>health: ${(mech.health*100).toFixed(0)}% &nbsp; energy: ${(mech.energy*100).toFixed(0)}% &nbsp;
<br>mass: ${player.mass.toFixed(1)} &nbsp; rerolls: ${powerUps.reroll.rerolls} <br>mass: ${player.mass.toFixed(1)} &nbsp; rerolls: ${powerUps.reroll.rerolls}
<br>position: (${player.position.x.toFixed(1)}, ${player.position.y.toFixed(1)}) &nbsp; velocity: (${player.velocity.x.toFixed(1)}, ${player.velocity.y.toFixed(1)}) <br>position: (${player.position.x.toFixed(1)}, ${player.position.y.toFixed(1)}) &nbsp; velocity: (${player.velocity.x.toFixed(1)}, ${player.velocity.y.toFixed(1)})
<br>global damage increase: ${((b.damageFromMods()-1)*100).toFixed(0)}% <br>global damage increase: ${((mod.damageFromMods()-1)*100).toFixed(0)}%
<br>global harm reduction: ${((1-mech.harmReduction())*100).toFixed(0)}% <br>global harm reduction: ${((1-mech.harmReduction())*100).toFixed(0)}%
</div>`; </div>`;
let countGuns = 0 let countGuns = 0
@@ -101,12 +101,12 @@ const build = {
text = ""; text = "";
text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[mech.fieldMode].name}</div> ${mech.fieldUpgrades[mech.fieldMode].description}</div>` text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[mech.fieldMode].name}</div> ${mech.fieldUpgrades[mech.fieldMode].description}</div>`
for (let i = 0, len = b.mods.length; i < len; i++) { for (let i = 0, len = mod.mods.length; i < len; i++) {
if (b.mods[i].count > 0) { if (mod.mods[i].count > 0) {
if (b.mods[i].count === 1) { if (mod.mods[i].count === 1) {
text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div> ${b.mods[i].description}</div>` text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[i].name}</div> ${mod.mods[i].description}</div>`
} else { } else {
text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name} (${b.mods[i].count}x)</div> ${b.mods[i].description}</div>` text += `<div class="pause-grid-module"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[i].name} (${mod.mods[i].count}x)</div> ${mod.mods[i].description}</div>`
} }
countMods++ countMods++
} }
@@ -154,25 +154,25 @@ const build = {
who.classList.add("build-field-selected"); who.classList.add("build-field-selected");
} }
} else if (type === "mod") { //remove mod if you have too many } else if (type === "mod") { //remove mod if you have too many
if (b.mods[index].count < b.mods[index].maxCount) { if (mod.mods[index].count < mod.mods[index].maxCount) {
if (!who.classList.contains("build-mod-selected")) who.classList.add("build-mod-selected"); if (!who.classList.contains("build-mod-selected")) who.classList.add("build-mod-selected");
b.giveMod(index) mod.giveMod(index)
// if (b.mods[index].count > 1) who.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[index].name} (${b.mods[index].count}x)</div> ${b.mods[index].description}` // if (mod.mods[index].count > 1) who.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[index].name} (${mod.mods[index].count}x)</div> ${mod.mods[index].description}`
} else { } else {
b.removeMod(index); mod.removeMod(index);
// who.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[index].name}</div> ${b.mods[index].description}` // who.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[index].name}</div> ${mod.mods[index].description}`
who.classList.remove("build-mod-selected"); who.classList.remove("build-mod-selected");
} }
} }
//update mod text //disable not allowed mods //update mod text //disable not allowed mods
for (let i = 0, len = b.mods.length; i < len; i++) { for (let i = 0, len = mod.mods.length; i < len; i++) {
const modID = document.getElementById("mod-" + i) const modID = document.getElementById("mod-" + i)
if (b.mods[i].allowed()) { if (mod.mods[i].allowed()) {
if (b.mods[i].count > 1) { if (mod.mods[i].count > 1) {
modID.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name} (${b.mods[i].count}x)</div>${b.mods[i].description}</div>` modID.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[i].name} (${mod.mods[i].count}x)</div>${mod.mods[i].description}</div>`
} else { } else {
modID.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div>${b.mods[i].description}</div>` modID.innerHTML = `<div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[i].name}</div>${mod.mods[i].description}</div>`
} }
if (modID.classList.contains("build-grid-disabled")) { if (modID.classList.contains("build-grid-disabled")) {
@@ -180,13 +180,13 @@ const build = {
modID.setAttribute("onClick", `javascript: build.choosePowerUp(this,${i},'mod')`); modID.setAttribute("onClick", `javascript: build.choosePowerUp(this,${i},'mod')`);
} }
} else { } else {
modID.innerHTML = `<div class="grid-title"><div class="circle-grid grey"></div> &nbsp; ${b.mods[i].name}</div><span style="color:#666;"><strong>requires:</strong> ${b.mods[i].requires}</span></div>` modID.innerHTML = `<div class="grid-title"><div class="circle-grid grey"></div> &nbsp; ${mod.mods[i].name}</div><span style="color:#666;"><strong>requires:</strong> ${mod.mods[i].requires}</span></div>`
if (!modID.classList.contains("build-grid-disabled")) { if (!modID.classList.contains("build-grid-disabled")) {
modID.classList.add("build-grid-disabled"); modID.classList.add("build-grid-disabled");
modID.onclick = null modID.onclick = null
} }
if (b.mods[i].count > 0) { if (mod.mods[i].count > 0) {
b.removeMod(i) mod.removeMod(i)
} }
if (modID.classList.contains("build-mod-selected")) { if (modID.classList.contains("build-mod-selected")) {
modID.classList.remove("build-mod-selected"); modID.classList.remove("build-mod-selected");
@@ -229,13 +229,13 @@ const build = {
for (let i = 0, len = b.guns.length; i < len; i++) { for (let i = 0, len = b.guns.length; i < len; i++) {
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'gun')"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[i].name}</div> ${b.guns[i].description}</div>` text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'gun')"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[i].name}</div> ${b.guns[i].description}</div>`
} }
for (let i = 0, len = b.mods.length; i < len; i++) { for (let i = 0, len = mod.mods.length; i < len; i++) {
if (!b.mods[i].allowed()) { // || b.mods[i].name === "+1 cardinality") { //|| b.mods[i].name === "leveraged investment" if (!mod.mods[i].allowed()) { // || mod.mods[i].name === "+1 cardinality") { //|| mod.mods[i].name === "leveraged investment"
text += `<div id="mod-${i}" class="build-grid-module build-grid-disabled"><div class="grid-title"><div class="circle-grid grey"></div> &nbsp; ${b.mods[i].name}</div><span style="color:#666;"><strong>requires:</strong> ${b.mods[i].requires}</span></div>` text += `<div id="mod-${i}" class="build-grid-module build-grid-disabled"><div class="grid-title"><div class="circle-grid grey"></div> &nbsp; ${mod.mods[i].name}</div><span style="color:#666;"><strong>requires:</strong> ${mod.mods[i].requires}</span></div>`
} else if (b.mods[i].count > 1) { } else if (mod.mods[i].count > 1) {
text += `<div id="mod-${i}" class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name} (${b.mods[i].count}x)</div> ${b.mods[i].description}</div>` text += `<div id="mod-${i}" class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[i].name} (${mod.mods[i].count}x)</div> ${mod.mods[i].description}</div>`
} else { } else {
text += `<div id="mod-${i}" class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[i].name}</div> ${b.mods[i].description}</div>` text += `<div id="mod-${i}" class="build-grid-module" onclick="build.choosePowerUp(this,${i},'mod')"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[i].name}</div> ${mod.mods[i].description}</div>`
} }
} }
document.getElementById("build-grid").innerHTML = text document.getElementById("build-grid").innerHTML = text
@@ -246,7 +246,7 @@ const build = {
document.getElementById("difficulty-select").value = document.getElementById("difficulty-select-custom").value document.getElementById("difficulty-select").value = document.getElementById("difficulty-select-custom").value
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
}); });
b.resetModText(); mod.resetModText();
}, },
reset() { reset() {
build.isCustomSelection = true; build.isCustomSelection = true;
@@ -261,7 +261,7 @@ const build = {
b.activeGun = null; b.activeGun = null;
game.makeGunHUD(); game.makeGunHUD();
b.setupAllMods(); mod.setupAllMods();
build.populateGrid(); build.populateGrid();
document.getElementById("field-0").classList.add("build-field-selected"); document.getElementById("field-0").classList.add("build-field-selected");
document.getElementById("build-grid").style.display = "grid" document.getElementById("build-grid").style.display = "grid"
@@ -276,9 +276,9 @@ const build = {
} }
} }
count = 0; count = 0;
for (let i = 0; i < b.mods.length; i++) { for (let i = 0; i < mod.mods.length; i++) {
for (let j = 0; j < b.mods[i].count; j++) { for (let j = 0; j < mod.mods[i].count; j++) {
url += `&mod${count}=${encodeURIComponent(b.mods[i].name.trim())}` url += `&mod${count}=${encodeURIComponent(mod.mods[i].name.trim())}`
count++ count++
} }
} }
@@ -291,7 +291,7 @@ const build = {
}, },
startBuildRun() { startBuildRun() {
build.isCustomSelection = false; build.isCustomSelection = false;
b.modOnHealthChange() mod.onHealthChange()
spawn.setSpawnList(); //gives random mobs, not starter mobs spawn.setSpawnList(); //gives random mobs, not starter mobs
spawn.setSpawnList(); spawn.setSpawnList();

View File

@@ -17,7 +17,7 @@ const level = {
// game.enableConstructMode() //used to build maps in testing mode // game.enableConstructMode() //used to build maps in testing mode
// level.difficultyIncrease(9) // level.difficultyIncrease(9)
// mech.setField("time dilation field") // mech.setField("time dilation field")
// b.giveMod("brushless motor"); // mod.giveMod("brushless motor");
// b.giveGuns("drones") // b.giveGuns("drones")
// b.giveGuns("mine") // b.giveGuns("mine")
// mech.setField("pilot wave") // mech.setField("pilot wave")
@@ -45,13 +45,13 @@ const level = {
game.setZoom(); game.setZoom();
level.addToWorld(); //add bodies to game engine level.addToWorld(); //add bodies to game engine
game.draw.setPaths(); game.draw.setPaths();
for (let i = 0; i < b.modLaserBotCount; i++) { for (let i = 0; i < mod.laserBotCount; i++) {
b.laserBot() b.laserBot()
} }
for (let i = 0; i < b.modNailBotCount; i++) { for (let i = 0; i < mod.nailBotCount; i++) {
b.nailBot() b.nailBot()
} }
for (let i = 0; i < b.modFoamBotCount; i++) { for (let i = 0; i < mod.foamBotCount; i++) {
b.foamBot() b.foamBot()
} }
}, },
@@ -188,7 +188,7 @@ const level = {
// spawn.stabber(1600, -500) // spawn.stabber(1600, -500)
// spawn.cellBossCulture(1600, -500) // spawn.cellBossCulture(1600, -500)
// spawn.shooter(1600, -500) // spawn.shooter(1600, -500)
spawn.focuser(1600, -500) spawn.striker(1600, -500)
// spawn.shield(mob[mob.length - 1], 1200, -500, 1); // spawn.shield(mob[mob.length - 1], 1200, -500, 1);
// spawn.nodeBoss(1200, -500, "spiker") // spawn.nodeBoss(1200, -500, "spiker")

View File

@@ -227,7 +227,7 @@ const mobs = {
gravity() { gravity() {
this.force.y += this.mass * this.g; this.force.y += this.mass * this.g;
}, },
seePlayerFreq: Math.round((30 + 30 * Math.random()) * game.lookFreqScale), //how often NPC checks to see where player is, lower numbers have better vision seePlayerFreq: Math.floor((30 + 30 * Math.random()) * game.lookFreqScale), //how often NPC checks to see where player is, lower numbers have better vision
foundPlayer() { foundPlayer() {
this.locatePlayer(); this.locatePlayer();
if (!this.seePlayer.yes) { if (!this.seePlayer.yes) {
@@ -983,25 +983,25 @@ const mobs = {
}, },
damage(dmg, isBypassShield = false) { damage(dmg, isBypassShield = false) {
if (!this.isShielded || isBypassShield) { if (!this.isShielded || isBypassShield) {
dmg *= b.damageFromMods() dmg *= mod.damageFromMods()
//mobs specific damage changes //mobs specific damage changes
dmg /= Math.sqrt(this.mass) dmg /= Math.sqrt(this.mass)
if (this.shield) dmg *= 0.04 if (this.shield) dmg *= 0.04
if (b.isModFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(500, Math.min(3000, this.distanceToPlayer())) - 500) * 0.0067 //up to 50% dmg at max range of 3500 if (mod.isFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(500, Math.min(3000, this.distanceToPlayer())) - 500) * 0.0067 //up to 50% dmg at max range of 3500
//energy and heal drain should be calculated after damage boosts //energy and heal drain should be calculated after damage boosts
if (b.modEnergySiphon && dmg !== Infinity) { if (mod.energySiphon && dmg !== Infinity) {
mech.energy += Math.min(this.health, dmg) * b.modEnergySiphon mech.energy += Math.min(this.health, dmg) * mod.energySiphon
if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy
} }
if (b.modHealthDrain && dmg !== Infinity) { if (mod.healthDrain && dmg !== Infinity) {
mech.addHealth(Math.min(this.health, dmg) * b.modHealthDrain) mech.addHealth(Math.min(this.health, dmg) * mod.healthDrain)
if (mech.health > mech.maxHealth) mech.health = mech.maxHealth if (mech.health > mech.maxHealth) mech.health = mech.maxHealth
} }
this.health -= dmg this.health -= dmg
//this.fill = this.color + this.health + ')'; //this.fill = this.color + this.health + ')';
this.onDamage(dmg); //custom damage effects this.onDamage(dmg); //custom damage effects
if (this.health < b.modMobDieAtHealth && this.alive) this.death(); if (this.health < mod.mobDieAtHealth && this.alive) this.death();
} }
}, },
onDamage() { onDamage() {
@@ -1019,16 +1019,16 @@ const mobs = {
this.removeConsBB(); this.removeConsBB();
this.alive = false; //triggers mob removal in mob[i].replace(i) this.alive = false; //triggers mob removal in mob[i].replace(i)
if (this.dropPowerUp) { if (this.dropPowerUp) {
if (b.isModEnergyLoss) mech.energy *= 0.66; if (mod.isEnergyLoss) mech.energy *= 0.66;
powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius); powerUps.spawnRandomPowerUp(this.position.x, this.position.y, this.mass, radius);
mech.lastKillCycle = mech.cycle; //tracks the last time a kill was made, mostly used in game.checks() mech.lastKillCycle = mech.cycle; //tracks the last time a kill was made, mostly used in game.checks()
if (Math.random() < b.modSporesOnDeath) { if (Math.random() < mod.sporesOnDeath) {
const len = Math.min(30, Math.floor(4 + this.mass * Math.random())) const len = Math.min(30, Math.floor(4 + this.mass * Math.random()))
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
b.spore(this) //spawn drone b.spore(this) //spawn drone
} }
} }
if (Math.random() < b.isModBotSpawner) { if (Math.random() < mod.isBotSpawner) {
if (Math.random() < 0.33) { if (Math.random() < 0.33) {
b.nailBot(this.position) b.nailBot(this.position)
} else if (Math.random() < 0.5) { } else if (Math.random() < 0.5) {
@@ -1038,8 +1038,8 @@ const mobs = {
} }
// if (mech.energy > 0.33) mech.energy -= 0.33 // if (mech.energy > 0.33) mech.energy -= 0.33
} }
if (b.isModExplodeMob) b.explosion(this.position, Math.min(450, Math.sqrt(this.mass + 3) * 80)) if (mod.isExplodeMob) b.explosion(this.position, Math.min(450, Math.sqrt(this.mass + 3) * 80))
if (b.modNailsDeathMob) b.targetedNail(this.position, b.modNailsDeathMob) if (mod.nailsDeathMob) b.targetedNail(this.position, mod.nailsDeathMob)
} }
}, },
removeConsBB() { removeConsBB() {

1789
js/mods.js Normal file

File diff suppressed because it is too large Load Diff

View File

@@ -106,7 +106,7 @@ const mech = {
Sy: 0, //adds a smoothing effect to vertical only Sy: 0, //adds a smoothing effect to vertical only
Vx: 0, Vx: 0,
Vy: 0, Vy: 0,
jumpForce: 0.38, //0.38 //this is reset in b.setupAllMods() jumpForce: 0.38, //0.38 //this is reset in mod.setupAllMods()
gravity: 0.0024, //0.0019 //game.g is 0.001 gravity: 0.0024, //0.0019 //game.g is 0.001
friction: { friction: {
ground: 0.01, ground: 0.01,
@@ -215,12 +215,12 @@ const mech = {
mech.yOff = mech.yOffWhen.jump; mech.yOff = mech.yOffWhen.jump;
mech.hardLandCD = mech.cycle + Math.min(momentum / 6.5 - 6, 40) mech.hardLandCD = mech.cycle + Math.min(momentum / 6.5 - 6, 40)
if (b.isModStomp) { if (mod.isStomp) {
const len = Math.min(25, (momentum - 120) * 0.1) const len = Math.min(25, (momentum - 120) * 0.1)
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
b.spore(player) //spawn drone b.spore(player) //spawn drone
} }
} else if (player.velocity.y > 27 && momentum > 180 * b.modSquirrelFx) { //falling damage } else if (player.velocity.y > 27 && momentum > 180 * mod.squirrelFx) { //falling damage
let dmg = Math.sqrt(momentum - 180) * 0.01 let dmg = Math.sqrt(momentum - 180) * 0.01
dmg = Math.min(Math.max(dmg, 0.02), 0.20); dmg = Math.min(Math.max(dmg, 0.02), 0.20);
mech.damage(dmg); mech.damage(dmg);
@@ -357,36 +357,36 @@ const mech = {
}, },
alive: false, alive: false,
death() { death() {
if (b.isModImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats if (mod.isImmortal) { //if player has the immortality buff, spawn on the same level with randomized stats
spawn.setSpawnList(); //new mob types spawn.setSpawnList(); //new mob types
game.clearNow = true; //triggers a map reset game.clearNow = true; //triggers a map reset
powerUps.reroll.rerolls = Math.floor(Math.random() * Math.random() * 12) powerUps.reroll.rerolls = Math.floor(Math.random() * Math.random() * 12)
//count mods //count mods
let totalMods = 0; let totalMods = 0;
for (let i = 0; i < b.mods.length; i++) { for (let i = 0; i < mod.mods.length; i++) {
totalMods += b.mods[i].count totalMods += mod.mods[i].count
} }
function randomizeMods() { function randomizeMods() {
for (let i = 0; i < totalMods; i++) { for (let i = 0; i < totalMods; i++) {
//find what mods I don't have //find what mods I don't have
let options = []; let options = [];
for (let i = 0, len = b.mods.length; i < len; i++) { for (let i = 0, len = mod.mods.length; i < len; i++) {
if (b.mods[i].count < b.mods[i].maxCount && if (mod.mods[i].count < mod.mods[i].maxCount &&
b.mods[i].name !== "quantum immortality" && mod.mods[i].name !== "quantum immortality" &&
b.mods[i].name !== "Born rule" && mod.mods[i].name !== "Born rule" &&
b.mods[i].name !== "determinism" && mod.mods[i].name !== "determinism" &&
b.mods[i].name !== "reallocation" && mod.mods[i].name !== "reallocation" &&
b.mods[i].name !== "many-worlds" && mod.mods[i].name !== "many-worlds" &&
b.mods[i].allowed() mod.mods[i].allowed()
) options.push(i); ) options.push(i);
} }
//add a new mod //add a new mod
if (options.length > 0) { if (options.length > 0) {
const choose = Math.floor(Math.random() * options.length) const choose = Math.floor(Math.random() * options.length)
let newMod = options[choose] let newMod = options[choose]
b.giveMod(newMod) mod.giveMod(newMod)
options.splice(choose, 1); options.splice(choose, 1);
} }
} }
@@ -431,7 +431,7 @@ const mech = {
} }
function randomizeEverything() { function randomizeEverything() {
b.setupAllMods(); //remove all mods mod.setupAllMods(); //remove all mods
for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]); for (let i = 0; i < bullet.length; ++i) Matter.World.remove(engine.world, bullet[i]);
bullet = []; //remove all bullets bullet = []; //remove all bullets
randomizeHealth() randomizeHealth()
@@ -500,10 +500,10 @@ const mech = {
} }
}, },
addHealth(heal) { addHealth(heal) {
if (!b.isModEnergyHealth) { if (!mod.isEnergyHealth) {
mech.health += heal * game.healScale; mech.health += heal * game.healScale;
if (mech.health > mech.maxHealth) mech.health = mech.maxHealth; if (mech.health > mech.maxHealth) mech.health = mech.maxHealth;
b.modOnHealthChange(); mod.onHealthChange();
mech.displayHealth(); mech.displayHealth();
} }
}, },
@@ -512,9 +512,9 @@ const mech = {
harmReduction() { harmReduction() {
let dmg = 1 let dmg = 1
dmg *= mech.fieldDamageResistance dmg *= mech.fieldDamageResistance
dmg *= b.isModSlowFPS ? 0.85 : 1 dmg *= mod.isSlowFPS ? 0.85 : 1
if (b.modEnergyRegen === 0) dmg *= 0.5 //0.22 + 0.78 * mech.energy //77% damage reduction at zero energy if (mod.energyRegen === 0) dmg *= 0.5 //0.22 + 0.78 * mech.energy //77% damage reduction at zero energy
if (b.isModEntanglement && b.inventory[0] === b.activeGun) { if (mod.isEntanglement && b.inventory[0] === b.activeGun) {
for (let i = 0, len = b.inventory.length; i < len; i++) { for (let i = 0, len = b.inventory.length; i < len; i++) {
dmg *= 0.84 // 1 - 0.16 dmg *= 0.84 // 1 - 0.16
} }
@@ -525,13 +525,13 @@ const mech = {
mech.lastHarmCycle = mech.cycle mech.lastHarmCycle = mech.cycle
//chance to build a drone on damage from mod //chance to build a drone on damage from mod
if (b.isModDroneOnDamage) { if (mod.isDroneOnDamage) {
const len = (dmg - 0.06 * Math.random()) * 40 const len = (dmg - 0.06 * Math.random()) * 40
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
if (Math.random() < 0.5) b.drone() //spawn drone if (Math.random() < 0.5) b.drone() //spawn drone
} }
} }
if (b.isModMineOnDamage && dmg > 0.004 + 0.05 * Math.random()) { if (mod.isMineOnDamage && dmg > 0.004 + 0.05 * Math.random()) {
b.mine({ b.mine({
x: mech.pos.x, x: mech.pos.x,
y: mech.pos.y - 80 y: mech.pos.y - 80
@@ -542,10 +542,10 @@ const mech = {
} }
dmg *= mech.harmReduction() dmg *= mech.harmReduction()
if (b.isModEnergyHealth) { if (mod.isEnergyHealth) {
mech.energy -= dmg; mech.energy -= dmg;
if (mech.energy < 0 || isNaN(mech.energy)) { if (mech.energy < 0 || isNaN(mech.energy)) {
if (b.isModDeathAvoid && powerUps.reroll.rerolls) { //&& Math.random() < 0.5 if (mod.isDeathAvoid && powerUps.reroll.rerolls) { //&& Math.random() < 0.5
powerUps.reroll.changeRerolls(-1) powerUps.reroll.changeRerolls(-1)
mech.energy = mech.maxEnergy * 0.5 mech.energy = mech.maxEnergy * 0.5
@@ -574,7 +574,7 @@ const mech = {
} else { } else {
mech.health -= dmg; mech.health -= dmg;
if (mech.health < 0 || isNaN(mech.health)) { if (mech.health < 0 || isNaN(mech.health)) {
if (b.isModDeathAvoid && powerUps.reroll.rerolls > 0) { //&& Math.random() < 0.5 if (mod.isDeathAvoid && powerUps.reroll.rerolls > 0) { //&& Math.random() < 0.5
powerUps.reroll.changeRerolls(-1) powerUps.reroll.changeRerolls(-1)
mech.health = mech.maxHealth * 0.5 mech.health = mech.maxHealth * 0.5
// if (mech.health < 0.05) mech.health = 0.05 // if (mech.health < 0.05) mech.health = 0.05
@@ -600,7 +600,7 @@ const mech = {
if (dmg > 0.2 * mech.holdingMassScale) mech.drop(); //drop block if holding if (dmg > 0.2 * mech.holdingMassScale) mech.drop(); //drop block if holding
b.modOnHealthChange(); mod.onHealthChange();
mech.displayHealth(); mech.displayHealth();
document.getElementById("dmg").style.transition = "opacity 0s"; document.getElementById("dmg").style.transition = "opacity 0s";
document.getElementById("dmg").style.opacity = 0.1 + Math.min(0.6, dmg * 4); document.getElementById("dmg").style.opacity = 0.1 + Math.min(0.6, dmg * 4);
@@ -617,7 +617,7 @@ const mech = {
}; };
if (mech.defaultFPSCycle < mech.cycle) requestAnimationFrame(normalFPS); if (mech.defaultFPSCycle < mech.cycle) requestAnimationFrame(normalFPS);
if (b.isModSlowFPS) { // slow game if (mod.isSlowFPS) { // slow game
game.fpsCap = 30 //new fps game.fpsCap = 30 //new fps
game.fpsInterval = 1000 / game.fpsCap; game.fpsInterval = 1000 / game.fpsCap;
//how long to wait to return to normal fps //how long to wait to return to normal fps
@@ -767,7 +767,7 @@ const mech = {
}, },
setHoldDefaults() { setHoldDefaults() {
if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy; if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
mech.fieldRegen = b.modEnergyRegen; //0.001 mech.fieldRegen = mod.energyRegen; //0.001
mech.fieldMeterColor = "#0cf" mech.fieldMeterColor = "#0cf"
mech.fieldShieldingScale = 1; mech.fieldShieldingScale = 1;
game.isBodyDamage = true; game.isBodyDamage = true;
@@ -830,7 +830,7 @@ const mech = {
definePlayerMass(mass = mech.defaultMass) { definePlayerMass(mass = mech.defaultMass) {
Matter.Body.setMass(player, mass); Matter.Body.setMass(player, mass);
//reduce air and ground move forces //reduce air and ground move forces
mech.Fx = 0.08 / mass * b.modSquirrelFx //base player mass is 5 mech.Fx = 0.08 / mass * mod.squirrelFx //base player mass is 5
mech.FxAir = 0.4 / mass / mass //base player mass is 5 mech.FxAir = 0.4 / mass / mass //base player mass is 5
//make player stand a bit lower when holding heavy masses //make player stand a bit lower when holding heavy masses
mech.yOffWhen.stand = Math.max(mech.yOffWhen.crouch, Math.min(49, 49 - (mass - 5) * 6)) mech.yOffWhen.stand = Math.max(mech.yOffWhen.crouch, Math.min(49, 49 - (mass - 5) * 6))
@@ -883,8 +883,8 @@ const mech = {
if (mech.holdingTarget) { if (mech.holdingTarget) {
if (keys[32] || game.mouseDownRight) { if (keys[32] || game.mouseDownRight) {
if (mech.energy > 0.001) { if (mech.energy > 0.001) {
mech.energy -= 0.001 / b.modThrowChargeRate; mech.energy -= 0.001 / mod.throwChargeRate;
mech.throwCharge += 0.5 * b.modThrowChargeRate / mech.holdingTarget.mass mech.throwCharge += 0.5 * mod.throwChargeRate / mech.holdingTarget.mass
//draw charge //draw charge
const x = mech.pos.x + 15 * Math.cos(mech.angle); const x = mech.pos.x + 15 * Math.cos(mech.angle);
const y = mech.pos.y + 15 * Math.sin(mech.angle); const y = mech.pos.y + 15 * Math.sin(mech.angle);
@@ -1009,7 +1009,7 @@ const mech = {
y: powerUp[i].velocity.y * 0.11 y: powerUp[i].velocity.y * 0.11
}); });
if (dist2 < 5000 && !game.isChoosing) { //use power up if it is close enough if (dist2 < 5000 && !game.isChoosing) { //use power up if it is close enough
if (b.isModMassEnergy) mech.energy = mech.maxEnergy * 2; if (mod.isMassEnergy) mech.energy = mech.maxEnergy * 2;
Matter.Body.setVelocity(player, { //player knock back, after grabbing power up Matter.Body.setVelocity(player, { //player knock back, after grabbing power up
x: player.velocity.x + ((powerUp[i].velocity.x * powerUp[i].mass) / player.mass) * 0.3, x: player.velocity.x + ((powerUp[i].velocity.x * powerUp[i].mass) / player.mass) * 0.3,
y: player.velocity.y + ((powerUp[i].velocity.y * powerUp[i].mass) / player.mass) * 0.3 y: player.velocity.y + ((powerUp[i].velocity.y * powerUp[i].mass) / player.mass) * 0.3
@@ -1034,12 +1034,12 @@ const mech = {
} }
if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy; if (mech.energy > mech.maxEnergy) mech.energy = mech.maxEnergy;
if (b.modBlockDmg && mech.fieldUpgrades[mech.fieldMode].name === "standing wave harmonics") { if (mod.blockDmg && mech.fieldUpgrades[mech.fieldMode].name === "standing wave harmonics") {
who.damage(b.modBlockDmg) who.damage(mod.blockDmg)
//draw electricity //draw electricity
const step = 40 const step = 40
ctx.beginPath(); ctx.beginPath();
for (let i = 0, len = 2 * b.modBlockDmg; i < len; i++) { for (let i = 0, len = 2 * mod.blockDmg; i < len; i++) {
let x = mech.pos.x - 20 * unit.x; let x = mech.pos.x - 20 * unit.x;
let y = mech.pos.y - 20 * unit.y; let y = mech.pos.y - 20 * unit.y;
ctx.moveTo(x, y); ctx.moveTo(x, y);
@@ -1076,8 +1076,8 @@ const mech = {
}); });
} }
} else { } else {
if (b.isModStunField && mech.fieldUpgrades[mech.fieldMode].name === "perfect diamagnetism") mobs.statusStun(who, b.isModStunField) if (mod.isStunField && mech.fieldUpgrades[mech.fieldMode].name === "perfect diamagnetism") mobs.statusStun(who, mod.isStunField)
// mobs.statusSlow(who, b.isModStunField) // mobs.statusSlow(who, mod.isStunField)
const massRoot = Math.sqrt(Math.max(0.15, who.mass)); // masses above 12 can start to overcome the push back const massRoot = Math.sqrt(Math.max(0.15, who.mass)); // masses above 12 can start to overcome the push back
Matter.Body.setVelocity(who, { Matter.Body.setVelocity(who, {
x: player.velocity.x - (20 * unit.x) / massRoot, x: player.velocity.x - (20 * unit.x) / massRoot,
@@ -1241,7 +1241,7 @@ const mech = {
}, },
fieldUpgrades: [{ fieldUpgrades: [{
name: "field emitter", name: "field emitter",
description: "use <strong class='color-f'>energy</strong> to <strong>shield</strong> yourself from <strong class='color-d'>damage</strong><br><strong>pick up</strong> and <strong>throw</strong> objects", description: "use <strong class='color-f'>energy</strong> to <strong>shield</strong> yourself from <strong>harm</strong><br><strong>pick up</strong> and <strong>throw</strong> objects",
isEasyToAim: false, isEasyToAim: false,
effect: () => { effect: () => {
game.replaceTextLog = true; //allow text over write game.replaceTextLog = true; //allow text over write
@@ -1372,14 +1372,14 @@ const mech = {
// mech.fieldRegen *= 2; // mech.fieldRegen *= 2;
mech.hold = function () { mech.hold = function () {
if (mech.energy > mech.maxEnergy - 0.02 && mech.fieldCDcycle < mech.cycle) { if (mech.energy > mech.maxEnergy - 0.02 && mech.fieldCDcycle < mech.cycle) {
if (b.isModSporeField) { if (mod.isSporeField) {
// mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones // mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones
const len = Math.floor(6 + 4 * Math.random()) const len = Math.floor(6 + 4 * Math.random())
mech.energy -= len * 0.074; mech.energy -= len * 0.074;
for (let i = 0; i < len; i++) { for (let i = 0; i < len; i++) {
b.spore(player) b.spore(player)
} }
} else if (b.isModMissileField) { } else if (mod.isMissileField) {
// mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones // mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones
mech.energy -= 0.6; mech.energy -= 0.6;
b.missile({ b.missile({
@@ -1387,9 +1387,9 @@ const mech = {
y: mech.pos.y + 40 * Math.sin(mech.angle) - 3 y: mech.pos.y + 40 * Math.sin(mech.angle) - 3
}, },
mech.angle + (0.5 - Math.random()) * (mech.crouch ? 0 : 0.2), mech.angle + (0.5 - Math.random()) * (mech.crouch ? 0 : 0.2),
-3 * (0.5 - Math.random()) + (mech.crouch ? 25 : -8) * b.modFireRate, -3 * (0.5 - Math.random()) + (mech.crouch ? 25 : -8) * mod.fireRate,
1, b.modBabyMissiles) 1, mod.babyMissiles)
} else if (b.isModIceField) { } else if (mod.isIceField) {
// mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones // mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones
mech.energy -= 0.061; mech.energy -= 0.061;
b.iceIX(1) b.iceIX(1)
@@ -1442,7 +1442,7 @@ const mech = {
mech.lookForPickUp(); mech.lookForPickUp();
let DRAIN = 0.00105; let DRAIN = 0.00105;
if (mech.energy > DRAIN) { if (mech.energy > DRAIN) {
if (b.isModHarmReduce) { if (mod.isHarmReduce) {
mech.fieldDamageResistance = 0.1; // 1 - 0.9 mech.fieldDamageResistance = 0.1; // 1 - 0.9
DRAIN = 0.0007 //2x energy drain DRAIN = 0.0007 //2x energy drain
} else { } else {
@@ -1518,7 +1518,7 @@ const mech = {
ctx.fillStyle = "#f5f5ff"; ctx.fillStyle = "#f5f5ff";
ctx.globalCompositeOperation = "difference"; ctx.globalCompositeOperation = "difference";
ctx.fill(); ctx.fill();
if (b.isModHawking) { if (mod.isHawking) {
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
if (mob[i].distanceToPlayer2() < this.fieldDrawRadius * this.fieldDrawRadius && Matter.Query.ray(map, mech.pos, mob[i].position).length === 0 && Matter.Query.ray(body, mech.pos, mob[i].position).length === 0) { if (mob[i].distanceToPlayer2() < this.fieldDrawRadius * this.fieldDrawRadius && Matter.Query.ray(map, mech.pos, mob[i].position).length === 0 && Matter.Query.ray(body, mech.pos, mob[i].position).length === 0) {
mob[i].damage(b.dmgScale * 0.085); mob[i].damage(b.dmgScale * 0.085);
@@ -1572,7 +1572,7 @@ const mech = {
} else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //not hold but field button is pressed } else if ((keys[32] || game.mouseDownRight) && mech.fieldCDcycle < mech.cycle) { //not hold but field button is pressed
mech.grabPowerUp(); mech.grabPowerUp();
mech.lookForPickUp(); mech.lookForPickUp();
const DRAIN = 0.0006 const DRAIN = 0.001
if (mech.energy > DRAIN) { if (mech.energy > DRAIN) {
mech.energy -= DRAIN; mech.energy -= DRAIN;
if (mech.energy < 0) { if (mech.energy < 0) {
@@ -1581,7 +1581,7 @@ const mech = {
} }
//calculate laser collision //calculate laser collision
let best; let best;
let range = b.isModPlasmaRange * (140 + (mech.crouch ? 400 : 300) * Math.sqrt(Math.random())) //+ 100 * Math.sin(mech.cycle * 0.3); let range = mod.isPlasmaRange * (140 + (mech.crouch ? 400 : 300) * Math.sqrt(Math.random())) //+ 100 * Math.sin(mech.cycle * 0.3);
// const dir = mech.angle // + 0.04 * (Math.random() - 0.5) // const dir = mech.angle // + 0.04 * (Math.random() - 0.5)
const path = [{ const path = [{
x: mech.pos.x + 20 * Math.cos(mech.angle), x: mech.pos.x + 20 * Math.cos(mech.angle),
@@ -1783,7 +1783,7 @@ const mech = {
} }
game.cycle--; //pause all functions that depend on game cycle increasing game.cycle--; //pause all functions that depend on game cycle increasing
if (b.isModTimeSkip) { if (mod.isTimeSkip) {
game.isTimeSkipping = true; game.isTimeSkipping = true;
mech.cycle++; mech.cycle++;
game.gravity(); game.gravity();
@@ -1803,7 +1803,7 @@ const mech = {
game.isTimeSkipping = false; game.isTimeSkipping = false;
} }
// game.cycle--; //pause all functions that depend on game cycle increasing // game.cycle--; //pause all functions that depend on game cycle increasing
// if (b.isModTimeSkip && !game.isTimeSkipping) { //speed up the rate of time // if (mod.isTimeSkip && !game.isTimeSkipping) { //speed up the rate of time
// game.timeSkip(1) // game.timeSkip(1)
// mech.energy += 1.5 * DRAIN; //x1 to undo the energy drain from time speed up, x1.5 to cut energy drain in half // mech.energy += 1.5 * DRAIN; //x1 to undo the energy drain from time speed up, x1.5 to cut energy drain in half
// } // }
@@ -1844,7 +1844,7 @@ const mech = {
const off2 = 1 - 0.06 * Math.sin(mech.fieldPhase); const off2 = 1 - 0.06 * Math.sin(mech.fieldPhase);
ctx.beginPath(); ctx.beginPath();
ctx.ellipse(mech.pos.x, mech.pos.y, radius * off1, radius * off2, rotate, 0, 2 * Math.PI); ctx.ellipse(mech.pos.x, mech.pos.y, radius * off1, radius * off2, rotate, 0, 2 * Math.PI);
if (b.modRenormalization) { if (mod.renormalization) {
for (let i = 0; i < bullet.length; i++) { for (let i = 0; i < bullet.length; i++) {
ctx.moveTo(bullet[i].position.x, bullet[i].position.y) ctx.moveTo(bullet[i].position.x, bullet[i].position.y)
ctx.arc(bullet[i].position.x, bullet[i].position.y, radius, 0, 2 * Math.PI); ctx.arc(bullet[i].position.x, bullet[i].position.y, radius, 0, 2 * Math.PI);
@@ -1877,7 +1877,7 @@ const mech = {
mech.grabPowerUp(); mech.grabPowerUp();
mech.lookForPickUp(); mech.lookForPickUp();
const DRAIN = 0.0003 + 0.00015 * player.speed + ((!b.modRenormalization && mech.fireCDcycle > mech.cycle) ? 0.005 : 0.001) const DRAIN = 0.0003 + 0.00015 * player.speed + ((!mod.renormalization && mech.fireCDcycle > mech.cycle) ? 0.005 : 0.001)
if (mech.energy > DRAIN) { if (mech.energy > DRAIN) {
mech.energy -= DRAIN; mech.energy -= DRAIN;
// if (mech.energy < 0.001) { // if (mech.energy < 0.001) {
@@ -1900,7 +1900,7 @@ const mech = {
//draw outline of shield //draw outline of shield
ctx.fillStyle = `rgba(140,217,255,0.5)` ctx.fillStyle = `rgba(140,217,255,0.5)`
ctx.fill() ctx.fill()
} else if (b.superposition && inPlayer[i].dropPowerUp) { } else if (mod.superposition && inPlayer[i].dropPowerUp) {
// inPlayer[i].damage(0.4 * b.dmgScale); //damage mobs inside the player // inPlayer[i].damage(0.4 * b.dmgScale); //damage mobs inside the player
// mech.energy += 0.005; // mech.energy += 0.005;
@@ -2035,7 +2035,7 @@ const mech = {
y: powerUp[i].velocity.y * 0.11 y: powerUp[i].velocity.y * 0.11
}); });
if (dist2 < 5000 && !game.isChoosing) { //use power up if it is close enough if (dist2 < 5000 && !game.isChoosing) { //use power up if it is close enough
if (b.isModMassEnergy) mech.energy = mech.maxEnergy * 2; if (mod.isMassEnergy) mech.energy = mech.maxEnergy * 2;
powerUp[i].effect(); powerUp[i].effect();
Matter.World.remove(engine.world, powerUp[i]); Matter.World.remove(engine.world, powerUp[i]);
powerUp.splice(i, 1); powerUp.splice(i, 1);
@@ -2077,7 +2077,7 @@ const mech = {
} }
} }
if (b.isModPilotFreeze) { if (mod.isPilotFreeze) {
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, mech.fieldPosition)) < mech.fieldRadius) { if (Vector.magnitude(Vector.sub(mob[i].position, mech.fieldPosition)) < mech.fieldRadius) {
mobs.statusSlow(mob[i], 120) mobs.statusSlow(mob[i], 120)

View File

@@ -13,17 +13,17 @@ const powerUps = {
// game.makeTextLog(`${game.SVGrightMouse}<strong style='font-size:30px;'> ${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'></span><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 600); // game.makeTextLog(`${game.SVGrightMouse}<strong style='font-size:30px;'> ${mech.fieldUpgrades[mech.fieldMode].name}</strong><br><span class='faded'></span><br>${mech.fieldUpgrades[mech.fieldMode].description}`, 600);
// game.replaceTextLog = false; // game.replaceTextLog = false;
} else if (type === "mod") { } else if (type === "mod") {
b.giveMod(index) mod.giveMod(index)
// game.replaceTextLog = true; // game.replaceTextLog = true;
// game.makeTextLog(`<div class="circle mod"></div> &nbsp; <strong style='font-size:30px;'>${b.mods[index].name}</strong><br><br> ${b.mods[index].description}`, 500); // game.makeTextLog(`<div class="circle mod"></div> &nbsp; <strong style='font-size:30px;'>${mod.mods[index].name}</strong><br><br> ${mod.mods[index].description}`, 500);
// game.replaceTextLog = false; // game.replaceTextLog = false;
} }
powerUps.endDraft(); powerUps.endDraft();
}, },
endDraft() { endDraft() {
if (b.manyWorlds && powerUps.reroll.rerolls < 1) { if (mod.manyWorlds && powerUps.reroll.rerolls < 1) {
powerUps.spawn(mech.pos.x, mech.pos.y, "reroll"); powerUps.spawn(mech.pos.x, mech.pos.y, "reroll");
if (Math.random() < b.modBayesian) 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.body.style.cursor = "none";
document.getElementById("choose-grid").style.display = "none" document.getElementById("choose-grid").style.display = "none"
@@ -53,7 +53,7 @@ const powerUps = {
changeRerolls(amount) { changeRerolls(amount) {
powerUps.reroll.rerolls += amount powerUps.reroll.rerolls += amount
if (powerUps.reroll.rerolls < 0) powerUps.reroll.rerolls = 0 if (powerUps.reroll.rerolls < 0) powerUps.reroll.rerolls = 0
if (b.isModDeathAvoid && document.getElementById("mod-anthropic")) { if (mod.isDeathAvoid && document.getElementById("mod-anthropic")) {
document.getElementById("mod-anthropic").innerHTML = `(${powerUps.reroll.rerolls})` document.getElementById("mod-anthropic").innerHTML = `(${powerUps.reroll.rerolls})`
} }
}, },
@@ -90,9 +90,9 @@ const powerUps = {
return 40 * Math.sqrt(0.1 + Math.random() * 0.5); return 40 * Math.sqrt(0.1 + Math.random() * 0.5);
}, },
effect() { effect() {
if (!b.isModEnergyHealth && mech.alive) { if (!mod.isEnergyHealth && mech.alive) {
let heal = 0 let heal = 0
for (let i = 0; i < b.modRecursiveHealing; i++) heal += ((this.size / 40) ** 2) for (let i = 0; i < mod.recursiveHealing; i++) heal += ((this.size / 40) ** 2)
if (heal > 0) { if (heal > 0) {
game.makeTextLog("<div class='circle heal'></div> &nbsp; <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (Math.min(mech.maxHealth - mech.health, heal) * game.healScale * 100).toFixed(0) + "%</span>", 300) game.makeTextLog("<div class='circle heal'></div> &nbsp; <span style='font-size:115%;'> <strong style = 'letter-spacing: 2px;'>heal</strong> " + (Math.min(mech.maxHealth - mech.health, heal) * game.healScale * 100).toFixed(0) + "%</span>", 300)
mech.addHealth(heal); mech.addHealth(heal);
@@ -151,7 +151,7 @@ const powerUps = {
if (i !== mech.fieldMode && (!game.isEasyToAimMode || mech.fieldUpgrades[i].isEasyToAim) && i !== skip1 && i !== skip2 && i !== skip3 && i !== skip4) options.push(i); if (i !== mech.fieldMode && (!game.isEasyToAimMode || mech.fieldUpgrades[i].isEasyToAim) && i !== skip1 && i !== skip2 && i !== skip3 && i !== skip4) options.push(i);
} }
//remove repeats from last selection //remove repeats from last selection
const totalChoices = b.isModDeterminism ? 1 : 3 + b.isModExtraChoice * 2 const totalChoices = mod.isDeterminism ? 1 : 3 + mod.isExtraChoice * 2
if (powerUps.field.choiceLog.length > totalChoices || powerUps.field.choiceLog.length === totalChoices) { //make sure this isn't the first time getting a power up and there are previous choices to remove if (powerUps.field.choiceLog.length > totalChoices || powerUps.field.choiceLog.length === totalChoices) { //make sure this isn't the first time getting a power up and there are previous choices to remove
for (let i = 0; i < totalChoices; i++) { //repeat for each choice from the last selection for (let i = 0; i < totalChoices; i++) { //repeat for each choice from the last selection
if (options.length > totalChoices) { if (options.length > totalChoices) {
@@ -175,13 +175,13 @@ const powerUps = {
if (choice1 > -1) { if (choice1 > -1) {
let text = `<div class='cancel' onclick='powerUps.endDraft()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a field</h3>` let text = `<div class='cancel' onclick='powerUps.endDraft()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a field</h3>`
text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice1})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice1].name}</div> ${mech.fieldUpgrades[choice1].description}</div>` text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice1})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice1].name}</div> ${mech.fieldUpgrades[choice1].description}</div>`
if (!b.isModDeterminism) { if (!mod.isDeterminism) {
choice2 = pick(mech.fieldUpgrades, choice1) choice2 = pick(mech.fieldUpgrades, choice1)
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice2})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice2].name}</div> ${mech.fieldUpgrades[choice2].description}</div>` if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice2})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice2].name}</div> ${mech.fieldUpgrades[choice2].description}</div>`
choice3 = pick(mech.fieldUpgrades, choice1, choice2) choice3 = pick(mech.fieldUpgrades, choice1, choice2)
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice3})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice3].name}</div> ${mech.fieldUpgrades[choice3].description}</div>` if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice3})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice3].name}</div> ${mech.fieldUpgrades[choice3].description}</div>`
} }
if (b.isModExtraChoice) { if (mod.isExtraChoice) {
let choice4 = pick(mech.fieldUpgrades, choice1, choice2, choice3) let choice4 = pick(mech.fieldUpgrades, choice1, choice2, choice3)
if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice4})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice4].name}</div> ${mech.fieldUpgrades[choice4].description}</div>` if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('field',${choice4})"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[choice4].name}</div> ${mech.fieldUpgrades[choice4].description}</div>`
let choice5 = pick(mech.fieldUpgrades, choice1, choice2, choice3, choice4) let choice5 = pick(mech.fieldUpgrades, choice1, choice2, choice3, choice4)
@@ -213,13 +213,13 @@ const powerUps = {
effect() { effect() {
function pick(skip1 = -1, skip2 = -1, skip3 = -1, skip4 = -1) { function pick(skip1 = -1, skip2 = -1, skip3 = -1, skip4 = -1) {
let options = []; let options = [];
for (let i = 0; i < b.mods.length; i++) { for (let i = 0; i < mod.mods.length; i++) {
if (b.mods[i].count < b.mods[i].maxCount && i !== skip1 && i !== skip2 && i !== skip3 && i !== skip4 && b.mods[i].allowed()) { if (mod.mods[i].count < mod.mods[i].maxCount && i !== skip1 && i !== skip2 && i !== skip3 && i !== skip4 && mod.mods[i].allowed()) {
options.push(i); options.push(i);
} }
} }
//remove repeats from last selection //remove repeats from last selection
const totalChoices = b.isModDeterminism ? 1 : 3 + b.isModExtraChoice * 2 const totalChoices = mod.isDeterminism ? 1 : 3 + mod.isExtraChoice * 2
if (powerUps.mod.choiceLog.length > totalChoices || powerUps.mod.choiceLog.length === totalChoices) { //make sure this isn't the first time getting a power up and there are previous choices to remove if (powerUps.mod.choiceLog.length > totalChoices || powerUps.mod.choiceLog.length === totalChoices) { //make sure this isn't the first time getting a power up and there are previous choices to remove
for (let i = 0; i < totalChoices; i++) { //repeat for each choice from the last selection for (let i = 0; i < totalChoices; i++) { //repeat for each choice from the last selection
if (options.length > totalChoices) { if (options.length > totalChoices) {
@@ -242,18 +242,18 @@ const powerUps = {
let choice3 = -1 let choice3 = -1
if (choice1 > -1) { if (choice1 > -1) {
let text = `<div class='cancel' onclick='powerUps.endDraft()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a mod</h3>` let text = `<div class='cancel' onclick='powerUps.endDraft()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a mod</h3>`
text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice1})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice1].name}</div> ${b.mods[choice1].description}</div>` text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice1})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[choice1].name}</div> ${mod.mods[choice1].description}</div>`
if (!b.isModDeterminism) { if (!mod.isDeterminism) {
choice2 = pick(choice1) choice2 = pick(choice1)
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice2})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice2].name}</div> ${b.mods[choice2].description}</div>` if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice2})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[choice2].name}</div> ${mod.mods[choice2].description}</div>`
choice3 = pick(choice1, choice2) choice3 = pick(choice1, choice2)
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice3})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice3].name}</div> ${b.mods[choice3].description}</div>` if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice3})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[choice3].name}</div> ${mod.mods[choice3].description}</div>`
} }
if (b.isModExtraChoice) { if (mod.isExtraChoice) {
let choice4 = pick(choice1, choice2, choice3) let choice4 = pick(choice1, choice2, choice3)
if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice4})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice4].name}</div> ${b.mods[choice4].description}</div>` if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice4})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[choice4].name}</div> ${mod.mods[choice4].description}</div>`
let choice5 = pick(choice1, choice2, choice3, choice4) let choice5 = pick(choice1, choice2, choice3, choice4)
if (choice5 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice5})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${b.mods[choice5].name}</div> ${b.mods[choice5].description}</div>` if (choice5 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('mod',${choice5})"><div class="grid-title"><div class="circle-grid mod"></div> &nbsp; ${mod.mods[choice5].name}</div> ${mod.mods[choice5].description}</div>`
powerUps.mod.choiceLog.push(choice4) powerUps.mod.choiceLog.push(choice4)
powerUps.mod.choiceLog.push(choice5) powerUps.mod.choiceLog.push(choice5)
} }
@@ -286,7 +286,7 @@ const powerUps = {
} }
//remove repeats from last selection //remove repeats from last selection
const totalChoices = b.isModDeterminism ? 1 : 3 + b.isModExtraChoice * 2 const totalChoices = mod.isDeterminism ? 1 : 3 + mod.isExtraChoice * 2
if (powerUps.gun.choiceLog.length > totalChoices || powerUps.gun.choiceLog.length === totalChoices) { //make sure this isn't the first time getting a power up and there are previous choices to remove if (powerUps.gun.choiceLog.length > totalChoices || powerUps.gun.choiceLog.length === totalChoices) { //make sure this isn't the first time getting a power up and there are previous choices to remove
for (let i = 0; i < totalChoices; i++) { //repeat for each choice from the last selection for (let i = 0; i < totalChoices; i++) { //repeat for each choice from the last selection
if (options.length > totalChoices) { if (options.length > totalChoices) {
@@ -310,13 +310,13 @@ const powerUps = {
if (choice1 > -1) { if (choice1 > -1) {
let text = `<div class='cancel' onclick='powerUps.endDraft()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a gun</h3>` let text = `<div class='cancel' onclick='powerUps.endDraft()'>✕</div><h3 style = 'color:#fff; text-align:left; margin: 0px;'>choose a gun</h3>`
text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice1})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice1].name}</div> ${b.guns[choice1].description}</div>` text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice1})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice1].name}</div> ${b.guns[choice1].description}</div>`
if (!b.isModDeterminism) { if (!mod.isDeterminism) {
choice2 = pick(b.guns, choice1) choice2 = pick(b.guns, choice1)
if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice2})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice2].name}</div> ${b.guns[choice2].description}</div>` if (choice2 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice2})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice2].name}</div> ${b.guns[choice2].description}</div>`
choice3 = pick(b.guns, choice1, choice2) choice3 = pick(b.guns, choice1, choice2)
if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice3})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice3].name}</div> ${b.guns[choice3].description}</div>` if (choice3 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice3})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice3].name}</div> ${b.guns[choice3].description}</div>`
} }
if (b.isModExtraChoice) { if (mod.isExtraChoice) {
let choice4 = pick(b.guns, choice1, choice2, choice3) let choice4 = pick(b.guns, choice1, choice2, choice3)
if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice4})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice4].name}</div> ${b.guns[choice4].description}</div>` if (choice4 > -1) text += `<div class="choose-grid-module" onclick="powerUps.choose('gun',${choice4})"><div class="grid-title"><div class="circle-grid gun"></div> &nbsp; ${b.guns[choice4].name}</div> ${b.guns[choice4].description}</div>`
let choice5 = pick(b.guns, choice1, choice2, choice3, choice4) let choice5 = pick(b.guns, choice1, choice2, choice3, choice4)
@@ -353,63 +353,63 @@ const powerUps = {
} }
}, },
spawnRandomPowerUp(x, y) { //mostly used after mob dies spawnRandomPowerUp(x, y) { //mostly used after mob dies
if ((Math.random() * Math.random() - 0.3 > Math.sqrt(mech.health) && !b.isModEnergyHealth) || Math.random() < 0.035) { //spawn heal chance is higher at low health 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"); powerUps.spawn(x, y, "heal");
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "heal"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "heal");
return; return;
} }
if (Math.random() < 0.15 && b.inventory.length > 0 && !b.modBayesian) { if (Math.random() < 0.15 && b.inventory.length > 0 && !mod.bayesian) {
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "ammo"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "ammo");
return; return;
} }
if (Math.random() < 0.002 * (3 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 3 if (Math.random() < 0.002 * (3 - b.inventory.length)) { //a new gun has a low chance for each not acquired gun up to 3
powerUps.spawn(x, y, "gun"); powerUps.spawn(x, y, "gun");
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "gun"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "gun");
return; return;
} }
if (Math.random() < 0.0027 * (15 - b.modCount)) { //a new mod has a low chance for each not acquired mod up to 15 if (Math.random() < 0.0027 * (15 - mod.totalCount)) { //a new mod has a low chance for each not acquired mod up to 15
powerUps.spawn(x, y, "mod"); powerUps.spawn(x, y, "mod");
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "mod"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod");
return; return;
} }
if (Math.random() < 0.006) { if (Math.random() < 0.006) {
powerUps.spawn(x, y, "field"); powerUps.spawn(x, y, "field");
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "field"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field");
return; return;
} }
if (Math.random() < 0.005) { if (Math.random() < 0.005) {
powerUps.spawn(x, y, "reroll"); powerUps.spawn(x, y, "reroll");
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "reroll"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "reroll");
return; return;
} }
}, },
spawnBossPowerUp(x, y) { //boss spawns field and gun mod upgrades spawnBossPowerUp(x, y) { //boss spawns field and gun mod upgrades
if (mech.fieldMode === 0) { if (mech.fieldMode === 0) {
powerUps.spawn(x, y, "field") powerUps.spawn(x, y, "field")
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "field") if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field")
} else if (Math.random() < 0.9) { } else if (Math.random() < 0.9) {
powerUps.spawn(x, y, "mod") powerUps.spawn(x, y, "mod")
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "mod") if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod")
} else if (Math.random() < 0.5) { } else if (Math.random() < 0.5) {
powerUps.spawn(x, y, "gun") powerUps.spawn(x, y, "gun")
if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "gun") if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "gun")
// } else if (Math.random() < 0.5) { // } else if (Math.random() < 0.5) {
// powerUps.spawn(x, y, "field"); // powerUps.spawn(x, y, "field");
// if (Math.random() < b.modBayesian) powerUps.spawn(x, y, "field"); // if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field");
} else if (mech.health < 0.65 && !b.isModEnergyHealth) { } else if (mech.health < 0.65 && !mod.isEnergyHealth) {
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
if (Math.random() < b.modBayesian) { if (Math.random() < mod.bayesian) {
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal"); powerUps.spawn(x, y, "heal");
} }
} else if (!b.modBayesian) { } else if (!mod.bayesian) {
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo"); powerUps.spawn(x, y, "ammo");
@@ -422,7 +422,7 @@ const powerUps = {
powerUps.spawn(x, y, "reroll"); powerUps.spawn(x, y, "reroll");
} else if (Math.random() < 0.5) { } else if (Math.random() < 0.5) {
powerUps.spawn(x, y, "heal", false); powerUps.spawn(x, y, "heal", false);
} else if (!b.modBayesian) { } else if (!mod.bayesian) {
powerUps.spawn(x, y, "ammo", false); powerUps.spawn(x, y, "ammo", false);
} }
}, },
@@ -430,7 +430,7 @@ const powerUps = {
if (level.levelsCleared < 5) { if (level.levelsCleared < 5) {
if (b.inventory.length === 0) { if (b.inventory.length === 0) {
powerUps.spawn(x, y, "gun", false); powerUps.spawn(x, y, "gun", false);
} else if (b.modCount === 0) { } else if (mod.totalCount === 0) {
powerUps.spawn(x, y, "mod", false); //starting gun powerUps.spawn(x, y, "mod", false); //starting gun
} else if (b.inventory.length < 2) { } else if (b.inventory.length < 2) {
powerUps.spawn(x, y, "gun", false); powerUps.spawn(x, y, "gun", false);

View File

@@ -1020,7 +1020,7 @@ const spawn = {
vertexCollision(where, look, body); vertexCollision(where, look, body);
if (!mech.isStealth) vertexCollision(where, look, [player]); if (!mech.isStealth) vertexCollision(where, look, [player]);
if (best.who && best.who === player && mech.immuneCycle < mech.cycle) { if (best.who && best.who === player && mech.immuneCycle < mech.cycle) {
mech.immuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles
const dmg = 0.14 * game.dmgScale; const dmg = 0.14 * game.dmgScale;
mech.damage(dmg); mech.damage(dmg);
game.drawList.push({ //add dmg to draw queue game.drawList.push({ //add dmg to draw queue
@@ -1140,7 +1140,7 @@ const spawn = {
!mech.isStealth !mech.isStealth
) { ) {
this.foundPlayer(); this.foundPlayer();
if (this.cd === Infinity) this.cd = game.cycle + this.delay; if (this.cd === Infinity) this.cd = game.cycle + this.delay * 0.7;
} else if (this.seePlayer.recall) { } else if (this.seePlayer.recall) {
this.lostPlayer(); this.lostPlayer();
this.cd = Infinity this.cd = Infinity
@@ -1445,11 +1445,11 @@ const spawn = {
// Matter.Body.rotate(me, Math.PI) // Matter.Body.rotate(me, Math.PI)
me.memory = 120; me.memory = 120;
me.fireFreq = 0.007 + Math.random() * 0.003; me.fireFreq = 0.0065 + Math.random() * 0.003;
me.noseLength = 0; me.noseLength = 0;
me.fireAngle = 0; me.fireAngle = 0;
me.accelMag = 0.0005 * game.accelScale; me.accelMag = 0.0006 * game.accelScale;
me.frictionAir = 0.05; me.frictionAir = 0.04;
me.lookTorque = 0.0000028 * (Math.random() > 0.5 ? -1 : 1); me.lookTorque = 0.0000028 * (Math.random() > 0.5 ? -1 : 1);
me.fireDir = { me.fireDir = {
x: 0, x: 0,
@@ -1476,7 +1476,7 @@ const spawn = {
Matter.Body.setDensity(me, 0.00005); //normal is 0.001 Matter.Body.setDensity(me, 0.00005); //normal is 0.001
me.timeLeft = 420; me.timeLeft = 420;
me.accelMag = 0.0004 * game.accelScale; me.accelMag = 0.0004 * game.accelScale;
me.frictionAir = 0.035; me.frictionAir = 0.033;
me.restitution = 0.5; me.restitution = 0.5;
me.leaveBody = false; me.leaveBody = false;
me.dropPowerUp = false; me.dropPowerUp = false;

View File

@@ -492,8 +492,6 @@ em {
margin-bottom: -5px; margin-bottom: -5px;
} }
.field { .field {
background: #0cf; background: #0cf;
} }

View File

@@ -1,12 +1,41 @@
mod - many worlds: 100% chance on choosing a power up to spawn a reroll if you have no rerolls
mod - microstates: +7% damage for every 10 active bullets
(requires mod: Lorentzian topology)
mod - laser diode: laser, pulse, and laser-bots use 37% less energy
25% increase in difficulty scaling (level 10 should now have the difficulty of level 12)
effects: player damage, mod damage, mob acceleration, mob reaction time, mob cooldown time
************** TODO - n-gon ************** ************** TODO - n-gon **************
impact shear buff to 3 nails?
make a lower tier of basic mods
33% chance for basic mod on each selection
make an odds variable that starts at 0% and gains 33% for each normal mod, resets to 0% after get a basic mod
don't track these mods for avoiding no repeats
make ball different color to indicate quality
basic: grey? smaller size?
also make gun/field specific mods have a different icon for top tier
don't include basic mods in custom mod?
basic mods can show on guns or fields?
ideas
+5% damage
+8% haste
+5% damage reduction
+25% max health
+25% max energy
spawn 2 ammo //or 3?
spawn 2 heal
spawn 2 reroll //or 1?
improve movement fluidity, through mods, or default improvements
let legs jump on mobs, but player will still take damage
like: ori and the blind forest, celeste
many of the movement abilities in these games require levels to be built around the ability
general feeling of responsiveness and control
coyote time: can still jump a few cycles after leaving ground
mod: double jump
mod: air dash
mod: wall jump
wall grab?
maybe remove falling damage and block damage?
rays can have width, how to use this? rays can have width, how to use this?
Matter.Query.ray(bodies, startPoint, endPoint, [rayWidth]) Matter.Query.ray(bodies, startPoint, endPoint, [rayWidth])
wide lasers? wide lasers?