Candlekeep Forum
Candlekeep Forum
Home | Profile | Register | Active Topics | Active Polls | Members | Private Messages | Search | FAQ
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 Forgotten Realms Products
 Forgotten Realms Software
 Programming Knowledge Request
 New Topic  New Poll New Poll
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Gary Dallison
Great Reader

United Kingdom
6351 Posts

Posted - 08 Jan 2014 :  19:44:59  Show Profile Send Gary Dallison a Private Message  Reply with Quote  Delete Topic
I have long tinkered with the idea of learning programming just because I want to and I wanted to combine my two loves; programming and forgotten realms, so a simple ascii computer game seemed the way to go.

I got quite far with a basic game, there was a map and movement and a monster with hit points and an attack method.

However I am struggling on the best way to resolve several things specific to DnD rules (3.5 ish edition) and I was wondering if anyone had any advice on the best way to accomplish things.

Just for the record I am a novice at this programming thing and I am using c++ because its the language I have most books on.


So the problems I have are as follows with some thoughts of mine on a solution but I would love to know if anyone has tried anything like this before and if so how.

1 - Classes: So in 3rd edition you can have as many classes as you want of as many levels as you want. I was thinking of a 2 dimensional vector array holding the class and its level.

2 - Levelling Up: This is a tricky one. I figure I could have a c++ class for classes and every class have a level method which would add a number of special abilities (such as sneak attack) to the character depending on what class level they have reached.
I should note that I have eliminated accumulating xp (its now sacrifice xp like basic dnd) and there are no level based bonuses to attack and saving throws so classes are all about the special abilities they grant.

3 - Feats: This one again I'm thinking of c++ class for feats. Each feat has a Use method or something like that which is called whenever the feat is used and it does its business. Of course on the character these feats would be held in a vector array that would hold the pointer to the use method.

4 - Combat Flow: This is the hard bit. There are so many variables and bits that can interrupt the flow of combat that I am having trouble deciding how to implement it. I was thinking of categorising the various combat actions. So for instance a melee attack would be categorised as "attack", "melee", then get various categories from the weapon used such as "slashing", "critical" etc.
Casting a spell at someone would be "attack", "spell", "Fortitude" or "Reflex" or "Willpower" or "AC".
Then I could either hard code in what to do with certain feats and special abilities, so if a character has improved sunder then do x. Or if I coded it right to iterate through all the use methods on the abilities and feats that matched the various categories and apply their bonuses etc.

5 - Bonuses: In 3rd edition there are bonuses up the Khyber for various random bits, feat bonuses of different types, spell bonuses of different types, class and race bonuses to every primary and secondary statistic on a character. Deciding what to do with them and how to build them is a nightmare.
I have first eliminated the various types. You can have one feat bonus, one class bonus, one race bonus, one magic item bonus, and one spell bonus to any one ability score (highest applies).
However building and keeping track of these bonuses is proving to be a nightmare since feats can be removed, classes and levels removed, templates added and removed, even race changed.
So do I have an add/remove method on every single feat, spell, class etc. Or should I build a check method into the program to check the bonuses on a score are correct every time they do anything.


Oh and if anyone is interested in collaborating on creating a game or learning programming with me then by all means let me know. As I said I'm a novice at this and would love the help. Although I know the 3rd edition rules inside out and have largely reworked them to make them balanced and fairer and sensible, I just need to translate that into computer code. If anyone has figured out how to use classes and inheritance and constructor and destructor and pointers then I take my hat off to you because it boggles my brain.

Forgotten Realms Alternate Dimensions Candlekeep Archive
Forgotten Realms Alternate Dimensions: Issue 1
Forgotten Realms Alternate Dimensions: Issue 2
Forgotten Realms Alternate Dimensions: Issue 3
Forgotten Realms Alternate Dimensions: Issue 4
Forgotten Realms Alternate Dimensions: Issue 5
Forgotten Realms Alternate Dimensions: Issue 6
Forgotten Realms Alternate Dimensions: Issue 7
Forgotten Realms Alternate Dimensions: Issue 8
Forgotten Realms Alternate Dimensions: Issue 9

Alternate Realms Site

Ayrik
Great Reader

Canada
7968 Posts

Posted - 08 Jan 2014 :  22:46:28  Show Profile Send Ayrik a Private Message  Reply with Quote
Your class/level array method seems workable enough, especially since you already understand how you intend to implement it. It has some drawbacks: you‘ll need to make each class/level permutation a separate entry (Fighter 1, Fighter 2, Fighter 3, etc), it won‘t easily allow multiclass combinations (unless these are also explicitly defined), and it may be very cumbersome to enter or modify all your class/level/feat/etc data.

