Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // INPUT MODIFIER
- function findLast(text,substr){
- var rtext = text.split("").reverse().join("");
- var rsubstr = substr.split("").reverse().join("");
- var reg = new RegExp("\\b"+rsubstr+"\\b")
- var index = rtext.search(reg);
- if(index != -1){index = rtext.length-index-rsubstr.length}
- return index;
- }
- function collectPreKeywords(text){
- if(!history || history.length <=1){return;}
- var recentHistory = text;
- var keywordList = [];
- for(var i =0; i <= Math.min(3,history.length-1);i++){
- recentHistory = history[(history.length-1)-i].text+recentHistory;
- }
- recentHistory = recentHistory.toLowerCase();
- for(var i =0;i<state.races.length;i++){
- //var index = Math.max(recentHistory.lastIndexOf(state.races[i].name),recentHistory.lastIndexOf(state.races[i].plural))
- var index = Math.max(findLast(recentHistory,state.races[i].name),findLast(recentHistory,state.races[i].plural))
- if(index>=0){
- keywordList.push({word:state.races[i].name,index:index});
- }
- }
- for(var i =0;i<state.jobs.length;i++){
- //var index = Math.max(recentHistory.lastIndexOf(state.jobs[i].name),recentHistory.lastIndexOf(state.jobs[i].plural))
- var index = Math.max(findLast(recentHistory,state.jobs[i].name),findLast(recentHistory,state.jobs[i].plural))
- if(index>=0){
- keywordList.push({word:state.jobs[i].name,index:index});
- }
- }
- for(var i =0; i< state.worldEntries.length;i++){
- var index = -1;
- var splitTags = state.worldEntries[i].keys.split(",")
- for(var a =0; a < splitTags.length;a++){
- //index = Math.max(recentHistory.lastIndexOf(splitTags[a]),index)
- index = Math.max(findLast(recentHistory,splitTags[a]),index)
- }
- if(index >=0){
- keywordList.push({word:splitTags[0],index:index})
- }
- }
- if(keywordList.length > 0){
- keywordList.sort((a,b)=>(a.index > b.index) ? -1: 1 );
- for(i = 0;i<keywordList.length;i++){
- addPreKeyword(keywordList[i].word);
- }
- }
- }
- function parseMemory(){
- addPreKeyword(state.worldEntries[Math.floor(Math.random()*state.worldEntries.length)].keys.split(',')[0].toLowerCase())
- //if(Math.random()*100>50){addPreKeyword(getRandWeight(state.races,1).name)}
- //if(Math.random()*100>50){addPreKeyword(getRandWeight(state.jobs,0).name)}
- var preMemText = "";
- var postMemText = "";
- if(memory.length > 0){
- state.memory.context = memory.split("---")[0]+"\n"
- var text = memory.split("---")[1];
- if(text!= null && text.length>0){
- if(text.toLowerCase().includes("[note:")){
- state.baseNote = text.split(/\[note:/i)[1].split("]")[0].replace(/(?:\r\n|\r|\n)/g, ']\n[');
- }else{
- state.baseNote = "";
- }
- if(text.toLowerCase().includes("[encounter:")){
- var encounterText = text.split(/\[encounter:/i)[1].split("]")[0]
- state.encounter = {text:encounterText,encountered:true,race:{name:encounterText},duration:1,timeout:1}
- }
- state.specialNotes = [];
- if(text.includes("[$")){
- var notes = text.split("[$");
- for(var i =0 ; i < notes.length;i++){
- notes[i] = notes[i].split("]")[0]
- var tag = notes[i].split(":")[0]
- if(notes.length>1){
- state.specialNotes.push({tag:tag,desc:notes[i]})
- }
- }
- }
- }
- }
- else{state.memory.context = ""};
- var memLength = state.memory.context.length;
- for(var i =0; i < state.postKeywords.length;i+=1){
- var entry = makeEntry(state.postKeywords[i]);
- if(entry.length+postMemText.length+memLength < 1400){
- postMemText+=entry;
- }
- }
- for(var i =0; i < state.preKeywords.length;i+=1){
- var entry = makeEntry(state.preKeywords[i]);
- if(entry.length+postMemText.length+preMemText.length+memLength < 1400){
- preMemText= entry+preMemText;
- }
- }
- state.memory.context = preMemText+state.memory.context+postMemText+"\n---";
- }
- function makeEntry(text){
- var lowered = text.toLowerCase();
- console.log(text);
- for(var i =0;i < state.races.length;i++){
- if(text == state.races[i].name.toLowerCase()){return"["+capitalizeFirst(state.races[i].plural)+": "+state.races[i].desc+"]\n";}
- }
- for(var i =0;i < state.jobs.length;i++){
- if(text == state.jobs[i].name.toLowerCase()){return"["+capitalizeFirst(state.jobs[i].plural)+": "+state.jobs[i].desc+"]\n";}
- }
- for(var i =0; i<state.worldEntries.length;i++){
- if(state.worldEntries[i].keys.toLowerCase().indexOf(lowered)!=-1){
- return "["+capitalizeFirst(state.worldEntries[i].keys.split(",")[0])+": "+state.worldEntries[i].desc+"]\n";}
- }
- return "";
- }
- function addNoteKeyword(text){
- if(!state.noteKeywords.includes(text)){
- state.noteKeywords.push(text);
- if(state.preKeywords.includes(text)){
- state.preKeywords = state.preKeywords.slice(state.preKeywords.indexOf(text),state.preKeywords.indexOf(text))
- }
- if(state.postKeywords.includes(text)){
- state.postKeywords = state.postKeywords.slice(state.postKeywords.indexOf(text),state.postKeywords.indexOf(text))
- }
- }
- }
- function addPostKeyword(text){
- if(!state.postKeywords.includes(text) && !state.noteKeywords.includes(text)){
- state.postKeywords.push(text);
- if(state.preKeywords.includes(text)){
- state.preKeywords = state.preKeywords.slice(state.preKeywords.indexOf(text),state.preKeywords.indexOf(text))
- }
- }
- }
- function addPreKeyword(text){
- if(!state.postKeywords.includes(text) && !state.preKeywords.includes(text) && !state.noteKeywords.includes(text)){
- state.preKeywords.push(text);
- }
- }
- function getRandWeight(list,id){
- var totalWeight = 0;
- for(var i = 0; i<list.length; i++){
- totalWeight += list[i].weight[id];
- }
- for(var i =0;i<list.length;i++){
- if(!list[i].baseChance){list[i].baseChance = [0,0]}
- list[i].baseChance[id] = Math.floor((list[i].weight[id]/totalWeight)*10000)/100;
- }
- var weight = Math.random()*totalWeight;
- for(var i =0; i<list.length;i++){
- weight -= list[i].weight[id];
- if(weight <=0){return list[i];}
- }
- return null;
- }
- function aOrAn(text){
- lowered = text.toLowerCase();
- if(lowered.startsWith('a') || lowered.startsWith('e') || lowered.startsWith('i') || lowered.startsWith('o') || lowered.startsWith('u')){
- return true;
- }else{
- return false;
- }
- }
- function capitalizeFirst(text){
- return text.substring(0,1).toUpperCase()+text.substring(1)
- }
- function uncapitalizeFirst(text){
- return text.substring(0,1).toLowerCase()+text.substring(1)
- }
- if(!memory){memory = "";}
- if(!state.preKeywords){state.preKeywords = []};
- if(!state.postKeywords){state.postKeywords = []};
- if(!state.noteKeywords){state.noteKeywords = []};
- if(!state.specialNotes){state.specialNotes = []};
- const modifier = (text) => {
- let modifiedText = text
- const lowered = text.toLowerCase()
- if(lowered.includes("/dbupdate")){
- state.databaseInit = false;
- modifiedText = "";
- state.blockOutput=true;
- }
- if(!state.databaseInit || state.databaseInit == false || Math.random()*100>80){
- //Declare Databases
- state.races = [
- {name:"human",plural:"humans",weight:[100,100],desc:"A common race. Their versatility and adaptability makes them prolific.",job:true},
- {name:"elf",plural:"elves",weight:[100,70],desc:"Long lived, graceful, and haughty. Elves have sharp teeth and venomous blood.",job:true},
- {name:"dwarf",plural:"dwarves",weight:[100,110],desc:"Stout and hardy. Dwarves can sense vibrations with their chitinous beards.",job:true},
- {name:"orc",plural:"orcs",weight:[100,150],desc:"Honorable and proud warriors, falsely considered savages.",job:true},
- {name:"cyclops",plural:"cyclopses",weight:[25,40],desc:"A fairly civilized lesser giant race, averaging 8 feet tall. Strong, and magically adept.",job:true},
- {name:"goblin",plural:"goblins",weight:[50,200],desc:"Small, mischevious, and agile. Goblins are smarter than others give them credit for.",job:true},
- {name:"gnome",plural:"gnomes",weight:[65,40],desc:"Culturally proficient at magitek. Gnomes often use magitek weaponry.",job:true},
- {name:"dryad",plural:"dryads",weight:[30,60],desc:"Plant-like humanoids. Usually have either prehensile vines, branches, or flowers for hair.",job:true},
- {name:"oread",plural:"oreads",weight:[30,60],desc:"Humanoids with stone-like skin and crystalline hair. Associated with Earth, and live in mountains.",job:true},
- {name:"naiad",plural:"naiads",weight:[30,60],desc:"Aquatic humanoids with webbed feet and hands, and slick amphibious skin.",job:true},
- {name:"devil",plural:"devils",weight:[30,90],desc:"Archetypical demons, with red skin, forked tails, and horns.",job:true},
- {name:"kobold",plural:"kobolds",weight:[30,150],desc:"Humanoid synapsids with a mix of mammal and reptile traits. Small and agile.",job:true},
- {name:"oni",plural:"onis",weight:[30,60],desc: "Strong, ogre-like demons with red or blue skin and 1-3 eyes. Some use storm magic. Onis love alcohol.",job:true},
- {name:"marilith",plural:"mariliths",weight:[10,40],desc:"Six-armed demons with snake tails instead of legs. Often wield many weapons at once.",job:true},
- {name:"amazon",plural:"amazons",weight:[40,30],desc: "An all-female race of lesser giants. Average over seven feet tall, and usually live in the jungle.",job:true},
- {name:"centaur",plural:"centaurs",weight:[40,30],desc: "A humanoid upper torso atop a horse's body. Centaurs have trouble with stairs.",job:true},
- {name:"arachne",plural:"arachnes",weight:[40,40],desc: "A humanoid upper torso atop a giant spider's body. They can climb walls and are at home underground.",job:true},
- {name:"harpy",plural:"harpies",weight:[40,30],desc:"Bird-like humanoids with wings for arms. They carry weapons using their feet instead.",job:true},
- {name:"naga",plural:"nagas",weight:[40,40],desc:"A humanoid upper torso atop a snake's body. Their slithering gives them versatile movement.",job:true},
- {name:"foocubus",plural:"foocubi",weight:[10,50],desc:"Demons who feed off of lust, including power and knowledge. 'Foocubus' is a gender neutral term for succubus or incubus.",job:true},
- {name:"succubus",plural:"succubi",weight:[0,0],desc:"A term for a female foocubus.",job:true},
- {name:"incubus",plural:"incubi",weight:[0,0],desc:"A term for a male foocubus.",job:true},
- {name:"minotaur",plural:"minotaurs",weight:[25,45],desc:"Humanoid bulls who like to show off their strength.",job:true},
- {name:"imp",plural:"imps",weight:[20,90],desc:"Small, goblin sized demons with wings. Tricky and mischevious, often use fire magic.",job:true},
- {name:"golem",plural:"golems",weight:[5,50],desc:"Automatons made of various materials, such as clay, metal, or even flesh. Golems don't work on Sundays.",job:true},
- {name:"tardigrade-kin",plural:"tardigrade-kins",weight:[15,20],desc:"Humanoid tardigrades. They have six arms and are extremely resilient, thanks to their cryptobiosis.",job:true},
- {name:"dullahan",plural:"dullahans",weight:[30,50],desc:"Fae with severed heads, and an affinity for mounted combat. Their heads can fly and scout ahead.",job:true},
- {name:"gargoyle",plural:"gargoyles",weight:[30,60],desc:"Winged humanoids that turn to statues during the day while they sleep.",job:true},
- {name:"angel",plural:"angels",weight:[10,30],desc:"Winged humanoids from the heavens with holy powers. Most angels are good, but some angels are evil.",job:true},
- {name:"tanuki",plural:"tanukis",weight:[15,30],desc:"Shapeshifting humanoid raccoons. They are tricky and mischevious, but usually friendly.",job:true},
- {name:"kitsune",plural:"kitsunes",weight:[5,25],desc:"Shapeshifting humanoid foxes. They are agile and sneaky.",job:true},
- {name:"mind flayer",plural:"mind flayers",weight:[20,40],desc:"Intelligent, psychic humanoids with tentacles on their mouths. They eat minds.",job:true},
- {name:"gnoll",plural:"gnolls",weight:[20,90],desc:"A race of humanoid hyenas with a savage love of fighting.",job:true},
- {name:"mothman",plural:"mothmen",weight:[25,50],desc:"A race of humanoid moths. They have elegant wings and love bright lights.",job:true},
- {name:"living armor",plural:"living armors",weight:[5,80],desc:"An animated suit of armor, with no-one inside. Some living armors are sentient.",job:true},
- //monster races
- {name:"hekatonchire",plural:"hekatoncheires",weight:[0,30],desc:"Massive, formless giants made up of arms and faces. They are powerful creations of the old gods.",job:false},
- {name:"slime",plural:"slimes",weight:[0,125],desc:"Common jelly-like monsters that are weak, but hard to kill.",job:false},
- {name:"meat man",plural:"meat men",weight:[0,40],desc:"Created through perverse Life magic. Their regenerative abilities make them easy to defeat, but hard to kill.",job:false},
- {name:"zombie",plural:"zombies",weight:[0,120],desc:"Common undead. All brawn and no brains, which is why they'd like to eat yours.",job:false},
- {name:"skeleton",plural:"skeletons",weight:[0,120],desc:"Common undead. Fragile, and tend to appear in large numbers.",job:false},
- {name:"manticore",plural:"manticores",weight:[0,40],desc:"Beasts with a lion's body, bat wings, and a scorpion's tail.",job:false},
- {name:"mimic",plural:"mimics",weight:[0,80],desc:"Hermit crab like monsters that inhabit chests or similar objects.",job:false},
- {name:"jotunn",plural:"jotunns",weight:[0,35],desc:"A race of giants, three times the height that of a human.",job:true},
- {name:"ogre",plural:"ogres",weight:[0,60],desc:"A race of giants, averaging eleven feet tall. They sleep a lot and are herbivores, but are still dangerous if provoked.",job:false},
- {name:"troll",plural:"trolls",weight:[0,90],desc:"Vicious and agile lesser giants, with long limbs, big claws, and shaggy bodies. They hate bright light.",job:false},
- {name:"poison dart raccoon",plural:"poison dart raccoons",weight:[0,55],desc:"Large poisonous rodents that are often found in dungeons. They are clever beasts.",job:false},
- {name:"gremlin",plural:"gremlins",weight:[0,90],desc:"Small monstrous fairies that like to tear through metal (especially machines) with their claws and teeth.",job:false},
- {name:"balrog",plural:"balrogs",weight:[0,25],desc:"Giant, powerful demons with horns, hooves, and wings. They are powerful, but not too magically potent.",job:false},
- {name:"beholder",plural:"beholders",weight:[0,50],desc:"Flying monsters with one large eye, and many eyestalks. They use magical lasers.",job:false},
- {name:"shoggoth",plural:"shoggoths",weight:[0,20],desc:"Formless creations of the old gods. Shoggoths are liquid blobs of flesh, eyes, and tentacles.",job:false},
- {name:"behemoth",plural:"behemoths",weight:[0,30],desc:"Large, thick-skinned animals native to the demon realm. They are used as war animals by demons.",job:false},
- {name:"domination",plural:"dominations",weight:[0,30],desc:"Bipedal, gorilla-like animals native to the heavenly realm. They are used as war animals by angels.",job:false},
- {name:"hydra",plural:"hydras",weight:[0,30],desc:"An ambulatory plant monster that resembles a wingless dragon. It has multiple heads, and if you cut one off, it grows new ones.",job:false},
- {name:"grue",plural:"grues",weight:[0,20],desc:"A deadly and ravenous monster that can only be found in pitch darkness. Even a dim light will repel them.",job:false},
- //elementals
- {name:"fire elemental",plural:"fire elementals",weight:[0,25],desc:"A magical entity formed from the destructive element of fire.",job:false},
- {name:"ice elemental",plural:"ice elementals",weight:[0,25],desc:"A magical entity formed from the calming element of ice.",job:false},
- {name:"earth elemental",plural:"earth elementals",weight:[0,25],desc:"A magical entity formed from the hardy element of earth.",job:false},
- {name:"air elemental",plural:"air elementals",weight:[0,25],desc:"A magical entity formed from the swift element of air.",job:false},
- {name:"sun elemental",plural:"sun elementals",weight:[0,20],desc:"A magical entity formed from the revealing element of sun.",job:false},
- {name:"dream elemental",plural:"dream elementals",weight:[0,20],desc:"A magical entity formed from the mistifying element of dream.",job:false},
- {name:"life elemental",plural:"life elementals",weight:[0,20],desc:"A magical entity formed from the growing element of life.",job:false},
- {name:"death elemental",plural:"death elementals",weight:[0,20],desc:"A magical entity formed from the decaying element of death.",job:false},
- {name:"poutine elemental",plural:"poutine elementals",weight:[0,10],desc:"A magical entity formed from the peaceful element of poutine.",job:false},
- {name:"knife elemental",plural:"knife elementals",weight:[0,10],desc:"A magical entity formed from the violent element of knives.",job:false},
- {name:"surprise elemental",plural:"surprise elementals",weight:[0,10],desc:"A magical entity formed from the the chaotic element of surprise.",job:false},
- //dragons
- {name:"fire dragon",plural:"fire dragons",weight:[0,15],desc:"A winged synapsid that breaths fire.",job:false},
- {name:"ice dragon",plural:"ice dragons",weight:[0,15],desc:"A winged synapsid that breaths ice.",job:false},
- {name:"air dragon",plural:"air dragons",weight:[0,15],desc:"A winged synapsid that produces lightning.",job:false},
- {name:"earth dragon",plural:"earth dragons",weight:[0,15],desc:"A wingless dragon that induces earthquakes.",job:false},
- {name:"sun dragon",plural:"sun dragons",weight:[0,8],desc:"A winged synapsid that emits blinding light.",job:false},
- {name:"dream dragon",plural:"dream dragons",weight:[0,8],desc:"A serpentine synapsid that breaths hallucinogenic mist.",job:false},
- {name:"knife dragon",plural:"knife dragons",weight:[0,5],desc:"Violent, winged synapsids that fire shards of metal from their mouths.",job:false},
- {name:"poutine dragon",plural:"poutine dragons",weight:[0,5],desc:"Gluttonous winged synapsids that blast molten poutine from their mouths.",job:false}
- ]
- state.jobs = [
- {name:"warrior",plural:"warriors",weight:[100],desc:"Typical sword & shield types.",elab:"wields [a sword,an axe,a hammer,a spear] and a shield."},
- {name:"ranger",plural:"rangers",weight:[100],desc:"Agile bow-wielding combatants.",elab:"wields [a bow,a crossbow], and looks quite agile."},
- {name:"monk",plural:"monks",weight:[60],desc:"Martial artists who fight using chi, and without weapons.",elab:"fights using martial arts and the power of chi."},
- {name:"berserker",plural:"berserkers",weight:[70],desc:"Fighters who use huge weapons and rage to fight.",elab:"has a huge [sword,axe,hammer,polearm,club] and a menacing gaze."},
- {name:"juggernaut",plural:"juggernauts",weight:[60],desc:"Heavily armored, slow-moving fighters.", elab:"is unusually large, and heavily armored."},
- {name:"rogue",plural:"rogues",weight:[100],desc:"Sneaky, stabby types. Hard to pin down. Associated with the element of Surprise.", elab:"is lithe and sneaky, and ready to stab."},
- {name:"lich",plural:"liches",weight:[50],desc:"Skeletal undead that retain their intelligence. They have enhanced strength and dark magic.", elab:"is a skeletal undead with [unholy strength and weapons,dark magical powers]."},
- {name:"vampire",plural:"vampires",weight:[50],desc:"Classic blood-suckers. Not all vampires are formerly human, of course.", elab:"is also a vampire, with a thirst for blood."},
- {name:"wizard",plural:"wizards",weight:[100],desc:"Well-rounded but fragile spellcasters.", elab:"is wearing robes, and carrying an ornate staff."},
- {name:"ninja",plural:"ninjas",weight:[50],desc:"Masters of stealth, traps, and sword-fighting.", elab:"wields a [ninjatō,katana,wakizashi], carries [shuriken,throwing knives,caltrops,smoke powder], and is lurking out of sight."},
- {name:"bard",plural:"bards",weight:[60],desc:"Spellcasters who use music and charisma to control their foes.",elab:"[sings,plays a lute,plays a guitar,plays a keyboard,plays a keytar,plays a flute,plays a trumpet,plays a ukulele,plays a violin,plays a theremin,badly plays a recorder,plays an otamatone] as the source of their magic."},
- {name:"dancer",plural:"dancers",weight:[40],desc:"Agile warriors who disorient foes before stabbing them with hidden weapons.",elab:"is adorned with ribbons, carries a knife, and moves hypnotically."},
- {name:"paladin",plural:"paladins",weight:[80],desc:"Warrior spellcasters who use divine magic to protect themselves and others.",elab:"is heavily armored, and [shining with holy magic,clouded with unholy magic]."},
- {name:"assassin",plural:"assassins",weight:[40],desc:"Masters of stealth who try to kill their foes in a single strike.",elab:"is waiting for the perfect moment to strike."},
- {name:"alchemist",plural:"alchemists",weight:[50],desc:"Potion brewers who use explosive flasks and toxic gasses.",elab:"is carrying an assortment of potions on their person."},
- {name:"necromancer",plural:"necromancers",weight:[80],desc:"Spellcasters who conjure and control the undead.",elab:"is accompanied by several reanimated servants."},
- {name:"demonologist",plural:"demonologists",weight:[70],desc:"Spellcasters who summon and bind demons.",elab:"is accompanied by a powerful demon servant."},
- {name:"fencer",plural:"fencers",weight:[40],desc:"Agile sword-fighters who wield a rapier.",elab:"is wielding a rapier, and capable of swift movements."},
- {name:"barbarian",plural:"barbarians",weight:[60],desc:"Brutish warriors who dual-wield weapons.",elab:"is ferocious, and wields [a sword,an axe] in each hand."},
- {name:"sniper",plural:"snipers",weight:[30],desc:"Ranged warriors who use bows or rifles from very long distances.",elab:"wields [a longbow,a rifle], ready to attack from afar."},
- {name:"gunslinger",plural:"gunslingers",weight:[50],desc:"Agile gun-slinging combatants who weave in and out of range.", elab:"wields [a revolver,a revolver in each hand], and is quick to react."},
- {name:"druid",plural:"druids",weight:[40],desc:"Martial spellcasters who channel the power of nature.", elab:"is dressed in druidic gear, ready to channel nature's power."},
- {name:"spellblade",plural:"spellblades",weight:[50],desc:"Magical warriors who use both weapons and magic.", elab:"is wielding a blade infused with magical energy."},
- {name:"psion",plural:"psions",weight:[30],desc:"Magical mentalists who use psychic powers, such as telekinesis and mind control.",elab:"is levitating, ready to unleash psychic powers."},
- {name:"magician",plural:"magicians",weight:[30],desc:"More like a rogue than a wizard, these spellcasters use both sleight of hand and magic.", elab:"wears a top-hat, and uses a mix of magic, sleight of hand, and knife-play."},
- {name:"skirmisher",plural:"skirmishers",weight:[50],desc:"Agile spear-wielding foes who keep just out of reach of opponents.", elab:"wields a long spear, capable of agile movements."},
- {name:"gladiator",plural:"gladiators",weight:[40],desc:"Agile, lightly-armored, and well-rounded fighters.", elab:"wields [a gladius,a trident,a bladed cestus], and wears light armor."},
- {name:"oracle",plural:"oracles",weight:[30],desc:"Utilitarian spellcasters who use clairvoyance and future vision.", elab:"carries a staff, and can see what other cannot."},
- {name:"biomancer",plural:"biomancers",weight:[30],desc:"Spellcasters who alter and mutate their biology through magic.", elab:"uses magic to mutate and enhance their body for combat."},
- {name:"artificer",plural:"artificers",weight:[50],desc:"Spellcasters who use their magic to create and wield enchanted armaments.", elab:"is equipped with self-made magitek equipment."},
- //mages
- {name:"fire mage",plural:"fire mages",weight:[30],desc:"Spellcasters who use the element of Fire, to bring destruction.", elab:"wields the destructive element of Fire, blazing with heat."},
- {name:"ice mage",plural:"ice mages",weight:[30],desc:"Spellcasters who use the element of Ice, and require utmost calm.", elab:"wields the calm element of Ice, surrounded by cool air."},
- {name:"earth mage",plural:"earth mages",weight:[30],desc:"Spellcasters who use the element of Earth, and have high endurance.", elab:"wields the hardy element of Earth, shaking the ground."},
- {name:"air mage",plural:"air mages",weight:[30],desc:"Spellcasters who use the element of Air, and are always in motion.", elab:"wields the swift element of Air, and crackles with lightning."},
- {name:"sun mage",plural:"sun mages",weight:[20],desc:"Spellcasters who use the element of Sun, to bring truth.", elab:"wields the revealing element of Sun, and emits a bright light."},
- {name:"dream mage",plural:"dream mages",weight:[20],desc:"Spellcasters who use the element of Dream, to create illusions.", elab:"wields the mistifying element of Dream, capable of making illusions."},
- {name:"life mage",plural:"life mages",weight:[20],desc:"Spellcasters who use the element of Life, to induce growth and healing.", elab:"wields the verdant element of Life, surrounded by plants."},
- {name:"death mage",plural:"death mages",weight:[20],desc:"Spellcasters who use the element of Death, to induce decay and stasis.", elab:"wields the decaying element of Death, with a toxic aura."},
- {name:"knife mage",plural:"knife mages",weight:[10],desc:"Spellcasters who use the element of Knives, to shed blood and spread hatred.", elab:"wields the violent element of Knifes, with a scarred body."},
- {name:"poutine mage",plural:"poutine mages",weight:[10],desc:"Spellcasters who use the element of Poutine, to promote peace and safety.", elab:"wields the nourishing element of Poutine, and smells delicious."},
- {name:"surprise mage",plural:"surprise mages",weight:[5],desc:"Spellcasters who use the element of Surprise, to unpredictable effect.", elab:"wields the chaotic element of Surprise, to unknown effect"},
- //rare jobs
- {name:"luchador",plural:"luchadors",weight:[20],desc:"Tough wrestlers who gain supernatural strength as long as they wear their mask.", elab:"wears a strength-enhancing wrestling mask, following the path of Lucha."},
- {name:"bouncer",plural:"bouncers",weight:[20],desc:"Hardy fighters who serve as impassable walls and guard their allies.", elab:"wields brass knuckles, and has an imposing presence."},
- {name:"engineer",plural:"engineers",weight:[20],desc:"Experts at mechanical engineering, which they use for a variety of purposes.", elab:"is equipped with strange mechanisms, and smeared with oil."},
- {name:"brewmaster",plural:"brewmasters",weight:[20],desc:"Fighters who brew alcoholic beverages, and are stronger when drunk.", elab:"is extremely drunk, but ready to fight nonetheless."},
- {name:"clown",plural:"clowns",weight:[10],desc:"Clowns are terrifying and surprisingly hardy masters of mischief and misdirection.", elab:"may be a clown, but is not to be underestimated."},
- {name:"nekomancer",plural:"nekomancers",weight:[10],desc:"Spellcasters who summon, control, and channel the power of cats. Yes, seriously.", elab:"is adorned with many cat-themed accessories, including a pair of claws."},
- {name:"stand user",plural:"stand users",weight:[5],desc:"Those who can manifest a \"Stand;\" an extension of their willpower that takes the form of a warrior.",elab:"can manifest a warrior known as a 'Stand' that serves as an extension of their will."}
- ]
- state.worldEntries = [
- {keys:"fire,flame",desc:"One of the eleven elements. Fire embodies passion and rage, and opposes ice. It is red."},
- {keys:"ice",desc:"One of the eleven elements. Ice embodies calm and willpower, and opposes fire. It is blue."},
- {keys:"air",desc:"One of the eleven elements. Air embodies motion and wanderlust, and opposes earth. It is white."},
- {keys:"earth",desc:"One of the eleven elements. Earth embodies stasis and endurance, and opposes air. It is brown."},
- {keys:"sun",desc:"One of the eleven elements. Sun embodies truth and reality, and opposes dream. It is yellow."},
- {keys:"dream",desc:"One of the eleven elements. Dream embodies illusion and fantasy, and opposes sun. It is purple."},
- {keys:"life",desc:"One of the eleven elements. Life embodies growth and healing, and opposes death. It is green."},
- {keys:"death",desc:"One of the eleven elements. Death embodies decay and stasis, and opposes life. It is black."},
- {keys:"knives,knife",desc:"One of the eleven elements. Knives embodies violence and hatred, and opposes poutine. It is gray."},
- {keys:"poutine",desc:"One of the eleven elements. Poutine embodies peace and safety, and opposes knives. It is beige."},
- {keys:"surprise",desc:"One of the eleven elements. Surprise embodies chance and chaos, and is the only element without an opposite. It is rainbow."},
- {keys:"elements,element",desc:"The eleven classic elements are fire, ice, air, earth, sun, dream, life, death, knives, poutine, and surprise."},
- {keys:"deepmouth dungeon,deepmouth,dungeon",desc:"The dungeon you are exploring. It leads into the abyss, where an evil entity awaits."},
- {keys:"demon,devil",desc:"There are many species of demon. Not all demons are evil, though many are."},
- {keys:"giant",desc:"There are many species of giants and lesser giants, such as cyclopses, jotunn, amazonians, ogres, and more."}
- ]
- state.modifiers = [
- {name:"dead",weight:[50]},
- {name:"hostile",weight:[60]},
- {name:"friendly",weight:[90]},
- {name:"female",weight:[120]},
- {name:"male",weight:[120]},
- {name:"wounded",weight:[90]},
- {name:"unaware",weight:[100]},
- {name:"???",weight:[10]},
- {name:"undead",weight:[40]},
- {name:"elite",weight:[60]}
- ]
- state.databaseInit = true;
- }
- if(!state.init){
- //Character Creation + initial setup
- modifiedText = modifiedText.split('[]');
- state.name = modifiedText[1];
- state.race = modifiedText[3];
- state.job = modifiedText[5];
- //You are []Name[], a an []random[] []random[].
- if(state.race.toLowerCase().includes("random")){state.race = getRandWeight(state.races,0).name;modifiedText[3] = state.race}
- if(state.job.toLowerCase().includes("random")){state.job = getRandWeight(state.jobs,0).name;modifiedText[5] = state.job}
- getRandWeight(state.races,1) //purely for debugging
- modifiedText = modifiedText.join('');
- if(aOrAn(state.race)){
- modifiedText = modifiedText.replace(/a an/g,"an");
- }else{
- modifiedText = modifiedText.replace(/a an/g,"a");
- }
- addPostKeyword(state.race);
- addPostKeyword(state.job);
- state.init = true;
- }
- //commands
- if(lowered.includes("/forceencounter")||lowered.includes("/force encounter")){
- state.encounter = null;
- state.forceEncounter = true;
- modifiedText = "";
- state.blockOutput = true;
- }
- if(lowered.includes("/setname")||lowered.includes("/set name")){
- if(!lowered.includes("[")){
- state.message = "Put your name in square brackets, i.e: \"/setname [name]\""
- }else{
- var re = /\[((.|\n)*)\]/;
- state.name = modifiedText.match(re)[1];
- state.message = "Name is now "+state.name;}
- state.blockOutput = true;
- modifiedText = "";
- }
- if(lowered.includes("/setclass")||lowered.includes("/set class")){
- if(!lowered.includes("[")){
- state.message = "Put your class in square brackets, i.e: \"/setclass [random]\""
- }else{
- var re = /\[((.|\n)*)\]/;
- state.job = modifiedText.match(re)[1];
- if(state.job.toLowerCase().includes("random")){state.job = getRandWeight(state.jobs,0).name}
- state.message = "Class is now "+state.job;}
- state.blockOutput = true;
- modifiedText = "";
- }
- if(lowered.includes("/setrace")||lowered.includes("/set race")){
- if(!lowered.includes("[")){
- state.message = "Put your race in square brackets, i.e: \"/setrace [random]\""
- }else{
- var re = /\[((.|\n)*)\]/;
- state.race = modifiedText.match(re)[1];
- if(state.race.toLowerCase().includes("random")){state.race = getRandWeight(state.races,0).name}
- state.message = "Race is now "+state.race;}
- state.blockOutput = true;
- modifiedText = "";
- }
- if(lowered.includes("/setencounter")||lowered.includes("/set encounter")){
- if(!lowered.includes("[")){
- state.message = "If you want a random encounter, use /forceencounter. To use /setencounter, put your encounter in square brackets, i.e: \"/setencounter [goblins]\""
- }
- else{
- var re = /\[((.|\n)*)\]/;
- var text = modifiedText.match(re)[1];
- state.encounter = {duration:3,timeout:8,text:text,encountered:false,desc:""};
- for(var i = 0;i<state.races.length;i++){
- if(text.toLowerCase().includes(state.races[i].name) || text.toLowerCase().includes(state.races[i].plural)){
- state.encounter.race = state.races[i];
- state.encounter.desc = capitalizeFirst(state.races[i].plural)+" are "+uncapitalizeFirst(state.races[i].desc)
- }
- }
- for(var i = 0;i<state.jobs.length;i++){
- if(text.toLowerCase().includes(state.jobs[i].name) || text.toLowerCase().includes(state.jobs[i].plural)){
- state.encounter.class = state.jobs[i];
- state.encounter.desc += " "+capitalizeFirst(state.jobs[i].plural)+" are "+uncapitalizeFirst(state.jobs[i].desc)
- }
- }
- if(state.encounter.race == null){state.encounter.race = {name:text}}
- }
- modifiedText = "";
- state.blockOutput = true;
- }
- if(lowered.includes("/help")){
- modifiedText = "Current list of commands and option blocks:\n"+
- "/forceEncounter: forces the AI to generate a random encounter\n"+
- "/setName [name]: rename the player. \n"+
- "/setRace [race]: change your race (can be set to \"random\")\n"+
- "/setClass [class]: change your class (can be set to \"random\")\n"+
- "[note: text] Insert this in memory below the --- to add an author's note. More option blocks like these will be added later.\n"+
- "[$skill name: text] If \"skill name\" is mentioned in input, adds the entry to author's note. You can have as many skills as you'd like in the option area of memory."
- state.blockOutput = true;
- }
- if(lowered.includes("/dbprint")){
- var string = "races: ";
- for(var i =0;i<state.races.length;i++){
- string+= state.races[i].name+", ";
- }
- string+="\n\nclasses: "
- for(var i=0;i<state.jobs.length;i++){
- string+= state.jobs[i].name+", ";
- }
- modifiedText = string;
- }
- collectPreKeywords(modifiedText);
- parseMemory();
- // You must return an object with the text property defined.
- return {text: modifiedText}
- }
- // Don't modify this part
- modifier(text)
- // CONTEXT MODIFIER
- function capitalizeFirst(text){
- return text.substring(0,1).toUpperCase()+text.substring(1)
- }
- function uncapitalizeFirst(text){
- return text.substring(0,1).toLowerCase()+text.substring(1)
- }
- function aOrAn(text){
- lowered = text.toLowerCase();
- if(lowered.startsWith('a') || lowered.startsWith('e') || lowered.startsWith('i') || lowered.startsWith('o') || lowered.startsWith('u')){
- return "an "+text;
- }else{
- return "a "+text;
- }
- }
- function parseDesc(text){
- if(text.includes("[")){
- var splits = text.split("[");
- for(var i =0 ;i < splits.length;i++){
- if(splits[i].includes("]")){
- var remainder = splits[i].split("]")[1];
- splits[i] = splits[i].split("]")[0].split(",");
- splits[i] = splits[i][Math.floor(Math.random()*splits[i].length)]+remainder;
- }
- }
- text = splits.join("");
- }
- return text;
- }
- function generateNote(text){
- state.authorsNote="["
- state.authorsNote += "You are "+state.name+", the "+state.race+" "+state.job+".";
- if(state.baseNote!=""){
- state.authorsNote+=" "+state.baseNote
- }
- if(state.noteKeywords.length>0){
- for(var i =0 ; i < state.noteKeywords.length;i++){
- var string = "]\n"+makeEntry(state.noteKeywords[i]);
- string = string.slice(0,-2);
- state.authorsNote+=string;
- }
- }
- state.authorsNote+="]";
- }
- function getEncounterNote(hist){
- var text = "";
- if(state.encounter!=null){
- if(state.encounter.encountered == false){
- text+="[Approaching Encounter: "+capitalizeFirst(state.encounter.text)+"]"}
- else{text+="[Current Encounter: "+capitalizeFirst(state.encounter.text)+"]";}
- if(state.encounter.desc!=null && state.encounter.desc.length > 1){
- text+= "\n["+state.encounter.desc+"]"
- }
- }
- return text;
- }
- function getSpecialNotes(hist){
- var text = "";
- for(var i = 0; i < state.specialNotes.length;i++){
- if(hist.toLowerCase().includes(state.specialNotes[i].tag.toLowerCase())){
- if(text.length>0){text+="\n"}
- text+="["+state.specialNotes[i].desc+"]";
- }
- }
- return text;
- }
- const combineLines = (lines)=>{
- var finalLines = "";
- for(var i = lines.length-1;i >= 0;i--){
- if(finalLines.length + lines[i].length < state.info.maxChars - state.info.memoryLength){
- finalLines = lines[i]+"\n"+finalLines;
- }
- else{return finalLines;}
- }
- return finalLines;
- }
- if(!info.maxChars){info = {maxChars:2800,memoryLength:0,actionCount:0}}
- const modifier = (text) => {
- const memory = info.memoryLength ? text.slice(0, info.memoryLength) : ''
- var context = info.memoryLength ? text.slice(info.memoryLength + 1) : text
- state.info = info;
- generateNote();
- context = context.replace(/\n\n/g,"\n")
- const lines = context.split("\n")
- var actionOffset = 0;
- for(var i =0; i < 2;i++){
- if(i < lines.length-1 && lines[lines.length-1-i].includes(">")){
- actionOffset = i;
- break;
- }
- }
- if (lines.length > 2) {
- lines.splice(-3-actionOffset, 0, state.authorsNote)
- var hist = lines.join("\n");
- encounterNote = getEncounterNote(hist.substring(Math.max(0,hist.length-500)));
- if(encounterNote!=""){
- lines.splice(state.encounter.encountered ? -3-actionOffset : -1-actionOffset,0,encounterNote);
- }
- var specialNotes = getSpecialNotes(hist)
- if(specialNotes!=""){
- lines.splice(-1-actionOffset,0,specialNotes);
- }
- }
- // Make sure the new context isn't too long, or it will get truncated by the server.
- const combinedLines = combineLines(lines);
- const finalText = [memory, combinedLines].join("")
- return { text: finalText }
- }
- // Don't modify this part
- modifier(text)
- // OUTPUT MODIFIER
- // Checkout the repo examples to get an idea of other ways you can use scripting
- // https://github.com/AIDungeon/Scripting/blob/master/examples
- function findLast(text,substr){
- var rtext = text.split("").reverse().join("");
- var rsubstr = substr.split("").reverse().join("");
- var reg = new RegExp("\\b"+rsubstr+"\\b")
- var index = rtext.search(reg);
- if(index != -1){index = rtext.length-index-rsubstr.length}
- return index;
- }
- function collectPreKeywords(text){
- if(!history || history.length <=1){return;}
- var recentHistory = text;
- var keywordList = [];
- for(var i =0; i < history.length;i++){
- if(recentHistory.length + history[(history.length-1)-i].text.length < 800){
- recentHistory = history[(history.length-1)-i].text+recentHistory;
- }else{
- break;
- }
- }
- recentHistory = recentHistory.toLowerCase();
- if(state.encounter!=null && state.encounter.encountered == false){
- var encounterTags = state.encounter.text.split(" ")
- for(var i =0; i < encounterTags.length;i++){
- if(encounterTags[i].length > 2 && recentHistory.includes(encounterTags[i].toLowerCase())){state.encounter.encountered = true;state.noteKeywords = [];}
- }
- if(recentHistory.includes(state.encounter.race.name) || recentHistory.includes(state.encounter.race.plural)){state.encounter.encountered = true;state.noteKeywords = [];}
- }
- for(var i =0;i<state.races.length;i++){
- //var index = Math.max(recentHistory.lastIndexOf(state.races[i].name),recentHistory.lastIndexOf(state.races[i].plural))
- var index = Math.max(findLast(recentHistory,state.races[i].name),findLast(recentHistory,state.races[i].plural))
- if(index>=0){
- keywordList.push({word:state.races[i].name,index:index});
- }
- }
- for(var i =0;i<state.jobs.length;i++){
- //var index = Math.max(recentHistory.lastIndexOf(state.jobs[i].name),recentHistory.lastIndexOf(state.jobs[i].plural))
- var index = Math.max(findLast(recentHistory,state.jobs[i].name),findLast(recentHistory,state.jobs[i].plural))
- if(index>=0){
- keywordList.push({word:state.jobs[i].name,index:index});
- }
- }
- for(var i =0; i< state.worldEntries.length;i++){
- var index = -1;
- var splitTags = state.worldEntries[i].keys.split(",")
- for(var a =0; a < splitTags.length;a++){
- //index = Math.max(recentHistory.lastIndexOf(splitTags[a]),index)
- index = Math.max(findLast(recentHistory,splitTags[a]),index)
- }
- if(index >=0){
- keywordList.push({word:splitTags[0],index:index})
- }
- }
- if(keywordList.length > 0){
- keywordList.sort((a,b)=>(a.index > b.index) ? -1: 1 );
- for(i = 0;i<keywordList.length;i++){
- addPreKeyword(keywordList[i].word);
- }
- }
- }
- function parseMemory(){
- addPreKeyword(state.worldEntries[Math.floor(Math.random()*state.worldEntries.length)].keys.split(',')[0].toLowerCase())
- //if(Math.random()*100>50){addPreKeyword(getRandWeight(state.races,1).name)}
- //if(Math.random()*100>50){addPreKeyword(getRandWeight(state.jobs,0).name)}
- var preMemText = "";
- var postMemText = "";
- if(memory.length > 0){
- state.memory.context = memory.split("---")[0]+"\n"
- var text = memory.split("---")[1];
- if(text!= null && text.length>0){
- if(text.toLowerCase().includes("[note:")){
- state.baseNote = text.split(/\[note:/i)[1].split("]")[0].replace(/(?:\r\n|\r|\n)/g, ']\n[');
- }else{
- state.baseNote = "";
- }
- if(text.toLowerCase().includes("[encounter:")){
- var encounterText = text.split(/\[encounter:/i)[1].split("]")[0]
- state.encounter = {text:encounterText,encountered:true,race:{name:encounterText},duration:1,timeout:1}
- }
- state.specialNotes = [];
- if(text.includes("[$")){
- var notes = text.split("[$");
- for(var i =0 ; i < notes.length;i++){
- notes[i] = notes[i].split("]")[0]
- var tag = notes[i].split(":")[0]
- if(notes.length>1){
- state.specialNotes.push({tag:tag,desc:notes[i]})
- }
- }
- }
- }
- }
- else{state.memory.context = ""};
- var memLength = state.memory.context.length;
- for(var i =0; i < state.postKeywords.length;i+=1){
- var entry = makeEntry(state.postKeywords[i]);
- if(entry.length+postMemText.length+memLength < 1400){
- postMemText+=entry;
- }
- }
- for(var i =0; i < state.preKeywords.length;i+=1){
- var entry = makeEntry(state.preKeywords[i]);
- if(entry.length+postMemText.length+preMemText.length+memLength < 1400){
- preMemText= entry+preMemText;
- }
- }
- state.memory.context = preMemText+state.memory.context+postMemText+"\n---";
- }
- function makeEntry(text){
- var lowered = text.toLowerCase();
- for(var i =0;i < state.races.length;i++){
- if(text == state.races[i].name.toLowerCase()){return"["+capitalizeFirst(state.races[i].plural)+": "+state.races[i].desc+"]\n";}
- }
- for(var i =0;i < state.jobs.length;i++){
- if(text == state.jobs[i].name.toLowerCase()){return"["+capitalizeFirst(state.jobs[i].plural)+": "+state.jobs[i].desc+"]\n";}
- }
- for(var i =0; i<state.worldEntries.length;i++){
- if(state.worldEntries[i].keys.toLowerCase().indexOf(lowered)!=-1){
- return "["+capitalizeFirst(state.worldEntries[i].keys.split(",")[0])+": "+state.worldEntries[i].desc+"]\n";}
- }
- return "";
- }
- function addNoteKeyword(text){
- if(!state.noteKeywords.includes(text)){
- state.noteKeywords.push(text);
- if(state.preKeywords.includes(text)){
- state.preKeywords = state.preKeywords.slice(state.preKeywords.indexOf(text),state.preKeywords.indexOf(text))
- }
- if(state.postKeywords.includes(text)){
- state.postKeywords = state.postKeywords.slice(state.postKeywords.indexOf(text),state.postKeywords.indexOf(text))
- }
- }
- }
- function addPostKeyword(text){
- if(!state.postKeywords.includes(text) && !state.noteKeywords.includes(text)){
- state.postKeywords.push(text);
- if(state.preKeywords.includes(text)){
- state.preKeywords = state.preKeywords.slice(state.preKeywords.indexOf(text),state.preKeywords.indexOf(text))
- }
- }
- }
- function addPreKeyword(text){
- if(!state.postKeywords.includes(text) && !state.preKeywords.includes(text) && !state.noteKeywords.includes(text)){
- state.preKeywords.push(text);
- }
- }
- function getRandWeight(list,id){
- var totalWeight = 0;
- for(var i = 0; i<list.length; i++){
- totalWeight += list[i].weight[id];
- }
- var weight = Math.random()*totalWeight;
- for(var i =0; i<list.length;i++){
- weight -= list[i].weight[id];
- if(weight <=0){return list[i];}
- }
- return null;
- }
- function generateEncounter(){
- state.encounter = {};
- var encounterRace = getRandWeight(state.races,1);
- //addNoteKeyword(encounterRace.name);
- state.encounter.race = encounterRace;
- state.encounter.desc = capitalizeFirst(encounterRace.plural)+" are "+uncapitalizeFirst(encounterRace.desc);
- state.encounter.duration = 3;
- state.encounter.timeout = 8;
- state.encounter.encountered = false;
- if (encounterRace.job != false && Math.random()*100>70){
- var encounterClass = getRandWeight(state.jobs,0);
- //addNoteKeyword(encounterClass.name);
- state.encounter.class = encounterClass;
- if(Math.random()*100 > 70){
- state.encounter.text = encounterRace.name+" "+encounterClass.plural;
- state.encounter.desc += " Of this group, each one "+encounterClass.elab;
- }
- else{
- state.encounter.text = aOrAn(encounterRace.name)+" "+encounterClass.name;
- state.encounter.desc += " This one "+encounterClass.elab;
- }
- }
- else{
- state.encounter.class = null;
- if(Math.random()*100 > 70){
- state.encounter.text = encounterRace.plural;
- }
- else{
- state.encounter.text = aOrAn(encounterRace.name);
- }
- }
- if(Math.random()*100 > 70){
- state.encounter.text += " ("+capitalizeFirst(getRandWeight(state.modifiers,0).name)+")"
- }
- state.encounter.desc = parseDesc(state.encounter.desc)
- }
- function aOrAn(text){
- lowered = text.toLowerCase();
- if(lowered.startsWith('a') || lowered.startsWith('e') || lowered.startsWith('i') || lowered.startsWith('o') || lowered.startsWith('u')){
- return "an "+text;
- }else{
- return "a "+text;
- }
- }
- function capitalizeFirst(text){
- return text.substring(0,1).toUpperCase()+text.substring(1)
- }
- function uncapitalizeFirst(text){
- return text.substring(0,1).toLowerCase()+text.substring(1)
- }
- function parseDesc(text){
- if(text.includes("[")){
- var splits = text.split("[");
- for(var i =0 ;i < splits.length;i++){
- if(splits[i].includes("]")){
- var remainder = splits[i].split("]")[1];
- splits[i] = splits[i].split("]")[0].split(",");
- splits[i] = splits[i][Math.floor(Math.random()*splits[i].length)]+remainder;
- }
- }
- text = splits.join("");
- }
- return text;
- }
- if(!state.baseNote){state.baseNote = "";}
- if(!memory){memory = "";}
- if(!state.name){state.name="Player"}
- if(!state.race){state.race="Race"}
- if(!state.job){state.job = "Job"}
- if(!state.encounterCD){state.encounterCD = 0}
- if(!state.blockOutput){state.blockOutput = false;}
- if(!state.forceEncounter){state.forceEncounter = false;}
- if(!history || history.length == 0){history = [{text:"This is some fire mage test text"} , {text:"this is some oni more test text"}]}
- const modifier = (text) => {
- if(!state.blockOutput){ state.message = "";}
- let modifiedText = text
- const lowered = text.toLowerCase()
- if(state.blockOutput){
- state.blockOutput = false;
- modifiedText = "";
- }else{
- state.postKeywords = [];
- state.preKeywords = [];
- state.noteKeywords = [];
- }
- addPostKeyword(state.race);
- addPostKeyword(state.job);
- if(state.encounter==null){
- if((state.encounterCD >=6 && Math.random()*100 > 80) && (history.map(a => a.text).join(" ").length > 800) || state.forceEncounter){
- state.forceEncounter = false;
- generateEncounter();
- }else{
- state.encounterCD += 1;
- }
- }else{
- if(state.encounter.duration <=0){state.encounter = null;state.encounterCD=0;}
- else{
- if(state.encounter.encountered == false){
- //addNoteKeyword(state.encounter.race.name);
- //if(state.encounter.class!=null){addNoteKeyword(state.encounter.class.name);}
- state.encounter.timeout -= 1;
- if(state.encounter.timeout <= 0){state.encounter = null;state.encounterCD=4;}
- }else{
- addPostKeyword(state.encounter.race.name);
- if(state.encounter.class!=null){addPostKeyword(state.encounter.class.name);}
- state.encounter.duration -= 1;
- }
- }
- }
- collectPreKeywords(modifiedText);
- parseMemory();
- // if(modifiedText.startsWith("\n")){modifiedText = modifiedText.substring(1);}
- // You must return an object with the text property defined.
- return {text: modifiedText}
- }
- // Don't modify this part
- modifier(text)
Add Comment
Please, Sign In to add comment