laser push

tech: relativistic momentum - laser beams push mobs away
This commit is contained in:
landgreen
2021-01-04 18:32:56 -08:00
parent 79136db727
commit 9a97371893
6 changed files with 480 additions and 432 deletions

View File

@@ -1125,7 +1125,7 @@ const b = {
}, whereEnd = {
x: where.x + 3000 * Math.cos(mech.angle),
y: where.y + 3000 * Math.sin(mech.angle)
}, dmg = tech.laserDamage, reflections = tech.laserReflections, isThickBeam = false) {
}, dmg = tech.laserDamage, reflections = tech.laserReflections, isThickBeam = false, push = 1) {
const reflectivity = 1 - 1 / (reflections * 1.5)
let damage = b.dmgScale * dmg
let best = {
@@ -1211,6 +1211,21 @@ const b = {
color: "rgba(255,0,0,0.5)",
time: simulation.drawTime
});
if (tech.isLaserPush) { //push mobs away
console.log(-0.003 * Math.min(4, best.who.mass), dmg)
const index = path.length - 1
// const force = Vector.mult(Vector.normalise(Vector.sub(path[Math.max(0, index - 1)], path[index])), -0.003 * Math.min(4, best.who.mass))
// const push = -0.004 / (1 + tech.beamSplitter + tech.wideLaser + tech.historyLaser)
// console.log(push)
const force = Vector.mult(Vector.normalise(Vector.sub(path[index], path[Math.max(0, index - 1)])), 0.004 * push * Math.min(4, best.who.mass))
Matter.Body.applyForce(best.who, path[index], force)
// Matter.Body.setVelocity(best.who, { //friction
// x: best.who.velocity.x * 0.7,
// y: best.who.velocity.y * 0.7
// });
}
}
// ctx.fillStyle = color; //draw mob damage circle
// ctx.beginPath();
@@ -2224,7 +2239,14 @@ const b = {
//hit target with laser
if (this.lockedOn && this.lockedOn.alive && mech.energy > this.drainThreshold) {
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
b.laser(this.vertices[0], this.lockedOn.position, b.dmgScale * (0.38 * tech.laserDamage + this.isUpgraded * 0.21), tech.laserReflections, false, 0.4) //tech.laserDamage = 0.16
// laser(where = {
// x: mech.pos.x + 20 * Math.cos(mech.angle),
// y: mech.pos.y + 20 * Math.sin(mech.angle)
// }, whereEnd = {
// x: where.x + 3000 * Math.cos(mech.angle),
// y: where.y + 3000 * Math.sin(mech.angle)
// }, dmg = tech.laserDamage, reflections = tech.laserReflections, isThickBeam = false, push = 1) {
}
}
})
@@ -3908,7 +3930,7 @@ const b = {
},
{
name: "laser",
description: "emit a <strong>beam</strong> of collimated coherent <strong>light</strong><br>drains <strong class='color-f'>energy</strong> instead of ammunition",
description: "emit a <strong>beam</strong> of collimated coherent <strong class='color-laser'>light</strong><br>drains <strong class='color-f'>energy</strong> instead of ammunition",
ammo: 0,
ammoPack: Infinity,
have: false,
@@ -3938,6 +3960,14 @@ const b = {
b.laser();
}
},
// laser(where = {
// x: mech.pos.x + 20 * Math.cos(mech.angle),
// y: mech.pos.y + 20 * Math.sin(mech.angle)
// }, whereEnd = {
// x: where.x + 3000 * Math.cos(mech.angle),
// y: where.y + 3000 * Math.sin(mech.angle)
// }, dmg = tech.laserDamage, reflections = tech.laserReflections, isThickBeam = false, push = 1) {
fireSplit() {
if (mech.energy < tech.laserFieldDrain) {
mech.fireCDcycle = mech.cycle + 100; // cool down if out of energy
@@ -3945,7 +3975,9 @@ const b = {
mech.fireCDcycle = mech.cycle
mech.energy -= mech.fieldRegen + tech.laserFieldDrain * tech.isLaserDiode
const divergence = mech.crouch ? 0.15 : 0.2
let dmg = tech.laserDamage * Math.pow(0.9, tech.beamSplitter) //Math.pow(0.9, tech.laserDamage)
const scale = Math.pow(0.9, tech.beamSplitter)
const pushScale = scale * scale
let dmg = tech.laserDamage * scale //Math.pow(0.9, tech.laserDamage)
const where = {
x: mech.pos.x + 20 * Math.cos(mech.angle),
y: mech.pos.y + 20 * Math.sin(mech.angle)
@@ -3953,16 +3985,16 @@ const b = {
b.laser(where, {
x: where.x + 3000 * Math.cos(mech.angle),
y: where.y + 3000 * Math.sin(mech.angle)
}, dmg)
}, dmg, tech.laserReflections, false, pushScale)
for (let i = 1; i < 1 + tech.beamSplitter; i++) {
b.laser(where, {
x: where.x + 3000 * Math.cos(mech.angle + i * divergence),
y: where.y + 3000 * Math.sin(mech.angle + i * divergence)
}, dmg)
}, dmg, tech.laserReflections, false, pushScale)
b.laser(where, {
x: where.x + 3000 * Math.cos(mech.angle - i * divergence),
y: where.y + 3000 * Math.sin(mech.angle - i * divergence)
}, dmg)
}, dmg, tech.laserReflections, false, pushScale)
}
}
},
@@ -3985,7 +4017,7 @@ const b = {
b.laser(where, {
x: where.x + 3000 * Math.cos(angle),
y: where.y + 3000 * Math.sin(angle)
}, dmg, 0, true)
}, dmg, 0, true, 0.4)
for (let i = 1; i < tech.wideLaser; i++) {
let whereOff = Vector.add(where, {
x: i * off * Math.cos(angle + Math.PI / 2),
@@ -3994,7 +4026,7 @@ const b = {
b.laser(whereOff, {
x: whereOff.x + 3000 * Math.cos(angle),
y: whereOff.y + 3000 * Math.sin(angle)
}, dmg, 0, true)
}, dmg, 0, true, 0.4)
whereOff = Vector.add(where, {
x: i * off * Math.cos(angle - Math.PI / 2),
y: i * off * Math.sin(angle - Math.PI / 2)
@@ -4002,7 +4034,7 @@ const b = {
b.laser(whereOff, {
x: whereOff.x + 3000 * Math.cos(angle),
y: whereOff.y + 3000 * Math.sin(angle)
}, dmg, 0, true)
}, dmg, 0, true, 0.4)
}
ctx.stroke();
ctx.globalAlpha = 1;
@@ -4039,7 +4071,7 @@ const b = {
}, {
x: mech.pos.x + 3000 * Math.cos(mech.angle),
y: mech.pos.y + 3000 * Math.sin(mech.angle)
}, dmg, 0, true);
}, dmg, 0, true, 0.3);
for (let i = 1; i < len; i++) {
const history = mech.history[(mech.cycle - i * spacing) % 600]
b.laser({
@@ -4048,7 +4080,7 @@ const b = {
}, {
x: history.position.x + 3000 * Math.cos(history.angle),
y: history.position.y + 3000 * Math.sin(history.angle) - mech.yPosDifference
}, dmg, 0, true);
}, dmg, 0, true, 0.3);
}
ctx.stroke();
}

