- Joined
- Sep 10, 2022
- Messages
- 101
Hello everyone, I am back after a long time to ask for some help. I am trying to implement a Ranking Unit System. There is a game you may know called "Battle for Wesnoth" where units on the field can gain exp for kills and they advance to the next rank after reaching some value.
------------------>
I decided to implement something like that but a bit simpler, so what I have (explanations are below all tables):
Table 1 - EXP gain within range (Xp1, Xp2) by killing a unit of determined level
Table 2 - Unit Ranking System
Table 3 - Theoretical Example of my Hashtable
Basically, Table 1 shows how many EXP points would gain a unit if it killed a unit of a certain LvL. For example, if Footman kills a default forest Troll it will gain from 10 to 19 EXP points.
Table 2 is about how many EXP points a certain LvL needs to advance to the next rank. For instance, again, Footman is lvl 2 unit, so he needs 40 points to advance to Captain, while Grunt needs 60 XP because he is a LvL 3 unit.
Table 3 represents my understanding and approach of how I will save a unit and its exp...
As usual, I came up with something but messed up with the implementation, so I pin my custom map here where I tried to implement the mentioned system. Even those who have the same level of practice with triggers as I do can understand that something went wrong, but to be honest it’s still difficult for me to understand whether I messed up with the code or the approach, because the tools of debugging other than outputting variable values are absent...
Therefore, I ask you to take a look and help solve the problem that has arisen with this system. (Ignore anything that doesn't relate to the topic when looking at the map)
I decided to implement something like that but a bit simpler, so what I have (explanations are below all tables):
Table 1 - EXP gain within range (Xp1, Xp2) by killing a unit of determined level
LvL
|
Xp 1
|
Xp 2
|
1
|
1
|
9
|
2
|
10
|
19
|
3
|
20
|
29
|
4
|
30
|
39
|
5
|
40
|
49
|
6+
|
50
|
60
|
Table 2 - Unit Ranking System
From Rank 1 ->
|
-> To Rank 2
|
Unit ingame LvL
|
Required EXP
|
LvL 1
|
20
|
LvL 2
|
40
|
LvL 3
|
60
|
LvL 4
|
80
|
LvL 5+
|
100
|
Table 3 - Theoretical Example of my Hashtable
Saved Value
|
Parent Key
|
Child Key
|
Saved Value
|
Parent Key
|
Child Key
|
Unit
|
unit_index
|
0
|
Unit EXP
|
unit_index
|
1
|
Footman
|
0
|
0
|
20
|
0
|
1
|
Grunt
|
1
|
0
|
12
|
1
|
1
|
Footman
|
2
|
0
|
34
|
2
|
1
|
Basically, Table 1 shows how many EXP points would gain a unit if it killed a unit of a certain LvL. For example, if Footman kills a default forest Troll it will gain from 10 to 19 EXP points.
Table 2 is about how many EXP points a certain LvL needs to advance to the next rank. For instance, again, Footman is lvl 2 unit, so he needs 40 points to advance to Captain, while Grunt needs 60 XP because he is a LvL 3 unit.
Table 3 represents my understanding and approach of how I will save a unit and its exp...
As usual, I came up with something but messed up with the implementation, so I pin my custom map here where I tried to implement the mentioned system. Even those who have the same level of practice with triggers as I do can understand that something went wrong, but to be honest it’s still difficult for me to understand whether I messed up with the code or the approach, because the tools of debugging other than outputting variable values are absent...
Therefore, I ask you to take a look and help solve the problem that has arisen with this system. (Ignore anything that doesn't relate to the topic when looking at the map)