Jul
27
2017




Python module for generating NPC’s in Star Wars RPG

Recently table top gaming has made a huge comeback.  For the first time in 20 years my friends and I are role playing!  We agreed on the new Star Wars RPG by Fantasy Flight games, STAR WARS: Age of Rebellion role playing game.  It’s novel in many aspects compared to the previous D6 and D20 systems.  If you like Role Playing and Star Wars I advise that you take a look!  Since I’m frequently tasked as the GM I’ve automated the process of Non Player Character creation with Python to free up more time for story development.  I developed a module toward this end.  It’s portable between scripts and is easy customize.

The code is on the page below, but you can find updated SWNPC on Github as well.

Goals of this post:

  • Introduce SWNPC module
  • Demonstrate how to customize npc() object
  • Example use

The SWNPC 1.0 was the first Python program I ever wrote.  It’s purpose was to create characters quickly for mass combat situations.  It works well, but is linear and takes many lines of code, it’s not portable, and the formatting is messy.  

The new SWNPC 2.0 version is trimmed down, object oriented and more Pythonic.  For instance, I use comprehensions to create list of random numbers in a certain range, then zip together with character skills to create a Python dictionary for later use.

 

SWNPC module

SWNPC is a Python module for generating Non-Player Characters within the rule system of, Star Wars: Age of Rebellion.  SWNPC automatically selects skills and scores characteristics based on Species, Career, and NPC type.

swnpc.py

 

 

 

Customize SWNPC Module

SWNPC module allows values to be easily customized for species, career or NPC type.  Additionally new species, careers, skills and weapons can be added by updating the respective dictionary.  The module itself currently only has the correct stats for Humans and a some other common Star Wars denizens,  but you can add your own or modify mine.  Observe the following,

The first key in the abilities dictionary is ‘human’, and contains a list of base stats.  The second list is logic to calculate Wound Threshold and Strain Threshold.  In this case 10 + Brawn and 10 + Willpower respectively.  All species and Droids base stats are defined here.  Lets add Wookies!

In the example above I approximated the base stats for an NPC Wookie with three lists.  The first list contains characteristics in the order listed above.  I gave him a base Brawn of 4 and set Willpower to 1(because by all accounts, a Wookie will rip some ones arms in anger for losing a board game, ouch).  ‘.

In a similar fashion we can create custom career types such as ‘pirate’.

The pirate career has no modifiers to stats as the first list shows. The second list specifies that pirates should have two general, three combat and 1 knowledge skill randomly selected  The next list is for equipment that you can add in as a string.  At some point I’ll add a list of generic equipment to pull from.  The final list is talents and bonuses in string format.  I’ll add examples in the future.

We can further modify the final outcome by selecting the NPC Type, ‘minion’, ‘rival’, and ‘nemesis’ as seen below.

 

The Wound/Strain threshold will be calculated by adding the default values with modifiers contained in second list(in this case 14 + Brawn & 12 + Willpower), Career modifiers and NPC type(minion, rival, and Nemesis) modifiers. The final tally is a method ‘object_name.characteristics().

 

 

Example Use

Below is an example of use.  I made a quick program for testing create_NPC.py.(npc2.py should be be in the same directory).  npc() requires parameters: name, species, career/class type, and NPC type(minion, rival, nemeses).  

Lets execute it!

[matt@mattcom1 swnpc2]$ ./create_NPC.py

 

Pirate Object Example
——————————–
Name: Chewy
Species: wookie
Class: pirate
Class Bonus: Some Bonus
NPC Type: rival
NPC Rules: [‘Will Die after exceeding wound threshold.’, ‘Suffers wounds for strain.’]

——————————–
Characteristics: {‘Brawn’: 4, ‘Presence’: 2, ‘Willpower’: 1, ‘Agility’: 2, ‘Cunning’: 2, ‘Strain’: 16, ‘Intellect’: 2, ‘Wound’: 18}
——————————–
General Skills: {‘Piloting – Planetary (Ag)’: 4, ‘Deception (Cun)’: 2, ‘Charm (Pr)’: 2}
Combat Skills: {‘Melee (Br)’: 3, ‘Gunnery (Ag)’: 4, ‘Ranged – Light (Ag)’: 4}
Knowledge Skills: {‘Education (Int)’: 4}

The result shows the increased Brawn and Wound/Strain Threshold because the NPC is a Wookie.  The skills reflect his/her career as a Pirate, and he/she has special rules because he/she is a NPC of type ‘rival’.

This could be adapted to a static script, Django app, or terminal application.  The time saved versus creating NPC’s by hand is well worth your time if you know a little Python!

 

If you like this article tell Google!!









Written by mattb in: Automation,Python,Scripts | Tags: , , , , ,

No Comments »

RSS feed for comments on this post. TrackBack URL

Leave a comment