How do I create a character class system?

0 favourites
  • 9 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hi Guys,

    I am a natural Level Designer in Game Development and I am learning programming (Also the programming that C2 uses) and I am created a game that will have some Character Classes (Summoner, Dark Knight, Assassin, Mage) and was wondering how I would start this process.

    I understand some knowledge on Variables etc and was wondering how I would start developing a system for different stats, sprites and moves for each character.

    Thank You!

  • I think the question is a bit too wide to give a direct answer to, but I'll try.

    Using different sprites for different characters would automatically work, even if you are planning to use one sprite to put all movement events on.

    Just pin the character sprite to the movement sprite and use the character for the interaction and animation.

    In the case of stats, a lot can be done by giving the character instance variables, but sometimes using the dictionary object or the array object is more usefull, depends on your needs and ofcourse your personal preferences.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I have been tinkering with an RPG myself and my class system is likely not the most efficient but here are some ways I handle it.

    Start with Global Variable for classes (can be either 0-5 and each number is a class or choose a text variable and store the name of the class). Then pull the class as a conditional variable to modify certain events, so a Dragon-Shaman may have fire immunity so a firey floor tile will have a condition of:

    If <Player> collides with <Fire>
    && Global Variable 'Class' does NOT = "DragonShaman"
    
    Global Variable <Health> reduce 5[/code:3308ketm]
    or maybe they are a fighter class that gives a damage reduction so you can have a damage calculation of this:
    
    [code:3308ketm]Health Lost = <Monster Damage> + <Monster Strength> - <Damage Reduction>
    
    If Class == "Fighter" than Damage Reduction = '5'
    else '0' [/code:3308ketm]
    Sprites can also be changed via having only one player sprite on the layout and then having multiple different animations loaded within it. So when you double click on the sprite and open it up you will see an animation pane (usually with only one animation called "Default"). You can then make multiple animations, one for each class, and upload a different sprite sheet for each one before adding an event that switches the currently chosen animation to the correct one. 
    
    However this may get a bit bloated as you will then have several move left animations (one for each class) and several move right animations. Although as LittleStain says above there are likely far more better ways such as arrays and such.
  • Thank You for the replies everyone, Really appreciate it

    Games like a Roguelike so top down but want different classes for different skills.

  • The easiest way to do this is through the creation of arrays and the use of dynamic functions. This will help to reduce the amount of code you'll need to implement, as well as making it easier to add/remove classes or skills. I'm presuming some foreknowledge of arrays and functions on your part. If you don't know a lot about them, check out some of the tutorials or the manual, as they give fairly good overviews of the concepts.

    First, you should establish the arrays that you want to use outside of C2. Editing them by hand this way does require a few more lines of code than normal, but it's far easier than trying to edit them via C2 directly. In this example, there will only be one array, though it's up to you how much you want to subdivide the arrays up.

    The leftmost column is entirely for the benefit of the editor. In actual scripts, it won't be referenced at all. The rightmost one (and any columns after that) contain the data for each class. This involves any stats that you might want to have (such as BaseDefense, BaseAttack, etc.), as well as any skills that a particular class will have.

    The arrays should be saved as .CSV files, which should then be added to your project as project files. I use rexrainbow's CSV2Array plugin (which you can find with a quick Google search) in order to "inject" the data from the .CSV files into an Array object. The method I use is mostly meant to make the injecting of multiple arrays easier, but it's not necessary if you only have a few of them. (It's a bit of a longer explanation, but I can show you an example, if you want.) The important thing is to get the data into an Array, which can be done by requesting the .CSV file using AJAX, checking for when that specific request has finished, and then injecting the data into an Array object using the CSV2Array plugin's features.

    The second step I would do is to set up a separate Array object that will store all of the character's data after they select a class. Set it to the same height as the Array object that contains all of the class information (in the case of my example, to 11). When the player selects a class, you can then copy the basic class data from the class array to the character stat array, like so:

    (Sorry that this got a bit cut off - just check the direct image link to see the full script.)

    In this example script, "MonsterSheet" is the name of the array that contains my class data (ignore the name - just pulling it from a script I already had set up), while "CharacterSheet" is the Array object that I'm injecting the data from MonsterSheet into. The first parameter in this function (the Function.Param(0) call) contains the string reference from my MonsterSheet array. So, if the player selects the Fighter class in the menu screen, you would call the "SetClass" function, with Parameter 0 as "Fighter". The script will look up the x-index in the MonsterSheet array that has "Fighter," and all of the data from that column will be put into the CharacterSheet array.

    You can then use basic scripts and functions to reference or change the data from the CharacterSheet array. If, for example, you have it so that the player character uses their first skill (Skill1 in the array) when they press "1" on the keyboard, you can simply have the script call up a function that references the CharacterSheet, like so:

    This will then, in the case of our example, automatically run the function named Skill_PowerBlow. The main advantage of this array method is that you can very easily move skills around (such as making the player get them at a different level) without having to also move the code around much. Similarly, if you end up patching your game at all, it's much easier for games that are already in-progress to adjust, since they simply have to read from the new array and make adjustments accordingly. This method is also much easier to use when trying to apply things like status effects. When using variables, I had to create individual functions for every status effect that I wanted to apply, whereas, when using an array, it only requires a small handful of functions for applying/stripping status effects.

  • Wow, Thank you so much for the time you have put into that!, I will look up Arrays today properly I have some knowledge but not fully.

    Thank You for all the replies! I am grateful

  • external arrays work the best.

    you define them and load into c2 and that's pretty much it. ancillary said it all

  • Where would I put my external sheets? I am guessing these are done in Excel and saved under a certain file, I have been looking at some of the documentation, If I was to create a project where would I save the files??

  • hey sorry about this necro but how is this process is done ? And what external array stat building program are we talking about and can you answer that question EXPFall had ?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)