buff falling pixel and use runAfterAutogen
This commit is contained in:
parent
5b7686a220
commit
be7236a9b6
|
|
@ -1,3 +1,8 @@
|
|||
var modName = "mods/insane_random_events.js";
|
||||
var runAfterAutogenMod = "mods/runAfterAutogen and onload restructure.js";
|
||||
var libraryMod = "mods/code_library.js";
|
||||
|
||||
if(enabledMods.includes(runAfterAutogenMod) && enabledMods.includes(libraryMod)) {
|
||||
if(typeof(width) === "undefined") {
|
||||
width = 20;
|
||||
}
|
||||
|
|
@ -5,30 +10,31 @@ if(typeof(height) === "undefined") {
|
|||
height = 10;
|
||||
}
|
||||
|
||||
runAfterLoad(function() {
|
||||
runAfterAutogen(function() {
|
||||
//Regenerate randomChoices
|
||||
var randomChoices = Object.keys(elements).filter(function(e) {
|
||||
return elements[e].excludeRandom != true && elements[e].category != "tools" && !elements[e].tool;
|
||||
});
|
||||
|
||||
//Set all event choices to randomChoices
|
||||
randomEventChoices = {
|
||||
"falling_pixel": randomChoices,
|
||||
"falling_pixel": randomChoices.filter( function(elem) { return commonMovableCriteria(elem) } ),
|
||||
"element_circle": randomChoices,
|
||||
"explosion": randomChoices,
|
||||
}
|
||||
|
||||
//Buff event functions
|
||||
randomEvents.old_falling_pixel = randomEvents.falling_pixel;
|
||||
//transform falling_pixel into a rain of pixels
|
||||
randomEvents.falling_pixel = function() {
|
||||
//console.log("changed");
|
||||
// random x between 1 and width-1
|
||||
var x = Math.floor(Math.random()*(width-1))+1;
|
||||
// random y between 1 and 6
|
||||
var y = Math.floor(Math.random()*6)+1;
|
||||
if (isEmpty(x,y)) {
|
||||
// random element from randomEventChoices.falling_pixel
|
||||
var element = randomEventChoices.falling_pixel[Math.floor(Math.random()*randomEventChoices.falling_pixel.length)];
|
||||
// if element is an array, choose a random element from the array
|
||||
if (Array.isArray(element)) {
|
||||
element = element[Math.floor(Math.random()*element.length)];
|
||||
}
|
||||
createPixel(element,x,y);
|
||||
}
|
||||
for(i = 1; i < width; i++) {
|
||||
for(j = 0; j < Math.round(height * 0.35); j++) {
|
||||
if(Math.random() < 0.1 && isEmpty(i,j)) {
|
||||
createPixel(element,i,j)
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
randomEvents.element_circle = function() {
|
||||
// random x between 1 and width-1
|
||||
|
|
@ -88,14 +94,30 @@ runAfterLoad(function() {
|
|||
};
|
||||
};
|
||||
};
|
||||
//creeper event
|
||||
//Buff mob events
|
||||
if(typeof(maximumCreeperTries) !== "undefined") {
|
||||
minimumCreeperTries = 10;
|
||||
maximumCreeperTries = 30;
|
||||
};
|
||||
//zombie event
|
||||
if(typeof(maximumZombieTries) !== "undefined") {
|
||||
minimumZombieTries = 10;
|
||||
maximumZombieTries = 30;
|
||||
};
|
||||
if(typeof(maximumSkeletonTries) !== "undefined") {
|
||||
minimumSkeletonTries = 10;
|
||||
maximumSkeletonTries = 30;
|
||||
};
|
||||
|
||||
//New event option
|
||||
var eventOptions = document.querySelectorAll('span[setting="events"]')[0].children[0];
|
||||
var newEventOption = document.createElement("option");
|
||||
newEventOption.setAttribute("value","1");
|
||||
newEventOption.textContent = "Every tick (why)";
|
||||
eventOptions.appendChild(newEventOption);
|
||||
});
|
||||
} else {
|
||||
if(!enabledMods.includes(libraryMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,libraryMod) };
|
||||
if(!enabledMods.includes(runAfterAutogenMod)) { enabledMods.splice(enabledMods.indexOf(modName),0,runAfterAutogenMod) };
|
||||
localStorage.setItem("enabledMods", JSON.stringify(enabledMods));
|
||||
alert(`The "${runAfterAutogenMod}" and "${libraryMod}" mods are required and have been automatically inserted (reload for this to take effect).`);
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue