diff --git a/js/bullets.js b/js/bullets.js index 0ab3c2e..0cd1689 100644 --- a/js/bullets.js +++ b/js/bullets.js @@ -721,7 +721,7 @@ const b = { { name: "spores", ammo: 0, - ammoPack: 6, + ammoPack: 7, have: false, fire() { const me = bullet.length; @@ -818,7 +818,7 @@ const b = { { name: "drones", ammo: 0, - ammoPack: 22, + ammoPack: 25, have: false, fire() { const MAX_SPEED = 6 @@ -851,7 +851,7 @@ const b = { //find mob targets if (!(game.cycle % this.lookFrequency)) { - this.close = null; + // this.close = null; this.lockedOn = null; this.isFollowMouse = true; //if no target is found default to follow mouse let closeDist = Infinity; @@ -865,7 +865,7 @@ const b = { const TARGET_VECTOR = Matter.Vector.sub(this.position, mob[i].position) const DIST = Matter.Vector.magnitude(TARGET_VECTOR); if (DIST < closeDist) { - this.close = mob[i].position; + // this.close = mob[i].position; closeDist = DIST; this.lockedOn = mob[i] this.isFollowMouse = false; @@ -900,7 +900,7 @@ const b = { { name: "wave beam", ammo: 0, - ammoPack: 110, + ammoPack: 120, have: false, fire() { const me = bullet.length; diff --git a/js/level.js b/js/level.js index d07358e..cc5d47c 100644 --- a/js/level.js +++ b/js/level.js @@ -13,7 +13,7 @@ const level = { // game.zoomScale = 1400 //1400 if (game.levelsCleared === 0) { this.intro(); //starting level - // b.giveGuns(12) // set a starting gun for testing + b.giveGuns(11) // set a starting gun for testing // game.levelsCleared = 3; //for testing to simulate all possible mobs spawns // this.bosses(); // this.testingMap(); @@ -353,6 +353,12 @@ const level = { spawn.wireKnee(); spawn.wireKneeLeft(); spawn.wireHead(); + + spawn.healer(1600, -500) + spawn.healer(1600, -500) + spawn.healer(1900, -500) + spawn.healer(1000, -500) + spawn.healer(1000, -400) }, rooftops() { diff --git a/js/spawn.js b/js/spawn.js index 55c045c..c0745e6 100644 --- a/js/spawn.js +++ b/js/spawn.js @@ -143,6 +143,63 @@ const spawn = { this.attraction(); }; }, + healer(x, y, radius = 20) { + //easy mob for on level 1 + mobs.spawn(x, y, 3, radius, "rgba(50,255,200,0.4)"); + let me = mob[mob.length - 1]; + me.frictionAir = 0.01; + me.accelMag = 0.0004; + me.lookFrequency = 100 + Math.floor(37 * Math.random()) + me.lockedOn = null; + Matter.Body.setDensity(me, 0.003) // normal density is 0.001 + + me.do = function () { + this.healthBar(); + + if (!(game.cycle % this.seePlayerFreq)) { + //slow self heal + // this.health += 0.03; + // if (this.health > 1) this.health = 1; + + //target mobs with low health + let closeDist = Infinity; + for (let i = 0; i < mob.length; i++) { + if (mob[i] != this && Matter.Query.ray(map, this.position, mob[i].position).length === 0) { + const TARGET_VECTOR = Matter.Vector.sub(this.position, mob[i].position) + const DIST = Matter.Vector.magnitude(TARGET_VECTOR) * mob[i].health * mob[i].health * mob[i].health; //distance is multiplied by mob health to prioritize low health mobs + if (DIST < closeDist) { + closeDist = DIST; + this.lockedOn = mob[i] + } + } + } + } + //move towards and heal locked on target + if (this.lockedOn) { //accelerate towards mobs + const TARGET_VECTOR = Matter.Vector.sub(this.position, this.lockedOn.position) + const DIST = Matter.Vector.magnitude(TARGET_VECTOR); + if (DIST > 200) { + this.force = Matter.Vector.mult(Matter.Vector.normalise(TARGET_VECTOR), -this.mass * this.accelMag) + } else { + if (this.lockedOn.health < 1) { + this.lockedOn.health += 0.002; + if (this.lockedOn.health > 1) this.lockedOn.health = 1; + //draw heal + ctx.beginPath(); + ctx.moveTo(this.position.x, this.position.y); + ctx.lineTo(this.lockedOn.position.x, this.lockedOn.position.y); + ctx.lineWidth = 10 + ctx.strokeStyle = "rgba(50,255,200,0.4)" + ctx.stroke(); + } + } + } + + //wander if no heal targets + + + }; + }, chaser(x, y, radius = 35 + Math.ceil(Math.random() * 40)) { mobs.spawn(x, y, 8, radius, "#2c9790"); let me = mob[mob.length - 1];