neocognitron pulse aim

This commit is contained in:
landgreen
2020-06-25 18:47:21 -07:00
parent ffc5aa3e1e
commit 869102aebb
7 changed files with 143 additions and 109 deletions

View File

@@ -369,7 +369,7 @@ const b = {
stillCount: 0,
isArmed: false,
endCycle: Infinity,
lookFrequency: 41 + Math.floor(23 * Math.random()),
lookFrequency: 0,
range: 700,
onDmg() {},
do() {
@@ -423,26 +423,33 @@ const b = {
if (this.stillCount > 25) this.arm();
},
arm() {
this.isArmed = true
game.drawList.push({
//add dmg to draw queue
x: this.position.x,
y: this.position.y,
radius: 10,
color: "#f00",
time: 4
});
this.lookFrequency = game.cycle + 60
this.do = function () { //overwrite the do method for this bullet
this.force.y += this.mass * 0.002; //extra gravity
if (!(game.cycle % this.lookFrequency)) { //find mob targets
for (let i = 0, len = mob.length; i < len; ++i) {
if (Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position)) < 500000 &&
mob[i].dropPowerUp &&
Matter.Query.ray(map, 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
if (Math.random() < 0.8) isAmmoBack = false; //20% chance to get ammo back after detonation
if (game.cycle > this.lookFrequency) {
this.isArmed = true
this.lookFrequency = 50 + Math.floor(27 * Math.random())
game.drawList.push({
//add dmg to draw queue
x: this.position.x,
y: this.position.y,
radius: 10,
color: "#f00",
time: 4
});
this.do = function () { //overwrite the do method for this bullet
this.force.y += this.mass * 0.002; //extra gravity
if (!(game.cycle % this.lookFrequency)) { //find mob targets
for (let i = 0, len = mob.length; i < len; ++i) {
if (Vector.magnitudeSquared(Vector.sub(this.position, mob[i].position)) < 500000 &&
mob[i].dropPowerUp &&
Matter.Query.ray(map, 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
if (Math.random() < 0.8) isAmmoBack = false; //20% chance to get ammo back after detonation
}
}
}
}
}
@@ -726,7 +733,7 @@ const b = {
let closeDist = Infinity;
for (let i = 0, len = powerUp.length; i < len; ++i) {
if (
((powerUp[i].name !== "field" && powerUp[i].name !== "heal") || (powerUp[i].name === "heal" && mech.health < 0.9)) &&
((powerUp[i].name !== "field" && powerUp[i].name !== "heal") || (powerUp[i].name === "heal" && mech.health < 0.9 * mech.maxHealth)) &&
Matter.Query.ray(map, this.position, powerUp[i].position).length === 0 &&
Matter.Query.ray(body, this.position, powerUp[i].position).length === 0
) {
@@ -2714,32 +2721,40 @@ const b = {
v1: null,
v2: null
};
vertexCollision(path[0], path[1], mob);
vertexCollision(path[0], path[1], map);
vertexCollision(path[0], path[1], body);
if (best.dist2 != Infinity) { //if hitting something
path[path.length - 1] = {
x: best.x,
y: best.y
};
if (mod.isPulseAim) { //find mobs in line of sight
for (let i = 0, len = mob.length; i < len; i++) {
if (Vector.magnitude(Vector.sub(path[0], mob[i].position)) < 2200 &&
Matter.Query.ray(map, path[0], mob[i].position).length === 0 &&
Matter.Query.ray(body, path[0], mob[i].position).length === 0) {
best.who = mob[i]
path[path.length - 1] = mob[i].position
break
}
}
}
//use energy to explode
let energy;
if (mod.isRapidPulse) {
energy = 0.02 + 0.06 * Math.min(mech.energy, 1.75)
if (mech.energy < energy) return
if (!best.who) {
vertexCollision(path[0], path[1], mob);
vertexCollision(path[0], path[1], map);
vertexCollision(path[0], path[1], body);
if (best.dist2 != Infinity) { //if hitting something
path[path.length - 1] = {
x: best.x,
y: best.y
};
}
}
let energy
if (mod.isPulseAim) {
energy = 0.25 * Math.min(mech.energy, 1.75)
mech.energy -= energy * mod.isLaserDiode
if (best.who) b.explosion(path[1], 2000 * energy, true)
mech.fireCDcycle = mech.cycle + Math.floor(15 * b.fireCD); // cool down
if (best.who) b.explosion(path[1], 1000 * energy, true)
mech.fireCDcycle = mech.cycle + Math.floor(25 * b.fireCD); // cool down
} else {
energy = 0.3 * Math.min(mech.energy, 1.75)
mech.energy -= energy * mod.isLaserDiode
if (best.who) b.explosion(path[1], 1000 * energy, true)
mech.fireCDcycle = mech.cycle + Math.floor(50 * b.fireCD); // cool down
}
if (mod.isPulseStun) {
const range = 100 + 2000 * energy
for (let i = 0, len = mob.length; i < len; ++i) {

View File

@@ -17,9 +17,10 @@ const level = {
// game.enableConstructMode() //used to build maps in testing mode
// level.difficultyIncrease(9)
// mech.isStealth = true;
// mod.giveMod("necrophoresis");
// b.giveGuns("foam")
// mech.setField("time dilation field")
// mod.giveMod("logistics");
// mod.giveMod("supply chain");
// b.giveGuns("pulse")
// mech.setField("phase decoherence field")
level.intro(); //starting level
// level.testing();

View File

@@ -188,7 +188,7 @@ const mobs = {
onHit: undefined,
alive: true,
index: i,
health: 1,
health: mod.mobSpawnWithHealth,
showHealthBar: true,
accelMag: 0.001 * game.accelScale,
cd: 0, //game cycle when cooldown will be over
@@ -972,7 +972,7 @@ const mobs = {
this.health -= dmg
//this.fill = this.color + this.health + ')';
this.onDamage(dmg); //custom damage effects
if (this.health < mod.mobDieAtHealth && this.alive) this.death();
if (this.health < 0.05 && this.alive) this.death();
}
},
onDamage() {

View File

@@ -113,7 +113,7 @@ const mod = {
mods: [{
name: "capacitor",
// nameInfo: "<span id='mod-capacitor'></span>",
description: "increase <strong class='color-d'>damage</strong> based on stored <strong class='color-f'>energy</strong><br><strong>+1%</strong> <strong class='color-d'>damage</strong> for every <strong>5.5%</strong> <strong class='color-f'>energy</strong>",
description: "increase <strong class='color-d'>damage</strong> based on stored <strong class='color-f'>energy</strong><br><strong>1%</strong> <strong class='color-d'>damage</strong> for every <strong>5.5%</strong> <strong class='color-f'>energy</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -227,7 +227,7 @@ const mod = {
},
{
name: "auto-loading heuristics",
description: "<strong>+20%</strong> decreased <strong>delay</strong> after firing",
description: "<strong>20%</strong> decreased <strong>delay</strong> after firing",
maxCount: 9,
count: 0,
allowed() {
@@ -244,7 +244,7 @@ const mod = {
}
},
{
name: "electrostatic shots",
name: "electrostatic discharge",
description: "<strong>25%</strong> increased <strong class='color-d'>damage</strong><br><strong>25%</strong> increased <strong>delay</strong> after firing",
maxCount: 1,
count: 0,
@@ -329,7 +329,7 @@ const mod = {
},
{
name: "scrap bots",
description: "<strong>+12%</strong> chance to build a <strong>bot</strong> after killing a mob<br>the bot only functions until the end of the level",
description: "<strong>12%</strong> chance to build a <strong>bot</strong> after killing a mob<br>the bot only functions until the end of the level",
maxCount: 6,
count: 0,
allowed() {
@@ -421,7 +421,7 @@ const mod = {
},
{
name: "zoospore vector",
description: "mobs produce <strong class='color-p' style='letter-spacing: 2px;'>spores</strong> when they <strong>die</strong><br><strong>+11%</strong> chance",
description: "mobs produce <strong class='color-p' style='letter-spacing: 2px;'>spores</strong> when they <strong>die</strong><br><strong>11%</strong> chance",
maxCount: 9,
count: 0,
allowed() {
@@ -456,7 +456,7 @@ const mod = {
},
{
name: "impact shear",
description: "mobs release <strong>+2</strong> <strong>nails</strong> when they <strong>die</strong><br>nails target nearby mobs",
description: "mobs release <strong>2</strong> <strong>nails</strong> when they <strong>die</strong><br>nails target nearby mobs",
maxCount: 9,
count: 0,
allowed() {
@@ -472,18 +472,23 @@ const mod = {
},
{
name: "reaction inhibitor",
description: "mobs <strong>die</strong> if their life goes below <strong>12%</strong>",
maxCount: 1,
description: "mobs spawn with <strong>12%</strong> less <strong>health</strong>",
maxCount: 3,
count: 0,
allowed() {
return true
},
requires: "",
effect: () => {
mod.mobDieAtHealth = 0.15
mod.mobSpawnWithHealth *= 0.88
//set all mobs at full health to 0.85
for (let i = 0; i < mob.length; i++) {
if (mob.health > mod.mobSpawnWithHealth) mob.health = mod.mobSpawnWithHealth
}
},
remove() {
mod.mobDieAtHealth = 0.05;
mod.mobSpawnWithHealth = 1;
}
},
{
@@ -540,7 +545,7 @@ const mod = {
},
{
name: "Pauli exclusion",
description: `<strong>immune</strong> to <strong>harm</strong> for <strong>+1</strong> seconds<br>activates after being <strong>harmed</strong> from a collision`,
description: `<strong>immune</strong> to <strong>harm</strong> for <strong>1</strong> seconds<br>activates after being <strong>harmed</strong> from a collision`,
maxCount: 9,
count: 0,
allowed() {
@@ -654,7 +659,7 @@ const mod = {
},
{
name: "energy conservation",
description: "<strong>+13%</strong> of <strong class='color-d'>damage</strong> done recovered as <strong class='color-f'>energy</strong>",
description: "<strong>13%</strong> of <strong class='color-d'>damage</strong> done recovered as <strong class='color-f'>energy</strong>",
maxCount: 9,
count: 0,
allowed() {
@@ -670,7 +675,7 @@ const mod = {
},
{
name: "overcharge",
description: "increase your <strong>maximum</strong> <strong class='color-f'>energy</strong> by <strong>+50%</strong>",
description: "increase your <strong>maximum</strong> <strong class='color-f'>energy</strong> by <strong>50%</strong>",
maxCount: 9,
count: 0,
allowed() {
@@ -687,7 +692,7 @@ const mod = {
},
{
name: "entropy exchange",
description: "<strong class='color-h'>heal</strong> for <strong>+1.5%</strong> of <strong class='color-d'>damage</strong> done",
description: "<strong class='color-h'>heal</strong> for <strong>1.5%</strong> of <strong class='color-d'>damage</strong> done",
maxCount: 9,
count: 0,
allowed() {
@@ -703,7 +708,7 @@ const mod = {
},
{
name: "supersaturation",
description: "increase your <strong>maximum</strong> <strong class='color-h'>health</strong> by <strong>+50%</strong>",
description: "increase your <strong>maximum</strong> <strong class='color-h'>health</strong> by <strong>50%</strong>",
maxCount: 9,
count: 0,
allowed() {
@@ -754,7 +759,7 @@ const mod = {
},
{
name: "recursive healing",
description: "<strong class='color-h'>healing</strong> <strong>power ups</strong> trigger <strong>+1</strong> more time",
description: "<strong class='color-h'>healing</strong> <strong>power ups</strong> trigger <strong>1</strong> more time",
maxCount: 9,
count: 0,
allowed() {
@@ -837,6 +842,24 @@ const mod = {
mod.isAmmoForGun = false;
}
},
{
name: "supply chain",
description: "double your current <strong>ammo</strong> for all <strong>gun</strong>",
maxCount: 9,
count: 0,
isNonRefundable: true,
allowed() {
return mod.isAmmoForGun
},
requires: "logistics",
effect() {
for (let i = 0; i < b.guns.length; i++) {
if (b.guns[i].have) b.guns[i].ammo = Math.floor(2 * b.guns[i].ammo)
}
game.makeGunHUD();
},
remove() {}
},
{
name: "catabolism",
description: "gain <strong>ammo</strong> when you <strong>fire</strong> while <strong>out</strong> of <strong>ammo</strong><br>drains <strong>2%</strong> of <strong>max health</strong>",
@@ -987,7 +1010,7 @@ const mod = {
description: "<strong>remove</strong> all current <strong class='color-m'>mods</strong><br>spawn new <strong class='color-m'>mods</strong> to replace them",
maxCount: 1,
count: 0,
isNonRefundable: true,
// isNonRefundable: true,
allowed() {
return (mod.totalCount > 6) && !build.isCustomSelection
},
@@ -1045,7 +1068,7 @@ const mod = {
//**************************************************
{
name: "Lorentzian topology",
description: "your <strong>bullets</strong> last <strong>+33% longer</strong>",
description: "your <strong>bullets</strong> last <strong>33% longer</strong>",
maxCount: 3,
count: 0,
allowed() {
@@ -1061,7 +1084,7 @@ const mod = {
},
{
name: "microstates",
description: "<strong>+6%</strong> <strong class='color-d'>damage</strong> for every <strong>10</strong> active <strong>bullets</strong>",
description: "<strong>6%</strong> <strong class='color-d'>damage</strong> for every <strong>10</strong> active <strong>bullets</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -1098,7 +1121,7 @@ const mod = {
},
{
name: "depleted uranium rounds",
description: `your <strong>bullets</strong> are <strong>+18%</strong> larger<br>increased mass and physical <strong class='color-d'>damage</strong>`,
description: `your <strong>bullets</strong> are <strong>18%</strong> larger<br>increased mass and physical <strong class='color-d'>damage</strong>`,
count: 0,
maxCount: 9,
allowed() {
@@ -1195,7 +1218,7 @@ const mod = {
},
{
name: "super duper",
description: "fire <strong>+2</strong> additional <strong>super balls</strong>",
description: "fire <strong>2</strong> additional <strong>super balls</strong>",
maxCount: 9,
count: 0,
allowed() {
@@ -1357,7 +1380,7 @@ const mod = {
},
{
name: "high explosives",
description: "<strong class='color-e'>explosions</strong> do <strong>+20%</strong> more <strong class='color-d'>damage</strong><br><strong class='color-e'>explosive</strong> area is <strong>+44% larger</strong>",
description: "<strong class='color-e'>explosions</strong> do <strong>20%</strong> more <strong class='color-d'>damage</strong><br><strong class='color-e'>explosive</strong> area is <strong>44% larger</strong>",
maxCount: 3,
count: 0,
allowed() {
@@ -1389,7 +1412,7 @@ const mod = {
},
{
name: "recursion",
description: "after <strong>missiles</strong> <strong class='color-e'>explode</strong><br>they launch <strong>+1</strong> smaller <strong>missile</strong>",
description: "after <strong>missiles</strong> <strong class='color-e'>explode</strong><br>they launch <strong>1</strong> smaller <strong>missile</strong>",
maxCount: 9,
count: 0,
allowed() {
@@ -1441,7 +1464,7 @@ const mod = {
},
{
name: "fragmentation grenade",
description: "<strong>grenades</strong> are loaded with <strong>+5</strong> nails<br>on detonation <strong>nails</strong> are ejected towards mobs",
description: "<strong>grenades</strong> are loaded with <strong>5</strong> nails<br>on detonation <strong>nails</strong> are ejected towards mobs",
maxCount: 9,
count: 0,
allowed() {
@@ -1505,7 +1528,7 @@ const mod = {
},
{
name: "inertial confinement",
description: "<strong>neutron bomb's</strong> initial detonation <br><strong>stuns</strong> nearby mobs for <strong>+1</strong> seconds",
description: "<strong>neutron bomb's</strong> initial detonation <br><strong>stuns</strong> nearby mobs for <strong>1</strong> seconds",
maxCount: 3,
count: 0,
allowed() {
@@ -1699,7 +1722,7 @@ const mod = {
},
{
name: "specular reflection",
description: "<strong>laser</strong> beams gain <strong>+1</strong> reflection<br><strong>+50%</strong> laser <strong class='color-d'>damage</strong> and <strong class='color-f'>energy</strong> drain",
description: "<strong>laser</strong> beams gain <strong>1</strong> reflection<br><strong>50%</strong> laser <strong class='color-d'>damage</strong> and <strong class='color-f'>energy</strong> drain",
maxCount: 9,
count: 0,
allowed() {
@@ -1733,22 +1756,23 @@ const mod = {
mod.isPulseStun = false;
}
},
// {
// name: "aim",
// description: "<strong>pulse</strong> <strong class='color-e'>explosions</strong> aim",
// maxCount: 1,
// count: 0,
// allowed() {
// return mod.haveGunCheck("pulse")
// },
// requires: "pulse",
// effect() {
// mod.isPulseAim = true;
// },
// remove() {
// mod.isPulseAim = false;
// }
// },
{
name: "neocognitron",
description: "<strong>pulse</strong> automatically <strong>aims</strong> at a nearby mob<br><strong>50%</strong> decreased <strong>delay</strong> after firing",
maxCount: 1,
count: 0,
allowed() {
return mod.haveGunCheck("pulse")
},
requires: "pulse",
effect() {
mod.isPulseAim = true;
},
remove() {
mod.isPulseAim = false;
}
},
// {
// name: "fast ignition",
// description: "<strong>pulse</strong> <strong class='color-e'>explosions</strong> more <strong>efficient</strong><br><strong>delay</strong> after firing is <strong>shorter</strong>",
@@ -1771,7 +1795,7 @@ const mod = {
//**************************************************
{
name: "flux pinning",
description: "blocking with <strong>perfect diamagnetism</strong><br><strong>stuns</strong> mobs for <strong>+1</strong> second",
description: "blocking with <strong>perfect diamagnetism</strong><br><strong>stuns</strong> mobs for <strong>1</strong> second",
maxCount: 9,
count: 0,
allowed() {
@@ -2150,7 +2174,7 @@ const mod = {
laserDamage: null,
laserFieldDrain: null,
isAmmoFromHealth: null,
mobDieAtHealth: null,
mobSpawnWithHealth: null,
isEnergyRecovery: null,
isHealthRecovery: null,
isEnergyLoss: null,
@@ -2205,7 +2229,7 @@ const mod = {
isArmorFromPowerUps: null,
isAmmoForGun: null,
isRapidPulse: null,
// isPulseAim: null,
isPulseAim: null,
isSporeFreeze: null,
isShotgunRecoil: null,
isHealLowHealth: null

View File

@@ -1760,7 +1760,7 @@ const mech = {
// }
function drawField(radius) {
radius *= 0.9 + 1 * mech.energy;
radius *= 0.9 + 1.5 * mech.energy * mech.energy;
const rotate = mech.cycle * 0.005;
mech.fieldPhase += 0.5 - 0.5 * Math.sqrt(Math.max(0.01, Math.min(mech.energy, 1)));
const off1 = 1 + 0.06 * Math.sin(mech.fieldPhase);
@@ -1801,9 +1801,10 @@ const mech = {
mech.lookForPickUp();
if (mech.fieldCDcycle < mech.cycle) {
// game.draw.bodyFill = "transparent"
// game.draw.bodyStroke = "transparent"
const DRAIN = 0.0003 + 0.00015 * player.speed + ((!mod.renormalization && mech.fireCDcycle > mech.cycle) ? 0.005 : 0.001)
const DRAIN = 0.0002 + 0.0001 * player.speed + ((!mod.renormalization && mech.fireCDcycle > mech.cycle) ? 0.005 : 0.001)
if (mech.energy > DRAIN) {
mech.energy -= DRAIN;
// if (mech.energy < 0.001) {

View File

@@ -388,7 +388,7 @@ const powerUps = {
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "field");
return;
}
if (Math.random() < 0.005) {
if (Math.random() < 0.01) {
powerUps.spawn(x, y, "reroll");
if (Math.random() < mod.bayesian) powerUps.spawn(x, y, "reroll");
return;

View File

@@ -1,27 +1,20 @@
damage immunity after a collisions is reduced from 1/2s to 1/4s
freezing status effects only last 1/4 as long on boss mobs
mod - shotgun 66% increased fire rate and recoil
mod - slowly heal when below 25% health
mod - superdeterminism spawn 4 mods, but rerolls, fields, and guns no longer spawn
foam mod, necrophoresis now aims the foam bullets, which makes it more effective at groups
flechettes mod, piercing needles now goes through blocks as well as mobs
mod - spawn 3 ammo, rerolls, or heals after destroying a shield
rerolls drop 60% more often
mines delay a 1/2 second longer before they arm
mod: supply chain - doubles your current ammo, requires mod:logistics
mod: neocognitron - pulse auto aiming
************** TODO - n-gon **************
physics question: why don't the bound states of fields spread out. What is making them bound.
mobs killed by _____ always drops ammo
issues getting the code to work
rework reaction inhibitor to spawn mobs with 12% less life, rather then killing them at 12%
levels: make a function in the main game loop that runs level specific code
reset the level function as each new level loads
phase field still isn't fun
rework renormalization mod as well
does phase field need the stealth flag?
mod: use the stealth flag from the phase decoherence field
maybe trigger it along with the damage immunity CD
levels: make a function in the main game loop that runs level specific code
reset the level function as each new level loads
mod: efficient shielding (requires standing wave harmonics field)
lowers force applied when blocking mobs (instead of flinging them away, you push them like with plasma torch), but uses less energy to block mobs
and making it so liquid nitrogen and uranium reactor core have that effect in a radius around the player instead of on contact