My Leveling System

Hello guys, this topic is related to my last topic Any ideas on why the leveling system not working?.


In the last topic, I was asking why the leveling system is not working, and the one I want is that in each level progress (level +1), the exp requirement to get to the next level also increases.

The one I make is just the (basic?) leveling system.

I was hoping that this will help everyone who wants a leveling system :v:.

And here is the result I’ve worked for the past 24 hours.


Full Code
startup.txt

*create level 1
*create exp 0
*create plusexp 0
*create exprange 1
*create expneed 1
*create totalexp 0
*create ammount 0
*create sp 0

readlevel.txt

*comment here is the leveling code
*label readagain
*if (exp >= expneed)
	*if ((level > 0) and (level < 8))
		*set exprange 1
		*gosub_scene readexp
		*gosub readagain
		*return
	*comment level 10-19
	*if ((level >= 8) and (level < 18))
		*set exprange 2
		*gosub_scene readexp
		*gosub readagain
		*return
	*comment  level 20-29
	*if ((level >= 18) and (level < 28))
		*set exprange 5
		*gosub_scene readexp
		*gosub readagain
		*return

readexp.txt

*comment here is to read if level up
*if (exp >= expneed)
	*set exp -expneed
	*gosub_scene pluslevel
	*return
*else
	*return

pluslevel.txt
*comment here is the +1 level code
*set expneed +exprange
*set level +1
*set ammount +5
*set sp +5
*return

Pros: Easy to use leveling system, you can level up multiple times if you have the amount of exp needed
Cons: Takes up too much time if you get a massive amount of exp (I happen to get some lag), and the amount of calls is limited (maybe around 180+)

I’m using a lot of *gosub_scene since they are the most efficient way to do things like this (from what I know, for now)

The sub_scene amount will depend on your repetitive command.

If you don’t want to have a lot of .txt, you can write all of them in one sub_scene, give them *label readhere, and you’re good to go.

May this helps anyone in need of a leveling system.

4 Likes

Make your experience range a formula based on level and you can simplify this enormously. Let’s say XP is 5 times level, e.g. if you’re level 2, you need 10 XP to get to level 3.

After every fight:

*set exp +10
*gosub_scene level_up
level_up.txt

*label level_up

*if (exp >= expneed)
  *set level +1
  *set expneed (level)
  *set expneed *5
  
  You level up to level ${level}!
  
  *goto level_up

*return

The only flaw with this is that you only gain one level at a time. If you gain enough XP to go up two levels at once, you’ll need to wait until you get more XP before you level up a second time. Someone else can come in and figure that one out for me if they’d like. The strength of the code above is that it is simple.

Oh I figured it out! Amended.

5 Likes

Thanks!

And yes, this is a simplier method on the exp range, but someone might want to get the experience range on a calculated base exprange +1 each level when you’re level 1-9, and when you’re level 10-19 you want the exprange +2, and when level 20-29 the exprange +5, and so on.

The code I give is that you can specific on what level the ammount of exprange should be. Maybe it’s alot complicated but that’s it, I can’t seem to find another simplier method than the one I wrote.

And for anyone who might have simplier method than this please help and thanks.

But if you want the expneed just 2 times more or less than the current player’s level, then your code work just fine

Are there any hosted games related with a levelling system?or wip even?

1 Like

I know it’s kind of late, but welcome to the community! And your welcome.


I haven’t encountered one from my research and all of the CoS games I’ve played, besides the demo I’m currently working on. But I haven’t played all of the Choice of Games, Hosted Games, Hearts Choice, and WIP out there, so there might be one or two games that use a leveling system that I don’t know.


Sorry for the late reply tho. I’m checking some of the replies that I haven’t reply yet.

2 Likes

One time I was just playing around with coding, and ended up with this…

*label leveling_up

*label level_1

*temp lvl "0"

*set lvl +1

*if (level="1")
  *if (exp_have >9)
    *set level +1
    *set exp_have -10
    *goto if

*label level_2

*set lvl +1

*if (level="2")
  *if (exp_have >19)
    *set level +1
    *set exp_have -20
    *goto if

*label level_3

*set lvl +1

*if (level="3")
  *if (exp_have >39)
    *set level +1
    *set exp_have -40
    *goto if

*label level_4

*set lvl +1