I would suggest using a record data structure, naming each class as part of an array within it, and perhaps using binary set variables to indicate the presence/absence of each feat/etc.

You could use a database engine (Access, dBase, etc) to do this a bit more easily, but exporting such data into actual programs would be more challenging.

This isn‘t really the best forum to ask about tech stuff ... I‘d recommend googling “open source programming“ or “team programming forum“ to find a more suitable venue.

You might be surprised at how many public domain D&D applications are out there, sourcecode and all. Most tend to be written in BASIC or Java, but many are done in various flavours of C. I can almost guarantee you‘ll find a few things very similar to what you‘re trying to design.

[/Ayrik]
Go to Top of Page

The Sage
Procrastinator Most High

Australia
31701 Posts

Posted - 09 Jan 2014 :  02:35:42  Show Profile Send The Sage a Private Message  Reply with Quote
Ayrik pretty much covered what I would have already said, myself.

Two bits I would add, however, is that you might also try Python. I've seem some pretty cool D&D applications written in that particular language. Or even LISP. I know it can be a difficult language to program for, but the actual proglang conceptualisation of lists really does benefit working with a lot of D&D statistical-related information.

Second bit, I'm more than happy to help out where and when I can with this. While I am a proficient programmer by trade, I don't have a lot of experience working with D&D programs written in code. So this would be a learning experience for both of us, I think.

Candlekeep Forums Moderator

Candlekeep - The Library of Forgotten Realms Lore
http://www.candlekeep.com
-- Candlekeep Forum Code of Conduct

Scribe for the Candlekeep Compendium -- Volume IX now available (Oct 2007)

"So Saith Ed" -- the collected Candlekeep replies of Ed Greenwood

Zhoth'ilam Folio -- The Electronic Misadventures of a Rambling Sage
Go to Top of Page

Gary Dallison
Great Reader

United Kingdom
6351 Posts

Posted - 09 Jan 2014 :  08:50:51  Show Profile Send Gary Dallison a Private Message  Reply with Quote
I did have a look at several programming websites but in all honesty there were so many of them and they werent particularly friendly whenever questions were asked (most answers revolved around "you need to go an read the book again" even though i had read the book i was just having trouble getting the books recommendations to work).

So since i knew there were a few programmers on this site and everyone is nice and friendly i thought i would try my luck here.

As i said i am a novice at this, but providing you dont change your mind Sage, if you let me know your email address i can send you what i have so far. Admittedly its very basic and not dnd at all and doesnt include the map class; my one year old daughter wrecked my c drive which had my latest master on (why do children feel compelled to press the reset button 40 times when you arent looking).

Then i got into planning how best to implement the various ideas for DnD and realised that what i needed is a degree in programming in order to try out some of the ideas (although i did get a pointer working and instantiated a class which was a landmark moment for me)

I have read that any game should use a scripting language for data entry, some recommend python, but all the books i have are very vague on how to implement a scripting language within c++ so i have been reduced to hardcoding the bits i want. The ideas would be though that c++ would contain the basic framework and the scripting language would contain the details of what the paladin class does or the dodge feat or a longsword etc.

I have found that DnD doesnt lend itself very well at all to programming, the openness is not however the problem, its the inconsistency in the various systems (attack rolls, DCs, saving throws etc). I think i might have solved those problems though.

Forgotten Realms Alternate Dimensions Candlekeep Archive
Forgotten Realms Alternate Dimensions: Issue 1
Forgotten Realms Alternate Dimensions: Issue 2
Forgotten Realms Alternate Dimensions: Issue 3
Forgotten Realms Alternate Dimensions: Issue 4
Forgotten Realms Alternate Dimensions: Issue 5
Forgotten Realms Alternate Dimensions: Issue 6
Forgotten Realms Alternate Dimensions: Issue 7
Forgotten Realms Alternate Dimensions: Issue 8
Forgotten Realms Alternate Dimensions: Issue 9

Alternate Realms Site
Go to Top of Page

Gary Dallison
Great Reader

United Kingdom
6351 Posts

Posted - 09 Jan 2014 :  08:54:24  Show Profile Send Gary Dallison a Private Message  Reply with Quote
Oh and just in case anyone gets the wrong idea. I'm not looking for someone to program it for me. I started this to improve my own programming knowledge.

