block damage disabled

This commit is contained in:
landgreen
2020-04-21 07:23:39 -07:00
parent 31316c430f
commit 8cd1078293
2 changed files with 33 additions and 33 deletions

View File

@@ -87,40 +87,40 @@ function collisionChecks(event) {
//body + player collision //body + player collision
if (game.isBodyDamage) { // if (game.isBodyDamage) {
if (pairs[i].bodyA === playerBody || pairs[i].bodyA === playerHead) { // if (pairs[i].bodyA === playerBody || pairs[i].bodyA === playerHead) {
collidePlayer(pairs[i].bodyB) // collidePlayer(pairs[i].bodyB)
} else if (pairs[i].bodyB === playerBody || pairs[i].bodyB === playerHead) { // } else if (pairs[i].bodyB === playerBody || pairs[i].bodyB === playerHead) {
collidePlayer(pairs[i].bodyA) // collidePlayer(pairs[i].bodyA)
} // }
} // }
function collidePlayer(obj) { // function collidePlayer(obj) {
//player dmg from hitting a body // //player dmg from hitting a body
if (obj.classType === "body" && mech.collisionImmuneCycle < mech.cycle) { // if (obj.classType === "body" && mech.collisionImmuneCycle < mech.cycle) {
const velocityThreshold = 13 // const velocityThreshold = 13
if (player.position.y > obj.position.y) { //block is above the player look at total momentum difference // if (player.position.y > obj.position.y) { //block is above the player look at total momentum difference
const velocityDiffMag = Vector.magnitude(Vector.sub(player.velocity, obj.velocity)) // const velocityDiffMag = Vector.magnitude(Vector.sub(player.velocity, obj.velocity))
if (velocityDiffMag > velocityThreshold) hit(velocityDiffMag - velocityThreshold) // if (velocityDiffMag > velocityThreshold) hit(velocityDiffMag - velocityThreshold)
} else { //block is below player only look at horizontal momentum difference // } else { //block is below player only look at horizontal momentum difference
const velocityDiffMagX = Math.abs(obj.velocity.x - player.velocity.x) // const velocityDiffMagX = Math.abs(obj.velocity.x - player.velocity.x)
if (velocityDiffMagX > velocityThreshold) hit(velocityDiffMagX - velocityThreshold) // if (velocityDiffMagX > velocityThreshold) hit(velocityDiffMagX - velocityThreshold)
} // }
function hit(dmg) { // function hit(dmg) {
mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles // mech.collisionImmuneCycle = mech.cycle + b.modCollisionImmuneCycles; //player is immune to collision damage for 30 cycles
dmg = Math.min(Math.max(Math.sqrt(dmg) * obj.mass * 0.01, 0.02), 0.15); // dmg = Math.min(Math.max(Math.sqrt(dmg) * obj.mass * 0.01, 0.02), 0.15);
mech.damage(dmg); // mech.damage(dmg);
game.drawList.push({ //add dmg to draw queue // game.drawList.push({ //add dmg to draw queue
x: pairs[i].activeContacts[0].vertex.x, // x: pairs[i].activeContacts[0].vertex.x,
y: pairs[i].activeContacts[0].vertex.y, // y: pairs[i].activeContacts[0].vertex.y,
radius: dmg * 500, // radius: dmg * 500,
color: game.mobDmgColor, // color: game.mobDmgColor,
time: game.drawTime // time: game.drawTime
}); // });
} // }
} // }
} // }
// function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) { // function collidePlayer(obj, speedThreshold = 12, massThreshold = 2) {
// //player dmg from hitting a body // //player dmg from hitting a body

View File

@@ -1938,7 +1938,7 @@ const mech = {
}, },
{ {
name: "pilot wave", name: "pilot wave",
description: "use <strong class='color-f'>energy</strong> to push <strong>blocks</strong> with your mouse<br><strong>immune</strong> to <strong class='color-d'>damage</strong> from block <strong>collisions</strong>", description: "use <strong class='color-f'>energy</strong> to push <strong>blocks</strong> with your mouse<br>field <strong>radius</strong> decreases out of <strong>line of sight</strong>",
isEasyToAim: false, isEasyToAim: false,
effect: () => { effect: () => {
game.replaceTextLog = true; //allow text over write game.replaceTextLog = true; //allow text over write