restore explosions' ability to break things
This commit is contained in:
parent
dc5af85d9f
commit
29700ac733
|
|
@ -14,7 +14,7 @@ try {
|
||||||
|
|
||||||
//ESSENTIAL COMMON FUNCTIONS (CODE LIBRARY) ##
|
//ESSENTIAL COMMON FUNCTIONS (CODE LIBRARY) ##
|
||||||
|
|
||||||
//U.R.L.
|
//URL
|
||||||
|
|
||||||
urlParams = new URLSearchParams(window.location.search);
|
urlParams = new URLSearchParams(window.location.search);
|
||||||
|
|
||||||
|
|
@ -616,9 +616,10 @@ try {
|
||||||
throw new Error("Offset is NaN");
|
throw new Error("Offset is NaN");
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var oldColor = color; //for error display
|
||||||
color = hexToRGB(color);
|
color = hexToRGB(color);
|
||||||
if(color === null) {
|
if(color === null) {
|
||||||
throw new Error("hexToRGB(color) was null (maybe it's an invalid hex triplet?)");
|
throw new Error(`hexToRGB(color) was null (${oldColor}, maybe it's an invalid hex triplet?)`);
|
||||||
};
|
};
|
||||||
|
|
||||||
//console.log("converted color: " + JSON.stringify(color));
|
//console.log("converted color: " + JSON.stringify(color));
|
||||||
|
|
@ -772,9 +773,10 @@ try {
|
||||||
};
|
};
|
||||||
//console.log(`octothorpe checked: ${color}`);
|
//console.log(`octothorpe checked: ${color}`);
|
||||||
|
|
||||||
|
var oldColor = color;
|
||||||
color = hexToRGB(color);
|
color = hexToRGB(color);
|
||||||
if(color === null) {
|
if(color === null) {
|
||||||
throw new Error("hexToRGB(color) was null (maybe it's an invalid hex triplet?)");
|
throw new Error(`hexToRGB(color) was null (${oldColor}, maybe it's an invalid hex triplet?)`);
|
||||||
};
|
};
|
||||||
|
|
||||||
switch(outputType.toLowerCase()) {
|
switch(outputType.toLowerCase()) {
|
||||||
|
|
@ -1498,18 +1500,29 @@ try {
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function breakPixel(pixel,changetemp=false) {
|
function breakPixel(pixel,changeTemp=false,defaultBreakIntoDust=false) {
|
||||||
var info = elements[pixel.element];
|
var result = elements[pixel.element].breakInto;
|
||||||
if(typeof(info.breakInto) === "undefined") {
|
if (result === undefined) {if(defaultBreakIntoDust) { result = "dust" } else { return }};
|
||||||
return false;
|
// if it is an array, choose a random item, else just use the value
|
||||||
|
while (Array.isArray(result)) {
|
||||||
|
result = randomChoice(result);
|
||||||
};
|
};
|
||||||
var breakIntoElement = info.breakInto;
|
// change the pixel to the result
|
||||||
if(Array.isArray(breakIntoElement)) {
|
if (result === null) {
|
||||||
breakIntoElement = breakIntoElement[Math.floor(Math.random() * breakIntoElement.length)]
|
deletePixel(pixel.x,pixel.y);
|
||||||
|
return
|
||||||
};
|
};
|
||||||
changePixel(pixel,breakIntoElement,changetemp)
|
if (elements[pixel.element].breakIntoColor) {
|
||||||
};
|
var oldelement = pixel.element;
|
||||||
|
changePixel(pixel,result);
|
||||||
|
pixel.color = pixelColorPick(pixel, elements[oldelement].breakIntoColor);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
changePixel(pixel,result);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
defaultHardness = 0.3;
|
||||||
function tryBreak(pixel,changetemp=false,defaultBreakIntoDust=false) {
|
function tryBreak(pixel,changetemp=false,defaultBreakIntoDust=false) {
|
||||||
var info = elements[pixel.element];
|
var info = elements[pixel.element];
|
||||||
var hardness = defaultHardness;
|
var hardness = defaultHardness;
|
||||||
|
|
@ -2052,6 +2065,26 @@ try {
|
||||||
}*/
|
}*/
|
||||||
};
|
};
|
||||||
|
|
||||||
|
//Language
|
||||||
|
|
||||||
|
function englishFormatList(thingsArrayIn) {
|
||||||
|
var thingsArray = thingsArrayIn;
|
||||||
|
var amount = thingsArray.length;
|
||||||
|
if(amount == 1) {
|
||||||
|
return thingsArray[0]
|
||||||
|
} else if(amount == 2) {
|
||||||
|
return thingsArray.join(" and ")
|
||||||
|
} else {
|
||||||
|
var lastItem = thingsArray[thingsArray.length - 1];
|
||||||
|
thingsArray[thingsArray.length - 1] = "and " + lastItem;
|
||||||
|
return thingsArray.join(", ")
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
function capitalizeFirstLetter(string,locale=null) {
|
||||||
|
return string[0][locale ? "toLocaleUpperCase" : "toUpperCase"](locale) + string.slice(1)
|
||||||
|
};
|
||||||
|
|
||||||
//COLOR MANIPULATION TOOLS ##
|
//COLOR MANIPULATION TOOLS ##
|
||||||
|
|
||||||
var colorToolCounter = 0;
|
var colorToolCounter = 0;
|
||||||
|
|
@ -3592,18 +3625,17 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
else if (damage > 0.25) {
|
else if (damage > 0.25) {
|
||||||
if (info.breakInto) {
|
if (info.breakInto) {
|
||||||
// if it is an array, choose a random item, else just use the value
|
// if it is an array, choose a random item, else just use the value
|
||||||
if (Array.isArray(info.breakInto)) {
|
if (info.breakInto !== undefined) {
|
||||||
var result = info.breakInto[Math.floor(Math.random() * info.breakInto.length)];
|
breakPixel(pixel);
|
||||||
|
} else {
|
||||||
|
if (Array.isArray(fire)) {
|
||||||
|
var newfire = fire[Math.floor(Math.random() * fire.length)];
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
var newfire = fire;
|
||||||
|
}
|
||||||
|
changePixel(pixel,newfire);
|
||||||
}
|
}
|
||||||
else {
|
|
||||||
var result = info.breakInto;
|
|
||||||
}
|
|
||||||
if(typeof(breakIntoElement) === "undefined") {
|
|
||||||
deletePixel(pixel.x,pixel.y);
|
|
||||||
continue
|
|
||||||
};
|
|
||||||
// change the pixel to the result
|
|
||||||
changePixel(pixel,result,changeTemp);
|
|
||||||
if(info.onExplosionBreakOrSurvive) {
|
if(info.onExplosionBreakOrSurvive) {
|
||||||
info.onExplosionBreakOrSurvive(pixel,x,y,radius,fire,smoke,power,damage);
|
info.onExplosionBreakOrSurvive(pixel,x,y,radius,fire,smoke,power,damage);
|
||||||
};
|
};
|
||||||
|
|
@ -4247,6 +4279,9 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
ignoreAir: true
|
ignoreAir: true
|
||||||
};
|
};
|
||||||
|
|
||||||
|
elements.cloner.burnTime = Infinity;
|
||||||
|
elements.cloner.burnInto = "cloner";
|
||||||
|
|
||||||
elements.cold_torch = {
|
elements.cold_torch = {
|
||||||
"color": "#4394d6",
|
"color": "#4394d6",
|
||||||
"behavior": [
|
"behavior": [
|
||||||
|
|
@ -7951,7 +7986,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
state: "gas",
|
state: "gas",
|
||||||
density: 550,
|
density: 550,
|
||||||
tick: function(pixel) {
|
tick: function(pixel) {
|
||||||
if(pixel.y % 6 == 0) {
|
if(pixel.y % 6 == 0) { //7989 yay soshi!
|
||||||
if(pixel.x % 6 == 0) {
|
if(pixel.x % 6 == 0) {
|
||||||
pixel.color = "rgb(255,255,255)"
|
pixel.color = "rgb(255,255,255)"
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -8019,7 +8054,7 @@ color1 and color2 spread through striped paint like dye does with itself. <u>col
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if(!settings.bg || settings.bg == "#fffff0") { //7989 yay soshi!
|
if(!settings.bg || settings.bg == "#fffff0") {
|
||||||
pixel.color = "rgb(255,255,247)"
|
pixel.color = "rgb(255,255,247)"
|
||||||
} else {
|
} else {
|
||||||
pixel.color = "rgb(255,255,240)"
|
pixel.color = "rgb(255,255,240)"
|
||||||
|
|
@ -18083,7 +18118,63 @@ Pixel size (rendering only): <input id="pixelSize"> (Use if the save looks cut o
|
||||||
elements[kesddfroged2[i]].reactions ??= {}; elements[kesddfroged2[i]].reactions[kesddfroged[j]] = {"elem1": "kurshuth_alloy", "elem2": "kurshuth_alloy"}
|
elements[kesddfroged2[i]].reactions ??= {}; elements[kesddfroged2[i]].reactions[kesddfroged[j]] = {"elem1": "kurshuth_alloy", "elem2": "kurshuth_alloy"}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
})
|
});
|
||||||
|
|
||||||
|
function newMetal(name,color,meltingPoint,boilingPoint,hardness,density,gasDensity,conduct) {
|
||||||
|
var temp = {
|
||||||
|
"name": name,
|
||||||
|
"color": color,
|
||||||
|
"meltingPoint": meltingPoint,
|
||||||
|
"boilingPoint": boilingPoint,
|
||||||
|
"hardness": hardness,
|
||||||
|
"density": density,
|
||||||
|
"gasDensity": gasDensity,
|
||||||
|
"conduct": conduct
|
||||||
|
};
|
||||||
|
var tempNulls = Object.keys(temp).filter(key => (typeof(temp[key]) == undefined || temp[key] == null));
|
||||||
|
if(tempNulls.length > 0) {
|
||||||
|
var errorMessage = capitalizeFirstLetter(englishFormatList(tempNulls));
|
||||||
|
throw new Error(`newMetal: ${errorMessage} {tempNulls.length == 1 ? "is" : "are"} required (generating "${name}")`);
|
||||||
|
};
|
||||||
|
|
||||||
|
elements[name] = {
|
||||||
|
"color": color,
|
||||||
|
"behavior": behaviors.WALL,
|
||||||
|
"category": "solids",
|
||||||
|
"state": "solid",
|
||||||
|
"density": density,
|
||||||
|
"conduct": conduct,
|
||||||
|
"tempHigh": meltingPoint,
|
||||||
|
"breakInto": `${name}_scrap`,
|
||||||
|
"hardness": hardness
|
||||||
|
};
|
||||||
|
|
||||||
|
elements[`molten_${name}`] = {
|
||||||
|
"tempHigh": boilingPoint
|
||||||
|
};
|
||||||
|
|
||||||
|
elements[`${name}_gas`] = {
|
||||||
|
"density": gasDensity
|
||||||
|
};
|
||||||
|
|
||||||
|
elements[`${name}_scrap`] = {
|
||||||
|
"color": gravelizeToHex(elements[name].color),
|
||||||
|
"behavior": behaviors.POWDER,
|
||||||
|
"tempHigh": meltingPoint,
|
||||||
|
"stateHigh": name,
|
||||||
|
"category": "powders",
|
||||||
|
"hidden": true,
|
||||||
|
"density": density * 0.09,
|
||||||
|
"conduct": conduct * 0.4,
|
||||||
|
"movable": true,
|
||||||
|
};
|
||||||
|
|
||||||
|
return [elements[name],elements[`${name}_scrap`]];
|
||||||
|
};
|
||||||
|
|
||||||
|
//newMetal( "exidmaden", ["#F8EDCF", "#EEAAAE", "#E5678D", "#A6659C", "#6763AD"], 2134, 6769, 0.8, 32333, 49.9, 0.88 );
|
||||||
|
//newMetal( "jisooium", "#9d0ac2", 8367, 10003, 0.63, 15024, 12.2, 0.9 );
|
||||||
|
newMetal( "twicium", ["#F9C596", "#FC5D9D"], 10240, 18018, 0.88, 29029, 24.3, 0.91 );
|
||||||
|
|
||||||
//ASSORTED LOONA-THEMED MATERIALS ##
|
//ASSORTED LOONA-THEMED MATERIALS ##
|
||||||
|
|
||||||
|
|
@ -20401,7 +20492,7 @@ Pixel size (rendering only): <input id="pixelSize"> (Use if the save looks cut o
|
||||||
if(typeof(elements[thing]) == "object") {
|
if(typeof(elements[thing]) == "object") {
|
||||||
if(typeof(elements[thing]?.breakInto) == "undefined") {
|
if(typeof(elements[thing]?.breakInto) == "undefined") {
|
||||||
elements[`${thing}_scrap`] = {
|
elements[`${thing}_scrap`] = {
|
||||||
color: elements[thing].color,
|
color: gravelizeToHex(elements[thing].color),
|
||||||
behavior: behaviors.POWDER,
|
behavior: behaviors.POWDER,
|
||||||
tempHigh: elements[thing].tempHigh,
|
tempHigh: elements[thing].tempHigh,
|
||||||
stateHigh: thing,
|
stateHigh: thing,
|
||||||
|
|
@ -21214,13 +21305,14 @@ Pixel size (rendering only): <input id="pixelSize"> (Use if the save looks cut o
|
||||||
//Gravels
|
//Gravels
|
||||||
|
|
||||||
function gravelizeToHex(colorIn) {
|
function gravelizeToHex(colorIn) {
|
||||||
//console.log("gravelizeToHex called",colorIn);
|
|
||||||
var colorInput = colorIn; //side effects?
|
var colorInput = colorIn; //side effects?
|
||||||
|
//console.log(`gravelizeToHex: ${colorInput}`)
|
||||||
|
|
||||||
//make sure in is array
|
//make sure in is array
|
||||||
if(!colorInput instanceof Array) {
|
if(!(colorInput instanceof Array)) {
|
||||||
colorInput = [colorInput];
|
colorInput = [colorInput];
|
||||||
};
|
};
|
||||||
|
//console.log(`gravelizeToHex: ${colorInput}`)
|
||||||
|
|
||||||
//console.log(colorInput);
|
//console.log(colorInput);
|
||||||
|
|
||||||
|
|
@ -29551,29 +29643,6 @@ Make sure to save your command in a file if you want to add this preset again.`
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
function breakPixel(pixel,changetemp=false,defaultBreakIntoDust=false) {
|
|
||||||
var info = elements[pixel.element];
|
|
||||||
if(typeof(info.breakInto) === "undefined") {
|
|
||||||
if(defaultBreakIntoDust) {
|
|
||||||
if(Math.random() < defaultBreakIntoDust) { changePixel(pixel,"dust",changetemp) };
|
|
||||||
};
|
|
||||||
return defaultBreakIntoDust;
|
|
||||||
};
|
|
||||||
var breakIntoElement = info.breakInto;
|
|
||||||
if(Array.isArray(breakIntoElement)) {
|
|
||||||
breakIntoElement = breakIntoElement[Math.floor(Math.random() * breakIntoElement.length)]
|
|
||||||
};
|
|
||||||
if(breakIntoElement === null) {
|
|
||||||
deletePixel(pixel.x,pixel.y);
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
if(typeof(breakIntoElement) === "undefined") { return false };
|
|
||||||
changePixel(pixel,breakIntoElement,changetemp)
|
|
||||||
return true;
|
|
||||||
};
|
|
||||||
|
|
||||||
defaultHardness = 0.3;
|
|
||||||
|
|
||||||
function arrowAltTb(pixel,breakChanceMultiplier,changetemp=false,defaultBreakIntoDust=false) {
|
function arrowAltTb(pixel,breakChanceMultiplier,changetemp=false,defaultBreakIntoDust=false) {
|
||||||
var info = elements[pixel.element];
|
var info = elements[pixel.element];
|
||||||
var hardness = defaultHardness;
|
var hardness = defaultHardness;
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue