ice IX energy

laser bots now use the same laser code as the player
mod: thermoelectric effect - ice IX bullets give you 7% energy after they collides with mobs
This commit is contained in:
landgreen
2020-10-04 18:16:01 -07:00
parent b1f4109827
commit 7947e69d4d
6 changed files with 144 additions and 86 deletions

View File

@@ -379,7 +379,10 @@ const b = {
laser(where = { laser(where = {
x: mech.pos.x + 20 * Math.cos(mech.angle), x: mech.pos.x + 20 * Math.cos(mech.angle),
y: mech.pos.y + 20 * Math.sin(mech.angle) y: mech.pos.y + 20 * Math.sin(mech.angle)
}, angle = mech.angle, dmg = mod.laserDamage, reflections = mod.laserReflections, isThickBeam = false) { }, whereEnd = {
x: where.x + 3000 * Math.cos(mech.angle),
y: where.y + 3000 * Math.sin(mech.angle)
}, dmg = mod.laserDamage, reflections = mod.laserReflections, isThickBeam = false) {
const reflectivity = 1 - 1 / (reflections * 1.5) const reflectivity = 1 - 1 / (reflections * 1.5)
let damage = b.dmgScale * dmg let damage = b.dmgScale * dmg
let best = { let best = {
@@ -391,14 +394,13 @@ const b = {
v2: null v2: null
}; };
const color = "#f00"; const color = "#f00";
const range = 3000;
const path = [{ const path = [{
x: where.x, x: where.x,
y: where.y y: where.y
}, },
{ {
x: where.x + range * Math.cos(angle), x: whereEnd.x,
y: where.y + range * Math.sin(angle) y: whereEnd.y
} }
]; ];
const vertexCollision = function (v1, v1End, domain) { const vertexCollision = function (v1, v1End, domain) {
@@ -470,7 +472,7 @@ const b = {
const d = Vector.sub(path[path.length - 1], path[path.length - 2]); const d = Vector.sub(path[path.length - 1], path[path.length - 2]);
const nn = Vector.mult(n, 2 * Vector.dot(d, n)); const nn = Vector.mult(n, 2 * Vector.dot(d, n));
const r = Vector.normalise(Vector.sub(d, nn)); const r = Vector.normalise(Vector.sub(d, nn));
path[path.length] = Vector.add(Vector.mult(r, range), path[path.length - 1]); path[path.length] = Vector.add(Vector.mult(r, 3000), path[path.length - 1]);
}; };
checkForCollisions(); checkForCollisions();
@@ -802,6 +804,7 @@ const b = {
mobs.statusSlow(who, 60) mobs.statusSlow(who, 60)
this.endCycle = game.cycle this.endCycle = game.cycle
if (mod.isHeavyWater) mobs.statusDoT(who, 0.1, 300) if (mod.isHeavyWater) mobs.statusDoT(who, 0.1, 300)
if (mod.iceEnergy && !who.shield) mech.energy += mod.iceEnergy //&& mech.energy < mech.maxEnergy
}, },
onEnd() {}, onEnd() {},
do() { do() {
@@ -1323,7 +1326,7 @@ const b = {
minDmgSpeed: 2, minDmgSpeed: 2,
lookFrequency: 40 + Math.floor(7 * Math.random()), lookFrequency: 40 + Math.floor(7 * Math.random()),
acceleration: 0.0015 * (1 + 0.3 * Math.random()), acceleration: 0.0015 * (1 + 0.3 * Math.random()),
range: 500 * (1 + 0.2 * Math.random()) + 150 * mod.isLaserBotUpgrade, range: 700 * (1 + 0.1 * Math.random()) + 250 * mod.isLaserBotUpgrade,
followRange: 150 + Math.floor(30 * Math.random()), followRange: 150 + Math.floor(30 * Math.random()),
offPlayer: { offPlayer: {
x: 0, x: 0,
@@ -1351,8 +1354,9 @@ const b = {
y: this.velocity.y * 0.95 y: this.velocity.y * 0.95
}); });
//find targets //find targets
if (!(game.cycle % this.lookFrequency) && !mech.isCloak) { if (!(game.cycle % this.lookFrequency)) {
this.lockedOn = null; this.lockedOn = null;
if (!mech.isCloak) {
let closeDist = this.range; let closeDist = this.range;
for (let i = 0, len = mob.length; i < len; ++i) { for (let i = 0, len = mob.length; i < len; ++i) {
const DIST = Vector.magnitude(Vector.sub(this.vertices[0], mob[i].position)); const DIST = Vector.magnitude(Vector.sub(this.vertices[0], mob[i].position));
@@ -1364,6 +1368,7 @@ const b = {
this.lockedOn = mob[i] this.lockedOn = mob[i]
} }
} }
}
//randomize position relative to player //randomize position relative to player
if (Math.random() < 0.15) { if (Math.random() < 0.15) {
this.offPlayer = { this.offPlayer = {
@@ -1374,42 +1379,46 @@ const b = {
} }
//hit target with laser //hit target with laser
if (this.lockedOn && this.lockedOn.alive && mech.energy > 0.15) { if (this.lockedOn && this.lockedOn.alive && mech.energy > 0.15) {
mech.energy -= 0.0014 * mod.isLaserDiode mech.energy -= 0.0012 * mod.isLaserDiode
//make sure you can still see vertex // const sub = Vector.sub(this.lockedOn.position, this.vertices[0])
const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position)); // const angle = Math.atan2(sub.y, sub.x);
if (DIST - this.lockedOn.radius < this.range + 150 && b.laser(this.vertices[0], this.lockedOn.position, b.dmgScale * (0.06 + 0.08 * this.isUpgraded))
Matter.Query.ray(map, this.vertices[0], this.lockedOn.position).length === 0 &&
Matter.Query.ray(body, this.vertices[0], this.lockedOn.position).length === 0) {
//move towards the target
this.force = Vector.add(this.force, Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), 0.0013))
//find the closest vertex
let bestVertexDistance = Infinity
let bestVertex = null
for (let i = 0; i < this.lockedOn.vertices.length; i++) {
const dist = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.vertices[i]));
if (dist < bestVertexDistance) {
bestVertex = i
bestVertexDistance = dist
}
}
const dmg = b.dmgScale * (0.06 + 0.08 * this.isUpgraded);
this.lockedOn.damage(dmg);
this.lockedOn.locatePlayer();
ctx.beginPath(); //draw laser // //make sure you can still see vertex
ctx.moveTo(this.vertices[0].x, this.vertices[0].y); // const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position));
ctx.lineTo(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y); // if (DIST - this.lockedOn.radius < this.range + 150 &&
ctx.strokeStyle = "#f00"; // Matter.Query.ray(map, this.vertices[0], this.lockedOn.position).length === 0 &&
ctx.lineWidth = "2" // Matter.Query.ray(body, this.vertices[0], this.lockedOn.position).length === 0) {
ctx.lineDashOffset = 300 * Math.random() // //move towards the target
ctx.setLineDash([50 + 100 * Math.random(), 100 * Math.random()]); // this.force = Vector.add(this.force, Vector.mult(Vector.normalise(Vector.sub(this.lockedOn.position, this.position)), 0.0013))
ctx.stroke(); // //find the closest vertex
ctx.setLineDash([0, 0]); // let bestVertexDistance = Infinity
ctx.beginPath(); // let bestVertex = null
ctx.arc(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y, Math.sqrt(dmg) * 100, 0, 2 * Math.PI); // for (let i = 0; i < this.lockedOn.vertices.length; i++) {
ctx.fillStyle = "#f00"; // const dist = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.vertices[i]));
ctx.fill(); // if (dist < bestVertexDistance) {
} // bestVertex = i
// bestVertexDistance = dist
// }
// }
// const dmg = b.dmgScale * (0.06 + 0.08 * this.isUpgraded);
// this.lockedOn.damage(dmg);
// this.lockedOn.locatePlayer();
// ctx.beginPath(); //draw laser
// ctx.moveTo(this.vertices[0].x, this.vertices[0].y);
// ctx.lineTo(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y);
// ctx.strokeStyle = "#f00";
// ctx.lineWidth = "2"
// ctx.lineDashOffset = 300 * Math.random()
// ctx.setLineDash([50 + 100 * Math.random(), 100 * Math.random()]);
// ctx.stroke();
// ctx.setLineDash([0, 0]);
// ctx.beginPath();
// ctx.arc(this.lockedOn.vertices[bestVertex].x, this.lockedOn.vertices[bestVertex].y, Math.sqrt(dmg) * 100, 0, 2 * Math.PI);
// ctx.fillStyle = "#f00";
// ctx.fill();
// }
} }
} }
}) })
@@ -3231,25 +3240,31 @@ const b = {
if (mod.isWideLaser) { if (mod.isWideLaser) {
const off = 8 const off = 8
const dmg = 0.4 * mod.laserDamage // 5 * 0.4 = 200% more damage const dmg = 0.4 * mod.laserDamage // 5 * 0.4 = 200% more damage
b.laser({ const where = {
x: mech.pos.x + 20 * Math.cos(mech.angle), x: mech.pos.x + 20 * Math.cos(mech.angle),
y: mech.pos.y + 20 * Math.sin(mech.angle) y: mech.pos.y + 20 * Math.sin(mech.angle)
}, mech.angle, dmg, 0, true) }
b.laser(where, {
x: where.x + 3000 * Math.cos(mech.angle),
y: where.y + 3000 * Math.sin(mech.angle)
}, dmg, 0, true)
for (let i = 1; i < 3; i++) { for (let i = 1; i < 3; i++) {
b.laser(Vector.add({ let whereOff = Vector.add(where, {
x: mech.pos.x + 20 * Math.cos(mech.angle),
y: mech.pos.y + 20 * Math.sin(mech.angle)
}, {
x: i * off * Math.cos(mech.angle + Math.PI / 2), x: i * off * Math.cos(mech.angle + Math.PI / 2),
y: i * off * Math.sin(mech.angle + Math.PI / 2) y: i * off * Math.sin(mech.angle + Math.PI / 2)
}), mech.angle, dmg, 0, true) })
b.laser(Vector.add({ b.laser(whereOff, {
x: mech.pos.x + 20 * Math.cos(mech.angle), x: whereOff.x + 3000 * Math.cos(mech.angle),
y: mech.pos.y + 20 * Math.sin(mech.angle) y: whereOff.y + 3000 * Math.sin(mech.angle)
}, { }, dmg, 0, true)
whereOff = Vector.add(where, {
x: i * off * Math.cos(mech.angle - Math.PI / 2), x: i * off * Math.cos(mech.angle - Math.PI / 2),
y: i * off * Math.sin(mech.angle - Math.PI / 2) y: i * off * Math.sin(mech.angle - Math.PI / 2)
}), mech.angle, dmg, 0, true) })
b.laser(whereOff, {
x: whereOff.x + 3000 * Math.cos(mech.angle),
y: whereOff.y + 3000 * Math.sin(mech.angle)
}, dmg, 0, true)
} }
} else if (mod.beamSplitter) { } else if (mod.beamSplitter) {
let dmg = mod.laserDamage * 0.9 let dmg = mod.laserDamage * 0.9
@@ -3257,10 +3272,19 @@ const b = {
x: mech.pos.x + 20 * Math.cos(mech.angle), x: mech.pos.x + 20 * Math.cos(mech.angle),
y: mech.pos.y + 20 * Math.sin(mech.angle) y: mech.pos.y + 20 * Math.sin(mech.angle)
} }
b.laser(where, mech.angle, dmg) b.laser(where, {
x: where.x + 3000 * Math.cos(mech.angle),
y: where.y + 3000 * Math.sin(mech.angle)
}, dmg)
for (let i = 1; i < 1 + mod.beamSplitter; i++) { for (let i = 1; i < 1 + mod.beamSplitter; i++) {
b.laser(where, mech.angle + i * 0.2, dmg) b.laser(where, {
b.laser(where, mech.angle - i * 0.2, dmg) x: where.x + 3000 * Math.cos(mech.angle + i * 0.2),
y: where.y + 3000 * Math.sin(mech.angle + i * 0.2)
}, dmg)
b.laser(where, {
x: where.x + 3000 * Math.cos(mech.angle - i * 0.2),
y: where.y + 3000 * Math.sin(mech.angle - i * 0.2)
}, dmg)
dmg *= 0.9 dmg *= 0.9
} }
} else { } else {

View File

@@ -15,10 +15,10 @@ const level = {
// game.zoomScale = 1000; // game.zoomScale = 1000;
// game.setZoom(); // game.setZoom();
// mech.isCloak = true; // mech.isCloak = true;
// mech.setField("metamaterial cloaking") // mech.setField("perfect diamagnetism")
// b.giveGuns("laser") // b.giveGuns("laser")
// for (let i = 0; i < 1; i++) { // for (let i = 0; i < 10; i++) {
// mod.giveMod("diffuse beam"); // mod.giveMod("laser-bot");
// } // }
// mod.giveMod("orbit-bot upgrade") // mod.giveMod("orbit-bot upgrade")
@@ -118,7 +118,7 @@ const level = {
spawn.mapRect(-950, -1800, 8200, 800); //roof spawn.mapRect(-950, -1800, 8200, 800); //roof
spawn.mapRect(-250, -700, 1000, 900); // shelf spawn.mapRect(-250, -700, 1000, 900); // shelf
spawn.mapRect(-250, -1200, 1000, 250); // shelf roof spawn.mapRect(-250, -1200, 1000, 250); // shelf roof
powerUps.spawnStartingPowerUps(600, -800); // powerUps.spawnStartingPowerUps(600, -800);
powerUps.spawn(550, -800, "reroll", false); powerUps.spawn(550, -800, "reroll", false);
function blockDoor(x, y, blockSize = 58) { function blockDoor(x, y, blockSize = 58) {
@@ -150,7 +150,7 @@ const level = {
// spawn.sniper(1800, -120) // spawn.sniper(1800, -120)
// spawn.sniper(2200, -120) // spawn.sniper(2200, -120)
// spawn.cellBossCulture(1600, -500) // spawn.cellBossCulture(1600, -500)
spawn.starter(1600, -500, 160) spawn.starter(1600, -500)
// spawn.powerUpBoss(1600, -500) // spawn.powerUpBoss(1600, -500)
// spawn.shield(mob[mob.length - 1], 1200, -500, 1); // spawn.shield(mob[mob.length - 1], 1200, -500, 1);

View File

@@ -603,7 +603,7 @@ const mod = {
}, },
{ {
name: "laser-bot", name: "laser-bot",
description: "a bot <strong>defends</strong> the space around you<br>uses a <strong>short range</strong> laser that drains <strong class='color-f'>energy</strong>", description: "a bot uses <strong class='color-f'>energy</strong> to emit a <strong>laser</strong><br>targeting nearby mobs",
maxCount: 9, maxCount: 9,
count: 0, count: 0,
allowed() { allowed() {
@@ -816,9 +816,9 @@ const mod = {
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {
return true return mod.totalBots() > 1 || mod.haveGunCheck("drone") || mod.haveGunCheck("mine") || mod.haveGunCheck("spores") || mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing"
}, },
requires: "", requires: "drones, spores, mines, or bots",
effect() { effect() {
mod.isNoFireDefense = true mod.isNoFireDefense = true
}, },
@@ -2208,7 +2208,7 @@ const mod = {
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {
return mod.haveGunCheck("ice IX") || (mech.fieldUpgrades[mech.fieldMode].name === "nano-scale manufacturing" && mod.isIceField) return mod.haveGunCheck("ice IX") || mod.isIceField
}, },
requires: "ice IX", requires: "ice IX",
effect() { effect() {
@@ -2218,6 +2218,22 @@ const mod = {
mod.isHeavyWater = false; mod.isHeavyWater = false;
} }
}, },
{
name: "thermoelectric effect",
description: "<strong>ice IX</strong> bullets give you <strong>7%</strong> <strong class='color-f'>energy</strong><br>after they <strong>collide</strong> with mobs",
maxCount: 9,
count: 0,
allowed() {
return mod.haveGunCheck("ice IX") || mod.isIceField
},
requires: "ice IX",
effect() {
mod.iceEnergy += 0.07
},
remove() {
mod.iceEnergy = 0;
}
},
{ {
name: "necrophoresis", name: "necrophoresis",
description: "<strong>foam</strong> bullets grow and split into 3 <strong>copies</strong><br> when the mob they are stuck to <strong>dies</strong>", description: "<strong>foam</strong> bullets grow and split into 3 <strong>copies</strong><br> when the mob they are stuck to <strong>dies</strong>",
@@ -2354,7 +2370,7 @@ const mod = {
}, },
{ {
name: "beam splitter", name: "beam splitter",
description: `your <strong>laser</strong> is <strong>split</strong> into diverging beams<br>decrease <strong class='color-d'>damage</strong> by <strong>10%</strong>`, description: `your <strong>laser</strong> gains <strong>2 diverging</strong> beams<br>decrease laser <strong class='color-d'>damage</strong> by <strong>10%</strong>`,
maxCount: 9, maxCount: 9,
count: 0, count: 0,
allowed() { allowed() {
@@ -2370,7 +2386,7 @@ const mod = {
}, },
{ {
name: "diffuse beam", name: "diffuse beam",
description: "<strong>laser</strong> beam is <strong>wider</strong> and doesn't <strong>reflect</strong><br>increase <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 laser <strong class='color-d'>damage</strong> by <strong>100%</strong>",
maxCount: 1, maxCount: 1,
count: 0, count: 0,
allowed() { allowed() {
@@ -2989,5 +3005,6 @@ const mod = {
isNoFireDefense: null, isNoFireDefense: null,
isNoFireDamage: null, isNoFireDamage: null,
duplicateChance: null, duplicateChance: null,
beamSplitter: null beamSplitter: null,
iceEnergy: null
} }

View File

@@ -1303,6 +1303,20 @@ const mech = {
// mech.fieldArc = 0.3; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) // mech.fieldArc = 0.3; //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)
// mech.calculateFieldThreshold(); // mech.calculateFieldThreshold();
mech.hold = function () { mech.hold = function () {
//cap mob speed based on distance
for (let i = 0; i < mob.length; i++) {
const distance = Vector.magnitude(Vector.sub(mech.pos, mob[i].position))
const range = 1000
if (distance < range) {
const cap = Math.max(0.01 * distance, 4)
if (mob[i].speed > cap) {
Matter.Body.setVelocity(mob[i], Vector.mult(Vector.normalise(mob[i].velocity), cap)); //set velocity to cap, but keep the direction
}
}
}
const wave = Math.sin(mech.cycle * 0.022); const wave = Math.sin(mech.cycle * 0.022);
mech.fieldRange = 170 + 12 * wave mech.fieldRange = 170 + 12 * wave
mech.fieldArc = 0.33 + 0.045 * wave //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob) mech.fieldArc = 0.33 + 0.045 * wave //run calculateFieldThreshold after setting fieldArc, used for powerUp grab and mobPush with lookingAt(mob)

View File

@@ -152,8 +152,7 @@ const powerUps = {
//give ammo to all guns in inventory //give ammo to all guns in inventory
if (mod.isAmmoForGun) { if (mod.isAmmoForGun) {
const target = b.guns[b.activeGun] const target = b.guns[b.activeGun]
target.ammo += Math.ceil(Math.random() * target.ammoPack) target.ammo += Math.ceil(Math.random() * target.ammoPack) + Math.ceil(Math.random() * target.ammoPack)
target.ammo += Math.ceil(Math.random() * target.ammoPack)
} else { } else {
for (let i = 0, len = b.inventory.length; i < len; i++) { for (let i = 0, len = b.inventory.length; i < len; i++) {
const target = b.guns[b.inventory[i]] const target = b.guns[b.inventory[i]]

View File

@@ -1,15 +1,19 @@
laser mod: beam splitter - laser is split into diverging beams, but does 10% less damage laser bots now use the same laser code as the player
mod: thermoelectric effect - ice IX bullets give you 7% energy after they collides with mobs
************** TODO - n-gon ************** ************** TODO - n-gon **************
laser mod, increase damage, but ass some angular spread to 5 laser beam a gun that gives back energy
require diffuse if your energy is below 90% your drones stay near you and give energy regen
use the b.laser() function buff neutron bomb?
less fire CD?
mod set a max speed cap based on distance from player while field is active mod set a max speed cap based on distance from player while field is active
mod for a field, or bot? name: eddy current brake
name: something about speed of light being the top speed who runs the code?
new bot
perfect diamagnetism
vacuum bomb applies status effect to mobs that makes blocks attracted to them vacuum bomb applies status effect to mobs that makes blocks attracted to them