View File

@@ -17,7 +17,7 @@ const level = {
// simulation.zoomScale = 1000;
// simulation.setZoom();
// mech.setField("plasma torch")
// b.giveGuns("missiles")
b.giveGuns("laser")
// tech.isMineSentry = true
// tech.giveTech("foam fractionation")
// tech.giveTech("missile-bot")

View File

@@ -2269,7 +2269,7 @@ const spawn = {
this.explode(this.mass * 20);
};
Matter.Body.setDensity(me, 0.000015); //normal is 0.001
me.timeLeft = 420 * (0.8 + 0.4 * Math.random());
me.timeLeft = 420 //* (0.8 + 0.4 * Math.random());
me.accelMag = 0.00017 * simulation.accelScale; //* (0.8 + 0.4 * Math.random())
me.frictionAir = 0.01 //* (0.8 + 0.4 * Math.random());
me.restitution = 0.5;

File diff suppressed because it is too large Load Diff

View File

@@ -543,6 +543,14 @@ summary {
letter-spacing: 1px;
}
.color-laser {
color: #f02;
/* text-shadow: 0px 0px 2px rgba(255, 0, 119, 0.3); */
/* text-shadow: 0px 0px 1.5px rgba(0, 0, 0, 1), 0px 0px 5px rgba(255, 0, 0, 1); */
font-weight: 100;
letter-spacing: -0.8px;
}
.color-plasma {
color: #c0e;
letter-spacing: 1px;

View File

@@ -1,16 +1,6 @@
******************************************************** NEXT PATCH ********************************************************
reroll renamed -> research
spore damage increased 25%
ice IX has it's damage buffed by 50%, and freeze effect lasts 2s (up from 1s)
ice IX is no longer a gun
but you can still get it for nano-scale field (and it's pretty strong)
tech: heavy water was removed
tech: correlated damage - duplication chance also gives % damage
(also added some minor nerfs to other duplication tech for balance)
tech: relativistic momentum - laser beams push mobs away
******************************************************** BUGS ********************************************************
@@ -48,9 +38,9 @@ tech: dodge chance for cloaking, harmonic fields, also pilot wave
set to 100% harm reduction randomly
if (Math.random() < 0.2) damage *= 0;
rename
health > integrity, unity
heal > also integrity, unity
rename ?
health -> integrity, unity
heal -> also integrity, unity
in game console
set highlighting rules
@@ -79,7 +69,7 @@ mob ability bombs/bullets that suck in player
tech where you can't stop firing, how to code?
tech: laser beams push like plasma torch pushes with directional force
tech: translational invariance - laser beams push like plasma torch pushes with directional force
mechanic: technological dead end - add tech to the tech pool with a dumb effect
don't show up in custom?