RPG element: experience points/levelling up

Get help using Construct 2

Post » Sat Nov 23, 2013 7:16 pm

I ended up writing a tutorial about this if you're interested.

All questions or comments are welcome, it's my first tutorial and I'd like to see if anyone finds it useful/has problems with it.[Tobye2013-11-23 19:19:17
B
28
S
8
G
5
Posts: 429
Reputation: 6,997

Post » Sat Nov 23, 2013 7:56 pm

https://www.scirra.com/images/articles/createarray_3.png

that won't work. It will always trigger if you don't destroy the default array (meaning you can get more than 1 array with the same name). If you destroy the array it will never run, because it doesn't properly check whether there is no array with the name in the game yet.

Instead use something like this:

on created
- localvar = 0
- array: id = player.name: set localvar = array.pickedcount
- if localvar = 0: create the array and set the namemindfaQ2013-11-23 19:57:36
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: 787
Reputation: 3,786

Post » Sat Nov 23, 2013 8:29 pm

@mindfaQ - oops! Thanks! I fixed it (name = player name (no action) followed by else: create array etc.).

Tested it with a few different players at once and it works fine.
B
28
S
8
G
5
Posts: 429
Reputation: 6,997

Post » Sun Nov 24, 2013 12:02 am

Oh yeah now I know what was on the tip of my tongue when I was writing this ^^.
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: 787
Reputation: 3,786

Post » Sun Nov 24, 2013 1:09 am

could you help me understand what is happening here? ceil(ax^y)megatronx2013-11-24 01:09:36
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
85
S
27
G
21
Posts: 1,969
Reputation: 19,167

Post » Sun Nov 24, 2013 1:55 am

@megatronx: x would be the level, a and y numbers, ^ stands for exponent, ceil would round the result up and the result would be the total exp needed for a level. It is basically exponential growth.
An example function could be ceil(2*level^1.5).

Basically it is a way to calculate the exp requirements for every level by a simple formula. Normally I would probably use a polynome for this, for example ax^4+bx^2+cx+d. But in the end it depends on how you scale the exp of you enemies in the game as well.

You could start calculating the time needed for a next level if you are constantly fighting creeps with a formula like to this:
time = time_needed_to_kill_enemy/exp_per_enemy * exp_needed for level
Tune the time it takes to reach the next level like you want, rule of thumb is ofc that it takes longer the higher your level is.

You can also check how long it takes to level up in easier areas of the game with the formula. You probably don't want the easier areas to give you more exp over time just because you can kill monsters much quicker there. To prevent this you can also add a malus if the level of your enemies differs from your level. It is like that in Diablo: if the monster level is more than 5 levels (iirc) below your character's level you get a smaller percentage of the total exp.mindfaQ2013-11-24 01:56:54
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: 787
Reputation: 3,786

Post » Sun Nov 24, 2013 2:18 am

And what numbers would be under LEVEL? Would it be current XP or would it be just level number ( for example number 4 ) ?
My professional Royalty Free Music at Scirra Assets Store
--------------------------------
Specs: i5 2500, 16gb of ram, gtx 770, win 7, Focusrite Scarlett 8i6, Mackie mr8mk2, Alesis 320, browsing the net on chrome.
B
85
S
27
G
21
Posts: 1,969
Reputation: 19,167

Post » Sun Nov 24, 2013 2:32 am

4
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: 787
Reputation: 3,786

Post » Sun Nov 24, 2013 12:12 pm

x in the example is indeed the current level of your character.
xpForNextLevel = floor or ceil(factor * playerLevel ^ exponent)

Cheers,
Nathan
B
77
S
22
G
4
Posts: 311
Reputation: 12,634

Post » Sun Nov 24, 2013 12:45 pm

@mindfaQ
@Valerien

I've only just got around to looking into what you guys are talking about, and thanks, I really need to learn this stuff. My maths is weak, but I enjoy it!
B
28
S
8
G
5
Posts: 429
Reputation: 6,997

PreviousNext

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 12 guests