April 25, 2024, 06:10:53 PM

News:

IonicWind Snippit Manager 2.xx Released!  Install it on a memory stick and take it with you!  With or without IWBasic!


Generic RPG Class Information - Character Definition

Started by J B Wood (Zumwalt), April 09, 2007, 01:59:29 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

J B Wood (Zumwalt)

April 09, 2007, 01:59:29 PM Last Edit: April 10, 2007, 08:31:22 AM by Jonathan (zumwalt) Wood
I have seen from time to time, people jumping into many forums and saying "I am making my very own MMORPG"... Great, so now what?
Should everyone start with "What code do you think I need to write first?"
Man I hate that question, turns me off on any forum and I find my way to a rock to crawl under.

Basic brainstorm for character developement.

What I have done in this first link, is to do a fast brainstorm layout for a basic character class.
Yea, my idea of "basic" is beyond basic, but, on the first page is the layout that any new programmer needs to understand before starting there own RPG style game.
This is just one component of the game, the character class.

Every single element steming from the core center is a class, which consits of Inventory, Weapon, Armor, Stats, Elements, Tradeskills and a very important Base.
Each of those elements from the tree, have child classes within them.
Inventory being the odd ball in the image, since it technically only contains 3 classes within it.
Purse, Slot and Tradeskill.

Tradeskill in the inventory would be the container that holds your tradeskill objects, not the tradeskills themself.
All of these sub classes could further be broken down into more elaborate sub classes, but I'll keep this simple for now.
What I have attempted to supply is a skeleton stucture in this first phase of development, so that everyone who is interested in this type of game architecture could see what a single character class looks like.

So, to recap for this initial post, brainstorm using some tool like Visio, or even pen / paper, to get a good feal as to what touches what and why they are connected.
In my next article, I'll be talking about class discovery and how you actually change the picture into words.
For those with Visio 2003, I have attached my Visio of this diagram.

J B Wood (Zumwalt)

Now, we build the outer skeleton based on our diagram, mind you, this is the basic skeleton structure. The idea is to now see if everything will 'fit' into place. So we build our source and include basic files into the skeleton mix, making sure that our character class inherits from our Base class.


J B Wood (Zumwalt)

April 09, 2007, 07:47:06 PM #2 Last Edit: April 09, 2007, 07:50:57 PM by Jonathan (zumwalt) Wood
Time for the exploration, now that we know what a basic skeleton structure would look like, just throw in a few debug commands, slap in some testing initializers, and compile in debug mode with a debug run.

In this version, we have simply initialized the core character class, which of course shows our base has been triggered for its default constructor, now, looking at the member classes, we test each in turn inside the character class. So in discovery, we learn that our base class is properly inherited, our class members are proprely instansiated, so in all aspects, our basic character class is now ready for us to start populating it with code to do some more work.

One thing I have also added to the base class would be an enumerator for our status and a Core structure, which looks simple enough and similar to a database table that would house our characters main information.

If all goes well, what it should now look like is this :

Starting debug session...
Loading DLL: ntdll.dll
Loading DLL: C:\WINDOWS\system32\kernel32.dll
Initialzing Game
Base Initialized
Character Initialized
KeyElements Initialized
Inventory Initialized
Weapons Initialized
TradeSkills initialized
Stats initialized
The program 'C:\Program Files\Aurora\projects\RPG\RPG.exe' exited with code: 0

J B Wood (Zumwalt)

April 10, 2007, 08:11:49 AM #3 Last Edit: April 10, 2007, 08:28:25 AM by Jonathan (zumwalt) Wood
Now, lets start to slowely build up our individual classes with there subclass members. Starting off with the Inventory class, it has 1 child class of Conatainers, this class will be used with 2 direct constructs and 1 pointerlist. In the end, we will have 5 total conatiner objects for our bags, 1 for our purse and 1 for our tradeskills, leaving 7 total container objects that get created.

The uniquenes of the code is that 2 are directly created container objects (purse and tradeskills) and 5 are held in the pointer list, so the cleanup is different between the 2 directly created container objects vs the 5 that are held in the pointer list. When we destroy the objects in the pointer list, we do not see the destructor purge of each individual object destroyed in the list, but we do see the 2 destructor calls for the ones directly created.

I have also added in destructor call debug printouts so that you can visually see what is happening behind the scene. I have also added in the Amorr constructor source, forgot that in the last build.

What you should understand from this, is that we have classes nested in classes which is created from another class, so we are now 3 classes deep. You can have a virtual endless level of classes. I am also starting to move the destructor into a virtual destructor which we will get into later for the difference between virtual and non-virtual.


Your output in your debug window should look something like this:
Starting debug session...

Initialzing Game
Base Initialized
Character Initialized
KeyElements Initialized
Weapons Initialized
TradeSkills initialized
Stats initialized
Armor Initialized
Container Initialized
Container Initialized
Inventory Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
KeyElements De-Initialized
Weapons De-Initialized
TradeSkills De-Initialized
Stats De-Initialized
Armor De-Initialized
Inventory De-Initialized
Inventory container list De-Initialized
Container De-Initialized
Container De-Initialized
The program 'C:\Program Files\Aurora\projects\RPG\RPG.exe' exited with code: 0

J B Wood (Zumwalt)

April 11, 2007, 07:10:29 AM #4 Last Edit: April 11, 2007, 07:12:31 AM by Jonathan (zumwalt) Wood
Our next set of classes that we define will now expand the Weapons class to include the classes attached to it in the diagram.
These include Primary, Secondary, Shield, Ammo, and Ranged classes. After we create the classes just like we did for all the other classes, we then update the Weapons.inc file to include the #include to point to each of the new classes inc files, our project is expanded to include there src files in the project and lastly, we update our weapons class to include a new instance of each of the weapon classes that are new.

When Weapons gets instansiated, it then in turn, instansiates a new instance of each of the sub classes for Primary, Secondary, Shield, Ammo, and Ranged. Now, I know what you are thinking, a Shield isn't a weapon, well, it takes damage and can deal damage, the only difference between a shield and a sword is its size. Ever get hit over the head with a shield with blunt force?

Ammo goes along with the ranged weapon, so why is it not attached to the ranged? Why not in deed, there are two different ways to handle ammo, in my diagram, ammo is a subclass of weapon, this allows you to have ammo individualy without a weaopn, or you can have ranged inherit ammo. In the code, just for fun, I have ranged inherit ammo, and since ammo is its own class, we can instansiate it by itself later if we need to.

So now our weapons class and its child classes are defined.
Once again, a debug compile and run as debug will show in the debug window, our desired results:

Starting debug session...

Initialzing Game
Base Initialized
Character Initialized
KeyElements Initialized
Weapons-Primary Initialized
Weapons-Secondary Initialized
Weapons-Shield Initialized
Weapons-Ammo Initialized
Weapons-Ranged Initialized
Weapons Initialized
TradeSkills initialized
Stats initialized
Armor Initialized
Container Initialized
Container Initialized
Inventory Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
KeyElements De-Initialized
Weapons De-Initialized
Weapons-Primary De-Initialized
Weapons-Secondary De-Initialized
Weapons-Shield De-Initialized
Weapons-Ranged De-Initialized
Weapons-Ammo De-Initialized
TradeSkills De-Initialized
Stats De-Initialized
Armor De-Initialized
Inventory De-Initialized
Inventory container list De-Initialized
Container De-Initialized
Container De-Initialized
The program 'C:\Program Files\Aurora\projects\RPG\RPG.exe' exited with code: 0

J B Wood (Zumwalt)

We are now over the half way point of building the full blown class skeleton. Today, we have added to the project the entire Tradeskill class, this means our Character class now contains the skeleton structure for both Weapon Crafting and Armor Crafting. Each of those two classes are member objects to the Tradeskills, these two in turn have there own child objects which are the different items that can get crafted. One thing to note that I have not gotten into yet, and once I get done with the full blown class skeleton model in code for you, will be the base classes that go along with each and every linked set of classes.

Just like the character inheriting its base class, every blocked class in the diagram (as in, contained in a block via the diagram) would infact have base classes that are helper classes to all of the contained objects, where they would all (within there block) inherit from that base. What would be in it? Could you envision some items that would be in common by looking at each blocked class set? Think about this for a while. Maybe you can go ahead and write your own base class and attach it to each child class within a superclass object.

This will catch you up to the tradeskills construction (or construct since its only the outer hull still)
(NOTE: if anyone is having problems compiling or understanding how to compile this project, let me know via PM)
Were over the hump now, only 3 child classes of Character remain, within them we have a total of 20 member classes...

