Senior Member
Volunteer Data File Contributor
Join Date: Nov 2009
Posts: 1,502
March 5th, 2014, 07:54 PM
|
So... I decided to finally get cracking, and I'm partway through an output script for 2E files that does some additional bits like showing the cost of individual powers. There are parts that are more difficult than I thought and parts that were far easier than expected. Right now, I only show the name, skills, saves, abilities, and powers, and the last is a bit rough.
Sample Output:
Quote:
Whiplash
Power Level: 10 Power Points Spent: 150/150
Str: +0/+5(10/20) Dex: +3(16) Con: +2/+7(14/24) Int: +1(12) Wis: +2(14) Cha: +0/+7(10/24)
Tough: +7/+11 (Imp: +4) Fort: +7 Ref: +10 Will: +7
Skills: - Acrobatics 12 (+15) [3 PP] - You can flip, dive, roll, tumble, and perform other acrobatic maneuvers, and you're also adept at keeping your balance under difficult circumstances.
- Bluff 0 (+7) [0 PP] - Bluff is the skill of making the outlandish seem credible. It covers acting, fast-talk, trickery, and subterfuge.
- Climb 0 (+5) [0 PP] - You're skilled in scaling angled and uneven surfaces.
- Concentration 4 (+6) [1 PP] - You can focus your mind and concentrate despite difficult conditions, including taking damage.
- Diplomacy 0 (+7) [0 PP] - You're skilled in dealing with people, from etiquette and social graces to a way with words and public speaking. Use this skill to make a good impression, negotiate, and win people over.
- Disguise 0 (+7) [0 PP] - You can use makeup, costumes, and other props to change your appearance.
- Escape Artist 6 (+9/+12) [1.5 PP] - You're trained in escaping bonds and other restraints.
- Gamble 0 (+2) [0 PP] - Use this skill to win games involving both skill and luck. Games based solely only luck - such as flipping a coin - or skill - such as chess - don't involve Gamble checks, unless the character cheats.
- Gather Information 0 (+7) [0 PP] - You know how to make contacts, collect gossip and rumors, question informants, and otherwise get information from people.
- Handle Animal 0 (+7) [0 PP] - You know how to handle, care for, and train various types of animals.
- Intimidate 12 (+19) [3 PP] - You know how to use threats (real or implied) to get others to cooperate.
- Medicine 2 (+4) [0.5 PP] - You're trained in treating injuries and illness.
- Navigate 0 (+1) [0 PP] - You're trained in finding directions and plotting courses from place to place.
- Notice 8 (+10) [2 PP] - Use this skill to notice things.
- Profession (Librarian) 2 (+4) [0.5 PP] - You're trained in a profession such as accountant, doctor, engineer, game designer, lawyer, police officer, reporter, teacher, writer, and so forth.
- Search 4 (+5) [1 PP] - You can search an area for clues, hidden items, traps, and other details. Notice allows you to immediately notice things, Search allows you to pick up on details with some effort. Search works in conjunction with all accurate senses (sight is the only accurate sense for normal humans).
- Sense Motive 6 (+8) [1.5 PP] - You can tell someone's true intentions by paying attention to body language, inflection, and intuition.
- Stealth 10 (+13) [2.5 PP] - You're skilled at going unnoticed.
- Survival 2 (+4) [0.5 PP] - You use this skill to survive in the wilderness, including finding food and shelter, and safely guiding others.
- Swim 0 (+5) [0 PP] - You can swim and maneuver underwater.
Powers:- Jaded (Immunity 5) (interaction skills) - [5 PP]
- Leaping 1 (Jumping distance: x2) - [1 PP]
- Leather Catsuit (Container, Passive 2) () - [10 PP]
- Immunity 2 (environmental condition: Heat, environmental condition: Cold) - [2 PP]
- Protection 4 (+4 Toughness; Impervious) - [8 PP]
- Magically Enhanced Traits (Enhanced Trait 40) (Traits: Constitution +10 (24, +7), Strength +10 (20, +5), Charisma +14 (24, +7), Dodge Focus 6 +4 (+6), Feats: Attractive 2 (+8)) - [40 PP]
- Speed 1 (Speed: 10 mph, 88 ft./rnd) - [1 PP]
- Whip Powers (Container, Passive 6) () - [30 PP]
- Elongation 3 (Elongation: 25 ft., range incr 30 ft., +3 Escape & Grapple; Projection; Limited (Limited to whip)) - [3 PP]
- Enhanced Trait 11 (Feats: Attack Specialization 3 (Grapple), Chokehold, Defensive Throw, Fascinate (Intimidate), Improved Disarm, Improved Grab, Improved Grapple, Improved Pin, Improved Trip) - [11 PP]
- Strike 6 (DC 26; Mighty) - [10 PP]
- Blinding Strike (Dazzle 7) (affects: visual senses, DC 17; Range (touch)) - [1 PP]
- Gimp (Paralyze 7) (DC 17; Alternate Save (Fortitude); Slow) - [1 PP]
- Trip 5 (Knockback; Range (touch); Custom (Mighty - Add Strength bonus to trip attempt), Custom (Up in the Air (Choose direction of Knockback))) - [1 PP]
- Super-Movement 3 (slow fall, swinging, wall-crawling 1 (half speed)) - [6 PP]
|
Python code:
Code:
import sys
import xml.etree.ElementTree as ET
def printPowers (powers):
if powers is not None and len(powers) > 0:
print (' - ')
for power in powers:
print ('
- ' + power.attrib['name'], '(' + power.attrib['summary'] + ') - [' + power.find('cost').attrib['text'] + ']')
otherpowersEl = power.find('otherpowers')
printPowers(otherpowersEl)
alternatePowersEl = power.find('alternatepowers')
printPowers(alternatePowersEl)
print('
')
xmlfile = open(sys.argv[1], 'r')
tree = ET.parse(xmlfile)
xmlfile.close()
root = tree.getroot()
for character in root.findall("./*/character"):
role = character.attrib['role']
name = character.attrib.get('name')
if name is None:
name = "Unnamed Hero"
print (' ' + character.attrib['name'] + '')
print ()
resources = character.find('resources')
if resources is not None:
currentPL = resources.attrib['currentpl']
totalPP = resources.attrib['totalpp']
# Next step is to pull in the resources themselves.
totalPPSpent = 0
resourceVals = resources.findall('resource')
for resource in resourceVals:
totalPPSpent += int(resource.attrib['spent'])
print ('Power Level: ' + str(currentPL) + ' Power Points Spent: ' + str(totalPPSpent), end='')
if role == 'pc':
print ('/' + str(totalPP))
else:
print ()
print ()
#print the attributes
attributesEl = character.find('attributes')
if attributesEl is not None:
attributes = attributesEl.findall('attribute')
for attribute in attributes:
print (' ' + attribute.attrib['name'][0:3] + ': ', end='')
attrvalue = attribute.find('attrvalue')
attrbonus = attribute.find('attrbonus')
if attrbonus is not None:
print (attrbonus.attrib['text'] + '', end='')
else:
print ('[/b]', end='')
if attrvalue is not None:
print ('(' + attrvalue.attrib['text'] + ')', end='')
print (' ', end='')
print ()
print ()
#Saves
savesEl = character.find('saves')
if savesEl is not None:
saves = savesEl.findall('save')
print (' ', end='')
for save in saves:
print (save.attrib['abbr'] + ': ' + save.attrib['text'] + ' ', end='')
if int(save.attrib['impervious']) > 0:
print ('(Imp: ' + save.attrib['impervious'] + ') ', end='')
print ('')
#Skills
skillsEl = character.find('skills')
if skillsEl is not None:
skills = skillsEl.findall('skill')
print (' Skills: - ')
for skill in skills:
userRanks = int(skill.attrib['user'])
if userRanks > 0 or skill.attrib.get('trainedonly') != 'yes':
print ('
- ', skill.attrib['name'], userRanks, '(' + skill.attrib['value'] + ')',
'[' + skill.find('cost').attrib['text'] + '] - ', skill.find('description').text)
print ('
')
#Powers
powersEl = character.find('powers')
if powersEl is not None:
print (' Powers:')
printPowers(powersEl)
|