This repository has been archived on 2025-02-27. You can view files and clone it, but cannot push or open issues or pull requests.
AIDScripting/examples/deathIsland.js

63 lines
2 KiB
JavaScript
Raw Permalink Normal View History

2021-05-06 08:13:50 -06:00
// Checkout the repo examples to get an idea of other ways you can use scripting
// https://github.com/AIDungeon/Scripting/blob/master/examples
const modifier = (text) => {
let modifiedText = text
if(!state.events){
state.turn = 0
state.events = [
'You hear a rustling in the bushes near you. Suddenly',
'An ear splitting scream suddenly echoes',
'You feel a cold chill go up your spine. You look up and see',
'You suddenly get hit by',
'Before you can do that you hear a loud crash. You look towards the sound and see a dark demonic looking creature',
'You discover a horrifying',
'You hear a terrifying sound',
'You wake up and realize you were dreaming. You look down and see that your arms are in shackles',
'A hand grabs your leg and you trip hitting your head on a stone. You wake up in a cage',
'An uneasy feeling begins to settle in your stomach as',
'You remember a dark feeling from last night',
'Suddenly a bloody head rolls toward you from out of the bushes',
'You see a massive creature',
'A band of cannibals',
'You see a band of cannibals',
'A dark creature',
'You feel a sharp pain in your side and realize'
]
}
else{
modifiedText = "\n> You try to " + text.substring(7)
}
state.turn = state.turn + 1
if(state.turn > 2){
state.memory = {context: "You're probably going to die."}
}
if(state.turn > 6){
state.memory = {context: "You're about to die."}
}
else if(state.turn > 10){
state.memory = {context: "You have no hope. There are minutes left till you die."}
}
const nTurn = Math.floor((Math.random() * 2)) + 3
if(state.turn % nTurn === 0){
const eventInd = Math.floor((Math.random() * state.events.length));
if(eventInd < state.events.length){
modifiedText = modifiedText + '\n' + state.events[eventInd]
state.events.splice(eventInd)
}
}
// You must return an object with the text property defined.
return {text: modifiedText}
}
// Don't modify this part
modifier(text)