buff planet crackers

also readd hiding
This commit is contained in:
An Orbit 2024-06-28 13:23:18 -04:00 committed by GitHub
parent f0c0837b4c
commit 612e423984
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 167 additions and 120 deletions

View File

@ -5504,6 +5504,8 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
}
};
hiding = false
runAfterAutogen(function() {
//rAA because velocity.js already puts its redef in a rAL and rAA comes after that
drawPixels = function(forceTick=false) {
@ -5567,6 +5569,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
};
ctx.fillRect(0, 0, canvas.width, canvas.height);
}
if(!hiding) {
var pixelDrawList = pixelsFirst.concat(pixelsLast);
for (var i = 0; i < pixelDrawList.length; i++) {
var pixel = pixelDrawList[i];
@ -5575,7 +5578,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
if((typeof(pixel.color) !== "string") || (pixel.color.indexOf("NaN") >= 0)) {
pixel.color = pixelColorPick(pixel)
};
if(pixel.color.length <= 7) { //hex triplets as colors seem to break some mods and can't be allowed
if(pixel.color.length <= 7) { //hex triplets as rgb colors seem to break some mods and can't be allowed
pixel.color = convertColorFormats(pixel.color,"rgb")
};
var colorFunction = viewColorFunctions[view] ?? normalColorFunction;
@ -5697,6 +5700,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
};
}
}
}
};
if (ctx.globalAlpha < 1) {
ctx.globalAlpha = 1;
@ -11214,23 +11218,41 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
pixel.vy *= 2;
};
};
function planetCrackerFinale(doColorChange=true) {
function planetCrackerFinale(doColorChange=true,spawnElements=null) {
var bottomFortyPercent = Math.round(height * 0.6);
var bottomTwentyPercent = Math.round(height * 0.8);
var bottomTenPercent = Math.round(height * 0.9);
if(typeof(spawnElements) == "string") {
if(spawnElements.indexOf(",") >= 0) {
spawnElements = spawnElements.split(",")
} else { spawnElements = [spawnElements] };
};
if(Array.isArray(spawnElements)) {
spawnElements = spawnElements.filter(n => elementExists(n));
if(spawnElements.length == 0) {
spawnElements = null
}
};
var doSpawning = (spawnElements !== null);
for(x = 1; x < width; x++) {
for(y = bottomFortyPercent; y < height; y++) {
var chance = y > bottomTwentyPercent ? 0.03 : 0.01
var radius = y > bottomTwentyPercent ? 8 : 6
if(!isEmpty(x,y,true)) {
pixelMap[x][y].vy ??= 0;
pixelMap[x][y].vy -= 20;
var newPixel = pixelMap[x]?.[y];
if(doSpawning && y > bottomTenPercent && isEmpty(x,y,false) && (Math.random() < 0.6)) {
var _np = tryCreatePixelReturn(randomChoice(spawnElements),x,y);
if(_np) { newPixel = _np }
};
if(y > bottomTenPercent && !isEmpty(x,y,true)) {
pixelMap[x][y].temp += 2000;
if(newPixel) {
newPixel.vy ??= 0;
newPixel.vy -= 20;
};
if(newPixel && y > bottomTenPercent) {
newPixel.temp += 2000;
pixelTempCheck(newPixel)
};
if(Math.random() < chance) {
explodeAt(x,y,radius,"plasma");
explodeAt(x,y,radius,spawnElements ? ((",plasma".repeat(spawnElements.length * 14).replace(",","")) + "," + spawnElements.join(",")) : "plasma");
};
};
};
@ -11251,21 +11273,46 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
return;
};
if(outOfBounds(pixel.x,pixel.y+pixel.counter)) {
planetCrackerFinale();
planetCrackerFinale(true,pixel._bottomStateHighCache ?? null);
pixel.active = false;
changePixel(pixel,"metal_scrap");
};
if(pixel.active) {
pixel._bottomStateHighCache ??= [];
pixel._bottomStateHighCache = currentPixels.filter(p => p.y == height - 1).map(p => p.element);
var bshcUniques = Array.from(new Set(pixel._bottomStateHighCache));
pixel._bottomStateHighCache = bshcUniques.filter(elemNameToFilterBy => (pixel._bottomStateHighCache.filter(elemName => elemName == elemNameToFilterBy).length >= (pixel._bottomStateHighCache.length / 10)));
pixel._bottomStateHighCache = pixel._bottomStateHighCache.map(elemName => getStateHigh(elemName) ?? elemName);
var pixelDistanceFromBottom = height - pixel.y;
var counterDistanceFromBottom = height - (pixel.y + pixel.counter);
var yRisingFromBottomToHalfway = Math.round((height - 1) - (pixel.counter / 2));
var closenessToBottom = 1 - (counterDistanceFromBottom / pixelDistanceFromBottom);
//console.log(closenessToBottom);
var finalRadius = Math.round(((1 + closenessToBottom) ** 2) * 6);
if(typeof(explodeAtPlus) === "function") {
explodeAtPlus(pixel.x,pixel.y+pixel.counter,finalRadius,"plasma","fire",null,planetCrackerHeat);
} else {
explodeAt(pixel.x,pixel.y+pixel.counter,finalRadius,"plasma");
var earthquakeChance = ((closenessToBottom >= 0.5) && (0.1 + (0.05 * (1 + (Math.max(closenessToBottom - 0.5,0) * 25)))))
var earthquakeMaxTryCount = 2 + (Math.random() < (closenessToBottom - 0.5)) + (Math.random() < (closenessToBottom - 0.75)) + (Math.random() < earthquakeChance) + (Math.random() < (earthquakeChance ** 2));
for(var i = 0; i < earthquakeMaxTryCount; i++) {
if((closenessToBottom >= 0.5) && (Math.random() < earthquakeChance)) { //random earthquake
var rX = (Math.floor(Math.random() * (width - 1)) + 1);
var rY = Math.round(height / 2) + Math.floor(Math.random() * height / 2);
var eq = createOrChangePixelAndReturn("earthquake",rX,rY);
if(eq) {
eq.stage = 1;
eq.mag = Math.floor(Math.random() * ((5 * (1 + (Math.max(closenessToBottom - 0.5,0) * 2.5))) + 1)) + 15;
}
}
};
for(var x = 1; x < width; x++) {
var y = yRisingFromBottomToHalfway;
if(isEmpty(x,y,true)) { continue };
var newPixel = pixelMap[x][y];
newPixel.temp += 400 + ((1 - closenessToBottom) * 100);
pixelTempCheck(newPixel)
};
explodeAtPlus(pixel.x,pixel.y+pixel.counter,finalRadius,"plasma","fire",null,planetCrackerHeat);
pixel.counter++;
};
},