Levelling System by Pinohkio w/ LadyLexUK

Have something important that other people might find usefull? Well, drop it here and help others!
User avatar
LucidStew
Level 3
Level 3
Posts: 180

Levelling System by Pinohkio w/ LadyLexUK

Post#1 » Mon Aug 15, 2016 5:57 pm

moved over from the projectspark.com forums

For this tutorial we will be creating a levelling system based on XP.
XP can be gained by killing goblins or eating apples.
As you level up the amount of XP you need to get to the next level increases.
The amount of damage you inflict on your enemies is also increased as you level up.
The XP is displayed on a meter, and your damage level is also shown

In your player brain
First we set up our number variables.
Code:

WHEN [once] DO [numvar:xp total][=][0] // this is the amount of xp our player has
WHEN [once] DO [numvar:xp to level][=][10] //this is how much xp he needs to level up
WHEN [once] DO [numvar:damage output][=]10] // this how much health damage he will inflict
WHEN [once] DO [numvar:level][=][1] //this is his current level number


Then we add the Kode that says what happens when you have enough xp to level up
Code:

WHEN [numvar:xp total][>=][numvar:xp to level] // when your player has enough or more xp to level up
...WHEN [started to] DO [numvar:level][increment by][1] // add 1 to the level number
.../...WHEN DO [numvar:xp total][=][numvar:xp total][-][numvar:xp to level] // set the xp meter back to 0 plus any extra xp
.../...WHEN DO [play fx][Level up Champion][on][me] // play an effect when you level up
...WHEN DO [numvar:damage output][=][(][round][numvar:damage output][multiplied by][1.2][)] // increases the amount of damage the player can inflict


Change the default melee line to
Code:

WHEN [x][pressed] DO [attack][with damage][numvar:damage output]


Add some display options
Code:

WHEN DO [display meter][gallery:xp meter][numvar:xp total][max][numvar:xp to level][screen top left]
WHEN DO [display][text:Level: ][+][numvar:level][screen top left][HUD stack left]
WHEN DO [display][icon:Melee][screen top right]
WHEN DO [display][text:<size:40>][numvar:damage output][screen top right][no HUD stack]


Now all you need to add is your Kode to increase xp.

In the apples or other interactable object that gives you xp

Code:

WHEN [interacted] DO
...WHEN DO [it][numvar:xp total][increment by][1] // or however many xp an apple is worth

In the goblins
Code:

WHEN [hit by attack] DO [my attacker][=][it]
...WHEN [started to][is dead] DO [my attacker][numvar:xp total][increment by][5]


And there is your simple levelling system. You can give xp to your player for completing tasks, entering a special area, collecting objects or anything really. You can use the level number to affect the way he looks, or what weapon he has equipped, or whether he can enter a certain area. You can also make enemies more dangerous depending on your players level, or maybe spawn different types of enemy based on level. Experimentation is the key here.
End of line.

Return to “Tutorials and guides”

Who is online

Users browsing this forum: No registered users and 2 guests

cron