I have detailed the output just a little more, so this is what you should see from a debug execution:

Starting debug session...

+-----------------------+
|    Initialzing Game   |
+-----------------------+
+-----------------------+
|  Character  Creation  |
+-----------------------+
KeyElements Initialized
Weapons-Primary Initialized
Weapons-Secondary Initialized
Weapons-Shield Initialized
Weapons-Ammo Initialized
Weapons-Ranged Initialized
Weapons Initialized
TradeSkills-Armor Crafting-CraftPlate initialized
TradeSkills-Armor Crafting-CraftChain initialized
TradeSkills-Armor Crafting-CraftLeather initialized
TradeSkills-Armor Crafting-CraftCloth initialized
TradeSkills-Armor Crafting-CraftShields initialized
TradeSkills-Armor Crafting initialized
TradeSkills-Weapon Crafting-CraftBlades initialized
TradeSkills-Weapon Crafting-CraftBlunt initialized
TradeSkills-Weapon Crafting-CraftRanged initialized
TradeSkills-Weapon Crafting initialized
TradeSkills initialized
Stats initialized
Armor Initialized
Container Initialized
Container Initialized
Inventory Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
Base Initialized
+-----------------------+
|    Terminating Game   |
+-----------------------+
+-----------------------+
| Character Termination |
+-----------------------+
Base De-Initialized
KeyElements De-Initialized
Weapons De-Initialized
Weapons-Primary De-Initialized
Weapons-Secondary De-Initialized
Weapons-Shield De-Initialized
Weapons-Ranged De-Initialized
Weapons-Ammo De-Initialized
TradeSkills De-Initialized
TradeSkills-Armor Crafting De-Initialized
TradeSkills-Armor Crafting-CraftPlate De-Initialized
TradeSkills-Armor Crafting-CraftChain De-Initialized
TradeSkills-Armor Crafting-CraftLeather De-Initialized
TradeSkills-Armor Crafting-CraftCloth De-Initialized
TradeSkills-Armor Crafting-CraftShields De-Initialized
TradeSkills-Weapon Crafting De-Initialized
TradeSkills-Weapon Crafting-CraftBlades De-Initialized
TradeSkills-Weapon Crafting-CraftBlunt De-Initialized
TradeSkills-Weapon Crafting-CraftRanged De-Initialized
Stats De-Initialized
Armor De-Initialized
Inventory De-Initialized
Inventory container list De-Initialized
Container De-Initialized
Container De-Initialized
The program 'C:\Program Files\Aurora\projects\RPG\RPG.exe' exited with code: 0

J B Wood (Zumwalt)

We finally made it, our initial skeleton structure is done and it matches our brainstorm diagram to a T.
This final zip has in it all src and inc files along with the project file that makes it all come together.
This is a template that can be expanded on to build up a solid character class.
There is enough information within the entire structure, to help you begin working on your character development model.

A few of you are probably wondering why I have stats and elements as classes instead of variables within the base class, this is because you can expand on them in a way that allows you to create a base class with methods that will do math operations for you. Each class could contain a value for each stat, or a definition for the value, the base class could have methods like AddTo, SubtractFrom, etc that would be shared amongst all the stats.

This initial run works you through brainstorming one element of a game, to starting each class object build and testing the results, through to a full skeleton model of the idea. This will also give you a general idea as to how much work would go into a single component of a game. The nice thing about this template, is that you can use it with modifications for FPS style games, you can also copy the template and modify it to work for other bypeds, quadrapeds, or any other type of animal class or monster class.

Just by implimenting some of these classes into other classes, when you change the base, all classes will get updated dynamically on the next build, very useful.

Here would be your current results if compiled as debug and ran under debug, all of our items in the diagram should show up in this list somewhere.

