Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /***
- *
- * Author: Draco18s
- *
- * call this from Output Modifier
- * const regex = /(^| )(human|el|dwar|svelk)[fve]*s*(?!\w)/gi;
- * if(modifiedText.match(regex)) {
- * modifiedText = modifiedText.replace(regex,"$1"+getRandomSpecies());
- * }
- *
- * Altering the regex to pick up additional unwanted races should be pretty straight forward.
- * Adjusting the species list is likewise "add, remove, or comment" as desired. They're grouped
- * by rough category (so you could disable all canines quickly) such that any given group has
- * same odds of appearing as any other group at the same level (so "a mammal" and "a bird" are
- * just as likely as each other, but "magpie" will be about half as common as "any rodent"
- * (15 total birds, vs 8 mammal groups).
- *
- * No attempt is made to massage the sentence grammar ("a owl").
- ***/
- const species = {
- mammal: {
- feline: [
- "feline",
- "lion",
- "panther",
- "tiger",
- "cheetah",
- "cougar",
- "jaguar",
- ],
- canine: [
- "canine",
- "wolf",
- "fox",
- "hyena",
- "jackal",
- "coyote",
- "african wild dog",
- ],
- equine: [
- "horse",
- "zebra",
- ],
- ungulate: [
- "deer",
- "cow",
- "antelope",
- "boar",
- "goat",
- "sheep",
- "reindeer",
- "giraffe",
- ],
- ursine: [
- "brown bear",
- "black bear",
- "polar bear",
- "sun bear",
- ],
- mustelide: [
- "otter",
- "ferret",
- "marten",
- "mink",
- "skunk",
- ],
- rodent: [
- "bat",
- "mouse",
- "rat",
- "beaver",
- ],
- other: [
- "kangaroo",
- "bunny",
- "red panda",
- "raccoon",
- "elephant",
- "rhinoceros",
- "civet",
- "sloth",
- "armadillo",
- "anteater",
- "pangolin",
- ]
- },
- bird: [
- "magpie",
- "hoatzin",
- "raven",
- "jay",
- "eagle",
- "hawk",
- "secretary bird",
- "rufous kingfisher",
- "plover",
- "owl",
- "robin",
- "kingfisher",
- "sunbittern",
- "falcon",
- "gannet",
- ],
- reptile: {
- modern: [
- "kobold",
- "lizardman",
- "gator",
- "crocodile",
- "iguanna",
- "snake",
- "komodo",
- ],
- dinosaur: [
- "theropod",
- "sauropod",
- "genasauria",
- ]
- },
- mythic: [
- "gryphon",
- "hippogriff",
- "dragon",
- "eastern dragon",
- "wyvern",
- "phoenix",
- ]
- }
- function getRandomSpecies() {
- var chunk = species;
- var max = chunk.length;
- while(!Array.isArray(chunk)) {
- var subchunk = Object.getOwnPropertyNames(chunk);
- max = subchunk.length;
- var r = Math.floor(Math.random()*max);
- chunk = chunk[subchunk[r]];
- }
- var max = chunk.length;
- var rr = Math.floor(Math.random()*max);
- chunk = chunk[rr];
- return chunk;
- }
Add Comment
Please, Sign In to add comment