If anyone wants to help with the programming bits then thats brilliant but i want to be able to do the programming bits as well. Which might make things slower because i am still figuring out how to use classes properly and make things inherit properties from base classes (its annoying that there seems to be at least two ways of doing these things and each book uses a different way but without any reasoning behind it).

Forgotten Realms Alternate Dimensions Candlekeep Archive
Forgotten Realms Alternate Dimensions: Issue 1
Forgotten Realms Alternate Dimensions: Issue 2
Forgotten Realms Alternate Dimensions: Issue 3
Forgotten Realms Alternate Dimensions: Issue 4
Forgotten Realms Alternate Dimensions: Issue 5
Forgotten Realms Alternate Dimensions: Issue 6
Forgotten Realms Alternate Dimensions: Issue 7
Forgotten Realms Alternate Dimensions: Issue 8
Forgotten Realms Alternate Dimensions: Issue 9

Alternate Realms Site
Go to Top of Page

The Sage
Procrastinator Most High

Australia
31701 Posts

Posted - 09 Jan 2014 :  15:26:31  Show Profile Send The Sage a Private Message  Reply with Quote
You'll find my email address in my profile here at Candlekeep.

Candlekeep Forums Moderator

Candlekeep - The Library of Forgotten Realms Lore
http://www.candlekeep.com
-- Candlekeep Forum Code of Conduct

Scribe for the Candlekeep Compendium -- Volume IX now available (Oct 2007)

"So Saith Ed" -- the collected Candlekeep replies of Ed Greenwood

Zhoth'ilam Folio -- The Electronic Misadventures of a Rambling Sage
Go to Top of Page

Gary Dallison
Great Reader

United Kingdom
6351 Posts

Posted - 09 Jan 2014 :  15:45:09  Show Profile Send Gary Dallison a Private Message  Reply with Quote
Silly me, didnt think to check there. Thankyou Sage, appreciate the offer and look forward to hopefully creating something that works (which would be a new thing for me)

Forgotten Realms Alternate Dimensions Candlekeep Archive
Forgotten Realms Alternate Dimensions: Issue 1
Forgotten Realms Alternate Dimensions: Issue 2
Forgotten Realms Alternate Dimensions: Issue 3
Forgotten Realms Alternate Dimensions: Issue 4
Forgotten Realms Alternate Dimensions: Issue 5
Forgotten Realms Alternate Dimensions: Issue 6
Forgotten Realms Alternate Dimensions: Issue 7
Forgotten Realms Alternate Dimensions: Issue 8
Forgotten Realms Alternate Dimensions: Issue 9

Alternate Realms Site
Go to Top of Page

The Sage
Procrastinator Most High

Australia
31701 Posts

Posted - 10 Jan 2014 :  01:19:16  Show Profile Send The Sage a Private Message  Reply with Quote
You're welcome.

I'm already off to work, so I'll take a look at what you've sent later this evening.

Candlekeep Forums Moderator

Candlekeep - The Library of Forgotten Realms Lore
http://www.candlekeep.com
-- Candlekeep Forum Code of Conduct

Scribe for the Candlekeep Compendium -- Volume IX now available (Oct 2007)

"So Saith Ed" -- the collected Candlekeep replies of Ed Greenwood

Zhoth'ilam Folio -- The Electronic Misadventures of a Rambling Sage
Go to Top of Page

Caolin
Senior Scribe

768 Posts

Posted - 11 Jan 2014 :  08:27:53  Show Profile Send Caolin a Private Message  Reply with Quote
So you've got a very VERY large project on your hands. It's impossible to simply encapsulate all of the DnD rules into a handful of lines of code. I'm not saying you are trying to, but most people don't understand the rabbit hole you fall into when going down this road. Trust me, I thought of this while I was in college and I got quickly overwhelmed.

With that being said, it's a great way to learn programming and a great way to get yourself into game development. My first advice would be to abandon C++. Its not a language for beginners and it's overkill for doing an ascii game. I'd advise taking up Python. It costs you nothing, it's very easy to learn and understand, and you can run your game in a web browser. You still get all of the advantages of object oriented programming. If you want a good intorduction to python I'd check out one of these two sites:

http://www.codecademy.com/
http://www.learnstreet.com/

They both do a very good job of introducing you to programming. The second thing I would do is find some literature on object oriented programming. It will be essential to understand if you seriously want to replicate the DnD rules.

http://www.amazon.com/Object-Oriented-Thought-Process-Edition-Developers/dp/0321861272/ref=sr_1_1?ie=UTF8&qid=1389428546&sr=8-1&keywords=object+oriented+programming

