From 20bea938fc2ff04cb124743b52bdf5b504c473cb Mon Sep 17 00:00:00 2001 From: landgreen Date: Mon, 9 Mar 2020 19:59:47 -0700 Subject: [PATCH] mod - super ball --- js/bullets.js | 72 ++++++++++++++++++++++++++++++++++++++++++++------- js/mobs.js | 6 ++--- todo.txt | 7 +++++ 3 files changed, 73 insertions(+), 12 deletions(-) diff --git a/js/bullets.js b/js/bullets.js index fdcd544..924a3ca 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -38,6 +38,7 @@ const b = { isModFastSpores: null, isModStomp: null, modSuperBallNumber: null, + modOneSuperBall: null, modLaserReflections: null, modLaserDamage: null, modLaserFieldDrain: null, @@ -188,13 +189,13 @@ const b = { }, { name: "thermal runaway", - description: "mobs explode when they die", + description: "mobs explode when they die
be careful", maxCount: 1, count: 0, allowed() { - return b.isModImmuneExplosion + return true }, - requires: "electric reactive armour", + requires: "", effect: () => { b.isModExplodeMob = true; }, @@ -828,6 +829,38 @@ const b = { b.modSuperBallNumber = 4; } }, + { + name: "super ball", + description: "rapidly fire one ball at a time
ammo costs are reduced by 50%", + maxCount: 1, + count: 0, + allowed() { + return b.haveGunCheck("super balls") + }, + requires: "super balls", + effect() { + b.modOneSuperBall = true; + // current ammo + for (i = 0, len = b.guns.length; i < len; i++) { //find which gun + if (b.guns[i].name === "super balls") b.guns[i].ammo = b.guns[i].ammo * 2; + } + //ammo power ups + for (i = 0, len = b.guns.length; i < len; i++) { //find which gun + if (b.guns[i].name === "super balls") b.guns[i].ammoPack = b.guns[i].defaultAmmoPack * 2; + } + }, + remove() { + b.modOneSuperBall = false; + // current ammo + for (i = 0, len = b.guns.length; i < len; i++) { //find which gun + if (b.guns[i].name === "super balls") b.guns[i].ammo = Math.floor(b.guns[i].ammo / 2); + } + //ammo power ups + for (i = 0, len = b.guns.length; i < len; i++) { //find which gun + if (b.guns[i].name === "super balls") b.guns[i].ammoPack = b.guns[i].defaultAmmoPack; + } + } + }, { name: "fléchettes cartridges", description: "fléchettes release three needles in each shot
ammo cost are increases by 3x", @@ -2165,18 +2198,17 @@ const b = { description: "fire four balls in a wide arc
balls bounce with no momentum loss", ammo: 0, ammoPack: 12, + defaultAmmoPack: 12, //use to revert ammoPack after mod changes drop rate have: false, num: 5, isStarterGun: true, isEasyToAim: true, fire() { - mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 25 : 20) * b.modFireRate); // cool down b.muzzleFlash(20); - // mobs.alert(450); const SPEED = mech.crouch ? 40 : 30 - const SPREAD = mech.crouch ? 0.08 : 0.15 - let dir = mech.angle - SPREAD * (b.modSuperBallNumber - 1) / 2; - for (let i = 0; i < b.modSuperBallNumber; i++) { + if (b.modOneSuperBall) { + mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 32 : 20) * b.modFireRate / (b.modSuperBallNumber)); // cool down + let dir = mech.angle const me = bullet.length; bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 12, 7 * b.modBulletSize, b.fireAttributes(dir, false)); World.add(engine.world, bullet[me]); //add bullet to world @@ -2193,7 +2225,29 @@ const b = { bullet[me].do = function () { this.force.y += this.mass * 0.001; }; - dir += SPREAD; + } else { + mech.fireCDcycle = mech.cycle + Math.floor((mech.crouch ? 25 : 20) * b.modFireRate); // cool down + const SPREAD = mech.crouch ? 0.08 : 0.15 + let dir = mech.angle - SPREAD * (b.modSuperBallNumber - 1) / 2; + for (let i = 0; i < b.modSuperBallNumber; i++) { + const me = bullet.length; + bullet[me] = Bodies.polygon(mech.pos.x + 30 * Math.cos(mech.angle), mech.pos.y + 30 * Math.sin(mech.angle), 12, 7 * b.modBulletSize, b.fireAttributes(dir, false)); + World.add(engine.world, bullet[me]); //add bullet to world + Matter.Body.setVelocity(bullet[me], { + x: SPEED * Math.cos(dir), + y: SPEED * Math.sin(dir) + }); + // Matter.Body.setDensity(bullet[me], 0.0001); + bullet[me].endCycle = game.cycle + Math.floor((300 + 60 * Math.random()) * b.isModBulletsLastLonger); + bullet[me].dmg = 0; + bullet[me].minDmgSpeed = 0; + bullet[me].restitution = 0.99; + bullet[me].friction = 0; + bullet[me].do = function () { + this.force.y += this.mass * 0.001; + }; + dir += SPREAD; + } } } }, diff --git a/js/mobs.js b/js/mobs.js index 0f55ef5..95cbf93 100644 --- a/js/mobs.js +++ b/js/mobs.js @@ -68,8 +68,8 @@ const mobs = { ctx.lineTo(who.vertices[j].x, who.vertices[j].y); } ctx.lineTo(who.vertices[0].x, who.vertices[0].y); - ctx.strokeStyle = "rgba(0,100,255,0.5)"; - ctx.lineWidth = 30; + ctx.strokeStyle = "rgba(0,100,255,0.8)"; + ctx.lineWidth = 15; ctx.stroke(); ctx.fillStyle = who.fill ctx.fill(); @@ -1015,7 +1015,7 @@ const mobs = { b.spore(this) //spawn drone } } - if (b.isModExplodeMob) b.explosion(this.position, Math.min(500, Math.sqrt(this.mass + 2) * 80)) + if (b.isModExplodeMob) b.explosion(this.position, Math.min(450, Math.sqrt(this.mass + 3) * 80)) } }, diff --git a/todo.txt b/todo.txt index 26f15ae..c05952c 100644 --- a/todo.txt +++ b/todo.txt @@ -1,5 +1,12 @@ ************** TODO - n-gon ************** +mod - super balls fire one ball at a time + ammo and fire rate is improved by the number of balls fired + +mod - robot that attack nearby mobs, and delivers a stun status effect + use laser bot code for the attack + large and 5 sided? + consider using the "e" key for picking up blocks and just q for gun swaps good for: plasma torch, time dilation, negative mass bad for: basic, nano-scale, harmonic