URL build goes to custom, ammo goes to all guns
This commit is contained in:
22
js/bullet.js
22
js/bullet.js
@@ -485,7 +485,7 @@ const b = {
|
||||
spore(where, isFreeze = mod.isSporeFreeze) { //used with the mod upgrade in mob.death()
|
||||
const bIndex = bullet.length;
|
||||
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,
|
||||
inertia: Infinity,
|
||||
isFreeze: isFreeze,
|
||||
@@ -1578,7 +1578,7 @@ const b = {
|
||||
name: "shotgun",
|
||||
description: "fire a <strong>burst</strong> of short range <strong> bullets</strong> <br><em>crouch to reduce recoil</em>",
|
||||
ammo: 0,
|
||||
ammoPack: 8,
|
||||
ammoPack: 6,
|
||||
have: false,
|
||||
fire() {
|
||||
let knock, spread
|
||||
@@ -1591,7 +1591,7 @@ const b = {
|
||||
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
|
||||
spread = 1.3
|
||||
knock = 0.08
|
||||
knock = 0.1
|
||||
}
|
||||
|
||||
if (mod.isShotgunRecoil) {
|
||||
@@ -1616,27 +1616,27 @@ const b = {
|
||||
x: speed * Math.cos(dir),
|
||||
y: speed * Math.sin(dir)
|
||||
}
|
||||
b.nail(pos, velocity, 0.6)
|
||||
b.nail(pos, velocity, 1)
|
||||
}
|
||||
} else {
|
||||
const side = 19 * mod.bulletSize
|
||||
const side = 21 * mod.bulletSize
|
||||
for (let i = 0; i < 15; i++) {
|
||||
const me = bullet.length;
|
||||
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));
|
||||
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], {
|
||||
x: SPEED * Math.cos(dir),
|
||||
y: SPEED * Math.sin(dir)
|
||||
});
|
||||
bullet[me].endCycle = game.cycle + 40
|
||||
bullet[me].minDmgSpeed = 20
|
||||
bullet[me].minDmgSpeed = 15
|
||||
// bullet[me].dmg = 0.1
|
||||
bullet[me].frictionAir = 0.034;
|
||||
bullet[me].do = function () {
|
||||
if (!mech.isBodiesAsleep) {
|
||||
const scale = 1 - 0.035 / mod.isBulletsLastLonger
|
||||
const scale = 1 - 0.034 / mod.isBulletsLastLonger
|
||||
Matter.Body.scale(this, scale, scale);
|
||||
}
|
||||
};
|
||||
@@ -2093,7 +2093,7 @@ const b = {
|
||||
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>",
|
||||
ammo: 0,
|
||||
ammoPack: 3,
|
||||
ammoPack: 2.5,
|
||||
have: false,
|
||||
fire() {
|
||||
const me = bullet.length;
|
||||
@@ -2105,7 +2105,7 @@ const b = {
|
||||
bullet[me].restitution = 0.2;
|
||||
bullet[me].friction = 0.3;
|
||||
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 () {
|
||||
b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
|
||||
|
||||
@@ -2562,7 +2562,7 @@ const b = {
|
||||
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",
|
||||
ammo: 0,
|
||||
ammoPack: 4,
|
||||
ammoPack: 3,
|
||||
have: false,
|
||||
fire() {
|
||||
const me = bullet.length;
|
||||
|
||||
20
js/game.js
20
js/game.js
@@ -199,7 +199,7 @@ const game = {
|
||||
if (b.inventory[0] === b.activeGun) {
|
||||
let lessDamage = 1
|
||||
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) + "%"
|
||||
} else {
|
||||
@@ -595,24 +595,6 @@ const game = {
|
||||
document.getElementById("dmg").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) {
|
||||
mech.spawn(); //spawns the player
|
||||
mod.setupAllMods(); //doesn't run on reset so that gun mods carry over to new runs
|
||||
|
||||
69
js/index.js
69
js/index.js
@@ -51,7 +51,66 @@ window.addEventListener('load', (event) => {
|
||||
const set = getUrlVars()
|
||||
if (Object.keys(set).length !== 0) {
|
||||
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> ${mech.fieldUpgrades[i].name}</div> ${mech.fieldUpgrades[i].description}</div>`
|
||||
}
|
||||
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> ${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> ${b.guns[i].name}</div> ${b.guns[i].description}</div>`
|
||||
}
|
||||
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"
|
||||
@@ -333,7 +392,7 @@ const build = {
|
||||
}
|
||||
}
|
||||
|
||||
document.getElementById("build-button").addEventListener("click", () => { //setup build run
|
||||
function openCustomBuildMenu() {
|
||||
build.isURLBuild = false;
|
||||
document.getElementById("build-button").style.display = "none";
|
||||
const el = document.getElementById("build-grid")
|
||||
@@ -347,6 +406,10 @@ document.getElementById("build-button").addEventListener("click", () => { //setu
|
||||
build.isCustomSelection = true;
|
||||
game.paused = true;
|
||||
build.reset();
|
||||
}
|
||||
|
||||
document.getElementById("build-button").addEventListener("click", () => { //setup build run
|
||||
openCustomBuildMenu();
|
||||
});
|
||||
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ const level = {
|
||||
levelsCleared: 0,
|
||||
levels: ["skyscrapers", "rooftops", "warehouse", "highrise", "office", "aerie", "satellite", "sewers", "testChamber"],
|
||||
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
|
||||
// level.difficultyIncrease(12)
|
||||
// game.enableConstructMode() //used to build maps in testing mode
|
||||
|
||||
20
js/mods.js
20
js/mods.js
@@ -79,7 +79,7 @@ const mod = {
|
||||
if (mod.isEnergyDamage) dmg *= 1 + mech.energy / 5.5;
|
||||
if (mod.isDamageFromBulletCount) dmg *= 1 + bullet.length * 0.005
|
||||
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
|
||||
},
|
||||
totalBots() {
|
||||
@@ -87,7 +87,7 @@ const mod = {
|
||||
},
|
||||
mods: [{
|
||||
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,
|
||||
count: 0,
|
||||
allowed() {
|
||||
@@ -759,13 +759,13 @@ const mod = {
|
||||
game.boldActiveGunHUD();
|
||||
}, 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,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return !mod.isEnergyHealth
|
||||
return b.inventory.length > 1 && !mod.isEnergyHealth
|
||||
},
|
||||
requires: "not mass-energy equivalence",
|
||||
requires: "at least 2 guns",
|
||||
effect() {
|
||||
mod.isEntanglement = true
|
||||
setTimeout(function () {
|
||||
@@ -1059,19 +1059,15 @@ const mod = {
|
||||
},
|
||||
{
|
||||
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,
|
||||
count: 0,
|
||||
allowed() {
|
||||
return b.inventory.length > 1
|
||||
return true
|
||||
},
|
||||
requires: "at least 2 guns",
|
||||
requires: "",
|
||||
effect() {
|
||||
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() {
|
||||
mod.isAmmoForGun = false;
|
||||
|
||||
@@ -125,39 +125,55 @@ const powerUps = {
|
||||
return 17;
|
||||
},
|
||||
effect() {
|
||||
//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 to all guns in inventory
|
||||
if (mod.isAmmoForGun) {
|
||||
const target = b.guns[b.activeGun]
|
||||
target.ammo += Math.ceil(Math.random() * target.ammoPack)
|
||||
target.ammo += Math.ceil(Math.random() * target.ammoPack)
|
||||
} else {
|
||||
for (let i = 0, len = b.inventory.length; i < len; i++) {
|
||||
const target = b.guns[b.inventory[i]]
|
||||
if (target.ammo !== Infinity) {
|
||||
target.ammo += Math.ceil(Math.random() * target.ammoPack)
|
||||
}
|
||||
}
|
||||
//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> <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> <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: {
|
||||
@@ -405,7 +421,7 @@ const powerUps = {
|
||||
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "ammo");
|
||||
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");
|
||||
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "gun");
|
||||
return;
|
||||
@@ -468,7 +484,7 @@ const powerUps = {
|
||||
if (mech.fieldMode === 0) {
|
||||
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")
|
||||
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "mod")
|
||||
} else {
|
||||
@@ -500,8 +516,8 @@ const powerUps = {
|
||||
powerUps.spawn(x, y, "gun", false);
|
||||
} else if (mod.totalCount === 0) {
|
||||
powerUps.spawn(x, y, "mod", false); //starting gun
|
||||
} else if (b.inventory.length < 2 && Math.random() < 0.5) {
|
||||
powerUps.spawn(x, y, "gun", false);
|
||||
// } else if (b.inventory.length < 2 && Math.random() < 0.2) {
|
||||
// powerUps.spawn(x, y, "gun", false);
|
||||
} else {
|
||||
powerUps.spawnRandomPowerUp(x, y);
|
||||
powerUps.spawnRandomPowerUp(x, y);
|
||||
|
||||
Reference in New Issue
Block a user