double helix and timelike world line

This commit is contained in:
landgreen
2020-04-08 07:36:04 -07:00
parent ba5020889e
commit c7c8c0f2bd
5 changed files with 177 additions and 106 deletions

View File

@@ -75,6 +75,7 @@ const b = {
modGrenadeFragments: null,
isModEnergyDamage: null,
isModBotSpawner: null,
modWaveHelix: null,
modOnHealthChange() { //used with acid mod
if (b.isModAcidDmg && mech.health > 0.8) {
b.modAcidDmg = 0.7
@@ -1029,6 +1030,23 @@ const b = {
b.modWaveSpeedBody = 0.25
}
},
{
name: "double helix",
description: "<strong>wave beam</strong> emits <strong>two</strong> out of phase particles<br>wave particles do <strong>40%</strong> less <strong class='color-d'>damage</strong>",
maxCount: 1,
count: 0,
allowed() {
return b.haveGunCheck("wave beam")
},
requires: "wave beam",
effect() {
b.modWaveHelix = 2
},
remove() {
b.modWaveHelix = 1
}
},
{
name: "pocket universe",
description: "<strong>wave beam</strong> bullets last <strong>4</strong> times longer<br>bullets are <strong>confined</strong> to a <strong>region</strong> around player",
@@ -1131,7 +1149,7 @@ const b = {
},
{
name: "tinsellated flagella",
description: "<strong class='color-p' style='letter-spacing: 2px;'>spores</strong> accelerate <strong>33% faster</strong>",
description: "<strong class='color-p' style='letter-spacing: 2px;'>spores</strong> accelerate <strong>50% faster</strong>",
maxCount: 1,
count: 0,
allowed() {
@@ -1245,6 +1263,22 @@ const b = {
b.isModStunField = 0;
}
},
{
name: "timelike world line",
description: "<strong>time dilation</strong> increases your time <strong>rate</strong> by <strong>2x</strong><br>while <strong class='color-f'>energy</strong> <strong>drain</strong> is decreased by <strong>2x</strong>",
maxCount: 9,
count: 0,
allowed() {
return mech.fieldUpgrades[mech.fieldMode].name === "time dilation field"
},
requires: "time dilation field",
effect() {
b.isModTimeSkip = true;
},
remove() {
b.isModTimeSkip = false;
}
},
{
name: "plasma jet",
description: "increase <strong>plasma torch's</strong> range by <strong>33%</strong>",
@@ -1494,7 +1528,7 @@ const b = {
}
}
},
bulletActions() { //run in main loop
bulletRemove() { //run in main loop
//remove bullet if at end cycle for that bullet
let i = bullet.length;
while (i--) {
@@ -1508,7 +1542,8 @@ const b = {
}
}
}
//draw
},
bulletDraw() {
ctx.beginPath();
for (let i = 0, len = bullet.length; i < len; i++) {
let vertices = bullet[i].vertices;
@@ -1520,8 +1555,8 @@ const b = {
}
ctx.fillStyle = "#000";
ctx.fill();
//do bullet things
},
bulletDo() {
for (let i = 0, len = bullet.length; i < len; i++) {
bullet[i].do();
}
@@ -1962,7 +1997,7 @@ const b = {
angle: Math.random() * 2 * Math.PI,
friction: 0,
frictionAir: 0.025,
thrust: b.isModFastSpores ? 0.0008 : 0.0004,
thrust: b.isModFastSpores ? 0.001 : 0.0004,
dmg: 2.4, //damage done in addition to the damage from momentum
classType: "bullet",
collisionFilter: {
@@ -1971,7 +2006,7 @@ const b = {
},
endCycle: game.cycle + Math.floor((660 + Math.floor(Math.random() * 240)) * b.isModBulletsLastLonger),
minDmgSpeed: 0,
onDmg() {
onDmg(who) {
// mobs.statusPoison(who, 0.5, 180) // (2.2) * 1.3 * 30/180 // 6 ticks (3 seconds)
this.endCycle = 0; //bullet ends cycle after doing damage
},
@@ -2608,106 +2643,108 @@ const b = {
isStarterGun: true,
isEasyToAim: false,
fire() {
const me = bullet.length;
mech.fireCDcycle = mech.cycle + Math.floor(3 * b.modFireRate); // cool down
const dir = mech.angle
const SPEED = 10
const wiggleMag = mech.crouch ? 3 : 10
bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 7, 5 * b.modBulletSize, {
angle: dir,
cycle: 0,
endCycle: game.cycle + Math.floor((b.isModWaveReflect ? 480 : 120) * b.isModBulletsLastLonger),
inertia: Infinity,
frictionAir: 0,
slow: 0,
minDmgSpeed: 0,
dmg: 0,
isJustReflected: false,
classType: "bullet",
collisionFilter: {
category: 0,
mask: 0, //cat.mob | cat.mobBullet | cat.mobShield
},
onDmg() {},
onEnd() {},
do() {
if (!mech.isBodiesAsleep) {
let slowCheck = 1;
if (Matter.Query.point(map, this.position).length) { //check if inside map
slowCheck = b.modWaveSpeedMap
} else { //check if inside a body
let q = Matter.Query.point(body, this.position)
if (q.length) {
slowCheck = b.modWaveSpeedBody
Matter.Body.setPosition(this, Vector.add(this.position, q[0].velocity)) //move with the medium
} else { // check if inside a mob
q = Matter.Query.point(mob, this.position)
for (let i = 0; i < q.length; i++) {
slowCheck = 0.3;
Matter.Body.setPosition(this, Vector.add(this.position, q[i].velocity)) //move with the medium
let dmg = b.dmgScale * 0.45 / Math.sqrt(q[i].mass)
q[i].damage(dmg);
q[i].foundPlayer();
game.drawList.push({ //add dmg to draw queue
x: this.position.x,
y: this.position.y,
radius: Math.log(2 * dmg + 1.1) * 40,
color: 'rgba(0,0,0,0.4)',
time: game.drawTime
});
const wiggleMag = mech.crouch ? 5 : 12
for (let i = 0; i < b.modWaveHelix; i++) {
const me = bullet.length;
bullet[me] = Bodies.polygon(mech.pos.x + 25 * Math.cos(dir), mech.pos.y + 25 * Math.sin(dir), 7, 5 * b.modBulletSize, {
angle: dir,
cycle: -0.5,
endCycle: game.cycle + Math.floor((b.isModWaveReflect ? 480 : 120) * b.isModBulletsLastLonger),
inertia: Infinity,
frictionAir: 0,
slow: 0,
minDmgSpeed: 0,
dmg: 0,
isJustReflected: false,
classType: "bullet",
collisionFilter: {
category: 0,
mask: 0, //cat.mob | cat.mobBullet | cat.mobShield
},
onDmg() {},
onEnd() {},
do() {
if (!mech.isBodiesAsleep) {
let slowCheck = 1;
if (Matter.Query.point(map, this.position).length) { //check if inside map
slowCheck = b.modWaveSpeedMap
} else { //check if inside a body
let q = Matter.Query.point(body, this.position)
if (q.length) {
slowCheck = b.modWaveSpeedBody
Matter.Body.setPosition(this, Vector.add(this.position, q[0].velocity)) //move with the medium
} else { // check if inside a mob
q = Matter.Query.point(mob, this.position)
for (let i = 0; i < q.length; i++) {
slowCheck = 0.3;
Matter.Body.setPosition(this, Vector.add(this.position, q[i].velocity)) //move with the medium
let dmg = b.dmgScale * 0.43 / Math.sqrt(q[i].mass) * (b.modWaveHelix ? 0.6 : 1) //1 - 0.4 = 0.6 for helix mod 40% damage reduction
q[i].damage(dmg);
q[i].foundPlayer();
game.drawList.push({ //add dmg to draw queue
x: this.position.x,
y: this.position.y,
radius: Math.log(2 * dmg + 1.1) * 40,
color: 'rgba(0,0,0,0.4)',
time: game.drawTime
});
}
}
}
if (slowCheck !== this.slow) { //toggle velocity based on inside and outside status change
this.slow = slowCheck
Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), SPEED * slowCheck));
}
this.cycle++
const wiggle = Vector.mult(transverse, wiggleMag * Math.cos(this.cycle * 0.35) * ((i % 2) ? -1 : 1))
Matter.Body.setPosition(this, Vector.add(this.position, wiggle))
}
if (slowCheck !== this.slow) { //toggle velocity based on inside and outside status change
this.slow = slowCheck
Matter.Body.setVelocity(this, Vector.mult(Vector.normalise(this.velocity), SPEED * slowCheck));
// if (b.isModWaveReflect) { //single reflection
// const sub = Vector.sub(this.position, mech.pos)
// if (Vector.magnitude(sub) > 630) {
// // Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side
// if (!this.isJustReflected) {
// Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect
// this.isJustReflected = true;
// }
// }
// }
if (b.isModWaveReflect) {
Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player
const sub = Vector.sub(this.position, mech.pos)
if (Vector.magnitude(sub) > 630) {
Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * 630))) //teleport to opposite side
}
}
this.cycle++
const wiggle = Vector.mult(transverse, wiggleMag * Math.cos(this.cycle * 0.35))
Matter.Body.setPosition(this, Vector.add(this.position, wiggle))
// if (b.isModWaveReflect) {
// Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player
// Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side
// const sub = Vector.sub(this.position, mech.pos)
// if (Vector.magnitude(sub) > 630) {
// if (!this.isJustReflected) {
// Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect
// this.isJustReflected = true;
// }
// } else {
// this.isJustReflected = false
// }
// }
}
// if (b.isModWaveReflect) { //single reflection
// const sub = Vector.sub(this.position, mech.pos)
// if (Vector.magnitude(sub) > 630) {
// // Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side
// if (!this.isJustReflected) {
// Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect
// this.isJustReflected = true;
// }
// }
// }
if (b.isModWaveReflect) {
Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player
const sub = Vector.sub(this.position, mech.pos)
if (Vector.magnitude(sub) > 630) {
Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * 630))) //teleport to opposite side
}
}
// if (b.isModWaveReflect) {
// Matter.Body.setPosition(this, Vector.add(this.position, player.velocity)) //bullets move with player
// Matter.Body.setPosition(this, Vector.add(this.position, Vector.mult(Vector.normalise(sub), -2 * POCKET_RANGE))) //teleport to opposite side
// const sub = Vector.sub(this.position, mech.pos)
// if (Vector.magnitude(sub) > 630) {
// if (!this.isJustReflected) {
// Matter.Body.setVelocity(this, Vector.mult(this.velocity, -1)); //reflect
// this.isJustReflected = true;
// }
// } else {
// this.isJustReflected = false
// }
// }
}
});
World.add(engine.world, bullet[me]); //add bullet to world
mech.fireCDcycle = mech.cycle + Math.floor(3 * b.modFireRate); // cool down
Matter.Body.setVelocity(bullet[me], {
x: SPEED * Math.cos(dir),
y: SPEED * Math.sin(dir)
});
const transverse = Vector.normalise(Vector.perp(bullet[me].velocity))
});
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)
});
const transverse = Vector.normalise(Vector.perp(bullet[me].velocity))
}
}
},
{
@@ -3032,7 +3069,7 @@ const b = {
name: "drones", //11
description: "deploy drones that <strong>crash</strong> into mobs<br>collisions reduce their <strong>lifespan</strong> by 1 second",
ammo: 0,
ammoPack: 11,
ammoPack: 12,
have: false,
isStarterGun: true,
isEasyToAim: true,