Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | FatherCCP |
Making a stat system and i wanna make it so it add a certain points to all stats and not randomly pick one as all other tutorials show it.
example 1-9 add 10 points to one stat and 5 to the others and increase it slightly 10 -19 and so on.
Sorry for the bad grammar!
And this is how the code looks like.
extends Node
# Character stats
export (int) var max_hp = 10
export (int) var max_mana = 10
export (int) var strength = 1
export (int) var dexterity = 1
export (int) var agility = 1
export (int) var magic = 1
export (int) var defence = 1
export (int) var speed = 1
export (int) var wisdom = 1
# Leveling system
export (int) var level = 1
var experience = 0
var experience_total = 0
var experience_required = get_required_experience(level + 1)
func get_required_experience(level):
return round(pow(level, 1.6) + level * 4)
func gain_experience(amount):
experience_total += amount
experience += amount
while experience >= experience_required:
experience -= experience_required
level_up()
func level_up():
level += 1
experience_required = get_required_experience(level + 1)
Edit: Sorry for the not so good explaining
level 2 add 10 to all var exept maxhp and maxmana
add 5 maxhp and maxmana
level 3 same as level 2 all the way to level 9
and from level 10 add 15 to all var exept maxhp and maxmana
and repete that type of pattern all the way until max level that is not decided yet
hops this explains it better
Not sure what are you asking. If you want to add predetermined values to specific stats, just do it. Like so:
magic += 2
speed +=1
max_hp += 14
etc...
Since I guess this isnt what you are asking for, try to be more specific with what you want to achieve (since I cant understand the example you gave, 1-9 what?, do you want the stat that gets 10 to be picked at random and give 5 to all others? even the max_hp ones? etc…)
Pomelo | 2022-07-25 19:15
Sorry for the not so good explaining
level 2 add 10 to all var exept max_hp and max_mana
add 5 max_hp and max_mana
level 3 same as level 2 all the way to level 9
and from level 10 add 15 to all var exept max_hp and max_mana
and repete that type of pattern all the way until max level that is not decided yet
hops this explains it better
FatherCCP | 2022-07-25 19:28