laser-mines

tech: laser-mines - a floating triangle spins around with lasers coming from it's points
This commit is contained in:
landgreen
2020-12-30 19:35:41 -08:00
parent 9f019b9988
commit 491b979d4c
4 changed files with 136 additions and 37 deletions

View File

@@ -2222,8 +2222,8 @@ const b = {
}
//hit target with laser
if (this.lockedOn && this.lockedOn.alive && mech.energy > this.drainThreshold) {
mech.energy -= 0.0012 * tech.isLaserDiode
b.laser(this.vertices[0], this.lockedOn.position, b.dmgScale * (0.06 + 0.15 * this.isUpgraded))
mech.energy -= tech.laserFieldDrain * tech.isLaserDiode
b.laser(this.vertices[0], this.lockedOn.position, b.dmgScale * (0.38 * tech.laserDamage + this.isUpgraded * 0.21)) //tech.laserDamage = 0.16
}
}
})
@@ -3283,18 +3283,107 @@ const b = {
ammoPack: 2.7,
have: false,
fire() {
const pos = {
x: mech.pos.x + 30 * Math.cos(mech.angle),
y: mech.pos.y + 30 * Math.sin(mech.angle)
if (tech.isLaserMine) { //laser mine
const me = bullet.length;
const position = mech.pos
bullet[me] = Bodies.polygon(position.x, position.y, 3, 25, {
bulletType: "mine",
angle: mech.angle,
friction: 0,
frictionAir: 0.05,
restitution: 0.5,
dmg: 0, // 0.14 //damage done in addition to the damage from momentum
minDmgSpeed: 2,
lookFrequency: 60 + Math.floor(7 * Math.random()),
drain: tech.isLaserDiode * tech.laserFieldDrain,
isArmed: false,
torqueMagnitude: (Math.random() > 0.5 ? 1 : -1) * 0.000003,
range: 1500,
endCycle: Infinity,
classType: "bullet",
collisionFilter: {
category: cat.bullet,
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield | cat.bullet
},
beforeDmg() {},
onEnd() {
if (tech.isMineAmmoBack && (!this.isArmed || Math.random() < 0.2)) { //get ammo back from tech.isMineAmmoBack
for (i = 0, len = b.guns.length; i < len; i++) { //find which gun
if (b.guns[i].name === "mine") {
b.guns[i].ammo++
simulation.updateGunHUD();
break;
}
}
}
},
do() {
if (!(simulation.cycle % this.lookFrequency) && mech.energy > this.drain) { //find mob targets
for (let i = 0, len = mob.length; i < len; ++i) {
if (
Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position)) < 2000000 &&
mob[i].dropPowerUp &&
Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
Matter.Query.ray(body, this.position, mob[i].position).length === 0
) {
this.do = this.laserSpin
this.endCycle = simulation.cycle + 300
this.torqueMagnitude *= 2
this.torque += this.inertia * this.torqueMagnitude * 30 //spin
this.isArmed = true
}
}
}
},
reflections: Math.max(0, tech.laserReflections - 2),
laserSpin() {
//drain energy
if (mech.energy > this.drain) {
mech.energy -= this.drain
if (this.angularSpeed < 0.02) this.torque += this.inertia * this.torqueMagnitude //spin
//fire lasers
ctx.strokeStyle = "#f00";
ctx.lineWidth = 1.5
// ctx.globalAlpha = 1;
ctx.beginPath();
for (let i = 0; i < 3; i++) {
const where = this.vertices[i]
const endPoint = Vector.add(where, Vector.mult(Vector.normalise(Vector.sub(where, this.position)), 2500))
b.laser(where, endPoint, tech.laserDamage * 10, this.reflections, true)
}
ctx.stroke();
// ctx.globalAlpha = 1;
}
}
})
// if (tech.isMineSentry) {
// bullet[me].endCycle = simulation.cycle + 480
// bullet[me].do = bullet[me].laserSpin
// bullet[me].isArmed = true
// // Matter.Body.setAngularVelocity(bullet[me], 3000 * bullet[me].torqueMagnitude);
// }
let speed = mech.crouch ? 50 : 20
Matter.Body.setVelocity(bullet[me], {
x: speed * Math.cos(mech.angle),
y: speed * Math.sin(mech.angle)
});
World.add(engine.world, bullet[me]); //add bullet to world
} else { //normal mines
const pos = {
x: mech.pos.x + 30 * Math.cos(mech.angle),
y: mech.pos.y + 30 * Math.sin(mech.angle)
}
let speed = mech.crouch ? 36 : 22
if (Matter.Query.point(map, pos).length > 0) { //don't fire if mine will spawn inside map
speed = -2
}
b.mine(pos, {
x: speed * Math.cos(mech.angle),
y: speed * Math.sin(mech.angle)
}, 0, tech.isMineAmmoBack)
}
let speed = mech.crouch ? 36 : 22
if (Matter.Query.point(map, pos).length > 0) { //don't fire if mine will spawn inside map
speed = -2
}
b.mine(pos, {
x: speed * Math.cos(mech.angle),
y: speed * Math.sin(mech.angle)
}, 0, tech.isMineAmmoBack)
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 50 : 25) * b.fireCD); // cool down
}
},

