Character Generator

Hi,

Sorry, I was away this weekend and spent more time sorting the laptop than I had expected - it is now however, up and running again!

I’ll have some more to share with you later. :slight_smile:

its ok i was away also but i was able to populate the dropdown for the races and classes. congrats on getting your laptop back up.

Thanks, frustrating and expensive but still, back up and running which is the main thing and no loss of data!

Well done on the dropdowns. :slight_smile:

I’ve had to restructure some of the code for a few reasons, nothing major, but I think in due course those enums will be become classes also. I had a bit of a read through the health side of things and could see that there are dependencies on class and I don’t expect this is the only item, but again, for now, still trying to keep things fairly simple so that they are more straight forward to following.

At present, I have a Player GameObject in the scene and after you have created your character using the dice rolling buttons and the race/class selection, a Character scriptable object is created and added to the Player GameObject.

So, if the little list above were numbered, then from top to bottom, 1, 2 and 6 I have something to show you. Health I will probably do later this evening and then I’ll pop all the scripts up for you to have a look at. Catch you in a bit :slight_smile:

Just to add, with the structure at the moment, you should be able to use it for both player and non-player characters, just needs a separate method for effectively triggering all of the dice rolls.

i am working on implementing a leveling system now. should i make one for each class since the leveling up is different for each class.