I'm going to keep my advice to that. Just explaining this is it's own rabbit hole. The last thing I'll say is use this project as motivation in your quest to learn how to code. Take it slow and don't get frustrated.
Go to Top of Page

Gary Dallison
Great Reader

United Kingdom
6351 Posts

Posted - 12 Jan 2014 :  15:14:09  Show Profile Send Gary Dallison a Private Message  Reply with Quote
Well I will have a look at python then if thats the recommendation.

Any game with well defined rules should be possible to convert into a computer program. I reckon the problem with dnd especially 3rd edition is that the rules werent well defined or indeed logical in many cases.
Im not afraid of rewriting the rules in fact ive already done so. Spell resistance was a bad rule, spells should have an attack roll like other attacks.
Once the rules are logical and everything is defined in a consistent manner it should just need the code to represent that.

I think if each feat, weapon, special ability, weapon, armour etc were an instantiated object then you can step through an array of those objects and run the method.

So an attack action would determine the base attack bonus then step through the various class abilities and add their modifiers then step through the feats and add theirs then step through any active spells and add those all by running the method of those objects.

At least thats my theory. I have yet to put it into practise and I reckon it would be mammoth like in its complexity but it must be possible.

Forgotten Realms Alternate Dimensions Candlekeep Archive
Forgotten Realms Alternate Dimensions: Issue 1
Forgotten Realms Alternate Dimensions: Issue 2
Forgotten Realms Alternate Dimensions: Issue 3
Forgotten Realms Alternate Dimensions: Issue 4
Forgotten Realms Alternate Dimensions: Issue 5
Forgotten Realms Alternate Dimensions: Issue 6
Forgotten Realms Alternate Dimensions: Issue 7
Forgotten Realms Alternate Dimensions: Issue 8
Forgotten Realms Alternate Dimensions: Issue 9

Alternate Realms Site
Go to Top of Page

Caolin
Senior Scribe

768 Posts

Posted - 12 Jan 2014 :  21:06:09  Show Profile Send Caolin a Private Message  Reply with Quote
It's definitely possible, there are games that prove it. But I would suggest making a very basic game with very basic rules first. Maybe create a game where a fighter with a sword fights an orc with an axe. Break down the logic in order to create your objects and their methods. Most of the objects will have their own objects. Like Character would be the master class with things like Class, Race, Weapons, Attributes, being inherited classes. Then you create objects that have characters fighting each other. A basic back and forth attack defend structure would be good. Once you get a basic frame work you can easily start to build upon it.

The key is not to bite off more than you can chew. You'll quickly get swamped.
Go to Top of Page

Gary Dallison
Great Reader

United Kingdom
6351 Posts

Posted - 13 Jan 2014 :  08:38:42  Show Profile Send Gary Dallison a Private Message  Reply with Quote
That sounds exactly like what i was planning. I initially tried to do it all in one go and you are exactly right it was overwhelming so then i did start again with a simple player with no stats and a simple orc with no stats and then added thinks in from there.

Right now im off to read my python books and convert what i have into python.

Forgotten Realms Alternate Dimensions Candlekeep Archive
Forgotten Realms Alternate Dimensions: Issue 1
Forgotten Realms Alternate Dimensions: Issue 2
Forgotten Realms Alternate Dimensions: Issue 3
Forgotten Realms Alternate Dimensions: Issue 4
Forgotten Realms Alternate Dimensions: Issue 5
Forgotten Realms Alternate Dimensions: Issue 6
Forgotten Realms Alternate Dimensions: Issue 7
Forgotten Realms Alternate Dimensions: Issue 8
Forgotten Realms Alternate Dimensions: Issue 9

Alternate Realms Site
Go to Top of Page

Ayrik
Great Reader

Canada
7968 Posts

Posted - 13 Jan 2014 :  22:40:58  Show Profile Send Ayrik a Private Message  Reply with Quote
Yes, start with the basics, just make it work, no matter how simplistic and ugly. Then add complexity, make sure each piece works. When all the rules seem to work you can shift your focus onto making it pretty.

Same as any other middly-size project. D&D doesn‘t really have an insurmountable number of formal rules. Don‘t try to tackle it all at once unless you‘re confident you have the code savvy, just reduce it to a number of intercompatible simple mini-projects.

[/Ayrik]
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  New Poll New Poll
 Reply to Topic
 Printer Friendly
Jump To:
Candlekeep Forum © 1999-2024 Candlekeep.com Go To Top Of Page
Snitz Forums 2000