From 2c34a7d89dd486797639817a87dec7e628578221 Mon Sep 17 00:00:00 2001 From: landgreen Date: Sun, 20 Sep 2020 08:31:17 -0700 Subject: [PATCH] cloaking balance --- js/bullet.js | 7 +++++- js/mods.js | 4 +-- js/player.js | 71 ++++++++++++++++++++++++++++++++++++---------------- todo.txt | 4 +++ 4 files changed, 62 insertions(+), 24 deletions(-) diff --git a/js/bullet.js b/js/bullet.js index 330d332..cfb0ed3 100644 --- a/js/bullet.js +++ b/js/bullet.js @@ -1015,6 +1015,11 @@ const b = { for (let i = 0; i < mod.foamBotCount; i++) b.foamBot() for (let i = 0; i < mod.boomBotCount; i++) b.boomBot() for (let i = 0; i < mod.plasmaBotCount; i++) b.plasmaBot() + if (mod.isIntangible && mech.isCloak) { + for (let i = 0; i < bullet.length; i++) { + if (bullet[i].botType) bullet[i].collisionFilter.mask = cat.map | cat.bullet | cat.mobBullet | cat.mobShield + } + } }, randomBot(where = mech.pos, isKeep = true) { if (Math.random() < 0.25) { @@ -1316,7 +1321,7 @@ const b = { } } //punch target - if (this.lockedOn && this.lockedOn.alive) { + if (this.lockedOn && this.lockedOn.alive && !mech.isCloak) { const DIST = Vector.magnitude(Vector.sub(this.vertices[0], this.lockedOn.position)); if (DIST - this.lockedOn.radius < this.range && Matter.Query.ray(map, this.position, this.lockedOn.position).length === 0) { diff --git a/js/mods.js b/js/mods.js index 759f4a2..6fb5bb8 100644 --- a/js/mods.js +++ b/js/mods.js @@ -819,7 +819,7 @@ const mod = { maxCount: 1, count: 0, allowed() { - return mod.isStunField || mod.isPulseStun || mod.isNeutronStun || mod.oneSuperBall || mod.isHarmFreeze || mod.isIceField || mod.isIceCrystals || mod.isSporeFreeze || mod.isAoESlow || mod.isFreezeMobs || mod.isPilotFreeze || mod.haveGunCheck("ice IX") + return mod.isStunField || mod.isPulseStun || mod.isNeutronStun || mod.oneSuperBall || mod.isHarmFreeze || mod.isIceField || mod.isIceCrystals || mod.isSporeFreeze || mod.isAoESlow || mod.isFreezeMobs || mod.isPilotFreeze || mod.haveGunCheck("ice IX") || mod.isCloakStun }, requires: "a freezing or stunning effect", effect() { @@ -2532,7 +2532,7 @@ const mod = { }, { name: "flashbang", - description: "decloaking stuns nearby mobs for 2 second", + description: "decloaking stuns nearby mobs
drains 25% of your stored energy", maxCount: 1, count: 0, allowed() { diff --git a/js/player.js b/js/player.js index 4ea0a0b..9c88e55 100644 --- a/js/player.js +++ b/js/player.js @@ -1775,7 +1775,8 @@ const mech = { mech.fieldPhase = 0; mech.isCloak = false mech.fieldDamage = 1.66 - const drawRadius = 900 + mech.fieldDrawRadius = 0 + const drawRadius = 1000 mech.hold = function () { if (mech.isHolding) { @@ -1786,7 +1787,7 @@ const mech = { } else if ((keys[32] || game.mouseDownRight && mech.fieldCDcycle < mech.cycle)) { //not hold and field button is pressed mech.grabPowerUp(); mech.lookForPickUp(); - if (mech.fireCDcycle < mech.cycle) mech.fireCDcycle = mech.cycle - 40 //to disable cloak + if (mech.fireCDcycle < mech.cycle) mech.fireCDcycle = mech.cycle //to disable cloak } else if (mech.holdingTarget && mech.fieldCDcycle < mech.cycle) { //holding target exists, and field button is not pressed mech.pickUp(); } else { @@ -1796,31 +1797,56 @@ const mech = { //120 cycles after shooting (or using field) enable cloak if (mech.energy < 0.05 && mech.fireCDcycle < mech.cycle) mech.fireCDcycle = mech.cycle if (mech.fireCDcycle + 50 < mech.cycle) { - if (!mech.isCloak) mech.isCloak = true - } else { - if (mech.isCloak) { - mech.isCloak = false - if (mod.isCloakStun) { //stun nearby mobs after exiting cloak - ctx.beginPath(); - ctx.arc(mech.pos.x, mech.pos.y, 800, 0, 2 * Math.PI); - ctx.fillStyle = "#000" - ctx.fill(); - for (let i = 0, len = mob.length; i < len; ++i) { - if (Vector.magnitude(Vector.sub(mob[i].position, mech.pos)) < drawRadius) { - mobs.statusStun(mob[i], 120) - } + if (!mech.isCloak) { + mech.isCloak = true //enter cloak + if (mod.isIntangible) { + for (let i = 0; i < bullet.length; i++) { + if (bullet[i].botType) bullet[i].collisionFilter.mask = cat.map | cat.bullet | cat.mobBullet | cat.mobShield } } } + } else if (mech.isCloak) { //exit cloak + mech.isCloak = false + if (mod.isIntangible) { + for (let i = 0; i < bullet.length; i++) { + if (bullet[i].botType) bullet[i].collisionFilter.mask = cat.map | cat.body | cat.bullet | cat.mob | cat.mobBullet | cat.mobShield + } + } + if (mod.isCloakStun) { //stun nearby mobs after exiting cloak + let isMobsAround = false + const stunRange = mech.fieldDrawRadius * 1.15 + const drain = 0.25 * mech.energy + for (let i = 0, len = mob.length; i < len; ++i) { + if ( + Vector.magnitude(Vector.sub(mob[i].position, mech.pos)) < stunRange && + Matter.Query.ray(map, mob[i].position, mech.pos).length === 0 + ) { + isMobsAround = true + mobs.statusStun(mob[i], drain * 500) + } + } + if (isMobsAround && mech.energy > drain) { + mech.energy -= drain + game.drawList.push({ + x: mech.pos.x, + y: mech.pos.y, + radius: stunRange, + color: "hsla(0,50%,100%,0.5)", + time: 3 + }); + // ctx.beginPath(); + // ctx.arc(mech.pos.x, mech.pos.y, 800, 0, 2 * Math.PI); + // ctx.fillStyle = "#000" + // ctx.fill(); + } + } } - function drawField(radius) { - const energy = Math.max(0.01, Math.min(mech.energy, 1)) - radius *= Math.min(1, 0.3 + 0.5 * Math.min(1, energy * energy)); + function drawField() { mech.fieldPhase += 0.007 + 0.07 * (1 - energy) const wiggle = 0.15 * Math.sin(mech.fieldPhase * 0.5) ctx.beginPath(); - ctx.ellipse(mech.pos.x, mech.pos.y, radius * (1 - wiggle), radius * (1 + wiggle), mech.fieldPhase, 0, 2 * Math.PI); + ctx.ellipse(mech.pos.x, mech.pos.y, mech.fieldDrawRadius * (1 - wiggle), mech.fieldDrawRadius * (1 + wiggle), mech.fieldPhase, 0, 2 * Math.PI); if (mech.fireCDcycle > mech.cycle && (keys[32] || game.mouseDownRight)) { ctx.lineWidth = 5; ctx.strokeStyle = `rgba(0, 204, 255,1)` @@ -1833,13 +1859,16 @@ const mech = { ctx.clip(); } + const energy = Math.max(0.01, Math.min(mech.energy, 1)) if (mech.isCloak) { this.fieldRange = this.fieldRange * 0.9 + 0.1 * drawRadius - drawField(this.fieldRange) + mech.fieldDrawRadius = this.fieldRange * Math.min(1, 0.3 + 0.5 * Math.min(1, energy * energy)); + drawField() } else { if (this.fieldRange < 3000) { this.fieldRange += 200 - drawField(this.fieldRange) + mech.fieldDrawRadius = this.fieldRange * Math.min(1, 0.3 + 0.5 * Math.min(1, energy * energy)); + drawField() } } if (mod.isIntangible) { diff --git a/todo.txt b/todo.txt index 6c4de8a..bfb2479 100644 --- a/todo.txt +++ b/todo.txt @@ -3,6 +3,10 @@ ************** TODO - n-gon ************** +exiting cloak gives +100 bonus damage for 2 seconds ++100 dmg while decloaked +damage mitigation while cloaked + add some more computer / AI stuff to the level lore text mod - mines stun targets nearby when they explode