Starting debug session...
+-----------------------+
|    Initialzing Game   |
+-----------------------+
+-----------------------+
|  Character  Creation  |
+-----------------------+
KeyElements-Initiative Initialized
KeyElements-Speed Initialized
KeyElements-AttackDMG Initialized
KeyElements-ArmorClass Initialized
KeyElements-HitPoints Initialized
KeyElements-Mana Initialized
KeyElements Initialized
Weapons-Primary Initialized
Weapons-Secondary Initialized
Weapons-Shield Initialized
Weapons-Ammo Initialized
Weapons-Ranged Initialized
Weapons Initialized
TradeSkills-Armor Crafting-CraftPlate initialized
TradeSkills-Armor Crafting-CraftChain initialized
TradeSkills-Armor Crafting-CraftLeather initialized
TradeSkills-Armor Crafting-CraftCloth initialized
TradeSkills-Armor Crafting-CraftShields initialized
TradeSkills-Armor Crafting initialized
TradeSkills-Weapon Crafting-CraftBlades initialized
TradeSkills-Weapon Crafting-CraftBlunt initialized
TradeSkills-Weapon Crafting-CraftRanged initialized
TradeSkills-Weapon Crafting initialized
TradeSkills initialized
Stats-StatsStrength initialized
Stats-StatsDexterity initialized
Stats-StatsConstitution initialized
Stats-StatsIntelligence initialized
Stats-StatsWisdom initialized
Stats-StatsCharisma initialized
Stats initialized
Armor-ArmorHead Initialized
Armor-ArmorChest Initialized
Armor-ArmorWaste Initialized
Armor-ArmorLegs Initialized
Armor-ArmorArms Initialized
Armor-ArmorWrists Initialized
Armor-ArmorGloves Initialized
Armor-ArmorRings Initialized
Armor Initialized
Container Initialized
Container Initialized
Inventory Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
Container Initialized
Base Initialized
+-----------------------+
|    Terminating Game   |
+-----------------------+
+-----------------------+
| Character Termination |
+-----------------------+
Base De-Initialized
KeyElements De-Initialized
KeyElements-Initiative De-Initialized
KeyElements-Speed De-Initialized
KeyElements-AttackDMG De-Initialized
KeyElements-ArmorClass De-Initialized
KeyElements-HitPoints De-Initialized
KeyElements-Mana De-Initialized
Weapons De-Initialized
Weapons-Primary De-Initialized
Weapons-Secondary De-Initialized
Weapons-Shield De-Initialized
Weapons-Ranged De-Initialized
Weapons-Ammo De-Initialized
TradeSkills De-Initialized
TradeSkills-Armor Crafting De-Initialized
TradeSkills-Armor Crafting-CraftPlate De-Initialized
TradeSkills-Armor Crafting-CraftChain De-Initialized
TradeSkills-Armor Crafting-CraftLeather De-Initialized
TradeSkills-Armor Crafting-CraftCloth De-Initialized
TradeSkills-Armor Crafting-CraftShields De-Initialized
TradeSkills-Weapon Crafting De-Initialized
TradeSkills-Weapon Crafting-CraftBlades De-Initialized
TradeSkills-Weapon Crafting-CraftBlunt De-Initialized
TradeSkills-Weapon Crafting-CraftRanged De-Initialized
Stats De-Initialized
Stats-StatsStrength De-Initialized
Stats-StatsDexterity De-Initialized
Stats-StatsConstitution De-Initialized
Stats-StatsIntelligence De-Initialized
Stats-StatsWisdom De-Initialized
Stats-StatsCharisma De-Initialized
Armor De-Initialized
Armor-ArmorHead De-Initialized
Armor-ArmorChest De-Initialized
Armor-ArmorWaste De-Initialized
Armor-ArmorLegs De-Initialized
Armor-ArmorArms De-Initialized
Armor-ArmorWrists De-Initialized
Armor-ArmorGloves De-Initialized
Armor-ArmorRings De-Initialized
Inventory De-Initialized
Inventory container list De-Initialized
Container De-Initialized
Container De-Initialized
The program 'C:\Program Files\Aurora\projects\RPG\RPG.exe' exited with code: 0

pistol350

Great Job Jonathan! ;)
Thanks for sharing your work.
I am sure one mate out there will soon create something out of it.
As for me,i am still in that learning process to understand each steps of that class. ;D
Regards,

Peter B.

J B Wood (Zumwalt)

Let me know if you (or anyone for that matter) have any questions about it, or how to expand it.
This is a skeleton structure, you get to 'fill in the blanks' as to what you want each subclass to do.
A few things could be added to the base class (or as I stated earlier, a base class that all the sub classes of each 'object' could hold) to include an image id, so that you could look at that inherited image id then load from a database if you desire.
I just hope it comes in handy to understand both inheritance and class instansiation.