Skip to content

Instantly share code, notes, and snippets.

@Bastlifa
Created May 15, 2020 01:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bastlifa/83fde756c606d303406650abf287405d to your computer and use it in GitHub Desktop.
Save Bastlifa/83fde756c606d303406650abf287405d to your computer and use it in GitHub Desktop.
Witcher TTRPG Life Events Script for Roll20
on("ready", function()
{
on("chat:message", function (msg)
{
if (msg.type === "api" && msg.content === "!allyEnemy")
{
allyEnemy()
}
if (msg.type === "api" && msg.content === "!fortuneMisfortune")
{
fortuneMisfortune()
}
if (msg.type === "api" && msg.content === "!romance")
{
romance()
}
if (msg.type === "api" && msg.content === "!randomLifeEvent")
{
randomLifeEvent()
}
})
})
function allyEnemy() {
let isAlly = randomInteger(2) - 1
if (isAlly) ally()
else enemy()
}
function fortuneMisfortune() {
if (randomInteger(2) - 1) fortune()
else misfortune()
}
function randomLifeEvent() {
let d10 = randomInteger(10)
if (d10 <= 4) fortuneMisfortune()
else if (d10 >= 5 && d10 <= 7) allyEnemy()
else romance()
}
function fortune() {
let fortuneEffect = [`Some major event or stroke of luck brought you ${randomInteger(10)*100} crowns.`,
`You trained with a teacher. Gain +1 in any INT skill or start a new INT skill at +2.`,
`Something you did gained you 1 favor from a nobleman/noblewoman.`,
`You trained with a soldier. Gain +1 in any combat skill or start a new combat skill at +2.`,
`You encountered a witcher at some point and managed to garner a favor from them.`,
`You fell in with a bandit gang. Once per month you can ask these bandits for 1 favor.`,
`You tamed a ${_.sample(['Wild dog (Pg.310)',
'Wild dog (Pg.310)',
'Wild dog (Pg.310)',
'Wild dog (Pg.310)',
'Wild dog (Pg.310)',
'Wild dog (Pg.310)',
'Wild dog (Pg.310)',
'Wolf (Pg 286)',
'Wolf (Pg 286)',
'Wolf (Pg 286)',])} you encountered in the wilderness.`,
`You managed to garner 1 favor from a powerful mage you helped.`,
`You were given a holy symbol that you can show to people of that faith to gain a +2 to Charisma with them.`,
`You were knighted for valor in a random kingdom. In this kingdom you gain +2 reputation and are recognized as a knight.`,
]
let fortuneName = [
'Jackpot',
'Find a Teacher',
'A Noble Owes You',
'Find a Combat Teacher',
'A Witcher Owes You',
'Fell in with Bandits',
'Tamed a Wild Animal',
'A Mage Owes You',
'Blessed by a Priest',
'Knighted',
]
let d10 = randomInteger(10)
sendChat('Witcher Life Event API Script', `&{template:default} {{name=Fortune}} {{**${fortuneName[d10 - 1]}**}} {{${fortuneEffect[d10 - 1]}}}`)
}
function misfortune() {
let misfortuneName = [
'Debt',
'Imprisonment',
'Addiction',
'Lover, Friend or Relative Killed',
'False Accusation',
'Hunted by the Law',
'Betrayal',
'Accident',
'Mental or Physical Incapacitation',
'Cursed'
]
let misfortuneEffect = [
`You fell deeply into debt to the tune of ${randomInteger(10)*100} crowns.`,
`Something you did (or a false acusation) had you imprisoned for ${randomInteger(10)} months.`,
`You contracted an addiction. You can choose. See the sidebar for addiction rules.`,
`${_.sample(['They died in an accident',
'They died in an accident',
'They died in an accident',
'They died in an accident',
'They died in an accident',
'They were murdered by monsters',
'They were murdered by monsters',
'They were murdered by monsters',
'They were murdered by bandits',
'They were murdered by bandits',
])}`,
`${_.sample(['The accusation is theft',
'The accusation is theft',
'The accusation is theft',
'It\'s cowardice or betrayal',
'It\'s cowardice or betrayal',
'It\'s murder',
'It\'s murder',
'It\'s murder',
'It\'s rape',
'It\'s illegal witchcraft',
])}`,
`${_.sample(['It\'s just a few guards',
'It\'s just a few guards',
'It\'s just a few guards',
'It\'s an entire small town',
'It\'s an entire small town',
'It\'s an entire small town',
'It\'s a major city',
'It\'s a major city',
'A whole kingdom is after you',
'A whole kingdom is after you',
])}`,
`${_.sample(['You are being blackmailed',
'You are being blackmailed',
'You are being blackmailed',
'A secret was exposed',
'A secret was exposed',
'A secret was exposed',
'A secret was exposed',
'You were betrayed by someone very close to you',
'You were betrayed by someone very close to you',
'You were betrayed by someone very close to you',
])}`,
`${_.sample(['You were disfigured. Change your social standing to feared',
'You were disfigured. Change your social standing to feared',
'You were disfigured. Change your social standing to feared',
'You were disfigured. Change your social standing to feared',
`You were healing for ${randomInteger(10)} months`,
`You were healing for ${randomInteger(10)} months`,
`You lost ${randomInteger(10)} months of memory from that year`,
`You lost ${randomInteger(10)} months of memory from that year`,
`You suffer from horrible nightmares (7 in 10 chance each time you sleep)`,
`You suffer from horrible nightmares (7 in 10 chance each time you sleep)`,
])}`,
`${_.sample(['You were poisoned; permanently lose 5 HP',
'You were poisoned; permanently lose 5 HP',
'You were poisoned; permanently lose 5 HP',
'You suffer from anxiety attacks and must make Stun saves (every 5 rounds) in times of stress',
'You suffer from anxiety attacks and must make Stun saves (every 5 rounds) in times of stress',
'You suffer from anxiety attacks and must make Stun saves (every 5 rounds) in times of stress',
'You suffer from anxiety attacks and must make Stun saves (every 5 rounds) in times of stress',
'You have a major psychosis. You hear voices and are violent, irrational, and depressive. The GM controls these voices.',
'You have a major psychosis. You hear voices and are violent, irrational, and depressive. The GM controls these voices.',
'You have a major psychosis. You hear voices and are violent, irrational, and depressive. The GM controls these voices.',
])}`,
`You have been cursed. See the Curse section on pg.230 to determine the details.`
]
let d10 = randomInteger(10)
sendChat('Witcher Life Event API Script', `&{template:default} {{name=Misfortune}} {{**${misfortuneName[d10 - 1]}**}} {{${misfortuneEffect[d10 - 1]}}}`)
}
function ally() {
let male = randomInteger(2) - 1
let pos = ["A Bounty Hunter",
"A Mage ",
"A Mentor or Teacher",
"A Childhood Friend",
"A Craftsman",
"An Old Enemy",
"A Duke/Duchess",
"A Priest/Priestess",
"A Soldier",
"A Bard",]
let met = ["Saved Them from Something",
"Met in a Tavern",
"They Saved You from Something",
"They Hired You for Something",
"You Were Trapped Together",
"You Were Forced to Work Together",
"You Hired Them for Something",
"You Met While Drunk and Hit It Off",
"You Met While Traveling",
"You Fought Together",]
let closeness = ["Acquaintances",
"Acquaintances",
"Acquaintances",
"Acquaintances",
"Friends",
"Friends",
"Close Friends",
"Close Friends",
"Inseperable",
"Bound By Bond",]
let whereAreThey = [
"The Northern Kingdoms",
"The Northern Kingdoms",
"The Northern Kingdoms",
"The Empire of Nilfgaard",
"The Empire of Nilfgaard",
"The Empire of Nilfgaard",
"Elder Lands",
"Elder Lands",
"Elder Lands",
"Beyond the Boundaries"]
let ally = {
Gender: male ? "male" : "female",
Position: _.sample(pos),
["How You Met"]: _.sample(met),
["How Close are You"]: _.sample(closeness),
["Where are they"]: _.sample(whereAreThey)
}
sendChat('Witcher Life Event API Script', `&{template:default} {{name=Ally}} {{Gender=${ally.Gender}}} {{Position=${ally.Position}}} {{How you met=${ally["How You Met"]}}} {{How close are you=${ally["How Close are You"]}}} {{Where are they?=${ally["Where are they"]}}}`)
}
function enemy() {
let pos = ['Ex-Friend',
'Ex-Lover',
'Relative',
'Childhood',
'A Cultist',
'A Bard',
'A Soldier',
'A Bandit',
'A Duke/Duchess',
'A Mage',]
let cause = ['Assaulted the Offended Party',
'Caused the Loss of a Loved One',
'Caused Major Humiliation',
'Enemy Caused a Curse',
'Accused of Illegal Witchcraft',
'Turned Down Romantically',
'Caused a Terrible Wound',
'Blackmail',
'Foiled Plans',
'Caused a Monster Attack',]
let power = ['Social Power',
'Social Power',
'Knowledge',
'Knowledge',
'Physical',
'Physical',
'Minions',
'Minions',
'Magic',
'Magic',]
let offender = _.sample(['You', 'They'])
let escalated = [`${offender} Have Mostly Forgotten`,
`${offender} Have Mostly Forgotten`,
`${offender} Plan to Backstab`,
`${offender} Plan to Backstab`,
`${offender} Will Attack If Encountered`,
`${offender} Will Attack If Encountered`,
`${offender} Will Hunt for Revenge`,
`${offender} Will Hunt for Revenge`,
`${offender} Are Out for Blood`,
`${offender} Are Out for Blood`,]
let enemy = {
Gender: _.sample(['Male', 'Female']),
Position: _.sample(pos),
Cause: _.sample(cause),
Escalated: _.sample(escalated),
Power: _.sample(power)
}
sendChat('Witcher Life Event API Script', `&{template:default} {{name=Enemy}} {{Gender=${enemy.Gender}}} {{Position=${enemy.Position}}} {{Cause=${enemy.Cause}}} {{Power=${randomInteger(10)}}} {{Escalation=${enemy.Escalated}}} {{What is their power=${enemy.Power}}}`)
}
function romance() {
let d10 = randomInteger(10)
if (d10 === 1) {
sendChat('Witcher Life Event API Script', `&{template:default} {{name=Romance}} {{Type=A Happy Love Affair (until next type applies to current lover)}}`)
return
}
if (d10 >= 7) {
sendChat('Witcher Life Event API Script', `&{template:default} {{name=Romance}} {{Type=Whores and Debauchery}}`)
return
}
let romType = null
if (d10 >= 2 && d10 <= 4) romType = "Tragedy"
else romType = "Problem"
let Tragedy = ["Your Lover was captured by bandits some time ago and is still their captive",
"Your Lover mysteriously vanished one day and you don’t know where they went",
"Your Lover was imprisoned or exiled for crimes they may not have commited",
"Your Lover was taken from you by a powerful curse",
"Something got between you and your Lover and you were forced to kill them",
"Your Lover comitted suicide. You may not know why they did it",
"Your Lover was kidnapped by a noble and made into a concubine",
"A rival cut you out of the action and stole your Lover’s af ection",
"Your Lover was killed by monsters. It may have been an accident or planned",
"Your Lover is a mage, a witcher, or a sentient monster, dooming the romance",]
let Problem = ["Your Lover’s family or friends hate you and do not condone your romance",
"Your Lover works as a whore for a living and refuses to give up their job",
"Your Lover is under a minor curse such as paranoia or horrible nightmares",
"Your Lover slept around and refused to stop when you found out",
"Your Lover is insanely jealous and can’t stand you being around any possible rival",
"You f ght constantly and nothing can stop it for long. You always descend into screaming",
"You’re professional rivals of some sort. You steal customers from each other often",
"One of you is human and the other is non-human, making your life difcult",
"Your Lover is already married. They may or may not be willing to leave their spouse",
"Your friends or family hate your Lover and do not condone your romance",]
refDict = {
"Tragedy": Tragedy,
"Problem": Problem
}
sendChat('Witcher Life Event API Script', `&{template:default} {{name=Romance}} {{Type=${romType}}} {{${romType}=${refDict[romType][randomInteger(10) - 1]}}}`)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment