ice IX, ablative mines

This commit is contained in:
landgreen
2020-03-27 05:38:14 -07:00
parent 2fb3d761a1
commit ad950d2cc2
9 changed files with 155 additions and 94 deletions

View File

@@ -17,6 +17,7 @@ const b = {
isModImmuneExplosion: null,
isModExplodeMob: null,
isModDroneOnDamage: null,
isModMineOnDamage: null,
modAcidDmg: null,
isModAcidDmg: null,
annihilation: null,
@@ -55,7 +56,7 @@ const b = {
modWaveSpeedBody: null,
isModSporeField: null,
isModMissileField: null,
isModSwarmField: null,
isModIceField: null,
isModFlechetteMultiShot: null,
isModMineAmmoBack: null,
isModPlasmaRange: null,
@@ -70,11 +71,26 @@ const b = {
isModAlphaRadiation: null,
modOnHealthChange() { //used with acid mod
if (b.isModAcidDmg && mech.health > 0.8) {
game.playerDmgColor = "rgba(0,80,80,0.9)"
b.modAcidDmg = 0.7
if (!build.isCustomSelection) {
setTimeout(function () {
if (document.getElementById("mod-acid")) document.getElementById("mod-acid").innerHTML = " (on)"
}, 10);
}
} else {
game.playerDmgColor = "rgba(0,0,0,0.7)"
b.modAcidDmg = 0
if (!build.isCustomSelection) {
setTimeout(function () {
if (document.getElementById("mod-acid")) document.getElementById("mod-acid").innerHTML = " (off)"
}, 10);
}
}
if (b.isModLowHealthDmg) {
if (!build.isCustomSelection) {
setTimeout(function () {
if (document.getElementById("mod-low-health-damage")) document.getElementById("mod-low-health-damage").innerHTML = " +" + (((3 / (2 + Math.min(mech.health, 1))) - 1) * 100).toFixed(0) + "%"
}, 10);
}
}
},
mods: [{
@@ -126,7 +142,7 @@ const b = {
}
},
{
name: "fluoroantimonic acid",
name: "fluoroantimonic acid<span id='mod-acid'></span>",
description: "each <strong>bullet</strong> does instant <strong class='color-p'>acid</strong> <strong class='color-d'>damage</strong><br><strong>active</strong> when you are above <strong>80%</strong> base health",
maxCount: 1,
count: 0,
@@ -145,7 +161,7 @@ const b = {
}
},
{
name: "negative feedback",
name: "negative feedback<span id='mod-low-health-damage'></span>",
description: "do extra <strong class='color-d'>damage</strong> at low health<br><em>up to <strong>50%</strong> increase when near death</em>",
maxCount: 1,
count: 0,
@@ -193,12 +209,12 @@ const b = {
}
},
{
name: "electric reactive armour",
name: "electric reactive armor",
description: "<strong class='color-e'>explosions</strong> drain your <strong class='color-f'>energy</strong><br>instead of <strong>harming</strong> you",
maxCount: 1,
count: 0,
allowed() {
return b.modExplosionRadius > 1
return b.modExplosionRadius > 1 || b.isModExplodeMob
},
requires: "high explosives",
effect: () => {
@@ -307,7 +323,7 @@ const b = {
}
},
{
name: "ablative synthesis",
name: "ablative drones",
description: "rebuild your broken parts as <strong>drones</strong><br>chance to occur after being <strong>harmed</strong>",
maxCount: 1,
count: 0,
@@ -325,15 +341,38 @@ const b = {
b.isModDroneOnDamage = false;
}
},
{
name: "ablative mines",
description: "rebuild your broken parts as a <strong>mine</strong><br>chance to occur after being <strong>harmed</strong>",
maxCount: 1,
count: 0,
allowed() {
return true
},
requires: "",
effect() {
b.isModMineOnDamage = true;
b.mine({
x: mech.pos.x,
y: mech.pos.y - 80
}, {
x: 0,
y: 0
})
},
remove() {
b.isModMineOnDamage = false;
}
},
{
name: "Lorentzian topology",
description: "your <strong>bullets</strong> last <strong>+33% longer</strong>",
maxCount: 3,
count: 0,
allowed() {
return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" || b.haveGunCheck("spores") || b.haveGunCheck("drones") || b.haveGunCheck("super balls") || b.haveGunCheck("foam") || b.haveGunCheck("wave beam") || b.haveGunCheck("swarm")
return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" || b.haveGunCheck("spores") || b.haveGunCheck("drones") || b.haveGunCheck("super balls") || b.haveGunCheck("foam") || b.haveGunCheck("wave beam") || b.haveGunCheck("ice IX")
},
requires: "drones, spores, super balls,<br> foam, wave beam, or swarm",
requires: "drones, spores, super balls,<br> foam, wave beam, or ice IX",
effect() {
b.isModBulletsLastLonger += 0.33
},
@@ -787,7 +826,7 @@ const b = {
{
name: "ice crystal nucleation",
description: "your <strong>minigun</strong> uses <strong class='color-f'>energy</strong> to condense<br><strong>bullets</strong> from water vapor that <strong>slow</strong> mobs",
description: "your <strong>minigun</strong> uses <strong class='color-f'>energy</strong> to condense<br>unlimited <strong class='color-s'>freezing</strong> <strong>bullets</strong> from water vapor",
maxCount: 1,
count: 0,
allowed() {
@@ -820,7 +859,7 @@ const b = {
},
{
name: "shotgun spin-statistics",
description: "firing the <strong>shotgun</strong> makes you <br><strong>immune</strong> to collisions for <strong>1/2</strong> a second",
description: "firing the <strong>shotgun</strong> makes you <br><strong>immune</strong> to collisions for <strong>1 second</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -1022,7 +1061,7 @@ const b = {
maxCount: 1,
count: 0,
allowed() {
return b.haveGunCheck("drones") || (mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModMissileField || b.isModSwarmField))
return b.haveGunCheck("drones") || (mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModMissileField || b.isModIceField))
},
requires: "drones",
effect() {
@@ -1033,14 +1072,14 @@ const b = {
}
},
{
name: "alpha radiation",
description: "the <strong>swarm</strong> bots deliver a dose of<br><strong class='color-p'>radioactive</strong> <strong class='color-d'>damage</strong> over 3 seconds",
name: "heavy water",
description: "<strong>ice IX</strong> is synthesized with unstable isotopes<br>does <strong class='color-p'>radioactive</strong> <strong class='color-d'>damage</strong> over 3 seconds",
maxCount: 1,
count: 0,
allowed() {
return b.haveGunCheck("swarm") || (mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && b.isModSwarmField)
return b.haveGunCheck("ice IX") || (mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && b.isModIceField)
},
requires: "swarm",
requires: "ice IX",
effect() {
b.isModAlphaRadiation = true
},
@@ -1188,7 +1227,7 @@ const b = {
maxCount: 1,
count: 0,
allowed() {
return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModMissileField || b.isModSwarmField)
return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModMissileField || b.isModIceField)
},
requires: "nano-scale manufacturing",
effect() {
@@ -1204,7 +1243,7 @@ const b = {
maxCount: 1,
count: 0,
allowed() {
return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModSwarmField)
return mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && !(b.isModSporeField || b.isModIceField)
},
requires: "nano-scale manufacturing",
effect() {
@@ -1215,8 +1254,8 @@ const b = {
}
},
{
name: "swarm manufacturing",
description: "<strong>nano-scale manufacturing</strong> is repurposed<br>excess <strong class='color-f'>energy</strong> used to construct <strong>swarm</strong> bots",
name: "ice IX manufacturing",
description: "<strong>nano-scale manufacturing</strong> is repurposed<br>excess <strong class='color-f'>energy</strong> used to synthesize <strong>ice IX</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -1224,10 +1263,10 @@ const b = {
},
requires: "nano-scale manufacturing",
effect() {
b.isModSwarmField = true;
b.isModIceField = true;
},
remove() {
b.isModSwarmField = false;
b.isModIceField = false;
}
},
{
@@ -1474,7 +1513,7 @@ const b = {
if (dist < radius) {
if (b.isModImmuneExplosion) {
const drain = Math.max(radius * 0.0004, 0.2)
const drain = Math.max(radius * 0.0003, 0.15)
if (mech.energy > drain) {
mech.energy -= drain
} else {
@@ -1853,18 +1892,18 @@ const b = {
});
World.add(engine.world, bullet[bIndex]); //add bullet to world
},
swarm(speed = 0, spread = 2 * Math.PI) {
iceIX(speed = 0, spread = 2 * Math.PI) {
const me = bullet.length;
const THRUST = 0.004
const dir = mech.angle + spread * (Math.random() - 0.5);
const RADIUS = 17 * b.modBulletSize
const RADIUS = 18 * b.modBulletSize
bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 3, RADIUS, {
angle: dir - Math.PI,
inertia: Infinity,
friction: 0,
frictionAir: 0.10,
restitution: 0.2,
dmg: 0.3, //damage done in addition to the damage from momentum
dmg: 0.25, //damage done in addition to the damage from momentum
lookFrequency: 10 + Math.floor(7 * Math.random()),
endCycle: game.cycle + 90 * b.isModBulletsLastLonger, //Math.floor((1200 + 420 * Math.random()) * b.isModBulletsLastLonger),
classType: "bullet",
@@ -1876,6 +1915,7 @@ const b = {
lockedOn: null,
isFollowMouse: true,
onDmg(who) {
mobs.statusSlow(who, 30)
this.endCycle = game.cycle
if (b.isModAlphaRadiation) mobs.statusPoison(who, 0.08, 180)
},
@@ -1884,7 +1924,7 @@ const b = {
// this.force.y += this.mass * 0.0002;
//find mob targets
if (!(game.cycle % this.lookFrequency)) {
const scale = 0.9;
const scale = 1 - 0.1 / b.isModBulletsLastLonger //0.9 * b.isModBulletsLastLonger;
Matter.Body.scale(this, scale, scale);
this.lockedOn = null;
let closeDist = Infinity;
@@ -2282,19 +2322,29 @@ const b = {
name: "shotgun", //1
description: "fire a <strong>burst</strong> of short range bullets<br><em>crouch to reduce recoil</em>",
ammo: 0,
ammoPack: 8,
ammoPack: 11,
have: false,
isStarterGun: true,
isEasyToAim: true,
fire() {
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 55 : 30) * b.modFireRate); // cool down
if (b.isModShotgunImmune) mech.collisionImmuneCycle = mech.cycle + 30; //player is immune to collision damage for 30 cycles
let knock, spread
if (mech.crouch) {
mech.fireCDcycle = mech.cycle + Math.floor(55 * b.modFireRate); // cool down
spread = 0.75
knock = 0.01 * b.modBulletSize * b.modBulletSize
} else {
mech.fireCDcycle = mech.cycle + Math.floor(45 * b.modFireRate); // cool down
spread = 1.3
knock = 0.08 * b.modBulletSize * b.modBulletSize
}
player.force.x -= knock * Math.cos(mech.angle)
player.force.y -= knock * Math.sin(mech.angle) * 0.3 //reduce knock back in vertical direction to stop super jumps
if (b.isModShotgunImmune) mech.collisionImmuneCycle = mech.cycle + 60; //player is immune to collision damage for 30 cycles
b.muzzleFlash(35);
// mobs.alert(650);
const side = 13 * b.modBulletSize
for (let i = 0; i < 12; i++) {
const side = 19 * b.modBulletSize
for (let i = 0; i < 15; i++) {
const me = bullet.length;
const dir = mech.angle + (Math.random() - 0.5) * (mech.crouch ? 0.40 : 1.2)
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
@@ -2302,17 +2352,15 @@ const b = {
x: SPEED * Math.cos(dir),
y: SPEED * Math.sin(dir)
});
bullet[me].endCycle = game.cycle + 55
bullet[me].frictionAir = 0.04;
bullet[me].endCycle = game.cycle + 40
bullet[me].minDmgSpeed = 20
// bullet[me].dmg = 0.1
bullet[me].frictionAir = 0.034;
bullet[me].do = function () {
this.force.y += this.mass * 0.001;
const scale = 1 - 0.035 / b.isModBulletsLastLonger
Matter.Body.scale(this, scale, scale);
};
}
//knock back
const KNOCK = ((mech.crouch) ? 0.01 : 0.07) * b.modBulletSize * b.modBulletSize
player.force.x -= KNOCK * Math.cos(mech.angle)
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.3 //reduce knock back in vertical direction to stop super jumps
}
},
{
@@ -2824,8 +2872,8 @@ const b = {
}
},
{
name: "swarm", //11
description: "rapidly deploy <strong>short-lived</strong> bots<br>that <strong>seek</strong> out nearby mobs",
name: "ice IX", //11
description: "synthesize <strong>short-lived</strong> ice crystals<br>crystals <strong>seek</strong> out and <strong class='color-s'>freeze</strong> mobs",
ammo: 0,
ammoPack: 80,
have: false,
@@ -2833,10 +2881,10 @@ const b = {
isEasyToAim: true,
fire() {
if (mech.crouch) {
b.swarm(20, 0.3)
b.iceIX(20, 0.3)
mech.fireCDcycle = mech.cycle + Math.floor(10 * b.modFireRate); // cool down
} else {
b.swarm(2)
b.iceIX(2)
mech.fireCDcycle = mech.cycle + Math.floor(3 * b.modFireRate); // cool down
}
@@ -2844,7 +2892,7 @@ const b = {
},
{
name: "foam", //12
description: "spray bubbly foam that <strong>sticks</strong> to mobs<br>does <strong class='color-d'>damage</strong> over time and <strong>slows</strong> movement",
description: "spray bubbly foam that <strong>sticks</strong> to mobs<br><strong class='color-s'>slows</strong> mobs and does <strong class='color-d'>damage</strong> over time",
ammo: 0,
ammoPack: 35,
have: false,

View File

@@ -177,6 +177,7 @@ const game = {
}
}
document.getElementById("mods").innerHTML = text
b.modOnHealthChange()
},
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" />
@@ -468,6 +469,7 @@ const game = {
game.difficulty = 0;
game.difficultyMode = Number(document.getElementById("difficulty-select").value)
level.isBuildRun = false;
build.isCustomSelection = false;
if (game.difficultyMode === 0) {
game.isEasyMode = true;
game.difficultyMode = 1

View File

@@ -71,7 +71,7 @@ const build = {
document.getElementById("pause-grid-left").style.display = "none"
document.getElementById("pause-grid-right").style.display = "none"
},
isCustomSelection: false,
isCustomSelection: true,
choosePowerUp(who, index, type) {
if (type === "gun") {
let isDeselect = false
@@ -189,6 +189,7 @@ const build = {
});
},
reset() {
build.isCustomSelection = true;
mech.setField(0)
b.inventory = []; //removes guns and ammo
@@ -201,7 +202,6 @@ const build = {
game.makeGunHUD();
b.setupAllMods();
build.isCustomSelection = true;
build.populateGrid();
document.getElementById("field-0").classList.add("build-field-selected");
document.getElementById("build-grid").style.display = "grid"
@@ -209,6 +209,8 @@ const build = {
startBuildRun() {
build.isCustomSelection = false;
b.modOnHealthChange()
spawn.setSpawnList(); //gives random mobs, not starter mobs
spawn.setSpawnList();
if (b.inventory.length > 0) {
@@ -242,6 +244,7 @@ document.getElementById("build-button").addEventListener("click", () => { //setu
level.isBuildRun = true;
game.startGame(); //starts game, but pauses it
build.isCustomSelection = true;
game.paused = true;
build.reset();
});

View File

@@ -14,7 +14,7 @@ const level = {
start() {
if (level.levelsCleared === 0) {
// level.difficultyIncrease(9)
// b.giveGuns("swarm")
b.giveGuns("shotgun")
// mech.setField("time dilation field")
// b.giveMod("quantum immortality");
// b.giveMod("reflective cavity");

View File

@@ -124,8 +124,8 @@ const mobs = {
let dmg = b.dmgScale * tickDamage
who.damage(dmg);
game.drawList.push({ //add dmg to draw queue
x: who.position.x,
y: who.position.y,
x: who.position.x + (Math.random() - 0.5) * who.radius * 0.5,
y: who.position.y + (Math.random() - 0.5) * who.radius * 0.5,
radius: Math.log(2 * dmg + 1.1) * 40,
color: "rgba(0,80,80,0.9)",
time: game.drawTime
@@ -983,7 +983,7 @@ const mobs = {
if (!this.isShielded || isBypassShield) {
dmg /= Math.sqrt(this.mass)
if (this.shield) dmg *= 0.04
if (b.isModLowHealthDmg) dmg *= (3 / (2 + mech.health)) //up to 50% dmg at zero player health
if (b.isModLowHealthDmg) dmg *= (3 / (2 + Math.min(mech.health, 1))) //up to 50% dmg at zero player health //if this changes all update display in modOnHealthChange()
if (b.isModHarmDamage && mech.lastHarmCycle + 300 > mech.cycle) dmg *= 2;
if (b.isModEnergyLoss) dmg *= 1.5;
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

View File

@@ -469,7 +469,7 @@ const mech = {
}
},
health: 0,
maxHealth: null, //set in game.reset()
maxHealth: 1, //set in game.reset()
drawHealth() {
if (mech.health < 1) {
ctx.fillStyle = "rgba(100, 100, 100, 0.5)";
@@ -549,6 +549,17 @@ const mech = {
if (Math.random() < 0.75) b.drone() //spawn drone
}
}
if (b.isModMineOnDamage && dmg > 0.05 + 0.5 * Math.random()) {
b.mine({
x: mech.pos.x,
y: mech.pos.y - 80
}, {
x: 0,
y: 0
})
}
// freeze game and display a full screen red color
if (dmg > 0.05) {
@@ -696,7 +707,7 @@ const mech = {
ctx.restore();
},
// *********************************************
// **************** holding ********************
// **************** fields *********************
// *********************************************
closest: {
dist: 1000,
@@ -1683,15 +1694,15 @@ const mech = {
mech.hold = function () {
if (mech.energy > mech.fieldEnergyMax - 0.02 && mech.fieldCDcycle < mech.cycle) {
if (b.isModSporeField) {
mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones
const len = Math.floor(6 + 3 * Math.random())
mech.energy -= len * 0.07;
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())
mech.energy -= len * 0.06;
for (let i = 0; i < len; i++) {
b.spore(player)
}
} else if (b.isModMissileField) {
mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones
mech.energy -= 0.5;
mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones
mech.energy -= 0.44;
b.missile({
x: mech.pos.x + 40 * Math.cos(mech.angle),
y: mech.pos.y + 40 * Math.sin(mech.angle) - 3
@@ -1699,13 +1710,13 @@ const mech = {
mech.angle + (0.5 - Math.random()) * (mech.crouch ? 0 : 0.2),
-3 * (0.5 - Math.random()) + (mech.crouch ? 25 : -8) * b.modFireRate,
1, b.modBabyMissiles)
} else if (b.isModSwarmField) {
} else if (b.isModIceField) {
// mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones
mech.energy -= 0.05;
b.swarm(1)
mech.energy -= 0.055;
b.iceIX(1)
} else {
mech.fieldCDcycle = mech.cycle + 17; // set cool down to prevent +energy from making huge numbers of drones
mech.energy -= 0.33;
mech.fieldCDcycle = mech.cycle + 10; // set cool down to prevent +energy from making huge numbers of drones
mech.energy -= 0.34;
b.drone(1)
}

View File

@@ -241,7 +241,7 @@ const powerUps = {
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod");
return;
}
if (Math.random() < 0.002) {
if (Math.random() < 0.006) {
powerUps.spawn(x, y, "field");
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field");
return;
@@ -251,16 +251,18 @@ const powerUps = {
if (mech.fieldMode === 0) {
powerUps.spawn(x, y, "field")
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field")
} else if (Math.random() < 0.85) {
} else if (Math.random() < 0.9) {
powerUps.spawn(x, y, "mod")
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "mod")
} else if (Math.random() < 0.35) {
} else if (Math.random() < 0.5) {
powerUps.spawn(x, y, "gun")
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "gun")
} else if (Math.random() < 0.5) {
powerUps.spawn(x, y, "field");
if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field");
} else if (mech.health < 0.7) {
// } else if (Math.random() < 0.5) {
// powerUps.spawn(x, y, "field");
// if (Math.random() < b.isModBayesian) powerUps.spawn(x, y, "field");
} else if (mech.health < 0.65) {
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");
@@ -268,17 +270,19 @@ const powerUps = {
if (Math.random() < b.isModBayesian) {
powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal");
powerUps.spawn(x, y, "heal");
}
} else if (!b.isModNoAmmo) {
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");
if (Math.random() < b.isModBayesian) {
powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo");
powerUps.spawn(x, y, "ammo");
}
}
},
chooseRandomPowerUp(x, y) { //100% chance to drop a random power up //used in spawn.debris