Leveling System

GamerOver9000
18 Dec 2018, 23:16

I'm creating a game where in order for my in game character to progress I have to do real life tasks. For example, I write down my to-do list for each day and assign points to each task. When I play the game I can add those points to my character's strength (or whatever skill).

Max Points Needed For Each Level

Level 0 = 0 points
Level 1 = 5 points
Level 2 = 10 points

Basically, the points needed for each level doubles.

I've already created a player.strength attribute. I was thinking of also creating a player.strength_points attribute to keep track of the total points dedicated to the skill and just using if statements to add a level to player.strength when it contains the necessary amount of points.

The only way I can think of doing is this is manually writing if statements for each level. Is there a way for to make it where my character can level up continuously without doing the following for each level?

if (player.strength_points = 5) {
set (player, player.strength, 1)
}
else if (player.strength_points = 10) {
set (player, player.strength, 2)
}


hegemonkhan
19 Dec 2018, 06:05

here's my own leveling function, which I think you can figure out your own needs from it, hopefully:

<function name="leveling_function">
  <![CDATA[
    exp_req_for_lvlup_integer_variable = player.level * 100 + 100
    if (player.experience >= exp_req_for_lvlup_integer_variable) {
      player.experience = player.experience - exp_req_for_lvlup_integer_variable
      player.level = player.level + 1
      leveling_function
    }
  ]]>
</function>

my leveling function's mechanics:

level 0 to level 1: +100 experience needed (100 total experience needed)
level 1 to level 2: +200 experience needed (300 total experience needed)
level 2 to level 3: +300 experience needed (600 total experience needed)
level 3 to level 4: +400 experience needed (1,000 total experience needed)
level 4 to level 5: +500 experience needed (1,500 total experience needed)
level 5 to level 6: +600 experience needed (2,100 total experience needed)
etc etc etc

Arithmetic Operation (simple) examples:

Addition Operator: +

player.strength = player.strength + 10

Subtraction Operator: -

player.strength = player.strength - 9

Multiplication Operator: *

player.strength = player.strength * 3

Division Operator: /

player.strength = player.strength / 2

Modulus (Division, but it finds/gets/returns the REMAINDER) Operator: %

Modulus (remainder from division) enables two really cool implementations:

  1. cyclic
clock.second = GetRandomInt (0,300)
clock.clock_second = clock.second % 60
//
// %60: 0 to 59
//
// clock.second = 0
// clock.clock_second = 0
//
// clock.second = 1
// clock.clock_second = 1
//
// clock.second = 30
// clock.clock_second = 30
//
// clock.second = 59
// clock.clock_second = 59
//
// clock.second = 60
// clock.clock_second = 0
//
// clock.second = 61
// clock.clock_second = 1
//
// clock.second = 90
// clock.clock_second = 30
//
// clock.second = 119
// clock.clock_second = 59
//
// clock.second = 120
// clock.clock_second = 0
//
// clock.second = 121
// clock.clock_second = 1
//
// etc etc etc

clock.hour = GetRandomInt (0,48)
clock.clock_military_hour = clock.hour % 24
clock.clock_civilian_hour = clock.hour % 12
// %24: 0 to 23
// %12: 0 to 11
  1. factors/divisibility of a number (which includes whether a number is even or odd):
number_integer_variable = GetRandomInt (0,100)
if (number_integer_variable % 2 = 1) {
  msg ("The number (" + number_integer_variable + ") is odd")
} else if (number_integer_variable % 2 = 0) {
  msg ("The number (" + number_integer_variable + ") is even")
  msg ("The number (" + number_integer_variable + ") is divisible by 2")
} else if (number_integer_variable % 3 = 0) {
  msg ("The number (" + number_integer_variable + ") is divisible by 3")
} else if (number_integer_variable % 4 = 0) {
  msg ("The number (" + number_integer_variable + ") is divisible by 4")
} else if (number_integer_variable % 5 = 0) {
  msg ("The number (" + number_integer_variable + ") is divisible by 5")
} else if (number_integer_variable % 6 = 0) {
  msg ("The number (" + number_integer_variable + ") is divisible by 6")
} else if (number_integer_variable % 7 = 0) {
  msg ("The number (" + number_integer_variable + ") is divisible by 7")
}
// etc etc etc

jmnevil54
19 Dec 2018, 06:28

This is the function I use to level up.

It's called love. (after Undertale)

if (player.exp >= player.level * 410 + 100) {
  player.level = player.level + 1
  player.reallevel = player.reallevel + 1
  msg ("You are level " + player.reallevel + ".")
  player.defence = player.defence + 1
  player.attack = player.attack + 1
  player.damage = player.damage + 1
  player.hitpoints = player.hitpoints + 5
  player.max = player.max + 5
}

I keep two attributes for the level. player.level is used for the function, player.reallevel is used for the way the number appears/string dictionary. That way, the player starts off at level 1, instead of level 0.

player attributes

player.alias = "you"
player.hitpoints = 110
player.max = 110
player.damage = 3
player.attack = 1
player.defence = 0
player.armour = 0
player.exp = 0
player.level = 0
player.attackers = NewObjectList()
player.ammo = 50
player.potion = 2
player.hyper_potion = 0
player.gold = 0
player.reallevel = 1