laser now has infinite ammo, but drains field energy

This commit is contained in:
lilgreenland
2019-07-14 18:55:50 -07:00
parent b6f21d76de
commit 7aba4473af
3 changed files with 129 additions and 113 deletions

View File

@@ -230,10 +230,18 @@ const b = {
{
name: "laser",
ammo: 0,
ammoPack: 350,
// ammoPack: 350,
ammoPack: Infinity,
have: false,
fire() {
//mech.fireCDcycle = game.cycle + 1
//laser drains energy as well as bullets
const FIELD_DRAIN = 0.006
if (mech.fieldMeter < FIELD_DRAIN) {
mech.fireCDcycle = game.cycle + 120; // cool down if out of energy
} else {
mech.fieldMeter -= mech.fieldRegen + FIELD_DRAIN
let best;
const color = "#f00";
const range = 3000;
@@ -301,7 +309,7 @@ const b = {
};
const laserHitMob = function (dmg) {
if (best.who.alive) {
dmg *= b.dmgScale * 0.065;
dmg *= b.dmgScale * 0.05;
best.who.damage(dmg);
best.who.locatePlayer();
//draw mob damage circle
@@ -377,6 +385,7 @@ const b = {
ctx.setLineDash([0, 0]);
ctx.globalAlpha = 1;
}
}
},
{
name: "rapid fire",

View File

@@ -204,6 +204,7 @@ const level = {
},
//empty map for testing mobs
intro() {
b.giveGuns(0, 1000)
game.zoomScale = 1000 //1400 is normal
game.zoomTransition(1600, 1)

View File

@@ -72,9 +72,15 @@ const powerUps = {
//ammo given scales as mobs take more hits to kill
const ammo = Math.ceil((target.ammoPack * (0.60 + 0.5 * Math.random())) / b.dmgScale);
target.ammo += ammo;
if (target.ammo === Infinity) {
mech.fieldMeter = 1;
game.makeTextLog("+energy", 180);
} else {
game.updateGunHUD();
game.makeTextLog("+" + ammo + " ammo: " + target.name, 180);
}
}
},
gun: {
name: "gun",