I’m going to try to add (C#) on the end of any references to the word class I use in our messages where they relate to code rather than the terminology in the game, just for clarity. :slight_smile:

To answer your question, you could do, although typically you want to remove any duplication of code in your classes (C#), looking for commonality and then move that to a base class (C#), which the other classes can then inherit from. As an example, if we created a class (C#) for a Shape, we might have a field (variable) which represents the number of sides the shape has, rather than duplicating that in every shape that we make, it could live in a base class (C#) which our shape could inherit from, for example;

public class Shape
{
    public int sides;
}
public class Square : Shape
{
    // ...
}
public class Triangle : Shape
{

}

The Square and the Triangle classes (C#) above are inheriting from the Shape class (C#) and thus have access to the sides field.

I would consider an air of caution on creating too many initially though, we already know that we will need to implement classes (C#) for the character classes, and where appropriate specific functionality to a character class should really live within its own class (C#).

p.s. I don’t think I have ever used the word “class” so much in my life!
p.p.s health is implmented, and hit die based on class.

Just to make sure I understand ex: I could make a BAB (Base Attack Bonus) class (C#) and have the player classes pull from that as they level up. this is the class info for a barbarian and bard.

//Table: Barbarian
//lvl   bab            fort   rexf  will Special
//1st   +1               +2   +0  +0    Fast movement, rage
//2nd   +2               +3  +0  +0     Rage power, uncanny dodge
//3rd   +3               +3   +1  +1     Trap sense +1
//4th   +4               +4    +1  +1     Rage power
//5th   +5               +4      +1  +1     Improved uncanny dodge
//6th   +6/+1            +5      +2  +2     Rage power, trap sense +2
//7th   +7/+2            +5      +2  +2     Damage reduction 1/—
//8th   +8/+3            +6      +2  +2     Rage power
//9th   +9/+4            +6      +3  +3     Trap sense +3
//10th  +10/+5           +7      +3  +3     Damage reduction 2/—, rage power
//11th  +11/+6/+1        +7      +3  +3     Greater rage
//12th  +12/+7/+2        +8      +4  +4     Rage power, trap sense +4
//13th  +13/+8/+3        +8      +4  +4     Damage reduction 3/—
//14th  +14/+9/+4        +9      +4  +4     Indomitable will, rage power
//15th  +15/+10/+5       +9      +5  +5     Trap sense +5
//16th  +16/+11/+6/+1   +10      +5  +5     Damage reduction 4/—, rage power
//17th  +17/+12/+7/+2   +10      +5  +5     Tireless rage
//18th  +18/+13/+8/+3   +11      +6  +6     Rage power, trap sense +6
//19th  +19/+14/+9/+4   +11      +6  +6     Damage reduction 5/—
//20th  +20/+15/+10/+5  +12      +6  +6     Mighty rage, rage power

//Table: Bard
//lvl   bab            fort   rexf  will Special
//1st   +0               +0   +2   +2   Bardic knowledge, bardic performance, cantrips, countersong, distraction, fascinate, inspire courage +1 
//2nd   +1               +0      +3   +3   Versatile performance, well-versed  
//3rd   +2               +1      +3   +3    Inspire competence +2 
//4th   +3               +1      +4   +4     
//5th   +3               +1      +4   +4    Inspire courage +2, lore master 1/day
//6th   +4               +2      +5   +5     Suggestion, versatile performance
//7th   +5               +2      +5   +5     Inspire competence +3
//8th   +6/+1            +2      +6   +6     Dirge of doom
//9th   +6/+1            +3      +6   +6     Inspire greatness
//10th  +7/+2            +3      +7   +7     Jack-of-all-trades, versatile performance
//11th  +8/+3            +3      +7   +7     Inspire competence +4, inspire courage +3, lore master 2/day
//12th  +9/+4/           +4      +8   +8     Soothing performance
//13th  +10/+5           +4      +8   +8     
//14th  +11/+6/+1        +4      +9   +9     Frightening tune, versatile performance
//15th  +12/+7/+2        +5      +9   +9     Inspire competence +5, inspire heroics
//16th  +12/+7/+2        +5      +10  +10     
//17th  +13/+8/+3        +5      +10  +10    Inspire courage +4, lore master 3/day
//18th  +13/+8/+3        +6      +11  +11    Mass suggestion, versatile performance
//19th  +14/+9/+4        +6      +11  +11    Inspire competence +6
//20th  +15/+10/+5       +6      +12  +12    Deadly performance

//Spells Per Day
//lvl     1st  2nd  3rd  4th  5th  6th        
//1st      1    -    -    -    -    -
//2nd      2    -    -    -    -    - 
//3rd      3    -    -    -    -    -
//4th      3    1    -    -    -    -
//5th      4    2    -    -    -    -
//6th      4    3    -    -    -    -
//7th      4    3    1    -    -    -
//8th      4    4    2    -    -    -
//9th      5    4    3    -    -    -
//10th     5    4    3    1    -    - 
//11th     5    4    4    2    -    -
//12th     5    5    4    3    -    -
//13th     5    5    4    3    1    - 
//14th     5    5    4    4    2    -
//15th     5    5    5    4    3    -
//16th     5    5    5    4    3    1 
//17th     5    5    5    4    4    2 
//18th     5    5    5    5    4    3
//19th     5    5    5    5    5    4
//20th     5    5    5    5    5    5

It would be things which are common that you would effectively put into a base class (C#).

So for example, looking at the Barbarian and Bard tables, a couple of things are common…

  • The number of levels (20)
  • The character class
  • The fort attribute
  • The rexf attribute
  • The will attribute
  • The specials collection

So, you could design a class (C#) to handle all of those but without any data. Then have a specific Barbarian class (C#) which inherits from the base class (C#) and sets the appropriate values.

The reason why this is useful is because if, for example, you have 12 character classes, and within each of those classes (C#) you define all of the above, as soon as someone has the great idea of introducing a “Level 21”, you will need to make your changes across 12 classes (C#). Where-as, using a base class (C#), you can just extend the size of the array / collection accordingly and all of the classes (C#) which inherit from it will see the new level 21, thus you make that change once, not 12 times. You would of course still need to add the specific changes for level 21 to the individual classes, e.g. the +3s and so on, but that is really where you would be reading in from a config file anyway and not having them hard-coded to the classes.

ok that makes since.

1 Like

just wanna check and make sure I’m doing this right

public class Stats {
    public int characterClass;
    public int lvl1;
    public int lvl2;
    public int lvl3;
    public int lvl4;
    public int lvl5;
    public int lvl6;
    public int lvl7;
    public int lvl8;
    public int lvl9;
    public int lvl10;
    public int lvl11;
    public int lvl12;
    public int lvl13;
    public int lvl14;
    public int lvl15;
    public int lvl16;
    public int lvl17;
    public int lvl18;
    public int lvl19;
    public int lvl20;
    public int BAB;
    public int will;
    public int reflex;
    public int fort;
    public int specials;
}
public class Barbarian : Stats
{
  public void levelup()
    {
        lvl1 = BAB + 1;
        lvl2 = BAB + 2;
        lvl3 = BAB + 3;
    }
}

Probably easier to consider using an array or a list rather than the 20 individual ints.


public class Stats : MonoBehaviour
{
    public int characterClass;
    public List<int> level = new List<int>();
    public List<int> levelbab = new List<int>();
    public List<int> levelfort = new List<int>();
    public List<int> levelreflex = new List<int>();
    public List<int> levelwill = new List<int>();
    public List<int> levelspecials = new List<int>();
}

I would look at your data above in the sense of rows and columns.

Each row would be a level. Thus, you would need a container for the items that appear in that row, for example;

public class CharacterExperienceLevel
{
    private int level;    // may not be necessary, but perhaps useful to start with
    private int[] bab;    // the array would allow for the scenarios where you have more than one value
    private int fort;
    private int rexf;
    private int will;    
    private string special;    // this would need more thinking about as there are multiple "things" which are not in scope yet
}

So the above could represent a row, then, you need something to contain all of those rows, this is where a List could be used;

using System.Collections.Generic;

public class CharacterExperienceLevels;  // note the plural
{
    potected List<CharacterExperienceLevel> characterExperienceLevels = new List<CharacterExperienceLevel>;
}

Then you could create your specific CharacterClass version of an experience level by inheriting;

public class BararianExperienceLevels : CharacterExperienceLevels
{
    // .... 
}

and then the Bard;

public class BardExperienceLevels : CharacterExperienceLevels
{
    // ....
}

Each of the specific classes (C#) above would inherit from your base class and as such would have access to the define list.

Within each class you could then have a method to initialise the list, in which you would create a CharacterExperienceLevel (note singular), set its values and add it to the list.

In the above I’ve written the variables as private, I typically use constructors or methods to initialise the classes, but the above was meant as a bit of a guide more than a finalised solution.

I wouldn’t create all 20 levels for each character class by the way, the end goal should really be to be reading this data in from config, and then have a method which iterates through the config file and creates these for you. So you could, for example, just add a couple of experience levels to a couple of the character classes just as a proof of concept and to be able to play with the levelling up mechanic. If you do create all 20 levels for all of the character types, you’ll be spending a lot of time typing and invariably deleting a lot of it later :slight_smile:


Question:

When looking at this Character Sheet, as a player of this game, would you use the Ability Modifier box for the Race Bonus when creating your character, or is that just added to the original base (rolled) value and put in the Ability Score?

No Its added to the rolled base stats. Then the ablity modifiers are adjusted. By total stat -10 / 2

Ah, I see, that’s not on the main Character Creation Outline document, but I’ve found it now. This was what you were referring to previously, got it. Thanks :slight_smile:

no thank you so much.

I’ve not forgotten I mentioned I would post up the code last night, it ended up being a fairly busy evening, so just trying to finish off a few bits, hopefully tonight/tomorrow.

I’ve replicated your UI for testing purposes, although it doesn’t look as nice :slight_smile:

speaking of looking nice when i play it in max screen everything is so close together.

Anchor presets on the rect transforms should probably help with that.

Also, typo in “Strength”, and “Constitution” is in a slightly small font.

I wouldn’t worry too much about appearance at this stage though, that is a feature in itself! :slight_smile:

that worked now the races and classes can give a description of what they are.

1 Like

I have the following now, which I think completes that little list above;

  • population of races from existing enums to dropdown menu
  • population of classes from existing enums to dropdown menu
  • ability score - based on roll of 4D6, losing the lowest value
  • ability bonus - based on race
  • ability modifier - based on ability score
  • hit die - based on character class selection (assumes new character creation, e.g. level 1)
  • base health - based hit die (assumes new character creation, e.g. level 1)
  • level - placeholder variable for now
  • experience - placeholder variable for now
  • Creation of instance of Character class (C#) with data from UI
  • Character class populated within Player GameObject

Demo;

1 Like

Privacy & Terms