URL build goes to custom, ammo goes to all guns

This commit is contained in:
landgreen
2020-08-09 05:43:00 -07:00
parent 2e9ff7e292
commit bf5f55a7ec
7 changed files with 148 additions and 85 deletions

View File

@@ -485,7 +485,7 @@ const b = {
spore(where, isFreeze = mod.isSporeFreeze) { //used with the mod upgrade in mob.death() spore(where, isFreeze = mod.isSporeFreeze) { //used with the mod upgrade in mob.death()
const bIndex = bullet.length; const bIndex = bullet.length;
const side = 4; const side = 4;
bullet[bIndex] = Bodies.polygon(where.x, where.y, 5, side, { bullet[bIndex] = Bodies.polygon(where.x, where.y, 4, side, {
// density: 0.0015, //frictionAir: 0.01, // density: 0.0015, //frictionAir: 0.01,
inertia: Infinity, inertia: Infinity,
isFreeze: isFreeze, isFreeze: isFreeze,
@@ -1578,7 +1578,7 @@ const b = {
name: "shotgun", name: "shotgun",
description: "fire a <strong>burst</strong> of short range <strong> bullets</strong> <br><em>crouch to reduce recoil</em>", description: "fire a <strong>burst</strong> of short range <strong> bullets</strong> <br><em>crouch to reduce recoil</em>",
ammo: 0, ammo: 0,
ammoPack: 8, ammoPack: 6,
have: false, have: false,
fire() { fire() {
let knock, spread let knock, spread
@@ -1591,7 +1591,7 @@ const b = {
mech.fireCDcycle = mech.cycle + Math.floor(45 * b.fireCD); // cool down mech.fireCDcycle = mech.cycle + Math.floor(45 * b.fireCD); // cool down
if (mod.isShotgunImmune) mech.immuneCycle = mech.cycle + Math.floor(47 * b.fireCD); //player is immune to collision damage for 30 cycles if (mod.isShotgunImmune) mech.immuneCycle = mech.cycle + Math.floor(47 * b.fireCD); //player is immune to collision damage for 30 cycles
spread = 1.3 spread = 1.3
knock = 0.08 knock = 0.1
} }
if (mod.isShotgunRecoil) { if (mod.isShotgunRecoil) {
@@ -1616,27 +1616,27 @@ const b = {
x: speed * Math.cos(dir), x: speed * Math.cos(dir),
y: speed * Math.sin(dir) y: speed * Math.sin(dir)
} }
b.nail(pos, velocity, 0.6) b.nail(pos, velocity, 1)
} }
} else { } else {
const side = 19 * mod.bulletSize const side = 21 * mod.bulletSize
for (let i = 0; i < 15; i++) { for (let i = 0; i < 15; i++) {
const me = bullet.length; const me = bullet.length;
const dir = mech.angle + (Math.random() - 0.5) * spread const dir = mech.angle + (Math.random() - 0.5) * spread
bullet[me] = Bodies.rectangle(mech.pos.x + 35 * Math.cos(mech.angle) + 15 * (Math.random() - 0.5), mech.pos.y + 35 * Math.sin(mech.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir)); bullet[me] = Bodies.rectangle(mech.pos.x + 35 * Math.cos(mech.angle) + 15 * (Math.random() - 0.5), mech.pos.y + 35 * Math.sin(mech.angle) + 15 * (Math.random() - 0.5), side, side, b.fireAttributes(dir));
World.add(engine.world, bullet[me]); //add bullet to world World.add(engine.world, bullet[me]); //add bullet to world
const SPEED = 50 + Math.random() * 10 const SPEED = 52 + Math.random() * 8
Matter.Body.setVelocity(bullet[me], { Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir), x: SPEED * Math.cos(dir),
y: SPEED * Math.sin(dir) y: SPEED * Math.sin(dir)
}); });
bullet[me].endCycle = game.cycle + 40 bullet[me].endCycle = game.cycle + 40
bullet[me].minDmgSpeed = 20 bullet[me].minDmgSpeed = 15
// bullet[me].dmg = 0.1 // bullet[me].dmg = 0.1
bullet[me].frictionAir = 0.034; bullet[me].frictionAir = 0.034;
bullet[me].do = function () { bullet[me].do = function () {
if (!mech.isBodiesAsleep) { if (!mech.isBodiesAsleep) {
const scale = 1 - 0.035 / mod.isBulletsLastLonger const scale = 1 - 0.034 / mod.isBulletsLastLonger
Matter.Body.scale(this, scale, scale); Matter.Body.scale(this, scale, scale);
} }
}; };
@@ -2093,7 +2093,7 @@ const b = {
name: "vacuum bomb", name: "vacuum bomb",
description: "fire a bomb that <strong>sucks</strong> before <strong class='color-e'>exploding</strong><br><strong>click</strong> left mouse again to <strong>detonate</strong>", description: "fire a bomb that <strong>sucks</strong> before <strong class='color-e'>exploding</strong><br><strong>click</strong> left mouse again to <strong>detonate</strong>",
ammo: 0, ammo: 0,
ammoPack: 3, ammoPack: 2.5,
have: false, have: false,
fire() { fire() {
const me = bullet.length; const me = bullet.length;
@@ -2105,7 +2105,7 @@ const b = {
bullet[me].restitution = 0.2; bullet[me].restitution = 0.2;
bullet[me].friction = 0.3; bullet[me].friction = 0.3;
bullet[me].endCycle = Infinity bullet[me].endCycle = Infinity
bullet[me].explodeRad = 450 + Math.floor(Math.random() * 30); bullet[me].explodeRad = 450 + Math.floor(Math.random() * 50);
bullet[me].onEnd = function () { bullet[me].onEnd = function () {
b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
@@ -2562,7 +2562,7 @@ const b = {
name: "rail gun", name: "rail gun",
description: "use <strong class='color-f'>energy</strong> to launch a high-speed <strong>dense</strong> rod<br><strong>hold</strong> left mouse to charge, <strong>release</strong> to fire", description: "use <strong class='color-f'>energy</strong> to launch a high-speed <strong>dense</strong> rod<br><strong>hold</strong> left mouse to charge, <strong>release</strong> to fire",
ammo: 0, ammo: 0,
ammoPack: 4, ammoPack: 3,
have: false, have: false,
fire() { fire() {
const me = bullet.length; const me = bullet.length;

View File

@@ -199,7 +199,7 @@ const game = {
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++) {
lessDamage *= 0.85 // 1 - 0.15 lessDamage *= 0.87 // 1 - 0.15
} }
document.getElementById("mod-entanglement").innerHTML = " " + ((1 - lessDamage) * 100).toFixed(0) + "%" document.getElementById("mod-entanglement").innerHTML = " " + ((1 - lessDamage) * 100).toFixed(0) + "%"
} else { } else {
@@ -595,24 +595,6 @@ const game = {
document.getElementById("dmg").style.display = "inline"; document.getElementById("dmg").style.display = "inline";
document.getElementById("health-bg").style.display = "inline"; document.getElementById("health-bg").style.display = "inline";
// window.onmousedown = function (e) {
// //mouse up event in set in index.js
// // game.mouseDown = true;
// if (e.which === 3) {
// game.mouseDownRight = true;
// } else {
// game.mouseDown = true;
// }
// // keep this disabled unless building maps
// // if (!game.mouseDown){
// // game.getCoords.pos1.x = Math.round(game.mouseInGame.x / 25) * 25;
// // game.getCoords.pos1.y = Math.round(game.mouseInGame.y / 25) * 25;
// // }
// // mech.throwBlock();
// };
if (game.firstRun) { if (game.firstRun) {
mech.spawn(); //spawns the player mech.spawn(); //spawns the player
mod.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

View File

@@ -51,7 +51,66 @@ window.addEventListener('load', (event) => {
const set = getUrlVars() const set = getUrlVars()
if (Object.keys(set).length !== 0) { if (Object.keys(set).length !== 0) {
build.isURLBuild = true; build.isURLBuild = true;
game.startGame() // game.startGame()
openCustomBuildMenu();
//add custom selections based on url
for (const property in set) {
// console.log(set[property], property);
set[property] = set[property].replace(/%20/g, " ")
if (property.substring(0, 3) === "gun") {
let found = false
let index
for (let i = 0; i < b.guns.length; i++) {
if (set[property] === b.guns[i].name) {
index = i;
found = true;
break;
}
}
if (found) build.choosePowerUp(document.getElementById(`gun-${index}`), index, 'gun')
}
if (property.substring(0, 3) === "mod") {
let found = false
let index
for (let i = 0; i < mod.mods.length; i++) {
if (set[property] === mod.mods[i].name) {
index = i;
found = true;
break;
}
}
if (found) build.choosePowerUp(document.getElementById(`mod-${index}`), index, 'mod')
}
if (property === "field") {
let found = false
let index
for (let i = 0; i < mech.fieldUpgrades.length; i++) {
if (set[property] === mech.fieldUpgrades[i].name) {
index = i;
found = true;
break;
}
}
if (found) build.choosePowerUp(document.getElementById(`field-${index}`), index, 'field')
}
if (property === "difficulty") {
game.difficultyMode = Number(set[property])
localSettings.difficultyMode = Number(set[property])
localStorage.setItem("localSettings", JSON.stringify(localSettings)); //update local storage
document.getElementById("difficulty-select").value = Number(set[property])
document.getElementById("difficulty-select-custom").value = Number(set[property])
}
if (property === "level") {
document.getElementById("starting-level").value = Number(set[property])
// level.levelsCleared += Number(set[property]);
// level.difficultyIncrease(Number(set[property]) * game.difficultyMode) //increase difficulty based on modes
// spawn.setSpawnList(); //picks a couple mobs types for a themed random mob spawns
// level.onLevel++
}
}
} }
}); });
@@ -248,7 +307,7 @@ const build = {
text += `<div id ="field-${i}" class="build-grid-module" onclick="build.choosePowerUp(this,${i},'field')"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[i].name}</div> ${mech.fieldUpgrades[i].description}</div>` text += `<div id ="field-${i}" class="build-grid-module" onclick="build.choosePowerUp(this,${i},'field')"><div class="grid-title"><div class="circle-grid field"></div> &nbsp; ${mech.fieldUpgrades[i].name}</div> ${mech.fieldUpgrades[i].description}</div>`
} }
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 id = "gun-${i}" 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 = mod.mods.length; i < len; i++) { for (let i = 0, len = mod.mods.length; i < len; i++) {
if (!mod.mods[i].allowed()) { // || mod.mods[i].name === "+1 cardinality") { //|| mod.mods[i].name === "leveraged investment" if (!mod.mods[i].allowed()) { // || mod.mods[i].name === "+1 cardinality") { //|| mod.mods[i].name === "leveraged investment"
@@ -333,7 +392,7 @@ const build = {
} }
} }
document.getElementById("build-button").addEventListener("click", () => { //setup build run function openCustomBuildMenu() {
build.isURLBuild = false; build.isURLBuild = false;
document.getElementById("build-button").style.display = "none"; document.getElementById("build-button").style.display = "none";
const el = document.getElementById("build-grid") const el = document.getElementById("build-grid")
@@ -347,6 +406,10 @@ document.getElementById("build-button").addEventListener("click", () => { //setu
build.isCustomSelection = true; build.isCustomSelection = true;
game.paused = true; game.paused = true;
build.reset(); build.reset();
}
document.getElementById("build-button").addEventListener("click", () => { //setup build run
openCustomBuildMenu();
}); });

View File

@@ -9,7 +9,7 @@ const level = {
levelsCleared: 0, levelsCleared: 0,
levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber"], levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber"],
start() { start() {
if (build.isURLBuild && level.levelsCleared === 0) build.onLoadPowerUps(); // if (build.isURLBuild && level.levelsCleared === 0) build.onLoadPowerUps();
if (level.levelsCleared === 0) { //this code only runs on the first level if (level.levelsCleared === 0) { //this code only runs on the first level
// level.difficultyIncrease(12) // level.difficultyIncrease(12)
// game.enableConstructMode() //used to build maps in testing mode // game.enableConstructMode() //used to build maps in testing mode

View File

@@ -79,7 +79,7 @@ const mod = {
if (mod.isEnergyDamage) dmg *= 1 + mech.energy / 5.5; if (mod.isEnergyDamage) dmg *= 1 + mech.energy / 5.5;
if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005 if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005
if (mod.isRerollDamage) dmg *= 1 + 0.05 * powerUps.reroll.rerolls if (mod.isRerollDamage) dmg *= 1 + 0.05 * powerUps.reroll.rerolls
if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.22 if (mod.isOneGun && b.inventory.length < 2) dmg *= 1.25
return dmg * mod.slowFire return dmg * mod.slowFire
}, },
totalBots() { totalBots() {
@@ -87,7 +87,7 @@ const mod = {
}, },
mods: [{ mods: [{
name: "integrated armament", name: "integrated armament",
description: "increase <strong class='color-d'>damage</strong> by <strong>22%</strong><br>your inventory can only hold <strong>1 gun</strong>", description: "increase <strong class='color-d'>damage</strong> by <strong>25%</strong><br>your inventory can only hold <strong>1 gun</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {
@@ -759,13 +759,13 @@ const mod = {
game.boldActiveGunHUD(); game.boldActiveGunHUD();
}, 1000); }, 1000);
}, },
description: "while your <strong>first gun</strong> is equipped<br>reduce <strong class='color-harm'>harm</strong> by <strong>15%</strong> for each of your <strong class='color-g'>guns</strong>", description: "while your <strong>first gun</strong> is equipped<br>reduce <strong class='color-harm'>harm</strong> by <strong>13%</strong> for each of your <strong class='color-g'>guns</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {
return !mod.isEnergyHealth return b.inventory.length > 1 && !mod.isEnergyHealth
}, },
requires: "not mass-energy equivalence", requires: "at least 2 guns",
effect() { effect() {
mod.isEntanglement = true mod.isEntanglement = true
setTimeout(function () { setTimeout(function () {
@@ -1059,19 +1059,15 @@ const mod = {
}, },
{ {
name: "logistics", name: "logistics",
description: "<strong class='color-g'>ammo</strong> power ups add to your <strong>current gun</strong><br>spawn <strong>7 ammo</strong>", description: "<strong class='color-g'>ammo</strong> power ups give <strong>100%</strong> more <strong class='color-g'>ammo</strong><br>but <strong class='color-g'>ammo</strong> is only added to your <strong>current gun</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {
return b.inventory.length > 1 return true
}, },
requires: "at least 2 guns", requires: "",
effect() { effect() {
mod.isAmmoForGun = true; mod.isAmmoForGun = true;
for (let i = 0; i < 7; i++) {
powerUps.spawn(mech.pos.x, mech.pos.y, "ammo");
if (Math.random() < mod.bayesian) powerUps.spawn(mech.pos.x, mech.pos.y, "ammo");
}
}, },
remove() { remove() {
mod.isAmmoForGun = false; mod.isAmmoForGun = false;

View File

@@ -125,39 +125,55 @@ const powerUps = {
return 17; return 17;
}, },
effect() { effect() {
//only get ammo for guns player has //give ammo to all guns in inventory
let target; if (mod.isAmmoForGun) {
if (b.inventory.length > 0) { const target = b.guns[b.activeGun]
if (mod.isAmmoForGun) { target.ammo += Math.ceil(Math.random() * target.ammoPack)
target = b.guns[b.activeGun]; target.ammo += Math.ceil(Math.random() * target.ammoPack)
} else { } else {
//find a gun in your inventory for (let i = 0, len = b.inventory.length; i < len; i++) {
target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]; const target = b.guns[b.inventory[i]]
//try 3 more times to give ammo to a gun with ammo, not Infinity if (target.ammo !== Infinity) {
if (target.ammo === Infinity) { target.ammo += Math.ceil(Math.random() * target.ammoPack)
target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]
if (target.ammo === Infinity) {
target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]
if (target.ammo === Infinity) target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]
}
} }
} }
//give ammo
if (target.ammo === Infinity) {
if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
} else {
let ammo = Math.ceil((target.ammoPack * (0.8 + 0.25 * Math.random())));
// if (level.isBuildRun) ammo = Math.floor(ammo * 1.1) //extra ammo on build run because no ammo from getting a new gun
target.ammo += ammo;
game.updateGunHUD();
game.makeTextLog("<div class='circle gun'></div> &nbsp; <span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
}
} else {
// target = b.guns[Math.floor(Math.random() * b.guns.length)]; //if you don't have any guns just add ammo to a random gun you don't have yet
if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
} }
game.updateGunHUD();
// //only get ammo for guns player has
// let target;
// if (b.inventory.length > 0) {
// if (mod.isAmmoForGun) {
// target = b.guns[b.activeGun];
// } else {
// //find a gun in your inventory
// target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]];
// //try 3 more times to give ammo to a gun with ammo, not Infinity
// if (target.ammo === Infinity) {
// target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]
// if (target.ammo === Infinity) {
// target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]
// if (target.ammo === Infinity) target = b.guns[b.inventory[Math.floor(Math.random() * (b.inventory.length))]]
// }
// }
// }
// //give ammo
// if (target.ammo === Infinity) {
// if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
// if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
// } else {
// let ammo = Math.ceil((target.ammoPack * (0.8 + 0.25 * Math.random())));
// // if (level.isBuildRun) ammo = Math.floor(ammo * 1.1) //extra ammo on build run because no ammo from getting a new gun
// target.ammo += ammo;
// game.updateGunHUD();
// game.makeTextLog("<div class='circle gun'></div> &nbsp; <span style='font-size:110%;'>+" + ammo + " ammo for " + target.name + "</span>", 300);
// }
// } else {
// // target = b.guns[Math.floor(Math.random() * b.guns.length)]; //if you don't have any guns just add ammo to a random gun you don't have yet
// if (mech.energy < mech.maxEnergy) mech.energy = mech.maxEnergy;
// if (!game.lastLogTime) game.makeTextLog("<span style='font-size:115%;'><span class='color-f'>+energy</span></span>", 300);
// }
} }
}, },
field: { field: {
@@ -405,7 +421,7 @@ const powerUps = {
if (Math.random() < mod.bayesian) 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.001 * (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() < mod.bayesian) powerUps.spawn(x, y, "gun"); if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "gun");
return; return;
@@ -468,7 +484,7 @@ const powerUps = {
if (mech.fieldMode === 0) { if (mech.fieldMode === 0) {
powerUps.spawn(x, y, "field") powerUps.spawn(x, y, "field")
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field") if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field")
} else if (Math.random() < 0.94) { } else if (Math.random() < 0.95) {
powerUps.spawn(x, y, "mod") powerUps.spawn(x, y, "mod")
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod") if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod")
} else { } else {
@@ -500,8 +516,8 @@ const powerUps = {
powerUps.spawn(x, y, "gun", false); powerUps.spawn(x, y, "gun", false);
} else if (mod.totalCount === 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 && Math.random() < 0.5) { // } else if (b.inventory.length < 2 && Math.random() < 0.2) {
powerUps.spawn(x, y, "gun", false); // powerUps.spawn(x, y, "gun", false);
} else { } else {
powerUps.spawnRandomPowerUp(x, y); powerUps.spawnRandomPowerUp(x, y);
powerUps.spawnRandomPowerUp(x, y); powerUps.spawnRandomPowerUp(x, y);

View File

@@ -1,13 +1,19 @@
added rotating platforms to sewers level ammo power ups give ammo to every gun in your inventory now,
mod negentropy: now spawns a heal power up for every 50% missing health at the start of a level but they only give half as much for each ammo power up
this should give a greater incentive for having more guns
mod: logistics now gives double ammo to only your current gun
all explosions do about 10% more damage custom build links now bring you to the custom build menu, not directly into the game
knock back no longer gets weaker at high levels
mod - electric reactive armor now gives explosion damage immunity when your energy is above 75%
************** TODO - n-gon ************** ************** TODO - n-gon **************
have custom links goto the custom build menu, not the intro level
performance issues with large numbers of spores
consider limiting total bullets?
300?
level element: a hanging chain of connected blocks level element: a hanging chain of connected blocks
give mobs more animal-like behaviors like rain world give mobs more animal-like behaviors like rain world