custom run fixes. mod balance

This commit is contained in:
landgreen
2019-12-05 05:31:06 -08:00
parent 3b7e877103
commit 23f953f699
6 changed files with 170 additions and 155 deletions

View File

@@ -88,9 +88,9 @@
</div> --> </div> -->
<div id="build-grid"></div> <div id="build-grid"></div>
<!-- <button type="button" id="build-button">challenge run</button> --> <!-- <button type="button" id="build-button">challenge run</button> -->
<svg class="SVG-button" id="build-button" width="94" height="40"> <svg class="SVG-button" id="build-button" width="110" height="40">
<g stroke='none' fill='#333' stroke-width="2" font-size="28px" font-family="Arial, sans-serif"> <g stroke='none' fill='#333' stroke-width="2" font-size="28px" font-family="Arial, sans-serif">
<text x="10" y="30">builds</text> <text x="10" y="30">custom</text>
</g> </g>
</svg> </svg>

View File

@@ -67,7 +67,7 @@ const b = {
}, },
{ {
name: "auto-loading heuristics", name: "auto-loading heuristics",
description: "<strong>delay</strong> between your shots is 15% <strong>shorter</strong>", description: "your <strong>delay</strong> after firing is 15% <strong>shorter</strong>",
have: false, //1 have: false, //1
effect: () => { //good for guns with extra ammo: needles, M80, rapid fire, flak, super balls effect: () => { //good for guns with extra ammo: needles, M80, rapid fire, flak, super balls
b.modFireRate = 0.85 b.modFireRate = 0.85
@@ -123,11 +123,11 @@ const b = {
} }
}, },
{ {
name: "field siphon", name: "energy transfer",
description: "gain <strong class='color-f'>energy</strong> proportional to <strong class='color-d'>damage</strong> done", description: "gain <strong class='color-f'>energy</strong> proportional to <strong class='color-d'>damage</strong> done",
have: false, //8 have: false, //8
effect: () => { //good with laser, and all fields effect: () => { //good with laser, and all fields
b.modEnergySiphon = 0.15; b.modEnergySiphon = 0.2;
} }
}, },
{ {
@@ -135,7 +135,7 @@ const b = {
description: "<strong class='color-h'>heal</strong> proportional to <strong class='color-d'>damage</strong> done", description: "<strong class='color-h'>heal</strong> proportional to <strong class='color-d'>damage</strong> done",
have: false, //9 have: false, //9
effect: () => { //good with guns that overkill: one shot, grenade effect: () => { //good with guns that overkill: one shot, grenade
b.modHealthDrain = 0.01; b.modHealthDrain = 0.015;
} }
}, },
{ {
@@ -192,7 +192,7 @@ const b = {
}, },
{ {
name: "fracture analysis", name: "fracture analysis",
description: "<strong>6x</strong> physical <strong class='color-d'>damage</strong> to unaware enemies<br><em>enemies aware of you have a health bar</em>", description: "<strong>5x</strong> physical <strong class='color-d'>damage</strong> to unaware enemies<br><em>unaware enemies don't have a health bar</em>",
have: false, //16 have: false, //16
effect: () => { // good with high damage guns that strike from a distance: rail gun, drones, flechettes, spores, grenade, vacuum bomb effect: () => { // good with high damage guns that strike from a distance: rail gun, drones, flechettes, spores, grenade, vacuum bomb
b.modIsCrit = true; b.modIsCrit = true;
@@ -223,7 +223,7 @@ const b = {
} }
}, },
{ {
name: "monogamy", name: "entanglement",
description: "using your first gun reduces <strong class='color-d'>damage</strong> taken<br><em>scales by <strong>7%</strong> for each gun in your inventory</em>", description: "using your first gun reduces <strong class='color-d'>damage</strong> taken<br><em>scales by <strong>7%</strong> for each gun in your inventory</em>",
have: false, //20 have: false, //20
effect: () => { // good with long term planning effect: () => { // good with long term planning
@@ -251,7 +251,7 @@ const b = {
} }
} else { } else {
if (!b.guns[gun].have) b.inventory.push(gun); if (!b.guns[gun].have) b.inventory.push(gun);
b.activeGun = gun; if (b.activeGun === null) b.activeGun = gun //if no active gun switch to new gun
b.guns[gun].have = true; b.guns[gun].have = true;
b.guns[gun].ammo = b.guns[gun].ammoPack * ammoPacks; b.guns[gun].ammo = b.guns[gun].ammoPack * ammoPacks;
} }
@@ -705,20 +705,20 @@ const b = {
}, },
{ {
name: "rail gun", //1 name: "rail gun", //1
description: "magnetically launch a dense rod<br><strong>hold left mouse</strong> to charge and <strong>repel</strong> enemies", description: "electro-magnetically launch a dense rod<br><strong>hold</strong> left mouse to charge <strong>release</strong> to fire", //and <strong>repel</strong> enemies
ammo: 0, ammo: 0,
ammoPack: 11, ammoPack: 7,
have: false, have: false,
isStarterGun: false, isStarterGun: false,
fire() { fire() {
const me = bullet.length; const me = bullet.length;
bullet[me] = Bodies.rectangle(0, 0, 0.012 * b.modBulletSize, 0.0022 * b.modBulletSize, { bullet[me] = Bodies.rectangle(0, 0, 0.012 * b.modBulletSize, 0.0025 * b.modBulletSize, {
density: 0.002, //0.001 is normal density: 0.01, //0.001 is normal
//frictionAir: 0.01, //restitution: 0, //frictionAir: 0.01, //restitution: 0,
// angle: 0, // angle: 0,
// friction: 0.5, // friction: 0.5,
frictionAir: 0, frictionAir: 0,
dmg: 3 + b.modExtraDmg, //damage done in addition to the damage from momentum dmg: b.modExtraDmg, //damage done in addition to the damage from momentum
classType: "bullet", classType: "bullet",
collisionFilter: { collisionFilter: {
category: 0x000000, category: 0x000000,
@@ -735,7 +735,7 @@ const b = {
bullet[me].charge = 0; bullet[me].charge = 0;
bullet[me].do = function () { bullet[me].do = function () {
if (this.isCharging) { if (this.isCharging) {
if ((!game.mouseDown && this.charge > 0.5)) { //fire on mouse release if ((!game.mouseDown && this.charge > 0.4)) { //fire on mouse release
this.isCharging = false this.isCharging = false
mech.fireCDcycle = mech.cycle + 2; // set fire cool down mech.fireCDcycle = mech.cycle + 2; // set fire cool down
Matter.Body.scale(this, 8000, 8000) // show the bullet by scaling it up (don't judge me... I know this is a bad way to do it) Matter.Body.scale(this, 8000, 8000) // show the bullet by scaling it up (don't judge me... I know this is a bad way to do it)
@@ -746,7 +746,7 @@ const b = {
y: mech.pos.y y: mech.pos.y
}) })
Matter.Body.setAngle(this, mech.angle) Matter.Body.setAngle(this, mech.angle)
const speed = 85 const speed = 90
Matter.Body.setVelocity(this, { Matter.Body.setVelocity(this, {
x: mech.Vx / 2 + speed * this.charge * Math.cos(mech.angle), x: mech.Vx / 2 + speed * this.charge * Math.cos(mech.angle),
y: mech.Vy / 2 + speed * this.charge * Math.sin(mech.angle) y: mech.Vy / 2 + speed * this.charge * Math.sin(mech.angle)
@@ -758,24 +758,36 @@ const b = {
player.force.y -= KNOCK * Math.sin(mech.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps player.force.y -= KNOCK * Math.sin(mech.angle) * 0.35 //reduce knock back in vertical direction to stop super jumps
//push away blocks when firing //push away blocks when firing
const RANGE = 450 * this.charge let range = 450 * this.charge
for (let i = 0, len = body.length; i < len; ++i) { for (let i = 0, len = body.length; i < len; ++i) {
const SUB = Matter.Vector.sub(body[i].position, mech.pos) const SUB = Matter.Vector.sub(body[i].position, mech.pos)
const DISTANCE = Matter.Vector.magnitude(SUB) const DISTANCE = Matter.Vector.magnitude(SUB)
if (DISTANCE < RANGE) { if (DISTANCE < range) {
const DEPTH = Math.max(RANGE - DISTANCE, 100) const DEPTH = Math.max(range - DISTANCE, 100)
const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.005 * Math.sqrt(DEPTH) * Math.sqrt(body[i].mass)) const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.005 * Math.sqrt(DEPTH) * Math.sqrt(body[i].mass))
body[i].force.x += FORCE.x body[i].force.x += FORCE.x;
body[i].force.y += FORCE.y - body[i].mass * (game.g * 1.5); //kick up a bit to give them some arc body[i].force.y += FORCE.y - body[i].mass * (game.g * 1.5); //kick up a bit to give them some arc
} }
} }
for (let i = 0, len = mob.length; i < len; ++i) {
const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
const DISTANCE = Matter.Vector.magnitude(SUB)
if (DISTANCE < range) {
const DEPTH = Math.max(range - DISTANCE, 100)
const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.005 * Math.sqrt(DEPTH) * Math.sqrt(mob[i].mass))
mob[i].force.x += 1.5 * FORCE.x;
mob[i].force.y += 1.5 * FORCE.y;
}
}
//push mobs around player when firing //push mobs around player when firing
// range = 600 * this.charge
// for (let i = 0, len = mob.length; i < len; ++i) { // for (let i = 0, len = mob.length; i < len; ++i) {
// const SUB = Matter.Vector.sub(mob[i].position, mech.pos) // const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
// const DISTANCE = Matter.Vector.magnitude(SUB) // const DISTANCE = Matter.Vector.magnitude(SUB)
// if (DISTANCE < RANGE) { // if (DISTANCE < range) {
// const DEPTH = RANGE - DISTANCE // const DEPTH = range - DISTANCE
// const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.00000001 * DEPTH * DEPTH * DEPTH * Math.sqrt(mob[i].mass)) // const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.00000001 * DEPTH * DEPTH * DEPTH * Math.sqrt(mob[i].mass))
// mob[i].force.x += FORCE.x // mob[i].force.x += FORCE.x
// mob[i].force.y += FORCE.y // mob[i].force.y += FORCE.y
@@ -786,107 +798,109 @@ const b = {
if (mech.crouch) { if (mech.crouch) {
this.charge = this.charge * 0.97 + 0.03 // this.charge converges to 1 this.charge = this.charge * 0.97 + 0.03 // this.charge converges to 1
} else { } else {
this.charge = this.charge * 0.98 + 0.02 // this.charge converges to 1 this.charge = this.charge * 0.987 + 0.013 // this.charge converges to 1
} }
//gently push away mobs while charging //gently push away mobs while charging
const RANGE = 270 * this.charge // const RANGE = 270 * this.charge
for (let i = 0, len = mob.length; i < len; ++i) { // for (let i = 0, len = mob.length; i < len; ++i) {
const SUB = Matter.Vector.sub(mob[i].position, mech.pos) // const SUB = Matter.Vector.sub(mob[i].position, mech.pos)
const DISTANCE = Matter.Vector.magnitude(SUB) // const DISTANCE = Matter.Vector.magnitude(SUB)
// // if (DISTANCE < RANGE) {
// // Matter.Body.setVelocity(mob[i], Matter.Vector.rotate(mob[i].velocity, 0.1))
// // }
// // const DRAIN = 0.0002 //&& mech.fieldMeter > DRAIN
// if (DISTANCE < RANGE) { // if (DISTANCE < RANGE) {
// Matter.Body.setVelocity(mob[i], Matter.Vector.rotate(mob[i].velocity, 0.1)) // // mech.fieldMeter -= DRAIN + mech.fieldRegen;
// const DEPTH = RANGE - DISTANCE
// const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.000000001 * DEPTH * DEPTH * DEPTH * Math.sqrt(mob[i].mass))
// mob[i].force.x += FORCE.x
// mob[i].force.y += FORCE.y
// } // }
// const DRAIN = 0.0002 //&& mech.fieldMeter > DRAIN // }
if (DISTANCE < RANGE) {
// mech.fieldMeter -= DRAIN + mech.fieldRegen; //draw laser targeting
const DEPTH = RANGE - DISTANCE let best;
const FORCE = Matter.Vector.mult(Matter.Vector.normalise(SUB), 0.000000001 * DEPTH * DEPTH * DEPTH * Math.sqrt(mob[i].mass)) let range = 3000
mob[i].force.x += FORCE.x const dir = mech.angle
mob[i].force.y += FORCE.y const path = [{
x: mech.pos.x + 20 * Math.cos(dir),
y: mech.pos.y + 20 * Math.sin(dir)
},
{
x: mech.pos.x + range * Math.cos(dir),
y: mech.pos.y + range * Math.sin(dir)
}
];
const vertexCollision = function (v1, v1End, domain) {
for (let i = 0; i < domain.length; ++i) {
let vertices = domain[i].vertices;
const len = vertices.length - 1;
for (let j = 0; j < len; j++) {
results = game.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]);
if (results.onLine1 && results.onLine2) {
const dx = v1.x - results.x;
const dy = v1.y - results.y;
const dist2 = dx * dx + dy * dy;
if (dist2 < best.dist2) {
best = {
x: results.x,
y: results.y,
dist2: dist2,
who: domain[i],
v1: vertices[j],
v2: vertices[j + 1]
};
} }
} }
}
results = game.checkLineIntersection(v1, v1End, vertices[0], vertices[len]);
if (results.onLine1 && results.onLine2) {
const dx = v1.x - results.x;
const dy = v1.y - results.y;
const dist2 = dx * dx + dy * dy;
if (dist2 < best.dist2) {
best = {
x: results.x,
y: results.y,
dist2: dist2,
who: domain[i],
v1: vertices[0],
v2: vertices[len]
};
}
}
}
};
// //draw laser targeting //check for collisions
// let best; best = {
// let range = 3000 x: null,
// const dir = mech.angle y: null,
// const path = [{ dist2: Infinity,
// x: mech.pos.x + 20 * Math.cos(dir), who: null,
// y: mech.pos.y + 20 * Math.sin(dir) v1: null,
// }, v2: null
// { };
// x: mech.pos.x + range * Math.cos(dir), vertexCollision(path[0], path[1], mob);
// y: mech.pos.y + range * Math.sin(dir) vertexCollision(path[0], path[1], map);
// } vertexCollision(path[0], path[1], body);
// ]; if (best.dist2 != Infinity) { //if hitting something
// const vertexCollision = function (v1, v1End, domain) { path[path.length - 1] = {
// for (let i = 0; i < domain.length; ++i) { x: best.x,
// let vertices = domain[i].vertices; y: best.y
// const len = vertices.length - 1; };
// for (let j = 0; j < len; j++) { }
// results = game.checkLineIntersection(v1, v1End, vertices[j], vertices[j + 1]);
// if (results.onLine1 && results.onLine2) {
// const dx = v1.x - results.x;
// const dy = v1.y - results.y;
// const dist2 = dx * dx + dy * dy;
// if (dist2 < best.dist2) {
// best = {
// x: results.x,
// y: results.y,
// dist2: dist2,
// who: domain[i],
// v1: vertices[j],
// v2: vertices[j + 1]
// };
// }
// }
// }
// results = game.checkLineIntersection(v1, v1End, vertices[0], vertices[len]);
// if (results.onLine1 && results.onLine2) {
// const dx = v1.x - results.x;
// const dy = v1.y - results.y;
// const dist2 = dx * dx + dy * dy;
// if (dist2 < best.dist2) {
// best = {
// x: results.x,
// y: results.y,
// dist2: dist2,
// who: domain[i],
// v1: vertices[0],
// v2: vertices[len]
// };
// }
// }
// }
// };
// //check for collisions //draw laser beam
// best = { ctx.beginPath();
// x: null, ctx.moveTo(path[0].x, path[0].y);
// y: null, ctx.lineTo(path[1].x, path[1].y);
// dist2: Infinity, ctx.strokeStyle = `rgba(100,0,180,0.7)`;
// who: null, ctx.lineWidth = this.charge * 1
// v1: null, ctx.setLineDash([10, 20]);
// v2: null ctx.stroke();
// }; ctx.setLineDash([0, 0]);
// vertexCollision(path[0], path[1], mob);
// vertexCollision(path[0], path[1], map);
// vertexCollision(path[0], path[1], body);
// if (best.dist2 != Infinity) { //if hitting something
// path[path.length - 1] = {
// x: best.x,
// y: best.y
// };
// }
// //draw laser beam
// ctx.beginPath();
// ctx.moveTo(path[0].x, path[0].y);
// ctx.lineTo(path[1].x, path[1].y);
// ctx.strokeStyle = `rgba(50,0,100,0.1)`;
// ctx.lineWidth = this.charge * 3
// ctx.stroke();
//draw magnetic field //draw magnetic field
const X = mech.pos.x const X = mech.pos.x

View File

@@ -179,7 +179,7 @@ function mobCollisionChecks(event) {
if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) { if (obj.classType === "bullet" && obj.speed > obj.minDmgSpeed) {
// const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity))); // const dmg = b.dmgScale * (obj.dmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity)));
let dmg = b.dmgScale * (obj.dmg + b.modExtraDmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity))) let dmg = b.dmgScale * (obj.dmg + b.modExtraDmg + 0.15 * obj.mass * Matter.Vector.magnitude(Matter.Vector.sub(mob[k].velocity, obj.velocity)))
if (b.modIsCrit && !mob[k].seePlayer.recall) dmg *= 6 if (b.modIsCrit && !mob[k].seePlayer.recall) dmg *= 5
mob[k].foundPlayer(); mob[k].foundPlayer();
mob[k].damage(dmg); mob[k].damage(dmg);
obj.onDmg(); //some bullets do actions when they hits things, like despawn obj.onDmg(); //some bullets do actions when they hits things, like despawn
@@ -187,7 +187,8 @@ function mobCollisionChecks(event) {
//add dmg to draw queue //add dmg to draw queue
x: pairs[i].activeContacts[0].vertex.x, x: pairs[i].activeContacts[0].vertex.x,
y: pairs[i].activeContacts[0].vertex.y, y: pairs[i].activeContacts[0].vertex.y,
radius: Math.sqrt(dmg) * 40, // radius: Math.sqrt(dmg) * 40,
radius: Math.log(2 * dmg + 1.1) * 40,
color: game.playerDmgColor, color: game.playerDmgColor,
time: game.drawTime time: game.drawTime
}); });

View File

@@ -71,7 +71,7 @@ mod power ups ideas
add a freeze add a freeze
give mobs more animal-like behaviors give mobs more animal-like behaviors
like rainworld like rain world
give mobs something to do when they don't see player give mobs something to do when they don't see player
explore map explore map
eat power ups eat power ups
@@ -180,19 +180,16 @@ document.getElementById("build-button").addEventListener("click", () => {
build.list = [] build.list = []
// let text = '<p>choose up to 5 powers<br> <button type="button" id="build-begin-button" onclick="build.startBuildRun()">Begin Run</button></p>' // let text = '<p>choose up to 5 powers<br> <button type="button" id="build-begin-button" onclick="build.startBuildRun()">Begin Run</button></p>'
let text = let text =
`<div style=" display: flex; `<div style="display: flex; justify-content: center; align-items: center;">
justify-content: center; <svg class="SVG-button" onclick="build.startBuildRun()" width="90" height="40">
align-items: center;"> <g stroke='none' fill='#333' stroke-width="2" font-size="30px" font-family="Ariel, sans-serif">
<p>choose up to 5 powers</p> <text x="15" y="31">start</text>
</div>
<div style=" display: flex;
justify-content: center;
align-items: center;">
<svg class="SVG-button" onclick="build.startBuildRun()" width="74" height="36">
<g stroke='none' fill='#333' stroke-width="2" font-size="28px" font-family="Ariel, sans-serif">
<text x="10" y="28">start</text>
</g> </g>
</svg></div>` </svg>
</div>
<div class="build-grid-module" style="font-size: 19px; line-height: 110%;">
Choose up to five power ups. Once you start, only health and ammo will drop, so pick carefully.
</div>`
for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) { for (let i = 1, len = mech.fieldUpgrades.length; i < len; i++) {
text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'field')" ><div class="circle-grid field"></div> &nbsp; <strong style='font-size:1.3em;'>${mech.fieldUpgrades[i].name}</strong><br> ${mech.fieldUpgrades[i].description}</div>` text += `<div class="build-grid-module" onclick="build.choosePowerUp(this,${i},'field')" ><div class="circle-grid field"></div> &nbsp; <strong style='font-size:1.3em;'>${mech.fieldUpgrades[i].name}</strong><br> ${mech.fieldUpgrades[i].description}</div>`
} }
@@ -248,7 +245,7 @@ document.body.addEventListener("mousemove", (e) => {
document.body.addEventListener("mouseup", (e) => { document.body.addEventListener("mouseup", (e) => {
// game.buildingUp(e); //uncomment when building levels // game.buildingUp(e); //uncomment when building levels
game.mouseDown = false; // game.mouseDown = false;
// console.log(e) // console.log(e)
if (e.which === 3) { if (e.which === 3) {
game.mouseDownRight = false; game.mouseDownRight = false;

View File

@@ -15,7 +15,7 @@ const level = {
if (level.levelsCleared === 0) { if (level.levelsCleared === 0) {
// game.difficulty = 6; //for testing to simulate possible mobs spawns // game.difficulty = 6; //for testing to simulate possible mobs spawns
// level.startBuildRun(5) // level.startBuildRun(5)
// b.giveGuns(11) // b.giveGuns(1)
// mech.fieldUpgrades[2].effect(); // mech.fieldUpgrades[2].effect();
// b.giveMod(13) // b.giveMod(13)
// spawn.pickList = ["ghoster", "ghoster"] // spawn.pickList = ["ghoster", "ghoster"]

View File

@@ -29,20 +29,20 @@ const mobs = {
ctx.stroke(); ctx.stroke();
} }
}, },
alert(range) { // alert(range) {
range = range * range; // range = range * range;
for (let i = 0; i < mob.length; i++) { // for (let i = 0; i < mob.length; i++) {
if (mob[i].distanceToPlayer2() < range) mob[i].locatePlayer(); // if (mob[i].distanceToPlayer2() < range) mob[i].locatePlayer();
} // }
}, // },
startle(amount) { // startle(amount) {
for (let i = 0; i < mob.length; i++) { // for (let i = 0; i < mob.length; i++) {
if (!mob[i].seePlayer.yes) { // if (!mob[i].seePlayer.yes) {
mob[i].force.x += amount * mob[i].mass * (Math.random() - 0.5); // mob[i].force.x += amount * mob[i].mass * (Math.random() - 0.5);
mob[i].force.y += amount * mob[i].mass * (Math.random() - 0.5); // mob[i].force.y += amount * mob[i].mass * (Math.random() - 0.5);
} // }
} // }
}, // },
//********************************************************************************************** //**********************************************************************************************
//********************************************************************************************** //**********************************************************************************************
spawn(xPos, yPos, sides, radius, color) { spawn(xPos, yPos, sides, radius, color) {
@@ -898,16 +898,19 @@ const mobs = {
} }
}, },
damage(dmg) { damage(dmg) {
console.log(dmg, "before")
dmg /= Math.sqrt(this.mass)
console.log(dmg, "after")
if (b.isModLowHealthDmg) dmg *= (3 / (2 + mech.health)) //up to 50% dmg at zero player health if (b.isModLowHealthDmg) dmg *= (3 / (2 + mech.health)) //up to 50% dmg at zero player health
if (b.isModFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(1000, Math.min(3500, this.distanceToPlayer())) - 1000) * 0.01 //up to 50% dmg at max range of 3500 if (b.isModFarAwayDmg) dmg *= 1 + Math.sqrt(Math.max(1000, Math.min(3500, this.distanceToPlayer())) - 1000) * 0.01 //up to 50% dmg at max range of 3500
this.health -= dmg / Math.sqrt(this.mass);
//this.fill = this.color + this.health + ')';
if (this.health < 0.1) this.death();
this.onDamage(this); //custom damage effects
if (dmg !== Infinity) { if (dmg !== Infinity) {
if (b.modEnergySiphon) mech.fieldMeter += dmg * b.modEnergySiphon if (b.modEnergySiphon) mech.fieldMeter += Math.min(this.health, dmg) * b.modEnergySiphon
if (b.modHealthDrain) mech.addHealth(dmg * b.modHealthDrain) if (b.modHealthDrain) mech.addHealth(Math.min(this.health, dmg) * b.modHealthDrain)
} }
this.health -= dmg
//this.fill = this.color + this.health + ')';
if (this.health < 0.01) this.death();
this.onDamage(this); //custom damage effects
}, },
onDamage() { onDamage() {
// a placeholder for custom effects on mob damage // a placeholder for custom effects on mob damage
@@ -996,7 +999,7 @@ const mobs = {
mob.splice(i, 1); mob.splice(i, 1);
} }
}); });
mob[i].alertRange2 = Math.pow(mob[i].radius * 3 + 200, 2); mob[i].alertRange2 = Math.pow(mob[i].radius * 3.5 + 550, 2);
World.add(engine.world, mob[i]); //add to world World.add(engine.world, mob[i]); //add to world
} }
}; };