Right way to set Max-XPs in Level-System
Posted: 13 Sep 2018, 14:08
Hello,
How are you? Hope you are fine . In this topic we will learn how we can set right cvars for our levels system.
OK, first you may notice that in our levels system you can't control the xp value needed for next level. So first term you should get is when i say:
Max-XP for level 1
In cvars, you need to define the max-xp for level 1:
First there is equation, how next level needed xp calculated:
Also i'll explain how to set some more increment factors like:
Let's see the software that will help in this:
How to use it?
Now you can edit code in levels system to add more factors for ranges (You will edit
How are you? Hope you are fine . In this topic we will learn how we can set right cvars for our levels system.
OK, first you may notice that in our levels system you can't control the xp value needed for next level. So first term you should get is when i say:
Max-XP for level 1
- Means how much xp i must get so i go to level 1? PlayerXP/NextLevelNeededXP
In cvars, you need to define the max-xp for level 1:
ze_max_xp_first_level 100
ze_maxlevels_increment 2
First there is equation, how next level needed xp calculated:
- nextLevelNeededXP = previousLevelNeededXP * IncrementFactor
- One player have 1200 xp and xp needed for next level is 1800. 1200/1800 So if he got the 1800 xp he will go to new level. 1800/UnknownValue and this unknown value is = 1800 * IncrementFactor
That's how it's calculated.
Also i'll explain how to set some more increment factors like:
- From level 0 to level 20 - Increment factor 1.4
From level 21 to level 40 - Increment factor 1.1
- #define MAX_LEVEL 50
- #define MAX_XP 500000
Let's see the software that will help in this:
How to use it?
- Write the starting level number.
- Write Max-XP needed so player can reach this starting level.
- Write the end level number.
- Write the increment factor.
- Calculate all max-xp - Will show you list of all levels and max xp needed to reach them.
- Calculate end level max-xp - will only calculate the max xp needed to reach the end level.
- MAX-XP For Levels:
- 2 - 110
- 3 - 121
- 4 - 133
Now you can edit code in levels system to add more factors for ranges (You will edit
public Check_User_Level(id)
):
- public Check_User_Level(id)
- {
- if(!is_user_connected(id))
- return
- if(g_iXP[id] >= g_iMaxXP[id])
- {
- if (get_pcvar_num(g_pCvarStartFromZero) == 1)
- {
- g_iXP[id] = 0
- }
- new szName[32]
- g_iLevel[id] ++
- if (g_iLevel[id] >= 0 && g_iLevel[id] < 20)
- {
- g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * 1.4)
- }
- else if (g_iLevel[id] >= 20 && g_iLevel[id] < 40)
- {
- g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * 1.2)
- }
- else if (g_iLevel[id] >= 40 && g_iLevel[id] <= 50) // 50 is our max
- {
- g_iMaxXP[id] = floatround(float(g_iMaxXP[id]) * 1.08)
- }
- get_user_name(id, szName, charsmax(szName))
- ze_colored_print(0, "!g%s !tNow in Level %i!y!", szName, g_iLevel[id])
- SaveData(id)
- PlaySound(id, LEVELUP)
- if (get_pcvar_num(g_pCvarLevelEffects) != 0)
- {
- // Screen Fade
- message_begin(MSG_ONE, get_user_msgid("ScreenFade"), {0,0,0}, id)
- write_short(4096*2)
- write_short(4096*5)
- write_short(0x0001)
- write_byte(random(256))
- write_byte(random(256))
- write_byte(random(256))
- write_byte(150)
- message_end()
- // Screen Shake
- message_begin(MSG_ONE, get_user_msgid("ScreenShake"), {0,0,0}, id)
- write_short(255<<14)
- write_short(10<<14)
- write_short(255<<14)
- message_end()
- }
- }
- }
public Check_MaxXP(id)
:
- public Check_MaxXP(id)
- {
- new iCurrentMaxXP = g_iMaxXP[id]
- new iMaxXP = get_pcvar_num(g_pCvarMaxXPFirstLevel)
- if (g_iLevel[id] >= 0 && g_iLevel[id] < 20)
- {
- for (new i = 1; i <= g_iLevel[id]; i++)
- {
- iMaxXP = floatround(float(iMaxXP) * 1.4)
- }
- }
- if (g_iLevel[id] >= 20 && g_iLevel[id] < 40)
- {
- for (new i = 1; i < 20; i++)
- {
- iMaxXP = floatround(float(iMaxXP) * 1.4)
- }
- for (new i = 20; i <= g_iLevel[id]; i++)
- {
- iMaxXP = floatround(float(iMaxXP) * 1.2)
- }
- }
- if (g_iLevel[id] >= 40 && g_iLevel[id] <= 50)
- {
- for (new i = 1; i < 20; i++)
- {
- iMaxXP = floatround(float(iMaxXP) * 1.4)
- }
- for (new i = 20; i < g_iLevel[id]; i++)
- {
- iMaxXP = floatround(float(iMaxXP) * 1.2)
- }
- for (new i = 40; i <= g_iLevel[id]; i++)
- {
- iMaxXP = floatround(float(iMaxXP) * 1.08)
- }
- }
- if (iCurrentMaxXP != iMaxXP)
- {
- g_iMaxXP[id] = iMaxXP
- }
- }