RPG element: experience points/levelling up

Get help using Construct 2

Post » Sat Nov 23, 2013 11:42 am

Greetings fellow C2 enthusiasts!

Firstly just want to say hi and introduce myself: HI! Im Luke but call me 'moy' :) i bought C2 a short while ago for personal use, have gone through the jungle, space, and battlefield tutorials, and am thoroughly enjoying the software. I had no idea something like this even existed so i am amazed with it!

Anyway, to the point at hand - From this Ive embarked on a quest to make my own game with Platform x RPG elements. I have most of the mechanics id like to implement planned out and tested but i would like to include some kind of XP/levelling up system and am having trouble trying to figure it out (im trying to get it all figured on paper before putting it into C2).

I guess the bedrock of my question is: are there any tips you guys can give for adding such a feature to my game? or is there a tutorial ive missed that can help with this?

If not dont worry but i just thought id ask :)
Thanks in advance!
moymoymoy
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Sat Nov 23, 2013 11:52 am

You just need some variables friend.

On monster123 killed add 123 to xp.

Experience >=123 set variable level = 2

Level = 2 set variable strength+2

Etc.

Hope you get what I mean:)
Image
Check out our start-up and configure your own helmet in true 3D.
B
44
S
11
G
11
Posts: 1,154
Reputation: 9,988

Post » Sat Nov 23, 2013 12:02 pm

Holy hell thats genius!
I understood it would take variables, i just couldnt get my head around the action/event side of things.
Thank you so much for your enlightenment :)
B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Sat Nov 23, 2013 12:04 pm

It depends on what type of leveling system you need, are you leveling your character as a whole or does each skill have an independent leveling system, are you gaining xp on enemy kill, enemy hit or level complete.

But what it comes down to is the usage of variables and/or arrays/dictionaries. You need to write, mostly using arrays or dictionaries, the xp number for every way you want to be able to gain xp, 10xp for killing enemy A, 50xp for killing boss B, 30xp for solving puzzle C etc.

After that you need to, using events, trigger the specific xp gain and add that number to the xp counter, which can also be recorded in an array, dictionary or a variable.

After the xp counter hits a specific number, your character or skill gains a level.

EDIT: I should type faster, or use easier examples.KFC2013-11-23 12:05:31
B
33
S
12
G
7
Posts: 227
Reputation: 7,582

Post » Sat Nov 23, 2013 12:06 pm

I would track all those sorts of things in the instance variables of an array. So make an array (I suggest you also rename it to something like 'experience'), add the instance variable 'exp', 'level', etc. This is just cleaner than using global variables and the array isn't destroyed between layouts like other objects. Also, if you later decide to add levelling for another character, you can just clone your existing array instead of needing to add more variables.

How to make a comprehensive levelling system is something quite complex, but for just a simple 'exp > 10,000: set level to 2' system, you should have no trouble.

EDIT: Also if using the paid version, create a family for your experience arrays and add the instance variables to the family instead of the array itself. This just allows more options and quicker cleanup in the future.Tobye2013-11-23 12:09:06
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Sat Nov 23, 2013 12:33 pm

Thanks a lot for your suggestions guys, much appreciated :)

Im familiar with arrays in terms of C++ and OOP and with a quick scan of a couple of the array tutorials, i think i could pick it up. I like Beaverlicious's idea of variables as well however.

I think what i'll do is give both ways a go and see what i feel comfortable doing :)

If i knew how to upvote all your comments/suggestions i would do so xD

B
11
S
2
G
1
Posts: 62
Reputation: 1,410

Post » Sat Nov 23, 2013 12:39 pm

[QUOTE=Tobye] I would track all those sorts of things in the instance variables of an array. So make an array (I suggest you also rename it to something like 'experience'), add the instance variable 'exp', 'level', etc. This is just cleaner than using global variables and the array isn't destroyed between layouts like other objects. Also, if you later decide to add levelling for another character, you can just clone your existing array instead of needing to add more variables.[/QUOTE]

I don't really understand why you would use an array, but then use instance variables on it when you could add them to the character instead. That would save some picking.
Although imo a good way to do is (imo) to put the status-array (that contains everything about the character's progress) in the container of the levelable character. So every new levelable character will have his own status-array when he is created, that also gets destroyed when he dies and that is automatically selected, when you pick the character.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Post » Sat Nov 23, 2013 1:03 pm

@mindfaQ - The problem with that is when they die/you change layouts, the experience is lost. By making it an array, it will not be destroyed allowing you to track it throughout the whole game and without causing mess with global variables.

To make it work with multiple characters, you simply create a variable in the array called 'id' and set it the the relevant unit's UID. It does involve 1 extra condition for picking, but is more flexible. Alternatively, you could just add a name variable to the array and reference that.

To me containers are not good for this sort of thing as you can't lose one without the other. If you decide later you want effects that, say, remove a character from play for X seconds, they now lose all their experience. You can make fixes and work-arounds of course, but that just keeps adding to the mess and requires more thought for solutions as these problems arise, instead of always knowing exactly what to do. And obviously if you want to carry experience between layouts, containers simply don't work at all.

To reduce the need for picking, you can also use functions. So character kills enemy: call function 'getExp' with parameters: character.uid, experience amount. Then in that function, you can do all your picking and experience assigning. 1 condition, 1 action, less room for error and more room for improvement.
B
28
S
8
G
5
Posts: 429
Reputation: 7,007

Post » Sat Nov 23, 2013 1:15 pm

You can also use a mathematical function for your experience and stats curve.
Let's say your character just got to level x :
nextLevel (xp required) = ceil(ax^y)

a and y being anything between 0 and +oo you simply set by hand.

You can then plot your xp curve online to instantly see what values it's giving as an output. We're using desmos with my teammate, which is a great free tool available online :
Desmos - online calculatorValerien2013-11-23 13:16:04
B
79
S
22
G
4
Posts: 311
Reputation: 12,814

Post » Sat Nov 23, 2013 1:35 pm

I see, forgot about that.
Visual Novel 'Engine' in 100 Events
if you ever have to choose between buying Construct 2 on scirra.com or on Steam, read this: Review
B
22
S
9
G
1
Posts: 788
Reputation: 3,788

Next

Return to How do I....?

Who is online

Users browsing this forum: dop2000 and 8 guests