SlideShare a Scribd company logo
1 of 6
Download to read offline
The Python RPG Generator
This tool set which is a series of programs, has been designed for a person with Python programming
experience so that they may build multiple computer based role playing games without having to re-
invent or re-code the fundamental parts of the RPG. This tool set includes the following programs
which will be discussed in greater detail later.

The pyDie.py program was designed separately from the RPG Generator and is used to create dice
using a preset pattern. This program allows for the creation of multiple dice with varying
characteristics.

The namegen.py program was adapted from source found on
http://www.uselesspython.com/download.php?script_id=32. It allows for the random generation of a
avatar's name.

The charGen.py program has been designed solely with the RPG Generator in mind. This program
allows for the creation of avatars and create some fundamental characteristics of each. This program
uses pyDie for dice rolls and namegen for avatar name generation.

The storyWriter.py program can be used to read in a file that uses a specific format, that can then be
used to create the story for the RPG. This program accepts shortcuts in the text file that it reads so that
various attributes of the avatar can be placed into the story.

Finally, the rpgGenerator.py is the main part of this tool set as it does the work of pulling the story
together with the characters. Any individual program or combination or programs can be used to create
the RPG, or by using the rpgGenerator program, the RPG developer can create a game by creating a
story text file with shortcuts included and then a wrapper program that contains the logic for the
sequences following the presentation of each scene/location/plot of the story (explained in further detail
later).


pyDie
To begin with let us look at the pyDie program in further detail. The pyDie program contains two
classes (die and cup). For this tool set we will only address the die class itself. A single die can be
created by calling this class and providing at least one parameter. The parameters and their defaults are
(sides, starting point = 1, maximum = 6, increment = 1). By calling the die class and passing the
number six (6), a standard six sided die is created. This die can then be rolled by calling the roll
method. Additional die can be created and made unique for the purposes required by altering the
default parameters (see pyDie documentation for details).


namegen
The namegen program came with no documentation or license. In fact it didn't even have a name just
simply the code. This program was used solely to prevent re-inventing the wheel, but it is the least
documented program and the one part of the tool suite that does not follow good coding standards, so at
some point this may be replaced.
charGen
The charGen program is the avatar (or character) generator for the RPG Generator tool set. It is made
up of a single class called character. The program uses five files located one directory back from the
script itself in the lib directory. Thus if the charGen.py file is located in RPG_Gen/etc, these files can
be found in RPG_Gen/lib. These files are used for controlling the various attributes of the randomly
generated character. They are (race.txt, specialty.txt, powers.txt, skills.txt, tools.txt). Let us look at
each of these files in order.
   1. The race.txt file is a text file that contains all the races you want to use for character generation
      in your game. By default these include (Human, Dwarf, Giant, Alien, Creature, and Organism)
      all on individual lines.
   2. The specialty.txt file is a | delimited file with the format of (specialty|sex[m,f,a]|race). This file
      is used to determine the various specialties for a race. The sex field is can contain one or more
      of m = male, f = female, a = no sex or asexual separated by commas, and the race field can
      contain one or more races separated by commas. Thus the line “Servant|m,f|
      Human,Dwarf,Alien” tells us that the “Servant” specialty can belong to any character that is
      male or female of the Human, Dwarf, or Alien race.
   3. The powers.txt file defines the powers that a specialty or race can be assigned. It is a | delimited
      file in the format of (power|specialty/race). The specialty/race field is comma delimited and
      limits the power assigned to a list of specialties and/or races. Thus the line “Invisibility|
      Sorcerer,Alien” tells us that Invisibility can be given to the Sorcerer specialty or the Alien race.
      At creation time, only one power is given by default, but others can be added as the rule in the
      powers.txt file dictates.
   4. The skills.txt file defines the skills that each specialty is allocated the time of character creation.
      This is a | delimited file in the format of (skill|specialty). The specialty field is comma
      delimited and limits the skill assigned to a list of specialties. Also the * symbol may be used to
      specify all specialties. Thus the line “Fight|*” means all specialties are given the Fight skill
      while the line “Heal|Physician,Mage” tells us that only the Physician and Mage specialties can
      Heal.
   5. The tools.txt file defines the tools that each specialty or race can be assigned. It is a | delimited
      file in the format of (tool|specialty/race). The specialty/race field is comma delimited and
      limits the power assigned to a list of specialties and/or races. Thus the line (Laser|
      Alien,Hacker) tells us that the Laser tool can be assigned to the Alien race or the Hacker
      specialty. Like powers only one tool is given by default at the creation of a character, but others
      may be added as the rule in tools.txt dictates.
