From 43a31a888288977d9326f40cfb74bcdb60e8d944 Mon Sep 17 00:00:00 2001 From: "Laetitia (O-01-67)" <68935009+O-01-67@users.noreply.github.com> Date: Sat, 10 Dec 2022 18:23:01 -0500 Subject: [PATCH] function onExplosionBreakOrSurvive fires if a pixel is broken by or survives an explosion --- mods/explodeAtPlus.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/mods/explodeAtPlus.js b/mods/explodeAtPlus.js index 4167ab67..34252672 100644 --- a/mods/explodeAtPlus.js +++ b/mods/explodeAtPlus.js @@ -1,3 +1,5 @@ +velocityBlacklist = []; + function explodeAtPlus(x,y,radius,fire="fire",smoke="smoke",beforeFunction=null,afterFunction=null,changeTemp=true) { // if fire contains , split it into an array if(fire !== null) { @@ -84,6 +86,9 @@ function explodeAtPlus(x,y,radius,fire="fire",smoke="smoke",beforeFunction=null, } // change the pixel to the result changePixel(pixel,result,changeTemp); + if(info.onExplosionBreakOrSurvive) { + info.onExplosionBreakOrSurvive(pixel,x,y,radius,fire,smoke,power,damage); + }; continue; } else { @@ -100,6 +105,10 @@ function explodeAtPlus(x,y,radius,fire="fire",smoke="smoke",beforeFunction=null, } continue; } + } else { + if(info.onExplosionBreakOrSurvive) { + info.onExplosionBreakOrSurvive(pixel,x,y,radius,fire,smoke,power,damage); + }; } if (damage > 0.75 && info.burn) { pixel.burning = true; @@ -107,6 +116,14 @@ function explodeAtPlus(x,y,radius,fire="fire",smoke="smoke",beforeFunction=null, } pixel.temp += damage*radius*power; pixelTempCheck(pixel); + if(enabledMods.includes("mods/velocity.js")) { + // set the pixel.vx and pixel.vy depending on the angle and power + if (!elements[pixel.element].excludeRandom && !elements[pixel.element].excludeVelocity) { + var angle = Math.atan2(pixel.y-y,pixel.x-x); + pixel.vx = Math.round((pixel.vx|0) + Math.cos(angle) * (radius * power/10)); + pixel.vy = Math.round((pixel.vy|0) + Math.sin(angle) * (radius * power/10)); + } + }; if(typeof(afterFunction) === "function") { //console.log(`running afterFunction ${afterFunction}`) //console.log(`arguments: ${pixel}, ${x}, ${y}, ${radius}, ${fire}, ${smoke}, ${power}, ${damage}`) @@ -115,4 +132,3 @@ function explodeAtPlus(x,y,radius,fire="fire",smoke="smoke",beforeFunction=null, }; }; }; -