Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
NyaaCat bloodmoon plugin mob.yml generator
'use strict';
var yaml = require('js-yaml');
var fs = require('fs');
var waves = 6,
wave_easy = 3,
wave_normal = 5;
var div = 3;
var maxmobs = 20;
var file = './mob.yml.new';
var normalMob = [
'pig_zombie',
'zombie',
'zombie',
'zombie',
'zombie',
'skeleton',
'skeleton',
'skeleton',
'skeleton',
'spider',
'spider',
'spider',
'cave_spider',
'cave_spider',
'creeper',
'creeper',
'witch',
'witch',
'enderman',
'giant',
'blaze',
'shulker'
];
var mobs = [
'pigzombie',
'zombie',
'zombie',
'zombie',
'zombie',
'skeleton',
'skeleton',
'skeleton',
'skeleton',
'spider',
'spider',
'spider',
'cavespider',
'cavespider',
'creeper',
'creeper',
'witch',
'witch',
'enderman',
'giant',
'blaze',
'shulker'
];
var skills = {
'EASY': [
'poisonous',
'tosser',
'quicksand',
'bullwark',
'sapper',
'cloaked',
'ghastly',
'lifesteal',
'sprint',
'storm',
'vengeance',
'berserk',
'potions',
'necromancer',
'firework',
'mounted',
'ghost',
'confusing'
],
'NORMAL': [
'poisonous',
'blinding',
'withering',
'tosser',
'quicksand',
'bullwark',
'rust',
'sapper',
'1up',
'cloaked',
'ender',
'ghastly',
'lifesteal',
'sprint',
'storm',
'webber',
'vengeance',
'weakness',
'berserk',
'potions',
'mama',
'molten',
'archer',
'necromancer',
'gravity',
'flying',
'mounted',
'ghost',
'confusing'
],
'INSANE': [
'poisonous',
'armoured',
'blinding',
'withering',
'tosser',
'thief',
'quicksand',
'bullwark',
'rust',
'sapper',
'1up',
'cloaked',
'ender',
'ghastly',
'lifesteal',
'storm',
'webber',
'vengeance',
'weakness',
'berserk',
'potions',
'mama',
'molten',
'archer',
'necromancer',
'gravity',
'flying',
'mounted',
'ghost',
'confusing'
]
};
var maxlv = [
[1, 6], // [minlv, maxlv]
[4, 12],
[8, 18],
[12, 20],
[16, 22],
[18, 24]
];
var gen = function() {
var lvs = {
normalMob: normalMob,
levels: {}
}
for (var i = 1; i <= waves; i++) {
lvs.levels[i] = {};
var sk = skills['INSANE'];
if (i <= wave_normal) sk = skills['NORMAL'];
if (i <= wave_easy) sk = skills['EASY'];
for (var t = 1; t <= maxmobs; t++) {
lvs.levels[i][t] = {
mobtype: rnd(mobs, 1, false)[0],
skills: rnd(sk, range(i), false)
}
}
}
fs.writeFileSync(file, yaml.safeDump(lvs));
}();
function rnd(arr, amount, dup) {
var len = arr.length;
if (amount >= len) return arr;
var narr = [];
if (dup) {
for (var i = 0; i < amount; i++) {
narr.push(arr[Math.floor(Math.random() * len)]);
}
return narr;
} else {
var dedup = {};
for (var i = 0; i < amount; i++) {
var x = arr[Math.floor(Math.random() * len)];
if (dedup[x]) {
i--;
} else {
dedup[x] = 1;
narr.push(x);
}
}
return narr;
}
}
function range(wave) {
for (;;) {
var i = Math.round(Math.random() * maxlv[wave - 1][1]);
if (i >= maxlv[wave - 1][0]) return i;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.