The use of these five files allows the RPG developer to specify characteristics and tools that are
allowed for each character, and thus additional characteristics can be added without changing the code
of the game itself.


The next thing to note about the charGen program is the methods (attack, defend, learn, isDead,
addTool, and addPower). We will look at each of these one at a time.
   1. If the character using the attack method is still alive, it will add the character values for
      strength, wisdom, and experience together, it then performs integer division upon this result by
      adding the result of the roll of a six sided die to 10. Thus the formula used is (strength +
      wisdom + experience)//(die value + 10). This result is then returned to the calling program.
2. If the character using the defend method is still alive, it will use the same logic in determining a
      defense value as the attack method, with the resulting value returned to the calling program.
   3. If the character using the learn method is still alive, it will roll an eight sided die that starts at
      two and increments by twos add this value to the character's wisdom value and return this
      number to the calling program. Thus a character with a wisdom of 11 that calls the learn
      method that gets a roll value of 8 would have the value 19 returned to the calling program. It is
      up to the RPG developer how to handle this value. They may simply change the learn value or
      use it in some other fashion as their program logic dictates.
   4. The isDead method looks at the character's strength and if it is < 1 then the character's strength,
      wisdom, experience, skills, powers, and tools are cleared and True is returned to the calling
      program. Otherwise False is returned to the calling program. This method can be used to
      determine if the character died during battle.
   5. The addTool and addPower methods are used to add another random tool or power to the
      character (if one is available as defined in the corresponding text files).



storyWriter
The storyWriter program is used to read in and process the story file. It has a single class called story
which has one method called open. It is used simply by creating a storyWriter.story object and then
calling the open method. The story class has one mandatory argument which is the name of the file to
be read. This file must be stored in the RPG_Gen/share directory. The story file itself is made up of
four sections labeled as Intro, Scene, Location, and Plot (see below).

               <Intro>
                    Introduction lines ...
               </Intro>
               <Scene>
                    Text inside here is ignored.
                    <Location>
                          Location lines ...
                          <Plot>
                               Plot lines ...
                          </Plot>
                    </Location>
               </Scene>
There are shortcuts which can be included in the text of each section (except for Scene which is
ignored) that allow the RPG Developer to specify where various aspects (such as name, experience,
race, etc) are to be displayed for each character as the story is played out. The following is a list of
allowed shortcuts.
Within the plot line use the &# shortcut to represent your character as it corresponds to the
      list #. For instance if you use a list avatars = [] that you populate with 10 characters then
      <5> would be the 6th character since lists begin with 0. Thus think of 0 as your main
      character. Shortcuts include:
      &# = character description (name the race specialty)
      &#.nam = character name (text)
      &#.rac = character race (text)
      &#.spe = character specialty (text)
      &#.sex = character sex (text m,f,a = male, female, asexual)
      &#.evi = character trait (text evil or good)
      &#.exp = character experience (number)
      &#.str = character strength (number)
      &#.wis = character wisdom (number)
      &#.skl$ = character skill where $ represents the list number for the skill in question
      starting with 0 (text)
      &#.pow$ = character power where $ represents the list number for the skill in question
      starting with 0 (text)
      &#.tol$ = character tool where $ represents the list number for the skill in question starting
      with 0 (text)


      So to access the 3rd tool for the 6th character the shortcut would be &5.to2
The line “This player is &1.evi.” within the story text file causes storyWriter to replace &1.evi with
Evil or Good for character 1. Keep in mind that this uses list processing within Python thus 0 is the
actual first character in the list.

