diff --git a/mods/generator_prompt.js b/mods/generator_prompt.js index cb0eef9e..cf03ef92 100644 --- a/mods/generator_prompt.js +++ b/mods/generator_prompt.js @@ -1,27 +1,12 @@ var lategenOptions = []; -var creeperMod = "mods/mobs.js"; -var spoutMod = "mods/spouts.js"; -var fairyMod = "mods/more_fairies.js"; -var cloudMod = "mods/more_clouds.js"; -var bombMod = "mods/more_bombs.js"; +var mainMod = "mods/generative_mods.js"; var singularityMod = "mods/neutronium_compressor.js"; -if(enabledMods.includes(creeperMod)) { +if(enabledMods.includes(mainMod)) { lategenOptions.push("creeper"); -}; -if(enabledMods.includes(spoutMod)) { lategenOptions.push("spout"); -}; -if(enabledMods.includes(fairyMod)) { lategenOptions.push("fairy"); -}; -if(enabledMods.includes(cloudMod)) { lategenOptions.push("cloud"); -}; -if(enabledMods.includes(bombMod)) { - lategenOptions.push("bomb"); -}; -if(enabledMods.includes(bombMod)) { lategenOptions.push("bomb"); }; if(enabledMods.includes(singularityMod)) { @@ -29,7 +14,7 @@ if(enabledMods.includes(singularityMod)) { }; lgoDisplayString = lategenOptions.join(", "); if(lgoDisplayString === "") { - lgoDisplayString: "[None. This requires at least one element-generating mod: mobs.js, spouts.js, more_fairies.js, more_clouds.js, more_bombs.js, or neutronium_compressor.js!]"; + lgoDisplayString: "[None. This requires at least one element-generating mod!: generative_mods.js or neutronium_compressor.js]"; }; document.addEventListener("keydown", function(e) { //prop prompt listener @@ -58,31 +43,43 @@ function generatorPrompt() { elements = prompt(`Enter the element(s) you want to generate ${typePlural} for. Elements are separated by commas; to use a combination of elements, the elements are separated by plus signs (like "gold_coin+diamond").`); elements = parseForLateGenerationParameter(elements); - switch(type) { - case "creeper": - generateCreeper(elements,true); - break; - case "spout": - generateSpout(elements,true); - break; - case "fairy": - generateFairy(elements,true); - break; - case "cloud": - generateCloud(elements,true); - break; - case "singularity": - generateSingularity(elements,true); - break; - case "bomb": - var number = prompt(`Enter a bomb number (default: 1) - 1 corresponds to radius 10, 2 corresponds to radius 15, etc.`); - if(isNaN(parseFloat(number))) { number = 1 }; - generateBomb(elements,true,number); - break; - default: - alert("An invalid type made it past the if statement. You shouldn't ever see this error."); - throw new Error("An invalid type made it through the if statement."); + try { + var amount = 0; + switch(type) { + case "creeper": + amount += generateCreeper(elements,true).length; + break; + case "spout": + amount += generateSpout(elements,true).length; + break; + case "fairy": + amount += generateFairy(elements,true).length; + break; + case "cloud": + amount += generateCloud(elements,true).length; + break; + case "singularity": + amount += generateSingularity(elements,true).length; + break; + case "bomb": + var number = prompt(`Enter a bomb number (default: 1) + 1 corresponds to radius 10, 2 corresponds to radius 15, etc.`); + if(isNaN(parseFloat(number))) { number = 1 }; + amount += generateBomb(elements,true,number).length; + break; + default: + alert("An invalid type made it past the if statement. You shouldn't ever see this error."); + throw new Error("An invalid type made it through the if statement."); + }; + alert(`Generated ${amount} ${amount == 1 ? "element" : "elements"}`); + } catch (error) { + var errorString = error.toString(); + var errorText = ""; + if(errorString.includes("Cannot read properties of undefined")) { + errorText += "\r\n(This is most likely from a nonexistent or misspelled element)"; + }; + alert("There was an error!\r\n" + error.toString() + errorText); + throw error; //for console }; }; }; diff --git a/mods/mobs.js b/mods/mobs.js index 7bb6af09..66c79a35 100644 --- a/mods/mobs.js +++ b/mods/mobs.js @@ -5113,822 +5113,6 @@ if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(explodeAtPlu /* ------------------------- - End skeleton elements - ------------------------- */ - - /* Creeper generation - ___#___#___#___#___#___#___#___#___#___ - __#___#___#___#___#___#___#___#___#___# - _#___#___#___#___#___#___#___#___#___#_ - #___#___#___#___#___#___#___#___#___#__ - ___#___#___#___#___#___#___#___#___#___ - __#___#___#___#___#___#___#___#___#___# - _#___#___#___#___#___#___#___#___#___#_ - #___#___#___#___#___#___#___#___#___#__ - ___#___#___#___#___#___#___#___#___#___ - __#___#___#___#___#___#___#___#___#___# - _#___#___#___#___#___#___#___#___#___#_ - #___#___#___#___#___#___#___#___#___#__ - ___#___#___#___#___#___#___#___#___#___ - __#___#___#___#___#___#___#___#___#___# - _#___#___#___#___#___#___#___#___#___#_ - #___#___#___#___#___#___#___#___#___#__ - */ - - //This code is a lot worse than I'd have liked it to be... - - //Include generated creepers in Random tool? - if(urlParams.get('creeperIncludeRandom') !== null) { //if the variable exists at all - creeperIncludeRandom = true - } else { //if it doesn't (and it returns null) - creeperIncludeRandom = false - } - - //Generate creepers - if(urlParams.get('generateCreepers') !== null) { //if the variable exists at all - generateCreepers = true - } else { //if it doesn't (and it returns null) - generateCreepers = false - } - - //Start Creeper Template Functions { - - autoCreeperPlacerTick = function(pixel) { - var creeperElement = elements[pixel.element].creeperType; - var headName,bodyName; - if(typeof(creeperElement === "string")) { //comma separated string check - if(creeperElement.includes(",")) { //if it is - creeperElement = creeperElement.split(","); //to array - creeperElement = creeperElement.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(creeperElement)) { - headName = `${creeperElement.join("_")}_creeper_head`; //auto head element name - bodyName = `${creeperElement.join("_")}_creeper_body`; //auto body element name - } else { - headName = `${creeperElement}_creeper_head`; //auto head element name - bodyName = `${creeperElement}_creeper_body`; //auto body element name - }; - if (isEmpty(pixel.x, pixel.y+1)) { - createPixel(bodyName, pixel.x, pixel.y+1); - pixel.element = headName; - pixel.color = pixelColorPick(pixel) - } else if (isEmpty(pixel.x, pixel.y-1)) { - createPixel(headName, pixel.x, pixel.y-1); - pixel.element = bodyName; - pixel.color = pixelColorPick(pixel) - } else { - deletePixel(pixel.x, pixel.y); - }; - }; - - autoCreeperBodyTick = function(pixel) { - var creeperElement = elements[pixel.element].creeperType; - var headName,bodyName,explodeInto; - if(typeof(creeperElement === "string")) { //comma separated string check - if(creeperElement.includes(",")) { //if it is - creeperElement = creeperElement.split(","); //to array - creeperElement = creeperElement.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(creeperElement)) { - headName = `${creeperElement.join("_")}_creeper_head`; //auto head element name - bodyName = `${creeperElement.join("_")}_creeper_body`; //auto body element name - explodeInto = creeperElement.join(","); //auto body element name - } else { - headName = `${creeperElement}_creeper_head`; //auto head element name - bodyName = `${creeperElement}_creeper_body`; //auto body element name - explodeInto = creeperElement; //auto body element name - }; - if (tryMove(pixel, pixel.x, pixel.y+1)) { // Fall - if (!isEmpty(pixel.x, pixel.y-2, true)) { // Drag head down - var headPixel = pixelMap[pixel.x][pixel.y-2]; - if (headPixel.element == headName) { - if (isEmpty(pixel.x, pixel.y-1)) { - movePixel(pixelMap[pixel.x][pixel.y-2], pixel.x, pixel.y-1); - } - else { - swapPixels(pixelMap[pixel.x][pixel.y-2], pixelMap[pixel.x][pixel.y-1]); - } - } - } - } - doHeat(pixel); - doBurning(pixel); - doElectricity(pixel); - if (pixel.dead) { - // Turn into rotten_meat if pixelTicks-dead > 500 - if (pixelTicks-pixel.dead > 200) { - Math.random() < 0.1 ? changePixel(pixel,"gunpowder") : changePixel(pixel,"rotten_meat"); - } - return - } - - // Find the head - if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == headName) { - var head = pixelMap[pixel.x][pixel.y-1]; - if (head.dead) { // If head is dead, kill body - pixel.dead = head.dead; - } - } - else { var head = null } - - if (isEmpty(pixel.x, pixel.y-1)) { - // create blood if decapitated 10% chance - if (Math.random() < 0.1) { - createPixel("blood", pixel.x, pixel.y-1); - // set dead to true 15% chance - if (Math.random() < 0.15) { - pixel.dead = pixelTicks; - } - } - } - else if (head == null) { return } - else if (Math.random() < 0.1) { // Move 10% chance - var movesToTry = [ - [1*pixel.dir,0], - [1*pixel.dir,-1], - ]; - // While movesToTry is not empty, tryMove(pixel, x, y) with a random move, then remove it. if tryMove returns true, break. - while (movesToTry.length > 0) { - var move = movesToTry.splice(Math.floor(Math.random() * movesToTry.length), 1)[0]; - if (isEmpty(pixel.x+move[0], pixel.y+move[1]-1)) { - if (tryMove(pixel, pixel.x+move[0], pixel.y+move[1])) { - movePixel(head, head.x+move[0], head.y+move[1]); - break; - }; - }; - }; - // 15% chance to change direction while not chasing a human - if(!head.following) { - if (Math.random() < 0.15) { - pixel.dir *= -1; - //console.log("*turns around cutely to face ${pixel.dir < 0 ? 'left' : 'right'}*"); - }; - }/* else { - //console.log("*chases cutely*"); - };*/ - }; - - if(pixel.charge) { - pixel.charged = true; - }; - - if(head) { - if(typeof(head.charge) !== "undefined") { - if(head.charge) { - pixel.charged = true; - }; - }; - if(typeof(head.charged) !== "undefined") { - if(head.charged) { - pixel.charged = true; - }; - }; - }; - - if(typeof(pixel.charged) === "undefined") { - pixel.charged = false; - }; - - if(pixel.charged) { - var explosionRadius = 7; - if(!pixel.didChargeBlueTinted) { //do once, on initial charge - //console.log("something something halsey lyric"); - var color = pixel.color; - if(color.startsWith("rgb")) { - //console.log("rgb detected"); - color = color.split(","); //split color for addition - var red = parseFloat(color[0].substring(4)); - var green = parseFloat(color[1]); - var blue = parseFloat(color[2].slice(0,-1)); - red = rgbColorBound(red + 51); - green = rgbColorBound(green + 51); - blue = rgbColorBound(blue + 102); - color = `rgb(${red},${green},${blue})`; - pixel.color = color; - //console.log("color set"); - } else if(color.startsWith("hsl")) { - //console.log("hsl detected"); - color = color.split(","); //split color for addition - var hue = parseFloat(color[0].substring(4)); - var saturation = parseFloat(color[1].slice(0,-1)); - var luminance = parseFloat(color[2].slice(0,-2)); - hue = hue % 360; //piecewise hue shift - if(hue <= 235 && hue >= 135) { - hue = 185; - } else if(hue < 135) { - hue += 50; - } else if(hue > 235 && hue < 360) { - hue -= 50; - }; - saturation = slBound (saturation + 10); - luminance = slBound(luminance + 20); - color = `hsl(${hue},${saturation}%,${luminance}%)`; - pixel.color = color; - //console.log("color set"); - }; - pixel.didChargeBlueTinted = true; - }; - } else { - var explosionRadius = 5; - }; - - if(pixel.burning) { - pixel.hissing = true; - if(!pixel.hissStart) { - pixel.hissStart = pixelTicks; - }; - if(!pixel.burnStart) { //I don't like errors. - pixel.burnStart = pixel.ticks; - }; - if(pixelTicks - pixel.burnStart > 30) { - //console.log("Kaboom?"); - explodeAt(pixel.x,pixel.y,explosionRadius,creeperElement); - //console.log("Yes, Rico, kaboom."); - }; - }; - - //Head hissing color handler: keeps track of head's hissing for coloring purposes - for(i = 0; i < 1; i++) { //dummy for loop - if(pixel.dead || !head || head.dead) { //can't hiss without a head according to the classic creeper anatomy - //console.log("ss-- oof"); - pixel.hissing = false; - break; - }; - if(head.hissing) { - //console.log("Ssssssss"); - if(!head.hissStart) { - //console.log("t-30 ticks or whatever it was"); - head.hissStart = pixelTicks; - }; - - //Color code { - var ticksHissing = pixelTicks - head.hissStart; - var color = pixel.color; //do on each hissing tick - if(color.startsWith("rgb")) { - //console.log("rgb detected"); - color = color.split(","); //split color for addition - var red = parseFloat(color[0].substring(4)); - var green = parseFloat(color[1]); - var blue = parseFloat(color[2].slice(0,-1)); - red = rgbColorBound(red + ticksHissing); - green = rgbColorBound(green + ticksHissing); - blue = rgbColorBound(blue + ticksHissing); - color = `rgb(${red},${green},${blue})`; - pixel.color = color; - //console.log("color set"); - } else if(color.startsWith("hsl")) { - //console.log("hsl detected"); - color = color.split(","); //split color for addition - var hue = parseFloat(color[0].substring(4)); - var saturation = parseFloat(color[1].slice(0,-1)); - var luminance = parseFloat(color[2].slice(0,-2)); - //console.log("the j"); - luminance = slBound(luminance + 1.176); - //console.log(luminance); - color = `hsl(${hue},${saturation}%,${luminance}%)`; - pixel.color = color; - //console.log("color set"); - }; - //} - }; - }; - }; - - autoCreeperHeadTick = function(pixel) { - var creeperElement = elements[pixel.element].creeperType; - var headName,bodyName,explodeInto; - if(typeof(creeperElement === "string")) { //comma separated string check - if(creeperElement.includes(",")) { //if it is - creeperElement = creeperElement.split(","); //to array - creeperElement = creeperElement.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(creeperElement)) { - headName = `${creeperElement.join("_")}_creeper_head`; //auto head element name - bodyName = `${creeperElement.join("_")}_creeper_body`; //auto body element name - explodeInto = creeperElement.join(","); //auto body element name - } else { - headName = `${creeperElement}_creeper_head`; //auto head element name - bodyName = `${creeperElement}_creeper_body`; //auto body element name - explodeInto = creeperElement; //auto body element name - }; - doHeat(pixel); - doBurning(pixel); - doElectricity(pixel); - if (pixel.dead) { - // Turn into rotten_meat if pixelTicks-dead > 500 - if (pixelTicks-pixel.dead > 200) { - Math.random() < 0.1 ? changePixel(pixel,"gunpowder") : changePixel(pixel,"rotten_meat"); - return - } - } - - // Find the body - if (!isEmpty(pixel.x, pixel.y+1, true) && pixelMap[pixel.x][pixel.y+1].element == bodyName) { - var body = pixelMap[pixel.x][pixel.y+1]; - if (body.dead) { // If body is dead, kill head - pixel.dead = body.dead; - } - } - else { var body = null } - - if(body) { - if(body.dir !== pixel.dir) { //hacky workaround: lock head dir to body dir - pixel.dir = body.dir; - }; - }; - - if (isEmpty(pixel.x, pixel.y+1)) { - tryMove(pixel, pixel.x, pixel.y+1); - // create blood if severed 10% chance - if (isEmpty(pixel.x, pixel.y+1) && !pixel.dead && Math.random() < 0.1) { - createPixel("blood", pixel.x, pixel.y+1); - // set dead to true 15% chance - if (Math.random() < 0.15) { - pixel.dead = pixelTicks; - } - } - } - - //start of most new code - var pX = pixel.x; - var pY = pixel.y; - - if(pixel.charge) { - pixel.charged = true; - }; - - if(body) { - if(typeof(body.charge) !== "undefined") { - if(body.charge) { - pixel.charged = true; - }; - }; - if(typeof(body.charged) !== "undefined") { - if(body.charged) { - pixel.charged = true; - }; - }; - }; - - if(typeof(pixel.charged) === "undefined") { - pixel.charged = false; - }; - - if(pixel.charged) { - var explosionRadius = 10; - if(!pixel.didChargeBlueTinted) { //do once, on initial charge - //console.log("something something halsey lyric"); - var color = pixel.color; - if(color.startsWith("rgb")) { - //console.log("rgb detected"); - color = color.split(","); //split color for addition - var red = parseFloat(color[0].substring(4)); - var green = parseFloat(color[1]); - var blue = parseFloat(color[2].slice(0,-1)); - red = rgbColorBound(red + 51); - green = rgbColorBound(green + 51); - blue = rgbColorBound(blue + 102); - color = `rgb(${red},${green},${blue})`; - pixel.color = color; - //console.log("color set"); - } else if(color.startsWith("hsl")) { - //console.log("hsl detected"); - color = color.split(","); //split color for addition - var hue = parseFloat(color[0].substring(4)); - var saturation = parseFloat(color[1].slice(0,-1)); - var luminance = parseFloat(color[2].slice(0,-2)); - hue = hue % 360; //piecewise hue shift - if(hue <= 235 && hue >= 135) { - hue = 185; - } else if(hue < 135) { - hue += 50; - } else if(hue > 235 && hue < 360) { - hue -= 50; - }; - saturation = slBound (saturation + 10); - luminance = slBound(luminance + 20); - color = `hsl(${hue},${saturation}%,${luminance}%)`; - pixel.color = color; - //console.log("color set"); - }; - pixel.didChargeBlueTinted = true; - }; - } else { - var explosionRadius = 7; - }; - - //Human detection loop (looks ahead according to direction and sets the "following" variable to true, telling the body to lock the direction) - var directionAdverb = "left"; - if(pixel.dir > 0) { - directionAdverb = "right"; - }; - //console.log(`Looking ${directionAdverb}`) - if(pixel.dir === -1) { - for(i = -4; i < 4+1; i++) { - var oY = i; - //console.log(`Starting row look at row ${pY+oY}`) - for(j = (-1); j > (-16 - 1); j--) { - var oX = j; - var nX = pX+oX; - var nY = pY+oY; - if(outOfBounds(nX,nY)) { - //console.log(`Stopping row look at pixel (${nX},${nY}) due to OoB`) - break; - }; - if(isEmpty(nX,nY)) { - ////console.log(`Skipping pixel (${nX},${nY}) (empty)`) - continue; - }; - if(!isEmpty(nX,nY,true)) { - var newPixel = pixelMap[nX][nY]; - var newElement = newPixel.element; - if(enemyHumanoidArray.includes(newElement)) { - //console.log(`Human part found at (${nX},${nY})`) - if(!newPixel.dead) { - pixel.following = true; - //console.log(`Human detected at (${nX},${nY})`) - //Start "hissing" if a human is close enough - if(coordPyth(pX,pY,nX,nY) <= 3.15) { //probably misapplying the tolerance from the MC Wiki line: "Creepers will chase after any player, as long as it is within a 16 block (±5%) radius" - pixel.hissing = true; - if(!pixel.hissStart) { - pixel.hissStart = pixelTicks; - }; - }; - }; - } else { - //console.log(`Stopping row look at pixel (${nX},${nY}) due to non-human pixel in the way`) - break; //can't see through humans - }; - }; - }; - }; - } else if(pixel.dir === 1) { - for(i = -4; i < 4+1; i++) { - var oY = i; - //console.log(`Starting row look at row ${pY+oY}`) - for(j = 1; j < 16 + 1; j++) { - var oX = j; - var nX = pX+oX; - var nY = pY+oY; - if(outOfBounds(nX,nY)) { - //console.log(`Stopping row look at pixel (${nX},${nY}) due to OoB`) - break; - }; - if(isEmpty(nX,nY)) { - ////console.log(`Skipping pixel (${nX},${nY}) (empty)`) - continue; - }; - if(!isEmpty(nX,nY,true)) { - var newPixel = pixelMap[nX][nY]; - var newElement = newPixel.element; - if(enemyHumanoidArray.includes(newElement)) { - //console.log(`Human part found at (${nX},${nY})`) - if(!newPixel.dead) { - pixel.following = true; - //console.log(`Human detected at (${nX},${nY})`) - //Start "hissing" if a human is close enough - if(coordPyth(pX,pY,nX,nY) <= 3.15) { - pixel.hissing = true; - if(!pixel.hissStart) { - pixel.hissStart = pixelTicks; - }; - }; - break; - }; - } else { - //console.log(`Stopping row look at pixel (${nX},${nY}) due to non-human pixel in the way`) - break; - }; - }; - }; - }; - }; - - //Pre-explosion handler: keeps track of time before the kaboom - for(i = 0; i < 1; i++) { //dummy for loop - if(pixel.hissing) { - //console.log("Ssssssss"); - if(pixel.dead || !body || body.dead) { //can't explode without a body according to the classic creeper anatomy - //console.log("ss-- oof"); - pixel.hissing = false; - break; - }; - if(!pixel.hissStart) { - //console.log("t-30 ticks or whatever it was"); - pixel.hissStart = pixelTicks; - }; - //Color code { - var ticksHissing = pixelTicks - pixel.hissStart; - var color = pixel.color; //do on each hissing tick - if(color.startsWith("rgb")) { - //console.log("rgb detected"); - color = color.split(","); //split color for addition - var red = parseFloat(color[0].substring(4)); - var green = parseFloat(color[1]); - var blue = parseFloat(color[2].slice(0,-1)); - red = rgbColorBound(red + ticksHissing); - green = rgbColorBound(green + ticksHissing); - blue = rgbColorBound(blue + ticksHissing); - color = `rgb(${red},${green},${blue})`; - pixel.color = color; - //console.log("color set"); - } else if(color.startsWith("hsl")) { - //console.log("hsl detected"); - color = color.split(","); //split color for addition - var hue = parseFloat(color[0].substring(4)); - var saturation = parseFloat(color[1].slice(0,-1)); - var luminance = parseFloat(color[2].slice(0,-2)); - luminance = slBound(luminance + 1.176); - color = `hsl(${hue},${saturation}%,${luminance}%)`; - pixel.color = color; - //console.log("color set"); - }; - //} - - if(pixelTicks - pixel.hissStart > 30) { - //console.log("Kaboom?"); - //console.log(`Exploding with element ${creeperElement} and radius ${explosionRadius} (charged: ${pixel.charged})`); - explodeAt(body.x,body.y,explosionRadius,explodeInto); - //console.log("Yes, Rico, kaboom."); - }; - }; - }; - - if(Math.random() < 0.01) { //1% chance each tick to lose interest - pixel.following = false; - //console.log("Meh."); - }; - }; - - //End Creeper Template Functions } - - var placeholderColor = "#FF00FF"; - - var hslOffsets = [[0, -5, 5], [0, -20, 10], [0, 0, 10], [0, -20, 10], [0, -35, 0], [0, -20, -30], [0, 10, -10], [0, 10, 20], [0, -20, 10], [0, -10, 5]]; - - var colorOfRandomCreeper = ["#7ba883", "#8aba8a", "#87b292", "#8aba8a", "#71a171", "#346434", "#4d6d72", "#a0caad", "#8aba8a", "#7dac7f"] - //random_creeper's final color but all values of the sixth one increased by 16 decimal and then everything's R and B -= 48 decimal - - elements.spawn_random_creeper = { - color: colorOfRandomCreeper, - behavior: behaviors.WALL, - category: "special", - excludeRandom: false, //see below - movable: true, - tick: function(pixel) { - changePixel(pixel,spawnCreepers[Math.floor(Math.random() * spawnCreepers.length)]) //spawnCreepers is already excludeRandom filtered - }, - }; - - //Standalone generator function - - function generateCreeper(creeperElements,isAfterScriptLoading=false) {//it can be a single element, though - //To specify an array creeper, have the array be inside another array. - /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. - Otherwise, you'll get TypeErrors for some reason when trying to place your creeper. If this is being run after the game has loaded (e.g. in the console), - then isAfterScriptLoading should be true or you might also get TypeErrors (this latter case was a bit inconsistent when I tested it, but - the former case wasn't. **isAfterScriptLoading must be false when this function is run from a JS mod file**. - If isAfterScriptLoading is true, buttons (depending on the hiding setting) will be added to the auto creeper category, the 3 new elements per creeper will be assigned IDs, and the footer will be updated with the increased element counts.*/ - if(typeof(creeperElements) === "string") { //it should be an array, so string check - //console.log("String detected"); - if(creeperElements.includes(",")) { //comma-separated string? - //console.log("Splitting string to array"); - creeperElements = creeperElements.split(","); //,SS to array - } else { - //console.log("Wrapping string in array"); - creeperElements = [creeperElements]; //single string to array - }; - }; - for(aaf = 0; aaf < creeperElements.length; aaf++) { - var elementOfCreeper = creeperElements[aaf]; - var startColor; - var randomExcl = 0; - //console.log("randomExcl set") - //console.log(elementOfCreeper); - - var headName,bodyName,placerName,descElement; - - if(typeof(elementOfCreeper === "string")) { //comma separated string check - if(elementOfCreeper.includes(",")) { //if it is - elementOfCreeper = elementOfCreeper.split(","); //to array - elementOfCreeper = elementOfCreeper.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(elementOfCreeper)) { - headName = `${elementOfCreeper.join("_")}_creeper_head`; //auto head element name - bodyName = `${elementOfCreeper.join("_")}_creeper_body`; //auto body element name - placerName = `${elementOfCreeper.join("_")}_creeper`; //auto placer element name - descElement = elementOfCreeper.join(", "); //auto explosion element list - - //array case color concatenator and excludeRandom handler - startColor = []; - //console.log(elementOfCreeper); - for(ll = 0; ll < elementOfCreeper.length; ll++) { - if(typeof(elements[elementOfCreeper[ll]].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfCreeper[ll]].excludeRandom) { //it it's true - randomExcl = 1; //the whole array creeper is excluded - //console.log("array nyet" + elementOfCreeper); - }; - }; - //console.log(elementOfCreeper[ll]); - startColor = startColor.concat(elements[elementOfCreeper[ll]].color); - }; - } else { //they should all be strings, so here - headName = `${elementOfCreeper}_creeper_head`; //auto head element name - bodyName = `${elementOfCreeper}_creeper_body`; //auto body element name - placerName = `${elementOfCreeper}_creeper`; //auto placer element name - descElement = elementOfCreeper; //auto explosion element - startColor = elements[elementOfCreeper].color; - if(typeof(elements[elementOfCreeper].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfCreeper].excludeRandom) { //it it's true - //console.log("nyet " + elementOfCreeper); - randomExcl = 1; //the creeper is excluded - } else { - //console.log("allow " + elementOfCreeper); - randomExcl = 0; - }; - }; - }; - //Color gen - if(Array.isArray(startColor)) { //Average arrays, make colors rgb() - startColor = averageRgbPrefixedColorArray(startColor); - } else { - startColor = rgbHexCatcher(startColor); - }; - var preColor = rgbStringToHSL(startColor); - var colorsArray = [preColor, preColor, preColor, preColor, preColor, preColor, preColor, preColor, preColor, preColor] - var colorObjectArray = []; - for(q = 0; q < hslOffsets.length; q++) { - colorsArray[q] = addArraysInPairs(colorsArray[q],hslOffsets[q]); - colorsArray[q] = hslToHex(...colorsArray[q]); - colorObjectArray[q] = hexToRGB(colorsArray[q]); //outputs hex - if(isAfterScriptLoading) { // if it's after the hex -> RGB conversion - var coq = colorObjectArray[q]; //pull the object - //console.log(coq.r); - colorsArray[q] = `rgb(${coq.r},${coq.g},${coq.b})`; //and change to the RGB from its values - }; - }; - - //End color gen - - //console.log(`${headName}; ${bodyName}; ${placerName}; ${descElement}`) - - //Placer - elements[placerName] = { - movable: true, - creeperType: elementOfCreeper, - color: colorsArray, - colorObject: colorObjectArray, - category: "auto creepers", - properties: { - dead: false, - dir: 1, - panic: 0, - following: false, - }, - tick: function(pixel) { - autoCreeperPlacerTick(pixel); - }, - related: [bodyName,headName,"creeper"], - desc: `Auto-generated creeper.
Explodes into ${descElement}.`, - }; - - eLists.CREEPER.push(placerName); - - //Body - elements[bodyName] = { - movable: true, - creeperType: elementOfCreeper, - color: colorsArray, - colorObject: colorObjectArray, - category: "auto creepers", - hidden: true, - excludeRandom: true, - density: 1500, - state: "solid", - conduct: 25, - tempHigh: 250, - stateHigh: "cooked_meat", - tempLow: -30, - stateLow: "frozen_meat", - burn: 10, - burnTime: 250, - burnInto: ["cooked_meat","cooked_meat","cooked_meat","cooked_meat","gunpowder"], - breakInto: ["blood","gunpowder"], - reactions: { - "cancer": { "elem1":"cancer", "chance":0.005 }, - "radiation": { "elem1":["ash","meat","rotten_meat","cooked_meat"], "chance":0.4 }, - "plague": { "elem1":"plague", "chance":0.05 }, - }, - properties: { - dead: false, - dir: 1, - panic: 0, - charged: false, - didChargeBlueTinted: false, - }, - tick: function(pixel) { - autoCreeperBodyTick(pixel); - }, - }; - - //Head - elements[headName] = { - movable: true, - creeperType: elementOfCreeper, - color: colorsArray, - colorObject: colorObjectArray, - category: "auto creepers", - hidden: true, - excludeRandom: true, - density: 1080, - state: "solid", - conduct: 25, - tempHigh: 250, - stateHigh: "cooked_meat", - tempLow: -30, - stateLow: "frozen_meat", - burn: 10, - burnTime: 250, - burnInto: ["cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","cooked_meat","gunpowder"], - breakInto: "blood", - reactions: { - "cancer": { "elem1":"cancer", "chance":0.005 }, - "radiation": { "elem1":["ash","meat","rotten_meat","cooked_meat"], "chance":0.4 }, - "plague": { "elem1":"plague", "chance":0.05 }, - "oxygen": { "elem2":"carbon_dioxide", "chance":0.5 }, - }, - properties: { - dead: false, - following: false, - hissing: false, - charged: false, - didChargeBlueTinted: false, - }, - tick: function(pixel) { - autoCreeperHeadTick(pixel); - }, - }; - if(isAfterScriptLoading) { - elementCount += 3; //placer, body, head - createElementButton(placerName) - if(settings["unhide"] === 0) { //hide some elements: body and head would be hidden, so only update hidden count - hiddenCount += 2; - } else if(settings["unhide"] === 1) { //unhide all elements: b/h would not be hidden, so only create their buttons - createElementButton(bodyName); - createElementButton(headName); - } else if(settings["unhide"] === 2) { - settings.unlocked[bodyName] ? createElementButton(bodyName) : hiddenCount++; //ternary: if headName is unlocked, create button, else increase hiddenCount - settings.unlocked[headName] ? createElementButton(headName) : hiddenCount++; //above with headName - }; - elements[placerName].id = nextid++; //set placer's id to nextid and then increment nextid - elements[bodyName].id = nextid++; //repeat with body and head - elements[headName].id = nextid++; - headBodyObject[headName] = bodyName; - document.getElementById("extraInfo").innerHTML = "

There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.

©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n

"; //update extra info counts (and the copyright year, due to the method used) - }; - if(creeperIncludeRandom) { - randomExcl ? elements[placerName].excludeRandom = true : elements[placerName].excludeRandom = false; - } else { - elements[placerName].excludeRandom = true; - }; - if(!randomExcl) { - //console.log("spawn enabling " + placerName); - spawnCreepers.push(placerName); - } else { - //console.log("nyetted " + placerName); - }; - }; - }; - - runAfterAutogen(function() { - if(generateCreepers) { - var tempArray = Object.keys(elements); - tempArray.push(["rock", "sand"]); - generateCreeper(tempArray,false) - }; - }); - - var solidBlacklist = ["mistake", "birthpool", "firesea"]; //exclude these since they seem to be liquid - - solids = Object.keys(elements).filter(function(e) { - return elements[e].category === "solids" && !solidBlacklist.includes(e); - }); - - for(i = 0; i < solids.length; i++) { //A lot of elements in solids, particularly metals, are missing a "state: solid". - var solidName = solids[i] - elements[solidName].state = "solid"; - }; - } else { if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; if(!enabledMods.includes(explodeAtPlusMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,explodeAtPlusMod) }; diff --git a/mods/more_bombs.js b/mods/more_bombs.js deleted file mode 100644 index 2d458f05..00000000 --- a/mods/more_bombs.js +++ /dev/null @@ -1,507 +0,0 @@ -var modName = "mods/more_bombs.js"; -var explodeAtPlusMod = "mods/explodeAtPlus.js"; -var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; -var libraryMod = "mods/code_library.js"; - -if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) { - eLists.BOMB = ["bomb", "tnt", "c4", "grenade", "dynamite", "gunpowder", "firework", "nuke", "h_bomb", "dirty_bomb", "emp_bomb", "sticky_bomb", "cold_bomb", "hot_bomb", "electro_bomb", "water_bomb", "antimatter_bomb", "flashbang", "smoke_grenade", "fireball", "landmine", "cluster_bomb", "cluster_nuke", "op_hottester_bomb", "anti-bomb", "electric_bomblet", "electric_cluster_bomb", "radioactive_popper", "acid_bomb", "amalgamated_bomb"]; - var excludedBombElements = ["water", "antimatter", "acid"]; - - //Generate bombs - if(urlParams.get('generateBombs') !== null) { //if the variable exists at all - generateBombs = true - } else { //if it doesn't (and it returns null) - generateBombs = false - } - - function firebombFire(pixel,x,y,radius,fire,smoke,power,damage) { - var coords = circleCoords(pixel.x,pixel.y,radius); - for (var i = 0; i < coords.length; i++) { - var x = coords[i].x; - var y = coords[i].y; - if(!isEmpty(x,y,true)) { - var pixel = pixelMap[x][y]; - var info = elements[pixel.element]; - var cursedFireChance = 0.15 + power; - if (info.burn) { //Light everything on fire - pixel.burning = true; - pixel.burnStart = pixelTicks; - pixel.temp += 10; //smoke prevention - } else if(Math.random() < cursedFireChance) { //(15+power)%/px cursed burning - pixel.burning = true; - pixel.burnStart = pixelTicks; - pixel.temp += 10; - }; - } else if(isEmpty(x,y)) { //if there's space for fire - if (Array.isArray(fire)) { //this should remain "fire" - var newfire = fire[Math.floor(Math.random() * fire.length)]; - } else { - var newfire = fire; - }; - createPixel(newfire,x,y); //add fire - var firePixel = pixelMap[x][y]; - firePixel.temp = Math.max(elements[newfire].temp,firePixel.temp); - firePixel.burning = true; - }; - }; - }; - - if(urlParams.get('bombAmount') != null) { //null check - bombAmount = urlParams.get('bombAmount') - if(isNaN(bombAmount) || bombAmount === "" || bombAmount === null) { //NaN check - bombAmount = 10 - } - bombAmount = parseInt(bombAmount) - if(bombAmount > 50) { - alert("Maximum amount of additional bomb/anti-bomb pairs is 50.\nOnly 50 were added.") - } else if(bombAmount < 1) { - alert("Minimum amount of additional bomb/anti-bomb pairs is 1.\n1 pair was added.") - } - bombAmount = Math.min(50,Math.max(bombAmount,1)) - } else { - bombAmount = 10 - } - - function hotterBomb(pixel,x,y,radius,fire,smoke,power,damage) { - //console.log(`Radius: ${radius}\nPower: ${power}\nPixel: (${pixel.x},${pixel.y})\nDamage: ${damage}`); - //console.log(`Expected temperature increase for pixel at (${pixel.x},${pixel.y}): ${800 * ((1 + (7 * damage)) ** 2) * ((power ** 2) * 1.5)}`); - pixel.temp += (800 * ((1 + (7 * damage)) ** 2) * ((power ** 2) * 1.5)); - }; - - elements.firebomb = { - color: "#ee7e3e", - tick: function(pixel) { - if(!isEmpty(pixel.x,pixel.y-1,true)) { //[0][1] EX (ignore bounds) - var newPixel = pixelMap[pixel.x][pixel.y-1]; - var newElement = newPixel.element; - var newInfo = elements[newElement]; - if(newInfo.state !== "gas" && newElement !== pixel.element) { - explodeAtPlus(pixel.x,pixel.y,10,"fire,fire,fire,fire,fire,greek_fire","fire",null,firebombFire); - }; - }; - if(!isEmpty(pixel.x,pixel.y+1,true)) { //[2][1] EX (don't ignore bounds, non-bound case) - var newPixel = pixelMap[pixel.x][pixel.y+1]; - var newElement = newPixel.element; - var newInfo = elements[newElement]; - if(newInfo.state !== "gas" && newElement !== pixel.element) { - explodeAtPlus(pixel.x,pixel.y,10,"fire,fire,fire,fire,fire,greek_fire","fire",null,firebombFire); - }; - }; - if(outOfBounds(pixel.x,pixel.y+1)) { //[2][1] EX (don't ignore bounds, bound case) - explodeAtPlus(pixel.x,pixel.y,10,"fire,fire,fire,fire,fire,greek_fire","fire",null,firebombFire); - }; - if(!tryMove(pixel,pixel.x,pixel.y+1)) { //behaviors.POWDER - Math.random() < 0.5 ? tryMove(pixel,pixel.x-1,pixel.y+1) : tryMove(pixel,pixel.x+1,pixel.y+1); - }; - }, - category: "weapons", - state: "solid", - density: 1500, - excludeRandom: true, - desc: "An advanced incendiary weapon.
To enable automatic bomb generation, set the generateBombs query parameter.", - }; - - elements.cluster_nuke = { - color: "#e3f636", - behavior: [ - "CR:radiation%5|EX:90>plasma,plasma,plasma,nuke,nuke,nuke,radiation,radiation,radiation,rad_steam,rad_steam,radiation,rad_steam AND CR:radiation%5|CR:radiation%5", - "CR:radiation%5|XX|CR:radiation%5", - "M2 AND CR:radiation%5|M1 AND EX:90>plasma,plasma,plasma,nuke,nuke,nuke,radiation,radiation,radiation,rad_steam,rad_steam,radiation,rad_steam AND CR:radiation%5|M2 AND CR:radiation%5", - ], - category: "weapons", - state: "solid", - density: 1500, - excludeRandom: true, - desc: "It's a nuke that drops more nukes.
To enable automatic bomb generation, set the generateBombs query parameter.", - }; - - elements.anti_bomb = { - color: "#525c61", - behavior: [ - "M2|M1 AND EX:10|M2", - "XX|XX|XX", - "XX|EX:10|XX", - ], - category: "weapons", - state: "solid", - density: 1300, - excludeRandom: true, - }; - - elements.electric_bomblet = { - color: "#ffffff", - behavior: [ - "SH%50|EX:8>electric AND SH%50|SH%50", - "SH%50|EX:9>electric%0.5|SH%50", - "M2 AND SH%50|M1 AND SH%50 AND EX:8>electric AND SW:electric|M2 AND SH%50", - ], - category: "weapons", - state: "solid", - density: 1200, - hidden: true, - excludeRandom: true, - hardness: 0.3, - }; - - elements.electric_cluster_bomb = { - color: "#ffffff", - behavior: [ - "SH%50|EX:8>electric_bomblet AND SH%50|SH%50", - "SH%50|XX|SH%50", - "M2 AND SH%50|M1 AND SH%50 AND EX:8>electric_bomblet AND SW:electric|M2 AND SH%50", - ], - category: "weapons", - state: "solid", - density: 1800, - hidden: true, - excludeRandom: true, - hardness: 0.3, - }; - - elements.radioactive_popper = { - color: "#d6ce72", - behavior: [ - "XX|EX:7>radiation|XX", - "XX|XX|XX", - "M2|M1 AND EX:7>radiation|M2", - ], - category: "weapons", - state: "solid", - density: 1200, - hidden: true, - excludeRandom: true, - hardness: 0.3, - cooldown: 3, - }; - - elements.acid_bomb = { - color: "#7d8a63", - behavior: [ - "XX|EX:15>acid_gas|XX", - "XX|XX|XX", - "M2|M1 AND EX:15>acid_gas|M2", - ], - category: "weapons", - state: "solid", - density: 1400, - excludeRandom: true, - cooldown: defaultCooldown, - }; - - amalgamatedBombFire = "plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,plasma,smoke,plasma,plasma,fire,smoke,fire,smoke,plasma,metal_scrap,metal_scrap,metal_scrap,metal_scrap,metal_scrap,acid,acid,oil,oil,oil,oil,oil,oil,oil,plasma,plasma,plasma,plasma,plasma,smoke,plasma,plasma,fire,smoke,plasma,metal_scrap,metal_scrap,metal_scrap,metal_scrap,metal_scrap,metal_scrap,flash,flash,flash,flash,flash,acid_gas,acid_gas,acid_gas,acid,oil,oil,oil,oil,oil,oil,oil,oil,oil,oil,plasma,plasma,plasma,plasma,metal_scrap,metal_scrap,metal_scrap,metal_scrap,metal_scrap,acid,acid,oil,oil,oil,oil,oil,oil,oil,plasma,plasma,plasma,plasma,plasma,smoke,plasma,plasma,fire,smoke,plasma,metal_scrap,metal_scrap,metal_scrap,metal_scrap,metal_scrap,metal_scrap,electric_cluster_bomb,electric_cluster_bomb,flash,flash,flash,flash,flash,acid_gas,acid_gas,acid_gas,acid,oil,oil,oil,oil,oil,oil,oil,oil,oil,oil,plasma,plasma,plasma,plasma,plague,plague,plague,plague,plague,plague,radiation,radiation,radiation,radiation,radiation,radiation,radiation,radiation,uranium,uranium,uranium,uranium,uranium,uranium,greek_fire,greek_fire,greek_fire,greek_fire,greek_fire,antimatter,antimatter,antimatter,antimatter,antimatter,smoke_grenade,antimatter,smoke_grenade,fireball,flash,acid_gas,acid_gas,acid_gas,plague,plague,plague,plague,plague,plague,radiation,radiation,radiation,radiation,radiation,radiation,radiation,radiation,uranium,uranium,uranium,uranium,uranium,uranium,greek_fire,greek_fire,greek_fire,greek_fire,greek_fire,antimatter,antimatter,antimatter,antimatter,antimatter,smoke_grenade,antimatter,flash,acid_gas,acid_gas,acid_gas,radiation,radiation,radiation,radiation,plague,acid_gas,acid_gas,acid_gas,chlorine,chlorine,chlorine" - - elements.amalgamated_bomb = { - color: ["#FF0000","#FF0000","#FFFF00","#FFFF00","#00FF00","#00FF00","#0000FF","#0000FF"], - tick: function(pixel) { - doDefaults(pixel); - if(!isEmpty(pixel.x,pixel.y-1,true)) { //[0][1] EX (ignore bounds) - var newPixel = pixelMap[pixel.x][pixel.y-1]; - var newElement = newPixel.element; - var newInfo = elements[newElement]; - if(newInfo.state !== "gas" && newElement !== pixel.element) { - explodeAtPlus(pixel.x,pixel.y,70,amalgamatedBombFire,amalgamatedBombFire); - }; - }; - if(!isEmpty(pixel.x,pixel.y+1,true)) { //[2][1] EX (don't ignore bounds, non-bound case) - var newPixel = pixelMap[pixel.x][pixel.y+1]; - var newElement = newPixel.element; - var newInfo = elements[newElement]; - if(newInfo.state !== "gas" && newElement !== pixel.element) { - explodeAtPlus(pixel.x,pixel.y,70,amalgamatedBombFire,amalgamatedBombFire); - }; - }; - if(outOfBounds(pixel.x,pixel.y+1)) { //[2][1] EX (don't ignore bounds, bound case) - explodeAtPlus(pixel.x,pixel.y,70,amalgamatedBombFire,amalgamatedBombFire); - }; - if(!tryMove(pixel,pixel.x,pixel.y+1)) { //behaviors.POWDER - Math.random() < 0.5 ? tryMove(pixel,pixel.x-1,pixel.y+1) : tryMove(pixel,pixel.x+1,pixel.y+1); - }; - }, - category: "weapons", - state: "solid", - temp: 7065, - density: 158000, - excludeRandom: true, - }; - - elements.op_hottester_bomb = { - color: "#cc436e", - properties: { - radius: 15, //just so people can edit it per pixel to be stupidly high - }, - tick: function(pixel) { - doDefaults(pixel); - if(!isEmpty(pixel.x,pixel.y-1,true)) { //[0][1] EX (ignore bounds) - var newPixel = pixelMap[pixel.x][pixel.y-1]; - var newElement = newPixel.element; - var newInfo = elements[newElement]; - if(newInfo.state !== "gas" && newElement !== pixel.element) { - explodeAtPlus(pixel.x,pixel.y,pixel.radius,"plasma","plasma",hotterBomb,hotterBomb,false); - }; - }; - if(!isEmpty(pixel.x,pixel.y+1,true)) { //[2][1] EX (don't ignore bounds, non-bound case) - var newPixel = pixelMap[pixel.x][pixel.y+1]; - var newElement = newPixel.element; - var newInfo = elements[newElement]; - if(newInfo.state !== "gas" && newElement !== pixel.element) { - explodeAtPlus(pixel.x,pixel.y,pixel.radius,"plasma","plasma",hotterBomb,hotterBomb,false); - }; - }; - if(outOfBounds(pixel.x,pixel.y+1)) { //[2][1] EX (don't ignore bounds, bound case) - explodeAtPlus(pixel.x,pixel.y,pixel.radius,"plasma","plasma",hotterBomb,hotterBomb,false); - }; - if(!tryMove(pixel,pixel.x,pixel.y+1)) { //behaviors.POWDER - Math.random() < 0.5 ? tryMove(pixel,pixel.x-1,pixel.y+1) : tryMove(pixel,pixel.x+1,pixel.y+1); - }; - }, - category: "weapons", - state: "solid", - temp: 7065, - density: 1900, - excludeRandom: true, - }; - - for (var i = 2; i <= bombAmount + 1; i++) { - elements[`bomb_${i}`] = { - name: `bomb ${i}`, - color: "#624c41", - behavior: [ - `XX|EX:${5*(i+1)}>fire|XX`, - "XX|XX|XX", - `M2|M1 AND EX:${5*(i+1)}>fire|M2`, - ], - state: "solid", - density: 1300 * 8**((i-1)/2), - excludeRandom:true, - category: "weapons", - desc: `${5*(i+1)/10} times the radius of the regular bomb`, - cooldown: defaultCooldown, - }; - eLists.BOMB.push(`bomb_${i}`); - }; - - elements.anti_bomb = { - color: "#625c71", - behavior: [ - "M2|M1 AND EX:10|M2", - "XX|XX|XX", - "XX|EX:10|XX", - ], - category: "weapons", - state: "solid", - density: 1300, - excludeRandom: true, - cooldown: defaultCooldown, - }; - - for (var i = 2; i <= bombAmount + 1; i++) { - elements[`anti_bomb_${i}`] = { - color: "#625c71", - behavior: [ - `M2|M1 AND EX:${5*(i+1)}>fire|M2`, - "XX|XX|XX", - `XX|EX:${5*(i+1)}>fire|XX`, - ], - state: "solid", - density: 1300 * 8**((i-1)/2), - excludeRandom:true, - category: "weapons", - desc: `${5*(i+1)/10} times the radius of the regular anti-bomb`, - cooldown: defaultCooldown, - }; - eLists.BOMB.push(`anti_bomb_${i}`); - }; - - //genfunc - function generateBomb(bombElements,isAfterScriptLoading=false,bombNumber=1) {//it can be a single element, though - bombNumber = Math.max(0,bombNumber); - - //To specify an array bomb, have the array be inside another array. - /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. - Otherwise, you'll get TypeErrors for some reason when trying to place your bomb. If this is being run after the game has loaded (e.g. in the console), - then isAfterScriptLoading should be true or you might also get TypeErrors (this latter case was a bit inconsistent when I tested it, but - the former case wasn't. **isAfterScriptLoading must be false when this function is run from a JS mod file**.*/ - if(typeof(bombElements) === "string") { //it should be an array, so string check - //console.log("String detected"); - if(bombElements.includes(",")) { //comma-separated string? - //console.log("Splitting string to array"); - bombElements = bombElements.split(","); //,SS to array - } else { - //console.log("Wrapping string in array"); - bombElements = [bombElements]; //single string to array - }; - }; - for(aaf = 0; aaf < bombElements.length; aaf++) { - var elementOfBomb = bombElements[aaf]; - var startColor; - //console.log(elementOfBomb); - - var bombName; - - if(typeof(elementOfBomb === "string")) { //comma separated string check - if(elementOfBomb.includes(",")) { //if it is - elementOfBomb = elementOfBomb.split(","); //to array - elementOfBomb = elementOfBomb.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(elementOfBomb)) { - bombName = `${elementOfBomb.join("_")}_bomb`; //auto placer element name - - //array case color concatenator (bombs are always excludeRandom) - startColor = []; - //console.log(elementOfBomb); - for(ll = 0; ll < elementOfBomb.length; ll++) { - startColor = startColor.concat(elements[elementOfBomb[ll]].color); - }; - } else { //they should all be strings, so here - bombName = `${elementOfBomb}_bomb`; //auto placer element name - startColor = elements[elementOfBomb].color; - }; - - //Color gen - if(Array.isArray(startColor)) { //Average arrays, make colors rgb() - startColor = averageRgbPrefixedColorArray(startColor); - } else { - startColor = rgbHexCatcher(startColor); - }; - - startColor = addColors(changeLuminance(changeSaturation(startColor,0.6,"multiply","hsl_json"),0.5,"multiply","rgb"),"rgb(24,0,0)","rgb"); - - var newColorObject = rgbStringToObject(startColor); - - //End color gen - - //The bomb - - //console.log(elementOfBomb); - var firstInfo, firstTemp; - if(Array.isArray(elementOfBomb)) { - firstInfo = elements[elementOfBomb[0]]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - } else { - firstInfo = elements[elementOfBomb]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - }; - - elementOfBomb = tryJoin(elementOfBomb,","); - descElement = tryJoin(elementOfBomb,", "); - - //console.log(elementOfBomb); - - if(bombNumber !== 1) { - bombName += `_${bombNumber}`; - }; - - if(!elementExists(bombName)) { - elements[bombName] = { - color: startColor, - insulate: true, - flippableX: true, - colorObject: newColorObject, - behavior: [ - ["XX",`EX:${5*(bombNumber+1)}>${elementOfBomb}`,"XX"], - ["XX","XX","XX"], - ["M2",`M1 AND EX:${5*(bombNumber+1)}>${elementOfBomb}`,"M2"] - ], - category: "auto_bombs", - desc: `Explodes into ${descElement}
Radius: ${5*(bombNumber+1)}`, - temp: firstTemp, - excludeRandom: true, - }; - if(typeof(eLists) === "undefined") { - eLists = {}; - }; - if(typeof(eLists.BOMB) === "undefined") { - eLists.BOMB = []; - }; - eLists.BOMB.push(bombName); - if(typeof(bombChoices) === "undefined") { - bombChoices = [] - }; - if(!bombChoices.includes(bombName)) { - bombChoices.push(bombName); - }; - if(isAfterScriptLoading) { - elements[bombName].flippableX = true; - elementCount++; //increment for new bomb element - createElementButton(bombName); - elements[bombName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "

There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.

©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n

"; //update extra info counts (and the copyright year, due to the method used) - }; - }; - }; - }; - - runAfterAutogen(function() { - if(elementExists("vaporized_rock")) { - elements.molten_dirt.tempHigh = 3000; - elements.molten_dirt.stateHigh = "vaporized_rock"; - }; - if(generateBombs) { - var tempArray = Object.keys(elements); - tempArray.push(["rock", "sand"]); - generateBomb(tempArray,false) - }; - }); - - runAfterLoad(function() { - if(enabledMods.includes("mods/fey_and_more.js")) { - amalgamatedBombFire += ",poisonwater".repeat(8); - amalgamatedBombFire += ",mystic_fire".repeat(4); - amalgamatedBombFire += ",firesea".repeat(6); - amalgamatedBombFire += ",lektre".repeat(6); - }; - if(enabledMods.includes("mods/Neutronium Mod.js")) { - amalgamatedBombFire += ",flamer".repeat(3); - amalgamatedBombFire += ",flamebomb".repeat(3); - amalgamatedBombFire += ",toxin".repeat(3); - }; - if(enabledMods.includes("mods/randomness.js")) { - amalgamatedBombFire += ",burning_unnamed_gas".repeat(4); - amalgamatedBombFire += ",warp".repeat(6); - amalgamatedBombFire += ",bomb_3".repeat(3); - amalgamatedBombFire += ",op_hottester_bomb".repeat(3); - eLists.BOMB.push("unnamed_bomb"); - eLists.BOMB.push("warp_bomb"); - }; - if(enabledMods.includes("mods/glenn_gases.js")) { - amalgamatedBombFire += ",electric_gas".repeat(3); - amalgamatedBombFire += ",corrosive_gas".repeat(3); - amalgamatedBombFire += ",iocalfaeus_gas".repeat(3); - amalgamatedBombFire += ",ignited_gas".repeat(3); - amalgamatedBombFire += ",finine".repeat(3); - amalgamatedBombFire += ",acidic_vapour".repeat(3); - amalgamatedBombFire += ",nitrous_gas".repeat(3); - amalgamatedBombFire += ",void_gas".repeat(3); - amalgamatedBombFire += ",black_damp".repeat(3); - }; - if(enabledMods.includes("mods/some_tf_liquids.js")) { - amalgamatedBombFire += ",blazing_pyrotheum".repeat(5); - amalgamatedBombFire += ",tectonic_petrotheum".repeat(7); - amalgamatedBombFire += ",resonant_ender".repeat(5); - }; - if(enabledMods.includes("mods/chem.js")) { - amalgamatedBombFire += ",FOOF".repeat(8); - }; - if(enabledMods.includes("mods/the_ground.js")) { - amalgamatedBombFire += ",liquid_irradium".repeat(7); - }; - if(enabledMods.includes("mods/bioooze.js")) { - amalgamatedBombFire += ",bioooze".repeat(8); - }; - }); -} else { - if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; - if(!enabledMods.includes(explodeAtPlusMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,explodeAtPlusMod) }; - if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) }; - localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); - alert(`The "${runAfterAutogenMod}", "${explodeAtPlusMod}", and "${libraryMod}" mods are all required; any missing mods in this list have been automatically inserted (reload for this to take effect).`) -}; diff --git a/mods/more_clouds.js b/mods/more_clouds.js deleted file mode 100644 index ba2d395c..00000000 --- a/mods/more_clouds.js +++ /dev/null @@ -1,249 +0,0 @@ -var modName = "mods/clouds.js"; -var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; -var libraryMod = "mods/code_library.js"; - -if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) { - - //Generate clouds - if(urlParams.get('generateClouds') !== null) { //if the variable exists at all - generateClouds = true - } else { //if it doesn't (and it returns null) - generateClouds = false - } - - if(urlParams.get('cloudIncludeRandom') !== null) { //if the variable exists at all - cloudIncludeRandom = true - } else { //if it doesn't (and it returns null) - cloudIncludeRandom = false - } - - eLists.CLOUD = ["cloud", "rain_cloud", "snow_cloud", "fire_cloud", "hail_cloud", "acid_cloud", "pyrocumulus"]; - var excludedCloudElements = ["snow", "fire", "hail", "acid"]; - var includedClouds = ["cloud", "rain_cloud", "snow_cloud", "fire_cloud", "hail_cloud", "acid_cloud", "pyrocumulus"]; - var backupCategoryWhitelist = ["land","powders","weapons","food","life","corruption","states","fey","Fantastic Creatures","dyes","energy liquids","random liquids","random gases","random rocks"]; - var backupElementWhitelist = ["mercury", "chalcopyrite_ore", "chalcopyrite_dust", "copper_concentrate", "fluxed_copper_concentrate", "unignited_pyrestone", "ignited_pyrestone", "everfire_dust", "extinguished_everfire_dust", "mistake", "polusium_oxide", "vaporized_polusium_oxide", "glowstone_dust", "redstone_dust", "soul_mud", "wet_soul_sand", "nitrogen_snow", "fusion_catalyst", "coal", "coal_coke", "blast_furnace_fuel", "molten_mythril"]; - //forces elements that logically should be clouded, but are refused even though the condition is true, to be clouded - function defaultCloudCondition(name) { - if(typeof(elements[name]) !== "object") { - throw new Error(`Nonexistent element ${name}`); - }; - var info = elements[name]; - //console.log(`${name} (${JSON.stringify(elements[name])})`); - if(typeof(info.state) === "undefined") { - var state = null; - } else { - var state = info.state; - }; - if(typeof(info.category) === "undefined") { - var category = "other"; - } else { - var category = info.category; - }; - if(excludedCloudElements.includes(name)) { - return false - }; - var include = false; - if(["liquid","gas"].includes(state)) { - include = true; - }; - if(info.movable) { - include = true; - }; - if(backupCategoryWhitelist.includes(category)) { - include = true; - }; - if(backupElementWhitelist.includes(name)) { - include = true; - }; - if(category.includes("mudstone")) { - include = true; - }; - //console.log(include); - return include; - }; - -//Generator function - - //Standalone generator - function generateCloud(cloudElements,isAfterScriptLoading=false) {//it can be a single element, though - //To specify an array cloud, have the array be inside another array. - /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. - Otherwise, you'll get TypeErrors for some reason when trying to place your cloud. If this is being run after the game has loaded (e.g. in the console), - then isAfterScriptLoading should be true or you might also get TypeErrors (this latter case was a bit inconsistent when I tested it, but - the former case wasn't. **isAfterScriptLoading must be false when this function is run from a JS mod file**.*/ - if(typeof(cloudElements) === "string") { //it should be an array, so string check - //console.log("String detected"); - if(cloudElements.includes(",")) { //comma-separated string? - //console.log("Splitting string to array"); - cloudElements = cloudElements.split(","); //,SS to array - } else { - //console.log("Wrapping string in array"); - cloudElements = [cloudElements]; //single string to array - }; - }; - for(aaf = 0; aaf < cloudElements.length; aaf++) { - var elementOfCloud = cloudElements[aaf]; - var startColor; - var randomExcl = 0; - //console.log("randomExcl set") - //console.log(elementOfCloud); - - var cloudName; - - if(typeof(elementOfCloud === "string")) { //comma separated string check - if(elementOfCloud.includes(",")) { //if it is - elementOfCloud = elementOfCloud.split(","); //to array - elementOfCloud = elementOfCloud.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(elementOfCloud)) { - cloudName = `${elementOfCloud.join("_")}_cloud`; //auto placer element name - - //array case color concatenator and excludeRandom handler - startColor = []; - //console.log(elementOfCloud); - for(ll = 0; ll < elementOfCloud.length; ll++) { - if(typeof(elements[elementOfCloud[ll]].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfCloud[ll]].excludeRandom) { //it it's true - randomExcl = 1; //the whole array cloud is excluded - //console.log("array nyet" + elementOfCloud); - }; - }; - //console.log(elementOfCloud[ll]); - startColor = startColor.concat(elements[elementOfCloud[ll]].color); - }; - } else { //they should all be strings, so here - cloudName = `${elementOfCloud}_cloud`; //auto placer element name - startColor = elements[elementOfCloud].color; - if(typeof(elements[elementOfCloud].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfCloud].excludeRandom) { //it it's true - //console.log("nyet " + elementOfCloud); - randomExcl = 1; //the cloud is excluded - } else { - //console.log("allow " + elementOfCloud); - randomExcl = 0; - }; - }; - }; - //Color gen - if(Array.isArray(startColor)) { //Average arrays, make colors rgb() - startColor = averageRgbPrefixedColorArray(startColor); - } else { - startColor = rgbHexCatcher(startColor); - }; - - startColor = changeLuminance(changeSaturation(startColor,0.5,"multiply","hsl_json"),0.5,"multiply","rgb"); - - var newColorObject = rgbStringToObject(startColor); - - //End color gen - - //The cloud - - //console.log(elementOfCloud); - var firstInfo, firstTemp; - if(Array.isArray(elementOfCloud)) { - firstInfo = elements[elementOfCloud[0]]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - } else { - firstInfo = elements[elementOfCloud]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - }; - - elementOfCloud = tryJoin(elementOfCloud,","); - - //console.log(elementOfCloud); - - if(!elementExists(cloudName)) { - elements[cloudName] = { - color: startColor, - insulate: true, - colorObject: newColorObject, - behavior: [ - ["XX","XX","XX"], - ["XX",`CH:${elementOfCloud}%0.05`,"M1%2.5 AND BO"], - ["XX","XX","XX"] - ], - category: "clouds", - temp: firstTemp, - state: "gas", - density: 0.6, - ignoreAir: true, - conduct: 0.01, - }; - } else { - elements[`auto_${cloudName}`] = { - color: startColor, - insulate: true, - colorObject: newColorObject, - behavior: [ - ["XX","XX","XX"], - ["XX",`CH:${elementOfCloud}%0.05`,"M1%2.5 AND BO"], - ["XX","XX","XX"] - ], - category: "clouds", - temp: firstTemp, - state: "gas", - density: 0.6, - ignoreAir: true, - conduct: 0.01, - }; - }; - - eLists.CLOUD.push(cloudName); - - if(!randomExcl) { - if(typeof(cloudChoices) === "undefined") { - cloudChoices = [] - }; - if(!cloudChoices.includes(cloudName)) { - cloudChoices.push(cloudName); - }; - } - if(cloudIncludeRandom) { - randomExcl ? elements[cloudName].excludeRandom = true : elements[cloudName].excludeRandom = false; - } else { - elements[cloudName].excludeRandom = true; - }; - if(isAfterScriptLoading) { - elementCount++; //increment for new cloud element - createElementButton(cloudName); - elements[cloudName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "

There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.

©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n

"; //update extra info counts (and the copyright year, due to the method used) - }; - }; - }; - - runAfterAutogen(function() { - if(generateClouds) { - liquidArray = Object.keys(elements).filter(function(e) { - return (defaultCloudCondition(e)); - }); - liquidArray.push(["rock","sand"]); - generateCloud(liquidArray,false); - }; - }); - - elements.random_cloud = { - color: ["#3e5f8a","#a334ec","#ea96f9","#a6ecf6","#70ebc8","#d9286b","#7eed91","#a18b30"], - behavior: behaviors.WALL, - category: "special", - excludeRandom: true, - tick: function(pixel) { - changePixel(pixel,cloudChoices[Math.floor(Math.random() * cloudChoices.length)]) - }, - }; -} else { - if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; - if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) }; - alert(`The "${runAfterAutogenMod}" and "${libraryMod}" mods are required; any missing mods in this list have been automatically inserted (reload for this to take effect).`) - localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); -}; diff --git a/mods/more_fairies.js b/mods/more_fairies.js deleted file mode 100644 index 244b765d..00000000 --- a/mods/more_fairies.js +++ /dev/null @@ -1,382 +0,0 @@ -var modName = "mods/more_fairies.js"; -var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; -var libraryMod = "mods/code_library.js"; -var feyAndMoreMod = "mods/fey_and_more.js"; - -if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod) && enabledMods.includes(feyAndMoreMod)) { - //keep old fairies - elements.acid_fairy = { - name: "acid fairy", - color: ["#e2f777","#d1ff94","#d8f7c1"], - behavior: [ - "XX|M1|M1", - "XX|FX%5|XX", - "XX|CR:acid%0.5 AND CR:fairy_dust%0.005 AND M1|M1", - ], - state: "solid", - category: "fey", - desc: "Like the other fairies, but with acid.
To enable automatic fairy generation, set the generateFairies query parameter.", - } - - elements.oil_fairy = { - name: "oil fairy", - color: ["#636360","#a6956f","#a3816d","#cfc191"], - behavior: [ - "XX|M1|M1", - "XX|FX%5|XX", - "XX|CR:oil%0.5 AND CR:fairy_dust%0.005 AND M1|M1", - ], - state: "solid", - category: "fey", - desc: "Like the other fairies, but with oil.
To enable automatic fairy generation, set the generateFairies query parameter.", - } - - elements.honey_fairy = { - name: "honey fairy", - color: ["#ffeaa6","#ffe987","#f2e7c2"], - behavior: [ - "XX|M1|M1", - "XX|FX%5|XX", - "XX|CR:honey%0.5 AND CR:fairy_dust%0.005 AND M1|M1", - ], - state: "solid", - category: "fey", - desc: "Like the other fairies, but with sweet honey.
To enable automatic fairy generation, set the generateFairies query parameter.", - } - - var excludedFairyElements = [] - var backupCategoryWhitelist = ["land","powders","weapons","food","life","corruption","states","fey","Fantastic Creatures","dyes","energy liquids","random liquids","random gases","random rocks"]; - var backupElementWhitelist = ["mercury", "chalcopyrite_ore", "chalcopyrite_dust", "copper_concentrate", "fluxed_copper_concentrate", "unignited_pyrestone", "ignited_pyrestone", "everfire_dust", "extinguished_everfire_dust", "mistake", "polusium_oxide", "vaporized_polusium_oxide", "glowstone_dust", "redstone_dust", "soul_mud", "wet_soul_sand", "nitrogen_snow", "fusion_catalyst", "coal", "coal_coke", "blast_furnace_fuel", "molten_mythril"]; - //forces elements that logically should be fairied, but are refused even though the condition is true, to be fairied - function defaultFairyCondition(name) { - if(typeof(elements[name]) !== "object") { - throw new Error(`Nonexistent element ${name}`); - }; - var info = elements[name]; - //console.log(`${name} (${JSON.stringify(elements[name])})`); - if(typeof(info.state) === "undefined") { - var state = null; - } else { - var state = info.state; - }; - if(typeof(info.category) === "undefined") { - var category = "other"; - } else { - var category = info.category; - }; - if(excludedFairyElements.includes(name)) { - return false - }; - var include = false; - if(["liquid","gas"].includes(state)) { - include = true; - }; - if(info.movable) { - include = true; - }; - if(backupCategoryWhitelist.includes(category)) { - include = true; - }; - if(backupElementWhitelist.includes(name)) { - include = true; - }; - if(category.includes("mudstone")) { - include = true; - }; - //console.log(include); - return include; - }; - - if(urlParams.get('fairyIncludeRandom') !== null) { //if the variable exists at all - fairyIncludeRandom = true - } else { //if it doesn't (and it returns null) - fairyIncludeRandom = false - } - - //Generate fairies - if(urlParams.get('generateFairies') !== null) { //if the variable exists at all - generateFairies = true - } else { //if it doesn't (and it returns null) - generateFairies = false - } - - //Generator function - - runAfterLoad(function() { - if(typeof(eLists.FAIRY) === "undefined") { eLists.FAIRY = [] }; - eLists.FAIRY.push("acid_fairy"); - eLists.FAIRY.push("oil_fairy"); - eLists.FAIRY.push("honey_fairy"); - fairyChoices = eLists.FAIRY; - for(i = 0; i < eLists.FAIRY.length; i++) { - var fairyName = eLists.FAIRY[i]; - if(!fairyChoices.includes(fairyName)) { - fairyChoices.push(fairyName); - }; - }; - }); - - - //Standalone generator - function generateFairy(fairyElements,isAfterScriptLoading=false) {//it can be a single element, though - //To specify an array fairy, have the array be inside another array. - /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. - Otherwise, you'll get TypeErrors for some reason when trying to place your fairy. If this is being run after the game has loaded (e.g. in the console), - then isAfterScriptLoading should be true or you might also get TypeErrors (this latter case was a bit inconsistent when I tested it, but - the former case wasn't. **isAfterScriptLoading must be false when this function is run from a JS mod file**.*/ - if(typeof(fairyElements) === "string") { //it should be an array, so string check - //console.log("String detected"); - if(fairyElements.includes(",")) { //comma-separated string? - //console.log("Splitting string to array"); - fairyElements = fairyElements.split(","); //,SS to array - } else { - //console.log("Wrapping string in array"); - fairyElements = [fairyElements]; //single string to array - }; - }; - for(aaf = 0; aaf < fairyElements.length; aaf++) { - var elementOfFairy = fairyElements[aaf]; - var startColor; - var randomExcl = 0; - var isNocheer = 0; - //console.log("randomExcl set") - //console.log(elementOfFairy); - - var fairyName; - - if(typeof(elementOfFairy === "string")) { //comma separated string check - if(elementOfFairy.includes(",")) { //if it is - elementOfFairy = elementOfFairy.split(","); //to array - elementOfFairy = elementOfFairy.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(elementOfFairy)) { - fairyName = `${elementOfFairy.join("_")}_fairy`; //auto placer element name - - //array case color concatenator and excludeRandom handler - startColor = []; - //console.log(elementOfFairy); - for(ll = 0; ll < elementOfFairy.length; ll++) { - if(typeof(elements[elementOfFairy[ll]].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfFairy[ll]].excludeRandom) { //it it's true - randomExcl = 1; //the whole array fairy is excluded - //console.log("array nyet" + elementOfFairy); - }; - }; - //console.log(elementOfFairy[ll]); - startColor = startColor.concat(elements[elementOfFairy[ll]].color); - }; - - for(ll = 0; ll < elementOfFairy.length; ll++) { - if(typeof(elements[elementOfFairy[ll]].nocheer !== "undefined")) { //if nocheer exists (prevent TypeError) - if(elements[elementOfFairy[ll]].nocheer) { //it it's true - isNocheer = 1; //the whole array fairy is excluded - //console.log("array nyet" + elementOfFairy); - }; - }; - //console.log(elementOfFairy[ll]); - startColor = startColor.concat(elements[elementOfFairy[ll]].color); - }; - } else { //they should all be strings, so here - fairyName = `${elementOfFairy}_fairy`; //auto placer element name - startColor = elements[elementOfFairy].color; - if(typeof(elements[elementOfFairy].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfFairy].excludeRandom) { //it it's true - //console.log("nyet " + elementOfFairy); - randomExcl = 1; //the fairy is excluded - } else { - //console.log("allow " + elementOfFairy); - randomExcl = 0; - }; - }; - - if(typeof(elements[elementOfFairy].nocheer !== "undefined")) { //if nocheer exists (prevent TypeError) - if(elements[elementOfFairy].nocheer) { //it it's true - //console.log("nyet " + elementOfFairy); - isNocheer = 1; //the fairy is excluded - } else { - //console.log("allow " + elementOfFairy); - isNocheer = 0; - }; - }; - }; - //Color gen - if(Array.isArray(startColor)) { //Average arrays, make colors rgb() - startColor = averageRgbPrefixedColorArray(startColor); - } else { - startColor = rgbHexCatcher(startColor); - }; - - //console.log(`rgbStringToObject(${startColor}) from more_fairies.js`) - var newColorObjectArray = []; - var newColorArray = []; - - for(i = 0; i < elements.fairy.color.length; i++) { - var newFairyColorlet = elements.fairy.color[i]; - var newColor = multiplyColors(startColor,newFairyColorlet); - var newColorJSON = multiplyColors(startColor,newFairyColorlet,"json"); - newColorArray.push(newColor); - newColorObjectArray.push(newColorJSON); - }; - - //End color gen - - //The fairy - - //console.log(elementOfFairy); - var firstInfo, firstTemp; - if(Array.isArray(elementOfFairy)) { - firstInfo = elements[elementOfFairy[0]]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - } else { - firstInfo = elements[elementOfFairy]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - }; - - elementOfFairy = tryJoin(elementOfFairy,","); - - //console.log(elementOfFairy); - - if(!elementExists(fairyName)) { - elements[fairyName] = { - color: newColorArray, - insulate: true, - flippableX: true, - colorObject: newColorObjectArray, - behavior: [ - ["XX","M1","M1"], - ["XX","FX%5","XX"], - ["XX",`CR:${elementOfFairy}%0.5 AND CR:fairy_dust%0.005 AND M1`,"M1"] - ], - category: "auto_fey", - temp: firstTemp, - hardness: 1, - }; - if(typeof(eLists) === "undefined") { - eLists = {}; - }; - if(typeof(eLists.FAIRY) === "undefined") { - eLists.FAIRY = []; - }; - eLists.FAIRY.push(fairyName); - if(!randomExcl) { - if(typeof(fairyChoices) === "undefined") { - fairyChoices = [] - }; - if(!fairyChoices.includes(fairyName)) { - fairyChoices.push(fairyName); - }; - } - if(isNocheer) { - elements[fairyName].nocheer = true; - } - if(fairyIncludeRandom) { - randomExcl ? elements[fairyName].excludeRandom = true : elements[fairyName].excludeRandom = false; - } else { - elements[fairyName].excludeRandom = true; - }; - if(isAfterScriptLoading) { - elements[fairyName].flippableX = true; - elementCount++; //increment for new fairy element - if (settings.cheerful && elements[fairyName].nocheer) { - elements[fairyName].hidden = true; - hiddenCount++; - } else { - createElementButton(fairyName); - }; - elements[fairyName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "

There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.

©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n

"; //update extra info counts (and the copyright year, due to the method used) - }; - }; - }; - }; - - runAfterAutogen(function() { - if(generateFairies) { - fairyArray = Object.keys(elements).filter(function(e) { //same criteria as spouts - return (defaultFairyCondition(e)); - }); - fairyArray.push(["rock","sand"]); - generateFairy(fairyArray,false); - }; - }); - - elements.spawn_random_fairy = { - color: ["#3e5f8a","#a334ec","#ea96f9","#a6ecf6","#70ebc8","#d9286b","#7eed91","#a18b30"], - behavior: behaviors.WALL, - category: "special", - excludeRandom: true, - tick: function(pixel) { - changePixel(pixel,fairyChoices[Math.floor(Math.random() * fairyChoices.length)]) - }, - }; - - //Post-generation tasks - //Revamp fairykill - behaviors.FAIRYKILL_OLD = behaviors.FAIRYKILL; - behaviors.FAIRYKILL = function(pixel) { - if (pixel.start === pixelTicks) {return} - if (pixel.charge && elements[pixel.element].behaviorOn) { - pixelTick(pixel) - } - var ignore = []; - if(typeof(elements[pixel.element].ignore) !== "undefined") { - ignore = elements[pixel.element].ignore; - }; - for(i = 0; i < adjacentCoords.length; i++) { - var coord = adjacentCoords[i]; - var offsetX = coord[0]; - var offsetY = coord[1]; - var newX = pixel.x+offsetX; - var newY = pixel.y+offsetY; - if(!isEmpty(newX,newY,true)) { - var newPixel = pixelMap[newX][newY]; - var newElement = newPixel.element; - var isIgnored = (newElement === ignore || ignore.includes(newElement)) - if(eLists.FAIRY.includes(newElement) && !isIgnored) { - deletePixel(newX,newY); - }; - }; - }; - doDefaults(pixel); - }; - - //Add ignores - var ignoreArray = ["acid", "iron", "silver", "steel", "tungstensteel", "void", "liquid_void", "chute", "vute", "drute", "drolute", "volute", "alkahest", "acid_gas"]; - for(l = 0; l < ignoreArray.length; l++) { - var name = ignoreArray[l]; - var fairyName = `${ignoreArray[l]}_fairy`; - if(elementExists(name) && elementExists(fairyName)) { - var baseInfo = elements[name]; - if(typeof(baseInfo.ignore) === "undefined") { - baseInfo.ignore = []; - } else if(typeof(baseInfo.ignore) === "string") { - baseInfo.ignore = [baseInfo.ignore]; - }; - baseInfo.ignore.push(fairyName); - }; - }; - - //Add updated fairykills - var fairykillElements = ["iron", "silver", "steel", "tungstensteel"]; - for(q = 0; q < fairykillElements.length; q++) { - var name = fairykillElements[q]; - if(elementExists(name)) { - elements[name].behavior = behaviors.FAIRYKILL; - }; - }; -} else { - if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; - if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) }; - if(!enabledMods.includes(feyAndMoreMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,feyAndMoreMod) }; - alert(`The "${runAfterAutogenMod}", "${libraryMod}", and "${feyAndMoreMod}" mods are required; any missing mods in this list have been automatically inserted (reload for this to take effect).`) - localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); -}; diff --git a/mods/spouts.js b/mods/spouts.js deleted file mode 100644 index 4f875be0..00000000 --- a/mods/spouts.js +++ /dev/null @@ -1,255 +0,0 @@ -var modName = "mods/spouts.js"; -var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js"; -var libraryMod = "mods/code_library.js"; - -if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) { - spoutChoices = ["spout", "udder", "torch"]; - - //Generate spouts - if(urlParams.get('generateSpouts') !== null) { //if the variable exists at all - generateSpouts = true - } else { //if it doesn't (and it returns null) - generateSpouts = false - } - - if(urlParams.get('spoutIncludeRandom') !== null) { //if the variable exists at all - spoutIncludeRandom = true - } else { //if it doesn't (and it returns null) - spoutIncludeRandom = false - } - - eLists.SPOUT = ["spout", "udder", "torch"]; - var excludedSpoutElements = ["ketchup", "liquid_cloner", "fire_cloner"] - var includedSpouts = ["ketchup_spout", "spout", "udder", "torch"] - var backupCategoryWhitelist = ["land","powders","weapons","food","life","corruption","states","fey","Fantastic Creatures","dyes","energy liquids","random liquids","random gases","random rocks"]; - var backupElementWhitelist = ["mercury", "chalcopyrite_ore", "chalcopyrite_dust", "copper_concentrate", "fluxed_copper_concentrate", "unignited_pyrestone", "ignited_pyrestone", "everfire_dust", "extinguished_everfire_dust", "mistake", "polusium_oxide", "vaporized_polusium_oxide", "glowstone_dust", "redstone_dust", "soul_mud", "wet_soul_sand", "nitrogen_snow", "fusion_catalyst", "coal", "coal_coke", "blast_furnace_fuel", "molten_mythril"]; - //forces elements that logically should be spouted, but are refused even though the condition is true, to be spouted - function defaultSpoutCondition(name) { - if(typeof(elements[name]) !== "object") { - throw new Error(`Nonexistent element ${name}`); - }; - var info = elements[name]; - //console.log(`${name} (${JSON.stringify(elements[name])})`); - if(typeof(info.state) === "undefined") { - var state = null; - } else { - var state = info.state; - }; - if(typeof(info.category) === "undefined") { - var category = "other"; - } else { - var category = info.category; - }; - if(excludedSpoutElements.includes(name)) { - return false - }; - var include = false; - if(["liquid","gas"].includes(state)) { - include = true; - }; - if(info.movable) { - include = true; - }; - if(backupCategoryWhitelist.includes(category)) { - include = true; - }; - if(backupElementWhitelist.includes(name)) { - include = true; - }; - if(category.includes("mudstone")) { - include = true; - }; - //console.log(include); - return include; - }; - -//Generator function - - //Standalone generator - function generateSpout(spoutElements,isAfterScriptLoading=false) {//it can be a single element, though - //To specify an array spout, have the array be inside another array. - /*For reasons related to how element colors are loaded, if this function is being run from a JS mod file, isAfterScriptLoading should be false. - Otherwise, you'll get TypeErrors for some reason when trying to place your spout. If this is being run after the game has loaded (e.g. in the console), - then isAfterScriptLoading should be true or you might also get TypeErrors (this latter case was a bit inconsistent when I tested it, but - the former case wasn't. **isAfterScriptLoading must be false when this function is run from a JS mod file**.*/ - if(typeof(spoutElements) === "string") { //it should be an array, so string check - //console.log("String detected"); - if(spoutElements.includes(",")) { //comma-separated string? - //console.log("Splitting string to array"); - spoutElements = spoutElements.split(","); //,SS to array - } else { - //console.log("Wrapping string in array"); - spoutElements = [spoutElements]; //single string to array - }; - }; - for(aaf = 0; aaf < spoutElements.length; aaf++) { - var elementOfSpout = spoutElements[aaf]; - var startColor; - var randomExcl = 0; - var isNocheer = 0; - //console.log("randomExcl set") - //console.log(elementOfSpout); - - var spoutName; - - if(typeof(elementOfSpout === "string")) { //comma separated string check - if(elementOfSpout.includes(",")) { //if it is - elementOfSpout = elementOfSpout.split(","); //to array - elementOfSpout = elementOfSpout.filter(function(e) { //strip nonexistent elements - return typeof(elements[e]) === "object"; - }); - }; - }; - if(Array.isArray(elementOfSpout)) { - spoutName = `${elementOfSpout.join("_")}_spout`; //auto placer element name - - //array case color concatenator and excludeRandom handler - startColor = []; - //console.log(elementOfSpout); - for(ll = 0; ll < elementOfSpout.length; ll++) { - if(typeof(elements[elementOfSpout[ll]].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfSpout[ll]].excludeRandom) { //it it's true - randomExcl = 1; //the whole array spout is excluded - //console.log("array nyet" + elementOfSpout); - }; - }; - //console.log(elementOfSpout[ll]); - startColor = startColor.concat(elements[elementOfSpout[ll]].color); - }; - - for(ll = 0; ll < elementOfSpout.length; ll++) { - if(typeof(elements[elementOfSpout[ll]].nocheer !== "undefined")) { //if nocheer exists (prevent TypeError) - if(elements[elementOfSpout[ll]].nocheer) { //it it's true - isNocheer = 1; //the whole array spout is excluded - //console.log("array nyet" + elementOfSpout); - }; - }; - //console.log(elementOfSpout[ll]); - startColor = startColor.concat(elements[elementOfSpout[ll]].color); - }; - } else { //they should all be strings, so here - spoutName = `${elementOfSpout}_spout`; //auto placer element name - startColor = elements[elementOfSpout].color; - if(typeof(elements[elementOfSpout].excludeRandom !== "undefined")) { //if excludeRandom exists (prevent TypeError) - if(elements[elementOfSpout].excludeRandom) { //it it's true - //console.log("nyet " + elementOfSpout); - randomExcl = 1; //the spout is excluded - } else { - //console.log("allow " + elementOfSpout); - randomExcl = 0; - }; - }; - - if(typeof(elements[elementOfSpout].nocheer !== "undefined")) { //if nocheer exists (prevent TypeError) - if(elements[elementOfSpout].nocheer) { //it it's true - //console.log("nyet " + elementOfSpout); - isNocheer = 1; //the spout is excluded - } else { - //console.log("allow " + elementOfSpout); - isNocheer = 0; - }; - }; - }; - //Color gen - if(Array.isArray(startColor)) { //Average arrays, make colors rgb() - startColor = averageRgbPrefixedColorArray(startColor); - } else { - startColor = rgbHexCatcher(startColor); - }; - - var newColorObject = rgbStringToObject(startColor); - - //End color gen - - //The spout - - //console.log(elementOfSpout); - var firstInfo, firstTemp; - if(Array.isArray(elementOfSpout)) { - firstInfo = elements[elementOfSpout[0]]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - } else { - firstInfo = elements[elementOfSpout]; - firstTemp = airTemp; - if(typeof(firstInfo.temp) !== "undefined") { - firstTemp = firstInfo.temp; - }; - }; - - elementOfSpout = tryJoin(elementOfSpout,","); - - //console.log(elementOfSpout); - - elements[spoutName] = { - color: startColor, - insulate: true, - colorObject: newColorObject, - behavior: [ - ["XX",`CR:${elementOfSpout}`,"XX"], - [`CR:${elementOfSpout}`,"XX",`CR:${elementOfSpout}`], - ["XX",`CR:${elementOfSpout}`,"XX"] - ], - category: "spouts", - temp: firstTemp, - hardness: 1, - }; - if(!randomExcl) { - if(typeof(spoutChoices) === "undefined") { - spoutChoices = [] - }; - if(!spoutChoices.includes(spoutName)) { - spoutChoices.push(spoutName); - }; - } - if(spoutIncludeRandom) { - randomExcl ? elements[spoutName].excludeRandom = true : elements[spoutName].excludeRandom = false; - } else { - elements[spoutName].excludeRandom = true; - }; - if(isNocheer) { - elements[spoutName].nocheer = true; - } - if(isAfterScriptLoading) { - elementCount++; //increment for new spout element - if (settings.cheerful && elements[spoutName].nocheer) { - elements[spoutName].hidden = true; - hiddenCount++; - } else { - createElementButton(spoutName); - }; - elements[spoutName].id = nextid++; - document.getElementById("extraInfo").innerHTML = "

There are " + elementCount + " elements, including " + hiddenCount + " hidden ones.

©2021-" + new Date().getFullYear() + ". All Rights Reserved. R74n

"; //update extra info counts (and the copyright year, due to the method used) - }; - - eLists.SPOUT.push(spoutName); - }; - }; - - runAfterAutogen(function() { - if(generateSpouts) { - liquidArray = Object.keys(elements).filter(function(e) { - return (defaultSpoutCondition(e)); - }); - liquidArray.push(["rock","sand"]); - generateSpout(liquidArray,false); - }; - }); - - elements.random_spout = { - color: ["#3e5f8a","#a334ec","#ea96f9","#a6ecf6","#70ebc8","#d9286b","#7eed91","#a18b30"], - behavior: behaviors.WALL, - category: "special", - excludeRandom: true, - tick: function(pixel) { - changePixel(pixel,spoutChoices[Math.floor(Math.random() * spoutChoices.length)]) - }, - }; -} else { - if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) }; - if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) }; - alert(`The "${runAfterAutogenMod}" and "${libraryMod}" mods are required; any missing mods in this list have been automatically inserted (reload for this to take effect).`) - localStorage.setItem("enabledMods", JSON.stringify(enabledMods)); -};