How do I create a character class system?

Get help using Construct 2

Post » Thu Apr 09, 2015 2:24 pm

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!
B
4
S
1
Posts: 56
Reputation: 464

Post » Thu Apr 09, 2015 3:02 pm

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.
I told my dentist I had trouble with my teeth and asked her to fix it without looking in my mouth..
B
54
S
16
G
8
Posts: 6,160
Reputation: 19,775

Post » Thu Apr 09, 2015 3:04 pm

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:
Code: Select all
If <Player> collides with <Fire>
&& Global Variable 'Class' does NOT = "DragonShaman"

Global Variable <Health> reduce 5

or maybe they are a fighter class that gives a damage reduction so you can have a damage calculation of this:

Code: Select all
Health Lost = <Monster Damage> + <Monster Strength> - <Damage Reduction>

If Class == "Fighter" than Damage Reduction = '5'
else '0'

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.
The Aurora Borealis? At this time of year? At this time of day? In this part of the country? Localized entirely within your kitchen?
B
11
S
2
Posts: 16
Reputation: 638

Post » Thu Apr 09, 2015 9:52 pm

Thank You for the replies everyone, Really appreciate it :)

Games like a Roguelike so top down but want different classes for different skills.
B
4
S
1
Posts: 56
Reputation: 464

Post » Fri Apr 10, 2015 2:43 am

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.

Image

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:

Image

(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:

Image

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.
B
5
Posts: 13
Reputation: 251

Post » Fri Apr 10, 2015 8:50 am

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 :D
B
4
S
1
Posts: 56
Reputation: 464

Post » Fri Apr 10, 2015 11:33 pm

external arrays work the best.
you define them and load into c2 and that's pretty much it. ancillary said it all :)
Sea Monsters template - Isometric
Also includes 40 pages PDF of optimizations and "how-to" for your games, and how the "sea monsters" template was built. Follow link for details :)

sea-monsters-templates-and-assets_t162705
B
42
S
14
G
12
Posts: 624
Reputation: 9,421

Post » Wed Apr 22, 2015 9:17 am

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??
B
4
S
1
Posts: 56
Reputation: 464

Post » Wed Mar 09, 2016 8:28 pm

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 ?
B
52
S
24
G
6
Posts: 391
Reputation: 7,845


Return to How do I....?

Who is online

Users browsing this forum: brunopalermo, marcinkowski, Rhindon, Shenkai the ssj and 19 guests