2022-02-04 20:01:14 -05:00
|
|
|
// Mod deprecated. Merged with base game.
|
|
|
|
|
|
|
|
|
|
/*elements.human = {
|
2022-01-31 18:56:18 -05:00
|
|
|
color: ["#f5eac6","#d4c594","#a89160","#7a5733","#523018","#361e0e"],
|
|
|
|
|
category: "life",
|
|
|
|
|
properties: {
|
2022-01-31 20:53:28 -05:00
|
|
|
dead: false,
|
|
|
|
|
dir: 1,
|
2022-02-01 23:22:13 -05:00
|
|
|
panic: 0,
|
2022-01-31 18:56:18 -05:00
|
|
|
},
|
|
|
|
|
tick: function(pixel) {
|
|
|
|
|
if (isEmpty(pixel.x, pixel.y+1)) {
|
|
|
|
|
createPixel("body", pixel.x, pixel.y+1);
|
|
|
|
|
pixel.element = "head";
|
|
|
|
|
}
|
|
|
|
|
else if (isEmpty(pixel.x, pixel.y-1)) {
|
|
|
|
|
createPixel("head", pixel.x, pixel.y-1);
|
|
|
|
|
pixelMap[pixel.x][pixel.y-1].color = pixel.color;
|
|
|
|
|
pixel.element = "body";
|
|
|
|
|
pixel.color = pixelColorPick(pixel)
|
|
|
|
|
}
|
|
|
|
|
else {
|
|
|
|
|
deletePixel(pixel.x, pixel.y);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
2022-02-01 23:22:13 -05:00
|
|
|
// If pixelTicks%60 == 0, look left and right from the head 20 pixels.
|
|
|
|
|
// If something favorable is found, set target to that pixel.
|
|
|
|
|
// If something unfavorable is found, set target to a few pixels in the opposite direction. Raise panic attribute.
|
|
|
|
|
// If nothing is found, set target to null.
|
|
|
|
|
// If target is not null, switch direction towards target.
|
|
|
|
|
// Favorable Things: food category, wood, tree_branch, plant, bamboo, gold_coin, firefly, frog
|
|
|
|
|
// Unfavorable Things: acid, fire, magma, plasma, cold_fire, electric, laser, infection, cancer, rat, bee, blood, weapons category, superheater, freezer, tesla_coil, virus, gray_goo, antimatter, void
|
|
|
|
|
// Panic attribute, 0-1, increases movement rate.
|
|
|
|
|
// On fire raises panic.
|
|
|
|
|
// Trample: grass, petal, pistil
|
|
|
|
|
// Regulate temperature.
|
|
|
|
|
|
|
|
|
|
|
2022-01-31 18:56:18 -05:00
|
|
|
elements.body = {
|
|
|
|
|
color: ["#049699","#638A61"],
|
|
|
|
|
category: "life",
|
|
|
|
|
hidden: true,
|
2022-02-01 23:22:13 -05:00
|
|
|
density: 1500,
|
2022-01-31 20:53:28 -05:00
|
|
|
state: "solid",
|
|
|
|
|
conduct: 25,
|
|
|
|
|
tempHigh: 250,
|
|
|
|
|
stateHigh: "cooked_meat",
|
|
|
|
|
tempLow: -30,
|
|
|
|
|
stateLow: "frozen_meat",
|
|
|
|
|
burn: 10,
|
|
|
|
|
burnTime: 250,
|
|
|
|
|
burnInto: "cooked_meat",
|
|
|
|
|
reactions: {
|
|
|
|
|
"cancer": { "elem1":"cancer", "chance":0.005 },
|
2022-02-04 20:01:14 -05:00
|
|
|
"radiation": { "elem1":["ash","meat","rotten_meat","cooked_meat"], "chance":0.4 },
|
2022-01-31 20:53:28 -05:00
|
|
|
},
|
2022-01-31 18:56:18 -05:00
|
|
|
properties: {
|
2022-01-31 20:53:28 -05:00
|
|
|
dead: false,
|
|
|
|
|
dir: 1,
|
2022-02-01 23:22:13 -05:00
|
|
|
panic: 0,
|
2022-01-31 18:56:18 -05:00
|
|
|
},
|
|
|
|
|
tick: function(pixel) {
|
2022-02-04 20:01:14 -05:00
|
|
|
if (tryMove(pixel, pixel.x, pixel.y+1)) { // Fall
|
2022-01-31 18:56:18 -05:00
|
|
|
if (!isEmpty(pixel.x, pixel.y-2, true)) { // Drag head down
|
|
|
|
|
var headpixel = pixelMap[pixel.x][pixel.y-2];
|
|
|
|
|
if (headpixel.element == "head") {
|
2022-02-01 23:22:13 -05:00
|
|
|
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]);
|
|
|
|
|
}
|
2022-01-31 18:56:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
doHeat(pixel);
|
2022-01-31 20:53:28 -05:00
|
|
|
doBurning(pixel);
|
|
|
|
|
doElectricity(pixel);
|
|
|
|
|
if (pixel.dead) {
|
|
|
|
|
// Turn into rotten_meat if pixelTicks-dead > 500
|
|
|
|
|
if (pixelTicks-pixel.dead > 200) {
|
|
|
|
|
pixel.element = "rotten_meat";
|
|
|
|
|
pixel.color = pixelColorPick(pixel);
|
|
|
|
|
}
|
|
|
|
|
return
|
|
|
|
|
}
|
2022-01-31 19:11:59 -05:00
|
|
|
|
|
|
|
|
// Find the head
|
|
|
|
|
if (!isEmpty(pixel.x, pixel.y-1, true) && pixelMap[pixel.x][pixel.y-1].element == "head") {
|
|
|
|
|
var head = pixelMap[pixel.x][pixel.y-1];
|
2022-01-31 20:53:28 -05:00
|
|
|
if (head.dead) { // If head is dead, kill body
|
|
|
|
|
pixel.dead = head.dead;
|
|
|
|
|
}
|
2022-01-31 19:11:59 -05:00
|
|
|
}
|
|
|
|
|
else { var head = null }
|
|
|
|
|
|
2022-01-31 18:56:18 -05:00
|
|
|
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) {
|
2022-01-31 20:53:28 -05:00
|
|
|
pixel.dead = pixelTicks;
|
2022-01-31 18:56:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-31 19:11:59 -05:00
|
|
|
else if (head == null) { return }
|
2022-01-31 18:56:18 -05:00
|
|
|
else if (Math.random() < 0.1) { // Move 10% chance
|
|
|
|
|
var movesToTry = [
|
2022-01-31 20:53:28 -05:00
|
|
|
[1*pixel.dir,0],
|
|
|
|
|
[1*pixel.dir,-1],
|
2022-01-31 19:11:59 -05:00
|
|
|
];
|
2022-01-31 18:56:18 -05:00
|
|
|
// 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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-01-31 20:53:28 -05:00
|
|
|
// 15% chance to change direction
|
|
|
|
|
if (Math.random() < 0.15) {
|
|
|
|
|
pixel.dir *= -1;
|
|
|
|
|
}
|
2022-01-31 18:56:18 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
},
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
elements.head = {
|
|
|
|
|
color: ["#f5eac6","#d4c594","#a89160","#7a6433","#524018"],
|
|
|
|
|
category: "life",
|
|
|
|
|
hidden: true,
|
2022-01-31 20:53:28 -05:00
|
|
|
density: 1080,
|
|
|
|
|
state: "solid",
|
|
|
|
|
conduct: 25,
|
|
|
|
|
tempHigh: 250,
|
|
|
|
|
stateHigh: "cooked_meat",
|
|
|
|
|
tempLow: -30,
|
|
|
|
|
stateLow: "frozen_meat",
|
|
|
|
|
burn: 10,
|
|
|
|
|
burnTime: 250,
|
|
|
|
|
burnInto: "cooked_meat",
|
2022-02-04 20:01:14 -05:00
|
|
|
reactions: {
|
|
|
|
|
"cancer": { "elem1":"cancer", "chance":0.005 },
|
|
|
|
|
"radiation": { "elem1":["ash","meat","rotten_meat","cooked_meat"], "chance":0.4 },
|
|
|
|
|
},
|
2022-01-31 18:56:18 -05:00
|
|
|
properties: {
|
|
|
|
|
dead: false
|
|
|
|
|
},
|
|
|
|
|
tick: function(pixel) {
|
2022-01-31 20:53:28 -05:00
|
|
|
doHeat(pixel);
|
|
|
|
|
doBurning(pixel);
|
|
|
|
|
doElectricity(pixel);
|
|
|
|
|
if (pixel.dead) {
|
|
|
|
|
// Turn into rotten_meat if pixelTicks-dead > 500
|
|
|
|
|
if (pixelTicks-pixel.dead > 200) {
|
|
|
|
|
pixel.element = "rotten_meat";
|
|
|
|
|
pixel.color = pixelColorPick(pixel);
|
|
|
|
|
return
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Find the body
|
|
|
|
|
if (!isEmpty(pixel.x, pixel.y+1, true) && pixelMap[pixel.x][pixel.y+1].element == "body") {
|
|
|
|
|
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 }
|
|
|
|
|
|
2022-01-31 18:56:18 -05:00
|
|
|
if (isEmpty(pixel.x, pixel.y+1)) {
|
2022-01-31 20:53:28 -05:00
|
|
|
tryMove(pixel, pixel.x, pixel.y+1);
|
2022-01-31 18:56:18 -05:00
|
|
|
// 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) {
|
2022-01-31 20:53:28 -05:00
|
|
|
pixel.dead = pixelTicks;
|
2022-01-31 18:56:18 -05:00
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!elements.blood.reactions) {
|
|
|
|
|
elements.blood.reactions = {};
|
|
|
|
|
}
|
|
|
|
|
// Blood mud
|
|
|
|
|
elements.blood.reactions.dirt = {
|
|
|
|
|
"elem1": null,
|
|
|
|
|
"elem2": "mud",
|
|
|
|
|
}
|
|
|
|
|
// Blood sand
|
|
|
|
|
elements.blood.reactions.sand = {
|
|
|
|
|
"elem1": null,
|
|
|
|
|
"elem2": "wet_sand",
|
2022-02-04 20:01:14 -05:00
|
|
|
}*/
|