added mine mod and felechette mod

This commit is contained in:
landgreen
2020-02-26 05:58:29 -08:00
parent 86673b5d21
commit e0354c28e3
5 changed files with 140 additions and 59 deletions

View File

@@ -54,6 +54,8 @@ const b = {
modWaveSpeedBody: null, modWaveSpeedBody: null,
modFieldEfficiency: null, modFieldEfficiency: null,
isModSporeField: null, isModSporeField: null,
isModFlechetteMultiShot: null,
isModMineAmmoBack: null,
modOnHealthChange() { //used with acid mod modOnHealthChange() { //used with acid mod
if (b.isModAcidDmg && mech.health > 0.8) { if (b.isModAcidDmg && mech.health > 0.8) {
game.playerDmgColor = "rgba(0,80,80,0.9)" game.playerDmgColor = "rgba(0,80,80,0.9)"
@@ -912,7 +914,54 @@ const b = {
b.isModShotgunImmune = false; b.isModShotgunImmune = false;
} }
}, },
{
name: "fléchettes cartridges",
description: "<strong>fléchettes</strong> release <strong>three</strong> needles in each shot<br><strong>ammo</strong> cost are increases by <strong>3x</strong>",
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: "<strong>ammo</strong> from undetonated <strong>mines</strong> is returned<br><em>at the end of a level or after 2000 second</em>",
maxCount: 1,
count: 0,
allowed() {
return b.haveGunCheck("mine")
},
requires: "mine",
effect() {
b.isModMineAmmoBack = true;
},
remove() {
b.isModMineAmmoBack = false;
}
},
{ {
name: "perfect diamagnetism", name: "perfect diamagnetism",
description: "when <strong>blocking</strong> with the basic <strong>field emitter</strong><br>gain <strong class='color-f'>energy</strong> instead losing it", description: "when <strong>blocking</strong> with the basic <strong>field emitter</strong><br>gain <strong class='color-f'>energy</strong> instead losing it",
@@ -947,20 +996,6 @@ const b = {
b.isModSporeField = false; 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) { removeMod(index) {
b.mods[index].remove(); 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; const bIndex = bullet.length;
bullet[bIndex] = Bodies.rectangle(where.x, where.y, 45 * b.modBulletSize, 16 * b.modBulletSize, { bullet[bIndex] = Bodies.rectangle(where.x, where.y, 45 * b.modBulletSize, 16 * b.modBulletSize, {
angle: angle, angle: angle,
@@ -1277,6 +1312,7 @@ const b = {
restitution: 0, restitution: 0,
dmg: 0, //damage done in addition to the damage from momentum dmg: 0, //damage done in addition to the damage from momentum
classType: "bullet", classType: "bullet",
bulletType: "mine",
collisionFilter: { collisionFilter: {
category: cat.bullet, category: cat.bullet,
mask: cat.map | cat.body | cat.mob | cat.mobBullet | cat.mobShield | 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(map, this.position, mob[i].position).length === 0 &&
Matter.Query.ray(body, 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 this.endCycle = 0 //end life if mob is near and visible
isAmmoBack = false;
} }
} }
} }
} }
}, },
onEnd() { 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) { if (this.isArmed) {
const targets = [] //target nearby mobs const targets = [] //target nearby mobs
for (let i = 0, len = mob.length; i < len; i++) { for (let i = 0, len = mob.length; i < len; i++) {
@@ -1882,7 +1929,8 @@ const b = {
name: "fléchettes", //3 name: "fléchettes", //3
description: "fire a volley of <strong>precise</strong> high velocity needles", description: "fire a volley of <strong>precise</strong> high velocity needles",
ammo: 0, ammo: 0,
ammoPack: 22, ammoPack: 24,
defaultAmmoPack: 24,
have: false, have: false,
isStarterGun: true, isStarterGun: true,
count: 0, //used to track how many shots are in a volley before a big CD 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 mech.fireCDcycle = mech.cycle + Math.floor(2 * b.modFireRate); // cool down
} }
const me = bullet.length; function makeFlechette(angle = mech.angle) {
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)); const me = bullet.length;
bullet[me].endCycle = game.cycle + 180; 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].dmg = 1.15; bullet[me].endCycle = game.cycle + 180;
bullet[me].do = function () { bullet[me].dmg = 1.15;
if (this.speed < 10) this.force.y += this.mass * 0.0003; //no gravity until it slows don to improve aiming 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], { const SPEED = 50
x: mech.Vx / 2 + SPEED * Math.cos(mech.angle), Matter.Body.setVelocity(bullet[me], {
y: mech.Vy / 2 + SPEED * Math.sin(mech.angle) 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 });
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), x: speed * Math.cos(mech.angle),
y: speed * Math.sin(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 mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 70 : 45) * b.modFireRate); // cool down
} }
}, },

