New properties: fireSpawnTemp, fireSpawnChance

temp is obvious
chance is int 0-100 (default 10)
This commit is contained in:
Laetitia (O-01-67) 2022-12-06 15:13:43 -05:00 committed by GitHub
parent 005389b9bc
commit 0d9e39384b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 19 additions and 5 deletions

View File

@ -20,7 +20,20 @@ function doBurning(pixel) {
fire = fire[Math.floor(Math.random()*fire.length)];
}
//End fire getter block
fireIsCold = (fire === "cold_fire");
//Fire temp getter block
var fireTemp = info.fireSpawnTemp;
if (fireTemp == undefined) {
fireTemp = pixel.temp;
};
//End fire temp getter block
//Fire chance getter block
var fireChance = info.fireSpawnChance;
if (fireChance == undefined) {
fireChance = 10;
};
//End fire chance getter block
var fireIsCold = (fire === "cold_fire");
var fireInfo = elements[fire];
pixel.temp += burnTempChange;
pixelTempCheck(pixel);
@ -42,7 +55,6 @@ function doBurning(pixel) {
//End fire getter block
newFireIsCold = (newFire === "cold_fire");
//console.log(`burning pixel ${pixel.element}: ${fire} (${fireIsCold}) / burned element ${newPixel.element}: ${newFire} (${newFireIsCold})`);
if((!fireIsCold && !newFireIsCold) || (fireIsCold && newFireIsCold)) {
if (elements[newPixel.element].burn && !newPixel.burning) {
@ -71,21 +83,23 @@ function doBurning(pixel) {
pixel.color = pixelColorPick(pixel)
}
}
else if (Math.floor(Math.random()*100)<10 && !fireSpawnBlacklist.includes(pixel.element)) { // Spawn fire
else if (Math.floor(Math.random()*100)<fireChance && !fireSpawnBlacklist.includes(pixel.element)) { // Spawn fire
if (isEmpty(pixel.x,pixel.y-1)) {
createPixel(fire,pixel.x,pixel.y-1);
pixelMap[pixel.x][pixel.y-1].temp = fireTemp;
pixelMap[pixel.x][pixel.y-1].temp = pixel.temp//+(pixelTicks - (pixel.burnStart || 0));
if (info.fireColor != undefined) {
pixelMap[pixel.x][pixel.y-1].color = pixelColorPick(pixelMap[pixel.x][pixel.y-1],info.fireColor);
}
};
}
// same for below if top is blocked
else if (isEmpty(pixel.x,pixel.y+1)) {
createPixel(fire,pixel.x,pixel.y+1);
pixelMap[pixel.x][pixel.y+1].temp = fireTemp;
pixelMap[pixel.x][pixel.y+1].temp = pixel.temp//+(pixelTicks - (pixel.burnStart || 0));
if (info.fireColor != undefined) {
pixelMap[pixel.x][pixel.y+1].color = pixelColorPick(pixelMap[pixel.x][pixel.y+1],info.fireColor);
}
};
}
}
}