diffuse beam optimizations
This commit is contained in:
57
js/bullet.js
57
js/bullet.js
@@ -4000,56 +4000,63 @@ const b = {
|
|||||||
} else {
|
} else {
|
||||||
mech.fireCDcycle = mech.cycle
|
mech.fireCDcycle = mech.cycle
|
||||||
mech.energy -= mech.fieldRegen + tech.laserFieldDrain * tech.isLaserDiode
|
mech.energy -= mech.fieldRegen + tech.laserFieldDrain * tech.isLaserDiode
|
||||||
const dmg = 0.55 * tech.laserDamage // 3.5 * 0.55 = 200% more damage
|
const range = {
|
||||||
const eye = {
|
x: 5000 * Math.cos(mech.angle),
|
||||||
x: mech.pos.x + 16 * Math.cos(mech.angle),
|
y: 5000 * Math.sin(mech.angle)
|
||||||
y: mech.pos.y + 16 * Math.sin(mech.angle)
|
}
|
||||||
|
const rangeOffPlus = {
|
||||||
|
x: 7.5 * Math.cos(mech.angle + Math.PI / 2),
|
||||||
|
y: 7.5 * Math.sin(mech.angle + Math.PI / 2)
|
||||||
|
}
|
||||||
|
const rangeOffMinus = {
|
||||||
|
x: 7.5 * Math.cos(mech.angle - Math.PI / 2),
|
||||||
|
y: 7.5 * Math.sin(mech.angle - Math.PI / 2)
|
||||||
|
}
|
||||||
|
const dmg = 0.55 * tech.laserDamage // 3.5 * 0.55 = 200% more damage
|
||||||
|
const where = { x: mech.pos.x + 30 * Math.cos(mech.angle), y: mech.pos.y + 30 * Math.sin(mech.angle) }
|
||||||
|
const eye = {
|
||||||
|
x: mech.pos.x + 15 * Math.cos(mech.angle),
|
||||||
|
y: mech.pos.y + 15 * Math.sin(mech.angle)
|
||||||
}
|
}
|
||||||
const wideLaser = function(where = {
|
|
||||||
x: mech.pos.x + 30 * Math.cos(mech.angle),
|
|
||||||
y: mech.pos.y + 30 * Math.sin(mech.angle)
|
|
||||||
}, angle = mech.angle) {
|
|
||||||
ctx.strokeStyle = "#f00";
|
ctx.strokeStyle = "#f00";
|
||||||
ctx.lineWidth = 8
|
ctx.lineWidth = 8
|
||||||
ctx.globalAlpha = 0.5;
|
ctx.globalAlpha = 0.5;
|
||||||
ctx.beginPath();
|
ctx.beginPath();
|
||||||
const off = 7.5
|
if (Matter.Query.ray(map, eye, where).length === 0 && Matter.Query.ray(body, eye, where).length === 0) {
|
||||||
b.laser(where, {
|
b.laser(eye, {
|
||||||
x: eye.x + 3000 * Math.cos(angle),
|
x: eye.x + range.x,
|
||||||
y: eye.y + 3000 * Math.sin(angle)
|
y: eye.y + range.y
|
||||||
}, dmg, 0, true, 0.3)
|
}, dmg, 0, true, 0.3)
|
||||||
|
}
|
||||||
for (let i = 1; i < tech.wideLaser; i++) {
|
for (let i = 1; i < tech.wideLaser; i++) {
|
||||||
let whereOff = Vector.add(where, {
|
let whereOff = Vector.add(where, {
|
||||||
x: i * off * Math.cos(angle + Math.PI / 2),
|
x: i * rangeOffPlus.x,
|
||||||
y: i * off * Math.sin(angle + Math.PI / 2)
|
y: i * rangeOffPlus.y
|
||||||
})
|
})
|
||||||
if (Matter.Query.ray(map, eye, whereOff).length === 0) {
|
if (Matter.Query.ray(map, eye, whereOff).length === 0 && Matter.Query.ray(body, eye, whereOff).length === 0) {
|
||||||
ctx.moveTo(eye.x, eye.y)
|
ctx.moveTo(eye.x, eye.y)
|
||||||
ctx.lineTo(whereOff.x, whereOff.y)
|
ctx.lineTo(whereOff.x, whereOff.y)
|
||||||
b.laser(whereOff, {
|
b.laser(whereOff, {
|
||||||
x: whereOff.x + 3000 * Math.cos(angle),
|
x: whereOff.x + range.x,
|
||||||
y: whereOff.y + 3000 * Math.sin(angle)
|
y: whereOff.y + range.y
|
||||||
}, dmg, 0, true, 0.3)
|
}, dmg, 0, true, 0.3)
|
||||||
}
|
}
|
||||||
whereOff = Vector.add(where, {
|
whereOff = Vector.add(where, {
|
||||||
x: i * off * Math.cos(angle - Math.PI / 2),
|
x: i * rangeOffMinus.x,
|
||||||
y: i * off * Math.sin(angle - Math.PI / 2)
|
y: i * rangeOffMinus.y
|
||||||
})
|
})
|
||||||
if (Matter.Query.ray(map, eye, whereOff).length === 0) {
|
if (Matter.Query.ray(map, eye, whereOff).length === 0 && Matter.Query.ray(body, eye, whereOff).length === 0) {
|
||||||
ctx.moveTo(eye.x, eye.y)
|
ctx.moveTo(eye.x, eye.y)
|
||||||
ctx.lineTo(whereOff.x, whereOff.y)
|
ctx.lineTo(whereOff.x, whereOff.y)
|
||||||
b.laser(whereOff, {
|
b.laser(whereOff, {
|
||||||
x: whereOff.x + 3000 * Math.cos(angle),
|
x: whereOff.x + range.x,
|
||||||
y: whereOff.y + 3000 * Math.sin(angle)
|
y: whereOff.y + range.y
|
||||||
}, dmg, 0, true, 0.3)
|
}, dmg, 0, true, 0.3)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
ctx.stroke();
|
ctx.stroke();
|
||||||
ctx.globalAlpha = 1;
|
ctx.globalAlpha = 1;
|
||||||
}
|
}
|
||||||
wideLaser();
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
fireHistory() {
|
fireHistory() {
|
||||||
if (mech.energy < tech.laserFieldDrain) {
|
if (mech.energy < tech.laserFieldDrain) {
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ const level = {
|
|||||||
// b.giveGuns("laser")
|
// b.giveGuns("laser")
|
||||||
// tech.isMineSentry = true
|
// tech.isMineSentry = true
|
||||||
// tech.giveTech("diffuse beam")
|
// tech.giveTech("diffuse beam")
|
||||||
|
// for (let i = 0; i < 60; i++) tech.giveTech("output coupler")
|
||||||
// tech.giveTech("missile-bot")
|
// tech.giveTech("missile-bot")
|
||||||
// tech.giveTech("nail-bot")
|
// tech.giveTech("nail-bot")
|
||||||
// for (let i = 0; i < 15; i++) tech.giveTech("plasma jet")
|
// for (let i = 0; i < 15; i++) tech.giveTech("plasma jet")
|
||||||
|
|||||||
34
js/tech.js
34
js/tech.js
@@ -2092,6 +2092,23 @@ const tech = {
|
|||||||
tech.isAoESlow = false
|
tech.isAoESlow = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
name: "radioactive contamination",
|
||||||
|
description: "after a mob or shield <strong>dies</strong>,<br> leftover <strong class='color-p'>radiation</strong> <strong>spreads</strong> to a nearby mob",
|
||||||
|
isGunTech: true,
|
||||||
|
maxCount: 1,
|
||||||
|
count: 0,
|
||||||
|
allowed() {
|
||||||
|
return tech.haveGunCheck("flechettes") || tech.isNailPoison || tech.isWormholeDamage || tech.isNeutronBomb
|
||||||
|
},
|
||||||
|
requires: "radiation damage source",
|
||||||
|
effect() {
|
||||||
|
tech.isRadioactive = true
|
||||||
|
},
|
||||||
|
remove() {
|
||||||
|
tech.isRadioactive = false
|
||||||
|
}
|
||||||
|
},
|
||||||
{
|
{
|
||||||
name: "anti-shear topology",
|
name: "anti-shear topology",
|
||||||
description: "some <strong>bullets</strong> last <strong>30% longer</strong><br><em style = 'font-size: 83%'>drones, spores, missiles, foam, wave, neutron</em>",
|
description: "some <strong>bullets</strong> last <strong>30% longer</strong><br><em style = 'font-size: 83%'>drones, spores, missiles, foam, wave, neutron</em>",
|
||||||
@@ -2452,23 +2469,6 @@ const tech = {
|
|||||||
tech.isFlechetteExplode = false
|
tech.isFlechetteExplode = false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
|
||||||
name: "radioactive contamination",
|
|
||||||
description: "after a mob or shield <strong>dies</strong>,<br> leftover <strong class='color-p'>radiation</strong> <strong>spreads</strong> to a nearby mob",
|
|
||||||
isGunTech: true,
|
|
||||||
maxCount: 1,
|
|
||||||
count: 0,
|
|
||||||
allowed() {
|
|
||||||
return tech.haveGunCheck("flechettes") || tech.isNailPoison || tech.isWormholeDamage || tech.isNeutronBomb
|
|
||||||
},
|
|
||||||
requires: "radiation damage source",
|
|
||||||
effect() {
|
|
||||||
tech.isRadioactive = true
|
|
||||||
},
|
|
||||||
remove() {
|
|
||||||
tech.isRadioactive = false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
name: "piercing needles",
|
name: "piercing needles",
|
||||||
description: "<strong>needles</strong> penetrate <strong>mobs</strong> and <strong>blocks</strong><br>potentially hitting <strong>multiple</strong> targets",
|
description: "<strong>needles</strong> penetrate <strong>mobs</strong> and <strong>blocks</strong><br>potentially hitting <strong>multiple</strong> targets",
|
||||||
|
|||||||
Reference in New Issue
Block a user