View File

@@ -97,8 +97,12 @@ function collisionChecks(event) {
function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) { function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) {
//player dmg from hitting a body //player dmg from hitting a body
if (obj.classType === "body" && obj.speed > speedThreshold && obj.mass > massThreshold && if (
(obj.velocity.y > 0 || player.velocity.y > 0)) { 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)); const v = Vector.magnitude(Vector.sub(player.velocity, obj.velocity));
if (v > speedThreshold && mech.collisionImmuneCycle < mech.cycle) { if (v > speedThreshold && mech.collisionImmuneCycle < mech.cycle) {
mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles

View File

@@ -236,10 +236,12 @@ const game = {
keyPress() { //runs on key down event keyPress() { //runs on key down event
if (keys[189]) { if (keys[189]) {
// - key // - key
game.isAutoZoom = false;
game.zoomScale /= 0.9; game.zoomScale /= 0.9;
game.setZoom(); game.setZoom();
} else if (keys[187]) { } else if (keys[187]) {
// = key // = key
game.isAutoZoom = false;
game.zoomScale *= 0.9; game.zoomScale *= 0.9;
game.setZoom(); game.setZoom();
} }
@@ -347,6 +349,7 @@ const game = {
}, },
zoom: null, zoom: null,
zoomScale: 1000, zoomScale: 1000,
isAutoZoom: true,
setZoom(zoomScale = game.zoomScale) { //use in window resize in index.js setZoom(zoomScale = game.zoomScale) { //use in window resize in index.js
game.zoomScale = zoomScale game.zoomScale = zoomScale
game.zoom = canvas.height / zoomScale; //sets starting zoom scale game.zoom = canvas.height / zoomScale; //sets starting zoom scale
@@ -362,29 +365,31 @@ const game = {
mech.transY += (mech.transSmoothY - mech.transY) * 1; mech.transY += (mech.transSmoothY - mech.transY) * 1;
}, },
zoomTransition(newZoomScale, step = 2) { zoomTransition(newZoomScale, step = 2) {
const isBigger = (newZoomScale - game.zoomScale > 0) ? true : false; if (game.isAutoZoom) {
requestAnimationFrame(zLoop); const isBigger = (newZoomScale - game.zoomScale > 0) ? true : false;
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();
requestAnimationFrame(zLoop); 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() { camera() {
@@ -444,6 +449,7 @@ const game = {
game.paused = false; game.paused = false;
engine.timing.timeScale = 1; engine.timing.timeScale = 1;
game.fpsCap = game.fpsCapDefault; game.fpsCap = game.fpsCapDefault;
game.isAutoZoom = true;
game.makeGunHUD(); game.makeGunHUD();
mech.drop(); mech.drop();
mech.holdingTarget = null mech.holdingTarget = null
@@ -565,6 +571,21 @@ const game = {
}, },
clearNow: false, clearNow: false,
clearMap() { 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 //if player is holding something this remembers it before it gets deleted
let holdTarget; let holdTarget;
if (mech.holdingTarget) { if (mech.holdingTarget) {

View File

@@ -14,10 +14,10 @@ const level = {
start() { start() {
if (level.levelsCleared === 0) { if (level.levelsCleared === 0) {
// level.difficultyIncrease(9) // level.difficultyIncrease(9)
// b.giveGuns("shotgun") // b.giveGuns("fléchettes")
// mech.setField("nano-scale manufacturing") // mech.setField("nano-scale manufacturing")
// for (let i = 0; i < 9; i++) { // for (let i = 0; i < 9; i++) {
// b.giveMod("mycelium manufacturing"); // b.giveMod("fléchettes multishot");
// b.giveMod("basidio-stomp"); // b.giveMod("basidio-stomp");
// b.giveMod("acute stress response"); // b.giveMod("acute stress response");
// } // }

View File

@@ -1,8 +1,9 @@
************** TODO - n-gon ************** ************** 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 gun - buff vacuum bomb
its weak late game its weak late game