*if (level="4")
  *if (exp_have >69)
    *set level +1
    *set exp_have -70
    *goto if

*label level_5

*set lvl +1

*if (level="5")
  *if (exp_have >119)
    *set level +1
    *set exp_have -120
    *goto if

*label level_6

*set lvl +1

*if (level="6")
  *if (exp_have >199)
    *set level +1
    *set exp_have -200
    *goto if

*label level_7

*set lvl +1

*if (level="7")
  *if (exp_have >349)
    *set level +1
    *set exp_have -350
    *goto if

*label level_8

*set lvl +1

*if (level="8")
  *if (exp_have >549)
    *set level +1
    *set exp_have -550
    *goto if

*label level_9

*set lvl +1

*if (level="9")
  *if (exp_have >799)
    *set level +1
    *set exp_have -800
    *goto if

*label level_10

*set lvl +1

*if (level="10")
  *if (exp_have >1099)
    *set level +1
    *set exp_have -1100
    *goto if

*label level_11

*set lvl +1

*if (level="11")
  *if (exp_have >1499)
    *set level +1
    *set exp_have -1500
    *goto if

*label level_12

*set lvl +1

*if (level="12")
  *if (exp_have >1999)
    *set level +1
    *set exp_have -2000
    *goto if

*label level_13

*set lvl +1

*if (level="13")
  *if (exp_have >2799)
    *set level +1
    *set exp_have -2800
    *goto if

*label level_14

*set lvl +1

*if (level="14")
  *if (exp_have >3799)
    *set level +1
    *set exp_have -3800
    *goto if

*label level_15

*set lvl +1

*if (level="15")
  *if (exp_have >4899)
    *set level +1
    *set exp_have -4900
    *goto if

*label level_16

*set lvl +1

*if (level="16")
  *if (exp_have >6299)
    *set level +1
    *set exp_have -6300
    *goto if

*label level_17

*set lvl +1

*if (level="17")
  *if (exp_have >7999)
    *set level +1
    *set exp_have -8000
    *goto if

*label level_18

*set lvl +1

*if (level="18")
  *if (exp_have >8999)
    *set level +1
    *set exp_have -9000
    *goto if

*label level_19

*set lvl +1

*if (level="19")
  *if (exp_have >9999)
    *set level +1
    *set exp_have -10000
    *goto if




*label if
  
*if (lvl="1")
  *goto level_2

*if (lvl="2")
  *goto level_3

*if (lvl="3")
  *goto level_4

*if (lvl="4")
  *goto level_5

*if (lvl="5")
  *goto level_6

*if (lvl="6")
  *goto level_7

*if (lvl="7")
  *goto level_8

*if (lvl="8")
  *goto level_9

*if (lvl="9")
  *goto level_10

*if (lvl="10")
  *goto level_11

*if (lvl="11")
  *goto level_12

*if (lvl="12")
  *goto level_13

*if (lvl="13")
  *goto level_14

*if (lvl="14")
  *goto level_15

*if (lvl="15")
  *goto level_16

*if (lvl="16")
  *goto level_17

*if (lvl="17")
  *goto level_18

*if (lvl="18")
  *goto level_19

*label next
*if (stats="on")
  [b]Level: ✰ ${level} ✰

*if (level="1")
  [b]Exp: ${exp_have}/10

Screen Shot 2021-08-30 at 5.02.14 PM

Screen Shot 2021-08-30 at 5.06.38 PM

Maybe it’s too complicated, but it works great.

1 Like

To have an easier formular you could"outsource" the range with a different variable. Ah I mixed up the Modulo part forget that, I will search the right thing tomorrow, my bad

1 Like

That’s another way to have a leveling system, but as you say, it’s too long to code the whole thing, especially if you want the level not to be capped (like max 100+ levels).


Can you please explain this modulus? I don’t really get what you’re saying, sorry I’m dumb :rofl:

Okay, but I really don’t know this modulus operator either, I’m not majoring in programming so I don’t know. I search it up and it’s like the program leaves a remainder after a division(?)

2 Likes

No that was my fault I mixed up the operators give me some time, I will take a closer look tomorrow

1 Like

Yeah I can understand that, as the Max lvl in my code is only 20

Screen Shot 2021-08-30 at 5.51.04 PM

1 Like