diff --git a/js/bullet.js b/js/bullet.js
index 852aa64..b5ebfff 100644
--- a/js/bullet.js
+++ b/js/bullet.js
@@ -928,17 +928,22 @@ const b = {
deathCycles: 110 + RADIUS * 5,
isImproved: false,
beforeDmg(who) {
- //move away from target after hitting
- const unit = Vector.mult(Vector.normalise(Vector.sub(this.position, who.position)), -20)
- Matter.Body.setVelocity(this, {
- x: unit.x,
- y: unit.y
- });
+ if (mod.isIncendiary) {
+ b.explosion(this.position, 120 + (Math.random() - 0.5) * 60); //makes bullet do explosive damage at end
+ this.endCycle = 0
+ } else {
+ //move away from target after hitting
+ const unit = Vector.mult(Vector.normalise(Vector.sub(this.position, who.position)), -20)
+ Matter.Body.setVelocity(this, {
+ x: unit.x,
+ y: unit.y
+ });
- this.lockedOn = null
- if (this.endCycle > game.cycle + this.deathCycles) {
- this.endCycle -= 60
- if (game.cycle + this.deathCycles > this.endCycle) this.endCycle = game.cycle + this.deathCycles
+ this.lockedOn = null
+ if (this.endCycle > game.cycle + this.deathCycles) {
+ this.endCycle -= 60
+ if (game.cycle + this.deathCycles > this.endCycle) this.endCycle = game.cycle + this.deathCycles
+ }
}
},
onEnd() {},
@@ -1377,6 +1382,7 @@ const b = {
dmg: 0, // 0.14 //damage done in addition to the damage from momentum
minDmgSpeed: 2,
lookFrequency: 40 + Math.floor(7 * Math.random()),
+ drainThreshold: mod.isEnergyHealth ? 0.5 : 0.15,
acceleration: 0.0015 * (1 + 0.3 * Math.random()),
range: 700 * (1 + 0.1 * Math.random()) + 250 * mod.isLaserBotUpgrade,
followRange: 150 + Math.floor(30 * Math.random()),
@@ -1430,47 +1436,9 @@ const b = {
}
}
//hit target with laser
- if (this.lockedOn && this.lockedOn.alive && mech.energy > 0.15) {
+ if (this.lockedOn && this.lockedOn.alive && mech.energy > this.drainThreshold) {
mech.energy -= 0.0012 * mod.isLaserDiode
- // const sub = Vector.sub(this.lockedOn.position, this.vertices[0])
- // const angle = Math.atan2(sub.y, sub.x);
b.laser(this.vertices[0], this.lockedOn.position, b.dmgScale * (0.06 + 0.1 * this.isUpgraded))
-
- // //make sure you can still see vertex
- // const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position));
- // if (DIST - this.lockedOn.radius < this.range + 150 &&
- // 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
- // 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();
- // }
}
}
})
@@ -1571,6 +1539,7 @@ const b = {
cd: 0,
acceleration: 0.009,
endCycle: Infinity,
+ drainThreshold: mod.isEnergyHealth ? 0.5 : 0.15,
classType: "bullet",
collisionFilter: {
category: cat.bullet,
@@ -1608,9 +1577,8 @@ const b = {
const sub = Vector.sub(this.lockedOn.position, this.position)
const DIST = Vector.magnitude(sub);
const unit = Vector.normalise(sub)
- const DRAIN = 0.0012
- if (DIST < mod.isPlasmaRange * 450 && mech.energy > DRAIN) {
- mech.energy -= DRAIN;
+ if (DIST < mod.isPlasmaRange * 450 && mech.energy > this.drainThreshold) {
+ mech.energy -= 0.0012;
if (mech.energy < 0) {
mech.fieldCDcycle = mech.cycle + 120;
mech.energy = 0;
@@ -1904,27 +1872,58 @@ const b = {
mech.fireCDcycle = mech.cycle + Math.floor(CD * b.fireCD); // cool down
const speed = 30 + 6 * Math.random() + 9 * mod.nailInstantFireRate
const angle = mech.angle + (Math.random() - 0.5) * (Math.random() - 0.5) * (mech.crouch ? 1.35 : 3.2) / CD
- const dmg = 0.9
- b.nail({
- x: mech.pos.x + 30 * Math.cos(mech.angle),
- y: mech.pos.y + 30 * Math.sin(mech.angle)
- }, {
- x: mech.Vx / 2 + speed * Math.cos(angle),
- y: mech.Vy / 2 + speed * Math.sin(angle)
- }, dmg) //position, velocity, damage
- if (mod.isIceCrystals) {
- bullet[bullet.length - 1].beforeDmg = function(who) {
- mobs.statusSlow(who, 30)
- if (mod.isNailPoison) mobs.statusDoT(who, dmg * 0.22, 120) // one tick every 30 cycles
- if (mod.isNailCrit && !who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.99) this.dmg *= 5 //crit if hit near center
- };
+ if (mod.isIncendiary) {
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 25, 2, {
+ density: 0.0001, //frictionAir: 0.01, //restitution: 0,
+ angle: angle,
+ friction: 0.5,
+ frictionAir: 0,
+ dmg: 0, //damage done in addition to the damage from momentum
+ endCycle: Math.floor(mech.crouch ? 28 : 13) + Math.random() * 5 + game.cycle,
+ classType: "bullet",
+ collisionFilter: {
+ category: cat.bullet,
+ mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield
+ },
+ minDmgSpeed: 10,
+ beforeDmg() {
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ },
+ onEnd() {
+ b.explosion(this.position, 72 + (Math.random() - 0.5) * 30); //makes bullet do explosive damage at end
+ },
+ do() {}
+ });
+ Matter.Body.setVelocity(bullet[me], {
+ x: speed * Math.cos(angle),
+ y: speed * Math.sin(angle)
+ });
+ World.add(engine.world, bullet[me]); //add bullet to world
+ } else {
+ const dmg = 0.9
+ b.nail({
+ x: mech.pos.x + 30 * Math.cos(mech.angle),
+ y: mech.pos.y + 30 * Math.sin(mech.angle)
+ }, {
+ x: mech.Vx / 2 + speed * Math.cos(angle),
+ y: mech.Vy / 2 + speed * Math.sin(angle)
+ }, dmg) //position, velocity, damage
+ if (mod.isIceCrystals) {
+ bullet[bullet.length - 1].beforeDmg = function(who) {
+ mobs.statusSlow(who, 30)
+ if (mod.isNailPoison) mobs.statusDoT(who, dmg * 0.22, 120) // one tick every 30 cycles
+ if (mod.isNailCrit && !who.shield && Vector.dot(Vector.normalise(Vector.sub(who.position, this.position)), Vector.normalise(this.velocity)) > 0.99) this.dmg *= 5 //crit if hit near center
+ };
- if (mech.energy < 0.01) {
- mech.fireCDcycle = mech.cycle + 60; // cool down
- } else {
- mech.energy -= mech.fieldRegen + 0.009
+ if (mech.energy < 0.01) {
+ mech.fireCDcycle = mech.cycle + 60; // cool down
+ } else {
+ mech.energy -= mech.fieldRegen + 0.009
+ }
}
}
+
}
},
{
@@ -1958,7 +1957,57 @@ const b = {
}
b.muzzleFlash(35);
- if (mod.isNailShot) {
+ if (mod.isIncendiary) {
+ const SPEED = mech.crouch ? 35 : 25
+ const END = Math.floor(mech.crouch ? 9 : 6);
+ const totalBullets = 8
+ const angleStep = (mech.crouch ? 0.1 : 0.33) / totalBullets
+ let dir = mech.angle - angleStep * totalBullets / 2;
+ for (let i = 0; i < totalBullets; i++) { //5 -> 7
+ dir += angleStep
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 17, 4, b.fireAttributes(dir));
+ const end = END + Math.random() * 3
+ bullet[me].endCycle = 2 * end + game.cycle
+ const speed = SPEED * end / END
+ const dirOff = dir + 0.15 * (Math.random() - 0.5)
+ Matter.Body.setVelocity(bullet[me], {
+ x: speed * Math.cos(dirOff),
+ y: speed * Math.sin(dirOff)
+ });
+ bullet[me].onEnd = function() {
+ b.explosion(this.position, 60 + (Math.random() - 0.5) * 40); //makes bullet do explosive damage at end
+ }
+ bullet[me].beforeDmg = function() {
+ this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ };
+ bullet[me].do = function() {}
+ World.add(engine.world, bullet[me]); //add bullet to world
+ }
+ // for (let i = 0; i < totalBullets; i++) { //5 -> 7
+ // dir += angleStep
+ // const me = bullet.length;
+ // bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), 17, 4, b.fireAttributes(dir));
+ // World.add(engine.world, bullet[me]); //add bullet to world
+ // Matter.Body.setVelocity(bullet[me], {
+ // x: (SPEED + 15 * Math.random() - 2 * i) * Math.cos(dir),
+ // y: (SPEED + 15 * Math.random() - 2 * i) * Math.sin(dir)
+ // });
+ // bullet[me].endCycle = 2 * i + END
+ // bullet[me].restitution = 0;
+ // bullet[me].friction = 1;
+ // bullet[me].onEnd = function() {
+ // b.explosion(this.position, (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50); //makes bullet do explosive damage at end
+ // }
+ // bullet[me].beforeDmg = function() {
+ // this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ // };
+ // bullet[me].do = function() {
+ // // this.force.y += this.mass * 0.0004;
+ // }
+ // }
+
+ } else if (mod.isNailShot) {
for (let i = 0; i < 14; i++) {
const dir = mech.angle + (Math.random() - 0.5) * spread * 0.2
const pos = {
@@ -2349,48 +2398,48 @@ const b = {
}
}
},
- {
- name: "flak",
- description: "fire a cluster of short range projectiles
explodes on contact or after half a second",
- ammo: 0,
- ammoPack: 4,
- defaultAmmoPack: 4, //use to revert ammoPack after mod changes drop rate
- have: false,
- fire() {
- mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 25 : 10) * b.fireCD); // cool down
- b.muzzleFlash(30);
- const SPEED = mech.crouch ? 29 : 25
- const END = Math.floor(mech.crouch ? 30 : 18);
- const side1 = 17
- const side2 = 4
- const totalBullets = 6
- const angleStep = (mech.crouch ? 0.06 : 0.25) / totalBullets
- let dir = mech.angle - angleStep * totalBullets / 2;
- for (let i = 0; i < totalBullets; i++) { //5 -> 7
- dir += angleStep
- const me = bullet.length;
- bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), side1, side2, b.fireAttributes(dir));
- World.add(engine.world, bullet[me]); //add bullet to world
- Matter.Body.setVelocity(bullet[me], {
- x: (SPEED + 15 * Math.random() - 2 * i) * Math.cos(dir),
- y: (SPEED + 15 * Math.random() - 2 * i) * Math.sin(dir)
- });
- bullet[me].endCycle = 2 * i + game.cycle + END
- bullet[me].restitution = 0;
- bullet[me].friction = 1;
- bullet[me].explodeRad = (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50;
- bullet[me].onEnd = function() {
- b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
- }
- bullet[me].beforeDmg = function() {
- this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
- };
- bullet[me].do = function() {
- // this.force.y += this.mass * 0.0004;
- }
- }
- }
- },
+ // {
+ // name: "flak",
+ // description: "fire a cluster of short range projectiles
explodes on contact or after half a second",
+ // ammo: 0,
+ // ammoPack: 4,
+ // defaultAmmoPack: 4, //use to revert ammoPack after mod changes drop rate
+ // have: false,
+ // fire() {
+ // mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 25 : 10) * b.fireCD); // cool down
+ // b.muzzleFlash(30);
+ // const SPEED = mech.crouch ? 29 : 25
+ // const END = Math.floor(mech.crouch ? 30 : 18);
+ // const side1 = 17
+ // const side2 = 4
+ // const totalBullets = 6
+ // const angleStep = (mech.crouch ? 0.06 : 0.25) / totalBullets
+ // let dir = mech.angle - angleStep * totalBullets / 2;
+ // for (let i = 0; i < totalBullets; i++) { //5 -> 7
+ // dir += angleStep
+ // const me = bullet.length;
+ // bullet[me] = Bodies.rectangle(mech.pos.x + 50 * Math.cos(mech.angle), mech.pos.y + 50 * Math.sin(mech.angle), side1, side2, b.fireAttributes(dir));
+ // World.add(engine.world, bullet[me]); //add bullet to world
+ // Matter.Body.setVelocity(bullet[me], {
+ // x: (SPEED + 15 * Math.random() - 2 * i) * Math.cos(dir),
+ // y: (SPEED + 15 * Math.random() - 2 * i) * Math.sin(dir)
+ // });
+ // bullet[me].endCycle = 2 * i + game.cycle + END
+ // bullet[me].restitution = 0;
+ // bullet[me].friction = 1;
+ // bullet[me].explodeRad = (mech.crouch ? 95 : 75) + (Math.random() - 0.5) * 50;
+ // bullet[me].onEnd = function() {
+ // b.explosion(this.position, this.explodeRad); //makes bullet do explosive damage at end
+ // }
+ // bullet[me].beforeDmg = function() {
+ // this.endCycle = 0; //bullet ends cycle after hitting a mob and triggers explosion
+ // };
+ // bullet[me].do = function() {
+ // // this.force.y += this.mass * 0.0004;
+ // }
+ // }
+ // }
+ // },
{
name: "grenades",
description: "lob a single bouncy projectile
explodes on contact or after one second",
diff --git a/js/engine.js b/js/engine.js
index 9ebe0a3..5856b25 100644
--- a/js/engine.js
+++ b/js/engine.js
@@ -24,8 +24,29 @@ function playerOnGroundCheck(event) {
//runs on collisions events
function enter() {
mech.numTouching++;
- if (!mech.onGround) mech.enterLand();
+ if (!mech.onGround) {
+ mech.onGround = true;
+ if (mech.crouch) {
+ if (mech.checkHeadClear()) {
+ mech.undoCrouch();
+ } else {
+ mech.yOffGoal = mech.yOffWhen.crouch;
+ }
+ } else {
+ //sets a hard land where player stays in a crouch for a bit and can't jump
+ //crouch is forced in groundControl below
+ const momentum = player.velocity.y * player.mass //player mass is 5 so this triggers at 26 down velocity, unless the player is holding something
+ if (momentum > 130) {
+ mech.doCrouch();
+ mech.yOff = mech.yOffWhen.jump;
+ mech.hardLandCD = mech.cycle + Math.min(momentum / 6.5 - 6, 40)
+ } else {
+ mech.yOffGoal = mech.yOffWhen.stand;
+ }
+ }
+ }
}
+
const pairs = event.pairs;
for (let i = 0, j = pairs.length; i != j; ++i) {
let pair = pairs[i];
@@ -42,76 +63,26 @@ function playerOnGroundCheck(event) {
function playerOffGroundCheck(event) {
//runs on collisions events
- function enter() {
- if (mech.onGround && mech.numTouching === 0) mech.enterAir();
- }
const pairs = event.pairs;
for (let i = 0, j = pairs.length; i != j; ++i) {
- if (pairs[i].bodyA === jumpSensor) {
- enter();
- } else if (pairs[i].bodyB === jumpSensor) {
- enter();
+ if (pairs[i].bodyA === jumpSensor || pairs[i].bodyB === jumpSensor) {
+ if (mech.onGround && mech.numTouching === 0) {
+ mech.onGround = false;
+ mech.hardLandCD = 0 // disable hard landing
+ if (mech.checkHeadClear()) {
+ if (mech.crouch) {
+ mech.undoCrouch();
+ }
+ mech.yOffGoal = mech.yOffWhen.jump;
+ }
+ }
}
}
}
-// function playerHeadCheck(event) {
-// //runs on collisions events
-// if (mech.crouch) {
-// mech.isHeadClear = true;
-// const pairs = event.pairs;
-// for (let i = 0, j = pairs.length; i != j; ++i) {
-// if (pairs[i].bodyA === headSensor) {
-// mech.isHeadClear = false;
-// } else if (pairs[i].bodyB === headSensor) {
-// mech.isHeadClear = false;
-// }
-// }
-// }
-// }
-
function collisionChecks(event) {
const pairs = event.pairs;
for (let i = 0, j = pairs.length; i != j; i++) {
-
- // //map + bullet collisions
- // if (pairs[i].bodyA.collisionFilter.category === cat.map && pairs[i].bodyB.collisionFilter.category === cat.bullet) {
- // collideBulletStatic(pairs[i].bodyB)
- // } else if (pairs[i].bodyB.collisionFilter.category === cat.map && pairs[i].bodyA.collisionFilter.category === cat.bullet) {
- // collideBulletStatic(pairs[i].bodyA)
- // }
- // //triggers when the bullets hits something static
- // function collideBulletStatic(obj, speedThreshold = 12, massThreshold = 2) {
- // if (obj.onWallHit) obj.onWallHit();
- // }
-
- // function collidePlayer(obj) {
- // //player dmg from hitting a body
- // if (obj.classType === "body" && obj.speed > 10 && mech.immuneCycle < mech.cycle) {
- // const velocityThreshold = 30 //keep this lines up with player.enterLand numbers (130/5 = 26)
- // if (player.position.y > obj.position.y) { //block is above the player look at total momentum difference
- // const velocityDiffMag = Vector.magnitude(Vector.sub(player.velocity, obj.velocity))
- // if (velocityDiffMag > velocityThreshold) hit(velocityDiffMag - velocityThreshold)
- // } else { //block is below player only look at horizontal momentum difference
- // const velocityDiffMagX = Math.abs(obj.velocity.x - player.velocity.x)
- // if (velocityDiffMagX > velocityThreshold) hit(velocityDiffMagX - velocityThreshold)
- // }
-
- // function hit(dmg) {
- // mech.immuneCycle = mech.cycle + mod.collisionImmuneCycles; //player is immune to collision damage for 30 cycles
- // dmg = Math.min(Math.max(Math.sqrt(dmg) * obj.mass * 0.01, 0.02), 0.15);
- // mech.damage(dmg);
- // game.drawList.push({ //add dmg to draw queue
- // x: pairs[i].activeContacts[0].vertex.x,
- // y: pairs[i].activeContacts[0].vertex.y,
- // radius: dmg * 500,
- // color: game.mobDmgColor,
- // time: game.drawTime
- // });
- // }
- // }
- // }
-
//mob + (player,bullet,body) collisions
for (let k = 0; k < mob.length; k++) {
if (mob[k].alive && mech.alive) {
diff --git a/js/index.js b/js/index.js
index cee0c81..e6af7b3 100644
--- a/js/index.js
+++ b/js/index.js
@@ -987,8 +987,8 @@ document.getElementById("updates").addEventListener("toggle", function() {
loadJSON('https://api.github.com/repos/landgreen/n-gon/commits',
function(data) {
// console.log(data)
- for (let i = 0, len = 4; i < len; i++) {
- text += data[i].commit.author.date.substr(0, 10) + ": "; //+ "
"
+ for (let i = 0, len = 3; i < len; i++) {
+ text += "" + data[i].commit.author.date.substr(0, 10) + " - "; //+ "
"
text += data[i].commit.message
if (i < len - 1) text += "