rpgGenerator
The main tool within the RPG Generator tookit is the rpgGenerator itself. It pulls in all the previously
mentioned programs and incorporates them into a functioning tool that can then be used to create your
game based upon the lib and share files mentioned above. It is made up of three classes (player,
opponent, and game). The player class simply inherits the charGen.character class for creating the
game's initial player, while the opponent class changes the inheritance slightly by forcing all opponents
to be on the opposite of the player. Thus if player is created as “Good”, then all opponents are “Evil”.
The game class is used to create the story and populate the shortcuts used in the storyWriter file. It
assumes that &0 is always the player and any &# > 0 is an enemy. The following is a very simplistic
example for using rpgGenerator.
import rpgGenerator


     fn = 'setup.txt'


     me = rpgGenerator.player(False)
     myGame = rpgGenerator.game(me, 4, fn)
     print 'Characters are:'
     for i in myGame.characters:
       print '        %s'%(i.name)
     print 'Intro:'
     print myGame.intro
     print
     for s in range(0, len(myGame.scenes)):
       print 'Scene: %i'%s
       loca = 0
       for l in range(0, len(myGame.locations)):
             sid, location = myGame.locations[l]
             if sid == s:
               print 'Location %i'%l
               print location
               for p in range(0, len(myGame.plots)):
                  sid2, lid, plot = myGame.plots[p]
                  if sid2 == s and lid == loca:
                      print 'Plot %i'%p
                      print plot
               loca += 1
First you import rpgGenerator. Then you have to create your initial player and tell it whether it is evil
or not (in this case the player is good so all enemies will be evil). Next you have to create your game,
by specifying the name of your player object, how many opponents you want to create, (this should
match the number used in your story file. It is acceptable to have too many but too few and you will
get weird results.), and your story file name. From that point it is up to the RPG Developer how they
want their game to flow, but the above example shows how to access the various elements of the story.
The following is an example of the output using the default files included with the RPG Generator.
Characters are:
           Einckae
           Yulemziu
           Iuoi
           Goi
           Yujrei
       Intro:
       This is a setup for a story file. It doesn't really do anything.
       But it does demonstrate the setup of the story file.




       Scene: 0
       Location 0
       Coolsville - Einckae the Dwarf Duke is Good


       Plot 0
       I want to do something here.
       I will display Yulemziu's name.
       The oponenet Yulemziu is Evil.


       Plot 1
       Now I want to do something else.
       I can even use multiple lines.
       Einckae can battle Yulemziu with Knife.
       Einckae has [] powers while
       Yulemziu has ['Teleportation'] powers.


       Location 1
       My House


       Plot 2
       Not much happening here...
       The character has these skills.
       ['Fight', 'Speak', 'Build', 'Read', 'Ride']
       And the first enemy has these tools.
       ['Shield']
       … etc

As you can see the tool kit allows for a great deal of flexibility for the RPG Developer to create a tailor
made game again and again, without having to rewrite much of the mundane code required for
character and plot line development. This allows them to focus on the story itself.

More Related Content

What's hot

Sql server difference faqs- 9
Sql server difference faqs- 9Sql server difference faqs- 9
Sql server difference faqs- 9Umar Ali
 
Chapter 13.1.3
Chapter 13.1.3Chapter 13.1.3
Chapter 13.1.3patcha535
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python FundamentalsPraveen M Jigajinni
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with pythonArslan Arshad
 
Python interview questions
Python interview questionsPython interview questions
Python interview questionsPragati Singh
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonSujith Kumar
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonObject Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonPython Ireland
 
Review python - By Amresh Tiwari
Review python - By Amresh TiwariReview python - By Amresh Tiwari
Review python - By Amresh TiwariAmresh Tiwari
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python amiable_indian
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python ProgrammingKamal Acharya
 
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...Ranel Padon
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like PythonistaChiyoung Song
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answersRojaPriya
 
CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONLalitkumar_98
 

What's hot (19)

Ruby_Basic
Ruby_BasicRuby_Basic
Ruby_Basic
 
Sql server difference faqs- 9
Sql server difference faqs- 9Sql server difference faqs- 9
Sql server difference faqs- 9
 
java
java java
java
 
Chapter 13.1.3
Chapter 13.1.3Chapter 13.1.3
Chapter 13.1.3
 
11 Unit 1 Chapter 02 Python Fundamentals
11  Unit 1 Chapter 02 Python Fundamentals11  Unit 1 Chapter 02 Python Fundamentals
11 Unit 1 Chapter 02 Python Fundamentals
 
Object oriented programming with python
Object oriented programming with pythonObject oriented programming with python
Object oriented programming with python
 
Python interview questions
Python interview questionsPython interview questions
Python interview questions
 
Basics of Object Oriented Programming in Python
Basics of Object Oriented Programming in PythonBasics of Object Oriented Programming in Python
Basics of Object Oriented Programming in Python
 
Object Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in PythonObject Orientation vs. Functional Programming in Python
Object Orientation vs. Functional Programming in Python
 
Review python - By Amresh Tiwari
Review python - By Amresh TiwariReview python - By Amresh Tiwari
Review python - By Amresh Tiwari
 
Introduction to Python
Introduction to Python Introduction to Python
Introduction to Python
 
Fundamentals of Python Programming
Fundamentals of Python ProgrammingFundamentals of Python Programming
Fundamentals of Python Programming
 
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
Python Programming - IV. Program Components (Functions, Classes, Modules, Pac...
 
Code Like Pythonista
Code Like PythonistaCode Like Pythonista
Code Like Pythonista
 
ppt
pptppt
ppt
 
Python Presentation
Python PresentationPython Presentation
Python Presentation
 
Python interview questions and answers
Python interview questions and answersPython interview questions and answers
Python interview questions and answers
 
CLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHONCLASS OBJECT AND INHERITANCE IN PYTHON
CLASS OBJECT AND INHERITANCE IN PYTHON
 
Ruby Programming
Ruby ProgrammingRuby Programming
Ruby Programming
 

Viewers also liked

Reli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbod
Reli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbodReli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbod
Reli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbodRELI_Vakantiewoningen
 
201303 magazine ronald
201303 magazine ronald201303 magazine ronald
201303 magazine ronaldRonald Smits
 
Social Business Collaboration Award 2012
Social Business Collaboration Award 2012Social Business Collaboration Award 2012
Social Business Collaboration Award 2012Herbert Wagger
 
Hoe het primaire brein ons (online) beïnvloedt?
Hoe het primaire brein ons (online) beïnvloedt?Hoe het primaire brein ons (online) beïnvloedt?
Hoe het primaire brein ons (online) beïnvloedt?Erwin Sigterman
 

Viewers also liked (7)

Reli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbod
Reli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbodReli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbod
Reli - vakantiewoningen - Zuid Frankrijk - 2015 - Volledig aanbod
 
201303 magazine ronald
201303 magazine ronald201303 magazine ronald
201303 magazine ronald
 
Kano
KanoKano
Kano
 
Social Business Collaboration Award 2012
Social Business Collaboration Award 2012Social Business Collaboration Award 2012
Social Business Collaboration Award 2012
 
Hoe het primaire brein ons (online) beïnvloedt?
Hoe het primaire brein ons (online) beïnvloedt?Hoe het primaire brein ons (online) beïnvloedt?
Hoe het primaire brein ons (online) beïnvloedt?
 
Soukzes
SoukzesSoukzes
Soukzes
 
Ontbijtsessie kortrijk
Ontbijtsessie kortrijkOntbijtsessie kortrijk
Ontbijtsessie kortrijk
 

Similar to

Esprima - What is that
Esprima - What is thatEsprima - What is that
Esprima - What is thatAbhijeet Pawar
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparationKushaal Singla
 
Assignment #8Objectives1. To learn how to design and impleme.docx
Assignment #8Objectives1. To learn how to design and impleme.docxAssignment #8Objectives1. To learn how to design and impleme.docx
Assignment #8Objectives1. To learn how to design and impleme.docxfredharris32
 
I have the following problemFor Java GUI project, you will implem.pdf
I have the following problemFor Java GUI project, you will implem.pdfI have the following problemFor Java GUI project, you will implem.pdf
I have the following problemFor Java GUI project, you will implem.pdfrajkumarm401
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdfprasnt1
 
Earthworm Platformer Package
Earthworm Platformer PackageEarthworm Platformer Package
Earthworm Platformer PackageOh DongReol
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxfredharris32
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addisorayan5ywschuit
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Techglyphs
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1Asad Khan
 
In this project you will define some interfaces, abstract classes, a.pdf
In this project you will define some interfaces, abstract classes, a.pdfIn this project you will define some interfaces, abstract classes, a.pdf
In this project you will define some interfaces, abstract classes, a.pdffathimaoptical
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java MayaTofik
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameAntony Stubbs
 

Similar to (20)

Sam python pro_points_slide
Sam python pro_points_slideSam python pro_points_slide
Sam python pro_points_slide
 
Esprima - What is that
Esprima - What is thatEsprima - What is that
Esprima - What is that
 
C interview-questions-techpreparation
C interview-questions-techpreparationC interview-questions-techpreparation
C interview-questions-techpreparation
 
Assignment #8Objectives1. To learn how to design and impleme.docx
Assignment #8Objectives1. To learn how to design and impleme.docxAssignment #8Objectives1. To learn how to design and impleme.docx
Assignment #8Objectives1. To learn how to design and impleme.docx
 
I have the following problemFor Java GUI project, you will implem.pdf
I have the following problemFor Java GUI project, you will implem.pdfI have the following problemFor Java GUI project, you will implem.pdf
I have the following problemFor Java GUI project, you will implem.pdf
 
Functions2.pdf
Functions2.pdfFunctions2.pdf
Functions2.pdf
 
Python basic
Python basicPython basic
Python basic
 
Earthworm Platformer Package
Earthworm Platformer PackageEarthworm Platformer Package
Earthworm Platformer Package
 
Turbo prolog 2.0 basics
Turbo prolog 2.0 basicsTurbo prolog 2.0 basics
Turbo prolog 2.0 basics
 
Article link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docxArticle link httpiveybusinessjournal.compublicationmanaging-.docx
Article link httpiveybusinessjournal.compublicationmanaging-.docx
 
Dynamic Python
Dynamic PythonDynamic Python
Dynamic Python
 
Data types
Data typesData types
Data types
 
Easy R
Easy REasy R
Easy R
 
Hey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addiHey i have attached the required file for my assignment.and addi
Hey i have attached the required file for my assignment.and addi
 
Bt0067 c programming and data structures2
Bt0067 c programming and data structures2Bt0067 c programming and data structures2
Bt0067 c programming and data structures2
 
Functions in python
Functions in pythonFunctions in python
Functions in python
 
Hibernate Training Session1
Hibernate Training Session1Hibernate Training Session1
Hibernate Training Session1
 
In this project you will define some interfaces, abstract classes, a.pdf
In this project you will define some interfaces, abstract classes, a.pdfIn this project you will define some interfaces, abstract classes, a.pdf
In this project you will define some interfaces, abstract classes, a.pdf
 
Modern_2.pptx for java
Modern_2.pptx for java Modern_2.pptx for java
Modern_2.pptx for java
 
Scala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love GameScala Language Intro - Inspired by the Love Game
Scala Language Intro - Inspired by the Love Game
 

More from cfministries

Py Die R E A D M E
Py Die  R E A D M EPy Die  R E A D M E
Py Die R E A D M Ecfministries
 
Elemental Christianity
Elemental  ChristianityElemental  Christianity
Elemental Christianitycfministries
 
Example Stream Setup
Example  Stream  SetupExample  Stream  Setup
Example Stream Setupcfministries
 
Peering Through The Mercy Seat
Peering Through The Mercy SeatPeering Through The Mercy Seat
Peering Through The Mercy Seatcfministries
 
Apostolic Private Eye
Apostolic  Private  EyeApostolic  Private  Eye
Apostolic Private Eyecfministries
 
Do You Make Jesus Sick
Do You Make  Jesus SickDo You Make  Jesus Sick
Do You Make Jesus Sickcfministries
 
Why Wait Get It Now
Why Wait    Get It NowWhy Wait    Get It Now
Why Wait Get It Nowcfministries
 
The Mind Of God ( Part 5)
The  Mind Of  God ( Part 5)The  Mind Of  God ( Part 5)
The Mind Of God ( Part 5)cfministries
 
The Mind Of God ( Part 4)
The  Mind Of  God ( Part 4)The  Mind Of  God ( Part 4)
The Mind Of God ( Part 4)cfministries
 
The Mind Of God ( Part 3)
The  Mind Of  God ( Part 3)The  Mind Of  God ( Part 3)
The Mind Of God ( Part 3)cfministries
 
The Mind Of God ( Part 2)
The  Mind Of  God ( Part 2)The  Mind Of  God ( Part 2)
The Mind Of God ( Part 2)cfministries
 
The Mind Of God ( Part 1)
The  Mind Of  God ( Part 1)The  Mind Of  God ( Part 1)
The Mind Of God ( Part 1)cfministries
 

More from cfministries (17)

Grade Statistics
Grade StatisticsGrade Statistics
Grade Statistics
 
R P G Generator
R P G  GeneratorR P G  Generator
R P G Generator
 
Py Die R E A D M E
Py Die  R E A D M EPy Die  R E A D M E
Py Die R E A D M E
 
Dealing W Spam
Dealing W SpamDealing W Spam
Dealing W Spam
 
Python Menu
Python MenuPython Menu
Python Menu
 
Elemental Christianity
Elemental  ChristianityElemental  Christianity
Elemental Christianity
 
Example Stream Setup
Example  Stream  SetupExample  Stream  Setup
Example Stream Setup
 
Peering Through The Mercy Seat
Peering Through The Mercy SeatPeering Through The Mercy Seat
Peering Through The Mercy Seat
 
Apostolic Private Eye
Apostolic  Private  EyeApostolic  Private  Eye
Apostolic Private Eye
 
Do You Make Jesus Sick
Do You Make  Jesus SickDo You Make  Jesus Sick
Do You Make Jesus Sick
 
Why Wait Get It Now
Why Wait    Get It NowWhy Wait    Get It Now
Why Wait Get It Now
 
The Mind Of God ( Part 5)
The  Mind Of  God ( Part 5)The  Mind Of  God ( Part 5)
The Mind Of God ( Part 5)
 
The Mind Of God ( Part 4)
The  Mind Of  God ( Part 4)The  Mind Of  God ( Part 4)
The Mind Of God ( Part 4)
 
5 Questions
5  Questions5  Questions
5 Questions
 
The Mind Of God ( Part 3)
The  Mind Of  God ( Part 3)The  Mind Of  God ( Part 3)
The Mind Of God ( Part 3)
 
The Mind Of God ( Part 2)
The  Mind Of  God ( Part 2)The  Mind Of  God ( Part 2)
The Mind Of God ( Part 2)
 
The Mind Of God ( Part 1)
The  Mind Of  God ( Part 1)The  Mind Of  God ( Part 1)
The Mind Of God ( Part 1)
 

  • 1. The Python RPG Generator This tool set which is a series of programs, has been designed for a person with Python programming experience so that they may build multiple computer based role playing games without having to re- invent or re-code the fundamental parts of the RPG. This tool set includes the following programs which will be discussed in greater detail later. The pyDie.py program was designed separately from the RPG Generator and is used to create dice using a preset pattern. This program allows for the creation of multiple dice with varying characteristics. The namegen.py program was adapted from source found on http://www.uselesspython.com/download.php?script_id=32. It allows for the random generation of a avatar's name. The charGen.py program has been designed solely with the RPG Generator in mind. This program allows for the creation of avatars and create some fundamental characteristics of each. This program uses pyDie for dice rolls and namegen for avatar name generation. The storyWriter.py program can be used to read in a file that uses a specific format, that can then be used to create the story for the RPG. This program accepts shortcuts in the text file that it reads so that various attributes of the avatar can be placed into the story. Finally, the rpgGenerator.py is the main part of this tool set as it does the work of pulling the story together with the characters. Any individual program or combination or programs can be used to create the RPG, or by using the rpgGenerator program, the RPG developer can create a game by creating a story text file with shortcuts included and then a wrapper program that contains the logic for the sequences following the presentation of each scene/location/plot of the story (explained in further detail later). pyDie To begin with let us look at the pyDie program in further detail. The pyDie program contains two classes (die and cup). For this tool set we will only address the die class itself. A single die can be created by calling this class and providing at least one parameter. The parameters and their defaults are (sides, starting point = 1, maximum = 6, increment = 1). By calling the die class and passing the number six (6), a standard six sided die is created. This die can then be rolled by calling the roll method. Additional die can be created and made unique for the purposes required by altering the default parameters (see pyDie documentation for details). namegen The namegen program came with no documentation or license. In fact it didn't even have a name just simply the code. This program was used solely to prevent re-inventing the wheel, but it is the least documented program and the one part of the tool suite that does not follow good coding standards, so at some point this may be replaced.
  • 2. charGen The charGen program is the avatar (or character) generator for the RPG Generator tool set. It is made up of a single class called character. The program uses five files located one directory back from the script itself in the lib directory. Thus if the charGen.py file is located in RPG_Gen/etc, these files can be found in RPG_Gen/lib. These files are used for controlling the various attributes of the randomly generated character. They are (race.txt, specialty.txt, powers.txt, skills.txt, tools.txt). Let us look at each of these files in order. 1. The race.txt file is a text file that contains all the races you want to use for character generation in your game. By default these include (Human, Dwarf, Giant, Alien, Creature, and Organism) all on individual lines. 2. The specialty.txt file is a | delimited file with the format of (specialty|sex[m,f,a]|race). This file is used to determine the various specialties for a race. The sex field is can contain one or more of m = male, f = female, a = no sex or asexual separated by commas, and the race field can contain one or more races separated by commas. Thus the line “Servant|m,f| Human,Dwarf,Alien” tells us that the “Servant” specialty can belong to any character that is male or female of the Human, Dwarf, or Alien race. 3. The powers.txt file defines the powers that a specialty or race can be assigned. It is a | delimited file in the format of (power|specialty/race). The specialty/race field is comma delimited and limits the power assigned to a list of specialties and/or races. Thus the line “Invisibility| Sorcerer,Alien” tells us that Invisibility can be given to the Sorcerer specialty or the Alien race. At creation time, only one power is given by default, but others can be added as the rule in the powers.txt file dictates. 4. The skills.txt file defines the skills that each specialty is allocated the time of character creation. This is a | delimited file in the format of (skill|specialty). The specialty field is comma delimited and limits the skill assigned to a list of specialties. Also the * symbol may be used to specify all specialties. Thus the line “Fight|*” means all specialties are given the Fight skill while the line “Heal|Physician,Mage” tells us that only the Physician and Mage specialties can Heal. 5. The tools.txt file defines the tools that each specialty or race can be assigned. It is a | delimited file in the format of (tool|specialty/race). The specialty/race field is comma delimited and limits the power assigned to a list of specialties and/or races. Thus the line (Laser| Alien,Hacker) tells us that the Laser tool can be assigned to the Alien race or the Hacker specialty. Like powers only one tool is given by default at the creation of a character, but others may be added as the rule in tools.txt dictates. The use of these five files allows the RPG developer to specify characteristics and tools that are allowed for each character, and thus additional characteristics can be added without changing the code of the game itself. The next thing to note about the charGen program is the methods (attack, defend, learn, isDead, addTool, and addPower). We will look at each of these one at a time. 1. If the character using the attack method is still alive, it will add the character values for strength, wisdom, and experience together, it then performs integer division upon this result by adding the result of the roll of a six sided die to 10. Thus the formula used is (strength + wisdom + experience)//(die value + 10). This result is then returned to the calling program.
  • 3. 2. If the character using the defend method is still alive, it will use the same logic in determining a defense value as the attack method, with the resulting value returned to the calling program. 3. If the character using the learn method is still alive, it will roll an eight sided die that starts at two and increments by twos add this value to the character's wisdom value and return this number to the calling program. Thus a character with a wisdom of 11 that calls the learn method that gets a roll value of 8 would have the value 19 returned to the calling program. It is up to the RPG developer how to handle this value. They may simply change the learn value or use it in some other fashion as their program logic dictates. 4. The isDead method looks at the character's strength and if it is < 1 then the character's strength, wisdom, experience, skills, powers, and tools are cleared and True is returned to the calling program. Otherwise False is returned to the calling program. This method can be used to determine if the character died during battle. 5. The addTool and addPower methods are used to add another random tool or power to the character (if one is available as defined in the corresponding text files). storyWriter The storyWriter program is used to read in and process the story file. It has a single class called story which has one method called open. It is used simply by creating a storyWriter.story object and then calling the open method. The story class has one mandatory argument which is the name of the file to be read. This file must be stored in the RPG_Gen/share directory. The story file itself is made up of four sections labeled as Intro, Scene, Location, and Plot (see below). <Intro> Introduction lines ... </Intro> <Scene> Text inside here is ignored. <Location> Location lines ... <Plot> Plot lines ... </Plot> </Location> </Scene> There are shortcuts which can be included in the text of each section (except for Scene which is ignored) that allow the RPG Developer to specify where various aspects (such as name, experience, race, etc) are to be displayed for each character as the story is played out. The following is a list of allowed shortcuts.
  • 4. Within the plot line use the &# shortcut to represent your character as it corresponds to the list #. For instance if you use a list avatars = [] that you populate with 10 characters then <5> would be the 6th character since lists begin with 0. Thus think of 0 as your main character. Shortcuts include: &# = character description (name the race specialty) &#.nam = character name (text) &#.rac = character race (text) &#.spe = character specialty (text) &#.sex = character sex (text m,f,a = male, female, asexual) &#.evi = character trait (text evil or good) &#.exp = character experience (number) &#.str = character strength (number) &#.wis = character wisdom (number) &#.skl$ = character skill where $ represents the list number for the skill in question starting with 0 (text) &#.pow$ = character power where $ represents the list number for the skill in question starting with 0 (text) &#.tol$ = character tool where $ represents the list number for the skill in question starting with 0 (text) So to access the 3rd tool for the 6th character the shortcut would be &5.to2 The line “This player is &1.evi.” within the story text file causes storyWriter to replace &1.evi with Evil or Good for character 1. Keep in mind that this uses list processing within Python thus 0 is the actual first character in the list. rpgGenerator The main tool within the RPG Generator tookit is the rpgGenerator itself. It pulls in all the previously mentioned programs and incorporates them into a functioning tool that can then be used to create your game based upon the lib and share files mentioned above. It is made up of three classes (player, opponent, and game). The player class simply inherits the charGen.character class for creating the game's initial player, while the opponent class changes the inheritance slightly by forcing all opponents to be on the opposite of the player. Thus if player is created as “Good”, then all opponents are “Evil”. The game class is used to create the story and populate the shortcuts used in the storyWriter file. It assumes that &0 is always the player and any &# > 0 is an enemy. The following is a very simplistic example for using rpgGenerator.
  • 5. import rpgGenerator fn = 'setup.txt' me = rpgGenerator.player(False) myGame = rpgGenerator.game(me, 4, fn) print 'Characters are:' for i in myGame.characters: print ' %s'%(i.name) print 'Intro:' print myGame.intro print for s in range(0, len(myGame.scenes)): print 'Scene: %i'%s loca = 0 for l in range(0, len(myGame.locations)): sid, location = myGame.locations[l] if sid == s: print 'Location %i'%l print location for p in range(0, len(myGame.plots)): sid2, lid, plot = myGame.plots[p] if sid2 == s and lid == loca: print 'Plot %i'%p print plot loca += 1 First you import rpgGenerator. Then you have to create your initial player and tell it whether it is evil or not (in this case the player is good so all enemies will be evil). Next you have to create your game, by specifying the name of your player object, how many opponents you want to create, (this should match the number used in your story file. It is acceptable to have too many but too few and you will get weird results.), and your story file name. From that point it is up to the RPG Developer how they want their game to flow, but the above example shows how to access the various elements of the story. The following is an example of the output using the default files included with the RPG Generator.
  • 6. Characters are: Einckae Yulemziu Iuoi Goi Yujrei Intro: This is a setup for a story file. It doesn't really do anything. But it does demonstrate the setup of the story file. Scene: 0 Location 0 Coolsville - Einckae the Dwarf Duke is Good Plot 0 I want to do something here. I will display Yulemziu's name. The oponenet Yulemziu is Evil. Plot 1 Now I want to do something else. I can even use multiple lines. Einckae can battle Yulemziu with Knife. Einckae has [] powers while Yulemziu has ['Teleportation'] powers. Location 1 My House Plot 2 Not much happening here... The character has these skills. ['Fight', 'Speak', 'Build', 'Read', 'Ride'] And the first enemy has these tools. ['Shield'] … etc As you can see the tool kit allows for a great deal of flexibility for the RPG Developer to create a tailor made game again and again, without having to rewrite much of the mundane code required for character and plot line development. This allows them to focus on the story itself.