#coding: utf-8
import workflow, random, fractions, pickle, clipboard, editor, ast
# Get the custom parameters as a dictionary (titles are keys):
params = workflow.get_parameters()
# Get the action's input (a string):
action_in = workflow.get_input()
name = workflow.get_variable('name')
level = workflow.get_variable('level')
trait_list = ast.literal_eval(workflow.get_variable('traits'))
class_profs = {}
class_profs = ast.literal_eval(workflow.get_variable('class_profs'))
statlist = ['strength','intelligence','wisdom','dexterity','constitution','charisma']
def roll_em(dice,pips,mod):
total = 0
for i in range(1,dice+1):
total += random.randint(1,pips)
total += mod
return total
attrib_mods = {3 : -3,4 : -2,5 : -2,6 : -1,7 : -1,8 : -1,9 : 0,10 : 0,11 : 0,12 : 0,13 : 1,14 : 1,15 : 1,16 : 2,17 : 2,18 : 3}
fighter_db = [0,1,1,2,2,2,3,3,3,4,4,4,5,5,5]
weapon_list = {
'dagger' : (4,False,3,0,0,'none',20),
'dart' : (4,False,3,0,0,'none',20),
'whip' : (4,False,3,0,0,'none',0),
'club' : (6,False,1,0,0,'none',0),
'short sword' :(6,False,6,0,0,'none',0),
'mace' : (6,False,5,0,0,'none',0),
'hand axe' : (6,False,5,0,0,'none',0),
'morningstar' : (6,False,8,0,0,'none',0),
'longsword' : (8,False,15,0,0,'none',0),
'spear' : (8,False,10,0,0,'none',0),
'great sword' : (10,True,30,0,0,'none',0),
'great axe' : (10,True,10,0,0,'none',0),
'battle axe' : (6,False,5,0,0,'none',0),
'warhammer' : (6,True,5,0,0,'none',0),
'javelin' : (6,True,3,0,0,'none',20),
'pole arm' : (10,True,7,0,0,'none',0),
'staff' : (6,True,5,0,0,'none',0),
'long bow' : (6,True,30,0,0,'none',125),
'bow' : (6,True,30,0,0,'none',125),
'short bow' : (6,True,30,0,0,'none',125),
'crossbow' : (6,True,30,0,0,'none',125)}
armour_list = {
'clothing' : (0,10),
'hide and fur' : (1,10),
'ring mail' : (3,30),
'lamellar armour' : (3,30),
'leather armour' : (2,20),
'chain mail' : (4,40),
'plate armour' : (6,60)}
professions = {
'villager':[4,0,1000,['clothing','leather armour'],['dagger'],False,''],
'fighter':[8,fractions.Fraction(2,3),2000,['leather armour','hide and fur','ring mail','chain mail','plate armour'],['club','morningstar','dagger','short sword','mace','longsword','spear','great sword'],True,'',{1:['Battlefield Prowess','Damage Bonus'],9:['Leader of Men']}],
'barbarian':[8,fractions.Fraction(2,3),2600,['clothing','leather armour','hide and fur','ring mail','chain mail','plate armour'],['club','morningstar','dagger','short sword','mace','longsword','spear','great sword'],True,'',{1:['Animal Reflexes','Stealthy','Savage Resilience'],5:['Animal Magnetism']}],
'cleric':[6,fractions.Fraction(2,4),1500,['clothing','leather armour','hide and fur','chain mail','ring mail','plate armour'],['club','mace','morningstar'],True,'cleric',{1:['Turn Undead'],2:['Divine Spells'],5:['research spells, scribe scrolls, and brew potions'],9:['craft magic','fortified church'],11:['ritual magic','greater crafting']}],
'shaman' : [6,fractions.Fraction(2,4),1500,['clothing','leather armour'],['club','dagger','hand axe','short sword','spear'],True,'shaman',{1:['Commune','Totem'],2:['Divine Spells'],3:['Sp. Ritual'],5:['Shapechange'],7:['Spiritwalk'],9:['Medicine Lodge']}],
'thief':[4,fractions.Fraction(2,4),1250,['clothing','hide and fur','leather armour'],['dagger','short sword'],False,'',{1:['Thief Skills','Backstab'],9:['hideout']}],
'mage':[4,fractions.Fraction(2,6),2500,['clothing'],['dagger','staff','dart'],False,'wizard',{1:["Arcane Spells","Spellbook"],5:['research spells, scribe scrolls, and brew potions'],9:['craft magic','sanctum'],11:['ritual magic','greater crafting']}],
'elven spellsword':[6,fractions.Fraction(2,3),1750,['leather armour','hide and fur','ring mail','chain mail','plate armour'],['dagger','short sword','longsword','bow'],True,'elf',{1:['Cast Spells','Attuned to Nature','Keen Eyes','Connection to Nature'],5:['research spells, scribe scrolls, and brew potions'],9:['craft magic','fastness']}],
'dwarven vaultguard':[8,fractions.Fraction(2,3),2200,['clothing','leather armour','ring mail','chain mail','plate armour'],['club','dagger','short sword','mace','morningstar','longsword','spear','great sword'],True,'',{1:['Sensitivity to Rock and Stone','Detect Traps','Hardy People']}],
'assassin':[6,fractions.Fraction(2,3),1700,['clothing','leather armour'],['dagger','short sword'],True,'',{1:['Move Silently','Hide in Shadows',"Backstab"]}],
'explorer':[6,fractions.Fraction(2,3),2000,['clothing','leather armour','ring mail','chain mail'],['dagger','short sword','longsword','bow'],True,'',{1:['Accuracy Bonus','Animal Reflexes','Difficult to Spot']}],
'bard':[6,fractions.Fraction(2,4),1400,['clothing','leather armour'],['dagger','short sword'],True,'',{1:['Inspire Courage'],5:['Chronicles of Battle'],9:['hall'],10:['read and cast magic from arcane scrolls']}],
'dwarven craftpriest':[6,fractions.Fraction(2,4),2400,['clothing','leather armour','ring mail','chain mail','plate armour'],['hand axe','battle axe','great axe','flail','mace','morningstar','warhammer'],True,'cleric',{1:['Turn Undead','Journeyman','Attention to Detail','Sensitivity to Rock and Stone','Detect Traps','Hardy People'],2:['Divine Spells'],5:['research spells, scribe scrolls, and brew potions'],9:['craft magic','vault']}],
'elven nightblade':[6,fractions.Fraction(2,4),2775,['clothing','leather armour'],['dagger','short sword','bow','crossbow'],True,'wizard',{1:['Move Silently','Hide in Shadows',"Backstab",'Climb Walls','Acrobatics','Attuned to Nature','Keen Eyes','Connection to Nature'],2:['Cast Spells'],9:['Hideout'],10:['research spells, scribe magical scrolls, and brew potions']}],
'warlock': [4,fractions.Fraction(2,6),2075,['clothing'],['dagger','dart','whip','staff'],False,'wizard',{1:['Arcane Spells','Familiar'],2:['Control Undead','Dark Arts'],4:['Curses'],6:['Contact Dark Powers'],7:['Magical Research'],8:['Alter Shape'],9:['Establish Coterie'],10:['Necromancy','Ritual Magic'],11:['Forbidden Spells']}],
'witch':[4,fractions.Fraction(2,6),2000,['clothing'],['dagger','staff','club','dart'],False,'cleric',{1:['Divine Spells','Tradition'],3:['Brew Potion'],5:['Research Magic'],7:['Scribe Scrolls'],9:['Craft Magic','Coven'],11:['Ritual Magic']}]}
motivation = ['Association','Goal','Glory','Greed','Knowledge','Political-Revolutionary/Patriot','Psychopath','Redemption','Responsibility','Teacher/Mentor','Thrillseeker','Upholding the Good','Unwanted Involvement','Vengeance','Wanderer']
gen_prof = ['Alchemy','Animal Husbandry','Animal Training','Art','Bargaining','Caving','Collegiate Wizardry','Craft','Diplomacy','Disguise','Endurance','Engineering','Gambling','Healing','Intimidation','Knowledge','Labor','Language','Leadership','Lip Reading','Manual of Arms','Mapping','Military Strategy','Mimicry','Naturalism','Navigation','Performance','Profession','Riding','Seafaring','Seduction','Siege Engineering','Signaling','Survival','Theology','Tracking','Trapping']
def pc_gen(name,level):
pc = {}
pc_text = []
pc['name'] = name
pc['level'] = int(level)
pc['alignment'] = random.choice(['Lawful','Lawful','Neutral','Neutral','Neutral','Chaotic'])
for stat in statlist:
pc[stat] = roll_em(3,6,0)
prof_choice = max(pc['strength'],pc['dexterity'],pc['constitution'],pc['intelligence'],pc['wisdom'],pc['charisma'])
if prof_choice == pc['strength']:
pc['profession'] = 'fighter'
if pc['constitution'] < 12:
pc['constitution'] = 12
elif prof_choice == pc['dexterity']:
pc['profession'] = 'thief'
if pc['intelligence'] < 12:
pc['intelligence'] = 12
elif prof_choice == pc['charisma']:
pc['profession'] = 'bard'
if pc['intelligence'] < 12:
pc['intelligence'] = 12
elif prof_choice == pc['constitution']:
pc['profession'] = 'explorer'
if pc['dexterity'] < 12:
pc['dexterity'] = 12
elif prof_choice == pc['wisdom']:
pc['profession'] = 'shaman'
if pc['charisma'] < 12:
pc['charisma'] = 12
elif prof_choice == pc['intelligence']:
pc['profession'] = 'mage'
if pc['wisdom'] < 12:
pc['wisdom'] = 12
level_rand = roll_em(1,6,0)
if level_rand == 1:
pc['level'] = int(level) -2
elif level_rand == 2:
pc['level'] = int(level) -1
elif level_rand in (3, 4):
pc['level'] = int(level)
elif level_rand == 5:
pc['level'] = int(level) +1
else:
pc['level'] = int(level) +2
if pc['level'] < 1:
pc['level'] = 1
hp = 0
hp = roll_em(pc['level'],professions[pc['profession']][0],int(attrib_mods.get(pc['constitution'])))
pc['hp'] = hp
pc['armour'] = str(random.choice(professions[pc['profession']][3])).rstrip(',')
pc['weapon'] = str(random.choice(professions[pc['profession']][4])).rstrip(',')
if professions[pc['profession']][5] == True and weapon_list[pc['weapon']][1] == False:
pc['shield'] = 1
pc['full_armour'] = pc['armour'] + ' & shield'
else:
pc['shield'] = 0
pc['full_armour'] = pc['armour']
pc['atk_throw'] = 10 - int(attrib_mods.get(pc['strength']) + (int(pc['level']) * professions[pc['profession']][1]))
pc['motivation'] = random.choice(motivation)
t1 = random.choice(trait_list)
t2 = random.choice(trait_list)
pc['traits'] = str(t1+', '+t2)
special = ""
for lvl in range(1,pc['level']+1):
try:
special += str(professions[pc['profession']][7][lvl])+', '
except KeyError:
pass
pc['special'] = special
pc['char_profs'] = []
gen_profs = 1
if pc['level'] < 5:
gen_profs = 1
elif pc['level'] < 9:
gen_profs = 2
elif pc['level'] > 13:
gen_profs = 3
else:
gen_profs = 4
gen_profs += attrib_mods.get(int(pc['intelligence']))
# Chooses general proficiencies
for i in range (1,gen_profs+1):
pc['char_profs'].append(random.choice(gen_prof))
# Chooses class proficiencies
for i in range(1,int(pc['level'] * professions[pc['profession']][1])+1):
pc['char_profs'].append(random.choice(class_profs[pc['profession'].title()]))
db = 0
if pc['profession'] in ("fighter","assassin","barbarian","explorer","dwarven vaultguard"):
db = fighter_db[pc['level']]
else:
db = 0
full_text = '> **{} - Level {} {}** ({})<br>\n**Alignment**: {}, **Motivation**: {}<br>\n**AC**: {} ({}), **HP**: {}, **Atk**: {} {}+ 1d{}+{} <br>\n**Str**: {} **Dex**: {} **Con**: {} **Int**: {} **Wis**: {} **Cha**: {}<br>\n**Spec**: {}<br>\n**Profs**: {}<br>'.format(pc['name'],pc['level'],pc['profession'].title(),pc['traits'],pc['alignment'],pc['motivation'],armour_list[pc['armour']][0]+attrib_mods.get(pc['dexterity'])+pc['shield'],pc['full_armour'],pc['hp'],pc['weapon'],pc['atk_throw'],str(weapon_list[pc['weapon']][0]),str(attrib_mods.get(pc['strength'])+db),pc['strength'],pc['dexterity'],pc['constitution'],pc['intelligence'],pc['wisdom'],pc['charisma'],str(pc['special']).translate(None,"['']").rstrip(','),str(pc['char_profs']).rstrip(',').translate(None,"['']"))
return full_text
#name1 = raw_input("What is the character's name? ")
#level1 = raw_input("What level is the character? ")
#pc_gen(name1,level1)
workflow.set_output(pc_gen(name,level))
#editor.replace_text([0],[0],[0])
#pc_gen(name,level)
There are no comments yet.