View File

@@ -17,7 +17,8 @@ const level = {
// simulation.zoomScale = 1000;
// simulation.setZoom();
// mech.setField("plasma torch")
// b.giveGuns("missiles")
// b.giveGuns("mine")
// tech.isMineSentry = true
// tech.giveTech("CPT reversal")
// tech.giveTech("missile-bot")
// tech.giveTech("nail-bot")
@@ -3824,8 +3825,9 @@ const level = {
// level.difficultyIncrease(simulation.difficultyMode) //increase difficulty based on modes
//difficulty is increased 5 times when finalBoss dies
const len = level.levelsCleared / level.levels.length //add 1 extra difficulty step for each time you have cleared all the levels
for (let i = 0; i < len; i++) level.difficultyIncrease(simulation.difficultyMode)
// const len = level.levelsCleared / level.levels.length //add 1 extra difficulty step for each time you have cleared all the levels
// for (let i = 0; i < len; i++)
level.difficultyIncrease(simulation.difficultyMode)
level.onLevel++; //cycles map to next level
if (level.onLevel > level.levels.length - 1) level.onLevel = 0;

View File

@@ -2574,6 +2574,23 @@ const tech = {
tech.isNeutronSlow = false
}
},
{
name: "laser-mines",
description: "<strong>mines</strong> hover in place until <strong>mobs</strong> get in range<br><strong>mines</strong> use <strong class='color-f'>energy</strong> to emit <strong>3</strong> unaimed <strong>lasers</strong>",
isGunTech: true,
maxCount: 1,
count: 0,
allowed() {
return (tech.haveGunCheck("mine") || tech.isMineDrop) && !tech.isMineSentry
},
requires: "mines, not sentry",
effect() {
tech.isLaserMine = true;
},
remove() {
tech.isLaserMine = false;
}
},
{
name: "mine reclamation",
description: "retrieve <strong class='color-g'>ammo</strong> from all undetonated <strong>mines</strong><br>and <strong>20%</strong> of <strong>mines</strong> after detonation",
@@ -2598,9 +2615,9 @@ const tech = {
maxCount: 1,
count: 0,
allowed() {
return (tech.haveGunCheck("mine") && !tech.isMineAmmoBack) || tech.isMineDrop
return (tech.haveGunCheck("mine") && !tech.isMineAmmoBack && !tech.isLaserMine) || tech.isMineDrop
},
requires: "mine, not mine reclamation",
requires: "mine, not mine reclamation, not laser-mines",
effect() {
tech.isMineSentry = true;
},
@@ -2615,7 +2632,7 @@ const tech = {
maxCount: 1,
count: 0,
allowed() {
return tech.isMineDrop + tech.nailBotCount + tech.fragments + tech.nailsDeathMob / 2 + (tech.haveGunCheck("mine") + tech.isNailShot + (tech.haveGunCheck("nail gun") && !tech.isIncendiary)) * 2 > 1
return tech.isMineDrop + tech.nailBotCount + tech.fragments + tech.nailsDeathMob / 2 + ((tech.haveGunCheck("mine") && !tech.isLaserMine) + tech.isNailShot + (tech.haveGunCheck("nail gun") && !tech.isIncendiary)) * 2 > 1
},
requires: "nails",
effect() {
@@ -2632,7 +2649,7 @@ const tech = {
maxCount: 1,
count: 0,
allowed() {
return tech.isMineDrop + tech.nailBotCount + tech.fragments + tech.nailsDeathMob / 2 + (tech.haveGunCheck("mine") + tech.isNailShot + (tech.haveGunCheck("nail gun") && !tech.isIncendiary)) * 2 > 1
return tech.isMineDrop + tech.nailBotCount + tech.fragments + tech.nailsDeathMob / 2 + ((tech.haveGunCheck("mine") && !tech.isLaserMine) + tech.isNailShot + (tech.haveGunCheck("nail gun") && !tech.isIncendiary)) * 2 > 1
},
requires: "nails",
effect() {
@@ -2934,12 +2951,12 @@ const tech = {
},
{
name: "laser diodes",
description: "<strong>lasers</strong> drain <strong>37%</strong> less <strong class='color-f'>energy</strong><br><em>effects laser-gun and laser-bot</em>",
description: "all <strong>lasers</strong> drain <strong>37%</strong> less <strong class='color-f'>energy</strong><br><em>effects laser-gun, laser-bot, and laser-mines</em>",
isGunTech: true,
maxCount: 1,
count: 0,
allowed() {
return tech.haveGunCheck("laser") || tech.laserBotCount > 1
return tech.haveGunCheck("laser") || tech.laserBotCount > 1 || tech.isLaserMine
},
requires: "laser",
effect() {
@@ -2951,12 +2968,12 @@ const tech = {
},
{
name: "specular reflection",
description: "<strong>laser</strong> beams gain <strong>1</strong> reflection<br>increase <strong class='color-d'>damage</strong> and <strong class='color-f'>energy</strong> drain by <strong>50%</strong>",
description: "increase <strong class='color-d'>damage</strong> and <strong class='color-f'>energy</strong> drain by <strong>50%</strong><br>and <strong>+1</strong> reflection for all <strong>lasers</strong> <em>(gun, bot, mine)</em>",
isGunTech: true,
maxCount: 9,
count: 0,
allowed() {
return tech.haveGunCheck("laser") && !tech.isWideLaser && !tech.isPulseLaser && !tech.historyLaser
return (tech.haveGunCheck("laser") || tech.isLaserMine || tech.laserBotCount > 1) && !tech.isWideLaser && !tech.isPulseLaser && !tech.historyLaser
},
requires: "laser, not wide beam",
effect() {
@@ -3942,6 +3959,6 @@ const tech = {
isExtruder: null,
isEndLevelPowerUp: null,
isRewindGun: null,
missileSize: null
missileSize: null,
isLaserMine: null
}

View File

@@ -1,14 +1,6 @@
******************************************************** NEXT PATCH ********************************************************
fixed some math on laser tech: diffraction grating and slow light propagation
they were giving too much damage
flechettes are slightly improved in: ammo, damage, fire rate
tech - MIRV can now stack up to 9 bonus missiles
removed tech - recursive missiles
tech: cruise missile - 50% larger size, but travels 50% slower
tech: missileBot - requires gun: missiles
tech: laser-mines - a floating triangle spins around with lasers coming from it's points
******************************************************** BUGS ********************************************************
@@ -58,8 +50,7 @@ in game console
death, max health, max energy, rewind
mine tech: laser mines - mines hover in the air
maybe they can be thrown a short distance, but they have no gravity and high friction, so they hover
when a mob gets close they spin and fire 3 unaimed lasers from their vertexes
unlock specular reflection and laser diodes
with tech:sentry the mines spin immediately, and spin 2x times longer?
mechanic: use gun swap as an active ability