Merge pull request #1308 from Cube14yt/static_mod
This commit is contained in:
commit
d5f4ceb062
|
|
@ -4,9 +4,7 @@ v 0.11 "axolotl" eats fish
|
|||
v 0.2 crocodiles scales and axolotls actually eat fish now
|
||||
v 0.3 chameleons + bugfixes
|
||||
v 0.4 turtles, tortoise + improved logic
|
||||
|
||||
|
||||
thats it for now
|
||||
v 0.41 Bugfixes (How was this even working before this fix)
|
||||
*/
|
||||
|
||||
const defaultColors = ["#02c937", "#18d64a", "#09e644"];
|
||||
|
|
@ -73,10 +71,6 @@ function poisonOther(pixel1, pixel2) {
|
|||
pixel2.poisoned ??= 30;
|
||||
}
|
||||
|
||||
function isInBounds(x, y) {
|
||||
return x >= 0 && x < width && y >= 0 && y < height;
|
||||
}
|
||||
|
||||
elements.human.reactions.snake =
|
||||
{ attr1: { panic: 5 } }
|
||||
|
||||
|
|
@ -87,7 +81,7 @@ if (!elements.glue.ignore.includes("scale")) {
|
|||
elements.glue.ignore.push("scale");
|
||||
}
|
||||
|
||||
danger = ["crocodile", "snake"];
|
||||
let danger = ["crocodile", "snake"];
|
||||
|
||||
|
||||
|
||||
|
|
@ -219,7 +213,6 @@ elements.toad_tadpole = {
|
|||
"bleach": { elem1: null, chance: 0.05 },
|
||||
"poison": { elem1: null },
|
||||
"radiation": { elem1: ["toad", "toad", "frog", "worm", null], chance: 0.4 },
|
||||
"poison": { elem1: null },
|
||||
"poison_gas": { elem1: null },
|
||||
},
|
||||
tempHigh: 100,
|
||||
|
|
@ -362,10 +355,10 @@ elements.snake = {
|
|||
"slug": { elem2: null, func: behaviors.FEEDPIXEL },
|
||||
"snail": { elem2: "limestone", func: behaviors.FEEDPIXEL },
|
||||
"egg": {
|
||||
elem2: "egg",
|
||||
func: function (pixel1, pixel2) {
|
||||
if (pixel2.animal === "snake") return; // Don't eat own egg
|
||||
behaviors.FEEDPIXEL(pixel1, pixel2);
|
||||
behaviors.FEEDPIXEL(pixel1);
|
||||
deletePixel(pixel2.x, pixel2.y)
|
||||
}
|
||||
},
|
||||
"radiation": { elem1: ["ash", "meat", "cooked_meat", "rotten_meat", "lizard", "crocodile", null], chance: 0.4 },
|
||||
|
|
@ -433,10 +426,10 @@ elements.crocodile = {
|
|||
"head": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"human": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"chameleon": {
|
||||
reactionFunction: function (pixel, otherPixel) {
|
||||
func: function (pixel, otherPixel) {
|
||||
let isNormalColor = defaultColors.includes(pixel.color);
|
||||
if (otherPixel.threatened !== true || isNormalColor === true) {
|
||||
behaviors.FEEDPIXEL(pixel, otherPixel);
|
||||
behaviors.FEEDPIXEL(pixel);
|
||||
deletePixel(otherPixel.x, otherPixel.y)
|
||||
}
|
||||
}
|
||||
|
|
@ -704,11 +697,6 @@ elements.turtle = {
|
|||
state: "solid",
|
||||
category: "life",
|
||||
foodNeed: 10,
|
||||
tempHigh: 100,
|
||||
stateHigh: "cooked_meat",
|
||||
tempLow: -10,
|
||||
stateLow: "frozen_meat",
|
||||
breakInto: ["scute", "blood", "meat", "limestone"],
|
||||
reactions: {
|
||||
"fish": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.1 },
|
||||
"kelp": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.5 },
|
||||
|
|
@ -726,44 +714,16 @@ elements.turtle = {
|
|||
"poison": { elem1: "limestone" },
|
||||
"poison_gas": { elem1: "limestone" },
|
||||
},
|
||||
}
|
||||
|
||||
elements.tortoise = {
|
||||
color: ["#47b000", "#406000"],
|
||||
behavior: [
|
||||
"XX|XX|XX",
|
||||
"XX|FX%1|M2%5",
|
||||
"M2|M1|M2",
|
||||
],
|
||||
density: 1080,
|
||||
state: "solid",
|
||||
category: "life",
|
||||
foodNeed: 10,
|
||||
tempHigh: 100,
|
||||
stateHigh: "cooked_meat",
|
||||
tempLow: -10,
|
||||
stateLow: "frozen_meat",
|
||||
breakInto: ["blood", "meat", "limestone"],
|
||||
reactions: {
|
||||
"grass": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"plant": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"evergreen": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"pistil": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"petal": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"lettuce": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"tomato": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"pumpkin": { elem2: null, func: behaviors.FEEDPIXEL, chance: 0.2 },
|
||||
"radiation": { elem1: ["ash", "meat", "cooked_meat", "rotten_meat", "limestone"], chance: 0.4 },
|
||||
"oxygen": { elem2: "carbon_dioxide", chance: 0.5 },
|
||||
"mercury": { elem1: "rotten_meat", chance: 0.1 },
|
||||
"bleach": { elem1: "rotten_meat", chance: 0.1 },
|
||||
"infection": { elem1: "rotten_meat", chance: 0.025 },
|
||||
"uranium": { elem1: "rotten_meat", chance: 0.1 },
|
||||
"cyanide": { elem1: "rotten_meat", chance: 0.1 },
|
||||
"chlorine": { elem1: "meat", chance: 0.1 },
|
||||
"alcohol": { elem1: "meat", chance: 0.025 },
|
||||
"vinegar": { elem1: "rotten_meat", chance: 0.001 },
|
||||
"poison": { elem1: "limestone" },
|
||||
"poison_gas": { elem1: "limestone" },
|
||||
tick: function (pixel) {
|
||||
pixel.cd ??= 600;
|
||||
pixel.cd--;
|
||||
for (let i = 0; i < squareCoords.length; i++) {
|
||||
let x = pixel.x + squareCoords[i][0];
|
||||
let y = pixel.y + squareCoords[i][1];
|
||||
if (isEmpty(x, y) && pixel.cd <= 0 && Math.random() <= 0.005) {
|
||||
createPixel("scute", x, y);
|
||||
pixel.cd = 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -797,7 +797,7 @@ elements.rgb_led = {
|
|||
promptInput("Enter red value (0-255):", function (r_inp) {
|
||||
r_inp = parseInt(r_inp);
|
||||
if (r_inp > 255 || r_inp < 0 || isNaN(r_inp)) {
|
||||
logMessage("Red value is invalid, using default/last red value: " + r);
|
||||
logMessage("Red value is invalid, using default/last red value: " + globals.red);
|
||||
} else {
|
||||
globals.red = r_inp;
|
||||
}
|
||||
|
|
@ -805,7 +805,7 @@ elements.rgb_led = {
|
|||
promptInput("Enter green value (0-255):", function (g_inp) {
|
||||
g_inp = parseInt(g_inp);
|
||||
if (g_inp > 255 || g_inp < 0 || isNaN(g_inp)) {
|
||||
logMessage("Green value is invalid, using default/last green value: " + g);
|
||||
logMessage("Green value is invalid, using default/last green value: " + globals.green);
|
||||
} else {
|
||||
globals.green = g_inp;
|
||||
}
|
||||
|
|
@ -813,7 +813,7 @@ elements.rgb_led = {
|
|||
promptInput("Enter blue value (0-255):", function (b_inp) {
|
||||
b_inp = parseInt(b_inp);
|
||||
if (b_inp > 255 || b_inp < 0 || isNaN(b_inp)) {
|
||||
logMessage("Blue value is invalid, using default/last blue value: " + b);
|
||||
logMessage("Blue value is invalid, using default/last blue value: " + globals.blue);
|
||||
} else {
|
||||
globals.blue = b_inp;
|
||||
}
|
||||
|
|
@ -823,7 +823,7 @@ elements.rgb_led = {
|
|||
},
|
||||
|
||||
onPlace: (pixel) => {
|
||||
var ledColor = RGBToHex([red, green, blue]);
|
||||
var ledColor = RGBToHex([globals.red, globals.green, globals.blue]);
|
||||
pixel.color = ledColor;
|
||||
}
|
||||
};
|
||||
|
|
@ -1321,7 +1321,7 @@ elements.custom_bomb = {
|
|||
|
||||
// If pixel is at the bottom or resting on a solid
|
||||
if (outOfBounds(pixel.x, pixel.y + 1) || (belowPixel && belowPixel.element !== "custom_bomb" && !isEmpty(pixel.x, pixel.y + 1) && belowPixel.element !== "fire" && belowPixel.element !== "smoke")) {
|
||||
explodeAt(pixel.x, pixel.y, 10, explodeElem);
|
||||
explodeAt(pixel.x, pixel.y, 10, globals.explodeElem);
|
||||
deletePixel(pixel.x, pixel.y);
|
||||
}
|
||||
}
|
||||
|
|
@ -1667,7 +1667,7 @@ elements.robot_body = {
|
|||
};
|
||||
|
||||
// Robot creator element
|
||||
var mode = "Aimless"
|
||||
globals.mode = "Aimless"
|
||||
elements.robot = {
|
||||
color: "#b1b1b1",
|
||||
category: "machines",
|
||||
|
|
@ -1679,10 +1679,10 @@ elements.robot = {
|
|||
(choice) => {
|
||||
if (choice === "Controlled" && isMobile) {
|
||||
logMessage("Controlled mode doesn't work on mobile");
|
||||
mode = "Aimless";
|
||||
globals.mode = "Aimless";
|
||||
} else {
|
||||
mode = choice || "Aimless";
|
||||
if (mode === "Controlled") {
|
||||
globals.mode = choice || "Aimless";
|
||||
if (globals.mode === "Controlled") {
|
||||
logMessage("Controls: A/D to move and W to jump or (Not reccomended) ←/→ to move, and ↑ to jump");
|
||||
}
|
||||
}
|
||||
|
|
@ -1695,17 +1695,17 @@ elements.robot = {
|
|||
if (isEmpty(pixel.x, pixel.y - 1)) {
|
||||
createPixel("robot_head", pixel.x, pixel.y - 1);
|
||||
const head = getPixel(pixel.x, pixel.y - 1);
|
||||
head.mode = mode;
|
||||
head.mode = globals.mode;
|
||||
changePixel(pixel, "robot_body");
|
||||
pixel.mode = mode;
|
||||
pixel.mode = globals.mode;
|
||||
}
|
||||
// Try to create body below if above is blocked
|
||||
else if (isEmpty(pixel.x, pixel.y + 1)) {
|
||||
createPixel("robot_body", pixel.x, pixel.y + 1);
|
||||
const body = getPixel(pixel.x, pixel.y + 1);
|
||||
body.mode = mode;
|
||||
body.mode = globals.mode;
|
||||
changePixel(pixel, "robot_head");
|
||||
pixel.mode = mode;
|
||||
pixel.mode = globals.mode;
|
||||
}
|
||||
// Delete if no space
|
||||
else {
|
||||
|
|
@ -2017,7 +2017,7 @@ elements.indestructable_filter = {
|
|||
}
|
||||
}
|
||||
|
||||
globals.glass_hole_expand = false
|
||||
globals.blackHoleExpand = false
|
||||
elements.black_hole = {
|
||||
color: "#111111",
|
||||
hardness: 1,
|
||||
|
|
@ -2105,7 +2105,7 @@ elements.black_hole = {
|
|||
}
|
||||
}
|
||||
}
|
||||
if (globals.glass_hole_expand) {
|
||||
if (globals.blackHoleExpand) {
|
||||
for (var i = 0; i < adjacentCoords.length; i++) {
|
||||
var x = pixel.x + adjacentCoords[i][0];
|
||||
var y = pixel.y + adjacentCoords[i][1];
|
||||
|
|
@ -2127,10 +2127,10 @@ elements.black_hole = {
|
|||
choice = "No"
|
||||
}
|
||||
if (choice == "Yes") {
|
||||
globals.glass_hole_expand = true
|
||||
globals.blackHoleExpand = true
|
||||
}
|
||||
else {
|
||||
globals.glass_hole_expand = false
|
||||
globals.blackHoleExpand = false
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
@ -3326,4 +3326,3 @@ elements.replace_all_of_element = {
|
|||
}
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,42 @@
|
|||
// IIFE to prevent this mod from breaking
|
||||
(() => {
|
||||
let staticMode = 0
|
||||
|
||||
function randomGrayscale() {
|
||||
const value = Math.floor(Math.random() * 256);
|
||||
return `rgb(${value}, ${value}, ${value})`;
|
||||
}
|
||||
|
||||
function randomColor() {
|
||||
const letters = "0123456789ABCDEF";
|
||||
let color = "#";
|
||||
for (let i = 0; i < 6; i++) {
|
||||
color += letters[Math.floor(Math.random() * 16)];
|
||||
}
|
||||
return color;
|
||||
}
|
||||
|
||||
function loopScreen(callback) {
|
||||
for (let x = 0; x <= width; x++) {
|
||||
for (let y = 0; y <= height; y++) {
|
||||
callback(x, y)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
keybinds["KeyS"] = () => {
|
||||
staticMode === 0 ? staticMode = 1 : staticMode === 1 ? staticMode = 2 : staticMode = 0
|
||||
}
|
||||
|
||||
renderPostPixel(function (ctx) {
|
||||
if (!staticMode) return
|
||||
loopScreen((x, y) => {
|
||||
if (staticMode === 1) {
|
||||
drawSquare(ctx, randomGrayscale(), x, y, 1, 0.2)
|
||||
}
|
||||
if (staticMode === 2) {
|
||||
drawSquare(ctx, randomColor(), x, y, 1, 0.3)
|
||||
}
|
||||
})
|
||||
})
|
||||
})()
|
||||
Loading…
Reference in New Issue