Any ideas on why the leveling system not working?

Hello everyone, this is my third post
As the title says, I’m currently stuck with the leveling code

I’m creating a level system in excel like this

Level     Exp Needed       Exp Range     Total Exp
1             0                0             0
2             1                1             1
3             2                1             3
4             3                1             6
5             4                1             10

I’m making 200 level with exp range within each level
But as I’m writing the code, it just doesn’t connect (I’m still learning here, sorry :sob:)

I tried 2 types
the first is looping with not leveling up and the other does not update the exp needed

My code looks like this:
1st code:

startup.txt

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

readexp.txt
*comment here is the second choice of leveling code
*set totalexp +exp
*if ((level > 0) and (level < 10))
	*set exprange 1
	*gosub readexp
	*return
*if ((level > 10) and (level < 20))
	*set exprange 2
	*gosub readexp

*label readexp
*set expneed (exp + exprange)
*if (exp >= expneed)
	*set exp -expneed
	*gosub pluslevel
	*return
*else
	*return

*comment here is the +1 level code
*label pluslevel
*set level +1
*set ammount +5
*set sp +5
*return

The first code just looping in plus the exp but not leveling up, so if the exp +1 the expneeded becomes 2 and if exp +1 again (makes the exp 2) then the expneeded also +1 which becomes 3 and so the level does not increase

2nd code:

startup.txt

*create level 1
*create exp 0
*create exprange 1
*create c_expneed 0
*create n_expneed 0
*create totalexp 0
*create ammount 0
*create sp 0

readexp.txt
*comment here is the second choice of leveling code
*set totalexp +exp
*if ((level > 0) and (level < 10))
	*set exprange 1
	*gosub readexp
	*return
*if ((level > 10) and (level < 20))
	*set exprange 2
	*gosub readexp

*label readexp
*set n_expneed (c_expneed + exprange)
*if (exp >= n_expneed)
	*set exp -n_expneed
	*gosub pluslevel
	*return
*else
	*return

*comment here is the +1 level code
*label pluslevel
*set level +1
*set ammount +5
*set sp +5
*return

For the second, the level does increase but the exp needed stays in 1 and not increasing further

Please help me :sob: and THANKS in advance :pray:

*create exp 0
*create level 1

*label test
You have ${exp} exp and you are currently Level ${level}.
*choice
    #Swing a sword.
        *set exp +25
        *gosub exp_check
        *goto test
    #Fire a bow.
        *set exp +25
        *gosub exp_check
        *goto test

*label exp_check
*if exp >99
    *set level +1
    *set exp 0
    *return
*else
    *return

This is just a simple code but should work for a level up system.

1 Like

I did put something like that before

*comment here is the second choice of leveling code
*if ((level > 0) and (level <= 5))
	*if exp >= 5
		*set exp -5
		*gosub pluslevel
		*return
	*else
		*return
*if ((level > 5) and (level <= 10))
	*if exp >= 10
		*set exp -10
		*gosub pluslevel
		*return
	*else
		*return
*if ((level > 10) and (level <= 20))
	*if exp >= 20
		*set exp -20
		*gosub pluslevel
		*return
	*else
		*return
*comment here is the +1 level code
*label pluslevel
*set level +1
*set ammount +5
*set sp +5
*return

But the thing is, the exp requirement is stuck within the number and can’t increases if you didn’t write the number different on what level.

The thing I want is that when you level up, the exp needed to go to the next level also increases

And thanks for the reply :pray:

*create exp 0
*create level 1
*create exp_current 50
*create exp_range 50

*label test
You have ${exp} exp and you are currently Level ${level}.
*choice
    #Swing a sword.
        *set exp +25
        *gosub exp_check
        *goto test
    #Fire a bow.
        *set exp +25
        *gosub exp_check
        *goto test

*label exp_check
*if (exp = (exp_current + exp_range))
    *set level +1
    *set exp 0
    *set exp_range +50
    *return
*else
    *return

Something like this?

1 Like

It’s close and THANKS

By you writing that scripts gives me some insight, and I managed to solved it.

Here is the final code

startup.txt

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

*label time_loop
choose
*choice
	#+1
		*set exp +1
		*set totalexp +1
		*gosub_scene readexp
		*goto time_loop
	#+4
		*set exp +4
		*set totalexp +4
		*gosub_scene readexp
		*goto time_loop
	#+9
		*set exp +9
		*set totalexp +9
		*gosub_scene readexp
		*goto time_loop

readexp.txt

*comment here is the second choice of leveling code
*if ((level > 0) and (level < 10))
	*set exprange 1
	*gosub readexp
	*return
*if ((level > 10) and (level < 20))
	*set exprange 2
	*gosub readexp
	*return

*label readexp
*if (exp >= expneed)
	*set exp -expneed
	*gosub pluslevel
	*return
*else
	*return

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

This one increase the range when you level up, and I just realized that you just need to adjust *set expneed in the *label readexp

Thanks for the insight :pray:

And for anyone who wants exp range increasing on each level with specific ammount you can copy and paste this code :laughing:

See you guys on my next post :wave:

2 Likes

This topic was automatically closed 24 hours after the last reply. If you want to reopen your WiP, contact the moderators.