pulse is a mod

This commit is contained in:
landgreen
2020-10-25 03:26:13 -07:00
parent e0131fcea1
commit a5f79bf742
8 changed files with 99 additions and 224 deletions

View File

@@ -1545,14 +1545,16 @@ const b = {
//find closest
if (!(game.cycle % this.lookFrequency)) {
this.lockedOn = null;
let closeDist = mod.isPlasmaRange * 1000;
for (let i = 0, len = mob.length; i < len; ++i) {
const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
if (DIST < closeDist &&
Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
closeDist = DIST;
this.lockedOn = mob[i]
if (!mech.isCloak) {
let closeDist = mod.isPlasmaRange * 1000;
for (let i = 0, len = mob.length; i < len; ++i) {
const DIST = Vector.magnitude(Vector.sub(this.position, mob[i].position)) - mob[i].radius;
if (DIST < closeDist &&
Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
closeDist = DIST;
this.lockedOn = mob[i]
}
}
}
}
@@ -3154,6 +3156,9 @@ const b = {
have: false,
nextFireCycle: 0, //use to remember how longs its been since last fire, used to reset count
fire() {
},
fireLaser() {
if (mech.energy < mod.laserFieldDrain) {
mech.fireCDcycle = mech.cycle + 100; // cool down if out of energy
} else {
@@ -3220,16 +3225,8 @@ const b = {
b.laser()
}
}
}
},
{
name: "pulse",
description: "convert <strong>25%</strong> of your <strong class='color-f'>energy</strong> into a pulsed laser<br>instantly initiates a fusion <strong class='color-e'>explosion</strong>",
ammo: 0,
ammoPack: Infinity,
have: false,
fire() {
},
firePulse() {
//calculate laser collision
let best, energy, explosionRange;
let range = 3000
@@ -3282,7 +3279,6 @@ const b = {
}
}
};
//check for collisions
best = {
x: null,
@@ -3295,7 +3291,7 @@ const b = {
if (mod.isPulseAim) { //find mobs in line of sight
let dist = 2200
energy = 0.23 * Math.min(mech.energy, 1.5)
explosionRange = 1400 * energy
explosionRange = 1680 * energy
for (let i = 0, len = mob.length; i < len; i++) {
const newDist = Vector.magnitude(Vector.sub(path[0], mob[i].position))
if (explosionRange < newDist &&
@@ -3319,7 +3315,6 @@ const b = {
};
}
}
if (mod.isPulseAim) {
mech.energy -= energy * mod.isLaserDiode
if (best.who) b.explosion(path[1], explosionRange, true)
@@ -3327,7 +3322,7 @@ const b = {
} else {
energy = 0.27 * Math.min(mech.energy, 1.5)
mech.energy -= energy * mod.isLaserDiode
explosionRange = 1300 * energy
explosionRange = 1560 * energy
if (best.who) b.explosion(path[1], explosionRange, true)
mech.fireCDcycle = mech.cycle + Math.floor(50 * b.fireCD); // cool down
}
@@ -3340,7 +3335,6 @@ const b = {
}
}
}
//draw laser beam
ctx.beginPath();
ctx.moveTo(path[0].x, path[0].y);
@@ -3368,136 +3362,18 @@ const b = {
time: Math.floor(2 + 33 * Math.random() * Math.random())
});
}
}
},
},
// {
// name: "maser",
// description: "emit a <strong>beam</strong> of collimated coherent <strong>light</strong><br>drains <strong class='color-f'>energy</strong> instead of ammunition",
// name: "pulse",
// description: "convert <strong>25%</strong> of your <strong class='color-f'>energy</strong> into a pulsed laser<br>instantly initiates a fusion <strong class='color-e'>explosion</strong>",
// ammo: 0,
// ammoPack: Infinity,
// have: false,
// fire() {
// if (mech.energy < 0.002) {
// mech.fireCDcycle = mech.cycle + 100; // cool down if out of energy
// } else {
// // mech.energy -= mech.fieldRegen + 0.002 * mod.isLaserDiode
// let range = 2000
// const looking = Vector.mult(Vector.rotate({
// x: 1,
// y: 0
// }, mech.angle), range)
// const endpoint = Matter.Vector.add(mech.pos, looking)
// const hits = Matter.Query.ray(body, mech.pos, endpoint, 100)
// for (let i = 0; i < hits.length; i++) {
// }
// // console.log(hits, target, range)
// //draw beam
// ctx.beginPath();
// ctx.moveTo(mech.pos.x, mech.pos.y);
// ctx.lineTo(endpoint.x, endpoint.y);
// ctx.stroke();
// }
// }
// },
// {
// name: "dwarf star", //14
// description: "drop a mine that gravitational pulls in matter",
// ammo: 0,
// ammoPack: 1000,
// have: false,
// isStarterGun: false,
// fire() {
// const me = bullet.length;
// const dir = mech.angle
// const TOTAL_CYCLES = 1020
// bullet[me] = Bodies.circle(mech.pos.x + 30 * Math.cos(dir), mech.pos.y + 30 * Math.sin(dir), 3 , {
// density: 0.05,
// //frictionAir: 0.01,
// restitution: 0,
// angle: 0,
// friction: 1,
// // frictionAir: 1,
// endCycle: game.cycle + TOTAL_CYCLES,
// dmg: 0, //damage done in addition to the damage from momentum
// classType: "bullet",
// collisionFilter: {
// category: 0x000100,
// mask: 0x010011 //mask: 0x000101, //for self collision
// },
// minDmgSpeed: 5,
// range: 0,
// beforeDmg() {
// this.endCycle = 0;
// }, //this.endCycle = 0 //triggers despawn
// onEnd() {},
// do() {
// this.force.y += this.mass * 0.005;
// this.range += 0.5
// //damage nearby mobs
// const dmg = b.dmgScale * 0.02
// for (let i = 0, len = mob.length; i < len; ++i) {
// if (mob[i].alive) {
// sub = Vector.sub(this.position, mob[i].position);
// dist = Vector.magnitude(sub) - mob[i].radius;
// if (dist < this.range) {
// mob[i].damage(dmg);
// mob[i].locatePlayer();
// }
// }
// }
// //pull in body, and power ups?, and bullets?
// for (let i = 0, len = body.length; i < len; ++i) {
// sub = Vector.sub(this.position, body[i].position);
// dist = Vector.magnitude(sub)
// if (dist < this.range) {
// this.range += body[i].mass * 2
// Matter.World.remove(engine.world, body[i]);
// body.splice(i, 1);
// break;
// }
// }
// //draw
// const opacity = (this.endCycle - game.cycle) / TOTAL_CYCLES
// ctx.fillStyle = `rgba(170,220,255,${opacity})`;
// ctx.beginPath();
// ctx.arc(this.position.x, this.position.y, this.range, 0, 2 * Math.PI);
// ctx.fill();
// }
// });
// b.fireProps(60, 0, dir, me); //cd , speed
// }
// },
// {
// name: "kinetic slugs", //1
// description: "fire a large <strong>rod</strong> that does excessive physical <strong class='color-d'>damage</strong><br><em>high recoil</em>",
// ammo: 0,
// ammoPack: 5,
// have: false,
//
// fire() {
// b.muzzleFlash(45);
// // mobs.alert(800);
// const me = bullet.length;
// const dir = mech.angle;
// bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 70 , 30 , b.fireAttributes(dir));
// b.fireProps(mech.crouch ? 55 : 40, 50, dir, me); //cd , speed
// bullet[me].endCycle = game.cycle + Math.floor(180 * mod.isBulletsLastLonger);
// bullet[me].do = function () {
// this.force.y += this.mass * 0.0005;
// };
// //knock back
// const KNOCK = ((mech.crouch) ? 0.025 : 0.25)
// player.force.x -= KNOCK * Math.cos(dir)
// player.force.y -= KNOCK * Math.sin(dir) * 0.3 //reduce knock back in vertical direction to stop super jumps
// },
]
};

View File

@@ -407,6 +407,7 @@ const build = {
const levelsCleared = Math.abs(Number(document.getElementById("starting-level").value))
level.difficultyIncrease(Math.min(99, levelsCleared * game.difficultyMode)) //increase difficulty based on modes
level.levelsCleared += levelsCleared;
game.isCheating = true;
document.body.style.cursor = "none";
document.body.style.overflow = "hidden"
document.getElementById("build-grid").style.display = "none"
@@ -416,7 +417,6 @@ const build = {
}
function openCustomBuildMenu() {
game.isCheating = true;
document.getElementById("build-button").style.display = "none";
const el = document.getElementById("build-grid")
el.style.display = "grid"

View File

@@ -704,21 +704,15 @@ const level = {
});
xLetter += 10 + width
}
level.setPosToSpawn(460, -100); //normal spawn
level.enter.x = -1000000; //hide enter graphic for first level by moving to the far left
level.exit.x = 2800;
level.exit.y = -335;
spawn.mapRect(level.exit.x, level.exit.y + 25, 100, 100); //exit bump
game.zoomScale = 1000 //1400 is normal
level.defaultZoom = 1600
game.zoomTransition(level.defaultZoom, 1)
document.body.style.backgroundColor = "#ddd";
level.fill.push({
x: 2600,
y: -600,
@@ -733,7 +727,6 @@ const level = {
height: 500,
color: "#fff"
});
const lineColor = "#ccc"
level.fillBG.push({
x: 1600,
@@ -742,7 +735,6 @@ const level = {
height: 100,
color: lineColor
});
level.fillBG.push({
x: -55,
y: -283,

View File

@@ -1045,7 +1045,7 @@ const mobs = {
}
if (Math.random() < mod.isBotSpawner) {
b.randomBot(this.position, false)
bullet[bullet.length - 1].endCycle = game.cycle + 1500 + Math.floor(600 * Math.random())
bullet[bullet.length - 1].endCycle = game.cycle + 1000 + Math.floor(400 * Math.random())
}
if (mod.isExplodeMob) b.explosion(this.position, Math.min(550, Math.sqrt(this.mass + 2.5) * 50))
if (mod.nailsDeathMob) b.targetedNail(this.position, mod.nailsDeathMob, 40 + 7 * Math.random())

View File

@@ -137,7 +137,7 @@ const mod = {
maxCount: 1,
count: 0,
allowed() {
return (mod.haveGunCheck("nail gun") && mod.isIceCrystals) || mod.haveGunCheck("laser") || mod.haveGunCheck("pulse") || mech.fieldUpgrades[mech.fieldMode].name === "plasma torch" || mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" || mech.fieldUpgrades[mech.fieldMode].name === "pilot wave"
return (mod.haveGunCheck("nail gun") && mod.isIceCrystals) || mod.haveGunCheck("laser") || mech.fieldUpgrades[mech.fieldMode].name === "plasma torch" || mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" || mech.fieldUpgrades[mech.fieldMode].name === "pilot wave"
},
requires: "energy based damage",
effect() {
@@ -408,7 +408,7 @@ const mod = {
maxCount: 9,
count: 0,
allowed() {
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.haveGunCheck("pulse") || mod.isMissileField || mod.boomBotCount > 1 || mod.isFlechetteExplode
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.isPulseLaser || mod.isMissileField || mod.boomBotCount > 1 || mod.isFlechetteExplode
},
requires: "an explosive damage source",
effect: () => {
@@ -424,7 +424,7 @@ const mod = {
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.haveGunCheck("pulse") || mod.isMissileField || mod.boomBotCount > 1 || mod.isFlechetteExplode
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.isPulseLaser || mod.isMissileField || mod.boomBotCount > 1 || mod.isFlechetteExplode
},
requires: "an explosive damage source",
effect: () => {
@@ -440,7 +440,7 @@ const mod = {
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.haveGunCheck("pulse") || mod.isMissileField || mod.isFlechetteExplode
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.isPulseLaser || mod.isMissileField || mod.isFlechetteExplode
},
requires: "an explosive damage source",
effect: () => {
@@ -457,7 +457,7 @@ const mod = {
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.isMissileField || mod.isExplodeMob || mod.isFlechetteExplode
return mod.haveGunCheck("missiles") || mod.haveGunCheck("flak") || mod.haveGunCheck("grenades") || mod.haveGunCheck("vacuum bomb") || mod.isMissileField || mod.isExplodeMob || mod.isFlechetteExplode || mod.isPulseLaser
},
requires: "an explosive damage source",
effect: () => {
@@ -469,7 +469,7 @@ const mod = {
},
{
name: "scrap bots",
description: "<strong>19%</strong> chance to build a <strong>bot</strong> after killing a mob<br>the bot last for about <strong>30</strong> seconds",
description: "<strong>20%</strong> chance to build a <strong>bot</strong> after killing a mob<br>the bot last for about <strong>20</strong> seconds",
maxCount: 3,
count: 0,
allowed() {
@@ -477,7 +477,7 @@ const mod = {
},
requires: "a bot",
effect() {
mod.isBotSpawner += 0.19;
mod.isBotSpawner += 0.20;
},
remove() {
mod.isBotSpawner = 0;
@@ -2047,22 +2047,6 @@ const mod = {
}
}
},
// {
// name: "electromagnetic pulse",
// description: "<strong>vacuum bomb's </strong> <strong class='color-e'>explosion</strong> removes<br><strong>80%</strong> of <strong>shields</strong> and <strong>100%</strong> of <strong class='color-f'>energy</strong>",
// maxCount: 1,
// count: 0,
// allowed() {
// return mod.haveGunCheck("vacuum bomb")
// },
// requires: "vacuum bomb",
// effect() {
// mod.isVacuumShield = true;
// },
// remove() {
// mod.isVacuumShield = false;
// }
// },
{
name: "water shielding",
description: "increase <strong>neutron bomb's</strong> range by <strong>20%</strong><br>player is <strong>immune</strong> to its harmful effects",
@@ -2404,11 +2388,11 @@ const mod = {
},
{
name: "laser diodes",
description: "<strong>lasers</strong> drain <strong>37%</strong> less <strong class='color-f'>energy</strong><br><em>effects laser gun, pulse gun, and laser-bot</em>",
description: "<strong>lasers</strong> drain <strong>37%</strong> less <strong class='color-f'>energy</strong><br><em>effects laser-gun and laser-bot</em>",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("pulse") || mod.haveGunCheck("laser") || mod.laserBotCount > 1
return mod.haveGunCheck("laser") || mod.laserBotCount > 1
},
requires: "laser",
effect() {
@@ -2424,7 +2408,7 @@ const mod = {
maxCount: 9,
count: 0,
allowed() {
return mod.haveGunCheck("laser") && !mod.isWideLaser
return mod.haveGunCheck("laser") && !mod.isWideLaser && !mod.isPulseLaser
},
requires: "laser, not wide beam",
effect() {
@@ -2444,7 +2428,7 @@ const mod = {
maxCount: 9,
count: 0,
allowed() {
return mod.haveGunCheck("laser") && !mod.isWideLaser
return mod.haveGunCheck("laser") && !mod.isWideLaser && !mod.isPulseLaser
},
requires: "laser, not specular reflection",
effect() {
@@ -2456,13 +2440,13 @@ const mod = {
},
{
name: "diffuse beam",
description: "<strong>laser</strong> beam is <strong>wider</strong> and doesn't <strong>reflect</strong><br>increase laser <strong class='color-d'>damage</strong> by <strong>100%</strong>",
description: "<strong>laser</strong> beam is <strong>wider</strong> and doesn't <strong>reflect</strong><br>increase full beam <strong class='color-d'>damage</strong> by <strong>175%</strong>",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("laser") && mod.laserReflections < 3 && !mod.beamSplitter
return mod.haveGunCheck("laser") && mod.laserReflections < 3 && !mod.beamSplitter && !mod.isPulseLaser
},
requires: "laser, not specular reflection",
requires: "laser, not specular reflection<br>not beam splitter",
effect() {
if (mod.wideLaser === 0) mod.wideLaser = 3
mod.isWideLaser = true;
@@ -2474,13 +2458,13 @@ const mod = {
},
{
name: "output coupler",
description: "diffuse <strong>laser</strong> beam is <strong>30%</strong> <strong>wider</strong><br> and the full beam does <strong>30%</strong> more <strong class='color-d'>damage</strong>",
description: "<strong>widen</strong> diffuse <strong>laser</strong> beam by <strong>40%</strong><br>increase full beam <strong class='color-d'>damage</strong> by <strong>40%</strong>",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("laser") && mod.isWideLaser
},
requires: "laser, not specular reflection",
requires: "laser, not specular reflection<br>not beam splitter",
effect() {
mod.wideLaser = 4
},
@@ -2492,29 +2476,35 @@ const mod = {
}
}
},
// {
// name: "waste heat recovery",
// description: "<strong>laser</strong> <strong class='color-d'>damage</strong> grows by <strong>400%</strong> as you fire<br>but you periodically <strong>eject</strong> your <strong class='color-h'>health</strong>",
// maxCount: 1,
// count: 0,
// allowed() {
// return mod.haveGunCheck("laser") && !mod.isEnergyHealth
// },
// requires: "laser<br>not mass-energy equivalence",
// effect() {
// mod.isLaserHealth = true;
// },
// remove() {
// mod.isLaserHealth = false
// }
// },
{
name: "pulse",
description: "convert <strong>25%</strong> of your <strong class='color-f'>energy</strong> into a pulsed laser<br>instantly initiates a fusion <strong class='color-e'>explosion</strong>",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("laser") && mod.laserReflections < 3 && !mod.beamSplitter && !mod.isWideLaser
},
requires: "laser, not specular reflection<br>not beam splitter, not diffuse",
effect() {
mod.isPulseLaser = true;
for (i = 0, len = b.guns.length; i < len; i++) { //find which gun
if (b.guns[i].name === "laser") b.guns[i].fire = b.guns[i].firePulse
}
},
remove() {
mod.isPulseLaser = false;
for (i = 0, len = b.guns.length; i < len; i++) { //find which gun
if (b.guns[i].name === "laser") b.guns[i].fire = b.guns[i].fireLaser
}
}
},
{
name: "shock wave",
description: "mobs caught in <strong>pulse's</strong> explosion are <strong>stunned</strong><br>for up to <strong>2 seconds</strong>",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("pulse")
return mod.isPulseLaser
},
requires: "pulse",
effect() {
@@ -2524,14 +2514,13 @@ const mod = {
mod.isPulseStun = false;
}
},
{
name: "neocognitron",
description: "<strong>pulse</strong> automatically <strong>aims</strong> at a nearby mob<br><strong>50%</strong> decreased <strong>delay</strong> after firing",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("pulse")
return mod.isPulseLaser
},
requires: "pulse",
effect() {
@@ -2725,7 +2714,7 @@ const mod = {
},
requires: "standing wave harmonics",
effect() {
mod.blockDmg += 0.66 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
mod.blockDmg += 0.7 //if you change this value also update the for loop in the electricity graphics in mech.pushMass
},
remove() {
mod.blockDmg = 0;
@@ -3188,5 +3177,6 @@ const mod = {
isWormSpores: null,
isWormBullets: null,
isWideLaser: null,
wideLaser: null
wideLaser: null,
isPulseLaser: null
}

View File

@@ -1273,9 +1273,9 @@ const mech = {
},
{
name: "standing wave harmonics",
description: "three oscillating <strong>shields</strong> are permanently active<br><strong>blocking</strong> has no <strong>cool down</strong><br>reduce <strong class='color-harm'>harm</strong> by <strong>20%</strong>",
description: "<strong>3</strong> oscillating <strong>shields</strong> are permanently active<br><strong>blocking</strong> drains <strong class='color-f'>energy</strong><br><strong>blocking</strong> has no <strong>cool down</strong>",
effect: () => {
mech.fieldHarmReduction = 0.80;
// mech.fieldHarmReduction = 0.80;
mech.fieldBlockCD = 0;
mech.hold = function () {
if (mech.isHolding) {
@@ -1390,7 +1390,7 @@ const mech = {
},
{
name: "nano-scale manufacturing",
description: "excess <strong class='color-f'>energy</strong> used to build <strong>drones</strong><br>increase <strong class='color-f'>energy</strong> regeneration by <strong>100%</strong>",
description: "use <strong class='color-f'>energy</strong> to <strong>block</strong> mobs<br>excess <strong class='color-f'>energy</strong> used to build <strong>drones</strong><br>increase <strong class='color-f'>energy</strong> regeneration by <strong>100%</strong>",
effect: () => {
mech.hold = function () {
if (mech.energy > mech.maxEnergy - 0.02 && mech.fieldCDcycle < mech.cycle) {
@@ -1420,7 +1420,6 @@ const mech = {
mech.energy -= 0.33;
b.drone(1)
}
}
if (mech.isHolding) {
mech.drawHold(mech.holdingTarget);
@@ -1445,13 +1444,13 @@ const mech = {
},
{
name: "negative mass field",
description: "use <strong class='color-f'>energy</strong> to nullify &nbsp;<strong style='letter-spacing: 7px;'>gravity</strong><br>reduce <strong class='color-harm'>harm</strong> by <strong>45%</strong><br><strong>blocks</strong> held by the field have a lower <strong>mass</strong>",
description: "use <strong class='color-f'>energy</strong> to nullify &nbsp;<strong style='letter-spacing: 7px;'>gravity</strong><br>reduce <strong class='color-harm'>harm</strong> by <strong>40%</strong><br><strong>blocks</strong> held by the field have a lower <strong>mass</strong>",
fieldDrawRadius: 0,
effect: () => {
mech.fieldFire = true;
mech.holdingMassScale = 0.03; //can hold heavier blocks with lower cost to jumping
mech.fieldMeterColor = "#000"
mech.fieldHarmReduction = 0.55;
mech.fieldHarmReduction = 0.6;
mech.fieldDrawRadius = 0;
mech.hold = function () {

View File

@@ -234,7 +234,7 @@ const spawn = {
me.frictionAir = 0.01
me.seeAtDistance2 = 9000000;
me.accelMag = 0.00062 * game.accelScale;
Matter.Body.setDensity(me, 0.001); //normal is 0.001
Matter.Body.setDensity(me, 0.0006); //normal is 0.001
me.collisionFilter.mask = cat.bullet | cat.player
me.memory = Infinity;
me.seePlayerFreq = 60