diff --git a/js/bullets.js b/js/bullets.js
index 52d974d..b6dac44 100644
--- a/js/bullets.js
+++ b/js/bullets.js
@@ -54,6 +54,8 @@ const b = {
modWaveSpeedBody: null,
modFieldEfficiency: null,
isModSporeField: null,
+ isModFlechetteMultiShot: null,
+ isModMineAmmoBack: null,
modOnHealthChange() { //used with acid mod
if (b.isModAcidDmg && mech.health > 0.8) {
game.playerDmgColor = "rgba(0,80,80,0.9)"
@@ -912,7 +914,54 @@ const b = {
b.isModShotgunImmune = false;
}
},
-
+ {
+ name: "fléchettes cartridges",
+ description: "fléchettes release three needles in each shot
ammo cost are increases by 3x",
+ maxCount: 1,
+ count: 0,
+ allowed() {
+ return b.haveGunCheck("fléchettes")
+ },
+ requires: "fléchettes",
+ effect() {
+ b.isModFlechetteMultiShot = true;
+ //cut current ammo by 1/3
+ for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak
+ if (b.guns[i].name === "fléchettes") b.guns[i].ammo = Math.ceil(b.guns[i].ammo / 3);
+ }
+ //cut ammo packs by 1/3
+ for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak
+ if (b.guns[i].name === "fléchettes") b.guns[i].ammoPack = Math.ceil(b.guns[i].defaultAmmoPack / 3);
+ }
+ game.updateGunHUD();
+ },
+ remove() {
+ b.isModFlechetteMultiShot = false;
+ for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak
+ if (b.guns[i].name === "fléchettes") b.guns[i].ammo = Math.ceil(b.guns[i].ammo * 3);
+ }
+ for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is flak
+ if (b.guns[i].name === "fléchettes") b.guns[i].ammoPack = b.guns[i].defaultAmmoPack;
+ }
+ game.updateGunHUD();
+ }
+ },
+ {
+ name: "mine reclamation",
+ description: "ammo from undetonated mines is returned
at the end of a level or after 2000 second",
+ maxCount: 1,
+ count: 0,
+ allowed() {
+ return b.haveGunCheck("mine")
+ },
+ requires: "mine",
+ effect() {
+ b.isModMineAmmoBack = true;
+ },
+ remove() {
+ b.isModMineAmmoBack = false;
+ }
+ },
{
name: "perfect diamagnetism",
description: "when blocking with the basic field emitter
gain energy instead losing it",
@@ -947,20 +996,6 @@ const b = {
b.isModSporeField = false;
}
},
-
- // {
- // name: "super mines",
- // description: "mines fire super balls when triggered",
- // maxCount: 1,
- // count: 0,
- // allowed() {
- // return b.haveGunCheck("mines")
- // },
- // requires: "",
- // effect() {
-
- // }
- // },
],
removeMod(index) {
b.mods[index].remove();
@@ -1267,7 +1302,7 @@ const b = {
}
}
},
- mine(where, velocity, angle = 0) {
+ mine(where, velocity, angle = 0, isAmmoBack = false) {
const bIndex = bullet.length;
bullet[bIndex] = Bodies.rectangle(where.x, where.y, 45 * b.modBulletSize, 16 * b.modBulletSize, {
angle: angle,
@@ -1277,6 +1312,7 @@ const b = {
restitution: 0,
dmg: 0, //damage done in addition to the damage from momentum
classType: "bullet",
+ bulletType: "mine",
collisionFilter: {
category: cat.bullet,
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield | cat.bullet
@@ -1357,12 +1393,23 @@ const b = {
Matter.Query.ray(map, this.position, mob[i].position).length === 0 &&
Matter.Query.ray(body, this.position, mob[i].position).length === 0) {
this.endCycle = 0 //end life if mob is near and visible
+ isAmmoBack = false;
}
}
}
}
},
onEnd() {
+ if (isAmmoBack) {
+ for (i = 0, len = b.guns.length; i < len; i++) { //find which gun
+ if (b.guns[i].name === "mine") {
+ b.guns[i].ammo++
+ game.updateGunHUD();
+ break;
+ }
+ }
+ return
+ }
if (this.isArmed) {
const targets = [] //target nearby mobs
for (let i = 0, len = mob.length; i < len; i++) {
@@ -1882,7 +1929,8 @@ const b = {
name: "fléchettes", //3
description: "fire a volley of precise high velocity needles",
ammo: 0,
- ammoPack: 22,
+ ammoPack: 24,
+ defaultAmmoPack: 24,
have: false,
isStarterGun: true,
count: 0, //used to track how many shots are in a volley before a big CD
@@ -1900,19 +1948,26 @@ const b = {
mech.fireCDcycle = mech.cycle + Math.floor(2 * b.modFireRate); // cool down
}
- const me = bullet.length;
- bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 45 * b.modBulletSize, 1.4 * b.modBulletSize, b.fireAttributes(mech.angle));
- bullet[me].endCycle = game.cycle + 180;
- bullet[me].dmg = 1.15;
- bullet[me].do = function () {
- if (this.speed < 10) this.force.y += this.mass * 0.0003; //no gravity until it slows don to improve aiming
- };
- const SPEED = 50
- Matter.Body.setVelocity(bullet[me], {
- x: mech.Vx / 2 + SPEED * Math.cos(mech.angle),
- y: mech.Vy / 2 + SPEED * Math.sin(mech.angle)
- });
- World.add(engine.world, bullet[me]); //add bullet to world
+ function makeFlechette(angle = mech.angle) {
+ const me = bullet.length;
+ bullet[me] = Bodies.rectangle(mech.pos.x + 40 * Math.cos(mech.angle), mech.pos.y + 40 * Math.sin(mech.angle), 45 * b.modBulletSize, 1.4 * b.modBulletSize, b.fireAttributes(angle));
+ bullet[me].endCycle = game.cycle + 180;
+ bullet[me].dmg = 1.15;
+ bullet[me].do = function () {
+ if (this.speed < 10) this.force.y += this.mass * 0.0003; //no gravity until it slows don to improve aiming
+ };
+ const SPEED = 50
+ Matter.Body.setVelocity(bullet[me], {
+ x: mech.Vx / 2 + SPEED * Math.cos(angle),
+ y: mech.Vy / 2 + SPEED * Math.sin(angle)
+ });
+ World.add(engine.world, bullet[me]); //add bullet to world
+ }
+ makeFlechette()
+ if (b.isModFlechetteMultiShot) {
+ makeFlechette(mech.angle + 0.01 + 0.01 * Math.random())
+ makeFlechette(mech.angle - 0.01 - 0.01 * Math.random())
+ }
}
},
{
@@ -2286,7 +2341,7 @@ const b = {
}, {
x: speed * Math.cos(mech.angle),
y: speed * Math.sin(mech.angle)
- })
+ }, 0, b.isModMineAmmoBack)
mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 70 : 45) * b.modFireRate); // cool down
}
},
diff --git a/js/engine.js b/js/engine.js
index a3e602a..1a67019 100644
--- a/js/engine.js
+++ b/js/engine.js
@@ -97,8 +97,12 @@ function collisionChecks(event) {
function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) {
//player dmg from hitting a body
- if (obj.classType === "body" && obj.speed > speedThreshold && obj.mass > massThreshold &&
- (obj.velocity.y > 0 || player.velocity.y > 0)) {
+ if (
+ obj.classType === "body" &&
+ obj.speed > speedThreshold &&
+ obj.mass > massThreshold &&
+ (obj.velocity.y > 0 || player.velocity.y > 0)
+ ) {
const v = Vector.magnitude(Vector.sub(player.velocity, obj.velocity));
if (v > speedThreshold && mech.collisionImmuneCycle < mech.cycle) {
mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
diff --git a/js/game.js b/js/game.js
index c2c0bdd..f2ba711 100644
--- a/js/game.js
+++ b/js/game.js
@@ -236,10 +236,12 @@ const game = {
keyPress() { //runs on key down event
if (keys[189]) {
// - key
+ game.isAutoZoom = false;
game.zoomScale /= 0.9;
game.setZoom();
} else if (keys[187]) {
// = key
+ game.isAutoZoom = false;
game.zoomScale *= 0.9;
game.setZoom();
}
@@ -347,6 +349,7 @@ const game = {
},
zoom: null,
zoomScale: 1000,
+ isAutoZoom: true,
setZoom(zoomScale = game.zoomScale) { //use in window resize in index.js
game.zoomScale = zoomScale
game.zoom = canvas.height / zoomScale; //sets starting zoom scale
@@ -362,29 +365,31 @@ const game = {
mech.transY += (mech.transSmoothY - mech.transY) * 1;
},
zoomTransition(newZoomScale, step = 2) {
- const isBigger = (newZoomScale - game.zoomScale > 0) ? true : false;
- requestAnimationFrame(zLoop);
- const currentLevel = level.onLevel
-
- function zLoop() {
- if (currentLevel != level.onLevel) return //stop the zoom if player goes to a new level
-
- if (isBigger) {
- game.zoomScale += step
- if (game.zoomScale >= newZoomScale) {
- game.setZoom(newZoomScale);
- return
- }
- } else {
- game.zoomScale -= step
- if (game.zoomScale <= newZoomScale) {
- game.setZoom(newZoomScale);
- return
- }
- }
-
- game.setZoom();
+ if (game.isAutoZoom) {
+ const isBigger = (newZoomScale - game.zoomScale > 0) ? true : false;
requestAnimationFrame(zLoop);
+ const currentLevel = level.onLevel
+
+ function zLoop() {
+ if (currentLevel !== level.onLevel || game.isAutoZoom === false) return //stop the zoom if player goes to a new level
+
+ if (isBigger) {
+ game.zoomScale += step
+ if (game.zoomScale >= newZoomScale) {
+ game.setZoom(newZoomScale);
+ return
+ }
+ } else {
+ game.zoomScale -= step
+ if (game.zoomScale <= newZoomScale) {
+ game.setZoom(newZoomScale);
+ return
+ }
+ }
+
+ game.setZoom();
+ requestAnimationFrame(zLoop);
+ }
}
},
camera() {
@@ -444,6 +449,7 @@ const game = {
game.paused = false;
engine.timing.timeScale = 1;
game.fpsCap = game.fpsCapDefault;
+ game.isAutoZoom = true;
game.makeGunHUD();
mech.drop();
mech.holdingTarget = null
@@ -565,6 +571,21 @@ const game = {
},
clearNow: false,
clearMap() {
+
+ if (b.isModMineAmmoBack) {
+ let count = 0;
+ for (i = 0, len = bullet.length; i < len; i++) { //count mines left on map
+ if (bullet[i].bulletType === "mine") count++
+ }
+ for (i = 0, len = b.guns.length; i < len; i++) { //find which gun is mine
+ if (b.guns[i].name === "mine") {
+ b.guns[i].ammo += count
+ game.updateGunHUD();
+ break;
+ }
+ }
+ }
+
//if player is holding something this remembers it before it gets deleted
let holdTarget;
if (mech.holdingTarget) {
diff --git a/js/level.js b/js/level.js
index 494b6da..52e47d9 100644
--- a/js/level.js
+++ b/js/level.js
@@ -14,10 +14,10 @@ const level = {
start() {
if (level.levelsCleared === 0) {
// level.difficultyIncrease(9)
- // b.giveGuns("shotgun")
+ // b.giveGuns("fléchettes")
// mech.setField("nano-scale manufacturing")
// for (let i = 0; i < 9; i++) {
- // b.giveMod("mycelium manufacturing");
+ // b.giveMod("fléchettes multishot");
// b.giveMod("basidio-stomp");
// b.giveMod("acute stress response");
// }
diff --git a/todo.txt b/todo.txt
index b9bc8ef..e403cce 100644
--- a/todo.txt
+++ b/todo.txt
@@ -1,8 +1,9 @@
************** TODO - n-gon **************
-disable automatic zoom if you have pressed + or -
+mod - flechettes mod for poison damage
+ other flechettes multi-shot is disabled
+mod - flechettes are guided towards targets
-mod - mines return ammo if they don't fire
gun - buff vacuum bomb
its weak late game