Kingdom Ablaze
Sponsor
so i am making a skills system like that of oblivion. its pretty much done now. but i noticed if you add enough exp to go up more then one level it messes up my math. it says stuff like -35 to go up a level. so i was hoping some one would help me figure out how to get it to check if the player will go up more then one level. here is what i am using atm.(i retyped what i remember, might not be exact code, but close enough i think. dont know how much you need to know.)
need to know info:
$data_skill[skill].total is total exp in skill
$data_skill[skill].current is the current exp
$data_skill[skill].next is the amount of exp needed(current) to go up a level
edit: think i could make an array containing all of the exp(total) required to go up a level then just have it check which two array elements the current $data_skill[skill].total is between?
like:
exp[1] = 5
exp[2] = 10
exp[3] = 15
exp[4] = 20
exp[5] = 25
im not sure how the check would look though...
need to know info:
$data_skill[skill].total is total exp in skill
$data_skill[skill].current is the current exp
$data_skill[skill].next is the amount of exp needed(current) to go up a level
Code:
def self.add_exp(skill, num)
$data_skill[skill].total = $data_skill[skill].total + num
$data_skill[skill].current = $data_skill[skill].current + num
if $data_skill[skill].current >= $data_skill[skill].next
$data_skill[skill].level = $data_skill[skill].level + 1
change = $data_skill[skill].next - $data_skill[skill].current
if change < 0
change = change * -1
$data_skill[skill].current = change
elsif
$data_skill[skill].current = 0
end
end
if $data_skill[skill].level <= 24
$data_skill[skill].next =$data_skill[skill].next +5
end
if $data_skill[skill].level > 24 && $data_skill[skill].level < 50
$data_skill[skill].next =$data_skill[skill].next +10
end
if $data_skill[skill].level > 49 && $data_skill[skill].level < 74
$data_skill[skill].next =$data_skill[skill].next +15
end
if $data_skill[skill].level > 74
$data_skill[skill].next =$data_skill[skill].next +20
end
end
edit: think i could make an array containing all of the exp(total) required to go up a level then just have it check which two array elements the current $data_skill[skill].total is between?
like:
exp[1] = 5
exp[2] = 10
exp[3] = 15
exp[4] = 20
exp[5] = 25
im not sure how the check would look though...